diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/ChangeLog | 4 | ||||
-rw-r--r-- | util/errors.c | 6 | ||||
-rw-r--r-- | util/fileutil.c | 1 | ||||
-rw-r--r-- | util/http.c | 38 | ||||
-rw-r--r-- | util/iobuf.c | 39 | ||||
-rw-r--r-- | util/logger.c | 39 | ||||
-rw-r--r-- | util/miscutil.c | 1 | ||||
-rw-r--r-- | util/strgutil.c | 3 | ||||
-rw-r--r-- | util/ttyio.c | 1 |
9 files changed, 72 insertions, 60 deletions
diff --git a/util/ChangeLog b/util/ChangeLog index e890e8d2f..b42bc37e5 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,7 @@ +Thu Jan 27 18:00:44 CET 2000 Werner Koch <[email protected]> + + * Changed all "g10_"/"GPG_" prefixes to "gpg_"/"GPG_". + Mon Jan 24 13:04:28 CET 2000 Werner Koch <[email protected]> * memory.c: Removed diff --git a/util/errors.c b/util/errors.c index d92892c12..d3eb2f172 100644 --- a/util/errors.c +++ b/util/errors.c @@ -43,12 +43,12 @@ strerror( int n ) #endif /* !HAVE_STRERROR */ const char * -g10_errstr( int err ) +gpg_errstr( int err ) { static char buf[50]; const char *p; - #define X(n,s) case G10ERR_##n : p = s; break; + #define X(n,s) case GPGERR_##n : p = s; break; switch( err ) { case -1: p = "eof"; break; case 0: p = "okay"; break; @@ -105,7 +105,7 @@ g10_errstr( int err ) if( err >= 0 ) /* pass on to libgcrypt */ p = gcry_strerror(err); /* fimxe: how do we handle i18n? */ else { - p = buf; sprintf(buf, "g10err=%d", err); break; + p = buf; sprintf(buf, "gpgerr=%d", err); break; } break; } diff --git a/util/fileutil.c b/util/fileutil.c index fe92c5c17..39268da74 100644 --- a/util/fileutil.c +++ b/util/fileutil.c @@ -25,6 +25,7 @@ #include <string.h> #include <assert.h> #include <unistd.h> +#include <gcrypt.h> #include "util.h" #include "memory.h" #include "ttyio.h" diff --git a/util/http.c b/util/http.c index fac26744b..173c17116 100644 --- a/util/http.c +++ b/util/http.c @@ -37,6 +37,8 @@ #include <arpa/inet.h> #include <netdb.h> +#include <gcrypt.h> + #include "util.h" #include "iobuf.h" #include "i18n.h" @@ -75,7 +77,7 @@ http_open( HTTP_HD hd, HTTP_REQ_TYPE reqtype, const char *url, int rc; if( flags || !(reqtype == HTTP_REQ_GET || reqtype == HTTP_REQ_POST) ) - return G10ERR_INV_ARG; + return GPGERR_INV_ARG; /* initialize the handle */ memset( hd, 0, sizeof *hd ); @@ -90,7 +92,7 @@ http_open( HTTP_HD hd, HTTP_REQ_TYPE reqtype, const char *url, hd->fp_write = iobuf_fdopen( hd->sock , "w" ); if( hd->fp_write ) return 0; - rc = G10ERR_GENERAL; + rc = GPGERR_GENERAL; } } @@ -125,7 +127,7 @@ http_wait_response( HTTP_HD hd, unsigned int *ret_status ) hd->sock = dup( hd->sock ); if( hd->sock == -1 ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; iobuf_close( hd->fp_write ); hd->fp_write = NULL; shutdown( hd->sock, 1 ); @@ -133,7 +135,7 @@ http_wait_response( HTTP_HD hd, unsigned int *ret_status ) hd->fp_read = iobuf_fdopen( hd->sock , "r" ); if( !hd->fp_read ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; rc = parse_response( hd ); if( !rc && ret_status ) @@ -149,7 +151,7 @@ http_open_document( HTTP_HD hd, const char *document, unsigned int flags ) int rc; if( flags ) - return G10ERR_INV_ARG; + return GPGERR_INV_ARG; rc = http_open( hd, HTTP_REQ_GET, document, 0 ); if( rc ) @@ -225,12 +227,12 @@ do_parse_uri( PARSED_URI uri, int only_local_part ) /* a quick validity check */ if( strspn( p, VALID_URI_CHARS) != n ) - return G10ERR_BAD_URI; /* invalid characters found */ + return GPGERR_BAD_URI; /* invalid characters found */ if( !only_local_part ) { /* find the scheme */ if( !(p2 = strchr( p, ':' ) ) || p2 == p ) - return G10ERR_BAD_URI; /* No scheme */ + return GPGERR_BAD_URI; /* No scheme */ *p2++ = 0; strlwr( p ); uri->scheme = p; @@ -239,13 +241,13 @@ do_parse_uri( PARSED_URI uri, int only_local_part ) else if( !strcmp( uri->scheme, "x-hkp" ) ) /* same as HTTP */ ; else - return G10ERR_INVALID_URI; /* Unsupported scheme */ + return GPGERR_INVALID_URI; /* Unsupported scheme */ p = p2; /* find the hostname */ if( *p != '/' ) - return G10ERR_INVALID_URI; /* does not start with a slash */ + return GPGERR_INVALID_URI; /* does not start with a slash */ p++; if( *p == '/' ) { /* there seems to be a hostname */ @@ -262,9 +264,9 @@ do_parse_uri( PARSED_URI uri, int only_local_part ) uri->port = 80; uri->host = p; if( (n = remove_escapes( uri->host )) < 0 ) - return G10ERR_BAD_URI; + return GPGERR_BAD_URI; if( n != strlen( p ) ) - return G10ERR_BAD_URI; /* hostname with a Nul in it */ + return GPGERR_BAD_URI; /* hostname with a Nul in it */ p = p2 ? p2 : NULL; } } /* end global URI part */ @@ -281,9 +283,9 @@ do_parse_uri( PARSED_URI uri, int only_local_part ) uri->path = p; if( (n = remove_escapes( p )) < 0 ) - return G10ERR_BAD_URI; + return GPGERR_BAD_URI; if( n != strlen( p ) ) - return G10ERR_BAD_URI; /* path with a Nul in it */ + return GPGERR_BAD_URI; /* path with a Nul in it */ p = p2 ? p2 : NULL; if( !p || !*p ) /* we don't have a query string */ @@ -297,7 +299,7 @@ do_parse_uri( PARSED_URI uri, int only_local_part ) if( (p2 = strchr( p, '&' )) ) *p2++ = 0; if( !(elem = parse_tuple( p )) ) - return G10ERR_BAD_URI; + return GPGERR_BAD_URI; *tail = elem; tail = &elem->next; @@ -433,7 +435,7 @@ send_request( HTTP_HD hd ) hd->sock = connect_server( server, port ); if( hd->sock == -1 ) - return G10ERR_NETWORK; + return GPGERR_NETWORK; p = build_rel_path( hd->uri ); request = gcry_xmalloc( strlen(p) + 20 ); @@ -679,7 +681,7 @@ write_server( int sock, const char *data, size_t length ) continue; } log_info("write failed: %s\n", strerror(errno)); - return G10ERR_NETWORK; + return GPGERR_NETWORK; } nleft -=nwritten; data += nwritten; @@ -716,7 +718,7 @@ main(int argc, char **argv) rc = parse_uri( &uri, *argv ); if( rc ) { - log_error("`%s': %s\n", *argv, g10_errstr(rc)); + log_error("`%s': %s\n", *argv, gpg_errstr(rc)); release_parsed_uri( uri ); return 1; } @@ -741,7 +743,7 @@ main(int argc, char **argv) rc = http_open_document( &hd, *argv, 0 ); if( rc ) { - log_error("can't get `%s': %s\n", *argv, g10_errstr(rc)); + log_error("can't get `%s': %s\n", *argv, gpg_errstr(rc)); return 1; } log_info("open_http_document succeeded; status=%u\n", hd.status_code ); diff --git a/util/iobuf.c b/util/iobuf.c index e07431024..ec5cfefbd 100644 --- a/util/iobuf.c +++ b/util/iobuf.c @@ -27,6 +27,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> +#include <gcrypt.h> #include "memory.h" #include "util.h" @@ -75,7 +76,7 @@ static int underflow(IOBUF a); * buffer, and should be set to the number of bytes * which were put into the buffer. The function * returns 0 to indicate success, -1 on EOF and - * G10ERR_xxxxx for other errors. + * GPGERR_xxxxx for other errors. * * IOBUFCTRL_FLUSH: called by iobuf_flush() to write out the collected stuff. * *RET_LAN is the number of bytes in BUF. @@ -104,7 +105,7 @@ file_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) else if( ferror(fp) && errno != EPIPE ) { log_error("%s: read error: %s\n", a->fname, strerror(errno)); - rc = G10ERR_READ_FILE; + rc = GPGERR_READ_FILE; } *ret_len = nbytes; } @@ -115,7 +116,7 @@ file_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) nbytes = fwrite( buf, 1, size, fp ); if( ferror(fp) ) { log_error("%s: write error: %s\n", a->fname, strerror(errno)); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; } } *ret_len = nbytes; @@ -177,7 +178,7 @@ block_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) } else if( (c = iobuf_get(chain)) == -1 ) { log_error("block_filter: 1st length byte missing\n"); - rc = G10ERR_READ_FILE; + rc = GPGERR_READ_FILE; break; } if( c < 192 ) { @@ -194,7 +195,7 @@ block_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) a->size = (c - 192) * 256; if( (c = iobuf_get(chain)) == -1 ) { log_error("block_filter: 2nd length byte missing\n"); - rc = G10ERR_READ_FILE; + rc = GPGERR_READ_FILE; break; } a->size += c + 192; @@ -212,7 +213,7 @@ block_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) a->size |= iobuf_get(chain) << 8; if( (c = iobuf_get(chain)) == -1 ) { log_error("block_filter: invalid 4 byte length\n"); - rc = G10ERR_READ_FILE; + rc = GPGERR_READ_FILE; break; } a->size |= c; @@ -229,7 +230,7 @@ block_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) a->size |= c; if( c == -1 ) { log_error("block_filter: error reading length info\n"); - rc = G10ERR_READ_FILE; + rc = GPGERR_READ_FILE; } if( !a->size ) { a->eof = 1; @@ -247,7 +248,7 @@ block_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) if( c == -1 ) c = 0; log_error("block_filter %p: read error (size=%lu,a->size=%lu)\n", a, (ulong)size+c, (ulong)a->size+c); - rc = G10ERR_READ_FILE; + rc = GPGERR_READ_FILE; } else { size -= c; @@ -289,14 +290,14 @@ block_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) if( (n=a->buflen) ) { /* write stuff from the buffer */ assert( n == OP_MIN_PARTIAL_CHUNK); if( iobuf_write(chain, a->buffer, n ) ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; a->buflen = 0; nbytes -= n; } if( (n = nbytes) > blen ) n = blen; if( n && iobuf_write(chain, p, n ) ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; p += n; nbytes -= n; } while( !rc && nbytes >= OP_MIN_PARTIAL_CHUNK ); @@ -334,7 +335,7 @@ block_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) if( n > avail ) n = avail; if( iobuf_write(chain, p, n ) ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; a->count += n; p += n; size -= n; @@ -391,7 +392,7 @@ block_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) rc = iobuf_write(chain, a->buffer, len ); if( rc ) { log_error("block_filter: write error: %s\n",strerror(errno)); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; } gcry_free( a->buffer ); a->buffer = NULL; a->buflen = 0; } @@ -479,13 +480,13 @@ iobuf_close( IOBUF a ) for( ; a && !rc ; a = a2 ) { a2 = a->chain; if( a->use == 2 && (rc=iobuf_flush(a)) ) - log_error("iobuf_flush failed on close: %s\n", g10_errstr(rc)); + log_error("iobuf_flush failed on close: %s\n", gpg_errstr(rc)); if( DBG_IOBUF ) log_debug("iobuf-%d.%d: close `%s'\n", a->no, a->subno, a->desc ); if( a->filter && (rc = a->filter(a->filter_ov, IOBUFCTRL_FREE, a->chain, NULL, &dummy_len)) ) - log_error("IOBUFCTRL_FREE failed on close: %s\n", g10_errstr(rc) ); + log_error("IOBUFCTRL_FREE failed on close: %s\n", gpg_errstr(rc) ); gcry_free(a->real_fname); gcry_free(a->d.buf); gcry_free(a); @@ -808,7 +809,7 @@ iobuf_push_filter2( IOBUF a, /* now we can initialize the new function if we have one */ if( a->filter && (rc = a->filter(a->filter_ov, IOBUFCTRL_INIT, a->chain, NULL, &dummy_len)) ) - log_error("IOBUFCTRL_INIT failed: %s\n", g10_errstr(rc) ); + log_error("IOBUFCTRL_INIT failed: %s\n", gpg_errstr(rc) ); return rc; } @@ -845,13 +846,13 @@ pop_filter( IOBUF a, int (*f)(void *opaque, int control, /* flush this stream if it is an output stream */ if( a->use == 2 && (rc=iobuf_flush(b)) ) { - log_error("iobuf_flush failed in pop_filter: %s\n", g10_errstr(rc)); + log_error("iobuf_flush failed in pop_filter: %s\n", gpg_errstr(rc)); return rc; } /* and tell the filter to free it self */ if( b->filter && (rc = b->filter(b->filter_ov, IOBUFCTRL_FREE, b->chain, NULL, &dummy_len)) ) { - log_error("IOBUFCTRL_FREE failed: %s\n", g10_errstr(rc) ); + log_error("IOBUFCTRL_FREE failed: %s\n", gpg_errstr(rc) ); return rc; } if( b->filter_ov && b->filter_ov_owner ) { @@ -960,7 +961,7 @@ underflow(IOBUF a) /* and tell the filter to free itself */ if( (rc = a->filter(a->filter_ov, IOBUFCTRL_FREE, a->chain, NULL, &dummy_len)) ) - log_error("IOBUFCTRL_FREE failed: %s\n", g10_errstr(rc) ); + log_error("IOBUFCTRL_FREE failed: %s\n", gpg_errstr(rc) ); if( a->filter_ov && a->filter_ov_owner ) { gcry_free( a->filter_ov ); a->filter_ov = NULL; @@ -1034,7 +1035,7 @@ iobuf_flush(IOBUF a) rc = a->filter( a->filter_ov, IOBUFCTRL_FLUSH, a->chain, a->d.buf, &len ); if( !rc && len != a->d.len ) { log_info("iobuf_flush did not write all!\n"); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; } else if( rc ) a->error = 1; diff --git a/util/logger.c b/util/logger.c index ae6984f48..83cba8c22 100644 --- a/util/logger.c +++ b/util/logger.c @@ -24,6 +24,7 @@ #include <stdarg.h> #include <string.h> #include <errno.h> +#include <gcrypt.h> #include "util.h" #include "i18n.h" @@ -103,7 +104,7 @@ log_get_errorcount( int clear) void -g10_log_print_prefix(const char *text) +gpg_log_print_prefix(const char *text) { if( !logfp ) logfp = stderr; @@ -125,18 +126,18 @@ print_prefix_f(const char *text, const char *fname) } void -g10_log_info( const char *fmt, ... ) +gpg_log_info( const char *fmt, ... ) { va_list arg_ptr ; - g10_log_print_prefix(""); + gpg_log_print_prefix(""); va_start( arg_ptr, fmt ) ; vfprintf(logfp,fmt,arg_ptr) ; va_end(arg_ptr); } void -g10_log_info_f( const char *fname, const char *fmt, ... ) +gpg_log_info_f( const char *fname, const char *fmt, ... ) { va_list arg_ptr ; @@ -147,11 +148,11 @@ g10_log_info_f( const char *fname, const char *fmt, ... ) } void -g10_log_error( const char *fmt, ... ) +gpg_log_error( const char *fmt, ... ) { va_list arg_ptr ; - g10_log_print_prefix(""); + gpg_log_print_prefix(""); va_start( arg_ptr, fmt ) ; vfprintf(logfp,fmt,arg_ptr) ; va_end(arg_ptr); @@ -159,7 +160,7 @@ g10_log_error( const char *fmt, ... ) } void -g10_log_error_f( const char *fname, const char *fmt, ... ) +gpg_log_error_f( const char *fname, const char *fmt, ... ) { va_list arg_ptr ; @@ -171,11 +172,11 @@ g10_log_error_f( const char *fname, const char *fmt, ... ) } void -g10_log_fatal( const char *fmt, ... ) +gpg_log_fatal( const char *fmt, ... ) { va_list arg_ptr ; - g10_log_print_prefix("fatal: "); + gpg_log_print_prefix("fatal: "); va_start( arg_ptr, fmt ) ; vfprintf(logfp,fmt,arg_ptr) ; va_end(arg_ptr); @@ -184,7 +185,7 @@ g10_log_fatal( const char *fmt, ... ) } void -g10_log_fatal_f( const char *fname, const char *fmt, ... ) +gpg_log_fatal_f( const char *fname, const char *fmt, ... ) { va_list arg_ptr ; @@ -197,12 +198,12 @@ g10_log_fatal_f( const char *fname, const char *fmt, ... ) } void -g10_log_bug( const char *fmt, ... ) +gpg_log_bug( const char *fmt, ... ) { va_list arg_ptr ; putc('\n', stderr ); - g10_log_print_prefix("Ohhhh jeeee: "); + gpg_log_print_prefix("Ohhhh jeeee: "); va_start( arg_ptr, fmt ) ; vfprintf(stderr,fmt,arg_ptr) ; va_end(arg_ptr); @@ -213,31 +214,31 @@ g10_log_bug( const char *fmt, ... ) #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) void -g10_log_bug0( const char *file, int line, const char *func ) +gpg_log_bug0( const char *file, int line, const char *func ) { log_bug(_("... this is a bug (%s:%d:%s)\n"), file, line, func ); } #else void -g10_log_bug0( const char *file, int line ) +gpg_log_bug0( const char *file, int line ) { log_bug(_("you found a bug ... (%s:%d)\n"), file, line); } #endif void -g10_log_debug( const char *fmt, ... ) +gpg_log_debug( const char *fmt, ... ) { va_list arg_ptr ; - g10_log_print_prefix("DBG: "); + gpg_log_print_prefix("DBG: "); va_start( arg_ptr, fmt ) ; vfprintf(logfp,fmt,arg_ptr) ; va_end(arg_ptr); } void -g10_log_debug_f( const char *fname, const char *fmt, ... ) +gpg_log_debug_f( const char *fname, const char *fmt, ... ) { va_list arg_ptr ; @@ -250,11 +251,11 @@ g10_log_debug_f( const char *fname, const char *fmt, ... ) void -g10_log_hexdump( const char *text, const char *buf, size_t len ) +gpg_log_hexdump( const char *text, const char *buf, size_t len ) { int i; - g10_log_print_prefix(text); + gpg_log_print_prefix(text); for(i=0; i < len; i++ ) fprintf(logfp, " %02X", ((const byte*)buf)[i] ); fputc('\n', logfp); diff --git a/util/miscutil.c b/util/miscutil.c index c96608d98..2cf0db0e2 100644 --- a/util/miscutil.c +++ b/util/miscutil.c @@ -27,6 +27,7 @@ #ifdef HAVE_LANGINFO_H #include <langinfo.h> #endif +#include <gcrypt.h> #include "types.h" #include "util.h" #include "i18n.h" diff --git a/util/strgutil.c b/util/strgutil.c index 274f2cda8..ea3ddc29c 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> +#include <gcrypt.h> #include "types.h" #include "util.h" #include "memory.h" @@ -276,7 +277,7 @@ set_native_charset( const char *newset ) active_charset = ibm850_unicode; } else - return G10ERR_GENERAL; + return GPGERR_GENERAL; return 0; } diff --git a/util/ttyio.c b/util/ttyio.c index 8dacb555e..527d64832 100644 --- a/util/ttyio.c +++ b/util/ttyio.c @@ -35,6 +35,7 @@ #endif #include <errno.h> #include <ctype.h> +#include <gcrypt.h> #include "util.h" #include "memory.h" #include "ttyio.h" |