summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1998-02-13 21:58:50 +0100
committerWerner Koch <wk@gnupg.org>1998-02-13 21:58:50 +0100
commitf477447d9af4097e8c5d4c15a3dd381237e93ee2 (patch)
treea655392c92fed02f06ebf503bf10b835b56e54e0 /util
parentadded assembler stuff for hppa (diff)
downloadgnupg2-f477447d9af4097e8c5d4c15a3dd381237e93ee2.tar.xz
gnupg2-f477447d9af4097e8c5d4c15a3dd381237e93ee2.zip
added option exportV0-2-6
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog18
-rw-r--r--util/Makefile.in1
-rw-r--r--util/argparse.c21
-rw-r--r--util/iobuf.c9
-rw-r--r--util/logger.c69
5 files changed, 77 insertions, 41 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
new file mode 100644
index 000000000..c72c6b80f
--- /dev/null
+++ b/util/ChangeLog
@@ -0,0 +1,18 @@
+Fri Feb 13 19:34:59 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * iobuf.c (iobuf_seek): Set counters to new offset.
+
+Fri Feb 13 17:13:04 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * logger.c (log_set_name, log_get_name): New.
+ (print_prefix, pgm_name): New, changed all function to make use it.
+ (log_mpidump): Removed the "DBG" prefix.
+ (log_hexdump): Ditto.
+
+ * logger.c (printstr): Removed.
+
+Fri Feb 13 15:14:13 1998 Werner Koch (wk@isil.d.shuttle.de)
+
+ * argparse.c (show_help): New '\v' kludge.
+
+
diff --git a/util/Makefile.in b/util/Makefile.in
index 4da66400a..1a7cc11a9 100644
--- a/util/Makefile.in
+++ b/util/Makefile.in
@@ -85,7 +85,6 @@ POSUB = @POSUB@
RANLIB = @RANLIB@
VERSION = @VERSION@
ZLIBS = @ZLIBS@
-ZLIB_SUBDIR = @ZLIB_SUBDIR@
INCLUDES = -I$(top_srcdir)/include
diff --git a/util/argparse.c b/util/argparse.c
index 0c8ad8f0b..620211e31 100644
--- a/util/argparse.c
+++ b/util/argparse.c
@@ -538,16 +538,31 @@ show_help( ARGPARSE_OPTS *opts, unsigned flags )
/* get max. length of long options */
for(i=indent=0; opts[i].short_opt; i++ ) {
if( opts[i].long_opt )
- if( (j=strlen(opts[i].long_opt)) > indent && j < 35 )
- indent = j;
+ if( !opts[i].description || *opts[i].description != '\v' )
+ if( (j=strlen(opts[i].long_opt)) > indent && j < 35 )
+ indent = j;
}
/* example: " -v, --verbose Viele Sachen ausgeben" */
indent += 10;
- puts("Options:");
+ if( *opts[0].description != '\v' )
+ puts("Options:");
for(i=0; opts[i].short_opt; i++ ) {
s = _( opts[i].description );
if( s && *s== '\r' ) /* hide this line */
continue;
+ if( s && *s == '\v' ) { /* unindented comment only line */
+ for(s++; *s; s++ ) {
+ if( *s == '\n' ) {
+ if( s[1] )
+ putchar('\n');
+ }
+ else
+ putchar(*s);
+ }
+ putchar('\n');
+ continue;
+ }
+
if( opts[i].short_opt < 256 )
printf(" -%c", opts[i].short_opt );
else
diff --git a/util/iobuf.c b/util/iobuf.c
index 65efc0ef5..cc3288d7e 100644
--- a/util/iobuf.c
+++ b/util/iobuf.c
@@ -867,6 +867,11 @@ iobuf_tell( IOBUF a )
}
+
+/****************
+ * This is a very limited implementation. It simply discards all internal
+ * buffering and remove all filters but the first one.
+ */
int
iobuf_seek( IOBUF a, ulong newpos )
{
@@ -885,6 +890,10 @@ iobuf_seek( IOBUF a, ulong newpos )
log_error("can't seek to %lu: %s\n", newpos, strerror(errno) );
return -1;
}
+ a->d.len = 0; /* discard buffer */
+ a->d.start = 0;
+ a->nbytes = 0;
+ a->nlimit = 0;
a->ntotal = newpos;
/* remove filters, but the last */
while( a->chain )
diff --git a/util/logger.c b/util/logger.c
index 7d101c29a..8b53a7b8d 100644
--- a/util/logger.c
+++ b/util/logger.c
@@ -26,9 +26,27 @@
#include "util.h"
static char pidstring[15];
+static char *pgm_name;
static int errorcount;
void
+log_set_name( const char *name )
+{
+ m_free(pgm_name);
+ if( name )
+ pgm_name = m_strdup(name);
+ else
+ pgm_name = NULL;
+}
+
+const char *
+log_get_name(void)
+{
+ return pgm_name? pgm_name : "";
+}
+
+
+void
log_set_pid( int pid )
{
if( pid )
@@ -46,45 +64,21 @@ log_get_errorcount( int clear)
return n;
}
-
-/****************
- * General interface for printing a line
- * level 0 := print to /dev/null
- * 1 := print to stdout
- * 2 := print as info to stderr
- * 3 := ditto but as error
- */
-void
-printstr( int level, const char *fmt, ... )
+static void
+print_prefix(const char *text)
{
- va_list arg_ptr ;
-
- if( !level )
- return;
-
- if( !fmt ) {
- putc('\n', level? stderr: stdout);
- return;
- }
-
- va_start( arg_ptr, fmt ) ;
- if( level < 2 ) {
- vfprintf(stdout,fmt,arg_ptr) ;
- }
- else {
- fprintf(stderr, level==2? "%s: ": "%s: error: ", strusage(13) ) ;
- vfprintf(stderr,fmt,arg_ptr) ;
- }
- va_end(arg_ptr);
+ if( pgm_name )
+ fprintf(stderr, "%s%s: %s", pgm_name, pidstring, text );
+ else
+ fprintf(stderr, "?%s: %s", pidstring, text );
}
-
void
log_info( const char *fmt, ... )
{
va_list arg_ptr ;
- fprintf(stderr, "info%s: ", pidstring ) ;
+ print_prefix("");
va_start( arg_ptr, fmt ) ;
vfprintf(stderr,fmt,arg_ptr) ;
va_end(arg_ptr);
@@ -95,7 +89,7 @@ log_error( const char *fmt, ... )
{
va_list arg_ptr ;
- fprintf(stderr, "error%s: ", pidstring ) ;
+ print_prefix("");
va_start( arg_ptr, fmt ) ;
vfprintf(stderr,fmt,arg_ptr) ;
va_end(arg_ptr);
@@ -107,7 +101,7 @@ log_fatal( const char *fmt, ... )
{
va_list arg_ptr ;
- fprintf(stderr, "Fatal%s: ", pidstring ) ;
+ print_prefix("fatal: ");
va_start( arg_ptr, fmt ) ;
vfprintf(stderr,fmt,arg_ptr) ;
va_end(arg_ptr);
@@ -120,7 +114,8 @@ log_bug( const char *fmt, ... )
{
va_list arg_ptr ;
- fprintf(stderr, "\nInternal Error%s: ", pidstring ) ;
+ putc('\n', stderr );
+ print_prefix("Ooops: ");
va_start( arg_ptr, fmt ) ;
vfprintf(stderr,fmt,arg_ptr) ;
va_end(arg_ptr);
@@ -148,7 +143,7 @@ log_debug( const char *fmt, ... )
{
va_list arg_ptr ;
- fprintf(stderr, "DBG%s: ", pidstring ) ;
+ print_prefix("DBG: ");
va_start( arg_ptr, fmt ) ;
vfprintf(stderr,fmt,arg_ptr) ;
va_end(arg_ptr);
@@ -161,7 +156,7 @@ log_hexdump( const char *text, char *buf, size_t len )
{
int i;
- fprintf(stderr, "DBG%s: %s", pidstring, text );
+ print_prefix(text);
for(i=0; i < len; i++ )
fprintf(stderr, " %02X", ((byte*)buf)[i] );
fputc('\n', stderr);
@@ -171,7 +166,7 @@ log_hexdump( const char *text, char *buf, size_t len )
void
log_mpidump( const char *text, MPI a )
{
- fprintf(stderr, "DBG%s: %s", pidstring, text );
+ print_prefix(text);
mpi_print(stderr, a, 1 );
fputc('\n', stderr);
}