summaryrefslogtreecommitdiff
path: root/g10/tdbdump.c
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-02-09 15:59:57 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-02-09 15:59:57 +0900
commited6a57244711b05833b351b7f7c88015e7ef16a7 (patch)
tree264ed10edc536d2eddb29af9f545124b21e9b7a3 /g10/tdbdump.c
parentc399f09830e89ea0ae248ed78502f6c0e6b632c1 (diff)
downloadgpg2-ed6a57244711b05833b351b7f7c88015e7ef16a7.tar.gz
gpg2-ed6a57244711b05833b351b7f7c88015e7ef16a7.tar.bz2
gpg2-ed6a57244711b05833b351b7f7c88015e7ef16a7.zip
Imported Upstream version 2.1.3upstream/2.1.3
Diffstat (limited to 'g10/tdbdump.c')
-rw-r--r--g10/tdbdump.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/g10/tdbdump.c b/g10/tdbdump.c
index c12e9b7..bf9f387 100644
--- a/g10/tdbdump.c
+++ b/g10/tdbdump.c
@@ -78,12 +78,12 @@ list_trustdb( const char *username )
ulong recnum;
int i;
- printf("TrustDB: %s\n", tdbio_get_dbname() );
+ es_printf ("TrustDB: %s\n", tdbio_get_dbname() );
for(i=9+strlen(tdbio_get_dbname()); i > 0; i-- )
- putchar('-');
- putchar('\n');
+ es_putc ('-', es_stdout);
+ es_putc ('\n', es_stdout);
for(recnum=0; !tdbio_read_record( recnum, &rec, 0); recnum++ )
- tdbio_dump_record( &rec, stdout );
+ tdbio_dump_record (&rec, es_stdout);
}
}
@@ -97,23 +97,25 @@ list_trustdb( const char *username )
void
export_ownertrust()
{
- TRUSTREC rec;
- ulong recnum;
- int i;
- byte *p;
+ TRUSTREC rec;
+ ulong recnum;
+ int i;
+ byte *p;
- init_trustdb();
- printf(_("# List of assigned trustvalues, created %s\n"
- "# (Use \"gpg --import-ownertrust\" to restore them)\n"),
- asctimestamp( make_timestamp() ) );
- for(recnum=0; !tdbio_read_record( recnum, &rec, 0); recnum++ ) {
- if( rec.rectype == RECTYPE_TRUST ) {
- if( !rec.r.trust.ownertrust )
- continue;
- p = rec.r.trust.fingerprint;
- for(i=0; i < 20; i++, p++ )
- printf("%02X", *p );
- printf(":%u:\n", (unsigned int)rec.r.trust.ownertrust );
+ init_trustdb();
+ es_printf (_("# List of assigned trustvalues, created %s\n"
+ "# (Use \"gpg --import-ownertrust\" to restore them)\n"),
+ asctimestamp( make_timestamp() ) );
+ for (recnum=0; !tdbio_read_record (recnum, &rec, 0); recnum++ )
+ {
+ if (rec.rectype == RECTYPE_TRUST)
+ {
+ if (!rec.r.trust.ownertrust)
+ continue;
+ p = rec.r.trust.fingerprint;
+ for (i=0; i < 20; i++, p++ )
+ es_printf("%02X", *p );
+ es_printf (":%u:\n", (unsigned int)rec.r.trust.ownertrust );
}
}
}
@@ -122,7 +124,7 @@ export_ownertrust()
void
import_ownertrust( const char *fname )
{
- FILE *fp;
+ estream_t fp;
int is_stdin=0;
char line[256];
char *p;
@@ -134,24 +136,24 @@ import_ownertrust( const char *fname )
init_trustdb();
if( iobuf_is_pipe_filename (fname) ) {
- fp = stdin;
+ fp = es_stdin;
fname = "[stdin]";
is_stdin = 1;
}
- else if( !(fp = fopen( fname, "r" )) ) {
+ else if( !(fp = es_fopen( fname, "r" )) ) {
log_error ( _("can't open '%s': %s\n"), fname, strerror(errno) );
return;
}
- if (is_secured_file (fileno (fp)))
+ if (is_secured_file (es_fileno (fp)))
{
- fclose (fp);
+ es_fclose (fp);
gpg_err_set_errno (EPERM);
log_error (_("can't open '%s': %s\n"), fname, strerror(errno) );
return;
}
- while( fgets( line, DIM(line)-1, fp ) ) {
+ while (es_fgets (line, DIM(line)-1, fp)) {
TRUSTREC rec;
if( !*line || *line == '#' )
@@ -216,10 +218,10 @@ import_ownertrust( const char *fname )
log_error (_("error finding trust record in '%s': %s\n"),
fname, gpg_strerror (rc));
}
- if( ferror(fp) )
+ if (es_ferror (fp))
log_error ( _("read error in '%s': %s\n"), fname, strerror(errno) );
- if( !is_stdin )
- fclose(fp);
+ if (!is_stdin)
+ es_fclose (fp);
if (any)
{