src/pgp_gpg.c
branchgpgme_passphrase_cb
changeset 1940 285d5cb86dfa
parent 1938 97fcdff36aa7
     1.1 --- a/src/pgp_gpg.c	Mon Jul 24 15:29:32 2017 +0200
     1.2 +++ b/src/pgp_gpg.c	Mon Jul 24 09:56:31 2017 -0400
     1.3 @@ -107,7 +107,7 @@
     1.4      printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n");
     1.5  
     1.6  	gpgme_error_t error = GPG_ERR_NO_ERROR; 
     1.7 -	//char *secret = "blah";
     1.8 +	char *secret = "passphrase";
     1.9    
    1.10  	// to cancel :  
    1.11   	// return gpg_error(GPG_ERR_CANCELED);
    1.12 @@ -115,21 +115,21 @@
    1.13  	// TODO : use hook to retrieve client session
    1.14  	// TODO : call adapter's client passphrase callback
    1.15  
    1.16 -    // size_t len = strlen(secret);
    1.17 -    // size_t cursor = 0;
    1.18 -    // do {
    1.19 -	// 	ssize_t wres = gpg.gpgme_io_write(fd, secret + cursor, len - cursor);
    1.20 -	// 	if (wres < 0) {
    1.21 -	// 		error = gpg.gpgme_error_from_errno(errno);
    1.22 -	// 		goto exit_free;
    1.23 -	// 		break;
    1.24 -	// 	}
    1.25 -	// 	cursor += wres;
    1.26 -    // } while ( cursor < len );
    1.27 +        size_t len = strlen(secret);
    1.28 +        size_t cursor = 0;
    1.29 +        do {
    1.30 +        	ssize_t wres = gpg.gpgme_io_write(fd, secret + cursor, len - cursor);
    1.31 +        	if (wres < 0) {
    1.32 +        		error = gpg.gpgme_error_from_errno(errno);
    1.33 +        		goto exit_free;
    1.34 +        		break;
    1.35 +        	}
    1.36 +        	cursor += wres;
    1.37 +        } while ( cursor < len );
    1.38  
    1.39  	gpg.gpgme_io_write( fd, "\n", 1 );
    1.40  
    1.41 -//exit_free:
    1.42 +exit_free:
    1.43  	//free(secret);
    1.44  	return error;
    1.45  }