1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

Minor fixes.

This commit is contained in:
Werner Koch 2008-12-09 08:58:02 +00:00
parent 78ff45c49e
commit 382d2f8efb
23 changed files with 106 additions and 54 deletions

View file

@ -24,6 +24,9 @@
#include <string.h>
#include <errno.h>
#include <assert.h>
#ifdef HAVE_DOSISH_SYSTEM
#include <fcntl.h> /* for setmode() */
#endif
#include "gpg.h"
#include "options.h"
@ -50,7 +53,8 @@ struct sig_stats
int oth_err;
};
static FILE *attrib_fp=NULL;
/* The stream used to write attribute packets to. */
static FILE *attrib_fp = NULL;
/****************
* List the keys
@ -745,6 +749,7 @@ dump_attribs(const PKT_user_id *uid,PKT_public_key *pk,PKT_secret_key *sk)
}
fwrite(uid->attribs[i].data,uid->attribs[i].len,1,attrib_fp);
fflush (attrib_fp);
}
}
@ -1609,29 +1614,35 @@ print_card_serialno (PKT_secret_key *sk)
void set_attrib_fd(int fd)
void
set_attrib_fd (int fd)
{
static int last_fd=-1;
if ( fd != -1 && last_fd == fd )
return;
if ( attrib_fp && attrib_fp != stdout && attrib_fp != stderr )
if ( attrib_fp && attrib_fp != stdout && attrib_fp != stderr
&& attrib_fp != log_get_stream () )
fclose (attrib_fp);
attrib_fp = NULL;
if ( fd == -1 )
return;
#ifdef HAVE_DOSISH_SYSTEM
setmode ( fileno(fp) , O_BINARY );
#endif
if( fd == 1 )
attrib_fp = stdout;
else if( fd == 2 )
attrib_fp = stderr;
else
attrib_fp = fdopen( fd, "wb" );
if( !attrib_fp ) {
log_fatal("can't open fd %d for attribute output: %s\n",
fd, strerror(errno));
}
attrib_fp = fdopen (fd, "wb");
if (!attrib_fp)
{
log_fatal("can't open fd %d for attribute output: %s\n",
fd, strerror(errno));
}
last_fd = fd;
}