From: Karl-Heinz Zimmer Date: Wed, 26 Jun 2002 00:05:30 +0000 (+0000) Subject: Oh pazzo mio! I forgot to *use* the nice dn string actually. X-Git-Tag: gpgme-1.2.0@1385~923 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b9db0fd3026a0b6a25fd70fc88b9646ff20b5883;p=gpgme.git Oh pazzo mio! I forgot to *use* the nice dn string actually. --- diff --git a/trunk/gpgmeplug/gpgmeplug.c b/trunk/gpgmeplug/gpgmeplug.c index 91c6653..a4c8b50 100644 --- a/trunk/gpgmeplug/gpgmeplug.c +++ b/trunk/gpgmeplug/gpgmeplug.c @@ -2389,11 +2389,15 @@ importCertificate( const char* fingerprint ) /* Find all certificate for a given addressee and return them in a '\1' separated list. - NOTE: The certificate parameter must point to an allready allocated - block of memory which is large enough to hold the complete list. + NOTE: The certificate parameter must point to a not-yet allocated + char*. The function will allocate the memory needed and + return the size in newSize. If secretOnly is true, only secret keys are returned. */ -bool findCertificates( const char* addressee, char** certificates, bool secretOnly ) +bool findCertificates( const char* addressee, + char** certificates, + /*int* newSize,*/ + bool secretOnly ) { GpgmeCtx ctx; GpgmeError err; @@ -2403,12 +2407,41 @@ bool findCertificates( const char* addressee, char** certificates, bool secretOn char* dn; struct DnPair* a; int nFound = 0; - +/* + if( ! newSize ){ + fprintf( stderr, "findCertificates called without valid newSize pointer\n" ); + return false; + } +*/ strcpy( *certificates, "" ); gpgme_new (&ctx); gpgme_set_protocol (ctx, GPGMEPLUG_PROTOCOL); - +/* + (*newSize) = 0; + err = gpgme_op_keylist_start(ctx, addressee, secretOnly ? 1 : 0); + while( GPGME_No_Error == err ) { + err = gpgme_op_keylist_next(ctx, &rKey); + if( GPGME_No_Error == err ) { + s = gpgme_key_get_string_attr (rKey, GPGME_ATTR_USERID, NULL, 0); + if( s ) { + s2 = gpgme_key_get_string_attr (rKey, GPGME_ATTR_FPR, NULL, 0); + if( s2 ) { + if( nFound ) + ++(*newSize); + (*newSize) += strlen( s ); + a = parse_dn( dn ); + dn = reorder_dn( a ); + (*newSize) += strlen( dn ); + safe_free( (void **)&dn ); + ++nFound; + } + } + } + } +*/ + gpgme_op_keylist_end( ctx ); + nFound = 0; err = gpgme_op_keylist_start(ctx, addressee, secretOnly ? 1 : 0); while( GPGME_No_Error == err ) { err = gpgme_op_keylist_next(ctx, &rKey); @@ -2424,7 +2457,7 @@ bool findCertificates( const char* addressee, char** certificates, bool secretOn a = parse_dn( dn ); dn = reorder_dn( a ); /*fprintf( stderr, "\nDN after reordering: \"%s\"\n", dn );*/ - strcat( *certificates, s ); + strcat( *certificates, dn ); strcat( *certificates, " (" ); strcat( *certificates, s2 ); strcat( *certificates, ")" );