diff options
author | Werner Koch <wk@gnupg.org> | 2000-01-27 17:50:45 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2000-01-27 17:50:45 +0100 |
commit | baa30ad117e12c5182a78ede84c5103bea23616b (patch) | |
tree | f1d174362ee1855c5af77dcb917451e026c0a8d5 | |
parent | See ChangeLog: Mon Jan 24 22:24:38 CET 2000 Werner Koch (diff) | |
download | gnupg2-baa30ad117e12c5182a78ede84c5103bea23616b.tar.xz gnupg2-baa30ad117e12c5182a78ede84c5103bea23616b.zip |
See ChangeLog: Thu Jan 27 18:00:44 CET 2000 Werner Koch
75 files changed, 1085 insertions, 776 deletions
@@ -1,3 +1,7 @@ +Thu Jan 27 18:00:44 CET 2000 Werner Koch <wk@gnupg.de> + + * configure.in (g10defs.h): Replaced by gnupg-defs.h + Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de> * jnlib/ : New. diff --git a/Makefile.am b/Makefile.am index 60fb64c88..bf47e022e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,7 @@ EXTRA_DIST = README-alpha VERSION PROJECTS BUGS # gettext never gets it right, so we take here care of deleting the # symlink. my_clean_gcrypt is just a kludge until we can include # libgcrypt. -DISTCLEANFILES = g10defs.h intl/libintl.h ${my_clean_gcrypt} +DISTCLEANFILES = gnupg-defs.h intl/libintl.h ${my_clean_gcrypt} dist-hook: @set -e; \ diff --git a/acconfig.h b/acconfig.h index 40ef16a60..d364c7b7a 100644 --- a/acconfig.h +++ b/acconfig.h @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_CONFIG_H -#define G10_CONFIG_H +#ifndef GNUPG_CONFIG_H +#define GNUPG_CONFIG_H /* need this, because some autoconf tests rely on this (e.g. stpcpy) * and it should be used for new programs @@ -107,6 +107,6 @@ @BOTTOM@ -#include "g10defs.h" +#include "gnupg-defs.h" -#endif /*G10_CONFIG_H*/ +#endif /*GNUPG_CONFIG_H*/ diff --git a/cipher/ChangeLog b/cipher/ChangeLog index 5925a0419..cd899ed6c 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,3 +1,7 @@ +Thu Jan 27 18:00:44 CET 2000 Werner Koch <wk@gnupg.de> + + * pubkey.c (sexp_to_key): Fixed mem leaks in case of errors. + Mon Jan 24 22:24:38 CET 2000 Werner Koch <wk@gnupg.de> * pubkey.c (gcry_pk_decrypt): Implemented. diff --git a/cipher/pubkey.c b/cipher/pubkey.c index 4def6f699..3ace1d83c 100644 --- a/cipher/pubkey.c +++ b/cipher/pubkey.c @@ -668,11 +668,15 @@ sexp_to_key( GCRY_SEXP sexp, int want_private, MPI **retarray, int *retalgo) for(s=elems1; *s; s++, idx++ ) { l2 = gcry_sexp_find_token( list, s, 1 ); if( !l2 ) { + for(i=0; i<idx; i++) + g10_free( array[i] ); g10_free( array ); return GCRYERR_NO_OBJ; /* required parameter not found */ } array[idx] = gcry_sexp_cdr_mpi( l2, GCRYMPI_FMT_USG ); if( !array[idx] ) { + for(i=0; i<idx; i++) + g10_free( array[i] ); g10_free( array ); return GCRYERR_INV_OBJ; /* required parameter is invalid */ } @@ -680,12 +684,16 @@ sexp_to_key( GCRY_SEXP sexp, int want_private, MPI **retarray, int *retalgo) for(s=elems2; *s; s++, idx++ ) { l2 = gcry_sexp_find_token( list, s, 1 ); if( !l2 ) { + for(i=0; i<idx; i++) + g10_free( array[i] ); g10_free( array ); return GCRYERR_NO_OBJ; /* required parameter not found */ } /* FIXME: put the MPI in secure memory when needed */ array[idx] = gcry_sexp_cdr_mpi( l2, GCRYMPI_FMT_USG ); if( !array[idx] ) { + for(i=0; i<idx; i++) + g10_free( array[i] ); g10_free( array ); return GCRYERR_INV_OBJ; /* required parameter is invalid */ } @@ -1100,21 +1108,138 @@ gcry_pk_testkey( GCRY_SEXP s_key ) /**************** * Create a public key pair and return it in r_key. * How the key is created depends on s_parms: - * (GNU - * (genkey - * (algo - * (parameter_name_1 ....) - * .... - * (parameter_name_n ....) - * ))) + * (genkey + * (algo + * (parameter_name_1 ....) + * .... + * (parameter_name_n ....) + * )) * The key is returned in a format depending on the - * algorithm. Both, private and secret key are returned + * algorithm. Both, private and secret keys are returned * and optionally some additional informatin. + * For elgamal we return this structure: + * (key-data + * (public-key + * (elg + * (p <mpi>) + * (g <mpi>) + * (y <mpi>) + * ) + * ) + * (private-key + * (elg + * (p <mpi>) + * (g <mpi>) + * (y <mpi>) + * (x <mpi>) + * ) + * ) + * (misc-key-info + * (pm1-factors n1 n2 ... nn) + * ) + * ) */ int gcry_pk_genkey( GCRY_SEXP *r_key, GCRY_SEXP s_parms ) { - return GCRYERR_NOT_IMPL; + GCRY_SEXP list, l2, *s_elems, pub_list, sec_list, misc_list; + const char *name; + const char *s; + size_t n; + int rc, i; + const char *algo_name; + int algo; + char sec_elems[20], pub_elems[20]; /* fixme: check bounds */ + GCRY_MPI skey[10], *factors; + unsigned int nbits; + + list = gcry_sexp_find_token( s_parms, "genkey", 0 ); + if( !list ) + return GCRYERR_INV_OBJ; /* Does not contain genkey data */ + list = gcry_sexp_cdr( list ); + if( !list ) + return GCRYERR_NO_OBJ; /* no cdr for the genkey */ + name = gcry_sexp_car_data( list, &n ); + if( !name ) + return GCRYERR_INV_OBJ; /* algo string missing */ + for(i=0; (s=algo_info_table[i].name); i++ ) { + if( strlen(s) == n && !memcmp( s, name, n ) ) + break; + } + if( !s ) + return GCRYERR_INV_PK_ALGO; /* unknown algorithm */ + + algo = algo_info_table[i].algo; + algo_name = algo_info_table[i].name; + strcpy( pub_elems, algo_info_table[i].common_elements ); + strcat( pub_elems, algo_info_table[i].public_elements ); + strcpy( sec_elems, algo_info_table[i].common_elements ); + strcat( sec_elems, algo_info_table[i].secret_elements ); + + l2 = gcry_sexp_find_token( list, "nbits", 0 ); + if( !l2 ) + return GCRYERR_NO_OBJ; /* no nbits aparemter */ + name = gcry_sexp_cdr_data( l2, &n ); + if( !name ) + return GCRYERR_INV_OBJ; /* nbits without a cdr */ + { + char *p = g10_xmalloc(n+1); + memcpy(p, name, n ); + p[n] = 0; + nbits = (unsigned int)strtol( p, NULL, 0 ); + g10_free( p ); + } + + rc = pubkey_generate( algo, nbits, skey, &factors ); + if( rc ) { + return rc; + } + + /* build the public key list */ + s_elems = g10_xcalloc( (strlen(pub_elems)+2), sizeof *s_elems ); + s_elems[0] = SEXP_NEW( algo_name, 0 ); + for(i=0; pub_elems[i]; i++ ) { + char tmp[2]; + tmp[0] = pub_elems[i]; + tmp[1] = 0; + s_elems[i+1] = gcry_sexp_new_name_mpi( tmp, skey[i] ); + } + pub_list = SEXP_CONS( SEXP_NEW( "public-key", 0 ), + gcry_sexp_alist( s_elems ) ); + g10_free( s_elems ); + + /* build the secret key list */ + s_elems = g10_xcalloc( (strlen(sec_elems)+2), sizeof *s_elems ); + s_elems[0] = SEXP_NEW( algo_name, 0 ); + for(i=0; sec_elems[i]; i++ ) { + char tmp[2]; + tmp[0] = sec_elems[i]; + tmp[1] = 0; + s_elems[i+1] = gcry_sexp_new_name_mpi( tmp, skey[i] ); + } + sec_list = SEXP_CONS( SEXP_NEW( "private-key", 0 ), + gcry_sexp_alist( s_elems ) ); + g10_free( s_elems ); + + /* build the list of factors */ + for(n=0; factors[n]; n++ ) + ; + s_elems = g10_xcalloc( n+2, sizeof *s_elems ); + s_elems[0] = SEXP_NEW( "pm1-factors", 0 ); + for(i=0; factors[i]; i++ ) { + s_elems[i+1] = gcry_sexp_new_mpi( factors[i] ); + } + misc_list = SEXP_CONS( SEXP_NEW( "misc-key-info", 0 ), + gcry_sexp_alist( s_elems ) ); + g10_free( s_elems ); + + /* and put all together */ + *r_key = gcry_sexp_vlist( SEXP_NEW( "key-data", 0 ), + pub_list, sec_list, misc_list, NULL ); + gcry_sexp_release( pub_list ); + gcry_sexp_release( sec_list ); + gcry_sexp_release( misc_list ); + return 0; } /**************** diff --git a/configure.in b/configure.in index ff584f533..6c3b209cd 100644 --- a/configure.in +++ b/configure.in @@ -8,7 +8,7 @@ dnl Must reset CDPATH so that bash's cd does not print to stdout CDPATH= AC_PREREQ(2.13) -AC_INIT(g10/g10.c) +AC_INIT(g10/gpg.c) AC_CONFIG_AUX_DIR(scripts) AM_CONFIG_HEADER(config.h) @@ -687,25 +687,25 @@ GNUPG_FIX_HDR_VERSION(gcrypt/gcrypt.h, GCRYPT_VERSION) AC_OUTPUT_COMMANDS([ chmod +x gcrypt/gcrypt-config -cat >g10defs.tmp <<G10EOF +cat >gnupg-defs.tmp <<G10EOF /* Generated automatically by configure */ #ifdef HAVE_DRIVE_LETTERS - #define G10_LOCALEDIR "c:/lib/gnupg/locale" + #define GNUPG_LOCALEDIR "c:/lib/gnupg/locale" #define GNUPG_LIBDIR "c:/lib/gnupg" #define GNUPG_DATADIR "c:/lib/gnupg" #else - #define G10_LOCALEDIR "${prefix}/${DATADIRNAME}/locale" + #define GNUPG_LOCALEDIR "${prefix}/${DATADIRNAME}/locale" #define GNUPG_LIBDIR "${libdir}/gnupg" #define GNUPG_DATADIR "${datadir}/gnupg" #endif G10EOF -if cmp -s g10defs.h g10defs.tmp 2>/dev/null; then - echo "g10defs.h is unchanged" - rm -f g10defs.tmp +if cmp -s gnupg-defs.h gnupg-defs.tmp 2>/dev/null; then + echo "gnupg-defs.h is unchanged" + rm -f gnupg-defs.tmp else - rm -f g10defs.h - mv g10defs.tmp g10defs.h - echo "g10defs.h created" + rm -f gnupg-defs.h + mv gnupg-defs.tmp gnupg-defs.h + echo "gnupg-defs.h created" fi ],[ prefix=$prefix diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 000000000..98825f605 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +case "$1" in + configure|abort-upgrade|abort-remove|abort-deconfigure) + if [ -x /usr/sbin/suidregister ]; then + suidregister -s gpg /usr/bin/gpg root root 4755 + else + chmod 4755 /usr/bin/gpg + fi + ;; +esac + diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 000000000..f640fb0b4 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + if [ -x /usr/sbin/suidunregister ]; then + suidunregister -s gpg /usr/bin/gpg + fi + ;; +esac diff --git a/g10/ChangeLog b/g10/ChangeLog index 537b48ede..f3898ca57 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,15 @@ +Thu Jan 27 18:00:44 CET 2000 Werner Koch <wk@gnupg.de> + + * keygen.c (gen_elg): Modified to work with gcry_pk_genkey. + (key_from_sexp): New. + (factors_from_sexp): New. + + * g10.c : Renamed to ... + * gpg.c : ... this + * Makefile.am: And fixed it here. + + * Changed all "g10_"/"GPG_" prefixes to "gpg_"/"GPG_". + Mon Jan 24 22:24:38 CET 2000 Werner Koch <wk@gnupg.de> * misc.c (mpi_read_opaque): Fixed double counting. diff --git a/g10/Makefile.am b/g10/Makefile.am index f0f6068c5..bc83ad9c2 100644 --- a/g10/Makefile.am +++ b/g10/Makefile.am @@ -3,7 +3,7 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl EXTRA_DIST = OPTIONS pubring.asc options.skel OMIT_DEPENDENCIES = zlib.h zconf.h -LDFLAGS = @LDFLAGS@ @DYNLINK_LDFLAGS@ +LDFLAGS = -static @LDFLAGS@ @DYNLINK_LDFLAGS@ needed_libs = ../util/libutil.la ../gcrypt/libgcrypt.la ../jnlib/libjnlib.la #noinst_PROGRAMS = gpgd @@ -60,7 +60,7 @@ common_source = \ signal.c \ helptext.c -gpg_SOURCES = g10.c \ +gpg_SOURCES = gpg.c \ $(common_source) \ verify.c \ decrypt.c \ diff --git a/g10/armor.c b/g10/armor.c index 828113b0c..0661d76ef 100644 --- a/g10/armor.c +++ b/g10/armor.c @@ -204,7 +204,7 @@ static void invalid_armor(void) { write_status(STATUS_BADARMOR); - g10_exit(1); /* stop here */ + gpg_exit(1); /* stop here */ } @@ -393,7 +393,7 @@ check_input( armor_filter_context_t *afx, IOBUF a ) if( hdr_line == BEGIN_SIGNED_MSG_IDX ) { if( afx->in_cleartext ) { log_error(_("nested clear text signatures\n")); - rc = G10ERR_INVALID_ARMOR; + rc = GPGERR_INVALID_ARMOR; } afx->in_cleartext = 1; } @@ -423,7 +423,7 @@ check_input( armor_filter_context_t *afx, IOBUF a ) i = parse_header_line( afx, line, len ); if( i <= 0 ) { if( i ) - rc = G10ERR_INVALID_ARMOR; + rc = GPGERR_INVALID_ARMOR; break; } } @@ -710,16 +710,16 @@ radix64_read( armor_filter_context_t *afx, IOBUF a, size_t *retn, } while( ++idx < 4 ); if( c == -1 ) { log_error(_("premature eof (in CRC)\n")); - rc = G10ERR_INVALID_ARMOR; + rc = GPGERR_INVALID_ARMOR; } else if( idx != 4 ) { log_error(_("malformed CRC\n")); - rc = G10ERR_INVALID_ARMOR; + rc = GPGERR_INVALID_ARMOR; } else if( mycrc != afx->crc ) { log_error(_("CRC error; %06lx - %06lx\n"), (ulong)afx->crc, (ulong)mycrc); - rc = G10ERR_INVALID_ARMOR; + rc = GPGERR_INVALID_ARMOR; } else { rc = 0; @@ -735,11 +735,11 @@ radix64_read( armor_filter_context_t *afx, IOBUF a, size_t *retn, rc = 0; else if( rc == 2 ) { log_error(_("premature eof (in Trailer)\n")); - rc = G10ERR_INVALID_ARMOR; + rc = GPGERR_INVALID_ARMOR; } else { log_error(_("error in trailer line\n")); - rc = G10ERR_INVALID_ARMOR; + rc = GPGERR_INVALID_ARMOR; } #endif } diff --git a/g10/basicdefs.h b/g10/basicdefs.h index 9e1edb56d..1a7f0901a 100644 --- a/g10/basicdefs.h +++ b/g10/basicdefs.h @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_BASICDEFS_H -#define G10_BASICDEFS_H +#ifndef GPG_BASICDEFS_H +#define GPG_BASICDEFS_H #include "types.h" @@ -37,4 +37,4 @@ typedef struct sk_list *SK_LIST; -#endif /* G10_BASICDEFS_H */ +#endif /* GPG_BASICDEFS_H */ diff --git a/g10/build-packet.c b/g10/build-packet.c index 34fd4ae1d..7b737d624 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -188,7 +188,7 @@ do_comment( IOBUF out, int ctb, PKT_comment *rem ) if( !opt.no_comment ) { write_header(out, ctb, rem->len); if( iobuf_write( out, rem->data, rem->len ) ) - return G10ERR_WRITE_FILE; + return GPGERR_WRITE_FILE; } return 0; } @@ -198,7 +198,7 @@ do_user_id( IOBUF out, int ctb, PKT_user_id *uid ) { write_header(out, ctb, uid->len); if( iobuf_write( out, uid->name, uid->len ) ) - return G10ERR_WRITE_FILE; + return GPGERR_WRITE_FILE; return 0; } @@ -231,7 +231,7 @@ do_public_key( IOBUF out, int ctb, PKT_public_key *pk ) write_header2(out, ctb, iobuf_get_temp_length(a), pk->hdrbytes, 1 ); if( iobuf_write_temp( out, a ) ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; iobuf_close(a); return rc; @@ -262,7 +262,7 @@ hash_public_key( GCRY_MD_HD md, PKT_public_key *pk ) pkt.pkttype = PKT_PUBLIC_KEY; pkt.pkt.public_key = pk; if( (rc = build_packet( a, &pkt )) ) - log_fatal("build public_key for hashing failed: %s\n", g10_errstr(rc)); + log_fatal("build public_key for hashing failed: %s\n", gpg_errstr(rc)); if( !(pk->version == 3 && pk->pubkey_algo == 16) ) { /* skip the constructed header but don't do this for our very old @@ -385,7 +385,7 @@ do_secret_key( IOBUF out, int ctb, PKT_secret_key *sk ) leave: write_header2(out, ctb, iobuf_get_temp_length(a), sk->hdrbytes, 1 ); if( iobuf_write_temp( out, a ) ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; iobuf_close(a); return rc; @@ -416,7 +416,7 @@ do_symkey_enc( IOBUF out, int ctb, PKT_symkey_enc *enc ) write_header(out, ctb, iobuf_get_temp_length(a) ); if( iobuf_write_temp( out, a ) ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; iobuf_close(a); return rc; @@ -450,7 +450,7 @@ do_pubkey_enc( IOBUF out, int ctb, PKT_pubkey_enc *enc ) write_header(out, ctb, iobuf_get_temp_length(a) ); if( iobuf_write_temp( out, a ) ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; iobuf_close(a); return rc; @@ -479,12 +479,12 @@ do_plaintext( IOBUF out, int ctb, PKT_plaintext *pt ) for(i=0; i < pt->namelen; i++ ) iobuf_put(out, pt->name[i] ); if( write_32(out, pt->timestamp ) ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; n = 0; while( (nbytes=iobuf_read(pt->buf, buf, 1000)) != -1 ) { if( iobuf_write(out, buf, nbytes) == -1 ) { - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; break; } n += nbytes; @@ -797,7 +797,7 @@ do_signature( IOBUF out, int ctb, PKT_signature *sig ) else write_header(out, ctb, iobuf_get_temp_length(a) ); if( iobuf_write_temp( out, a ) ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; iobuf_close(a); return rc; @@ -820,7 +820,7 @@ do_onepass_sig( IOBUF out, int ctb, PKT_onepass_sig *ops ) write_header(out, ctb, iobuf_get_temp_length(a) ); if( iobuf_write_temp( out, a ) ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; iobuf_close(a); return rc; diff --git a/g10/cipher.c b/g10/cipher.c index 48dde31cc..8fc0d3815 100644 --- a/g10/cipher.c +++ b/g10/cipher.c @@ -128,7 +128,7 @@ cipher_filter( void *opaque, int control, if( rc ) log_fatal("encrypt failed: %s\n", gcry_strerror(rc) ); if( iobuf_write( a, buf, size ) ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; } else if( control == IOBUFCTRL_FREE ) { if( cfx->mdc_hash ) { @@ -139,7 +139,7 @@ cipher_filter( void *opaque, int control, if( rc ) log_fatal("encrypt failed: %s\n", gcry_strerror(rc) ); if( iobuf_write( a, hash, hashlen ) ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; gcry_md_close( cfx->mdc_hash ); cfx->mdc_hash = NULL; } gcry_cipher_close(cfx->cipher_hd); diff --git a/g10/comment.c b/g10/comment.c index f0abd0bac..fe80a1cf8 100644 --- a/g10/comment.c +++ b/g10/comment.c @@ -56,7 +56,7 @@ write_comment( IOBUF out, const char *s ) strcpy(pkt.pkt.comment->data, s); } if( (rc = build_packet( out, &pkt )) ) - log_error("build_packet(comment) failed: %s\n", g10_errstr(rc) ); + log_error("build_packet(comment) failed: %s\n", gpg_errstr(rc) ); free_packet( &pkt ); return rc; } diff --git a/g10/compress.c b/g10/compress.c index 478da5684..48335ba89 100644 --- a/g10/compress.c +++ b/g10/compress.c @@ -96,7 +96,7 @@ do_compress( compress_filter_context_t *zfx, z_stream *zs, int flush, IOBUF a ) if( iobuf_write( a, zfx->outbuf, n ) ) { log_debug("deflate: iobuf_write failed\n"); - return G10ERR_WRITE_FILE; + return GPGERR_WRITE_FILE; } } while( zs->avail_in || (flush == Z_FINISH && zrc != Z_STREAM_END) ); return 0; @@ -264,7 +264,7 @@ handle_compressed( void *procctx, PKT_compressed *cd, memset( &cfx, 0, sizeof cfx ); if( cd->algorithm < 1 || cd->algorithm > 2 ) - return G10ERR_COMPR_ALGO; + return GPGERR_COMPR_ALGO; cfx.algo = cd->algorithm; iobuf_push_filter( cd->buf, compress_filter, &cfx ); diff --git a/g10/dearmor.c b/g10/dearmor.c index 70255629c..1c0a15bc6 100644 --- a/g10/dearmor.c +++ b/g10/dearmor.c @@ -52,7 +52,7 @@ dearmor_file( const char *fname ) if( !(inp = iobuf_open(fname)) ) { log_error("can't open %s: %s\n", fname? fname: "[stdin]", strerror(errno) ); - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } @@ -94,7 +94,7 @@ enarmor_file( const char *fname ) if( !(inp = iobuf_open(fname)) ) { log_error("can't open %s: %s\n", fname? fname: "[stdin]", strerror(errno) ); - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } diff --git a/g10/decrypt.c b/g10/decrypt.c index c742a92d4..e9f1d2b93 100644 --- a/g10/decrypt.c +++ b/g10/decrypt.c @@ -57,7 +57,7 @@ decrypt_message( const char *filename ) fp = iobuf_open(filename); if( !fp ) { log_error(_("can't open `%s'\n"), print_fname_stdin(filename)); - return G10ERR_OPEN_FILE; + return GPGERR_OPEN_FILE; } if( !opt.no_armor ) { diff --git a/g10/delkey.c b/g10/delkey.c index 9de3a7b08..c452567a8 100644 --- a/g10/delkey.c +++ b/g10/delkey.c @@ -68,7 +68,7 @@ delete_key( const char *username, int secret ) /* read the keyblock */ rc = read_keyblock( &kbpos, &keyblock ); if( rc ) { - log_error("%s: read problem: %s\n", username, g10_errstr(rc) ); + log_error("%s: read problem: %s\n", username, gpg_errstr(rc) ); goto leave; } @@ -76,7 +76,7 @@ delete_key( const char *username, int secret ) node = find_kbnode( keyblock, secret? PKT_SECRET_KEY:PKT_PUBLIC_KEY ); if( !node ) { log_error("Oops; key not found anymore!\n"); - rc = G10ERR_GENERAL; + rc = GPGERR_GENERAL; goto leave; } @@ -95,8 +95,8 @@ delete_key( const char *username, int secret ) "use option \"--delete-secret-key\" to delete it first.\n")); rc = -1; } - else if( rc != G10ERR_NO_SECKEY ) - log_error("%s: get secret key: %s\n", username, g10_errstr(rc) ); + else if( rc != GPGERR_NO_SECKEY ) + log_error("%s: get secret key: %s\n", username, gpg_errstr(rc) ); else rc = 0; } @@ -148,7 +148,7 @@ delete_key( const char *username, int secret ) if( okay ) { rc = delete_keyblock( &kbpos ); if( rc ) { - log_error("delete_keyblock failed: %s\n", g10_errstr(rc) ); + log_error("delete_keyblock failed: %s\n", gpg_errstr(rc) ); goto leave; } } diff --git a/g10/encode.c b/g10/encode.c index 736eba6f6..ed4b1df0f 100644 --- a/g10/encode.c +++ b/g10/encode.c @@ -61,7 +61,7 @@ pk_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey ) NULL )); } else - return G10ERR_PUBKEY_ALGO; + return GPGERR_PUBKEY_ALGO; /* put the data into a simple list */ s_data = gcry_sexp_new_mpi( data ); @@ -136,7 +136,7 @@ encode_simple( const char *filename, int mode ) if( !(inp = iobuf_open(filename)) ) { log_error(_("%s: can't open: %s\n"), filename? filename: "[stdin]", strerror(errno) ); - return G10ERR_OPEN_FILE; + return GPGERR_OPEN_FILE; } if( opt.textmode ) @@ -152,11 +152,11 @@ encode_simple( const char *filename, int mode ) opt.def_cipher_algo ? opt.def_cipher_algo : opt.s2k_cipher_algo , s2k, 2 ); if( !cfx.dek || !cfx.dek->keylen ) { - rc = G10ERR_PASSPHRASE; + rc = GPGERR_PASSPHRASE; gcry_free(cfx.dek); gcry_free(s2k); iobuf_close(inp); - log_error(_("error creating passphrase: %s\n"), g10_errstr(rc) ); + log_error(_("error creating passphrase: %s\n"), gpg_errstr(rc) ); return rc; } } @@ -186,7 +186,7 @@ encode_simple( const char *filename, int mode ) pkt.pkttype = PKT_SYMKEY_ENC; pkt.pkt.symkey_enc = enc; if( (rc = build_packet( out, &pkt )) ) - log_error("build symkey packet failed: %s\n", g10_errstr(rc) ); + log_error("build symkey packet failed: %s\n", gpg_errstr(rc) ); gcry_free(enc); } @@ -242,7 +242,7 @@ encode_simple( const char *filename, int mode ) /* do the work */ if (!opt.no_literal) { if( (rc = build_packet( out, &pkt )) ) - log_error("build_packet failed: %s\n", g10_errstr(rc) ); + log_error("build_packet failed: %s\n", gpg_errstr(rc) ); } else { /* user requested not to create a literal packet, @@ -251,8 +251,8 @@ encode_simple( const char *filename, int mode ) int bytes_copied; while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1) if (iobuf_write(out, copy_buffer, bytes_copied) == -1) { - rc = G10ERR_WRITE_FILE; - log_error("copying input to output failed: %s\n", g10_errstr(rc) ); + rc = GPGERR_WRITE_FILE; + log_error("copying input to output failed: %s\n", gpg_errstr(rc) ); break; } memset(copy_buffer, 0, 4096); /* burn buffer */ @@ -305,7 +305,7 @@ encode_crypt( const char *filename, STRLIST remusr ) if( !(inp = iobuf_open(filename)) ) { log_error(_("can't open %s: %s\n"), filename? filename: "[stdin]", strerror(errno) ); - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } else if( opt.verbose ) @@ -398,7 +398,7 @@ encode_crypt( const char *filename, STRLIST remusr ) /* do the work */ if (!opt.no_literal) { if( (rc = build_packet( out, &pkt )) ) - log_error("build_packet failed: %s\n", g10_errstr(rc) ); + log_error("build_packet failed: %s\n", gpg_errstr(rc) ); } else { /* user requested not to create a literal packet, so we copy the plain data */ @@ -406,8 +406,8 @@ encode_crypt( const char *filename, STRLIST remusr ) int bytes_copied; while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1) if (iobuf_write(out, copy_buffer, bytes_copied) == -1) { - rc = G10ERR_WRITE_FILE; - log_error("copying input to output failed: %s\n", g10_errstr(rc) ); + rc = GPGERR_WRITE_FILE; + log_error("copying input to output failed: %s\n", gpg_errstr(rc) ); break; } memset(copy_buffer, 0, 4096); /* burn buffer */ @@ -522,7 +522,7 @@ write_pubkey_enc_from_list( PK_LIST pk_list, DEK *dek, IOBUF out ) rc = pk_encrypt( pk->pubkey_algo, enc->data, frame, pk->pkey ); mpi_release( frame ); if( rc ) - log_error("pubkey_encrypt failed: %s\n", g10_errstr(rc) ); + log_error("pubkey_encrypt failed: %s\n", gpg_errstr(rc) ); else { if( opt.verbose ) { char *ustr = get_user_id_string( enc->keyid ); @@ -537,7 +537,7 @@ write_pubkey_enc_from_list( PK_LIST pk_list, DEK *dek, IOBUF out ) pkt.pkt.pubkey_enc = enc; rc = build_packet( out, &pkt ); if( rc ) - log_error("build_packet(pubkey_enc) failed: %s\n", g10_errstr(rc)); + log_error("build_packet(pubkey_enc) failed: %s\n", gpg_errstr(rc)); } free_pubkey_enc(enc); if( rc ) diff --git a/g10/encr-data.c b/g10/encr-data.c index 286475003..0f741b9ec 100644 --- a/g10/encr-data.c +++ b/g10/encr-data.c @@ -62,7 +62,7 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek ) if( gcry_cipher_test_algo( dek->algo ) ) { if( opt.verbose ) log_info(_("encrypted with unknown algorithm %d\n"), dek->algo ); - rc = G10ERR_CIPHER_ALGO; + rc = GPGERR_CIPHER_ALGO; goto leave; } if( opt.verbose ) @@ -129,7 +129,7 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek ) p = temp; /* log_hexdump( "prefix", temp, nprefix+2 ); */ if( p[nprefix-2] != p[nprefix] || p[nprefix-1] != p[nprefix+1] ) { - rc = G10ERR_BAD_KEY; + rc = GPGERR_BAD_KEY; goto leave; } if( ed->mdc_method ) @@ -139,12 +139,12 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek ) proc_packets( procctx, ed->buf); ed->buf = NULL; if( ed->mdc_method && dfx.eof_seen == 2 ) - rc = G10ERR_INVALID_PACKET; + rc = GPGERR_INVALID_PACKET; else if( ed->mdc_method ) { /* check the mdc */ int datalen = gcry_md_get_algo_dlen( ed->mdc_method ); if( datalen != 20 || memcmp(gcry_md_read( dfx.mdc_hash, 0 ), dfx.defer, datalen) ) - rc = G10ERR_BAD_SIGN; + rc = GPGERR_BAD_SIGN; log_hexdump("MDC calculated:", gcry_md_read( dfx.mdc_hash, 0), datalen); log_hexdump("MDC message :", dfx.defer, 20); } diff --git a/g10/export.c b/g10/export.c index 4021c050f..df81babf4 100644 --- a/g10/export.c +++ b/g10/export.c @@ -121,7 +121,7 @@ do_export_stream( IOBUF out, STRLIST users, int secret, int onlyrfc, int *any ) rc = enum_keyblocks( secret?5:0, &kbpos, &keyblock ); if( rc ) { if( rc != -1 ) - log_error("enum_keyblocks(open) failed: %s\n", g10_errstr(rc) ); + log_error("enum_keyblocks(open) failed: %s\n", gpg_errstr(rc) ); goto leave; } all = 2; @@ -135,7 +135,7 @@ do_export_stream( IOBUF out, STRLIST users, int secret, int onlyrfc, int *any ) if( rc == -1 ) /* EOF */ break; if( rc ) { - log_error("enum_keyblocks(read) failed: %s\n", g10_errstr(rc)); + log_error("enum_keyblocks(read) failed: %s\n", gpg_errstr(rc)); break; } } @@ -144,7 +144,7 @@ do_export_stream( IOBUF out, STRLIST users, int secret, int onlyrfc, int *any ) rc = secret? find_secret_keyblock_byname( &kbpos, sl->d ) : find_keyblock_byname( &kbpos, sl->d ); if( rc ) { - log_error(_("%s: user not found: %s\n"), sl->d, g10_errstr(rc)); + log_error(_("%s: user not found: %s\n"), sl->d, gpg_errstr(rc)); rc = 0; continue; } @@ -153,7 +153,7 @@ do_export_stream( IOBUF out, STRLIST users, int secret, int onlyrfc, int *any ) } if( rc ) { - log_error(_("certificate read problem: %s\n"), g10_errstr(rc)); + log_error(_("certificate read problem: %s\n"), gpg_errstr(rc)); goto leave; } @@ -185,8 +185,8 @@ do_export_stream( IOBUF out, STRLIST users, int secret, int onlyrfc, int *any ) if( (rc = build_packet( out, node->pkt )) ) { log_error("build_packet(%d) failed: %s\n", - node->pkt->pkttype, g10_errstr(rc) ); - rc = G10ERR_WRITE_FILE; + node->pkt->pkttype, gpg_errstr(rc) ); + rc = GPGERR_WRITE_FILE; goto leave; } } diff --git a/g10/filter.h b/g10/filter.h index c9ea2f394..389026d2c 100644 --- a/g10/filter.h +++ b/g10/filter.h @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_FILTER_H -#define G10_FILTER_H +#ifndef GPG_FILTER_H +#define GPG_FILTER_H #include <gcrypt.h> @@ -135,4 +135,4 @@ int copy_clearsig_text( IOBUF out, IOBUF inp, GCRY_MD_HD md, -#endif /*G10_FILTER_H*/ +#endif /*GPG_FILTER_H*/ diff --git a/g10/getkey.c b/g10/getkey.c index bf36fcb96..d0b9cc1dd 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -298,7 +298,7 @@ get_pubkey( PKT_public_key *pk, u32 *keyid ) keyid_list_t kl; for( kl = unknown_keyids; kl; kl = kl->next ) if( kl->keyid[0] == keyid[0] && kl->keyid[1] == keyid[1] ) - return G10ERR_NO_PUBKEY; /* already checked and not found */ + return GPGERR_NO_PUBKEY; /* already checked and not found */ } #endif @@ -354,7 +354,7 @@ get_pubkey( PKT_public_key *pk, u32 *keyid ) unknown_keyids = kl; } #endif - rc = G10ERR_NO_PUBKEY; + rc = GPGERR_NO_PUBKEY; leave: if( !rc ) @@ -444,7 +444,7 @@ get_primary_seckey( PKT_secret_key *sk, u32 *keyid ) /**************** * Check whether the secret key is available * Returns: 0 := key is available - * G10ERR_NO_SECKEY := not availabe + * GPGERR_NO_SECKEY := not availabe */ int seckey_available( u32 *keyid ) @@ -714,7 +714,7 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist, NULL ); if( !ctx->items[n].mode ) { gcry_free( ctx ); - return G10ERR_INV_USER_ID; + return GPGERR_INV_USER_ID; } if( ctx->items[n].mode == 6 ) { ctx->items[n].namebuf = prepare_word_match(ctx->items[n].name); @@ -831,7 +831,7 @@ get_pubkey_byfprint( PKT_public_key *pk, const byte *fprint, size_t fprint_len) get_pubkey_end( &ctx ); } else - rc = G10ERR_GENERAL; /* Oops */ + rc = GPGERR_GENERAL; /* Oops */ return rc; } @@ -857,7 +857,7 @@ get_keyblock_byfprint( KBNODE *ret_keyblock, const byte *fprint, get_pubkey_end( &ctx ); } else - rc = G10ERR_GENERAL; /* Oops */ + rc = GPGERR_GENERAL; /* Oops */ free_public_key( pk ); return rc; @@ -1531,7 +1531,7 @@ finish_lookup( KBNODE keyblock, PKT_public_key *pk, KBNODE k, byte *namehash, else { if( primary && pk->pubkey_usage && openpgp_pk_test_algo( k->pkt->pkt.public_key->pubkey_algo, - pk->pubkey_usage ) == G10ERR_WR_PUBKEY_ALGO ) { + pk->pubkey_usage ) == GPGERR_WR_PUBKEY_ALGO ) { /* if the usage is not correct, try to use a subkey */ KBNODE save_k = k; @@ -1587,7 +1587,7 @@ finish_lookup_sk( KBNODE keyblock, PKT_secret_key *sk, KBNODE k, int primary ) else { if( primary && sk->pubkey_usage && openpgp_pk_test_algo( k->pkt->pkt.secret_key->pubkey_algo, - sk->pubkey_usage ) == G10ERR_WR_PUBKEY_ALGO ) { + sk->pubkey_usage ) == GPGERR_WR_PUBKEY_ALGO ) { /* if the usage is not correct, try to use a subkey */ KBNODE save_k = k; @@ -1679,7 +1679,7 @@ lookup_pk( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock ) found: ; } if( rc && rc != -1 ) - log_error("enum_keyblocks failed: %s\n", g10_errstr(rc)); + log_error("enum_keyblocks failed: %s\n", gpg_errstr(rc)); if( !rc ) { if( ret_keyblock ) { @@ -1688,7 +1688,7 @@ lookup_pk( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock ) } } else if( rc == -1 ) - rc = G10ERR_NO_PUBKEY; + rc = GPGERR_NO_PUBKEY; release_kbnode( ctx->keyblock ); ctx->keyblock = NULL; @@ -1706,7 +1706,7 @@ lookup_pk( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock ) lkup_stats[ctx->mode].any = 1; if( !rc ) lkup_stats[ctx->mode].okay_count++; - else if ( rc == G10ERR_NO_PUBKEY ) + else if ( rc == GPGERR_NO_PUBKEY ) lkup_stats[ctx->mode].nokey_count++; else lkup_stats[ctx->mode].error_count++; @@ -1765,7 +1765,7 @@ lookup_sk( GETKEY_CTX ctx, PKT_secret_key *sk, KBNODE *ret_keyblock ) found: ; } if( rc && rc != -1 ) - log_error("enum_keyblocks failed: %s\n", g10_errstr(rc)); + log_error("enum_keyblocks failed: %s\n", gpg_errstr(rc)); if( !rc ) { if( ret_keyblock ) { @@ -1774,7 +1774,7 @@ lookup_sk( GETKEY_CTX ctx, PKT_secret_key *sk, KBNODE *ret_keyblock ) } } else if( rc == -1 ) - rc = G10ERR_NO_SECKEY; + rc = GPGERR_NO_SECKEY; release_kbnode( ctx->keyblock ); ctx->keyblock = NULL; @@ -1,5 +1,5 @@ -/* g10.c - The GnuPG utility (main for gpg) - * Copyright (C) 1998, 1999 Free Software Foundation, Inc. +/* gpg.c - The GnuPG utility (main for gpg) + * Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -39,7 +39,7 @@ #include "ttyio.h" #include "i18n.h" #include "status.h" -#include "g10defs.h" +#include "gnupg-defs.h" #include "hkp.h" @@ -344,7 +344,7 @@ static ARGPARSE_OPTS opts[] = { -int g10_errors_seen = 0; +int gpg_errors_seen = 0; static int utf8_strings = 0; static int maybe_setuid = 1; @@ -457,7 +457,7 @@ i18n_init(void) #else setlocale( LC_ALL, "" ); #endif - bindtextdomain( PACKAGE, G10_LOCALEDIR ); + bindtextdomain( PACKAGE, GNUPG_LOCALEDIR ); textdomain( PACKAGE ); #endif #endif @@ -469,7 +469,7 @@ wrong_args( const char *text) fputs(_("usage: gpg [options] "),stderr); fputs(text,stderr); putc('\n',stderr); - g10_exit(2); + gpg_exit(2); } @@ -547,7 +547,7 @@ set_cmd( enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd ) cmd = aClearsign; else { log_error(_("conflicting commands\n")); - g10_exit(2); + gpg_exit(2); } *ret_cmd = cmd; @@ -696,7 +696,7 @@ main( int argc, char **argv ) else { log_error(_("option file `%s': %s\n"), configname, strerror(errno) ); - g10_exit(2); + gpg_exit(2); } gcry_free(configname); configname = NULL; } @@ -933,7 +933,7 @@ main( int argc, char **argv ) } gcry_free( configname ); configname = NULL; if( log_get_errorcount(0) ) - g10_exit(2); + gpg_exit(2); if( nogreeting ) greeting = 0; @@ -969,7 +969,7 @@ main( int argc, char **argv ) set_debug(); /* FIXME: should set filenames of libgcrypt explicitly - * g10_opt_homedir = opt.homedir; */ + * gpg_opt_homedir = opt.homedir; */ /* must do this after dropping setuid, because string_to... * may try to load a module */ @@ -1020,7 +1020,7 @@ main( int argc, char **argv ) if( log_get_errorcount(0) ) - g10_exit(2); + gpg_exit(2); if( !cmd && opt.fingerprint && !with_fpr ) set_cmd( &cmd, aListKeys); @@ -1092,7 +1092,7 @@ main( int argc, char **argv ) default: rc = setup_trustdb(1, trustdb_name ); break; } if( rc ) - log_error(_("failed to initialize the TrustDB: %s\n"), g10_errstr(rc)); + log_error(_("failed to initialize the TrustDB: %s\n"), gpg_errstr(rc)); switch( cmd ) { @@ -1101,21 +1101,21 @@ main( int argc, char **argv ) wrong_args(_("--store [filename]")); if( (rc = encode_store(fname)) ) log_error_f( print_fname_stdin(fname), - "store failed: %s\n", g10_errstr(rc) ); + "store failed: %s\n", gpg_errstr(rc) ); break; case aSym: /* encrypt the given file only with the symmetric cipher */ if( argc > 1 ) wrong_args(_("--symmetric [filename]")); if( (rc = encode_symmetric(fname)) ) log_error_f(print_fname_stdin(fname), - "symmetric encryption failed: %s\n",g10_errstr(rc) ); + "symmetric encryption failed: %s\n",gpg_errstr(rc) ); break; case aEncr: /* encrypt the given file */ if( argc > 1 ) wrong_args(_("--encrypt [filename]")); if( (rc = encode_crypt(fname,remusr)) ) - log_error("%s: encryption failed: %s\n", print_fname_stdin(fname), g10_errstr(rc) ); + log_error("%s: encryption failed: %s\n", print_fname_stdin(fname), gpg_errstr(rc) ); break; case aSign: /* sign the given file */ @@ -1133,7 +1133,7 @@ main( int argc, char **argv ) } } if( (rc = sign_file( sl, detached_sig, locusr, 0, NULL, NULL)) ) - log_error("signing failed: %s\n", g10_errstr(rc) ); + log_error("signing failed: %s\n", gpg_errstr(rc) ); free_strlist(sl); break; @@ -1147,7 +1147,7 @@ main( int argc, char **argv ) else sl = NULL; if( (rc = sign_file(sl, detached_sig, locusr, 1, remusr, NULL)) ) - log_error("%s: sign+encrypt failed: %s\n", print_fname_stdin(fname), g10_errstr(rc) ); + log_error("%s: sign+encrypt failed: %s\n", print_fname_stdin(fname), gpg_errstr(rc) ); free_strlist(sl); break; @@ -1155,19 +1155,19 @@ main( int argc, char **argv ) if( argc > 1 ) wrong_args(_("--clearsign [filename]")); if( (rc = clearsign_file(fname, locusr, NULL)) ) - log_error("%s: clearsign failed: %s\n", print_fname_stdin(fname), g10_errstr(rc) ); + log_error("%s: clearsign failed: %s\n", print_fname_stdin(fname), gpg_errstr(rc) ); break; case aVerify: if( (rc = verify_signatures( argc, argv ) )) - log_error("verify signatures failed: %s\n", g10_errstr(rc) ); + log_error("verify signatures failed: %s\n", gpg_errstr(rc) ); break; case aDecrypt: if( argc > 1 ) wrong_args(_("--decrypt [filename]")); if( (rc = decrypt_message( fname ) )) - log_error("decrypt_message failed: %s\n", g10_errstr(rc) ); + log_error("decrypt_message failed: %s\n", gpg_errstr(rc) ); break; @@ -1211,7 +1211,7 @@ main( int argc, char **argv ) wrong_args(_("--delete-key user-id")); username = make_username( fname ); if( (rc = delete_key(username, cmd==aDeleteSecretKey)) ) - log_error("%s: delete key failed: %s\n", username, g10_errstr(rc) ); + log_error("%s: delete key failed: %s\n", username, gpg_errstr(rc) ); gcry_free(username); break; @@ -1258,13 +1258,13 @@ main( int argc, char **argv ) if( !argc ) { rc = import_keys( NULL, (cmd == aFastImport) ); if( rc ) - log_error("import failed: %s\n", g10_errstr(rc) ); + log_error("import failed: %s\n", gpg_errstr(rc) ); } for( ; argc; argc--, argv++ ) { rc = import_keys( *argv, (cmd == aFastImport) ); if( rc ) log_error("import from `%s' failed: %s\n", - *argv, g10_errstr(rc) ); + *argv, gpg_errstr(rc) ); } break; @@ -1305,7 +1305,7 @@ main( int argc, char **argv ) wrong_args("--dearmor [file]"); rc = dearmor_file( argc? *argv: NULL ); if( rc ) - log_error(_("dearmoring failed: %s\n"), g10_errstr(rc)); + log_error(_("dearmoring failed: %s\n"), gpg_errstr(rc)); break; case aEnArmor: @@ -1313,7 +1313,7 @@ main( int argc, char **argv ) wrong_args("--enarmor [file]"); rc = enarmor_file( argc? *argv: NULL ); if( rc ) - log_error(_("enarmoring failed: %s\n"), g10_errstr(rc)); + log_error(_("enarmoring failed: %s\n"), gpg_errstr(rc)); break; @@ -1486,7 +1486,7 @@ main( int argc, char **argv ) } rc = proc_packets(NULL, a ); if( rc ) - log_error("processing message failed: %s\n", g10_errstr(rc) ); + log_error("processing message failed: %s\n", gpg_errstr(rc) ); iobuf_close(a); } break; @@ -1495,13 +1495,13 @@ main( int argc, char **argv ) /* cleanup */ FREE_STRLIST(remusr); FREE_STRLIST(locusr); - g10_exit(0); + gpg_exit(0); return 8; /*NEVER REACHED*/ } void -g10_exit( int rc ) +gpg_exit( int rc ) { if( opt.debug & DBG_MEMSTAT_VALUE ) { gcry_control( GCRYCTL_DUMP_MEMORY_STATS ); @@ -1511,7 +1511,7 @@ g10_exit( int rc ) gcry_control( GCRYCTL_DUMP_SECMEM_STATS ); gcry_control( GCRYCTL_TERM_SECMEM ); rc = rc? rc : log_get_errorcount(0)? 2 : - g10_errors_seen? 1 : 0; + gpg_errors_seen? 1 : 0; /*write_status( STATUS_LEAVE );*/ exit(rc ); } diff --git a/g10/gpgd.c b/g10/gpgd.c index 50eb7db59..a11a6aacf 100644 --- a/g10/gpgd.c +++ b/g10/gpgd.c @@ -138,7 +138,7 @@ set_debug(void) if( opt.debug & DBG_MPI_VALUE ) mpi_debug_mode = 1; if( opt.debug & DBG_CIPHER_VALUE ) - g10c_debug_mode = 1; + gpgc_debug_mode = 1; if( opt.debug & DBG_IOBUF_VALUE ) iobuf_debug_mode = 1; } @@ -201,7 +201,7 @@ main( int argc, char **argv ) else { log_error("option file `%s': %s\n", configname, strerror(errno) ); - g10_exit(1); + gpg_exit(1); } gcry_free(configname); configname = NULL; } @@ -235,7 +235,7 @@ main( int argc, char **argv ) } gcry_free( configname ); configname = NULL; if( log_get_errorcount(0) ) - g10_exit(2); + gpg_exit(2); fprintf(stderr, "%s %s; %s\n", strusage(11), strusage(13), strusage(14) ); fprintf(stderr, "%s\n", strusage(15) ); @@ -245,13 +245,13 @@ main( int argc, char **argv ) become_daemon(); - g10_exit(0); + gpg_exit(0); return 8; /*NEVER REACHED*/ } void -g10_exit( int rc ) +gpg_exit( int rc ) { secmem_term(); rc = rc? rc : log_get_errorcount(0)? 2:0; @@ -69,8 +69,8 @@ hkp_ask_import( u32 *keyid ) rc = http_open_document( &hd, request, 0 ); if( rc ) { log_info("can't get key from keyserver: %s\n", - rc == G10ERR_NETWORK? strerror(errno) - : g10_errstr(rc) ); + rc == GPGERR_NETWORK? strerror(errno) + : gpg_errstr(rc) ); } else { rc = import_keys_stream( hd.fp_read , 0 ); @@ -147,8 +147,8 @@ hkp_export( STRLIST users ) if( rc ) { log_error("can't connect to `%s': %s\n", opt.keyserver_name, - rc == G10ERR_NETWORK? strerror(errno) - : g10_errstr(rc) ); + rc == GPGERR_NETWORK? strerror(errno) + : gpg_errstr(rc) ); iobuf_close(temp); gcry_free( request ); return rc; @@ -170,7 +170,7 @@ hkp_export( STRLIST users ) rc = http_wait_response( &hd, &status ); if( rc ) { log_error("error sending to `%s': %s\n", - opt.keyserver_name, g10_errstr(rc) ); + opt.keyserver_name, gpg_errstr(rc) ); } else { #if 1 @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_HKP_H -#define G10_HKP_H 1 +#ifndef GPG_HKP_H +#define GPG_HKP_H 1 int hkp_ask_import( u32 *keyid ); @@ -27,4 +27,4 @@ int hkp_import( STRLIST users ); int hkp_export( STRLIST users ); -#endif /*G10_HKP_H*/ +#endif /*GPG_HKP_H*/ diff --git a/g10/import.c b/g10/import.c index 01f70dbd4..731351275 100644 --- a/g10/import.c +++ b/g10/import.c @@ -116,7 +116,7 @@ import_keys( const char *fname, int fast ) fname = "[stdin]"; if( !inp ) { log_error(_("can't open `%s': %s\n"), fname, strerror(errno) ); - return G10ERR_OPEN_FILE; + return GPGERR_OPEN_FILE; } rc = import( inp, fast, fname ); @@ -170,8 +170,8 @@ import( IOBUF inp, int fast, const char* fname ) } if( rc == -1 ) rc = 0; - else if( rc && rc != G10ERR_INV_KEYRING ) - log_error( _("error reading `%s': %s\n"), fname, g10_errstr(rc)); + else if( rc && rc != GPGERR_INV_KEYRING ) + log_error( _("error reading `%s': %s\n"), fname, gpg_errstr(rc)); if( !opt.quiet ) { log_info(_("Total number processed: %lu\n"), count ); @@ -248,9 +248,9 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root ) init_packet(pkt); while( (rc=parse_packet(a, pkt)) != -1 ) { if( rc ) { /* ignore errors */ - if( rc != G10ERR_UNKNOWN_PACKET ) { - log_error("read_block: read error: %s\n", g10_errstr(rc) ); - rc = G10ERR_INV_KEYRING; + if( rc != GPGERR_UNKNOWN_PACKET ) { + log_error("read_block: read error: %s\n", gpg_errstr(rc) ); + rc = GPGERR_INV_KEYRING; goto ready; } free_packet( pkt ); @@ -272,7 +272,7 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root ) case PKT_COMPRESSED: if( pkt->pkt.compressed->algorithm < 1 || pkt->pkt.compressed->algorithm > 2 ) { - rc = G10ERR_COMPR_ALGO; + rc = GPGERR_COMPR_ALGO; goto ready; } { @@ -324,7 +324,7 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root ) * Try to import one keyblock. Return an error only in serious cases, but * never for an invalid keyblock. It uses log_error to increase the * internal errorcount, so that invalid input can be detected by programs - * which called g10. + * which called gpg. */ static int import_one( const char *fname, KBNODE keyblock, int fast ) @@ -385,25 +385,25 @@ import_one( const char *fname, KBNODE keyblock, int fast ) /* do we have this key already in one of our pubrings ? */ pk_orig = gcry_xcalloc( 1, sizeof *pk_orig ); rc = get_pubkey( pk_orig, keyid ); - if( rc && rc != G10ERR_NO_PUBKEY ) { + if( rc && rc != GPGERR_NO_PUBKEY ) { log_error( _("key %08lX: public key not found: %s\n"), - (ulong)keyid[1], g10_errstr(rc)); + (ulong)keyid[1], gpg_errstr(rc)); } else if( rc ) { /* insert this key */ /* get default resource */ if( get_keyblock_handle( NULL, 0, &kbpos ) ) { log_error(_("no default public keyring\n")); - return G10ERR_GENERAL; + return GPGERR_GENERAL; } if( opt.verbose > 1 ) log_info( _("writing to `%s'\n"), keyblock_resource_name(&kbpos) ); if( (rc=lock_keyblock( &kbpos )) ) log_error(_("can't lock keyring `%s': %s\n"), - keyblock_resource_name(&kbpos), g10_errstr(rc) ); + keyblock_resource_name(&kbpos), gpg_errstr(rc) ); else if( (rc=insert_keyblock( &kbpos, keyblock )) ) log_error( _("error writing keyring `%s': %s\n"), - keyblock_resource_name(&kbpos), g10_errstr(rc) ); + keyblock_resource_name(&kbpos), gpg_errstr(rc) ); unlock_keyblock( &kbpos ); /* we are ready */ if( !opt.quiet ) @@ -426,7 +426,7 @@ import_one( const char *fname, KBNODE keyblock, int fast ) if( cmp_public_keys( pk_orig, pk ) ) { log_error( _("key %08lX: doesn't match our copy\n"), (ulong)keyid[1]); - rc = G10ERR_GENERAL; + rc = GPGERR_GENERAL; goto leave; } @@ -434,13 +434,13 @@ import_one( const char *fname, KBNODE keyblock, int fast ) rc = find_keyblock_bypk( &kbpos, pk_orig ); if( rc ) { log_error( _("key %08lX: can't locate original keyblock: %s\n"), - (ulong)keyid[1], g10_errstr(rc)); + (ulong)keyid[1], gpg_errstr(rc)); goto leave; } rc = read_keyblock( &kbpos, &keyblock_orig ); if( rc ) { log_error( _("key %08lX: can't read original keyblock: %s\n"), - (ulong)keyid[1], g10_errstr(rc)); + (ulong)keyid[1], gpg_errstr(rc)); goto leave; } @@ -458,10 +458,10 @@ import_one( const char *fname, KBNODE keyblock, int fast ) /* keyblock_orig has been updated; write */ if( (rc=lock_keyblock( &kbpos )) ) log_error( _("can't lock keyring `%s': %s\n"), - keyblock_resource_name(&kbpos), g10_errstr(rc) ); + keyblock_resource_name(&kbpos), gpg_errstr(rc) ); else if( (rc=update_keyblock( &kbpos, keyblock_orig )) ) log_error( _("error writing keyring `%s': %s\n"), - keyblock_resource_name(&kbpos), g10_errstr(rc) ); + keyblock_resource_name(&kbpos), gpg_errstr(rc) ); unlock_keyblock( &kbpos ); /* we are ready */ if( !opt.quiet ) { @@ -498,12 +498,12 @@ import_one( const char *fname, KBNODE keyblock, int fast ) if( !rc && !fast ) { rc = query_trust_record( new_key? pk : pk_orig ); if( rc && rc != -1 ) - log_error("trustdb error: %s\n", g10_errstr(rc) ); + log_error("trustdb error: %s\n", gpg_errstr(rc) ); else if( rc == -1 ) { /* not found trustdb */ rc = insert_trust_record( new_key? keyblock : keyblock_orig ); if( rc ) log_error("key %08lX: trustdb insert failed: %s\n", - (ulong)keyid[1], g10_errstr(rc) ); + (ulong)keyid[1], gpg_errstr(rc) ); } else if( mod_key ) rc = update_trust_record( keyblock_orig, 1, NULL ); @@ -559,18 +559,18 @@ import_secret_one( const char *fname, KBNODE keyblock ) /* do we have this key already in one of our secrings ? */ rc = seckey_available( keyid ); - if( rc == G10ERR_NO_SECKEY ) { /* simply insert this key */ + if( rc == GPGERR_NO_SECKEY ) { /* simply insert this key */ /* get default resource */ if( get_keyblock_handle( NULL, 1, &kbpos ) ) { log_error("no default secret keyring\n"); - return G10ERR_GENERAL; + return GPGERR_GENERAL; } if( (rc=lock_keyblock( &kbpos )) ) log_error( _("can't lock keyring `%s': %s\n"), - keyblock_resource_name(&kbpos), g10_errstr(rc) ); + keyblock_resource_name(&kbpos), gpg_errstr(rc) ); else if( (rc=insert_keyblock( &kbpos, keyblock )) ) log_error( _("error writing keyring `%s': %s\n"), - keyblock_resource_name(&kbpos), g10_errstr(rc) ); + keyblock_resource_name(&kbpos), gpg_errstr(rc) ); unlock_keyblock( &kbpos ); /* we are ready */ if( !opt.quiet ) @@ -584,7 +584,7 @@ import_secret_one( const char *fname, KBNODE keyblock ) } else log_error( _("key %08lX: secret key not found: %s\n"), - (ulong)keyid[1], g10_errstr(rc)); + (ulong)keyid[1], gpg_errstr(rc)); return rc; } @@ -611,7 +611,7 @@ import_revoke_cert( const char *fname, KBNODE node ) pk = gcry_xcalloc( 1, sizeof *pk ); rc = get_pubkey( pk, keyid ); - if( rc == G10ERR_NO_PUBKEY ) { + if( rc == GPGERR_NO_PUBKEY ) { log_info( _("key %08lX: no public key - " "can't apply revocation certificate\n"), (ulong)keyid[1]); rc = 0; @@ -619,7 +619,7 @@ import_revoke_cert( const char *fname, KBNODE node ) } else if( rc ) { log_error( _("key %08lX: public key not found: %s\n"), - (ulong)keyid[1], g10_errstr(rc)); + (ulong)keyid[1], gpg_errstr(rc)); goto leave; } @@ -627,13 +627,13 @@ import_revoke_cert( const char *fname, KBNODE node ) rc = find_keyblock_bypk( &kbpos, pk ); if( rc ) { log_error( _("key %08lX: can't locate original keyblock: %s\n"), - (ulong)keyid[1], g10_errstr(rc)); + (ulong)keyid[1], gpg_errstr(rc)); goto leave; } rc = read_keyblock( &kbpos, &keyblock ); if( rc ) { log_error( _("key %08lX: can't read original keyblock: %s\n"), - (ulong)keyid[1], g10_errstr(rc)); + (ulong)keyid[1], gpg_errstr(rc)); goto leave; } @@ -644,7 +644,7 @@ import_revoke_cert( const char *fname, KBNODE node ) rc = check_key_signature( keyblock, node, NULL); if( rc ) { log_error( _("key %08lX: invalid revocation certificate" - ": %s - rejected\n"), (ulong)keyid[1], g10_errstr(rc)); + ": %s - rejected\n"), (ulong)keyid[1], gpg_errstr(rc)); } @@ -668,10 +668,10 @@ import_revoke_cert( const char *fname, KBNODE node ) /* and write the keyblock back */ if( (rc=lock_keyblock( &kbpos )) ) log_error( _("can't lock keyring `%s': %s\n"), - keyblock_resource_name(&kbpos), g10_errstr(rc) ); + keyblock_resource_name(&kbpos), gpg_errstr(rc) ); else if( (rc=update_keyblock( &kbpos, keyblock )) ) log_error( _("error writing keyring `%s': %s\n"), - keyblock_resource_name(&kbpos), g10_errstr(rc) ); + keyblock_resource_name(&kbpos), gpg_errstr(rc) ); unlock_keyblock( &kbpos ); /* we are ready */ if( !opt.quiet ) @@ -714,7 +714,7 @@ chk_self_sigs( const char *fname, KBNODE keyblock, } rc = check_key_signature( keyblock, n, NULL); if( rc ) { - log_info( rc == G10ERR_PUBKEY_ALGO ? + log_info( rc == GPGERR_PUBKEY_ALGO ? _("key %08lX: unsupported public key algorithm\n"): _("key %08lX: invalid self-signature\n"), (ulong)keyid[1]); @@ -738,7 +738,7 @@ chk_self_sigs( const char *fname, KBNODE keyblock, else { rc = check_key_signature( keyblock, n, NULL); if( rc ) { - log_info( rc == G10ERR_PUBKEY_ALGO ? + log_info( rc == GPGERR_PUBKEY_ALGO ? _("key %08lX: unsupported public key algorithm\n"): _("key %08lX: invalid subkey binding\n"), (ulong)keyid[1]); @@ -862,7 +862,7 @@ delete_inv_parts( const char *fname, KBNODE keyblock, u32 *keyid ) if( rc ) { log_error( _("key %08lX: invalid revocation " "certificate: %s - skipped\n"), - (ulong)keyid[1], g10_errstr(rc)); + (ulong)keyid[1], gpg_errstr(rc)); delete_kbnode( node ); } } @@ -1127,7 +1127,7 @@ append_uid( KBNODE keyblock, KBNODE node, int *n_sigs, if( !node->next || node->next->pkt->pkttype == PKT_USER_ID ) { log_error( _("key %08lX: our copy has no self-signature\n"), (ulong)keyid[1]); - return G10ERR_GENERAL; + return GPGERR_GENERAL; } /* find the position */ diff --git a/g10/keydb.h b/g10/keydb.h index fe4f8be94..221c01c64 100644 --- a/g10/keydb.h +++ b/g10/keydb.h @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_KEYDB_H -#define G10_KEYDB_H +#ifndef GPG_KEYDB_H +#define GPG_KEYDB_H #ifdef HAVE_LIBGDBM #include <gdbm.h> @@ -214,4 +214,4 @@ int delete_keyblock( KBPOS *kbpos ); int update_keyblock( KBPOS *kbpos, KBNODE root ); -#endif /*G10_KEYDB_H*/ +#endif /*GPG_KEYDB_H*/ diff --git a/g10/keyedit.c b/g10/keyedit.c index 74f97aa95..fdb8bf6ad 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -97,7 +97,7 @@ get_keyblock_byname( KBNODE *keyblock, KBPOS *kbpos, const char *username ) /* read the keyblock */ rc = read_keyblock( kbpos, keyblock ); if( rc ) - log_error("%s: keyblock read problem: %s\n", username, g10_errstr(rc)); + log_error("%s: keyblock read problem: %s\n", username, gpg_errstr(rc)); else merge_keys_and_selfsig( *keyblock ); @@ -123,13 +123,13 @@ print_and_check_one_sig( KBNODE keyblock, KBNODE node, node->flag &= ~(NODFLG_BADSIG|NODFLG_NOKEY|NODFLG_SIGERR); sigrc = '!'; break; - case G10ERR_BAD_SIGN: + case GPGERR_BAD_SIGN: node->flag = NODFLG_BADSIG; sigrc = '-'; if( inv_sigs ) ++*inv_sigs; break; - case G10ERR_NO_PUBKEY: + case GPGERR_NO_PUBKEY: node->flag = NODFLG_NOKEY; sigrc = '?'; if( no_key ) @@ -147,7 +147,7 @@ print_and_check_one_sig( KBNODE keyblock, KBNODE node, is_rev? "rev":"sig", sigrc, sig->keyid[1], datestr_from_sig(sig)); if( sigrc == '%' ) - tty_printf("[%s] ", g10_errstr(rc) ); + tty_printf("[%s] ", gpg_errstr(rc) ); else if( sigrc == '?' ) ; else if( *is_selfsig ) { @@ -367,7 +367,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified, int local ) sign_uid_mk_attrib, &attrib ); if( rc ) { - log_error(_("signing failed: %s\n"), g10_errstr(rc)); + log_error(_("signing failed: %s\n"), gpg_errstr(rc)); goto leave; } *ret_modified = 1; /* we changed the keyblock */ @@ -417,7 +417,7 @@ change_passphrase( KBNODE keyblock ) switch( is_secret_key_protected( sk ) ) { case -1: - rc = G10ERR_PUBKEY_ALGO; + rc = GPGERR_PUBKEY_ALGO; break; case 0: tty_printf(_("This key is not protected.\n")); @@ -440,7 +440,7 @@ change_passphrase( KBNODE keyblock ) } if( rc ) - tty_printf(_("Can't edit this key: %s\n"), g10_errstr(rc)); + tty_printf(_("Can't edit this key: %s\n"), gpg_errstr(rc)); else { DEK *dek = NULL; STRING2KEY *s2k = gcry_xmalloc_secure( sizeof *s2k ); @@ -477,7 +477,7 @@ change_passphrase( KBNODE keyblock ) } } if( rc ) - log_error("protect_secret_key failed: %s\n", g10_errstr(rc) ); + log_error("protect_secret_key failed: %s\n", gpg_errstr(rc) ); else changed++; break; @@ -629,7 +629,7 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands, rc = read_keyblock( &sec_keyblockpos, &sec_keyblock ); if( rc ) { log_error("%s: secret keyblock read problem: %s\n", - username, g10_errstr(rc)); + username, gpg_errstr(rc)); goto leave; } merge_keys_and_selfsig( sec_keyblock ); @@ -784,7 +784,7 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands, rc = update_trust_record( keyblock, 0, NULL ); if( rc ) { log_error(_("update of trustdb failed: %s\n"), - g10_errstr(rc) ); + gpg_errstr(rc) ); rc = 0; } } @@ -943,7 +943,7 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands, if( modified ) { rc = update_keyblock( &keyblockpos, keyblock ); if( rc ) { - log_error(_("update failed: %s\n"), g10_errstr(rc) ); + log_error(_("update failed: %s\n"), gpg_errstr(rc) ); break; } } @@ -951,7 +951,7 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands, rc = update_keyblock( &sec_keyblockpos, sec_keyblock ); if( rc ) { log_error(_("update secret failed: %s\n"), - g10_errstr(rc) ); + gpg_errstr(rc) ); break; } } @@ -966,7 +966,7 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands, rc = update_trust_record( keyblock, 0, NULL ); if( rc ) log_error(_("update of trustdb failed: %s\n"), - g10_errstr(rc) ); + gpg_errstr(rc) ); goto leave; case cmdINVCMD: @@ -1092,11 +1092,11 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, if( !rc ) tty_printf( "rev! subkey has been revoked: %s\n", datestr_from_sig( sig ) ); - else if( rc == G10ERR_BAD_SIGN ) + else if( rc == GPGERR_BAD_SIGN ) tty_printf( "rev- faked revocation found\n" ); else if( rc ) tty_printf( "rev? problem checking revocation: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); } } /* the user ids */ @@ -1218,7 +1218,7 @@ menu_adduid( KBNODE pub_keyblock, KBNODE sec_keyblock ) keygen_add_std_prefs, pk ); free_secret_key( sk ); if( rc ) { - log_error("signing failed: %s\n", g10_errstr(rc) ); + log_error("signing failed: %s\n", gpg_errstr(rc) ); free_user_id(uid); return 0; } @@ -1516,7 +1516,7 @@ menu_expire( KBNODE pub_keyblock, KBNODE sec_keyblock ) keygen_add_key_expire, sub_pk ); if( rc ) { log_error("make_keysig_packet failed: %s\n", - g10_errstr(rc)); + gpg_errstr(rc)); free_secret_key( sk ); return 0; } @@ -1829,7 +1829,7 @@ menu_revsig( KBNODE keyblock ) &attrib ); free_secret_key(sk); if( rc ) { - log_error(_("signing failed: %s\n"), g10_errstr(rc)); + log_error(_("signing failed: %s\n"), gpg_errstr(rc)); return changed; } changed = 1; /* we changed the keyblock */ @@ -1878,7 +1878,7 @@ menu_revkey( KBNODE pub_keyblock, KBNODE sec_keyblock ) NULL, NULL ); free_secret_key(sk); if( rc ) { - log_error(_("signing failed: %s\n"), g10_errstr(rc)); + log_error(_("signing failed: %s\n"), gpg_errstr(rc)); return changed; } changed = 1; /* we changed the keyblock */ diff --git a/g10/keygen.c b/g10/keygen.c index 70590bc89..1a0130072 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -137,7 +137,7 @@ write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk ) rc = make_keysig_packet( &sig, pk, uid, NULL, sk, 0x13, 0, keygen_add_std_prefs, pk ); if( rc ) { - log_error("make_keysig_packet failed: %s\n", g10_errstr(rc) ); + log_error("make_keysig_packet failed: %s\n", gpg_errstr(rc) ); return rc; } @@ -178,7 +178,7 @@ write_keybinding( KBNODE root, KBNODE pub_root, PKT_secret_key *sk ) rc = make_keysig_packet( &sig, pk, NULL, subpk, sk, 0x18, 0, keygen_add_key_expire, subpk ); if( rc ) { - log_error("make_keysig_packet failed: %s\n", g10_errstr(rc) ); + log_error("make_keysig_packet failed: %s\n", gpg_errstr(rc) ); return rc; } @@ -191,6 +191,92 @@ write_keybinding( KBNODE root, KBNODE pub_root, PKT_secret_key *sk ) static int +key_from_sexp( GCRY_MPI *array, + GCRY_SEXP sexp, const char *topname, const char *elems ) +{ + GCRY_SEXP list, l2; + const char *s; + int i, idx; + + list = gcry_sexp_find_token( sexp, topname, 0 ); + if( !list ) + return GCRYERR_INV_OBJ; + list = gcry_sexp_cdr( list ); + if( !list ) + return GCRYERR_NO_OBJ; + + idx = 0; + for(s=elems; *s; s++, idx++ ) { + l2 = gcry_sexp_find_token( list, s, 1 ); + if( !l2 ) { + for(i=0; i<idx; i++) { + gcry_free( array[i] ); + array[i] = NULL; + } + return GCRYERR_NO_OBJ; /* required parameter not found */ + } + array[idx] = gcry_sexp_cdr_mpi( l2, GCRYMPI_FMT_USG ); + if( !array[idx] ) { + for(i=0; i<idx; i++) { + gcry_free( array[i] ); + array[i] = NULL; + } + return GCRYERR_INV_OBJ; /* required parameter is invalid */ + } + } + + return 0; +} + + +static int +factors_from_sexp( MPI **retarray, GCRY_SEXP sexp ) +{ + GCRY_SEXP list, l2; + size_t n; + int i; + GCRY_MPI *array; + void *ctx; + + list = gcry_sexp_find_token( sexp, "misc-key-info", 0 ); + if( !list ) + return GCRYERR_INV_OBJ; + list = gcry_sexp_cdr( list ); + if( !list ) + return GCRYERR_NO_OBJ; + list = gcry_sexp_find_token( list, "pm1-factors", 0 ); + if( !list ) + return GCRYERR_NO_OBJ; + + /* count factors */ + ctx = NULL; + for( n=0; (l2 = gcry_sexp_enum( list, &ctx, 0 )); n++ ) + ; + + array = gcry_calloc( n, sizeof *array ); + if( !array ) + return GCRYERR_NO_MEM; + + /* retrieve factors (the first enum is to skip the car) */ + ctx = NULL; + if( gcry_sexp_enum( list, &ctx, 0 ) ) { + for( n=0; (l2 = gcry_sexp_enum( list, &ctx, 0 )); n++ ) { + array[n] = gcry_sexp_car_mpi( l2, 0 ); + if( !array[n] ) { + for(i=0; i < n; i++ ) + gcry_mpi_release( array[i] ); + gcry_free(array); + return GCRYERR_INV_OBJ; + } + } + } + + *retarray = array; + return 0; +} + + +static int gen_elg(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek, STRING2KEY *s2k, PKT_secret_key **ret_sk, u32 expireval, int version ) @@ -200,16 +286,27 @@ gen_elg(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek, PACKET *pkt; PKT_secret_key *sk; PKT_public_key *pk; - MPI skey[4]; MPI *factors; - - assert( is_ELGAMAL(algo) ); - /*rc = pubkey_generate( algo, nbits, skey, &factors );*/ - rc = gcry_pk_genkey( NULL, NULL ); + char buf[100]; + GCRY_SEXP s_parms, s_key; + + sprintf(buf, "%u", nbits ); + s_parms = SEXP_CONS( SEXP_NEW( "genkey", 0 ), + SEXP_CONS( SEXP_NEW(algo == GCRY_PK_ELG_E ? "openpgp-elg" : + algo == GCRY_PK_ELG ? "elg" : "x-oops",0), + gcry_sexp_new_name_data( "nbits", buf, 0 ) ) + ); + log_debug("input is:\n"); + gcry_sexp_dump( s_parms ); + + rc = gcry_pk_genkey( &s_key, s_parms ); + gcry_sexp_release( s_parms ); if( rc ) { - log_error("pk_genkey failed: %s\n", g10_errstr(rc) ); + log_error("pk_genkey failed: %s\n", gpg_errstr(rc) ); return rc; } + log_debug("output is:\n"); + gcry_sexp_dump( s_key ); sk = gcry_xcalloc( 1, sizeof *sk ); pk = gcry_xcalloc( 1, sizeof *pk ); @@ -219,13 +316,23 @@ gen_elg(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek, sk->expiredate = pk->expiredate = sk->timestamp + expireval; } sk->pubkey_algo = pk->pubkey_algo = algo; - pk->pkey[0] = mpi_copy( skey[0] ); - pk->pkey[1] = mpi_copy( skey[1] ); - pk->pkey[2] = mpi_copy( skey[2] ); - sk->skey[0] = skey[0]; - sk->skey[1] = skey[1]; - sk->skey[2] = skey[2]; - sk->skey[3] = skey[3]; + + rc = key_from_sexp( pk->pkey, s_key, "public-key", "pgy" ); + if( rc ) { + log_error("key_from_sexp failed: rc=%d\n", rc ); + return rc; + } + rc = key_from_sexp( sk->skey, s_key, "private-key", "pgyx" ); + if( rc ) { + log_error("key_from_sexp failed: rc=%d\n", rc ); + return rc; + } + rc = factors_from_sexp( &factors, s_key ); + if( rc ) { + log_error("factors_from_sexp failed: rc=%d\n", rc ); + return rc; + } + sk->is_protected = 0; sk->protect.algo = 0; @@ -238,7 +345,7 @@ gen_elg(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek, sk->protect.s2k = *s2k; rc = protect_secret_key( sk, dek ); if( rc ) { - log_error("protect_secret_key failed: %s\n", g10_errstr(rc) ); + log_error("protect_secret_key failed: %s\n", gpg_errstr(rc) ); free_public_key(pk); free_secret_key(sk); return rc; @@ -256,9 +363,11 @@ gen_elg(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek, pkt->pkttype = ret_sk ? PKT_SECRET_KEY : PKT_SECRET_SUBKEY; pkt->pkt.secret_key = sk; add_kbnode(sec_root, new_kbnode( pkt )); - for(i=0; factors[i]; i++ ) + for(i=0; factors[i]; i++ ) { add_kbnode( sec_root, make_mpi_comment_node("#:ELG_factor:", factors[i] )); + gcry_mpi_release(factors[i]); + } return 0; } @@ -285,7 +394,7 @@ gen_dsa(unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek, /*rc = pubkey_generate( GCRY_PK_DSA, nbits, skey, &factors );*/ rc = gcry_pk_genkey( NULL, NULL ); if( rc ) { - log_error("pubkey_generate failed: %s\n", g10_errstr(rc) ); + log_error("pubkey_generate failed: %s\n", gpg_errstr(rc) ); return rc; } @@ -318,7 +427,7 @@ gen_dsa(unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek, sk->protect.s2k = *s2k; rc = protect_secret_key( sk, dek ); if( rc ) { - log_error("protect_secret_key failed: %s\n", g10_errstr(rc) ); + log_error("protect_secret_key failed: %s\n", gpg_errstr(rc) ); free_public_key(pk); free_secret_key(sk); return rc; @@ -930,11 +1039,11 @@ generate_keypair() if( get_keyblock_handle( pub_fname, 0, &pub_kbpos ) ) { if( add_keyblock_resource( pub_fname, 1, 0 ) ) { log_error("can add keyblock file `%s'\n", pub_fname ); - rc = G10ERR_CREATE_FILE; + rc = GPGERR_CREATE_FILE; } else if( get_keyblock_handle( pub_fname, 0, &pub_kbpos ) ) { log_error("can get keyblock handle for `%s'\n", pub_fname ); - rc = G10ERR_CREATE_FILE; + rc = GPGERR_CREATE_FILE; } } if( rc ) @@ -942,24 +1051,24 @@ generate_keypair() else if( get_keyblock_handle( sec_fname, 1, &sec_kbpos ) ) { if( add_keyblock_resource( sec_fname, 1, 1 ) ) { log_error("can add keyblock file `%s'\n", sec_fname ); - rc = G10ERR_CREATE_FILE; + rc = GPGERR_CREATE_FILE; } else if( get_keyblock_handle( sec_fname, 1, &sec_kbpos ) ) { log_error("can get keyblock handle for `%s'\n", sec_fname ); - rc = G10ERR_CREATE_FILE; + rc = GPGERR_CREATE_FILE; } } if( rc ) ; else if( (rc=rc1=lock_keyblock( &pub_kbpos )) ) - log_error("can't lock public keyring: %s\n", g10_errstr(rc) ); + log_error("can't lock public keyring: %s\n", gpg_errstr(rc) ); else if( (rc=rc2=lock_keyblock( &sec_kbpos )) ) - log_error("can't lock secret keyring: %s\n", g10_errstr(rc) ); + log_error("can't lock secret keyring: %s\n", gpg_errstr(rc) ); else if( (rc=insert_keyblock( &pub_kbpos, pub_root )) ) - log_error("can't write public key: %s\n", g10_errstr(rc) ); + log_error("can't write public key: %s\n", gpg_errstr(rc) ); else if( (rc=insert_keyblock( &sec_kbpos, sec_root )) ) - log_error("can't write secret key: %s\n", g10_errstr(rc) ); + log_error("can't write secret key: %s\n", gpg_errstr(rc) ); else { tty_printf(_("public and secret key created and signed.\n") ); if( algo == GCRY_PK_DSA ) @@ -977,7 +1086,7 @@ generate_keypair() if( rc ) - tty_printf(_("Key generation failed: %s\n"), g10_errstr(rc) ); + tty_printf(_("Key generation failed: %s\n"), gpg_errstr(rc) ); release_kbnode( pub_root ); release_kbnode( sec_root ); if( sk ) /* the unprotected secret key */ @@ -1025,7 +1134,7 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock ) "in future (time warp or clock problem)\n") : _("key has been created %lu seconds " "in future (time warp or clock problem)\n"), d ); - rc = G10ERR_TIME_CONFLICT; + rc = GPGERR_TIME_CONFLICT; goto leave; } @@ -1033,7 +1142,7 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock ) /* unprotect to get the passphrase */ switch( is_secret_key_protected( sk ) ) { case -1: - rc = G10ERR_PUBKEY_ALGO; + rc = GPGERR_PUBKEY_ALGO; break; case 0: tty_printf("This key is not protected.\n"); @@ -1076,7 +1185,7 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock ) leave: if( rc ) - log_error(_("Key generation failed: %s\n"), g10_errstr(rc) ); + log_error(_("Key generation failed: %s\n"), gpg_errstr(rc) ); gcry_free( passphrase ); gcry_free( dek ); gcry_free( s2k ); diff --git a/g10/keylist.c b/g10/keylist.c index 91e660352..0cefa2d56 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -85,7 +85,7 @@ list_all( int secret ) rc = enum_keyblocks( secret? 5:0, &kbpos, &keyblock ); if( rc ) { if( rc != -1 ) - log_error("enum_keyblocks(open) failed: %s\n", g10_errstr(rc) ); + log_error("enum_keyblocks(open) failed: %s\n", gpg_errstr(rc) ); goto leave; } @@ -107,7 +107,7 @@ list_all( int secret ) } if( rc && rc != -1 ) - log_error("enum_keyblocks(read) failed: %s\n", g10_errstr(rc)); + log_error("enum_keyblocks(read) failed: %s\n", gpg_errstr(rc)); leave: enum_keyblocks( 2, &kbpos, &keyblock ); /* close */ @@ -126,7 +126,7 @@ list_one( STRLIST names, int secret ) if( secret ) { rc = get_seckey_bynames( &ctx, NULL, names, &keyblock ); if( rc ) { - log_error("error reading key: %s\n", g10_errstr(rc) ); + log_error("error reading key: %s\n", gpg_errstr(rc) ); get_seckey_end( ctx ); return; } @@ -140,7 +140,7 @@ list_one( STRLIST names, int secret ) else { rc = get_pubkey_bynames( &ctx, NULL, names, &keyblock ); if( rc ) { - log_error("error reading key: %s\n", g10_errstr(rc) ); + log_error("error reading key: %s\n", gpg_errstr(rc) ); get_pubkey_end( ctx ); return; } @@ -381,8 +381,8 @@ list_keyblock( KBNODE keyblock, int secret ) rc = check_key_signature( keyblock, node, NULL ); switch( rc ) { case 0: sigrc = '!'; break; - case G10ERR_BAD_SIGN: sigrc = '-'; break; - case G10ERR_NO_PUBKEY: sigrc = '?'; break; + case GPGERR_BAD_SIGN: sigrc = '-'; break; + case GPGERR_NO_PUBKEY: sigrc = '?'; break; default: sigrc = '%'; break; } } @@ -402,7 +402,7 @@ list_keyblock( KBNODE keyblock, int secret ) printf("%c %08lX %s ", sigrc, (ulong)sig->keyid[1], datestr_from_sig(sig)); if( sigrc == '%' ) - printf("[%s] ", g10_errstr(rc) ); + printf("[%s] ", gpg_errstr(rc) ); else if( sigrc == '?' ) ; else { diff --git a/g10/ks-proto.h b/g10/ks-proto.h index bd58db5f9..2a3b2ddb1 100644 --- a/g10/ks-proto.h +++ b/g10/ks-proto.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_KS_PROTO_H -#define G10_KS_PROTO_H +#ifndef GPG_KS_PROTO_H +#define GPG_KS_PROTO_H -#endif /*G10_KS_PROTO_H*/ +#endif /*GPG_KS_PROTO_H*/ diff --git a/g10/main.h b/g10/main.h index 9d632db6d..621fc57de 100644 --- a/g10/main.h +++ b/g10/main.h @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_MAIN_H -#define G10_MAIN_H +#ifndef GPG_MAIN_H +#define GPG_MAIN_H #include <gcrypt.h> #include "basicdefs.h" @@ -34,13 +34,13 @@ #define is_ELGAMAL(a) ((a)==GCRY_PK_ELG || (a)==GCRY_PK_ELG_E) -/*-- g10.c --*/ -extern int g10_errors_seen; +/*-- gpg.c --*/ +extern int gpg_errors_seen; #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) - void g10_exit(int rc) __attribute__ ((noreturn)); + void gpg_exit(int rc) __attribute__ ((noreturn)); #else - void g10_exit(int rc); + void gpg_exit(int rc); #endif void print_pubkey_algo_note( int algo ); void print_cipher_algo_note( int algo ); @@ -165,4 +165,4 @@ void pause_on_sigusr( int which ); void block_all_signals(void); void unblock_all_signals(void); -#endif /*G10_MAIN_H*/ +#endif /*GPG_MAIN_H*/ diff --git a/g10/mainproc.c b/g10/mainproc.c index 6facd822b..f2637340c 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -160,11 +160,11 @@ add_signature( CTX c, PACKET *pkt ) if( pkt->pkttype == PKT_SIGNATURE && !c->list ) { /* This is the first signature for the following datafile. - * G10 does not write such packets; instead it always uses + * gpg does not write such packets; instead it always uses * onepass-sig packets. The drawback of PGP's method * of prepending the signature to the data is * that it is not possible to make a signature from data read - * from stdin. (G10 is able to read PGP stuff anyway.) */ + * from stdin. (gpg is able to read PGP stuff anyway.) */ node = new_kbnode( pkt ); c->list = node; return 1; @@ -231,10 +231,10 @@ proc_pubkey_enc( CTX c, PACKET *pkt ) } } else - result = G10ERR_NO_SECKEY; + result = GPGERR_NO_SECKEY; } else - result = G10ERR_PUBKEY_ALGO; + result = GPGERR_PUBKEY_ALGO; if( result == -1 ) ; @@ -286,7 +286,7 @@ print_failed_pkenc( struct kidlist_item *list ) } free_public_key( pk ); - if( list->reason == G10ERR_NO_SECKEY ) { + if( list->reason == GPGERR_NO_SECKEY ) { log_info(_("no secret key for decryption available\n")); if( is_status_enabled() ) { char buf[20]; @@ -297,7 +297,7 @@ print_failed_pkenc( struct kidlist_item *list ) } else log_error(_("public key decryption failed: %s\n"), - g10_errstr(list->reason)); + gpg_errstr(list->reason)); } } @@ -319,7 +319,7 @@ proc_encrypted( CTX c, PACKET *pkt ) : DEFAULT_CIPHER_ALGO, NULL, 0 ); } else if( !c->dek ) - result = G10ERR_NO_SECKEY; + result = GPGERR_NO_SECKEY; if( !result ) result = decrypt_data( c, pkt->pkt.encrypted, c->dek ); gcry_free(c->dek); c->dek = NULL; @@ -332,13 +332,13 @@ proc_encrypted( CTX c, PACKET *pkt ) if( pkt->pkt.encrypted->mdc_method ) write_status( STATUS_GOODMDC ); } - else if( result == G10ERR_BAD_SIGN ) { + else if( result == GPGERR_BAD_SIGN ) { log_error(_("WARNING: encrypted message has been manipulated!\n")); write_status( STATUS_BADMDC ); } else { write_status( STATUS_DECRYPTION_FAILED ); - log_error(_("decryption failed: %s\n"), g10_errstr(result)); + log_error(_("decryption failed: %s\n"), gpg_errstr(result)); /* Hmmm: does this work when we have encrypted using a multiple * ways to specify the session key (symmmetric and PK)*/ } @@ -417,13 +417,13 @@ proc_plaintext( CTX c, PACKET *pkt ) md_start_debug( c->mfx.md, "verify" ); #endif rc = handle_plaintext( pt, &c->mfx, c->sigs_only, clearsig ); - if( rc == G10ERR_CREATE_FILE && !c->sigs_only) { + if( rc == GPGERR_CREATE_FILE && !c->sigs_only) { /* can't write output but we hash it anyway to * check the signature */ rc = handle_plaintext( pt, &c->mfx, 1, clearsig ); } if( rc ) - log_error( "handle plaintext failed: %s\n", g10_errstr(rc)); + log_error( "handle plaintext failed: %s\n", gpg_errstr(rc)); free_packet(pkt); c->last_was_session_key = 0; } @@ -456,7 +456,7 @@ proc_compressed( CTX c, PACKET *pkt ) else rc = handle_compressed( c, zd, NULL, NULL ); if( rc ) - log_error("uncompressing failed: %s\n", g10_errstr(rc)); + log_error("uncompressing failed: %s\n", gpg_errstr(rc)); free_packet(pkt); c->last_was_session_key = 0; } @@ -516,13 +516,13 @@ do_check_sig( CTX c, KBNODE node, int *is_selfsig ) else { log_error("invalid root packet for sigclass %02x\n", sig->sig_class); - return G10ERR_SIG_CLASS; + return GPGERR_SIG_CLASS; } } else - return G10ERR_SIG_CLASS; + return GPGERR_SIG_CLASS; rc = signature_check( sig, md ); - if( rc == G10ERR_BAD_SIGN && md2 ) + if( rc == GPGERR_BAD_SIGN && md2 ) rc = signature_check( sig, md2 ); gcry_md_close(md); gcry_md_close(md2); @@ -806,8 +806,8 @@ list_node( CTX c, KBNODE node ) fflush(stdout); switch( (rc2=do_check_sig( c, node, &is_selfsig )) ) { case 0: sigrc = '!'; break; - case G10ERR_BAD_SIGN: sigrc = '-'; break; - case G10ERR_NO_PUBKEY: sigrc = '?'; break; + case GPGERR_BAD_SIGN: sigrc = '-'; break; + case GPGERR_NO_PUBKEY: sigrc = '?'; break; default: sigrc = '%'; break; } } @@ -837,7 +837,7 @@ list_node( CTX c, KBNODE node ) printf("%c %08lX %s ", sigrc, (ulong)sig->keyid[1], datestr_from_sig(sig)); if( sigrc == '%' ) - printf("[%s] ", g10_errstr(rc2) ); + printf("[%s] ", gpg_errstr(rc2) ); else if( sigrc == '?' ) ; else if( is_selfsig ) { @@ -917,7 +917,7 @@ do_proc_packets( CTX c, IOBUF a ) any_data = 1; if( rc ) { free_packet(pkt); - if( rc == G10ERR_INVALID_PACKET ) + if( rc == GPGERR_INVALID_PACKET ) break; continue; } @@ -941,7 +941,7 @@ do_proc_packets( CTX c, IOBUF a ) case PKT_PUBKEY_ENC: case PKT_ENCRYPTED: case PKT_ENCRYPTED_MDC: - rc = G10ERR_UNEXPECTED; + rc = GPGERR_UNEXPECTED; goto leave; case PKT_SIGNATURE: newpkt = add_signature( c, pkt ); break; case PKT_PLAINTEXT: proc_plaintext( c, pkt ); break; @@ -955,7 +955,7 @@ do_proc_packets( CTX c, IOBUF a ) case PKT_PUBLIC_KEY: case PKT_SECRET_KEY: case PKT_USER_ID: - rc = G10ERR_UNEXPECTED; + rc = GPGERR_UNEXPECTED; goto leave; case PKT_SIGNATURE: newpkt = add_signature( c, pkt ); break; case PKT_SYMKEY_ENC: proc_symkey_enc( c, pkt ); break; @@ -1005,7 +1005,7 @@ do_proc_packets( CTX c, IOBUF a ) else free_packet(pkt); } - if( rc == G10ERR_INVALID_PACKET ) + if( rc == GPGERR_INVALID_PACKET ) write_status_text( STATUS_NODATA, "3" ); if( any_data ) rc = 0; @@ -1041,11 +1041,11 @@ check_sig_and_print( CTX c, KBNODE node ) (ulong)sig->keyid[1] ); rc = do_check_sig(c, node, NULL ); - if( rc == G10ERR_NO_PUBKEY && opt.keyserver_name ) { + if( rc == GPGERR_NO_PUBKEY && opt.keyserver_name ) { if( !hkp_ask_import( sig->keyid ) ) rc = do_check_sig(c, node, NULL ); } - if( !rc || rc == G10ERR_BAD_SIGN ) { + if( !rc || rc == GPGERR_BAD_SIGN ) { KBNODE un, keyblock; char *us; int count=0; @@ -1106,9 +1106,9 @@ check_sig_and_print( CTX c, KBNODE node ) if( !rc ) rc = check_signatures_trust( sig ); if( rc ) - g10_errors_seen = 1; + gpg_errors_seen = 1; if( opt.batch && rc ) - g10_exit(1); + gpg_exit(1); } else { char buf[50]; @@ -1117,11 +1117,11 @@ check_sig_and_print( CTX c, KBNODE node ) sig->pubkey_algo, sig->digest_algo, sig->sig_class, (ulong)sig->timestamp, rc ); write_status_text( STATUS_ERRSIG, buf ); - if( rc == G10ERR_NO_PUBKEY ) { + if( rc == GPGERR_NO_PUBKEY ) { buf[16] = 0; write_status_text( STATUS_NO_PUBKEY, buf ); } - log_error(_("Can't check signature: %s\n"), g10_errstr(rc) ); + log_error(_("Can't check signature: %s\n"), gpg_errstr(rc) ); } return rc; } @@ -1171,7 +1171,7 @@ proc_tree( CTX c, KBNODE node ) rc = ask_for_detached_datafile( c->mfx.md, c->mfx.md2, iobuf_get_fname(c->iobuf), 0 ); if( rc ) { - log_error("can't hash datafile: %s\n", g10_errstr(rc)); + log_error("can't hash datafile: %s\n", gpg_errstr(rc)); return; } } @@ -1217,7 +1217,7 @@ proc_tree( CTX c, KBNODE node ) iobuf_get_fname(c->iobuf), c->mfx.md2? 0 :(sig->sig_class == 0x01) ); if( rc ) { - log_error("can't hash datafile: %s\n", g10_errstr(rc)); + log_error("can't hash datafile: %s\n", gpg_errstr(rc)); return; } } diff --git a/g10/openfile.c b/g10/openfile.c index 60910031a..0b768fe5e 100644 --- a/g10/openfile.c +++ b/g10/openfile.c @@ -161,7 +161,7 @@ open_outfile( const char *iname, int mode, IOBUF *a ) if( (!iname || (*iname=='-' && !iname[1])) && !opt.outfile ) { if( !(*a = iobuf_create(NULL)) ) { log_error(_("%s: can't open: %s\n"), "[stdout]", strerror(errno) ); - rc = G10ERR_CREATE_FILE; + rc = GPGERR_CREATE_FILE; } else if( opt.verbose ) log_info(_("writing to stdout\n")); @@ -209,13 +209,13 @@ open_outfile( const char *iname, int mode, IOBUF *a ) if( overwrite_filep( name ) ) { if( !(*a = iobuf_create( name )) ) { log_error(_("%s: can't create: %s\n"), name, strerror(errno) ); - rc = G10ERR_CREATE_FILE; + rc = GPGERR_CREATE_FILE; } else if( opt.verbose ) log_info(_("writing to `%s'\n"), name ); } else - rc = G10ERR_FILE_EXISTS; + rc = GPGERR_FILE_EXISTS; gcry_free(buf); } return rc; diff --git a/g10/options.h b/g10/options.h index abb0c7ad0..cbe6c24e0 100644 --- a/g10/options.h +++ b/g10/options.h @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_OPTIONS_H -#define G10_OPTIONS_H +#ifndef GPG_OPTIONS_H +#define GPG_OPTIONS_H #include <types.h> @@ -106,4 +106,4 @@ struct { #define DBG_CIPHER (opt.debug & DBG_CIPHER_VALUE) -#endif /*G10_OPTIONS_H*/ +#endif /*GPG_OPTIONS_H*/ diff --git a/g10/packet.h b/g10/packet.h index 8e0c8c7e1..ca7005a74 100644 --- a/g10/packet.h +++ b/g10/packet.h @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_PACKET_H -#define G10_PACKET_H +#ifndef GPG_PACKET_H +#define GPG_PACKET_H #include "types.h" #include "iobuf.h" @@ -360,4 +360,4 @@ int make_keysig_packet( PKT_signature **ret_sig, PKT_public_key *pk, /*-- keygen.c --*/ PKT_user_id *generate_user_id(void); -#endif /*G10_PACKET_H*/ +#endif /*GPG_PACKET_H*/ diff --git a/g10/parse-packet.c b/g10/parse-packet.c index 71fa19ed5..107bf1a62 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -304,7 +304,7 @@ parse( IOBUF inp, PACKET *pkt, int reqtype, ulong *retpos, if( !(ctb & 0x80) ) { log_error("%s: invalid packet (ctb=%02x) near %lu\n", iobuf_where(inp), ctb, iobuf_tell(inp) ); - rc = G10ERR_INVALID_PACKET; + rc = GPGERR_INVALID_PACKET; goto leave; } pktlen = 0; @@ -313,7 +313,7 @@ parse( IOBUF inp, PACKET *pkt, int reqtype, ulong *retpos, pkttype = ctb & 0x3f; if( (c = iobuf_get(inp)) == -1 ) { log_error("%s: 1st length byte missing\n", iobuf_where(inp) ); - rc = G10ERR_INVALID_PACKET; + rc = GPGERR_INVALID_PACKET; goto leave; } hdr[hdrlen++] = c; @@ -323,7 +323,7 @@ parse( IOBUF inp, PACKET *pkt, int reqtype, ulong *retpos, pktlen = (c - 192) * 256; if( (c = iobuf_get(inp)) == -1 ) { log_error("%s: 2nd length byte missing\n", iobuf_where(inp) ); - rc = G10ERR_INVALID_PACKET; + rc = GPGERR_INVALID_PACKET; goto leave; } hdr[hdrlen++] = c; @@ -335,7 +335,7 @@ parse( IOBUF inp, PACKET *pkt, int reqtype, ulong *retpos, pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 8; if( (c = iobuf_get(inp)) == -1 ) { log_error("%s: 4 byte length invalid\n", iobuf_where(inp) ); - rc = G10ERR_INVALID_PACKET; + rc = GPGERR_INVALID_PACKET; goto leave; } pktlen |= (hdr[hdrlen++] = c ); @@ -363,7 +363,7 @@ parse( IOBUF inp, PACKET *pkt, int reqtype, ulong *retpos, if( out && pkttype ) { if( iobuf_write( out, hdr, hdrlen ) == -1 ) - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; else rc = copy_packet(inp, out, pkttype, pktlen ); goto leave; @@ -387,7 +387,7 @@ parse( IOBUF inp, PACKET *pkt, int reqtype, ulong *retpos, #endif } pkt->pkttype = pkttype; - rc = G10ERR_UNKNOWN_PACKET; /* default error */ + rc = GPGERR_UNKNOWN_PACKET; /* default error */ switch( pkttype ) { case PKT_PUBLIC_KEY: case PKT_PUBLIC_SUBKEY: @@ -441,7 +441,7 @@ parse( IOBUF inp, PACKET *pkt, int reqtype, ulong *retpos, leave: if( !rc && iobuf_error(inp) ) - rc = G10ERR_INV_KEYRING; + rc = GPGERR_INV_KEYRING; return rc; } @@ -471,23 +471,23 @@ copy_packet( IOBUF inp, IOBUF out, int pkttype, unsigned long pktlen ) if( iobuf_in_block_mode(inp) ) { while( (n = iobuf_read( inp, buf, 100 )) != -1 ) if( iobuf_write(out, buf, n ) ) - return G10ERR_WRITE_FILE; /* write error */ + return GPGERR_WRITE_FILE; /* write error */ } else if( !pktlen && pkttype == PKT_COMPRESSED ) { log_debug("copy_packet: compressed!\n"); /* compressed packet, copy till EOF */ while( (n = iobuf_read( inp, buf, 100 )) != -1 ) if( iobuf_write(out, buf, n ) ) - return G10ERR_WRITE_FILE; /* write error */ + return GPGERR_WRITE_FILE; /* write error */ } else { for( ; pktlen; pktlen -= n ) { n = pktlen > 100 ? 100 : pktlen; n = iobuf_read( inp, buf, n ); if( n == -1 ) - return G10ERR_READ_FILE; + return GPGERR_READ_FILE; if( iobuf_write(out, buf, n ) ) - return G10ERR_WRITE_FILE; /* write error */ + return GPGERR_WRITE_FILE; /* write error */ } } return 0; @@ -1042,7 +1042,7 @@ parse_signature( IOBUF inp, int pkttype, unsigned long pktlen, n = read_16(inp); pktlen -= 2; /* length of hashed data */ if( n > 10000 ) { log_error("signature packet: hashed data too long\n"); - rc = G10ERR_INVALID_PACKET; + rc = GPGERR_INVALID_PACKET; goto leave; } if( n ) { @@ -1059,7 +1059,7 @@ parse_signature( IOBUF inp, int pkttype, unsigned long pktlen, n = read_16(inp); pktlen -= 2; /* length of unhashed data */ if( n > 10000 ) { log_error("signature packet: unhashed data too long\n"); - rc = G10ERR_INVALID_PACKET; + rc = GPGERR_INVALID_PACKET; goto leave; } if( n ) { @@ -1077,7 +1077,7 @@ parse_signature( IOBUF inp, int pkttype, unsigned long pktlen, if( pktlen < 5 ) { /* sanity check */ log_error("packet(%d) too short\n", pkttype); - rc = G10ERR_INVALID_PACKET; + rc = GPGERR_INVALID_PACKET; goto leave; } @@ -1205,7 +1205,7 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen, version = iobuf_get_noeof(inp); pktlen--; if( pkttype == PKT_PUBLIC_SUBKEY && version == '#' ) { - /* early versions of G10 use old PGP comments packets; + /* early versions of gpg use old PGP comments packets; * luckily all those comments are started by a hash */ if( list_mode ) { printf(":rfc1991 comment packet: \"" ); @@ -1312,7 +1312,7 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen, sk->protect.s2k.count = 0; if( sk->protect.algo == 255 ) { if( pktlen < 3 ) { - rc = G10ERR_INVALID_PACKET; + rc = GPGERR_INVALID_PACKET; goto leave; } sk->protect.algo = iobuf_get_noeof(inp); pktlen--; @@ -1337,7 +1337,7 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen, if( list_mode ) printf( "\tunknown S2K %d\n", sk->protect.s2k.mode ); - rc = G10ERR_INVALID_PACKET; + rc = GPGERR_INVALID_PACKET; goto leave; } @@ -1356,7 +1356,7 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen, if( sk->protect.s2k.mode == 3 ) { if( pktlen < 1 ) { - rc = G10ERR_INVALID_PACKET; + rc = GPGERR_INVALID_PACKET; goto leave; } sk->protect.s2k.count = iobuf_get(inp); @@ -1390,7 +1390,7 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen, sk->protect.ivlen = 8; } if( pktlen < sk->protect.ivlen ) { - rc = G10ERR_INVALID_PACKET; + rc = GPGERR_INVALID_PACKET; goto leave; } for(i=0; i < sk->protect.ivlen && pktlen; i++, pktlen-- ) diff --git a/g10/pkclist.c b/g10/pkclist.c index 18c1e9860..abd75f9cd 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -127,7 +127,7 @@ show_paths( ulong lid, int only_first ) rc = get_pubkey( pk, keyid ); if( rc ) { log_error("key %08lX: public key not found: %s\n", - (ulong)keyid[1], g10_errstr(rc) ); + (ulong)keyid[1], gpg_errstr(rc) ); return; } @@ -188,7 +188,7 @@ do_edit_ownertrust( ulong lid, int mode, unsigned *new_trust, int defer_help ) rc = get_pubkey( pk, keyid ); if( rc ) { log_error("key %08lX: public key not found: %s\n", - (ulong)keyid[1], g10_errstr(rc) ); + (ulong)keyid[1], gpg_errstr(rc) ); return 0; } @@ -374,13 +374,13 @@ do_we_trust( PKT_public_key *pk, int trustlevel ) rc = insert_trust_record_by_pk( pk ); if( rc ) { log_error("failed to insert it into the trustdb: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return 0; /* no */ } rc = check_trust( pk, &trustlevel, NULL, NULL, NULL ); if( rc ) log_fatal("trust check after insert failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); if( trustlevel == TRUST_UNKNOWN || trustlevel == TRUST_EXPIRED ) { log_debug("do_we_trust: oops at %d\n", __LINE__ ); return 0; @@ -513,13 +513,13 @@ check_signatures_trust( PKT_signature *sig ) rc = get_pubkey( pk, sig->keyid ); if( rc ) { /* this should not happen */ log_error("Ooops; the key vanished - can't check the trust\n"); - rc = G10ERR_NO_PUBKEY; + rc = GPGERR_NO_PUBKEY; goto leave; } rc = check_trust( pk, &trustlevel, NULL, NULL, NULL ); if( rc ) { - log_error("check trust failed: %s\n", g10_errstr(rc)); + log_error("check trust failed: %s\n", gpg_errstr(rc)); goto leave; } @@ -540,13 +540,13 @@ check_signatures_trust( PKT_signature *sig ) rc = insert_trust_record_by_pk( pk ); if( rc ) { log_error("failed to insert it into the trustdb: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); goto leave; } rc = check_trust( pk, &trustlevel, NULL, NULL, NULL ); if( rc ) log_fatal("trust check after insert failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); if( trustlevel == TRUST_UNKNOWN || trustlevel == TRUST_EXPIRED ) BUG(); goto retry; @@ -581,7 +581,7 @@ check_signatures_trust( PKT_signature *sig ) write_status( STATUS_TRUST_NEVER ); log_info(_("WARNING: We do NOT trust this key!\n")); log_info(_(" The signature is probably a FORGERY.\n")); - rc = G10ERR_BAD_SIGN; + rc = GPGERR_BAD_SIGN; break; case TRUST_MARGINAL: @@ -692,7 +692,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) pk->pubkey_usage = use; if( (rc = get_pubkey_byname( NULL, pk, rov->d, NULL )) ) { free_public_key( pk ); pk = NULL; - log_error(_("%s: skipped: %s\n"), rov->d, g10_errstr(rc) ); + log_error(_("%s: skipped: %s\n"), rov->d, gpg_errstr(rc) ); } else if( !(rc=openpgp_pk_test_algo(pk->pubkey_algo, use )) ) { @@ -714,7 +714,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) } else { free_public_key( pk ); pk = NULL; - log_error(_("%s: skipped: %s\n"), rov->d, g10_errstr(rc) ); + log_error(_("%s: skipped: %s\n"), rov->d, gpg_errstr(rc) ); } } } @@ -773,7 +773,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) rc = check_trust( pk, &trustlevel, NULL, NULL, NULL ); if( rc ) { log_error("error checking pk of `%s': %s\n", - answer, g10_errstr(rc) ); + answer, gpg_errstr(rc) ); } else if( (trustlevel & TRUST_FLAG_DISABLED) ) { tty_printf(_("Public key is disabled.\n") ); @@ -839,7 +839,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) pk->pubkey_usage = use; if( (rc = get_pubkey_byname( NULL, pk, remusr->d, NULL )) ) { free_public_key( pk ); pk = NULL; - log_error(_("%s: skipped: %s\n"), remusr->d, g10_errstr(rc) ); + log_error(_("%s: skipped: %s\n"), remusr->d, gpg_errstr(rc) ); } else if( !(rc=openpgp_pk_test_algo(pk->pubkey_algo, use )) ) { int trustlevel; @@ -848,7 +848,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) if( rc ) { free_public_key( pk ); pk = NULL; log_error(_("%s: error checking key: %s\n"), - remusr->d, g10_errstr(rc) ); + remusr->d, gpg_errstr(rc) ); } else if( (trustlevel & TRUST_FLAG_DISABLED) ) { free_public_key(pk); pk = NULL; @@ -884,14 +884,14 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) } else { free_public_key( pk ); pk = NULL; - log_error(_("%s: skipped: %s\n"), remusr->d, g10_errstr(rc) ); + log_error(_("%s: skipped: %s\n"), remusr->d, gpg_errstr(rc) ); } } } if( !rc && !any_recipients ) { log_error(_("no valid addressees\n")); - rc = G10ERR_NO_USER_ID; + rc = GPGERR_NO_USER_ID; } if( rc ) diff --git a/g10/plaintext.c b/g10/plaintext.c index 88b76bc70..f0c01ca8e 100644 --- a/g10/plaintext.c +++ b/g10/plaintext.c @@ -68,7 +68,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, if( !fname ) fname = ask_outfile_name( pt->name, pt->namelen ); if( !fname ) { - rc = G10ERR_CREATE_FILE; + rc = GPGERR_CREATE_FILE; goto leave; } } @@ -83,7 +83,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, fp = stdout; } else if( !overwrite_filep( fname ) ) { - rc = G10ERR_CREATE_FILE; + rc = GPGERR_CREATE_FILE; goto leave; } @@ -91,7 +91,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, ; else if( !(fp = fopen(fname,"wb")) ) { log_error("Error creating `%s': %s\n", fname, strerror(errno) ); - rc = G10ERR_CREATE_FILE; + rc = GPGERR_CREATE_FILE; goto leave; } @@ -102,7 +102,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, if( (c = iobuf_get(pt->buf)) == -1 ) { log_error("Problem reading source (%u bytes remaining)\n", (unsigned)pt->len); - rc = G10ERR_READ_FILE; + rc = GPGERR_READ_FILE; goto leave; } if( mfx->md ) @@ -113,7 +113,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, if( putc( c, fp ) == EOF ) { log_error("Error writing to `%s': %s\n", fname, strerror(errno) ); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; goto leave; } } @@ -127,7 +127,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, if( len == -1 ) { log_error("Problem reading source (%u bytes remaining)\n", (unsigned)pt->len); - rc = G10ERR_READ_FILE; + rc = GPGERR_READ_FILE; gcry_free( buffer ); goto leave; } @@ -137,7 +137,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, if( fwrite( buffer, 1, len, fp ) != len ) { log_error("Error writing to `%s': %s\n", fname, strerror(errno) ); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; gcry_free( buffer ); goto leave; } @@ -158,7 +158,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, if( putc( c, fp ) == EOF ) { log_error("Error writing to `%s': %s\n", fname, strerror(errno) ); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; goto leave; } } @@ -185,7 +185,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, if( fwrite( buffer, 1, len, fp ) != len ) { log_error("Error writing to `%s': %s\n", fname, strerror(errno) ); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; gcry_free( buffer ); goto leave; } @@ -203,7 +203,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, if( putc( c, fp ) == EOF ) { log_error("Error writing to `%s': %s\n", fname, strerror(errno) ); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; goto leave; } } @@ -240,7 +240,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, if( fp && fp != stdout && fclose(fp) ) { log_error("Error closing `%s': %s\n", fname, strerror(errno) ); fp = NULL; - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; goto leave; } fp = NULL; @@ -315,7 +315,7 @@ ask_for_detached_datafile( GCRY_MD_HD md, GCRY_MD_HD md2, _("Please enter name of data file: ")); cpr_kill_prompt(); if( any && !*answer ) { - rc = G10ERR_READ_FILE; + rc = GPGERR_READ_FILE; goto leave; } fp = iobuf_open(answer); @@ -325,7 +325,7 @@ ask_for_detached_datafile( GCRY_MD_HD md, GCRY_MD_HD md2, } else if( !fp ) { log_error("can't open `%s': %s\n", answer, strerror(errno) ); - rc = G10ERR_READ_FILE; + rc = GPGERR_READ_FILE; goto leave; } } while( !fp ); @@ -380,7 +380,7 @@ hash_datafiles( GCRY_MD_HD md, GCRY_MD_HD md2, STRLIST files, print_fname_stdin(sl->d)); if( !files ) free_strlist(sl); - return G10ERR_OPEN_FILE; + return GPGERR_OPEN_FILE; } do_hash( md, md2, fp, textmode ); iobuf_close(fp); diff --git a/g10/pubkey-enc.c b/g10/pubkey-enc.c index 70e4bc6c1..245c250eb 100644 --- a/g10/pubkey-enc.c +++ b/g10/pubkey-enc.c @@ -71,7 +71,7 @@ pk_decrypt( int algo, MPI *result, MPI *data, MPI *skey ) NULL )); } else - return G10ERR_PUBKEY_ALGO; + return GPGERR_PUBKEY_ALGO; /* put data into a S-Exp s_data */ if( algo == GCRY_PK_ELG || algo == GCRY_PK_ELG_E ) { @@ -138,7 +138,7 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek ) sk = gcry_xcalloc( 1, sizeof *sk ); rc=enum_secret_keys( &enum_context, sk, 1); if( rc ) { - rc = G10ERR_NO_SECKEY; + rc = GPGERR_NO_SECKEY; break; } if( sk->pubkey_algo != k->pubkey_algo ) @@ -204,19 +204,19 @@ get_it( PKT_pubkey_enc *k, DEK *dek, PKT_secret_key *sk, u32 *keyid ) log_hexdump("DEK frame:", frame, nframe ); n=0; if( n + 7 > nframe ) - { rc = G10ERR_WRONG_SECKEY; goto leave; } + { rc = GPGERR_WRONG_SECKEY; goto leave; } if( frame[n] == 1 && frame[nframe-1] == 2 ) { log_info(_("old encoding of the DEK is not supported\n")); - rc = G10ERR_CIPHER_ALGO; + rc = GPGERR_CIPHER_ALGO; goto leave; } if( frame[n] != 2 ) /* somethink is wrong */ - { rc = G10ERR_WRONG_SECKEY; goto leave; } + { rc = GPGERR_WRONG_SECKEY; goto leave; } for(n++; n < nframe && frame[n]; n++ ) /* skip the random bytes */ ; n++; /* and the zero byte */ if( n + 4 > nframe ) - { rc = G10ERR_WRONG_SECKEY; goto leave; } + { rc = GPGERR_WRONG_SECKEY; goto leave; } dek->keylen = nframe - (n+1) - 2; dek->algo = frame[n++]; @@ -228,7 +228,7 @@ get_it( PKT_pubkey_enc *k, DEK *dek, PKT_secret_key *sk, u32 *keyid ) goto leave; } if( dek->keylen != gcry_cipher_get_algo_keylen( dek->algo ) ) { - rc = G10ERR_WRONG_SECKEY; + rc = GPGERR_WRONG_SECKEY; goto leave; } @@ -239,7 +239,7 @@ get_it( PKT_pubkey_enc *k, DEK *dek, PKT_secret_key *sk, u32 *keyid ) for( csum2=0, n=0; n < dek->keylen; n++ ) csum2 += dek->key[n]; if( csum != csum2 ) { - rc = G10ERR_WRONG_SECKEY; + rc = GPGERR_WRONG_SECKEY; goto leave; } if( (opt.debug & DBG_CIPHER_VALUE) ) @@ -248,7 +248,7 @@ get_it( PKT_pubkey_enc *k, DEK *dek, PKT_secret_key *sk, u32 *keyid ) { PKT_public_key *pk = gcry_xcalloc( 1, sizeof *pk ); if( (rc = get_pubkey( pk, keyid )) ) - log_error("public key problem: %s\n", g10_errstr(rc) ); + log_error("public key problem: %s\n", gpg_errstr(rc) ); else if( !pk->local_id && query_trust_record(pk) ) log_error("can't check algorithm against preferences\n"); else if( dek->algo != GCRY_CIPHER_3DES diff --git a/g10/revoke.c b/g10/revoke.c index e71124515..b1a50e786 100644 --- a/g10/revoke.c +++ b/g10/revoke.c @@ -58,7 +58,7 @@ gen_revoke( const char *uname ) if( opt.batch ) { log_error(_("sorry, can't do this in batch mode\n")); - return G10ERR_GENERAL; + return GPGERR_GENERAL; } @@ -90,7 +90,7 @@ gen_revoke( const char *uname ) /* read the keyblock */ rc = read_keyblock( &kbpos, &keyblock ); if( rc ) { - log_error(_("error reading the certificate: %s\n"), g10_errstr(rc) ); + log_error(_("error reading the certificate: %s\n"), gpg_errstr(rc) ); goto leave; } @@ -98,7 +98,7 @@ gen_revoke( const char *uname ) node = find_kbnode( keyblock, PKT_SECRET_KEY ); if( !node ) { /* maybe better to use log_bug ? */ log_error(_("Oops; secret key not found anymore!\n")); - rc = G10ERR_GENERAL; + rc = GPGERR_GENERAL; goto leave; } @@ -120,12 +120,12 @@ gen_revoke( const char *uname ) pk = gcry_xcalloc( 1, sizeof *pk ); rc = get_pubkey( pk, sk_keyid ); if( rc ) { - log_error(_("no corresponding public key: %s\n"), g10_errstr(rc) ); + log_error(_("no corresponding public key: %s\n"), gpg_errstr(rc) ); goto leave; } if( cmp_public_secret_key( pk, sk ) ) { log_error(_("public key does not match secret key!\n") ); - rc = G10ERR_GENERAL; + rc = GPGERR_GENERAL; goto leave; } @@ -139,7 +139,7 @@ gen_revoke( const char *uname ) switch( is_secret_key_protected( sk ) ) { case -1: log_error(_("unknown protection algorithm\n")); - rc = G10ERR_PUBKEY_ALGO; + rc = GPGERR_PUBKEY_ALGO; break; case 0: tty_printf(_("NOTE: This key is not protected!\n")); @@ -165,7 +165,7 @@ gen_revoke( const char *uname ) /* create it */ rc = make_keysig_packet( &sig, pk, NULL, NULL, sk, 0x20, 0, NULL, NULL); if( rc ) { - log_error(_("make_keysig_packet failed: %s\n"), g10_errstr(rc)); + log_error(_("make_keysig_packet failed: %s\n"), gpg_errstr(rc)); goto leave; } init_packet( &pkt ); @@ -174,7 +174,7 @@ gen_revoke( const char *uname ) rc = build_packet( out, &pkt ); if( rc ) { - log_error(_("build_packet failed: %s\n"), g10_errstr(rc) ); + log_error(_("build_packet failed: %s\n"), gpg_errstr(rc) ); goto leave; } @@ -272,7 +272,7 @@ gen_sig_revoke( const char *uname ) if( opt.batch ) { log_error(_("sorry, can't do this in batch mode\n")); - return G10ERR_GENERAL; + return GPGERR_GENERAL; } @@ -291,7 +291,7 @@ gen_sig_revoke( const char *uname ) /* read the keyblock */ rc = read_keyblock( &kbpos, &keyblock ); if( rc ) { - log_error(_("error reading the certificate: %s\n"), g10_errstr(rc) ); + log_error(_("error reading the certificate: %s\n"), gpg_errstr(rc) ); goto leave; } @@ -299,7 +299,7 @@ gen_sig_revoke( const char *uname ) node = find_kbnode( keyblock, PKT_PUBLIC_KEY ); if( !node ) { log_error(_("Oops; public key lost!\n")); - rc = G10ERR_GENERAL; + rc = GPGERR_GENERAL; goto leave; } @@ -343,7 +343,7 @@ gen_sig_revoke( const char *uname ) pkt.pkt.public_key = keyblock->pkt->pkt.public_key; rc = build_packet( out, &pkt ); if( rc ) { - log_error(_("build_packet failed: %s\n"), g10_errstr(rc) ); + log_error(_("build_packet failed: %s\n"), gpg_errstr(rc) ); goto leave; } uidchg = 1; @@ -362,7 +362,7 @@ gen_sig_revoke( const char *uname ) /* create it */ rc = make_keysig_packet( &sig, pk, NULL, NULL, sk, 0x30, 0, NULL, NULL); if( rc ) { - log_error(_("make_keysig_packet failed: %s\n"), g10_errstr(rc)); + log_error(_("make_keysig_packet failed: %s\n"), gpg_errstr(rc)); goto leave; } init_packet( &pkt ); @@ -371,7 +371,7 @@ gen_sig_revoke( const char *uname ) rc = build_packet( out, &pkt ); if( rc ) { - log_error(_("build_packet failed: %s\n"), g10_errstr(rc) ); + log_error(_("build_packet failed: %s\n"), gpg_errstr(rc) ); goto leave; } } diff --git a/g10/ringedit.c b/g10/ringedit.c index b4091f41c..df51be695 100644 --- a/g10/ringedit.c +++ b/g10/ringedit.c @@ -221,7 +221,7 @@ add_keyblock_resource( const char *url, int force, int secret ) #ifndef HAVE_DRIVE_LETTERS else if( strchr( resname, ':' ) ) { log_error("%s: invalid URL\n", url ); - rc = G10ERR_GENERAL; + rc = GPGERR_GENERAL; goto leave; } #endif @@ -243,7 +243,7 @@ add_keyblock_resource( const char *url, int force, int secret ) if( !resource_table[i].used ) break; if( i == MAX_RESOURCES ) { - rc = G10ERR_RESOURCE_LIMIT; + rc = GPGERR_RESOURCE_LIMIT; goto leave; } @@ -273,13 +273,13 @@ add_keyblock_resource( const char *url, int force, int secret ) switch( rt ) { case rt_UNKNOWN: log_error("%s: unknown resource type\n", url ); - rc = G10ERR_GENERAL; + rc = GPGERR_GENERAL; goto leave; case rt_RING: iobuf = iobuf_open( filename ); if( !iobuf && !force ) { - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } @@ -296,7 +296,7 @@ add_keyblock_resource( const char *url, int force, int secret ) { log_error( _("%s: can't create directory: %s\n"), filename, strerror(errno)); - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } else if( !opt.quiet ) @@ -305,7 +305,7 @@ add_keyblock_resource( const char *url, int force, int secret ) } else { - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } } @@ -316,7 +316,7 @@ add_keyblock_resource( const char *url, int force, int secret ) if( !iobuf ) { log_error(_("%s: can't create keyring: %s\n"), filename, strerror(errno)); - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } else { @@ -325,7 +325,7 @@ add_keyblock_resource( const char *url, int force, int secret ) if( chmod( filename, S_IRUSR | S_IWUSR ) ) { log_error("%s: chmod failed: %s\n", filename, strerror(errno) ); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; goto leave; } } @@ -351,7 +351,7 @@ add_keyblock_resource( const char *url, int force, int secret ) if( !resource_table[i].dbf ) { log_error("%s: can't open gdbm file: %s\n", filename, gdbm_strerror(gdbm_errno)); - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } break; @@ -359,7 +359,7 @@ add_keyblock_resource( const char *url, int force, int secret ) default: log_error("%s: unsupported resource type\n", url ); - rc = G10ERR_GENERAL; + rc = GPGERR_GENERAL; goto leave; } @@ -383,7 +383,7 @@ add_keyblock_resource( const char *url, int force, int secret ) leave: if( rc ) - log_error("keyblock resource `%s': %s\n", filename, g10_errstr(rc) ); + log_error("keyblock resource `%s': %s\n", filename, gpg_errstr(rc) ); else if( secret ) any_secret = 1; else @@ -481,7 +481,7 @@ search( PACKET *pkt, KBPOS *kbpos, int secret ) } if( rc != -1 ) { log_error("error searching resource %d: %s\n", - i, g10_errstr(rc)); + i, gpg_errstr(rc)); last_rc = rc; } } @@ -585,7 +585,7 @@ find_secret_keyblock_byname( KBPOS *kbpos, const char *username ) * * Returns: 0 if found, * -1 if not found - * G10ERR_UNSUPPORTED if no resource is able to handle this + * GPGERR_UNSUPPORTED if no resource is able to handle this * or another errorcode. */ int @@ -606,7 +606,7 @@ locate_keyblock_by_fpr( KBPOS *kbpos, const byte *fpr, int fprlen, int secret ) break; #endif default: - rc = G10ERR_UNSUPPORTED; + rc = GPGERR_UNSUPPORTED; break; } @@ -615,15 +615,15 @@ locate_keyblock_by_fpr( KBPOS *kbpos, const byte *fpr, int fprlen, int secret ) kbpos->fp = NULL; return 0; } - else if( rc != -1 && rc != G10ERR_UNSUPPORTED ) { + else if( rc != -1 && rc != GPGERR_UNSUPPORTED ) { log_error("error searching resource %d: %s\n", - i, g10_errstr(rc)); + i, gpg_errstr(rc)); last_rc = rc; } } } - return (last_rc == -1 && !any)? G10ERR_UNSUPPORTED : last_rc; + return (last_rc == -1 && !any)? GPGERR_UNSUPPORTED : last_rc; } @@ -634,7 +634,7 @@ locate_keyblock_by_keyid( KBPOS *kbpos, u32 *keyid, int shortkid, int secret ) int i, rc, any=0, last_rc=-1; if( shortkid ) - return G10ERR_UNSUPPORTED; + return GPGERR_UNSUPPORTED; for(i=0, rentry = resource_table; i < MAX_RESOURCES; i++, rentry++ ) { if( rentry->used && !rentry->secret == !secret ) { @@ -647,7 +647,7 @@ locate_keyblock_by_keyid( KBPOS *kbpos, u32 *keyid, int shortkid, int secret ) break; #endif default: - rc = G10ERR_UNSUPPORTED; + rc = GPGERR_UNSUPPORTED; break; } @@ -656,15 +656,15 @@ locate_keyblock_by_keyid( KBPOS *kbpos, u32 *keyid, int shortkid, int secret ) kbpos->fp = NULL; return 0; } - else if( rc != -1 && rc != G10ERR_UNSUPPORTED ) { + else if( rc != -1 && rc != GPGERR_UNSUPPORTED ) { log_error("error searching resource %d: %s\n", - i, g10_errstr(rc)); + i, gpg_errstr(rc)); last_rc = rc; } } } - return (last_rc == -1 && !any)? G10ERR_UNSUPPORTED : last_rc; + return (last_rc == -1 && !any)? GPGERR_UNSUPPORTED : last_rc; } @@ -680,7 +680,7 @@ int lock_keyblock( KBPOS *kbpos ) { if( !check_pos(kbpos) ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; return 0; } @@ -701,7 +701,7 @@ int read_keyblock( KBPOS *kbpos, KBNODE *ret_root ) { if( !check_pos(kbpos) ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; switch( kbpos->rt ) { case rt_RING: @@ -765,7 +765,7 @@ enum_keyblocks( int mode, KBPOS *kbpos, KBNODE *ret_root ) kbpos->fp = iobuf_open( rentry->fname ); if( !kbpos->fp ) { log_error("can't open `%s'\n", rentry->fname ); - return G10ERR_OPEN_FILE; + return GPGERR_OPEN_FILE; } break; #ifdef HAVE_LIBGDBM @@ -785,7 +785,7 @@ enum_keyblocks( int mode, KBPOS *kbpos, KBNODE *ret_root ) switch( kbpos->rt ) { case rt_RING: if( !kbpos->fp ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; rc = keyring_enum( kbpos, ret_root, mode == 11 ); break; #ifdef HAVE_LIBGDBM @@ -846,7 +846,7 @@ insert_keyblock( KBPOS *kbpos, KBNODE root ) int rc; if( !check_pos(kbpos) ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; switch( kbpos->rt ) { case rt_RING: @@ -875,7 +875,7 @@ delete_keyblock( KBPOS *kbpos ) int rc; if( !check_pos(kbpos) ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; switch( kbpos->rt ) { case rt_RING: @@ -903,7 +903,7 @@ update_keyblock( KBPOS *kbpos, KBNODE root ) int rc; if( !check_pos(kbpos) ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; switch( kbpos->rt ) { case rt_RING: @@ -1101,13 +1101,13 @@ keyring_search( PACKET *req, KBPOS *kbpos, IOBUF iobuf, const char *fname ) iobuf = iobuf_open( fname ); if( !iobuf ) { log_error("%s: can't open keyring file\n", fname); - rc = G10ERR_KEYRING_OPEN; + rc = GPGERR_KEYRING_OPEN; goto leave; } #else if( iobuf_seek( iobuf, 0 ) ) { log_error("can't rewind keyring file\n"); - rc = G10ERR_KEYRING_OPEN; + rc = GPGERR_KEYRING_OPEN; goto leave; } #endif @@ -1159,12 +1159,12 @@ keyring_read( KBPOS *kbpos, KBNODE *ret_root ) int in_cert = 0; if( !(rentry=check_pos(kbpos)) ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; a = iobuf_open( rentry->fname ); if( !a ) { log_error("can't open `%s'\n", rentry->fname ); - return G10ERR_OPEN_FILE; + return GPGERR_OPEN_FILE; } if( !kbpos->valid ) @@ -1172,7 +1172,7 @@ keyring_read( KBPOS *kbpos, KBNODE *ret_root ) if( iobuf_seek( a, kbpos->offset ) ) { log_error("can't seek to %lu\n", kbpos->offset); iobuf_close(a); - return G10ERR_KEYRING_OPEN; + return GPGERR_KEYRING_OPEN; } pkt = gcry_xmalloc( sizeof *pkt ); @@ -1180,9 +1180,9 @@ keyring_read( KBPOS *kbpos, KBNODE *ret_root ) kbpos->count=0; while( (rc=parse_packet(a, pkt)) != -1 ) { if( rc ) { /* ignore errors */ - if( rc != G10ERR_UNKNOWN_PACKET ) { - log_error("read_keyblock: read error: %s\n", g10_errstr(rc) ); - rc = G10ERR_INV_KEYRING; + if( rc != GPGERR_UNKNOWN_PACKET ) { + log_error("read_keyblock: read error: %s\n", gpg_errstr(rc) ); + rc = GPGERR_INV_KEYRING; goto ready; } kbpos->count++; @@ -1239,7 +1239,7 @@ keyring_enum( KBPOS *kbpos, KBNODE *ret_root, int skipsigs ) KBNODE root = NULL; if( !(rentry=check_pos(kbpos)) ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; if( kbpos->pkt ) { root = new_kbnode( kbpos->pkt ); @@ -1250,9 +1250,9 @@ keyring_enum( KBPOS *kbpos, KBNODE *ret_root, int skipsigs ) init_packet(pkt); while( (rc=parse_packet(kbpos->fp, pkt)) != -1 ) { if( rc ) { /* ignore errors */ - if( rc != G10ERR_UNKNOWN_PACKET ) { - log_error("read_keyblock: read error: %s\n", g10_errstr(rc) ); - rc = G10ERR_INV_KEYRING; + if( rc != GPGERR_UNKNOWN_PACKET ) { + log_error("read_keyblock: read error: %s\n", gpg_errstr(rc) ); + rc = GPGERR_INV_KEYRING; goto ready; } free_packet( pkt ); @@ -1329,7 +1329,7 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) char *tmpfname = NULL; if( !(rentry = check_pos( kbpos )) ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; if( kbpos->fp ) BUG(); /* not allowed with such a handle */ @@ -1348,7 +1348,7 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) if( !newfp ) { log_error(_("%s: can't create: %s\n"), rentry->fname, strerror(errno)); unlock_rentry( rentry ); - return G10ERR_OPEN_FILE; + return GPGERR_OPEN_FILE; } else if( !opt.quiet ) log_info(_("%s: keyring created\n"), rentry->fname ); @@ -1357,28 +1357,28 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) while( (node = walk_kbnode( root, &kbctx, 0 )) ) { if( (rc = build_packet( newfp, node->pkt )) ) { log_error("build_packet(%d) failed: %s\n", - node->pkt->pkttype, g10_errstr(rc) ); + node->pkt->pkttype, gpg_errstr(rc) ); iobuf_cancel(newfp); unlock_rentry( rentry ); - return G10ERR_WRITE_FILE; + return GPGERR_WRITE_FILE; } } if( iobuf_close(newfp) ) { log_error("%s: close failed: %s\n", rentry->fname, strerror(errno)); unlock_rentry( rentry ); - return G10ERR_CLOSE_FILE; + return GPGERR_CLOSE_FILE; } if( chmod( rentry->fname, S_IRUSR | S_IWUSR ) ) { log_error("%s: chmod failed: %s\n", rentry->fname, strerror(errno) ); unlock_rentry( rentry ); - return G10ERR_WRITE_FILE; + return GPGERR_WRITE_FILE; } return 0; } if( !fp ) { log_error("%s: can't open: %s\n", rentry->fname, strerror(errno) ); - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } @@ -1414,7 +1414,7 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) if( !newfp ) { log_error("%s: can't create: %s\n", tmpfname, strerror(errno) ); iobuf_close(fp); - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } @@ -1423,7 +1423,7 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) rc = copy_all_packets( fp, newfp ); if( rc != -1 ) { log_error("%s: copy to %s failed: %s\n", - rentry->fname, tmpfname, g10_errstr(rc) ); + rentry->fname, tmpfname, gpg_errstr(rc) ); iobuf_close(fp); iobuf_cancel(newfp); goto leave; @@ -1436,7 +1436,7 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) rc = copy_some_packets( fp, newfp, kbpos->offset ); if( rc ) { /* should never get EOF here */ log_error("%s: copy to %s failed: %s\n", - rentry->fname, tmpfname, g10_errstr(rc) ); + rentry->fname, tmpfname, gpg_errstr(rc) ); iobuf_close(fp); iobuf_cancel(newfp); goto leave; @@ -1446,7 +1446,7 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) rc = skip_some_packets( fp, kbpos->count ); if( rc ) { log_error("%s: skipping %u packets failed: %s\n", - rentry->fname, kbpos->count, g10_errstr(rc)); + rentry->fname, kbpos->count, gpg_errstr(rc)); iobuf_close(fp); iobuf_cancel(newfp); goto leave; @@ -1461,10 +1461,10 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) while( (node = walk_kbnode( root, &kbctx, 0 )) ) { if( (rc = build_packet( newfp, node->pkt )) ) { log_error("build_packet(%d) failed: %s\n", - node->pkt->pkttype, g10_errstr(rc) ); + node->pkt->pkttype, gpg_errstr(rc) ); iobuf_close(fp); iobuf_cancel(newfp); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; goto leave; } } @@ -1476,7 +1476,7 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) rc = copy_all_packets( fp, newfp ); if( rc != -1 ) { log_error("%s: copy to %s failed: %s\n", - rentry->fname, tmpfname, g10_errstr(rc) ); + rentry->fname, tmpfname, gpg_errstr(rc) ); iobuf_close(fp); iobuf_cancel(newfp); goto leave; @@ -1487,12 +1487,12 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) /* close both files */ if( iobuf_close(fp) ) { log_error("%s: close failed: %s\n", rentry->fname, strerror(errno) ); - rc = G10ERR_CLOSE_FILE; + rc = GPGERR_CLOSE_FILE; goto leave; } if( iobuf_close(newfp) ) { log_error("%s: close failed: %s\n", tmpfname, strerror(errno) ); - rc = G10ERR_CLOSE_FILE; + rc = GPGERR_CLOSE_FILE; goto leave; } /* if the new file is a secring, restrict the permissions */ @@ -1501,7 +1501,7 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) if( chmod( tmpfname, S_IRUSR | S_IWUSR ) ) { log_error("%s: chmod failed: %s\n", tmpfname, strerror(errno) ); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; goto leave; } } @@ -1515,7 +1515,7 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) if( rename( rentry->fname, bakfname ) ) { log_error("%s: rename to %s failed: %s\n", rentry->fname, bakfname, strerror(errno) ); - rc = G10ERR_RENAME_FILE; + rc = GPGERR_RENAME_FILE; goto leave; } } @@ -1525,7 +1525,7 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root ) if( rename( tmpfname, rentry->fname ) ) { log_error("%s: rename to %s failed: %s\n", tmpfname, rentry->fname,strerror(errno) ); - rc = G10ERR_RENAME_FILE; + rc = GPGERR_RENAME_FILE; if( rentry->secret ) { log_info(_( "WARNING: 2 files with confidential information exists.\n")); @@ -1572,7 +1572,7 @@ do_gdbm_store( KBPOS *kbpos, KBNODE root, int update ) int i, rc; if( !(rentry = check_pos( kbpos )) ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; if( opt.dry_run ) return 0; @@ -1594,8 +1594,8 @@ do_gdbm_store( KBPOS *kbpos, KBNODE root, int update ) while( (node = walk_kbnode( root, &kbctx, 0 )) ) { if( (rc = build_packet( fp, node->pkt )) ) { log_error("build_packet(%d) failed: %s\n", - node->pkt->pkttype, g10_errstr(rc) ); - rc = G10ERR_WRITE_FILE; + node->pkt->pkttype, gpg_errstr(rc) ); + rc = GPGERR_WRITE_FILE; goto leave; } } @@ -1615,7 +1615,7 @@ do_gdbm_store( KBPOS *kbpos, KBNODE root, int update ) log_error("%s: gdbm_store failed: %s\n", rentry->fname, rc == 1 ? "already stored" : gdbm_strerror(gdbm_errno) ); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; goto leave; } /* now store all keyids */ @@ -1705,18 +1705,18 @@ do_gdbm_locate_by_keyid( GDBM_FILE dbf, KBPOS *kbpos, u32 *keyid ) if( content.dsize < 2 ) { log_error("gdbm_fetch did not return enough data\n" ); free( content.dptr ); /* can't use gcry_free() here */ - return G10ERR_INV_KEYRING; + return GPGERR_INV_KEYRING; } if( *content.dptr != 2 ) { log_error("gdbm_fetch returned unexpected type %d\n", *(byte*)content.dptr ); free( content.dptr ); /* can't use gcry_free() here */ - return G10ERR_INV_KEYRING; + return GPGERR_INV_KEYRING; } if( content.dsize < 21 ) { log_error("gdbm_fetch did not return a complete fingerprint\n" ); free( content.dptr ); /* can't use gcry_free() here */ - return G10ERR_INV_KEYRING; + return GPGERR_INV_KEYRING; } if( content.dsize > 21 ) log_info("gdbm_fetch: WARNING: more than one fingerprint\n" ); @@ -1739,25 +1739,25 @@ do_gdbm_read( KBPOS *kbpos, KBNODE *ret_root ) datum key, content; if( !(rentry=check_pos(kbpos)) ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; key.dptr = kbpos->keybuf; key.dsize = 21; content = gdbm_fetch( rentry->dbf, key ); if( !content.dptr ) { log_error("gdbm_fetch failed: %s\n", gdbm_strerror(gdbm_errno) ); - return G10ERR_INV_KEYRING; + return GPGERR_INV_KEYRING; } if( content.dsize < 2 ) { log_error("gdbm_fetch did not return enough data\n" ); free( content.dptr ); /* can't use gcry_free() here */ - return G10ERR_INV_KEYRING; + return GPGERR_INV_KEYRING; } if( *content.dptr != 1 ) { log_error("gdbm_fetch returned unexpected type %d\n", *(byte*)content.dptr ); free( content.dptr ); /* can't use gcry_free() here */ - return G10ERR_INV_KEYRING; + return GPGERR_INV_KEYRING; } a = iobuf_temp_with_content( content.dptr+1, content.dsize-1 ); @@ -1768,9 +1768,9 @@ do_gdbm_read( KBPOS *kbpos, KBNODE *ret_root ) kbpos->count=0; while( (rc=parse_packet(a, pkt)) != -1 ) { if( rc ) { /* ignore errors */ - if( rc != G10ERR_UNKNOWN_PACKET ) { - log_error("read_keyblock: read error: %s\n", g10_errstr(rc) ); - rc = G10ERR_INV_KEYRING; + if( rc != GPGERR_UNKNOWN_PACKET ) { + log_error("read_keyblock: read error: %s\n", gpg_errstr(rc) ); + rc = GPGERR_INV_KEYRING; break; } kbpos->count++; @@ -1810,7 +1810,7 @@ do_gdbm_enum( KBPOS *kbpos, KBNODE *ret_root ) datum key, helpkey; if( !(rentry=check_pos(kbpos)) ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; if( !kbpos->offset ) { kbpos->offset = 1; @@ -1832,7 +1832,7 @@ do_gdbm_enum( KBPOS *kbpos, KBNODE *ret_root ) if( key.dsize < 21 ) { free( key.dptr ); /* free and not gcry_free() ! */ log_error("do_gdm_enum: key is too short\n" ); - return G10ERR_INV_KEYRING; + return GPGERR_INV_KEYRING; } memcpy( kbpos->keybuf, key.dptr, 21 ); free( key.dptr ); /* free and not gcry_free() ! */ diff --git a/g10/seckey-cert.c b/g10/seckey-cert.c index 88ec69389..bef75507e 100644 --- a/g10/seckey-cert.c +++ b/g10/seckey-cert.c @@ -75,7 +75,7 @@ pk_check_secret_key( int algo, MPI *skey ) NULL )); } else - return G10ERR_PUBKEY_ALGO; + return GPGERR_PUBKEY_ALGO; rc = gcry_pk_testkey( s_skey ); gcry_sexp_release( s_skey ); @@ -100,7 +100,7 @@ do_check( PKT_secret_key *sk ) if( openpgp_cipher_test_algo( sk->protect.algo ) ) { log_info(_("protection algorithm %d is not supported\n"), sk->protect.algo ); - return G10ERR_CIPHER_ALGO; + return GPGERR_CIPHER_ALGO; } keyid_from_sk( sk, keyid ); keyid[2] = keyid[3] = 0; @@ -196,14 +196,14 @@ do_check( PKT_secret_key *sk ) if( csum != sk->csum ) { copy_secret_key( sk, save_sk ); free_secret_key( save_sk ); - return G10ERR_BAD_PASS; + return GPGERR_BAD_PASS; } /* the checksum may fail, so we also check the key itself */ res = pk_check_secret_key( sk->pubkey_algo, sk->skey ); if( res ) { copy_secret_key( sk, save_sk ); free_secret_key( save_sk ); - return G10ERR_BAD_PASS; + return GPGERR_BAD_PASS; } free_secret_key( save_sk ); sk->is_protected = 0; @@ -216,7 +216,7 @@ do_check( PKT_secret_key *sk ) csum += checksum_mpi( sk->skey[i] ); } if( csum != sk->csum ) - return G10ERR_CHECKSUM; + return GPGERR_CHECKSUM; } return 0; @@ -231,17 +231,17 @@ do_check( PKT_secret_key *sk ) int check_secret_key( PKT_secret_key *sk, int n ) { - int rc = G10ERR_BAD_PASS; + int rc = GPGERR_BAD_PASS; int i; if( n < 1 ) n = opt.batch? 1 : 3; /* use the default value */ - for(i=0; i < n && rc == G10ERR_BAD_PASS; i++ ) { + for(i=0; i < n && rc == GPGERR_BAD_PASS; i++ ) { if( i ) log_info(_("Invalid passphrase; please try again ...\n")); rc = do_check( sk ); - if( rc == G10ERR_BAD_PASS && is_status_enabled() ) { + if( rc == GPGERR_BAD_PASS && is_status_enabled() ) { u32 kid[2]; char buf[50]; @@ -289,7 +289,7 @@ protect_secret_key( PKT_secret_key *sk, DEK *dek ) GCRY_CIPHER_HD cipher_hd=NULL; if( openpgp_cipher_test_algo( sk->protect.algo ) ) - rc = G10ERR_CIPHER_ALGO; /* unsupport protection algorithm */ + rc = GPGERR_CIPHER_ALGO; /* unsupport protection algorithm */ else { print_cipher_algo_note( sk->protect.algo ); if( !(cipher_hd = gcry_cipher_open( sk->protect.algo, diff --git a/g10/sig-check.c b/g10/sig-check.c index aec50ab38..bd68d44d7 100644 --- a/g10/sig-check.c +++ b/g10/sig-check.c @@ -83,7 +83,7 @@ pk_verify( int algo, MPI hash, MPI *data, MPI *pkey, NULL )); } else - return G10ERR_PUBKEY_ALGO; + return GPGERR_PUBKEY_ALGO; /* put hash into a S-Exp s_hash */ s_hash = gcry_sexp_new_mpi( hash ); @@ -145,7 +145,7 @@ do_signature_check( PKT_signature *sig, GCRY_MD_HD digest, u32 *r_expire ) *r_expire = 0; if( get_pubkey( pk, sig->keyid ) ) - rc = G10ERR_NO_PUBKEY; + rc = GPGERR_NO_PUBKEY; else { *r_expire = pk->expiredate; rc = do_check( pk, sig, digest ); @@ -250,7 +250,7 @@ mdc_kludge_check( PKT_signature *sig, GCRY_MD_HD digest ) } md_final( digest ); - rc = G10ERR_BAD_SIGN; + rc = GPGERR_BAD_SIGN; { const byte *s1 = md_read( digest, sig->digest_algo ); int s1len = md_digest_length( sig->digest_algo ); @@ -279,7 +279,7 @@ mdc_kludge_check( PKT_signature *sig, GCRY_MD_HD digest ) if( !rc && sig->flags.unknown_critical ) { log_info(_("assuming bad MDC due to an unknown critical bit\n")); - rc = G10ERR_BAD_SIGN; + rc = GPGERR_BAD_SIGN; } sig->flags.checked = 1; sig->flags.valid = !rc; @@ -326,7 +326,7 @@ cmp_help( void *opaque, MPI result ) } if( old_enc ) { log_error("old encoding scheme is not supported\n"); - return G10ERR_GENERAL; + return GPGERR_GENERAL; } if( (rc=check_digest_algo(sig->digest_algo)) ) @@ -338,25 +338,25 @@ cmp_help( void *opaque, MPI result ) if( asn[j] != c ) break; if( j != -1 || mpi_getbyte(result, i) ) - return G10ERR_BAD_PUBKEY; /* ASN is wrong */ + return GPGERR_BAD_PUBKEY; /* ASN is wrong */ for(i++; (c=mpi_getbyte(result, i)) != -1; i++ ) if( c != 0xff ) break; i++; if( c != sig->digest_algo || mpi_getbyte(result, i) ) { /* Padding or leading bytes in signature is wrong */ - return G10ERR_BAD_PUBKEY; + return GPGERR_BAD_PUBKEY; } if( mpi_getbyte(result, mdlen-1) != sig->digest_start[0] || mpi_getbyte(result, mdlen-2) != sig->digest_start[1] ) { /* Wrong key used to check the signature */ - return G10ERR_BAD_PUBKEY; + return GPGERR_BAD_PUBKEY; } dp = md_read( digest, sig->digest_algo ); for(i=mdlen-1; i >= 0; i--, dp++ ) { if( mpi_getbyte( result, i ) != *dp ) - return G10ERR_BAD_SIGN; + return GPGERR_BAD_SIGN; } return 0; #else @@ -376,7 +376,7 @@ do_check( PKT_public_key *pk, PKT_signature *sig, GCRY_MD_HD digest ) if( pk->version == 4 && pk->pubkey_algo == GCRY_PK_ELG_E ) { log_info(_("this is a PGP generated " "ElGamal key which is NOT secure for signatures!\n")); - return G10ERR_PUBKEY_ALGO; + return GPGERR_PUBKEY_ALGO; } if( pk->timestamp > sig->timestamp ) { @@ -385,7 +385,7 @@ do_check( PKT_public_key *pk, PKT_signature *sig, GCRY_MD_HD digest ) ? _("public key is %lu second newer than the signature\n") : _("public key is %lu seconds newer than the signature\n"), d ); - return G10ERR_TIME_CONFLICT; /* pubkey newer than signature */ + return GPGERR_TIME_CONFLICT; /* pubkey newer than signature */ } cur_time = make_timestamp(); @@ -395,7 +395,7 @@ do_check( PKT_public_key *pk, PKT_signature *sig, GCRY_MD_HD digest ) "in future (time warp or clock problem)\n") : _("key has been created %lu seconds " "in future (time warp or clock problem)\n"), d ); - return G10ERR_TIME_CONFLICT; + return GPGERR_TIME_CONFLICT; } if( pk->expiredate && pk->expiredate < cur_time ) { @@ -457,7 +457,7 @@ do_check( PKT_public_key *pk, PKT_signature *sig, GCRY_MD_HD digest ) mpi_release( result ); if( !rc && sig->flags.unknown_critical ) { log_info(_("assuming bad signature due to an unknown critical bit\n")); - rc = G10ERR_BAD_SIGN; + rc = GPGERR_BAD_SIGN; } sig->flags.checked = 1; sig->flags.valid = !rc; @@ -544,7 +544,7 @@ check_key_signature2( KBNODE root, KBNODE node, int *is_selfsig, u32 *r_expire) } else { log_error("no subkey for subkey revocation packet\n"); - rc = G10ERR_SIG_CLASS; + rc = GPGERR_SIG_CLASS; } } else if( sig->sig_class == 0x18 ) { @@ -567,7 +567,7 @@ check_key_signature2( KBNODE root, KBNODE node, int *is_selfsig, u32 *r_expire) } else { log_error("no subkey for key signature packet\n"); - rc = G10ERR_SIG_CLASS; + rc = GPGERR_SIG_CLASS; } } else { @@ -592,7 +592,7 @@ check_key_signature2( KBNODE root, KBNODE node, int *is_selfsig, u32 *r_expire) } else { log_error("no user ID for key signature packet\n"); - rc = G10ERR_SIG_CLASS; + rc = GPGERR_SIG_CLASS; } } diff --git a/g10/sign.c b/g10/sign.c index a227a0c25..bb2d2290c 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -70,7 +70,7 @@ pk_sign( int algo, MPI *data, MPI hash, MPI *skey ) NULL )); } else - return G10ERR_PUBKEY_ALGO; + return GPGERR_PUBKEY_ALGO; /* put hash into a S-Exp s_hash */ s_hash = gcry_sexp_new_mpi( hash ); @@ -163,7 +163,7 @@ do_sign( PKT_secret_key *sk, PKT_signature *sig, "in future (time warp or clock problem)\n") : _("key has been created %lu seconds " "in future (time warp or clock problem)\n"), d ); - return G10ERR_TIME_CONFLICT; + return GPGERR_TIME_CONFLICT; } @@ -182,7 +182,7 @@ do_sign( PKT_secret_key *sk, PKT_signature *sig, rc = pk_sign( sk->pubkey_algo, sig->data, frame, sk->skey ); mpi_release(frame); if( rc ) - log_error(_("signing failed: %s\n"), g10_errstr(rc) ); + log_error(_("signing failed: %s\n"), gpg_errstr(rc) ); else { if( opt.verbose ) { char *ustr = get_user_id_string( sig->keyid ); @@ -311,14 +311,14 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr, else if( !(inp = iobuf_open(fname)) ) { log_error("can't open %s: %s\n", fname? fname: "[stdin]", strerror(errno) ); - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } if( outfile ) { if( !(out = iobuf_create( outfile )) ) { log_error(_("can't create %s: %s\n"), outfile, strerror(errno) ); - rc = G10ERR_CREATE_FILE; + rc = GPGERR_CREATE_FILE; goto leave; } else if( opt.verbose ) @@ -404,7 +404,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr, free_packet( &pkt ); if( rc ) { log_error("build onepass_sig packet failed: %s\n", - g10_errstr(rc)); + gpg_errstr(rc)); goto leave; } } @@ -423,7 +423,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr, if( !(inp = iobuf_open(sl->d)) ) { log_error(_("can't open %s: %s\n"), sl->d, strerror(errno) ); - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } if( opt.verbose ) @@ -482,7 +482,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr, pkt.pkt.plaintext = pt; /*cfx.datalen = filesize? calc_packet_length( &pkt ) : 0;*/ if( (rc = build_packet( out, &pkt )) ) - log_error("build_packet(PLAINTEXT) failed: %s\n", g10_errstr(rc) ); + log_error("build_packet(PLAINTEXT) failed: %s\n", gpg_errstr(rc) ); pt->buf = NULL; } else { @@ -490,8 +490,8 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr, int bytes_copied; while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1) if (iobuf_write(out, copy_buffer, bytes_copied) == -1) { - rc = G10ERR_WRITE_FILE; - log_error("copying input to output failed: %s\n", g10_errstr(rc)); + rc = GPGERR_WRITE_FILE; + log_error("copying input to output failed: %s\n", gpg_errstr(rc)); break; } memset(copy_buffer, 0, 4096); /* burn buffer */ @@ -575,7 +575,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr, rc = build_packet( out, &pkt ); free_packet( &pkt ); if( rc ) - log_error("build signature packet failed: %s\n", g10_errstr(rc) ); + log_error("build signature packet failed: %s\n", gpg_errstr(rc) ); } if( rc ) goto leave; @@ -624,14 +624,14 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile ) if( !(inp = iobuf_open(fname)) ) { log_error("can't open %s: %s\n", fname? fname: "[stdin]", strerror(errno) ); - rc = G10ERR_OPEN_FILE; + rc = GPGERR_OPEN_FILE; goto leave; } if( outfile ) { if( !(out = iobuf_create( outfile )) ) { log_error(_("can't create %s: %s\n"), outfile, strerror(errno) ); - rc = G10ERR_CREATE_FILE; + rc = GPGERR_CREATE_FILE; goto leave; } else if( opt.verbose ) @@ -770,7 +770,7 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile ) rc = build_packet( out, &pkt ); free_packet( &pkt ); if( rc ) - log_error("build signature packet failed: %s\n", g10_errstr(rc) ); + log_error("build signature packet failed: %s\n", gpg_errstr(rc) ); } if( rc ) goto leave; diff --git a/g10/skclist.c b/g10/skclist.c index 8d06364d8..ab5682891 100644 --- a/g10/skclist.c +++ b/g10/skclist.c @@ -63,7 +63,7 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list, int unlock, sk->pubkey_usage = use; if( (rc = get_seckey_byname( sk, NULL, unlock )) ) { free_secret_key( sk ); sk = NULL; - log_error("no default secret key: %s\n", g10_errstr(rc) ); + log_error("no default secret key: %s\n", gpg_errstr(rc) ); } else if( !(rc=openpgp_pk_test_algo(sk->pubkey_algo, use)) ) { SK_LIST r; @@ -83,7 +83,7 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list, int unlock, } else { free_secret_key( sk ); sk = NULL; - log_error("invalid default secret key: %s\n", g10_errstr(rc) ); + log_error("invalid default secret key: %s\n", gpg_errstr(rc) ); } } else { @@ -94,7 +94,7 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list, int unlock, sk->pubkey_usage = use; if( (rc = get_seckey_byname( sk, locusr->d, unlock )) ) { free_secret_key( sk ); sk = NULL; - log_error(_("skipped `%s': %s\n"), locusr->d, g10_errstr(rc) ); + log_error(_("skipped `%s': %s\n"), locusr->d, gpg_errstr(rc) ); } else if( !(rc=openpgp_pk_test_algo(sk->pubkey_algo, use)) ) { SK_LIST r; @@ -115,7 +115,7 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list, int unlock, } else { free_secret_key( sk ); sk = NULL; - log_error("skipped `%s': %s\n", locusr->d, g10_errstr(rc) ); + log_error("skipped `%s': %s\n", locusr->d, gpg_errstr(rc) ); } } } @@ -123,7 +123,7 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list, int unlock, if( !rc && !sk_list ) { log_error("no valid signators\n"); - rc = G10ERR_NO_USER_ID; + rc = GPGERR_NO_USER_ID; } if( rc ) diff --git a/g10/status.h b/g10/status.h index 817b34a3c..73cc1b1bf 100644 --- a/g10/status.h +++ b/g10/status.h @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_STATUS_H -#define G10_STATUS_H +#ifndef GPG_STATUS_H +#define GPG_STATUS_H #define STATUS_ENTER 1 @@ -86,4 +86,4 @@ int cpr_get_answer_is_yes( const char *keyword, const char *prompt ); int cpr_get_answer_yes_no_quit( const char *keyword, const char *prompt ); -#endif /*G10_STATUS_H*/ +#endif /*GPG_STATUS_H*/ diff --git a/g10/tdbdump.c b/g10/tdbdump.c index 6ffa0465c..9be91241b 100644 --- a/g10/tdbdump.c +++ b/g10/tdbdump.c @@ -58,7 +58,7 @@ read_record( ulong recno, TRUSTREC *rec, int rectype ) if( !rc ) return; log_error(_("trust record %lu, req type %d: read failed: %s\n"), - recno, rectype, g10_errstr(rc) ); + recno, rectype, gpg_errstr(rc) ); tdbio_invalid(); } #endif @@ -72,7 +72,7 @@ write_record( TRUSTREC *rec ) if( !rc ) return; log_error(_("trust record %lu, type %d: write failed: %s\n"), - rec->recnum, rec->rectype, g10_errstr(rc) ); + rec->recnum, rec->rectype, gpg_errstr(rc) ); tdbio_invalid(); } @@ -86,8 +86,8 @@ do_sync(void) int rc = tdbio_sync(); if( !rc ) return; - log_error(_("trustdb: sync failed: %s\n"), g10_errstr(rc) ); - g10_exit(2); + log_error(_("trustdb: sync failed: %s\n"), gpg_errstr(rc) ); + gpg_exit(2); } #if 0 @@ -274,7 +274,7 @@ list_records( ulong lid ) rc = tdbio_read_record( lid, &dr, RECTYPE_DIR ); if( rc ) { log_error(_("lid %lu: read dir record failed: %s\n"), - lid, g10_errstr(rc)); + lid, gpg_errstr(rc)); return rc; } tdbio_dump_record( &dr, stdout ); @@ -283,7 +283,7 @@ list_records( ulong lid ) rc = tdbio_read_record( recno, &rec, 0 ); if( rc ) { log_error(_("lid %lu: read key record failed: %s\n"), - lid, g10_errstr(rc)); + lid, gpg_errstr(rc)); return rc; } tdbio_dump_record( &rec, stdout ); @@ -293,7 +293,7 @@ list_records( ulong lid ) rc = tdbio_read_record( recno, &ur, RECTYPE_UID ); if( rc ) { log_error(_("lid %lu: read uid record failed: %s\n"), - lid, g10_errstr(rc)); + lid, gpg_errstr(rc)); return rc; } tdbio_dump_record( &ur, stdout ); @@ -302,7 +302,7 @@ list_records( ulong lid ) rc = tdbio_read_record( recno, &rec, RECTYPE_PREF ); if( rc ) { log_error(_("lid %lu: read pref record failed: %s\n"), - lid, g10_errstr(rc)); + lid, gpg_errstr(rc)); return rc; } tdbio_dump_record( &rec, stdout ); @@ -312,7 +312,7 @@ list_records( ulong lid ) rc = tdbio_read_record( recno, &rec, RECTYPE_SIG ); if( rc ) { log_error(_("lid %lu: read sig record failed: %s\n"), - lid, g10_errstr(rc)); + lid, gpg_errstr(rc)); return rc; } tdbio_dump_record( &rec, stdout ); @@ -343,28 +343,28 @@ list_trustdb( const char *username ) if( (rc = list_records( lid)) ) log_error(_("user '%s' read problem: %s\n"), - username, g10_errstr(rc)); + username, gpg_errstr(rc)); else if( (rc = list_sigs( lid )) ) log_error(_("user '%s' list problem: %s\n"), - username, g10_errstr(rc)); + username, gpg_errstr(rc)); } else if( username ) { PKT_public_key *pk = gcry_xcalloc( 1, sizeof *pk ); int rc; if( (rc = get_pubkey_byname( NULL, pk, username, NULL )) ) - log_error(_("user '%s' not found: %s\n"), username, g10_errstr(rc) ); + log_error(_("user '%s' not found: %s\n"), username, gpg_errstr(rc) ); else if( (rc=tdbio_search_dir_bypk( pk, &rec )) && rc != -1 ) log_error(_("problem finding '%s' in trustdb: %s\n"), - username, g10_errstr(rc)); + username, gpg_errstr(rc)); else if( rc == -1 ) log_error(_("user '%s' not in trustdb\n"), username); else if( (rc = list_records( pk->local_id)) ) log_error(_("user '%s' read problem: %s\n"), - username, g10_errstr(rc)); + username, gpg_errstr(rc)); else if( (rc = list_sigs( pk->local_id )) ) log_error(_("user '%s' list problem: %s\n"), - username, g10_errstr(rc)); + username, gpg_errstr(rc)); free_public_key( pk ); } else { @@ -411,7 +411,7 @@ export_ownertrust() continue; rc = tdbio_read_record( rec.r.dir.keylist, &rec2, RECTYPE_KEY); if( rc ) { - log_error(_("error reading key record: %s\n"), g10_errstr(rc)); + log_error(_("error reading key record: %s\n"), gpg_errstr(rc)); continue; } p = rec2.r.key.fingerprint; @@ -497,7 +497,7 @@ import_ownertrust( const char *fname ) log_info_f(fname, _("key not in trustdb, searching ring.\n")); rc = get_pubkey_byfprint( pk, line, fprlen ); if( rc ) - log_info_f(fname, _("key not in ring: %s\n"), g10_errstr(rc)); + log_info_f(fname, _("key not in ring: %s\n"), gpg_errstr(rc)); else { rc = query_trust_record( pk ); /* only as assertion */ if( rc != -1 ) @@ -507,13 +507,13 @@ import_ownertrust( const char *fname ) if( !rc ) goto repeat; /* update the ownertrust */ log_error_f(fname, _("insert trust record failed: %s\n"), - g10_errstr(rc) ); + gpg_errstr(rc) ); } } } else /* error */ log_error_f(fname, _("error finding dir record: %s\n"), - g10_errstr(rc)); + gpg_errstr(rc)); } if( ferror(fp) ) log_error_f(fname, _("read error: %s\n"), strerror(errno) ); diff --git a/g10/tdbio.c b/g10/tdbio.c index 3118d71ac..926048fbf 100644 --- a/g10/tdbio.c +++ b/g10/tdbio.c @@ -120,13 +120,13 @@ write_cache_item( CACHE_CTRL r ) if( lseek( db_fd, r->recno * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) { log_error(_("trustdb rec %lu: lseek failed: %s\n"), r->recno, strerror(errno) ); - return G10ERR_WRITE_FILE; + return GPGERR_WRITE_FILE; } n = write( db_fd, r->data, TRUST_RECORD_LEN); if( n != TRUST_RECORD_LEN ) { log_error(_("trustdb rec %lu: write failed (n=%d): %s\n"), r->recno, n, strerror(errno) ); - return G10ERR_WRITE_FILE; + return GPGERR_WRITE_FILE; } r->flags.dirty = 0; return 0; @@ -235,7 +235,7 @@ put_record_into_cache( ulong recno, const char *data ) return 0; } log_info(_("trustdb transaction too large\n")); - return G10ERR_RESOURCE_LIMIT; + return GPGERR_RESOURCE_LIMIT; } if( dirty_count ) { int n = dirty_count / 5; /* discard some dirty entries */ @@ -428,7 +428,7 @@ tdbio_set_dbname( const char *new_dbname, int create ) if( errno != ENOENT ) { log_error( _("%s: can't access: %s\n"), fname, strerror(errno) ); gcry_free(fname); - return G10ERR_TRUSTDB; + return GPGERR_TRUSTDB; } if( create ) { FILE *fp; @@ -485,7 +485,7 @@ tdbio_set_dbname( const char *new_dbname, int create ) tdbio_sync(); if( rc ) log_fatal( _("%s: failed to create version record: %s"), - fname, g10_errstr(rc)); + fname, gpg_errstr(rc)); /* and read again to check that we are okay */ if( tdbio_read_record( 0, &rec, RECTYPE_VER ) ) log_fatal( _("%s: invalid trustdb created\n"), db_name ); @@ -562,7 +562,7 @@ create_hashtable( TRUSTREC *vr, int type ) rc = tdbio_write_record( &rec ); if( rc ) log_fatal( _("%s: failed to create hashtable: %s\n"), - db_name, g10_errstr(rc)); + db_name, gpg_errstr(rc)); } /* update the version record */ rc = tdbio_write_record( vr ); @@ -570,7 +570,7 @@ create_hashtable( TRUSTREC *vr, int type ) rc = tdbio_sync(); if( rc ) log_fatal( _("%s: error updating version record: %s\n"), - db_name, g10_errstr(rc)); + db_name, gpg_errstr(rc)); } @@ -586,7 +586,7 @@ tdbio_db_matches_options() rc = tdbio_read_record( 0, &vr, RECTYPE_VER ); if( rc ) log_fatal( _("%s: error reading version record: %s\n"), - db_name, g10_errstr(rc) ); + db_name, gpg_errstr(rc) ); if( !vr.r.ver.marginals && !vr.r.ver.completes && !vr.r.ver.cert_depth ) @@ -599,7 +599,7 @@ tdbio_db_matches_options() rc = tdbio_sync(); if( rc ) log_error( _("%s: error writing version record: %s\n"), - db_name, g10_errstr(rc) ); + db_name, gpg_errstr(rc) ); } yes_no = vr.r.ver.marginals == opt.marginals_needed @@ -625,7 +625,7 @@ tdbio_read_modify_stamp( int modify_down ) rc = tdbio_read_record( 0, &vr, RECTYPE_VER ); if( rc ) log_fatal( _("%s: error reading version record: %s\n"), - db_name, g10_errstr(rc) ); + db_name, gpg_errstr(rc) ); mod = modify_down? vr.r.ver.mod_down : vr.r.ver.mod_up; @@ -647,7 +647,7 @@ tdbio_write_modify_stamp( int up, int down ) rc = tdbio_read_record( 0, &vr, RECTYPE_VER ); if( rc ) log_fatal( _("%s: error reading version record: %s\n"), - db_name, g10_errstr(rc) ); + db_name, gpg_errstr(rc) ); stamp = make_timestamp(); if( down ) @@ -658,7 +658,7 @@ tdbio_write_modify_stamp( int up, int down ) rc = tdbio_write_record( &vr ); if( rc ) log_fatal( _("%s: error writing version record: %s\n"), - db_name, g10_errstr(rc) ); + db_name, gpg_errstr(rc) ); } @@ -677,7 +677,7 @@ get_keyhashrec(void) rc = tdbio_read_record( 0, &vr, RECTYPE_VER ); if( rc ) log_fatal( _("%s: error reading version record: %s\n"), - db_name, g10_errstr(rc) ); + db_name, gpg_errstr(rc) ); if( !vr.r.ver.keyhashtbl ) create_hashtable( &vr, 0 ); @@ -702,7 +702,7 @@ get_sdirhashrec(void) rc = tdbio_read_record( 0, &vr, RECTYPE_VER ); if( rc ) log_fatal( _("%s: error reading version record: %s\n"), - db_name, g10_errstr(rc) ); + db_name, gpg_errstr(rc) ); if( !vr.r.ver.sdirhashtbl ) create_hashtable( &vr, 1 ); @@ -733,7 +733,7 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum ) rc = tdbio_read_record( hashrec, &rec, RECTYPE_HTBL ); if( rc ) { log_error( db_name, "upd_hashtable: read failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } @@ -743,7 +743,7 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum ) rc = tdbio_write_record( &rec ); if( rc ) { log_error( db_name, "upd_hashtable: write htbl failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } } @@ -752,7 +752,7 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum ) rc = tdbio_read_record( item, &rec, 0 ); if( rc ) { log_error( "upd_hashtable: read item failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } @@ -761,7 +761,7 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum ) level++; if( level >= keylen ) { log_error( "hashtable has invalid indirections.\n"); - return G10ERR_TRUSTDB; + return GPGERR_TRUSTDB; } goto next_level; } @@ -778,7 +778,7 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum ) &rec, RECTYPE_HLST); if( rc ) { log_error( "scan keyhashtbl read hlst failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } } @@ -793,7 +793,7 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum ) rc = tdbio_write_record( &rec ); if( rc ) log_error( "upd_hashtable: write hlst failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; /* done */ } } @@ -802,7 +802,7 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum ) &rec, RECTYPE_HLST ); if( rc ) { log_error( "upd_hashtable: read hlst failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } } @@ -811,7 +811,7 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum ) rc = tdbio_write_record( &rec ); if( rc ) { log_error( "upd_hashtable: write hlst failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } memset( &rec, 0, sizeof rec ); @@ -821,7 +821,7 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum ) rc = tdbio_write_record( &rec ); if( rc ) log_error( "upd_hashtable: write ext hlst failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; /* done */ } } /* end loop over hlst slots */ @@ -841,7 +841,7 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum ) rc = tdbio_write_record( &rec ); if( rc ) { log_error( "upd_hashtable: write new hlst failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } /* update the hashtable record */ @@ -849,14 +849,14 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum ) rc = tdbio_write_record( &lastrec ); if( rc ) log_error( "upd_hashtable: update htbl failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; /* ready */ } else { log_error( "hashtbl %lu: %lu/%d points to an invalid record %lu\n", table, hashrec, (msb % ITEMS_PER_HTBL_RECORD), item); list_trustdb(NULL); - return G10ERR_TRUSTDB; + return GPGERR_TRUSTDB; } } @@ -884,7 +884,7 @@ drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum ) rc = tdbio_read_record( hashrec, &rec, RECTYPE_HTBL ); if( rc ) { log_error( db_name, "drop_from_hashtable: read failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } @@ -897,14 +897,14 @@ drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum ) rc = tdbio_write_record( &rec ); if( rc ) log_error( db_name, "drop_from_hashtable: write htbl failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } rc = tdbio_read_record( item, &rec, 0 ); if( rc ) { log_error( "drop_from_hashtable: read item failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } @@ -913,7 +913,7 @@ drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum ) level++; if( level >= keylen ) { log_error( "hashtable has invalid indirections.\n"); - return G10ERR_TRUSTDB; + return GPGERR_TRUSTDB; } goto next_level; } @@ -926,7 +926,7 @@ drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum ) rc = tdbio_write_record( &rec ); if( rc ) log_error( db_name, "drop_from_hashtable: write htbl failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } } @@ -935,7 +935,7 @@ drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum ) &rec, RECTYPE_HLST); if( rc ) { log_error( "scan keyhashtbl read hlst failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } } @@ -946,7 +946,7 @@ drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum ) log_error( "hashtbl %lu: %lu/%d points to wrong record %lu\n", table, hashrec, (msb % ITEMS_PER_HTBL_RECORD), item); - return G10ERR_TRUSTDB; + return GPGERR_TRUSTDB; } @@ -972,7 +972,7 @@ lookup_hashtable( ulong table, const byte *key, size_t keylen, hashrec += msb / ITEMS_PER_HTBL_RECORD; rc = tdbio_read_record( hashrec, rec, RECTYPE_HTBL ); if( rc ) { - log_error( db_name, "lookup_hashtable failed: %s\n", g10_errstr(rc) ); + log_error( db_name, "lookup_hashtable failed: %s\n", gpg_errstr(rc) ); return rc; } @@ -982,7 +982,7 @@ lookup_hashtable( ulong table, const byte *key, size_t keylen, rc = tdbio_read_record( item, rec, 0 ); if( rc ) { - log_error( db_name, "hashtable read failed: %s\n", g10_errstr(rc) ); + log_error( db_name, "hashtable read failed: %s\n", gpg_errstr(rc) ); return rc; } if( rec->rectype == RECTYPE_HTBL ) { @@ -990,7 +990,7 @@ lookup_hashtable( ulong table, const byte *key, size_t keylen, level++; if( level >= keylen ) { log_error( db_name, "hashtable has invalid indirections\n"); - return G10ERR_TRUSTDB; + return GPGERR_TRUSTDB; } goto next_level; } @@ -1005,7 +1005,7 @@ lookup_hashtable( ulong table, const byte *key, size_t keylen, rc = tdbio_read_record( rec->r.hlst.rnum[i], &tmp, 0 ); if( rc ) { log_error( "lookup_hashtable: read item failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } if( (*cmpfnc)( cmpdata, &tmp ) ) { @@ -1018,7 +1018,7 @@ lookup_hashtable( ulong table, const byte *key, size_t keylen, rc = tdbio_read_record( rec->r.hlst.next, rec, RECTYPE_HLST ); if( rc ) { log_error( "lookup_hashtable: read hlst failed: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); return rc; } } @@ -1245,7 +1245,7 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected ) if( !buf ) { if( lseek( db_fd, recnum * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) { log_error(_("trustdb: lseek failed: %s\n"), strerror(errno) ); - return G10ERR_READ_FILE; + return GPGERR_READ_FILE; } n = read( db_fd, readbuf, TRUST_RECORD_LEN); if( !n ) { @@ -1254,7 +1254,7 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected ) else if( n != TRUST_RECORD_LEN ) { log_error(_("trustdb: read failed (n=%d): %s\n"), n, strerror(errno) ); - return G10ERR_READ_FILE; + return GPGERR_READ_FILE; } buf = readbuf; } @@ -1265,7 +1265,7 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected ) if( expected && rec->rectype != expected ) { log_error("%lu: read expected rec type %d, got %d\n", recnum, expected, rec->rectype ); - return G10ERR_TRUSTDB; + return GPGERR_TRUSTDB; } p++; /* skip reserved byte */ switch( rec->rectype ) { @@ -1274,7 +1274,7 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected ) case RECTYPE_VER: /* version record */ if( memcmp(buf+1, "gpg", 3 ) ) { log_error( _("%s: not a trustdb file\n"), db_name ); - rc = G10ERR_TRUSTDB; + rc = GPGERR_TRUSTDB; } p += 2; /* skip "pgp" */ rec->r.ver.version = *p++; @@ -1291,12 +1291,12 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected ) if( recnum ) { log_error( _("%s: version record with recnum %lu\n"), db_name, (ulong)recnum ); - rc = G10ERR_TRUSTDB; + rc = GPGERR_TRUSTDB; } else if( rec->r.ver.version != 2 ) { log_error( _("%s: invalid file version %d\n"), db_name, rec->r.ver.version ); - rc = G10ERR_TRUSTDB; + rc = GPGERR_TRUSTDB; } break; case RECTYPE_FREE: @@ -1326,7 +1326,7 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected ) if( rec->r.dir.lid != recnum ) { log_error( "%s: dir LID != recnum (%lu,%lu)\n", db_name, rec->r.dir.lid, (ulong)recnum ); - rc = G10ERR_TRUSTDB; + rc = GPGERR_TRUSTDB; } break; case RECTYPE_KEY: /* public key record */ @@ -1383,7 +1383,7 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected ) if( rec->r.sdir.lid != recnum ) { log_error( "%s: sdir LID != recnum (%lu,%lu)\n", db_name, rec->r.sdir.lid, (ulong)recnum ); - rc = G10ERR_TRUSTDB; + rc = GPGERR_TRUSTDB; } break; case RECTYPE_CACH: /* cache record */ @@ -1405,7 +1405,7 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected ) default: log_error( "%s: invalid record type %d at recnum %lu\n", db_name, rec->rectype, (ulong)recnum ); - rc = G10ERR_TRUSTDB; + rc = GPGERR_TRUSTDB; break; } @@ -1566,7 +1566,7 @@ tdbio_delete_record( ulong recnum ) rc = tdbio_read_record( 0, &vr, RECTYPE_VER ); if( rc ) log_fatal( _("%s: error reading version record: %s\n"), - db_name, g10_errstr(rc) ); + db_name, gpg_errstr(rc) ); rec.recnum = recnum; rec.rectype = RECTYPE_FREE; @@ -1593,13 +1593,13 @@ tdbio_new_recnum() rc = tdbio_read_record( 0, &vr, RECTYPE_VER ); if( rc ) log_fatal( _("%s: error reading version record: %s\n"), - db_name, g10_errstr(rc) ); + db_name, gpg_errstr(rc) ); if( vr.r.ver.firstfree ) { recnum = vr.r.ver.firstfree; rc = tdbio_read_record( recnum, &rec, RECTYPE_FREE ); if( rc ) { log_error( _("%s: error reading free record: %s\n"), - db_name, g10_errstr(rc) ); + db_name, gpg_errstr(rc) ); return rc; } /* update dir record */ @@ -1607,7 +1607,7 @@ tdbio_new_recnum() rc = tdbio_write_record( &vr ); if( rc ) { log_error( _("%s: error writing dir record: %s\n"), - db_name, g10_errstr(rc) ); + db_name, gpg_errstr(rc) ); return rc; } /*zero out the new record */ @@ -1617,7 +1617,7 @@ tdbio_new_recnum() rc = tdbio_write_record( &rec ); if( rc ) log_fatal(_("%s: failed to zero a record: %s\n"), - db_name, g10_errstr(rc)); + db_name, gpg_errstr(rc)); } else { /* not found, append a new record */ offset = lseek( db_fd, 0, SEEK_END ); @@ -1634,20 +1634,20 @@ tdbio_new_recnum() if( lseek( db_fd, recnum * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) { log_error(_("trustdb rec %lu: lseek failed: %s\n"), recnum, strerror(errno) ); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; } else { int n = write( db_fd, &rec, TRUST_RECORD_LEN); if( n != TRUST_RECORD_LEN ) { log_error(_("trustdb rec %lu: write failed (n=%d): %s\n"), recnum, n, strerror(errno) ); - rc = G10ERR_WRITE_FILE; + rc = GPGERR_WRITE_FILE; } } if( rc ) log_fatal(_("%s: failed to append a record: %s\n"), - db_name, g10_errstr(rc)); + db_name, gpg_errstr(rc)); } return recnum ; } @@ -1715,7 +1715,7 @@ tdbio_search_dir_byfpr( const byte *fingerprint, size_t fingerlen, rc = tdbio_read_record( recnum, rec, RECTYPE_DIR); if( rc ) log_error("%s: can't read dirrec %lu: %s\n", - db_name, recnum, g10_errstr(rc) ); + db_name, recnum, gpg_errstr(rc) ); } return rc; } @@ -1758,7 +1758,7 @@ tdbio_invalid(void) { log_error(_( "the trustdb is corrupted; please run \"gpg --fix-trustdb\".\n") ); - g10_exit(2); + gpg_exit(2); } diff --git a/g10/tdbio.h b/g10/tdbio.h index a64f21b5f..4eabed91c 100644 --- a/g10/tdbio.h +++ b/g10/tdbio.h @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_TDBIO_H -#define G10_TDBIO_H +#ifndef GPG_TDBIO_H +#define GPG_TDBIO_H #include "host2net.h" @@ -194,4 +194,4 @@ int tdbio_search_sdir( u32 *keyid, int pubkey_algo, TRUSTREC *rec ); void tdbio_invalid(void); -#endif /*G10_TDBIO_H*/ +#endif /*GPG_TDBIO_H*/ diff --git a/g10/trustdb.c b/g10/trustdb.c index 6f0ed59a7..610b3b355 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -158,7 +158,7 @@ read_record( ulong recno, TRUSTREC *rec, int rectype ) if( !rc ) return; log_error(_("trust record %lu, req type %d: read failed: %s\n"), - recno, rectype, g10_errstr(rc) ); + recno, rectype, gpg_errstr(rc) ); tdbio_invalid(); } @@ -173,7 +173,7 @@ write_record( TRUSTREC *rec ) if( !rc ) return; log_error(_("trust record %lu, type %d: write failed: %s\n"), - rec->recnum, rec->rectype, g10_errstr(rc) ); + rec->recnum, rec->rectype, gpg_errstr(rc) ); tdbio_invalid(); } @@ -187,7 +187,7 @@ delete_record( ulong recno ) if( !rc ) return; log_error(_("trust record %lu: delete failed: %s\n"), - recno, g10_errstr(rc) ); + recno, gpg_errstr(rc) ); tdbio_invalid(); } @@ -200,8 +200,8 @@ do_sync(void) int rc = tdbio_sync(); if( !rc ) return; - log_error(_("trustdb: sync failed: %s\n"), g10_errstr(rc) ); - g10_exit(2); + log_error(_("trustdb: sync failed: %s\n"), gpg_errstr(rc) ); + gpg_exit(2); } @@ -345,25 +345,25 @@ keyid_from_lid( ulong lid, u32 *keyid ) rc = tdbio_read_record( lid, &rec, 0 ); if( rc ) { log_error(_("error reading dir record for LID %lu: %s\n"), - lid, g10_errstr(rc)); - return G10ERR_TRUSTDB; + lid, gpg_errstr(rc)); + return GPGERR_TRUSTDB; } if( rec.rectype == RECTYPE_SDIR ) return 0; if( rec.rectype != RECTYPE_DIR ) { log_error(_("lid %lu: expected dir record, got type %d\n"), lid, rec.rectype ); - return G10ERR_TRUSTDB; + return GPGERR_TRUSTDB; } if( !rec.r.dir.keylist ) { log_error(_("no primary key for LID %lu\n"), lid ); - return G10ERR_TRUSTDB; + return GPGERR_TRUSTDB; } rc = tdbio_read_record( rec.r.dir.keylist, &rec, RECTYPE_KEY ); if( rc ) { log_error(_("error reading primary key for LID %lu: %s\n"), - lid, g10_errstr(rc)); - return G10ERR_TRUSTDB; + lid, gpg_errstr(rc)); + return GPGERR_TRUSTDB; } keyid_from_fingerprint( rec.r.key.fingerprint, rec.r.key.fingerprint_len, keyid ); @@ -401,7 +401,7 @@ get_dir_record( PKT_public_key *pk, TRUSTREC *rec ) else { /* no local_id: scan the trustdb */ if( (rc=tdbio_search_dir_bypk( pk, rec )) && rc != -1 ) log_error(_("get_dir_record: search_record failed: %s\n"), - g10_errstr(rc)); + gpg_errstr(rc)); } return rc; } @@ -508,7 +508,7 @@ verify_own_keys(void) release_public_key_parts( pk ); } if( rc != -1 ) - log_error(_("enumerate secret keys failed: %s\n"), g10_errstr(rc) ); + log_error(_("enumerate secret keys failed: %s\n"), gpg_errstr(rc) ); else rc = 0; @@ -567,7 +567,7 @@ init_trustdb() else BUG(); if( rc ) - log_fatal("can't init trustdb: %s\n", g10_errstr(rc) ); + log_fatal("can't init trustdb: %s\n", gpg_errstr(rc) ); } @@ -800,7 +800,7 @@ create_shadow_dir( PKT_signature *sig ) /* first see whether we already have such a record */ rc = tdbio_search_sdir( sig->keyid, sig->pubkey_algo, &sdir ); if( rc && rc != -1 ) { - log_error("tdbio_search_sdir failed: %s\n", g10_errstr(rc)); + log_error("tdbio_search_sdir failed: %s\n", gpg_errstr(rc)); tdbio_invalid(); } if( rc == -1 ) { /* not found: create */ @@ -882,7 +882,7 @@ check_keybinding( KBNODE keyblock, KBNODE keynode, u32 *mainkid, else { log_info(_( "key %08lX.%lu: Invalid subkey binding: %s\n"), - (ulong)keyid_from_pk(pk,NULL), lid, g10_errstr(rc) ); + (ulong)keyid_from_pk(pk,NULL), lid, gpg_errstr(rc) ); keyflags |= KEYF_CHECKED; keyflags &= ~KEYF_VALID; } @@ -900,7 +900,7 @@ check_keybinding( KBNODE keyblock, KBNODE keynode, u32 *mainkid, else { log_info(_( "key %08lX.%lu: Invalid key revocation: %s\n"), - (ulong)keyid_from_pk(pk,NULL), lid, g10_errstr(rc) ); + (ulong)keyid_from_pk(pk,NULL), lid, gpg_errstr(rc) ); } revoke_seen = 1; } @@ -917,7 +917,7 @@ check_keybinding( KBNODE keyblock, KBNODE keynode, u32 *mainkid, else { log_info(_( "key %08lX.%lu: Invalid subkey binding: %s\n"), - (ulong)keyid_from_pk(pk,NULL), lid, g10_errstr(rc) ); + (ulong)keyid_from_pk(pk,NULL), lid, gpg_errstr(rc) ); } revoke_seen = 1; } @@ -1032,7 +1032,7 @@ check_uidsigs( KBNODE keyblock, KBNODE keynode, u32 *mainkid, ulong lid, else { log_info( "uid %08lX: %s: %s\n", (ulong)mainkid[1], _("Invalid self-signature"), - g10_errstr(rc) ); + gpg_errstr(rc) ); uidflags |= UIDF_CHECKED; } } @@ -1070,7 +1070,7 @@ check_uidsigs( KBNODE keyblock, KBNODE keynode, u32 *mainkid, ulong lid, else { log_info("uid %08lX: %s: %s\n", (ulong)mainkid[1], _("Invalid user ID revocation"), - g10_errstr(rc) ); + gpg_errstr(rc) ); } } } @@ -1120,7 +1120,7 @@ check_sig_record( KBNODE keyblock, KBNODE signode, else /**mod_up = 1*/; } - else if( rc == G10ERR_NO_PUBKEY ) { + else if( rc == GPGERR_NO_PUBKEY ) { /* This may happen if the key is still in the trustdb * but not available in the keystorage */ sigflag |= SIGF_NOPUBKEY; @@ -1134,7 +1134,7 @@ check_sig_record( KBNODE keyblock, KBNODE signode, (ulong)sig->keyid[1], revocation? _("Invalid certificate revocation") : _("Invalid certificate"), - g10_errstr(rc)); + gpg_errstr(rc)); sigflag |= SIGF_CHECKED; if( revocation ) { sigflag |= SIGF_REVOKED; @@ -1512,7 +1512,7 @@ insert_trust_record( KBNODE keyblock ) * as the dir record. */ rc = tdbio_search_sdir( pk->keyid, pk->pubkey_algo, &shadow ); if( rc && rc != -1 ) { - log_error(_("tdbio_search_dir failed: %s\n"), g10_errstr(rc)); + log_error(_("tdbio_search_dir failed: %s\n"), gpg_errstr(rc)); tdbio_invalid(); } memset( &dirrec, 0, sizeof dirrec ); @@ -1564,7 +1564,7 @@ insert_trust_record_by_pk( PKT_public_key *pk ) rc = get_keyblock_byfprint( &keyblock, fingerprint, fingerlen ); if( rc ) { /* that should never happen */ log_debug( "insert_trust_record_by_pk: keyblock not found: %s\n", - g10_errstr(rc) ); + gpg_errstr(rc) ); } else { rc = insert_trust_record( keyblock ); @@ -1593,7 +1593,7 @@ check_trust_record( TRUSTREC *drec ) rc = get_keyblock_bylid( &keyblock, drec->recnum ); if( rc ) { log_debug( "check_trust_record %lu: keyblock not found: %s\n", - drec->recnum, g10_errstr(rc) ); + drec->recnum, gpg_errstr(rc) ); return rc; } @@ -1635,12 +1635,12 @@ update_trustdb() rc = insert_trust_record( keyblock ); if( rc && !pk->local_id ) { log_error(_("lid ?: insert failed: %s\n"), - g10_errstr(rc) ); + gpg_errstr(rc) ); err_count++; } else if( rc ) { log_error(_("lid %lu: insert failed: %s\n"), - pk->local_id, g10_errstr(rc) ); + pk->local_id, gpg_errstr(rc) ); err_count++; } else { @@ -1650,7 +1650,7 @@ update_trustdb() } } else if( rc ) { - log_error(_("error reading dir record: %s\n"), g10_errstr(rc)); + log_error(_("error reading dir record: %s\n"), gpg_errstr(rc)); err_count++; } @@ -1665,7 +1665,7 @@ update_trustdb() log_info(_("\t%lu keys inserted\n"), new_count); } if( rc && rc != -1 ) - log_error(_("enumerate keyblocks failed: %s\n"), g10_errstr(rc)); + log_error(_("enumerate keyblocks failed: %s\n"), gpg_errstr(rc)); enum_keyblocks( 2, &kbpos, &keyblock ); /* close */ release_kbnode( keyblock ); @@ -2056,11 +2056,11 @@ do_check( TRUSTREC *dr, unsigned *validity, { if( !dr->r.dir.keylist ) { log_error(_("Ooops, no keys\n")); - return G10ERR_TRUSTDB; + return GPGERR_TRUSTDB; } if( !dr->r.dir.uidlist ) { log_error(_("Ooops, no user IDs\n")); - return G10ERR_TRUSTDB; + return GPGERR_TRUSTDB; } if( retflgs ) @@ -2217,16 +2217,16 @@ check_trust( PKT_public_key *pk, unsigned *r_trustlevel, else { /* no local_id: scan the trustdb */ if( (rc=tdbio_search_dir_bypk( pk, &rec )) && rc != -1 ) { log_error(_("check_trust: search dir record failed: %s\n"), - g10_errstr(rc)); + gpg_errstr(rc)); return rc; } else if( rc == -1 && opt.dry_run ) - return G10ERR_GENERAL; + return GPGERR_GENERAL; else if( rc == -1 ) { /* not found - insert */ rc = insert_trust_record_by_pk( pk ); if( rc ) { log_error(_("key %08lX: insert trust record failed: %s\n"), - (ulong)keyid[1], g10_errstr(rc)); + (ulong)keyid[1], gpg_errstr(rc)); goto leave; } log_info(_("key %08lX.%lu: inserted into trustdb\n"), @@ -2240,7 +2240,7 @@ check_trust( PKT_public_key *pk, unsigned *r_trustlevel, log_info(_("key %08lX.%lu: created in future " "(time warp or clock problem)\n"), (ulong)keyid[1], pk->local_id ); - return G10ERR_TIME_CONFLICT; + return GPGERR_TIME_CONFLICT; } if( rec.r.dir.checkat && rec.r.dir.checkat <= cur_time ) check_trust_record( &rec ); @@ -2255,7 +2255,7 @@ check_trust( PKT_public_key *pk, unsigned *r_trustlevel, rc = do_check( &rec, &trustlevel, namehash, add_fnc, retflgs ); if( rc ) { log_error(_("key %08lX.%lu: trust check failed: %s\n"), - (ulong)keyid[1], pk->local_id, g10_errstr(rc)); + (ulong)keyid[1], pk->local_id, gpg_errstr(rc)); return rc; } } @@ -2360,16 +2360,16 @@ list_trust_path( const char *username ) init_trustdb(); if( (rc = get_pubkey_byname(NULL, pk, username, NULL )) ) - log_error(_("user '%s' not found: %s\n"), username, g10_errstr(rc) ); + log_error(_("user '%s' not found: %s\n"), username, gpg_errstr(rc) ); else if( (rc=tdbio_search_dir_bypk( pk, &rec )) && rc != -1 ) log_error(_("problem finding '%s' in trustdb: %s\n"), - username, g10_errstr(rc)); + username, gpg_errstr(rc)); else if( rc == -1 ) { log_info(_("user '%s' not in trustdb - inserting\n"), username); rc = insert_trust_record_by_pk( pk ); if( rc ) log_error(_("failed to put '%s' into trustdb: %s\n"), - username, g10_errstr(rc)); + username, gpg_errstr(rc)); else { assert( pk->local_id ); } diff --git a/g10/trustdb.h b/g10/trustdb.h index 6396fde45..86351c1eb 100644 --- a/g10/trustdb.h +++ b/g10/trustdb.h @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_TRUSTDB_H -#define G10_TRUSTDB_H +#ifndef GPG_TRUSTDB_H +#define GPG_TRUSTDB_H /* Trust values must be sorted in ascending order */ @@ -78,4 +78,4 @@ void import_ownertrust(const char *fname); /*-- pkclist.c --*/ int edit_ownertrust( ulong lid, int mode ); -#endif /*G10_TRUSTDB_H*/ +#endif /*GPG_TRUSTDB_H*/ diff --git a/g10/verify.c b/g10/verify.c index bdb6f178f..5fdf99338 100644 --- a/g10/verify.c +++ b/g10/verify.c @@ -64,7 +64,7 @@ verify_signatures( int nfiles, char **files ) fp = iobuf_open(sigfile); if( !fp ) { log_error(_("can't open `%s'\n"), print_fname_stdin(sigfile)); - return G10ERR_OPEN_FILE; + return GPGERR_OPEN_FILE; } if( !opt.no_armor ) { diff --git a/include/ChangeLog b/include/ChangeLog index e37b9a3db..dc8e6fbc1 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +Thu Jan 27 18:00:44 CET 2000 Werner Koch <wk@gnupg.de> + + * Changed all "g10_"/"GPG_" prefixes to "gpg_"/"GPG_". + Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de> * memory.h: Removed. diff --git a/include/errors.h b/include/errors.h index a126e2636..cb60e7dae 100644 --- a/include/errors.h +++ b/include/errors.h @@ -17,66 +17,66 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_ERRORS_H -#define G10_ERRORS_H +#ifndef GPG_ERRORS_H +#define GPG_ERRORS_H /* FIXME: some constants have to be the same as the ones from * libgcrypt - include gcrypt.h and use those constants */ -#define G10ERR_GENERAL 101 -#define G10ERR_UNKNOWN_PACKET 102 -#define G10ERR_UNKNOWN_VERSION 103 /* Unknown version (in packet) */ -#define G10ERR_PUBKEY_ALGO 4 /* Unknown pubkey algorithm */ -#define G10ERR_DIGEST_ALGO 5 /* Unknown digest algorithm */ -#define G10ERR_BAD_PUBKEY 6 /* Bad public key */ -#define G10ERR_BAD_SECKEY 7 /* Bad secret key */ -#define G10ERR_BAD_SIGN 8 /* Bad signature */ -#define G10ERR_NO_PUBKEY 109 /* public key not found */ -#define G10ERR_CHECKSUM 110 /* checksum error */ -#define G10ERR_BAD_PASS 111 /* Bad passphrase */ -#define G10ERR_CIPHER_ALGO 12 /* Unknown cipher algorithm */ -#define G10ERR_KEYRING_OPEN 113 -#define G10ERR_INVALID_PACKET 114 -#define G10ERR_INVALID_ARMOR 115 -#define G10ERR_NO_USER_ID 116 -#define G10ERR_NO_SECKEY 117 /* secret key not available */ -#define G10ERR_WRONG_SECKEY 118 /* wrong seckey used */ -#define G10ERR_UNSUPPORTED 119 -#define G10ERR_BAD_KEY 120 /* bad (session) key */ -#define G10ERR_READ_FILE 121 -#define G10ERR_WRITE_FILE 122 -#define G10ERR_COMPR_ALGO 123 /* Unknown compress algorithm */ -#define G10ERR_OPEN_FILE 124 -#define G10ERR_CREATE_FILE 125 -#define G10ERR_PASSPHRASE 126 /* invalid passphrase */ -#define G10ERR_NI_PUBKEY 127 -#define G10ERR_NI_CIPHER 128 -#define G10ERR_SIG_CLASS 129 -#define G10ERR_BAD_MPI 30 -#define G10ERR_RESOURCE_LIMIT 131 -#define G10ERR_INV_KEYRING 132 -#define G10ERR_TRUSTDB 133 /* a problem with the trustdb */ -#define G10ERR_BAD_CERT 134 /* bad certicate */ -#define G10ERR_INV_USER_ID 135 -#define G10ERR_CLOSE_FILE 136 -#define G10ERR_RENAME_FILE 137 -#define G10ERR_DELETE_FILE 138 -#define G10ERR_UNEXPECTED 139 -#define G10ERR_TIME_CONFLICT 140 -#define G10ERR_WR_PUBKEY_ALGO 41 /* unusabe pubkey algo */ -#define G10ERR_FILE_EXISTS 142 -#define G10ERR_WEAK_KEY 43 /* NOTE: hardcoded into the cipher modules */ -#define G10ERR_WRONG_KEYLEN 44 /* NOTE: hardcoded into the cipher modules */ -#define G10ERR_INV_ARG 145 -#define G10ERR_BAD_URI 146 /* syntax error in URI */ -#define G10ERR_INVALID_URI 147 /* e.g. unsupported scheme */ -#define G10ERR_NETWORK 148 /* general network error */ -#define G10ERR_UNKNOWN_HOST 149 -#define G10ERR_SELFTEST_FAILED 50 -#define G10ERR_NOT_ENCRYPTED 151 +#define GPGERR_GENERAL 101 +#define GPGERR_UNKNOWN_PACKET 102 +#define GPGERR_UNKNOWN_VERSION 103 /* Unknown version (in packet) */ +#define GPGERR_PUBKEY_ALGO 4 /* Unknown pubkey algorithm */ +#define GPGERR_DIGEST_ALGO 5 /* Unknown digest algorithm */ +#define GPGERR_BAD_PUBKEY 6 /* Bad public key */ +#define GPGERR_BAD_SECKEY 7 /* Bad secret key */ +#define GPGERR_BAD_SIGN 8 /* Bad signature */ +#define GPGERR_NO_PUBKEY 109 /* public key not found */ +#define GPGERR_CHECKSUM 110 /* checksum error */ +#define GPGERR_BAD_PASS 111 /* Bad passphrase */ +#define GPGERR_CIPHER_ALGO 12 /* Unknown cipher algorithm */ +#define GPGERR_KEYRING_OPEN 113 +#define GPGERR_INVALID_PACKET 114 +#define GPGERR_INVALID_ARMOR 115 +#define GPGERR_NO_USER_ID 116 +#define GPGERR_NO_SECKEY 117 /* secret key not available */ +#define GPGERR_WRONG_SECKEY 118 /* wrong seckey used */ +#define GPGERR_UNSUPPORTED 119 +#define GPGERR_BAD_KEY 120 /* bad (session) key */ +#define GPGERR_READ_FILE 121 +#define GPGERR_WRITE_FILE 122 +#define GPGERR_COMPR_ALGO 123 /* Unknown compress algorithm */ +#define GPGERR_OPEN_FILE 124 +#define GPGERR_CREATE_FILE 125 +#define GPGERR_PASSPHRASE 126 /* invalid passphrase */ +#define GPGERR_NI_PUBKEY 127 +#define GPGERR_NI_CIPHER 128 +#define GPGERR_SIG_CLASS 129 +#define GPGERR_BAD_MPI 30 +#define GPGERR_RESOURCE_LIMIT 131 +#define GPGERR_INV_KEYRING 132 +#define GPGERR_TRUSTDB 133 /* a problem with the trustdb */ +#define GPGERR_BAD_CERT 134 /* bad certicate */ +#define GPGERR_INV_USER_ID 135 +#define GPGERR_CLOSE_FILE 136 +#define GPGERR_RENAME_FILE 137 +#define GPGERR_DELETE_FILE 138 +#define GPGERR_UNEXPECTED 139 +#define GPGERR_TIME_CONFLICT 140 +#define GPGERR_WR_PUBKEY_ALGO 41 /* unusabe pubkey algo */ +#define GPGERR_FILE_EXISTS 142 +#define GPGERR_WEAK_KEY 43 /* NOTE: hardcoded into the cipher modules */ +#define GPGERR_WRONG_KEYLEN 44 /* NOTE: hardcoded into the cipher modules */ +#define GPGERR_INV_ARG 145 +#define GPGERR_BAD_URI 146 /* syntax error in URI */ +#define GPGERR_INVALID_URI 147 /* e.g. unsupported scheme */ +#define GPGERR_NETWORK 148 /* general network error */ +#define GPGERR_UNKNOWN_HOST 149 +#define GPGERR_SELFTEST_FAILED 50 +#define GPGERR_NOT_ENCRYPTED 151 #ifndef HAVE_STRERROR char *strerror( int n ); #endif -#endif /*G10_ERRORS_H*/ +#endif /*GPG_ERRORS_H*/ diff --git a/include/host2net.h b/include/host2net.h index 4c14d64ce..784737a0d 100644 --- a/include/host2net.h +++ b/include/host2net.h @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_HOST2NET_H -#define G10_HOST2NET_H +#ifndef GPG_HOST2NET_H +#define GPG_HOST2NET_H #include "types.h" @@ -40,4 +40,4 @@ #define u32tobuf( p, a) ulongtobuf( (p), (a) ) -#endif /*G10_HOST2NET_H*/ +#endif /*GPG_HOST2NET_H*/ diff --git a/include/http.h b/include/http.h index 7e6d9d970..e644a1b11 100644 --- a/include/http.h +++ b/include/http.h @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_HTTP_H -#define G10_HTTP_H 1 +#ifndef GPG_HTTP_H +#define GPG_HTTP_H 1 #include "iobuf.h" @@ -72,4 +72,4 @@ void http_close( HTTP_HD hd ); int http_open_document( HTTP_HD hd, const char *document, unsigned int flags ); -#endif /*G10_HTTP_H*/ +#endif /*GPG_HTTP_H*/ diff --git a/include/i18n.h b/include/i18n.h index 5caf86e92..db22940a3 100644 --- a/include/i18n.h +++ b/include/i18n.h @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_I18N_H -#define G10_I18N_H +#ifndef GPG_I18N_H +#define GPG_I18N_H #ifdef USE_SIMPLE_GETTEXT int set_gettext_file( const char *filename ); @@ -47,4 +47,4 @@ #endif #endif /* !USE_SIMPLE_GETTEXT */ -#endif /*G10_I18N_H*/ +#endif /*GPG_I18N_H*/ diff --git a/include/iobuf.h b/include/iobuf.h index 363b09e5b..cbbb74133 100644 --- a/include/iobuf.h +++ b/include/iobuf.h @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_IOBUF_H -#define G10_IOBUF_H +#ifndef GPG_IOBUF_H +#define GPG_IOBUF_H #include "types.h" @@ -144,4 +144,4 @@ int iobuf_in_block_mode( IOBUF a ); #define iobuf_get_temp_length(a) ( (a)->d.len ) #define iobuf_is_temp(a) ( (a)->use == 3 ) -#endif /*G10_IOBUF_H*/ +#endif /*GPG_IOBUF_H*/ diff --git a/include/ttyio.h b/include/ttyio.h index 7992d85e8..0b447066f 100644 --- a/include/ttyio.h +++ b/include/ttyio.h @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_TTYIO_H -#define G10_TTYIO_H +#ifndef GPG_TTYIO_H +#define GPG_TTYIO_H int tty_batchmode( int onoff ); void tty_printf( const char *fmt, ... ); @@ -31,4 +31,4 @@ int tty_get_answer_is_yes( const char *prompt ); int tty_no_terminal(int onoff); -#endif /*G10_TTYIO_H*/ +#endif /*GPG_TTYIO_H*/ diff --git a/include/types.h b/include/types.h index baac2b5c2..6e12c3406 100644 --- a/include/types.h +++ b/include/types.h @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_TYPES_H -#define G10_TYPES_H +#ifndef GPG_TYPES_H +#define GPG_TYPES_H /* The AC_CHECK_SIZEOF() in configure fails for some machines. @@ -116,4 +116,4 @@ typedef struct string_list { } *STRLIST; -#endif /*G10_TYPES_H*/ +#endif /*GPG_TYPES_H*/ diff --git a/include/util.h b/include/util.h index db221bba6..a95b42c7b 100644 --- a/include/util.h +++ b/include/util.h @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef G10_UTIL_H -#define G10_UTIL_H +#ifndef GPG_UTIL_H +#define GPG_UTIL_H #ifdef _GCRYPT_IN_LIBGCRYPT #error This header should not be used internally by libgcrypt @@ -36,60 +36,60 @@ /*-- logger.c --*/ void log_set_logfile( const char *name, int fd ); FILE *log_stream(void); -void g10_log_print_prefix(const char *text); +void gpg_log_print_prefix(const char *text); void log_set_name( const char *name ); const char *log_get_name(void); void log_set_pid( int pid ); int log_get_errorcount( int clear ); -void g10_log_hexdump( const char *text, const char *buf, size_t len ); +void gpg_log_hexdump( const char *text, const char *buf, size_t len ); #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) - void g10_log_bug( const char *fmt, ... ) + void gpg_log_bug( const char *fmt, ... ) __attribute__ ((noreturn, format (printf,1,2))); - void g10_log_bug0( const char *, int, const char * ) __attribute__ ((noreturn)); - void g10_log_fatal( const char *fmt, ... ) + void gpg_log_bug0( const char *, int, const char * ) __attribute__ ((noreturn)); + void gpg_log_fatal( const char *fmt, ... ) __attribute__ ((noreturn, format (printf,1,2))); - void g10_log_error( const char *fmt, ... ) __attribute__ ((format (printf,1,2))); - void g10_log_info( const char *fmt, ... ) __attribute__ ((format (printf,1,2))); - void g10_log_debug( const char *fmt, ... ) __attribute__ ((format (printf,1,2))); - void g10_log_fatal_f( const char *fname, const char *fmt, ... ) + void gpg_log_error( const char *fmt, ... ) __attribute__ ((format (printf,1,2))); + void gpg_log_info( const char *fmt, ... ) __attribute__ ((format (printf,1,2))); + void gpg_log_debug( const char *fmt, ... ) __attribute__ ((format (printf,1,2))); + void gpg_log_fatal_f( const char *fname, const char *fmt, ... ) __attribute__ ((noreturn, format (printf,2,3))); - void g10_log_error_f( const char *fname, const char *fmt, ... ) + void gpg_log_error_f( const char *fname, const char *fmt, ... ) __attribute__ ((format (printf,2,3))); - void g10_log_info_f( const char *fname, const char *fmt, ... ) + void gpg_log_info_f( const char *fname, const char *fmt, ... ) __attribute__ ((format (printf,2,3))); - void g10_log_debug_f( const char *fname, const char *fmt, ... ) + void gpg_log_debug_f( const char *fname, const char *fmt, ... ) __attribute__ ((format (printf,2,3))); - #define BUG() g10_log_bug0( __FILE__ , __LINE__, __FUNCTION__ ) + #define BUG() gpg_log_bug0( __FILE__ , __LINE__, __FUNCTION__ ) #else - void g10_log_bug( const char *fmt, ... ); - void g10_log_bug0( const char *, int ); - void g10_log_fatal( const char *fmt, ... ); - void g10_log_error( const char *fmt, ... ); - void g10_log_info( const char *fmt, ... ); - void g10_log_debug( const char *fmt, ... ); - void g10_log_fatal_f( const char *fname, const char *fmt, ... ); - void g10_log_error_f( const char *fname, const char *fmt, ... ); - void g10_log_info_f( const char *fname, const char *fmt, ... ); - void g10_log_debug_f( const char *fname, const char *fmt, ... ); - #define BUG() g10_log_bug0( __FILE__ , __LINE__ ) + void gpg_log_bug( const char *fmt, ... ); + void gpg_log_bug0( const char *, int ); + void gpg_log_fatal( const char *fmt, ... ); + void gpg_log_error( const char *fmt, ... ); + void gpg_log_info( const char *fmt, ... ); + void gpg_log_debug( const char *fmt, ... ); + void gpg_log_fatal_f( const char *fname, const char *fmt, ... ); + void gpg_log_error_f( const char *fname, const char *fmt, ... ); + void gpg_log_info_f( const char *fname, const char *fmt, ... ); + void gpg_log_debug_f( const char *fname, const char *fmt, ... ); + #define BUG() gpg_log_bug0( __FILE__ , __LINE__ ) #endif -#define log_hexdump g10_log_hexdump -#define log_bug g10_log_bug -#define log_bug0 g10_log_bug0 -#define log_fatal g10_log_fatal -#define log_error g10_log_error -#define log_info g10_log_info -#define log_debug g10_log_debug -#define log_fatal_f g10_log_fatal_f -#define log_error_f g10_log_error_f -#define log_info_f g10_log_info_f -#define log_debug_f g10_log_debug_f +#define log_hexdump gpg_log_hexdump +#define log_bug gpg_log_bug +#define log_bug0 gpg_log_bug0 +#define log_fatal gpg_log_fatal +#define log_error gpg_log_error +#define log_info gpg_log_info +#define log_debug gpg_log_debug +#define log_fatal_f gpg_log_fatal_f +#define log_error_f gpg_log_error_f +#define log_info_f gpg_log_info_f +#define log_debug_f gpg_log_debug_f /*-- errors.c --*/ -const char * g10_errstr( int no ); +const char * gpg_errstr( int no ); @@ -145,4 +145,4 @@ int check_utf8_string( const char *string ); #define DIM(v) (sizeof(v)/sizeof((v)[0])) #define DIMof(type,member) DIM(((type *)0)->member) -#endif /*G10_UTIL_H*/ +#endif /*GPG_UTIL_H*/ diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog new file mode 100644 index 000000000..a41901bf4 --- /dev/null +++ b/jnlib/ChangeLog @@ -0,0 +1,14 @@ +Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de> + + * README: New. + * Makefile.am: new. + * argparse.c argparse.h logging.c logging.h + mischelp.h stringhelp.c stringhelp.h xmalloc.c + xmalloc.h dotlock.c: Moved from ../util to here. + * dotlock.h: New. + * libjnlib-config.h: New. + + * logging.c (log_set_file): New. + (log_printf): New. + (do_logv): Add kludge to insert LFs. + 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 <wk@gnupg.de> + + * Changed all "g10_"/"GPG_" prefixes to "gpg_"/"GPG_". + Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de> * 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" |