mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-23 10:29:58 +01:00
Forgot to sync the CVS. Check in the code again.
This commit is contained in:
parent
5ee4951f28
commit
b79275a66f
@ -1,3 +1,18 @@
|
|||||||
|
2003-04-13 Timo Schulz <twoaday@freakmail.de>
|
||||||
|
|
||||||
|
* mainproc.c (mainproc_open_output): New. Support for
|
||||||
|
--output when GPG is in the list mode.
|
||||||
|
(mainproc_get_output): New.
|
||||||
|
|
||||||
|
* keylist.c (print_fingerprint): If the mode is zero and
|
||||||
|
we are in the colon mode, we try to get the file handle
|
||||||
|
via mainproc_get_output().
|
||||||
|
|
||||||
|
* g10.c (main): Use the new code to support --output in
|
||||||
|
the list mode.
|
||||||
|
|
||||||
|
* main.h: Add prototypes.
|
||||||
|
|
||||||
2003-04-10 Werner Koch <wk@gnupg.org>
|
2003-04-10 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* passphrase.c (read_passphrase_from_fd): Do a dummy read if the
|
* passphrase.c (read_passphrase_from_fd): Do a dummy read if the
|
||||||
|
@ -2545,10 +2545,13 @@ main( int argc, char **argv )
|
|||||||
set_packet_list_mode(1);
|
set_packet_list_mode(1);
|
||||||
opt.list_packets=1;
|
opt.list_packets=1;
|
||||||
}
|
}
|
||||||
|
if( opt.outfile )
|
||||||
|
mainproc_open_output( opt.outfile );
|
||||||
rc = proc_packets(NULL, a );
|
rc = proc_packets(NULL, a );
|
||||||
if( rc )
|
if( rc )
|
||||||
log_error("processing message failed: %s\n", g10_errstr(rc) );
|
log_error("processing message failed: %s\n", g10_errstr(rc) );
|
||||||
iobuf_close(a);
|
iobuf_close(a);
|
||||||
|
mainproc_open_output( NULL );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1050,6 +1050,7 @@ print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode )
|
|||||||
fingerprint_from_pk (pk, array, &n);
|
fingerprint_from_pk (pk, array, &n);
|
||||||
p = array;
|
p = array;
|
||||||
if (opt.with_colons && !mode) {
|
if (opt.with_colons && !mode) {
|
||||||
|
fp = mainproc_get_output( );
|
||||||
fprintf (fp, "fpr:::::::::");
|
fprintf (fp, "fpr:::::::::");
|
||||||
for (i=0; i < n ; i++, p++ )
|
for (i=0; i < n ; i++, p++ )
|
||||||
fprintf (fp, "%02X", *p );
|
fprintf (fp, "%02X", *p );
|
||||||
|
124
g10/mainproc.c
124
g10/mainproc.c
@ -79,12 +79,38 @@ struct mainproc_context {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static FILE *list_fp = NULL;
|
||||||
|
|
||||||
static int do_proc_packets( CTX c, IOBUF a );
|
static int do_proc_packets( CTX c, IOBUF a );
|
||||||
|
|
||||||
static void list_node( CTX c, KBNODE node );
|
static void list_node( CTX c, KBNODE node );
|
||||||
static void proc_tree( CTX c, KBNODE node );
|
static void proc_tree( CTX c, KBNODE node );
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
mainproc_open_output( const char * file )
|
||||||
|
{
|
||||||
|
if( !file ) {
|
||||||
|
if( list_fp && list_fp != stderr && list_fp != stdout ) {
|
||||||
|
fclose( list_fp );
|
||||||
|
list_fp = stdout;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if( *file != '-' )
|
||||||
|
list_fp = fopen( file, "w" );
|
||||||
|
if( !list_fp )
|
||||||
|
list_fp = stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FILE*
|
||||||
|
mainproc_get_output( void )
|
||||||
|
{
|
||||||
|
return list_fp? list_fp : stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_list( CTX c )
|
release_list( CTX c )
|
||||||
{
|
{
|
||||||
@ -737,22 +763,23 @@ print_userid( PACKET *pkt )
|
|||||||
{
|
{
|
||||||
if (!pkt)
|
if (!pkt)
|
||||||
BUG();
|
BUG();
|
||||||
if( pkt->pkttype != PKT_USER_ID ) {
|
if (pkt->pkttype != PKT_USER_ID)
|
||||||
|
{
|
||||||
printf("ERROR: unexpected packet type %d", pkt->pkttype );
|
printf("ERROR: unexpected packet type %d", pkt->pkttype );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (opt.with_colons)
|
if (opt.with_colons)
|
||||||
{
|
{
|
||||||
if (pkt->pkt.user_id->attrib_data)
|
if (pkt->pkt.user_id->attrib_data)
|
||||||
printf("%u %lu",
|
fprintf (list_fp, "%u %lu",
|
||||||
pkt->pkt.user_id->numattribs,
|
pkt->pkt.user_id->numattribs,
|
||||||
pkt->pkt.user_id->attrib_len);
|
pkt->pkt.user_id->attrib_len);
|
||||||
else
|
else
|
||||||
print_string( stdout, pkt->pkt.user_id->name,
|
print_string (list_fp, pkt->pkt.user_id->name,
|
||||||
pkt->pkt.user_id->len, ':');
|
pkt->pkt.user_id->len, ':');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
print_utf8_string( stdout, pkt->pkt.user_id->name,
|
print_utf8_string (list_fp, pkt->pkt.user_id->name,
|
||||||
pkt->pkt.user_id->len);
|
pkt->pkt.user_id->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,31 +854,31 @@ list_node( CTX c, KBNODE node )
|
|||||||
c->trustletter = opt.fast_list_mode?
|
c->trustletter = opt.fast_list_mode?
|
||||||
0 : get_validity_info( pk, NULL );
|
0 : get_validity_info( pk, NULL );
|
||||||
}
|
}
|
||||||
printf("%s:", mainkey? "pub":"sub" );
|
fprintf( list_fp, "%s:", mainkey? "pub":"sub" );
|
||||||
if( c->trustletter )
|
if( c->trustletter )
|
||||||
putchar( c->trustletter );
|
fputc( c->trustletter, list_fp );
|
||||||
printf(":%u:%d:%08lX%08lX:%s:%s:",
|
fprintf( list_fp, ":%u:%d:%08lX%08lX:%s:%s:",
|
||||||
nbits_from_pk( pk ),
|
nbits_from_pk( pk ),
|
||||||
pk->pubkey_algo,
|
pk->pubkey_algo,
|
||||||
(ulong)keyid[0],(ulong)keyid[1],
|
(ulong)keyid[0],(ulong)keyid[1],
|
||||||
colon_datestr_from_pk( pk ),
|
colon_datestr_from_pk( pk ),
|
||||||
colon_strtime (pk->expiredate) );
|
colon_strtime (pk->expiredate) );
|
||||||
if( c->local_id )
|
if( c->local_id )
|
||||||
printf("%lu", c->local_id );
|
fprintf( list_fp, "%lu", c->local_id );
|
||||||
putchar(':');
|
fputc( ':', list_fp );
|
||||||
if( mainkey && !opt.fast_list_mode )
|
if( mainkey && !opt.fast_list_mode )
|
||||||
putchar( get_ownertrust_info (pk) );
|
fputc( get_ownertrust_info (pk), list_fp );
|
||||||
putchar(':');
|
fputc( ':', list_fp );
|
||||||
if( node->next && node->next->pkt->pkttype == PKT_RING_TRUST) {
|
if( node->next && node->next->pkt->pkttype == PKT_RING_TRUST) {
|
||||||
putchar('\n'); any=1;
|
fputc('\n', list_fp ); any=1;
|
||||||
if( opt.fingerprint )
|
if( opt.fingerprint )
|
||||||
print_fingerprint( pk, NULL, 0 );
|
print_fingerprint( pk, NULL, 0 );
|
||||||
printf("rtv:1:%u:\n",
|
fprintf( list_fp, "rtv:1:%u:\n",
|
||||||
node->next->pkt->pkt.ring_trust->trustval );
|
node->next->pkt->pkt.ring_trust->trustval );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("%s %4u%c/%08lX %s ",
|
fprintf( list_fp, "%s %4u%c/%08lX %s ",
|
||||||
mainkey? "pub":"sub",
|
mainkey? "pub":"sub",
|
||||||
nbits_from_pk( pk ),
|
nbits_from_pk( pk ),
|
||||||
pubkey_letter( pk->pubkey_algo ),
|
pubkey_letter( pk->pubkey_algo ),
|
||||||
@ -864,9 +891,9 @@ list_node( CTX c, KBNODE node )
|
|||||||
if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
||||||
if( !any ) {
|
if( !any ) {
|
||||||
if( node->pkt->pkt.signature->sig_class == 0x20 )
|
if( node->pkt->pkt.signature->sig_class == 0x20 )
|
||||||
puts("[revoked]");
|
fputs("[revoked]", list_fp );
|
||||||
else
|
else
|
||||||
putchar('\n');
|
fputc('\n', list_fp );
|
||||||
any = 1;
|
any = 1;
|
||||||
}
|
}
|
||||||
list_node(c, node );
|
list_node(c, node );
|
||||||
@ -874,27 +901,27 @@ list_node( CTX c, KBNODE node )
|
|||||||
else if( node->pkt->pkttype == PKT_USER_ID ) {
|
else if( node->pkt->pkttype == PKT_USER_ID ) {
|
||||||
if( any ) {
|
if( any ) {
|
||||||
if( opt.with_colons )
|
if( opt.with_colons )
|
||||||
printf("%s:::::::::",
|
fprintf( list_fp, "%s:::::::::",
|
||||||
node->pkt->pkt.user_id->attrib_data?"uat":"uid");
|
node->pkt->pkt.user_id->attrib_data?"uat":"uid");
|
||||||
else
|
else
|
||||||
printf( "uid%*s", 28, "" );
|
fprintf( list_fp, "uid%*s", 28, "" );
|
||||||
}
|
}
|
||||||
print_userid( node->pkt );
|
print_userid( node->pkt );
|
||||||
if( opt.with_colons )
|
if( opt.with_colons )
|
||||||
putchar(':');
|
fputc( ':', list_fp );
|
||||||
putchar('\n');
|
fputc( '\n', list_fp );
|
||||||
if( opt.fingerprint && !any )
|
if( opt.fingerprint && !any )
|
||||||
print_fingerprint( pk, NULL, 0 );
|
print_fingerprint( pk, NULL, 0 );
|
||||||
if( node->next
|
if( node->next
|
||||||
&& node->next->pkt->pkttype == PKT_RING_TRUST ) {
|
&& node->next->pkt->pkttype == PKT_RING_TRUST ) {
|
||||||
printf("rtv:2:%u:\n",
|
fprintf( list_fp, "rtv:2:%u:\n",
|
||||||
node->next->pkt->pkt.ring_trust->trustval );
|
node->next->pkt->pkt.ring_trust->trustval );
|
||||||
}
|
}
|
||||||
any=1;
|
any=1;
|
||||||
}
|
}
|
||||||
else if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
|
else if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
|
||||||
if( !any ) {
|
if( !any ) {
|
||||||
putchar('\n');
|
fputc('\n', list_fp );
|
||||||
any = 1;
|
any = 1;
|
||||||
}
|
}
|
||||||
list_node(c, node );
|
list_node(c, node );
|
||||||
@ -902,11 +929,11 @@ list_node( CTX c, KBNODE node )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( pk->expiredate ) { /* of subkey */
|
else if( pk->expiredate ) { /* of subkey */
|
||||||
printf(_(" [expires: %s]"), expirestr_from_pk( pk ) );
|
fprintf( list_fp, _(" [expires: %s]"), expirestr_from_pk( pk ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !any )
|
if( !any )
|
||||||
putchar('\n');
|
fputc('\n', list_fp );
|
||||||
if( !mainkey && opt.fingerprint > 1 )
|
if( !mainkey && opt.fingerprint > 1 )
|
||||||
print_fingerprint( pk, NULL, 0 );
|
print_fingerprint( pk, NULL, 0 );
|
||||||
}
|
}
|
||||||
@ -917,7 +944,7 @@ list_node( CTX c, KBNODE node )
|
|||||||
if( opt.with_colons ) {
|
if( opt.with_colons ) {
|
||||||
u32 keyid[2];
|
u32 keyid[2];
|
||||||
keyid_from_sk( sk, keyid );
|
keyid_from_sk( sk, keyid );
|
||||||
printf("%s::%u:%d:%08lX%08lX:%s:%s:::",
|
fprintf( list_fp, "%s::%u:%d:%08lX%08lX:%s:%s:::",
|
||||||
mainkey? "sec":"ssb",
|
mainkey? "sec":"ssb",
|
||||||
nbits_from_sk( sk ),
|
nbits_from_sk( sk ),
|
||||||
sk->pubkey_algo,
|
sk->pubkey_algo,
|
||||||
@ -927,7 +954,7 @@ list_node( CTX c, KBNODE node )
|
|||||||
/* fixme: add LID */ );
|
/* fixme: add LID */ );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("%s %4u%c/%08lX %s ",
|
fprintf( list_fp, "%s %4u%c/%08lX %s ",
|
||||||
mainkey? "sec":"ssb",
|
mainkey? "sec":"ssb",
|
||||||
nbits_from_sk( sk ),
|
nbits_from_sk( sk ),
|
||||||
pubkey_letter( sk->pubkey_algo ),
|
pubkey_letter( sk->pubkey_algo ),
|
||||||
@ -939,9 +966,9 @@ list_node( CTX c, KBNODE node )
|
|||||||
if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
||||||
if( !any ) {
|
if( !any ) {
|
||||||
if( node->pkt->pkt.signature->sig_class == 0x20 )
|
if( node->pkt->pkt.signature->sig_class == 0x20 )
|
||||||
puts("[revoked]");
|
fputs("[revoked]", list_fp);
|
||||||
else
|
else
|
||||||
putchar('\n');
|
fputc('\n', list_fp);
|
||||||
any = 1;
|
any = 1;
|
||||||
}
|
}
|
||||||
list_node(c, node );
|
list_node(c, node );
|
||||||
@ -949,22 +976,22 @@ list_node( CTX c, KBNODE node )
|
|||||||
else if( node->pkt->pkttype == PKT_USER_ID ) {
|
else if( node->pkt->pkttype == PKT_USER_ID ) {
|
||||||
if( any ) {
|
if( any ) {
|
||||||
if( opt.with_colons )
|
if( opt.with_colons )
|
||||||
printf("%s:::::::::",
|
fprintf( list_fp, "%s:::::::::",
|
||||||
node->pkt->pkt.user_id->attrib_data?"uat":"uid");
|
node->pkt->pkt.user_id->attrib_data?"uat":"uid");
|
||||||
else
|
else
|
||||||
printf( "uid%*s", 28, "" );
|
fprintf( list_fp, "uid%*s", 28, "" );
|
||||||
}
|
}
|
||||||
print_userid( node->pkt );
|
print_userid( node->pkt );
|
||||||
if( opt.with_colons )
|
if( opt.with_colons )
|
||||||
putchar(':');
|
fputc(':', list_fp);
|
||||||
putchar('\n');
|
fputc('\n', list_fp);
|
||||||
if( opt.fingerprint && !any )
|
if( opt.fingerprint && !any )
|
||||||
print_fingerprint( NULL, sk, 0 );
|
print_fingerprint( NULL, sk, 0 );
|
||||||
any=1;
|
any=1;
|
||||||
}
|
}
|
||||||
else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|
else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
|
||||||
if( !any ) {
|
if( !any ) {
|
||||||
putchar('\n');
|
fputc('\n', list_fp);
|
||||||
any = 1;
|
any = 1;
|
||||||
}
|
}
|
||||||
list_node(c, node );
|
list_node(c, node );
|
||||||
@ -988,11 +1015,11 @@ list_node( CTX c, KBNODE node )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if( sig->sig_class == 0x20 || sig->sig_class == 0x30 )
|
if( sig->sig_class == 0x20 || sig->sig_class == 0x30 )
|
||||||
fputs("rev", stdout);
|
fputs("rev", list_fp);
|
||||||
else
|
else
|
||||||
fputs("sig", stdout);
|
fputs("sig", list_fp);
|
||||||
if( opt.check_sigs ) {
|
if( opt.check_sigs ) {
|
||||||
fflush(stdout);
|
fflush(list_fp);
|
||||||
switch( (rc2=do_check_sig( c, node, &is_selfsig, NULL )) ) {
|
switch( (rc2=do_check_sig( c, node, &is_selfsig, NULL )) ) {
|
||||||
case 0: sigrc = '!'; break;
|
case 0: sigrc = '!'; break;
|
||||||
case G10ERR_BAD_SIGN: sigrc = '-'; break;
|
case G10ERR_BAD_SIGN: sigrc = '-'; break;
|
||||||
@ -1016,35 +1043,36 @@ list_node( CTX c, KBNODE node )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( opt.with_colons ) {
|
if( opt.with_colons ) {
|
||||||
putchar(':');
|
fputc(':', list_fp);
|
||||||
if( sigrc != ' ' )
|
if( sigrc != ' ' )
|
||||||
putchar(sigrc);
|
fputc(sigrc, list_fp);
|
||||||
printf("::%d:%08lX%08lX:%s::::", sig->pubkey_algo,
|
fprintf( list_fp, "::%d:%08lX%08lX:%s::::", sig->pubkey_algo,
|
||||||
(ulong)sig->keyid[0],
|
(ulong)sig->keyid[0],
|
||||||
(ulong)sig->keyid[1], colon_datestr_from_sig(sig));
|
(ulong)sig->keyid[1], colon_datestr_from_sig(sig));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("%c %08lX %s ",
|
fprintf( list_fp, "%c %08lX %s ",
|
||||||
sigrc, (ulong)sig->keyid[1], datestr_from_sig(sig));
|
sigrc, (ulong)sig->keyid[1], datestr_from_sig(sig));
|
||||||
if( sigrc == '%' )
|
if( sigrc == '%' )
|
||||||
printf("[%s] ", g10_errstr(rc2) );
|
fprintf( list_fp, "[%s] ", g10_errstr(rc2) );
|
||||||
else if( sigrc == '?' )
|
else if( sigrc == '?' )
|
||||||
;
|
;
|
||||||
else if( is_selfsig ) {
|
else if( is_selfsig ) {
|
||||||
if( opt.with_colons )
|
if( opt.with_colons )
|
||||||
putchar(':');
|
fputc(':', list_fp);
|
||||||
fputs( sig->sig_class == 0x18? "[keybind]":"[selfsig]", stdout);
|
fputs( sig->sig_class == 0x18? "[keybind]":"[selfsig]", list_fp );
|
||||||
if( opt.with_colons )
|
if( opt.with_colons )
|
||||||
putchar(':');
|
fputc(':', list_fp);
|
||||||
}
|
}
|
||||||
else if( !opt.fast_list_mode ) {
|
else if( !opt.fast_list_mode ) {
|
||||||
p = get_user_id( sig->keyid, &n );
|
p = get_user_id( sig->keyid, &n );
|
||||||
print_string( stdout, p, n, opt.with_colons );
|
print_string( list_fp, p, n, opt.with_colons );
|
||||||
m_free(p);
|
m_free(p);
|
||||||
}
|
}
|
||||||
if( opt.with_colons )
|
if( opt.with_colons )
|
||||||
printf(":%02x%c:", sig->sig_class, sig->flags.exportable?'x':'l');
|
fprintf( list_fp, ":%02x%c:", sig->sig_class,
|
||||||
putchar('\n');
|
sig->flags.exportable?'x':'l');
|
||||||
|
fputc('\n', list_fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
log_error("invalid node with packet of type %d\n", node->pkt->pkttype);
|
log_error("invalid node with packet of type %d\n", node->pkt->pkttype);
|
||||||
@ -1104,6 +1132,8 @@ do_proc_packets( CTX c, IOBUF a )
|
|||||||
int any_data=0;
|
int any_data=0;
|
||||||
int newpkt;
|
int newpkt;
|
||||||
|
|
||||||
|
if( !list_fp )
|
||||||
|
list_fp = stdout;
|
||||||
c->iobuf = a;
|
c->iobuf = a;
|
||||||
init_packet(pkt);
|
init_packet(pkt);
|
||||||
while( (rc=parse_packet(a, pkt)) != -1 ) {
|
while( (rc=parse_packet(a, pkt)) != -1 ) {
|
||||||
|
@ -356,6 +356,8 @@ int proc_signature_packets( void *ctx, IOBUF a,
|
|||||||
STRLIST signedfiles, const char *sigfile );
|
STRLIST signedfiles, const char *sigfile );
|
||||||
int proc_encryption_packets( void *ctx, IOBUF a );
|
int proc_encryption_packets( void *ctx, IOBUF a );
|
||||||
int list_packets( IOBUF a );
|
int list_packets( IOBUF a );
|
||||||
|
void mainproc_open_output( const char * file );
|
||||||
|
FILE* mainproc_get_output( void );
|
||||||
|
|
||||||
/*-- parse-packet.c --*/
|
/*-- parse-packet.c --*/
|
||||||
int set_packet_list_mode( int mode );
|
int set_packet_list_mode( int mode );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user