diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/ChangeLog | 13 | ||||
-rw-r--r-- | util/errors.c | 8 | ||||
-rw-r--r-- | util/fileutil.c | 23 | ||||
-rw-r--r-- | util/iobuf.c | 2 | ||||
-rw-r--r-- | util/miscutil.c | 12 |
5 files changed, 53 insertions, 5 deletions
diff --git a/util/ChangeLog b/util/ChangeLog index 169a5b96f..561b84905 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,16 @@ +Sat Mar 7 11:54:35 1998 Werner Koch ([email protected]) + + * miscutil.c (print_string): New arg delim; changed all callers. + +Thu Mar 5 12:19:30 1998 Werner Koch ([email protected]) + + * errors.c: New strings. + +Thu Mar 5 12:06:31 1998 Werner Koch ([email protected]) + + * iobuf.c (iobuf_open): A name of "-" now opens stdin. + * fileutil.c (print_fname_stdout, print_fname_stdin): New. + Fri Feb 27 10:20:03 1998 Werner Koch ([email protected]) * memory.c (m_is_secure): Removed. diff --git a/util/errors.c b/util/errors.c index 28a418536..35b55177c 100644 --- a/util/errors.c +++ b/util/errors.c @@ -64,9 +64,13 @@ g10_errstr( int err ) X(NI_PUBKEY ,"Unimplemented pubkey algorithm") X(NI_CIPHER ,"Unimplemented cipher algorithm") X(SIG_CLASS ,"Unknown signature class") - X(TRUSTDB ,"TrustDB error") + X(TRUSTDB ,"Trust database error") X(BAD_CERT ,"Bad certificate") - X(INV_USER_ID ,"malformed user id") + X(INV_USER_ID ,"Malformed user id") + X(CLOSE_FILE ,"File close error") + X(RENAME_FILE ,"File rename error") + X(DELETE_FILE ,"File delete error") + X(UNEXPECTED ,"Unexpected data") default: p = buf; sprintf(buf, "g10err=%d", err); break; } diff --git a/util/fileutil.c b/util/fileutil.c index e5f9311bc..f3e00f8d6 100644 --- a/util/fileutil.c +++ b/util/fileutil.c @@ -64,3 +64,26 @@ make_filename( const char *first_part, ... ) return name; } + +/**************** + * A simple function to decide, wether the filename ist stdout + * or a real filename. + */ +const char * +print_fname_stdout( const char *s ) +{ + if( !s || (*s == '-' && !s[1]) ) + return "[stdout]"; + return s; +} + + +const char * +print_fname_stdin( const char *s ) +{ + if( !s || (*s == '-' && !s[1]) ) + return "[stdin]"; + return s; +} + + diff --git a/util/iobuf.c b/util/iobuf.c index ca3398674..30d6186fd 100644 --- a/util/iobuf.c +++ b/util/iobuf.c @@ -371,7 +371,7 @@ iobuf_open( const char *fname ) file_filter_ctx_t *fcx; size_t len; - if( !fname ) { + if( !fname || (*fname=='-' && !fname[1]) ) { fp = stdin; /* fixme: set binary mode for msdoze */ fname = "[stdin]"; } diff --git a/util/miscutil.c b/util/miscutil.c index 9dbb13ac1..cad89e8ab 100644 --- a/util/miscutil.c +++ b/util/miscutil.c @@ -37,13 +37,21 @@ make_timestamp() * Print a string to FP, but filter all control characters out. */ void -print_string( FILE *fp, byte *p, size_t n ) +print_string( FILE *fp, byte *p, size_t n, int delim ) { for( ; n; n--, p++ ) - if( iscntrl( *p ) ) { + if( iscntrl( *p ) || *p == delim ) { putc('\\', fp); if( *p == '\n' ) putc('n', fp); + else if( *p == '\r' ) + putc('r', fp); + else if( *p == '\f' ) + putc('f', fp); + else if( *p == '\v' ) + putc('v', fp); + else if( *p == '\b' ) + putc('b', fp); else if( !*p ) putc('0', fp); else |