diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 869354be..fc31bc40 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,5 +1,13 @@ 2003-01-29 Marcus Brinkmann + * util.h (mk_error): Remove macro. + * conversion.c, data.c, data-compat.c, decrypt.c, delete.c, + edit.c, encrypt.c, encrypt-sign.c, engine.c, engine-gpgsm.c, + export.c, genkey.c, gpgme.c, import.c, key.c, keylist.c, + passphrase.c, progress.c, recipient.c, rungpg.c, sign.c, + signers.c, trustlist.c, verify.c, wait.c, wait-global.c, + wait-private (literally everywhere): Expand the mk_error macro. + * context.h (wait_on_request_or_fail): Remove macro. * context.h (gpgme_context_s): Remove member ERROR. diff --git a/gpgme/conversion.c b/gpgme/conversion.c index 32fc954c..143c8dbc 100644 --- a/gpgme/conversion.c +++ b/gpgme/conversion.c @@ -76,7 +76,7 @@ _gpgme_decode_c_string (const char *src, char **destp, int len) string will never be larger. */ dest = malloc (strlen (src) + 1); if (!dest) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; *destp = dest; } @@ -158,13 +158,13 @@ GpgmeError _gpgme_data_append (GpgmeData dh, const char *buffer, size_t length) { if (!dh || !buffer) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; do { ssize_t amt = gpgme_data_write (dh, buffer, length); if (amt == 0 || (amt < 0 && errno != EINTR)) - return mk_error (File_Error); + return GPGME_File_Error; buffer += amt; length -= amt; } @@ -192,7 +192,7 @@ _gpgme_data_append_for_xml (GpgmeData dh, const char *buffer, size_t len) int err = 0; if (!dh || !buffer) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; do { diff --git a/gpgme/data-compat.c b/gpgme/data-compat.c index 3c934061..c5ec0716 100644 --- a/gpgme/data-compat.c +++ b/gpgme/data-compat.c @@ -40,12 +40,12 @@ gpgme_data_new_from_filepart (GpgmeData *dh, const char *fname, FILE *stream, char *buf = NULL; if (stream && fname) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (fname) stream = fopen (fname, "rb"); if (!stream) - return mk_error (File_Error); + return GPGME_File_Error; if (fseek (stream, offset, SEEK_SET)) goto ferr; @@ -85,7 +85,7 @@ gpgme_data_new_from_filepart (GpgmeData *dh, const char *fname, FILE *stream, if (fname) fclose (stream); errno = saved_errno; - return mk_error (File_Error); + return GPGME_File_Error; } } @@ -98,10 +98,10 @@ gpgme_data_new_from_file (GpgmeData *dh, const char *fname, int copy) struct stat statbuf; if (!fname || !copy) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (stat (fname, &statbuf) < 0) - return mk_error (File_Error); + return GPGME_File_Error; return gpgme_data_new_from_filepart (dh, fname, NULL, 0, statbuf.st_size); } @@ -112,18 +112,18 @@ gpgme_error_to_errno (GpgmeError err) { switch (err) { - case mk_error (EOF): + case GPGME_EOF: return 0; - case mk_error (Out_Of_Core): + case GPGME_Out_Of_Core: errno = ENOMEM; return -1; - case mk_error (Invalid_Value): + case GPGME_Invalid_Value: errno = EINVAL; return -1; - case mk_error (Busy): + case GPGME_Busy: errno = EBUSY; return -1; - case mk_error (Not_Implemented): + case GPGME_Not_Implemented: errno = EOPNOTSUPP; return -1; default: @@ -188,5 +188,5 @@ GpgmeError gpgme_data_rewind (GpgmeData dh) { return (gpgme_data_seek (dh, 0, SEEK_SET) == -1) - ? mk_error (File_Error) : 0; + ? GPGME_File_Error : 0; } diff --git a/gpgme/data.c b/gpgme/data.c index ccec8132..e0ab8fbb 100644 --- a/gpgme/data.c +++ b/gpgme/data.c @@ -39,12 +39,12 @@ _gpgme_data_new (GpgmeData *r_dh, struct gpgme_data_cbs *cbs) GpgmeData dh; if (!r_dh) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; *r_dh = NULL; dh = calloc (1, sizeof (*dh)); if (!dh) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; dh->cbs = cbs; @@ -149,7 +149,7 @@ GpgmeError gpgme_data_set_encoding (GpgmeData dh, GpgmeDataEncoding enc) { if (!dh) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (enc < 0 || enc > GPGME_DATA_ENCODING_ARMOR) return GPGME_Invalid_Value; dh->encoding = enc; @@ -170,7 +170,7 @@ _gpgme_data_inbound_handler (void *opaque, int fd) buflen = read (fd, buffer, BUFFER_SIZE); if (buflen < 0) - return mk_error (File_Error); + return GPGME_File_Error; if (buflen == 0) { _gpgme_io_close (fd); @@ -193,7 +193,7 @@ _gpgme_data_outbound_handler (void *opaque, int fd) { ssize_t amt = gpgme_data_read (dh, dh->pending, BUFFER_SIZE); if (amt < 0) - return mk_error (File_Error); + return GPGME_File_Error; if (amt == 0) { _gpgme_io_close (fd); @@ -207,7 +207,7 @@ _gpgme_data_outbound_handler (void *opaque, int fd) return 0; if (nwritten <= 0) - return mk_error (File_Error); + return GPGME_File_Error; if (nwritten < dh->pending_len) memmove (dh->pending, dh->pending + nwritten, dh->pending_len - nwritten); diff --git a/gpgme/decrypt.c b/gpgme/decrypt.c index 7f3189eb..6f38e6a0 100644 --- a/gpgme/decrypt.c +++ b/gpgme/decrypt.c @@ -100,9 +100,9 @@ _gpgme_decrypt_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args) { case GPGME_STATUS_EOF: if (ctx->result.decrypt->failed) - return mk_error (Decryption_Failed); + return GPGME_Decryption_Failed; else if (!ctx->result.decrypt->okay) - return mk_error (No_Data); + return GPGME_No_Data; break; case GPGME_STATUS_DECRYPTION_OKAY: @@ -172,12 +172,12 @@ _gpgme_decrypt_start (GpgmeCtx ctx, int synchronous, /* Check the supplied data. */ if (!ciph) { - err = mk_error (No_Data); + err = GPGME_No_Data; goto leave; } if (!plain) { - err = mk_error (Invalid_Value); + err = GPGME_Invalid_Value; goto leave; } diff --git a/gpgme/delete.c b/gpgme/delete.c index e29ad8e0..ec77d3c1 100644 --- a/gpgme/delete.c +++ b/gpgme/delete.c @@ -65,15 +65,15 @@ delete_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args) case DELETE_No_Problem: break; case DELETE_No_Such_Key: - return mk_error(Invalid_Key); + return GPGME_Invalid_Key; break; case DELETE_Must_Delete_Secret_Key: - return mk_error(Conflict); + return GPGME_Conflict; break; case DELETE_Ambiguous_Specification: /* XXX Need better error value. Fall through. */ default: - return mk_error(General_Error); + return GPGME_General_Error; break; } break; diff --git a/gpgme/edit.c b/gpgme/edit.c index 219e657e..d713cab6 100644 --- a/gpgme/edit.c +++ b/gpgme/edit.c @@ -83,7 +83,7 @@ _gpgme_op_edit_start (GpgmeCtx ctx, int synchronous, GpgmeError err = 0; if (!fnc) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; err = _gpgme_op_reset (ctx, synchronous); if (err) @@ -93,7 +93,7 @@ _gpgme_op_edit_start (GpgmeCtx ctx, int synchronous, ctx->result.edit = malloc (sizeof *ctx->result.edit); if (!ctx->result.edit) { - err = mk_error (Out_Of_Core); + err = GPGME_Out_Of_Core; goto leave; } ctx->result.edit->fnc = fnc; @@ -102,7 +102,7 @@ _gpgme_op_edit_start (GpgmeCtx ctx, int synchronous, /* Check the supplied data. */ if (!out) { - err = mk_error (Invalid_Value); + err = GPGME_Invalid_Value; goto leave; } diff --git a/gpgme/encrypt-sign.c b/gpgme/encrypt-sign.c index cc55a146..9768756d 100644 --- a/gpgme/encrypt-sign.c +++ b/gpgme/encrypt-sign.c @@ -64,12 +64,12 @@ _gpgme_op_encrypt_sign_start (GpgmeCtx ctx, int synchronous, /* Check the supplied data */ if (!plain) { - err = mk_error (No_Data); + err = GPGME_No_Data; goto leave; } if (!cipher) { - err = mk_error (Invalid_Value); + err = GPGME_Invalid_Value; goto leave; } diff --git a/gpgme/encrypt.c b/gpgme/encrypt.c index 98e08fd8..06b6ff8f 100644 --- a/gpgme/encrypt.c +++ b/gpgme/encrypt.c @@ -112,9 +112,9 @@ _gpgme_encrypt_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args) ctx->result.encrypt->xmlinfo = NULL; } if (ctx->result.encrypt->no_valid_recipients) - return mk_error (No_Recipients); + return GPGME_No_Recipients; else if (ctx->result.encrypt->invalid_recipients) - return mk_error (Invalid_Recipients); + return GPGME_Invalid_Recipients; break; case GPGME_STATUS_INV_RECP: @@ -153,7 +153,7 @@ _gpgme_op_encrypt_start (GpgmeCtx ctx, int synchronous, symmetric = 1; else if (!gpgme_recipients_count (recp)) { - err = mk_error (No_Recipients); + err = GPGME_No_Recipients; goto leave; } @@ -178,12 +178,12 @@ _gpgme_op_encrypt_start (GpgmeCtx ctx, int synchronous, /* Check the supplied data */ if (!plain) { - err = mk_error (No_Data); + err = GPGME_No_Data; goto leave; } if (!ciph) { - err = mk_error (Invalid_Value); + err = GPGME_Invalid_Value; goto leave; } diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c index f286af92..1ab234d7 100644 --- a/gpgme/engine-gpgsm.c +++ b/gpgme/engine-gpgsm.c @@ -117,7 +117,7 @@ static GpgmeError gpgsm_check_version (void) { return _gpgme_compare_versions (gpgsm_get_version (), NEED_GPGSM_VERSION) - ? 0 : mk_error (Invalid_Engine); + ? 0 : GPGME_Invalid_Engine; } @@ -160,17 +160,17 @@ map_assuan_error (AssuanError err) switch (err) { case ASSUAN_No_Error: - return mk_error (No_Error); + return GPGME_No_Error; case ASSUAN_General_Error: - return mk_error (General_Error); + return GPGME_General_Error; case ASSUAN_Out_Of_Core: - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; case ASSUAN_Invalid_Value: - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; case ASSUAN_Read_Error: - return mk_error (Read_Error); + return GPGME_Read_Error; case ASSUAN_Write_Error: - return mk_error (Write_Error); + return GPGME_Write_Error; case ASSUAN_Timeout: case ASSUAN_Problem_Starting_Server: @@ -182,18 +182,18 @@ map_assuan_error (AssuanError err) case ASSUAN_No_Inquire_Callback: case ASSUAN_Connect_Failed: case ASSUAN_Accept_Failed: - return mk_error (General_Error); + return GPGME_General_Error; /* The following error codes are meant as status codes. */ case ASSUAN_Not_Implemented: - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; case ASSUAN_Canceled: - return mk_error (Canceled); + return GPGME_Canceled; case ASSUAN_Unsupported_Algorithm: - return mk_error (Not_Implemented); /* XXX Argh. */ + return GPGME_Not_Implemented; /* XXX Argh. */ case ASSUAN_No_Data_Available: - return mk_error (EOF); + return GPGME_EOF; /* These are errors internal to GPGME. */ case ASSUAN_No_Input: @@ -216,7 +216,7 @@ map_assuan_error (AssuanError err) case ASSUAN_Unexpected_Data: case ASSUAN_Invalid_Status: case ASSUAN_Not_Confirmed: - return mk_error (General_Error); + return GPGME_General_Error; /* These are errors in the server. */ case ASSUAN_Server_Fault: @@ -225,7 +225,7 @@ map_assuan_error (AssuanError err) case ASSUAN_Server_Bug: case ASSUAN_No_Agent: case ASSUAN_Agent_Error: - return mk_error (Invalid_Engine); /* XXX: Need something more useful. */ + return GPGME_Invalid_Engine; /* XXX: Need something more useful. */ case ASSUAN_Bad_Certificate: case ASSUAN_Bad_Certificate_Path: @@ -238,19 +238,19 @@ map_assuan_error (AssuanError err) case ASSUAN_No_PKCS15_App: /* XXX: Oh well. */ case ASSUAN_Card_Not_Present: /* XXX: Oh well. */ case ASSUAN_Invalid_Id: /* XXX: Oh well. */ - return mk_error (Invalid_Key); + return GPGME_Invalid_Key; case ASSUAN_Bad_Signature: - return mk_error (Invalid_Key); /* XXX: This is wrong. */ + return GPGME_Invalid_Key; /* XXX: This is wrong. */ case ASSUAN_Cert_Revoked: case ASSUAN_No_CRL_For_Cert: case ASSUAN_CRL_Too_Old: case ASSUAN_Not_Trusted: - return mk_error (Invalid_Key); /* XXX Some more details would be good. */ + return GPGME_Invalid_Key; /* XXX Some more details would be good. */ default: - return mk_error (General_Error); + return GPGME_General_Error; } } @@ -299,7 +299,7 @@ gpgsm_new (void **engine) gpgsm = calloc (1, sizeof *gpgsm); if (!gpgsm) { - err = mk_error (Out_Of_Core); + err = GPGME_Out_Of_Core; return err; } @@ -331,7 +331,7 @@ gpgsm_new (void **engine) if (_gpgme_io_pipe (fds, 0) < 0) { - err = mk_error (Pipe_Error); + err = GPGME_Pipe_Error; goto leave; } gpgsm->input_cb.fd = fds[1]; @@ -340,7 +340,7 @@ gpgsm_new (void **engine) if (_gpgme_io_pipe (fds, 1) < 0) { - err = mk_error (Pipe_Error); + err = GPGME_Pipe_Error; goto leave; } gpgsm->output_cb.fd = fds[0]; @@ -349,7 +349,7 @@ gpgsm_new (void **engine) if (_gpgme_io_pipe (fds, 0) < 0) { - err = mk_error (Pipe_Error); + err = GPGME_Pipe_Error; goto leave; } gpgsm->message_cb.fd = fds[1]; @@ -376,7 +376,7 @@ gpgsm_new (void **engine) fdlist, DIM (fdlist)); if (nfds < 1) { - err = mk_error (General_Error); /* FIXME */ + err = GPGME_General_Error; /* FIXME */ goto leave; } /* We duplicate the file descriptor, so we can close it without @@ -387,7 +387,7 @@ gpgsm_new (void **engine) gpgsm->status_cb.fd = dup (fdlist[0]); if (gpgsm->status_cb.fd < 0) { - err = mk_error (General_Error); /* FIXME */ + err = GPGME_General_Error; /* FIXME */ goto leave; } gpgsm->status_cb.dir = 1; @@ -398,7 +398,7 @@ gpgsm_new (void **engine) { if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0) { - err = mk_error (Out_Of_Core); + err = GPGME_Out_Of_Core; goto leave; } err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, @@ -415,7 +415,7 @@ gpgsm_new (void **engine) { if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0) { - err = mk_error (Out_Of_Core); + err = GPGME_Out_Of_Core; goto leave; } err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, NULL, NULL, @@ -432,7 +432,7 @@ gpgsm_new (void **engine) { if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0) { - err = mk_error (Out_Of_Core); + err = GPGME_Out_Of_Core; goto leave; } err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, NULL, NULL, @@ -459,7 +459,7 @@ gpgsm_new (void **engine) if (dft_lc) { if (asprintf (&optstr, "OPTION lc-ctype=%s", dft_lc) < 0) - err = mk_error (Out_Of_Core); + err = GPGME_Out_Of_Core; else { err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, @@ -492,7 +492,7 @@ gpgsm_new (void **engine) if (dft_lc) { if (asprintf (&optstr, "OPTION lc-messages=%s", dft_lc) < 0) - err = mk_error (Out_Of_Core); + err = GPGME_Out_Of_Core; else { err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, NULL, NULL, @@ -521,7 +521,7 @@ gpgsm_new (void **engine) || _gpgme_io_set_close_notify (gpgsm->message_cb.fd, close_notify_handler, gpgsm))) { - err = mk_error (General_Error); + err = GPGME_General_Error; goto leave; } @@ -593,10 +593,10 @@ gpgsm_assuan_simple_command (ASSUAN_CONTEXT ctx, char *cmd, GpgmeStatusHandler s if (r >= 0 && status_fnc) status_fnc (status_fnc_value, r, rest); else - err = mk_error (General_Error); + err = GPGME_General_Error; } else - err = mk_error (General_Error); + err = GPGME_General_Error; } while (!err); @@ -685,7 +685,7 @@ status_handler (void *opaque, int fd) if (line[3] == ' ') err = map_assuan_error (atoi (&line[4])); else - err = mk_error (General_Error); + err = GPGME_General_Error; } else if (linelen >= 2 && line[0] == 'O' && line[1] == 'K' @@ -730,7 +730,7 @@ status_handler (void *opaque, int fd) unsigned char *newline = realloc (*aline, *alinelen + linelen + 1); if (!newline) - err = mk_error (Out_Of_Core); + err = GPGME_Out_Of_Core; else { *aline = newline; @@ -856,17 +856,17 @@ gpgsm_decrypt (void *engine, GpgmeData ciph, GpgmeData plain) GpgmeError err; if (!gpgsm) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; gpgsm->input_cb.data = ciph; err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, map_input_enc (gpgsm->input_cb.data)); if (err) - return mk_error (General_Error); /* FIXME */ + return GPGME_General_Error; /* FIXME */ gpgsm->output_cb.data = plain; err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, 0); if (err) - return mk_error (General_Error); /* FIXME */ + return GPGME_General_Error; /* FIXME */ _gpgme_io_close (gpgsm->message_cb.fd); err = start (engine, "DECRYPT"); @@ -885,7 +885,7 @@ gpgsm_delete (void *engine, GpgmeKey key, int allow_secret) int length = 8; /* "DELKEYS " */ if (!fpr) - return mk_error (Invalid_Key); + return GPGME_Invalid_Key; while (*linep) { @@ -898,7 +898,7 @@ gpgsm_delete (void *engine, GpgmeKey key, int allow_secret) line = malloc (length); if (!line) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; strcpy (line, "DELKEYS "); linep = &line[8]; @@ -954,7 +954,7 @@ set_recipients (GpgsmObject gpgsm, GpgmeRecipients recp) linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */ line = malloc (10 + 40 + 1); if (!line) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; strcpy (line, "RECIPIENT "); for (r = recp->list; r; r = r->next) { @@ -965,7 +965,7 @@ set_recipients (GpgsmObject gpgsm, GpgmeRecipients recp) if (! newline) { free (line); - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } line = newline; linelen = newlen; @@ -997,9 +997,9 @@ gpgsm_encrypt (void *engine, GpgmeRecipients recp, GpgmeData plain, GpgmeError err; if (!gpgsm) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!recp) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; gpgsm->input_cb.data = plain; err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, @@ -1033,11 +1033,11 @@ gpgsm_export (void *engine, GpgmeRecipients recp, GpgmeData keydata, int cmdlen = 32; if (!gpgsm) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; cmd = malloc (cmdlen); if (!cmd) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; strcpy (cmd, "EXPORT"); cmdi = 6; @@ -1057,7 +1057,7 @@ gpgsm_export (void *engine, GpgmeRecipients recp, GpgmeData keydata, if (!newcmd) { free (cmd); - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } cmd = newcmd; cmdlen *= 2; @@ -1094,7 +1094,7 @@ gpgsm_genkey (void *engine, GpgmeData help_data, int use_armor, GpgmeError err; if (!gpgsm || !pubkey || seckey) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; gpgsm->input_cb.data = help_data; err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, @@ -1120,7 +1120,7 @@ gpgsm_import (void *engine, GpgmeData keydata) GpgmeError err; if (!gpgsm) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; gpgsm->input_cb.data = keydata; err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, @@ -1147,7 +1147,7 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only, pattern = ""; if (asprintf (&line, "OPTION list-mode=%d", (keylist_mode & 3)) < 0) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL); free (line); if (err) @@ -1156,7 +1156,7 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only, /* Length is "LISTSECRETKEYS " + p + '\0'. */ line = malloc (15 + strlen (pattern) + 1); if (!line) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; if (secret_only) { strcpy (line, "LISTSECRETKEYS "); @@ -1190,10 +1190,10 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only, char *linep; if (reserved) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (asprintf (&line, "OPTION list-mode=%d", (keylist_mode & 3)) < 0) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL); free (line); if (err) @@ -1221,7 +1221,7 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only, } line = malloc (length); if (!line) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; if (secret_only) { strcpy (line, "LISTSECRETKEYS "); @@ -1291,10 +1291,10 @@ gpgsm_sign (void *engine, GpgmeData in, GpgmeData out, GpgmeSigMode mode, GpgmeKey key; if (!gpgsm) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (asprintf (&assuan_cmd, "OPTION include-certs %i", include_certs) < 0) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, assuan_cmd, NULL,NULL); free (assuan_cmd); if (err) @@ -1347,7 +1347,7 @@ static GpgmeError gpgsm_trustlist (void *engine, const char *pattern) { /* FIXME */ - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; } @@ -1359,7 +1359,7 @@ gpgsm_verify (void *engine, GpgmeData sig, GpgmeData signed_text, GpgmeError err; if (!gpgsm) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; gpgsm->input_cb.data = sig; err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, diff --git a/gpgme/engine.c b/gpgme/engine.c index dff6e544..ee4f387f 100644 --- a/gpgme/engine.c +++ b/gpgme/engine.c @@ -83,10 +83,10 @@ GpgmeError gpgme_engine_check_version (GpgmeProtocol proto) { if (proto > sizeof (engine_ops) / sizeof (engine_ops[0])) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine_ops[proto]) - return mk_error (Invalid_Engine); + return GPGME_Invalid_Engine; if (engine_ops[proto]->check_version) return (*engine_ops[proto]->check_version) (); @@ -143,19 +143,19 @@ _gpgme_engine_new (GpgmeProtocol proto, EngineObject *r_engine) const char *version; if (proto > sizeof (engine_ops) / sizeof (engine_ops[0])) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine_ops[proto]) - return mk_error (Invalid_Engine); + return GPGME_Invalid_Engine; path = _gpgme_engine_get_path (proto); version = _gpgme_engine_get_version (proto); if (!path || !version) - return mk_error (Invalid_Engine); + return GPGME_Invalid_Engine; engine = calloc (1, sizeof *engine); if (!engine) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; engine->ops = engine_ops[proto]; if (engine_ops[proto]->new) @@ -216,10 +216,10 @@ _gpgme_engine_set_command_handler (EngineObject engine, GpgmeData linked_data) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->set_command_handler) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->set_command_handler) (engine->engine, fnc, fnc_value, linked_data); @@ -230,10 +230,10 @@ GpgmeError _gpgme_engine_set_colon_line_handler (EngineObject engine, void *fnc_value) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->set_colon_line_handler) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->set_colon_line_handler) (engine->engine, fnc, fnc_value); @@ -243,10 +243,10 @@ GpgmeError _gpgme_engine_op_decrypt (EngineObject engine, GpgmeData ciph, GpgmeData plain) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->decrypt) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->decrypt) (engine->engine, ciph, plain); } @@ -255,10 +255,10 @@ GpgmeError _gpgme_engine_op_delete (EngineObject engine, GpgmeKey key, int allow_secret) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->delete) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->delete) (engine->engine, key, allow_secret); } @@ -269,10 +269,10 @@ _gpgme_engine_op_edit (EngineObject engine, GpgmeKey key, GpgmeData out, GpgmeCtx ctx /* FIXME */) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->edit) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->edit) (engine->engine, key, out, ctx); } @@ -283,10 +283,10 @@ _gpgme_engine_op_encrypt (EngineObject engine, GpgmeRecipients recp, GpgmeData plain, GpgmeData ciph, int use_armor) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->encrypt) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->encrypt) (engine->engine, recp, plain, ciph, use_armor); @@ -299,10 +299,10 @@ _gpgme_engine_op_encrypt_sign (EngineObject engine, GpgmeRecipients recp, GpgmeCtx ctx /* FIXME */) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->encrypt_sign) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->encrypt_sign) (engine->engine, recp, plain, ciph, use_armor, ctx); @@ -314,10 +314,10 @@ _gpgme_engine_op_export (EngineObject engine, GpgmeRecipients recp, GpgmeData keydata, int use_armor) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->export) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->export) (engine->engine, recp, keydata, use_armor); @@ -329,10 +329,10 @@ _gpgme_engine_op_genkey (EngineObject engine, GpgmeData help_data, int use_armor, GpgmeData pubkey, GpgmeData seckey) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->genkey) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->genkey) (engine->engine, help_data, use_armor, pubkey, seckey); @@ -343,10 +343,10 @@ GpgmeError _gpgme_engine_op_import (EngineObject engine, GpgmeData keydata) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->import) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->import) (engine->engine, keydata); } @@ -357,10 +357,10 @@ _gpgme_engine_op_keylist (EngineObject engine, const char *pattern, int secret_only, int keylist_mode) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->keylist) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->keylist) (engine->engine, pattern, secret_only, keylist_mode); @@ -372,10 +372,10 @@ _gpgme_engine_op_keylist_ext (EngineObject engine, const char *pattern[], int secret_only, int reserved, int keylist_mode) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->keylist_ext) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->keylist_ext) (engine->engine, pattern, secret_only, reserved, keylist_mode); @@ -389,10 +389,10 @@ _gpgme_engine_op_sign (EngineObject engine, GpgmeData in, GpgmeData out, GpgmeCtx ctx /* FIXME */) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->sign) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->sign) (engine->engine, in, out, mode, use_armor, use_textmode, include_certs, ctx); @@ -403,10 +403,10 @@ GpgmeError _gpgme_engine_op_trustlist (EngineObject engine, const char *pattern) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->trustlist) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->trustlist) (engine->engine, pattern); } @@ -417,10 +417,10 @@ _gpgme_engine_op_verify (EngineObject engine, GpgmeData sig, GpgmeData signed_text, GpgmeData plaintext) { if (!engine) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!engine->ops->verify) - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; return (*engine->ops->verify) (engine->engine, sig, signed_text, plaintext); } diff --git a/gpgme/export.c b/gpgme/export.c index 796ae12b..e9e58e14 100644 --- a/gpgme/export.c +++ b/gpgme/export.c @@ -49,7 +49,7 @@ _gpgme_op_export_start (GpgmeCtx ctx, int synchronous, if (!keydata) { - err = mk_error (Invalid_Value); + err = GPGME_Invalid_Value; goto leave; } diff --git a/gpgme/genkey.c b/gpgme/genkey.c index 9ac85959..85e252e7 100644 --- a/gpgme/genkey.c +++ b/gpgme/genkey.c @@ -72,7 +72,7 @@ genkey_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args) free (ctx->result.genkey->fpr); ctx->result.genkey->fpr = strdup (&args[2]); if (!ctx->result.genkey->fpr) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } } break; @@ -81,7 +81,7 @@ genkey_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args) /* FIXME: Should return some more useful error value. */ if (!ctx->result.genkey->created_primary && !ctx->result.genkey->created_sub) - return mk_error (General_Error); + return GPGME_General_Error; break; default: @@ -118,7 +118,7 @@ _gpgme_op_genkey_start (GpgmeCtx ctx, int synchronous, const char *parms, err = gpgme_data_new_from_mem (&ctx->help_data_1, s, s2-s, 1); } else - err = mk_error (Invalid_Value); + err = GPGME_Invalid_Value; if (err) goto leave; @@ -216,7 +216,7 @@ gpgme_op_genkey (GpgmeCtx ctx, const char *parms, { *fpr = strdup (ctx->result.genkey->fpr); if (!*fpr) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } else *fpr = NULL; diff --git a/gpgme/gpgme.c b/gpgme/gpgme.c index b4fc0366..827516cd 100644 --- a/gpgme/gpgme.c +++ b/gpgme/gpgme.c @@ -46,11 +46,11 @@ gpgme_new (GpgmeCtx *r_ctx) GpgmeCtx ctx; if (!r_ctx) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; *r_ctx = 0; ctx = calloc (1, sizeof *ctx); if (!ctx) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL; ctx->verbosity = 1; ctx->include_certs = 1; @@ -199,7 +199,7 @@ GpgmeError gpgme_set_protocol (GpgmeCtx ctx, GpgmeProtocol protocol) { if (!ctx) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; switch (protocol) { @@ -210,9 +210,9 @@ gpgme_set_protocol (GpgmeCtx ctx, GpgmeProtocol protocol) ctx->use_cms = 1; break; case GPGME_PROTOCOL_AUTO: - return mk_error (Not_Implemented); + return GPGME_Not_Implemented; default: - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; } return 0; @@ -345,12 +345,12 @@ GpgmeError gpgme_set_keylist_mode (GpgmeCtx ctx, int mode) { if (!ctx) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!((mode & GPGME_KEYLIST_MODE_LOCAL) || (mode & GPGME_KEYLIST_MODE_EXTERN) || (mode & GPGME_KEYLIST_MODE_SIGS))) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; ctx->keylist_mode = mode; return 0; diff --git a/gpgme/import.c b/gpgme/import.c index b08c8857..d4f1154c 100644 --- a/gpgme/import.c +++ b/gpgme/import.c @@ -186,7 +186,7 @@ _gpgme_op_import_start (GpgmeCtx ctx, int synchronous, GpgmeData keydata) /* Check the supplied data */ if (!keydata) { - err = mk_error (No_Data); + err = GPGME_No_Data; goto leave; } diff --git a/gpgme/key.c b/gpgme/key.c index 2a2af91c..c9ef53d1 100644 --- a/gpgme/key.c +++ b/gpgme/key.c @@ -333,7 +333,7 @@ key_new (GpgmeKey *r_key, int secret) *r_key = NULL; key = calloc (1, sizeof *key); if (!key) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; key->ref_count = 1; *r_key = key; if (secret) @@ -656,7 +656,7 @@ _gpgme_key_append_name (GpgmeKey key, const char *src) size, so that we are able to store the parsed stuff there too. */ uid = malloc (sizeof (*uid) + 2 * src_len + 3); if (!uid) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; memset (uid, 0, sizeof *uid); dst = uid->name; @@ -1199,12 +1199,12 @@ gpgme_get_key (GpgmeCtx ctx, const char *fpr, GpgmeKey *r_key, GpgmeError err; if (!ctx || !r_key) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (ctx->pending) - return mk_error (Busy); + return GPGME_Busy; if (strlen (fpr) < 16) /* We have at least a key ID. */ - return mk_error (Invalid_Key); + return GPGME_Invalid_Key; if (!force_update) { diff --git a/gpgme/keylist.c b/gpgme/keylist.c index 1076d267..3c671dea 100644 --- a/gpgme/keylist.c +++ b/gpgme/keylist.c @@ -384,21 +384,21 @@ keylist_colon_handler (GpgmeCtx ctx, char *line) /* Start a new subkey. */ rectype = RT_SUB; if (!(subkey = _gpgme_key_add_subkey (key))) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } else if (!strcmp (field[0], "ssb") && key) { /* Start a new secret subkey. */ rectype = RT_SSB; if (!(subkey = _gpgme_key_add_secret_subkey (key))) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } else if (!strcmp (field[0], "pub")) { /* Start a new keyblock. */ if (_gpgme_key_new (&key)) /* The only kind of error we can get. */ - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; rectype = RT_PUB; finish_key (ctx); assert (!ctx->tmp_key); @@ -408,7 +408,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line) { /* Start a new keyblock, */ if (_gpgme_key_new_secret (&key)) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; rectype = RT_SEC; finish_key (ctx); assert (!ctx->tmp_key); @@ -418,7 +418,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line) { /* Start a new certificate. */ if (_gpgme_key_new (&key)) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; key->x509 = 1; rectype = RT_CRT; finish_key (ctx); @@ -429,7 +429,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line) { /* Start a new certificate. */ if (_gpgme_key_new_secret (&key)) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; key->x509 = 1; rectype = RT_CRS; finish_key (ctx); @@ -456,14 +456,14 @@ keylist_colon_handler (GpgmeCtx ctx, char *line) { key->issuer_serial = strdup (field[7]); if (!key->issuer_serial) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } /* Field 10 is not used for gpg due to --fixed-list-mode option but GPGSM stores the issuer name. */ if (fields >= 10 && _gpgme_decode_c_string (field[9], &key->issuer_name, 0)) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; /* Fall through! */ case RT_PUB: @@ -563,7 +563,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line) if (fields >= 10) { if (_gpgme_key_append_name (key, field[9])) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; else { if (field[1]) @@ -579,7 +579,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line) { key->keys.fingerprint = strdup (field[9]); if (!key->keys.fingerprint) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } /* Field 13 has the gpgsm chain ID (take only the first one). */ @@ -587,7 +587,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line) { key->chain_id = strdup (field[12]); if (!key->chain_id) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } break; @@ -600,7 +600,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line) assert (ctx->tmp_uid == key->last_uid); certsig = _gpgme_key_add_certsig (key, (fields >= 10) ? field[9] : NULL); if (!certsig) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; /* Field 2 has the calculated trust ('!', '-', '?', '%'). */ if (fields >= 2) @@ -686,7 +686,7 @@ _gpgme_op_keylist_event_cb (void *data, GpgmeEventIO type, void *type_data) if (!q) { gpgme_key_release (key); - /* FIXME return mk_error (Out_Of_Core); */ + /* FIXME return GPGME_Out_Of_Core; */ return; } q->key = key; @@ -825,12 +825,12 @@ gpgme_op_keylist_next (GpgmeCtx ctx, GpgmeKey *r_key) struct key_queue_item_s *queue_item; if (!r_key) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; *r_key = NULL; if (!ctx) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!ctx->pending) - return mk_error (No_Request); + return GPGME_No_Request; if (!ctx->key_queue) { @@ -852,7 +852,7 @@ gpgme_op_keylist_next (GpgmeCtx ctx, GpgmeKey *r_key) if (!ctx->key_cond) { ctx->pending = 0; - return mk_error (EOF); + return GPGME_EOF; } ctx->key_cond = 0; assert (ctx->key_queue); @@ -879,9 +879,9 @@ GpgmeError gpgme_op_keylist_end (GpgmeCtx ctx) { if (!ctx) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!ctx->pending) - return mk_error (No_Request); + return GPGME_No_Request; ctx->pending = 0; return 0; diff --git a/gpgme/ops.h b/gpgme/ops.h index 602b4ea1..83f26f82 100644 --- a/gpgme/ops.h +++ b/gpgme/ops.h @@ -32,7 +32,7 @@ { \ ctx->result.field = calloc (1, sizeof *ctx->result.field); \ if (!ctx->result.field) \ - return mk_error (Out_Of_Core); \ + return GPGME_Out_Of_Core; \ } \ } \ while (0) diff --git a/gpgme/passphrase.c b/gpgme/passphrase.c index 9bcbd17b..f9020fdb 100644 --- a/gpgme/passphrase.c +++ b/gpgme/passphrase.c @@ -62,7 +62,7 @@ _gpgme_passphrase_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args case GPGME_STATUS_USERID_HINT: free (ctx->result.passphrase->userid_hint); if (!(ctx->result.passphrase->userid_hint = strdup (args))) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; break; case GPGME_STATUS_BAD_PASSPHRASE: @@ -80,7 +80,7 @@ _gpgme_passphrase_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args free (ctx->result.passphrase->passphrase_info); ctx->result.passphrase->passphrase_info = strdup (args); if (!ctx->result.passphrase->passphrase_info) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; break; case GPGME_STATUS_MISSING_PASSPHRASE: @@ -91,7 +91,7 @@ _gpgme_passphrase_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args case GPGME_STATUS_EOF: if (ctx->result.passphrase->no_passphrase || ctx->result.passphrase->bad_passphrase) - return mk_error (No_Passphrase); + return GPGME_No_Passphrase; break; default: @@ -112,7 +112,7 @@ _gpgme_passphrase_command_handler (void *opaque, GpgmeStatusCode code, { ctx->result.passphrase = calloc (1, sizeof *ctx->result.passphrase); if (!ctx->result.passphrase) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } if (!code) @@ -149,7 +149,7 @@ _gpgme_passphrase_command_handler (void *opaque, GpgmeStatusCode code, buf = malloc (20 + strlen (userid_hint) + strlen (passphrase_info) + 3); if (!buf) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; sprintf (buf, "%s\n%s\n%s", bad_passphrase ? "TRY_AGAIN":"ENTER", userid_hint, passphrase_info); diff --git a/gpgme/progress.c b/gpgme/progress.c index 7d5fc976..f5daca5d 100644 --- a/gpgme/progress.c +++ b/gpgme/progress.c @@ -42,7 +42,7 @@ _gpgme_progress_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args) args_cpy = strdup (args); if (!args_cpy) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; p = strchr (args_cpy, ' '); if (p) diff --git a/gpgme/recipient.c b/gpgme/recipient.c index 31712c67..f7f9192b 100644 --- a/gpgme/recipient.c +++ b/gpgme/recipient.c @@ -44,7 +44,7 @@ gpgme_recipients_new (GpgmeRecipients *r_rset) rset = calloc ( 1, sizeof *rset ); if (!rset) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; *r_rset = rset; return 0; } @@ -111,10 +111,10 @@ gpgme_recipients_add_name_with_validity (GpgmeRecipients rset, struct user_id_s *r; if (!name || !rset ) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; r = malloc ( sizeof *r + strlen (name) ); if (!r) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; r->validity = val; r->name_part = ""; r->email_part = ""; @@ -164,7 +164,7 @@ GpgmeError gpgme_recipients_enum_open ( const GpgmeRecipients rset, void **ctx ) { if (!rset || !ctx) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; *ctx = rset->list; return 0; @@ -217,7 +217,7 @@ GpgmeError gpgme_recipients_enum_close ( const GpgmeRecipients rset, void **ctx ) { if (!rset || !ctx) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; *ctx = NULL; return 0; } diff --git a/gpgme/rungpg.c b/gpgme/rungpg.c index fd83e69a..17c1b99e 100644 --- a/gpgme/rungpg.c +++ b/gpgme/rungpg.c @@ -190,7 +190,7 @@ add_arg (GpgObject gpg, const char *arg) if (!a) { gpg->arg_error = 1; - return mk_error(Out_Of_Core); + return GPGME_Out_Of_Core; } a->next = NULL; a->data = NULL; @@ -213,7 +213,7 @@ add_data (GpgObject gpg, GpgmeData data, int dup_to, int inbound) if (!a) { gpg->arg_error = 1; - return mk_error(Out_Of_Core); + return GPGME_Out_Of_Core; } a->next = NULL; a->data = data; @@ -252,7 +252,7 @@ static GpgmeError gpg_check_version (void) { return _gpgme_compare_versions (gpg_get_version (), NEED_GPG_VERSION) - ? 0 : mk_error (Invalid_Engine); + ? 0 : GPGME_Invalid_Engine; } @@ -334,7 +334,7 @@ gpg_new (void **engine) gpg = calloc (1, sizeof *gpg); if (!gpg) { - rc = mk_error (Out_Of_Core); + rc = GPGME_Out_Of_Core; goto leave; } gpg->argtail = &gpg->arglist; @@ -354,14 +354,14 @@ gpg_new (void **engine) gpg->status.buffer = malloc (gpg->status.bufsize); if (!gpg->status.buffer) { - rc = mk_error (Out_Of_Core); + rc = GPGME_Out_Of_Core; goto leave; } /* In any case we need a status pipe - create it right here and don't handle it with our generic GpgmeData mechanism. */ if (_gpgme_io_pipe (gpg->status.fd, 1) == -1) { - rc = mk_error (Pipe_Error); + rc = GPGME_Pipe_Error; goto leave; } if (_gpgme_io_set_close_notify (gpg->status.fd[0], @@ -369,7 +369,7 @@ gpg_new (void **engine) || _gpgme_io_set_close_notify (gpg->status.fd[1], close_notify_handler, gpg)) { - rc = mk_error (General_Error); + rc = GPGME_General_Error; goto leave; } gpg->status.eof = 0; @@ -425,18 +425,18 @@ gpg_set_colon_line_handler (void *engine, GpgmeColonLineHandler fnc, gpg->colon.readpos = 0; gpg->colon.buffer = malloc (gpg->colon.bufsize); if (!gpg->colon.buffer) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; if (_gpgme_io_pipe (gpg->colon.fd, 1) == -1) { free (gpg->colon.buffer); gpg->colon.buffer = NULL; - return mk_error (Pipe_Error); + return GPGME_Pipe_Error; } if (_gpgme_io_set_close_notify (gpg->colon.fd[0], close_notify_handler, gpg) || _gpgme_io_set_close_notify (gpg->colon.fd[1], close_notify_handler, gpg)) - return mk_error (General_Error); + return GPGME_General_Error; gpg->colon.eof = 0; gpg->colon.fnc = fnc; gpg->colon.fnc_value = fnc_value; @@ -588,12 +588,12 @@ build_argv (GpgObject gpg) argv = calloc (argc + 1, sizeof *argv); if (!argv) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; fd_data_map = calloc (datac + 1, sizeof *fd_data_map); if (!fd_data_map) { free_argv (argv); - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } argc = datac = 0; @@ -602,7 +602,7 @@ build_argv (GpgObject gpg) { free (fd_data_map); free_argv (argv); - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } argc++; if (need_special) @@ -612,7 +612,7 @@ build_argv (GpgObject gpg) { free (fd_data_map); free_argv (argv); - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } argc++; } @@ -623,7 +623,7 @@ build_argv (GpgObject gpg) { free (fd_data_map); free_argv (argv); - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } argc++; } @@ -634,7 +634,7 @@ build_argv (GpgObject gpg) { free (fd_data_map); free_argv (argv); - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } argc++; } @@ -643,7 +643,7 @@ build_argv (GpgObject gpg) { free (fd_data_map); free_argv (argv); - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } argc++; argv[argc] = strdup (""); @@ -651,7 +651,7 @@ build_argv (GpgObject gpg) { free (fd_data_map); free_argv (argv); - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } argc++; for (a = gpg->arglist; a; a = a->next) @@ -670,7 +670,7 @@ build_argv (GpgObject gpg) { free (fd_data_map); free_argv (argv); - return mk_error (Pipe_Error); + return GPGME_Pipe_Error; } if (_gpgme_io_set_close_notify (fds[0], close_notify_handler, gpg) @@ -678,7 +678,7 @@ build_argv (GpgObject gpg) close_notify_handler, gpg)) { - return mk_error (General_Error); + return GPGME_General_Error; } /* If the data_type is FD, we have to do a dup2 here. */ if (fd_data_map[datac].inbound) @@ -717,7 +717,7 @@ build_argv (GpgObject gpg) { free (fd_data_map); free_argv (argv); - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } sprintf (argv[argc], a->print_fd ? "%d" : "-&%d", @@ -733,7 +733,7 @@ build_argv (GpgObject gpg) { free (fd_data_map); free_argv (argv); - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } argc++; } @@ -794,13 +794,13 @@ read_status (GpgObject gpg) bufsize += 1024; buffer = realloc (buffer, bufsize); if (!buffer) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } nread = _gpgme_io_read (gpg->status.fd[0], buffer + readpos, bufsize-readpos); if (nread == -1) - return mk_error(Read_Error); + return GPGME_Read_Error; if (!nread) { @@ -845,7 +845,7 @@ read_status (GpgObject gpg) free (gpg->cmd.keyword); gpg->cmd.keyword = strdup (rest); if (!gpg->cmd.keyword) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; /* This should be the last thing we have received and the next thing will be that the command handler does its action. */ @@ -964,12 +964,12 @@ read_colon_line (GpgObject gpg) bufsize += 1024; buffer = realloc (buffer, bufsize); if (!buffer) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } nread = _gpgme_io_read (gpg->colon.fd[0], buffer+readpos, bufsize-readpos); if (nread == -1) - return mk_error (Read_Error); + return GPGME_Read_Error; if (!nread) { @@ -1051,15 +1051,15 @@ start (GpgObject gpg) struct spawn_fd_item_s *fd_child_list, *fd_parent_list; if (!gpg) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (! _gpgme_get_gpg_path ()) - return mk_error (Invalid_Engine); + return GPGME_Invalid_Engine; /* Kludge, so that we don't need to check the return code of all the add_arg (). We bail out here instead. */ if (gpg->arg_error) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; rc = build_argv (gpg); if (rc) @@ -1070,7 +1070,7 @@ start (GpgObject gpg) n++; fd_child_list = calloc (n + n, sizeof *fd_child_list); if (!fd_child_list) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; fd_parent_list = fd_child_list + n; /* build the fd list for the child */ @@ -1120,7 +1120,7 @@ start (GpgObject gpg) gpg->argv, fd_child_list, fd_parent_list); free (fd_child_list); if (status == -1) - return mk_error (Exec_Error); + return GPGME_Exec_Error; /*_gpgme_register_term_handler ( closure, closure_value, pid );*/ @@ -1207,7 +1207,7 @@ gpg_delete (void *engine, GpgmeKey key, int allow_secret) { const char *s = gpgme_key_get_string_attr (key, GPGME_ATTR_FPR, NULL, 0); if (!s) - err = mk_error (Invalid_Key); + err = GPGME_Invalid_Key; else err = add_arg (gpg, s); } @@ -1262,7 +1262,7 @@ gpg_edit (void *engine, GpgmeKey key, GpgmeData out, GpgmeCtx ctx /* FIXME */) { const char *s = gpgme_key_get_string_attr (key, GPGME_ATTR_FPR, NULL, 0); if (!s) - err = mk_error (Invalid_Key); + err = GPGME_Invalid_Key; else err = add_arg (gpg, s); } @@ -1420,14 +1420,14 @@ gpg_genkey (void *engine, GpgmeData help_data, int use_armor, GpgmeError err; if (!gpg) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; /* We need a special mechanism to get the fd of a pipe here, so that we can use this for the %pubring and %secring parameters. We don't have this yet, so we implement only the adding to the standard keyrings. */ if (pubkey || seckey) - return err = mk_error (Not_Implemented); + return err = GPGME_Not_Implemented; err = add_arg (gpg, "--gen-key"); if (!err && use_armor) @@ -1499,7 +1499,7 @@ gpg_keylist_ext (void *engine, const char *pattern[], int secret_only, GpgmeError err; if (reserved) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; err = add_arg (gpg, "--with-colons"); if (!err) diff --git a/gpgme/sign.c b/gpgme/sign.c index 0fc5e82a..08449bdd 100644 --- a/gpgme/sign.c +++ b/gpgme/sign.c @@ -155,7 +155,7 @@ _gpgme_sign_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args) ctx->result.sign->xmlinfo = NULL; } if (!ctx->result.sign->okay) - return mk_error (No_Data); /* Hmmm: choose a better error? */ + return GPGME_No_Data; /* Hmmm: choose a better error? */ break; case GPGME_STATUS_SIG_CREATED: @@ -180,7 +180,7 @@ _gpgme_op_sign_start (GpgmeCtx ctx, int synchronous, if (mode != GPGME_SIG_MODE_NORMAL && mode != GPGME_SIG_MODE_DETACH && mode != GPGME_SIG_MODE_CLEAR) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; err = _gpgme_op_reset (ctx, synchronous); if (err) @@ -189,12 +189,12 @@ _gpgme_op_sign_start (GpgmeCtx ctx, int synchronous, /* Check the supplied data. */ if (!in) { - err = mk_error (No_Data); + err = GPGME_No_Data; goto leave; } if (!out) { - err = mk_error (Invalid_Value); + err = GPGME_Invalid_Value; goto leave; } diff --git a/gpgme/signers.c b/gpgme/signers.c index fa8a9e3b..7f99ea0a 100644 --- a/gpgme/signers.c +++ b/gpgme/signers.c @@ -74,7 +74,7 @@ GpgmeError gpgme_signers_add (GpgmeCtx ctx, const GpgmeKey key) { if (!ctx || !key) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (ctx->signers_len == ctx->signers_size) { @@ -84,7 +84,7 @@ gpgme_signers_add (GpgmeCtx ctx, const GpgmeKey key) newarr = realloc (ctx->signers, n * sizeof (*newarr)); if (!newarr) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; for (j = ctx->signers_size; j < n; j++) newarr[j] = NULL; ctx->signers = newarr; diff --git a/gpgme/trustlist.c b/gpgme/trustlist.c index 11860322..81b255cc 100644 --- a/gpgme/trustlist.c +++ b/gpgme/trustlist.c @@ -100,7 +100,7 @@ trustlist_colon_handler (GpgmeCtx ctx, char *line) case 1: /* level */ item = trust_item_new (); if (!item) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; item->level = atoi (p); break; case 2: /* long keyid */ @@ -121,7 +121,7 @@ trustlist_colon_handler (GpgmeCtx ctx, char *line) case 9: /* user ID */ item->name = strdup (p); if (!item->name) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; break; } } @@ -146,7 +146,7 @@ _gpgme_op_trustlist_event_cb (void *data, GpgmeEventIO type, void *type_data) { gpgme_trust_item_release (item); /* FIXME */ - /* ctx->error = mk_error (Out_Of_Core); */ + /* ctx->error = GPGME_Out_Of_Core; */ return; } q->item = item; @@ -172,7 +172,7 @@ gpgme_op_trustlist_start (GpgmeCtx ctx, const char *pattern, int max_level) GpgmeError err = 0; if (!pattern || !*pattern) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; err = _gpgme_op_reset (ctx, 2); if (err) @@ -204,12 +204,12 @@ gpgme_op_trustlist_next (GpgmeCtx ctx, GpgmeTrustItem *r_item) struct trust_queue_item_s *q; if (!r_item) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; *r_item = NULL; if (!ctx) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!ctx->pending) - return mk_error (No_Request); + return GPGME_No_Request; if (!ctx->trust_queue) { @@ -231,7 +231,7 @@ gpgme_op_trustlist_next (GpgmeCtx ctx, GpgmeTrustItem *r_item) if (!ctx->key_cond) { ctx->pending = 0; - return mk_error (EOF); + return GPGME_EOF; } ctx->key_cond = 0; assert (ctx->trust_queue); @@ -256,9 +256,9 @@ GpgmeError gpgme_op_trustlist_end (GpgmeCtx ctx) { if (!ctx) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (!ctx->pending) - return mk_error (No_Request); + return GPGME_No_Request; ctx->pending = 0; return 0; diff --git a/gpgme/util.h b/gpgme/util.h index 6d99cad3..8bc62536 100644 --- a/gpgme/util.h +++ b/gpgme/util.h @@ -1,23 +1,22 @@ /* util.h - * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef UTIL_H #define UTIL_H @@ -25,8 +24,6 @@ #include "types.h" #include "debug.h" -#define mk_error(a) ( GPGME_##a ) - #define DIM(v) (sizeof(v)/sizeof((v)[0])) #define DIMof(type,member) DIM(((type *)0)->member) diff --git a/gpgme/verify.c b/gpgme/verify.c index 921d727e..29b6b4d4 100644 --- a/gpgme/verify.c +++ b/gpgme/verify.c @@ -127,7 +127,7 @@ add_notation (GpgmeCtx ctx, GpgmeStatusCode code, const char *data) if (!dh) { if (gpgme_data_new (&dh)) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; ctx->result.verify->notation = dh; _gpgme_data_append_string (dh, " \n"); } @@ -184,7 +184,7 @@ finish_sig (GpgmeCtx ctx, int stop) /* Create a new result structure. */ res2 = calloc (1, sizeof *res2); if (!res2) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; res2->next = ctx->result.verify; ctx->result.verify = res2; @@ -375,12 +375,12 @@ _gpgme_op_verify_start (GpgmeCtx ctx, int synchronous, /* Check the supplied data. */ if (!sig) { - err = mk_error (No_Data); + err = GPGME_No_Data; goto leave; } if (!signed_text && !plaintext) { - err = mk_error (Invalid_Value); + err = GPGME_Invalid_Value; goto leave; } err = _gpgme_engine_op_verify (ctx->engine, sig, signed_text, plaintext); @@ -624,15 +624,15 @@ gpgme_get_sig_key (GpgmeCtx ctx, int idx, GpgmeKey *r_key) VerifyResult result; if (!ctx || !r_key) - return mk_error (Invalid_Value); + return GPGME_Invalid_Value; if (ctx->pending || !ctx->result.verify) - return mk_error (Busy); + return GPGME_Busy; for (result = ctx->result.verify; result && idx > 0; result = result->next, idx--) ; if (!result) - return mk_error (EOF); + return GPGME_EOF; return gpgme_get_key (ctx, result->fpr, r_key, 0, 0); } diff --git a/gpgme/wait-global.c b/gpgme/wait-global.c index 074d98c5..434e8388 100644 --- a/gpgme/wait-global.c +++ b/gpgme/wait-global.c @@ -91,7 +91,7 @@ ctx_active (GpgmeCtx ctx) { struct ctx_list_item *li = malloc (sizeof (struct ctx_list_item)); if (!li) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; li->ctx = ctx; LOCK (ctx_list_lock); @@ -266,7 +266,7 @@ gpgme_wait (GpgmeCtx ctx, GpgmeError *status, int hang) { UNLOCK (ctx_list_lock); if (status) - *status = mk_error (Out_Of_Core); + *status = GPGME_Out_Of_Core; return NULL; } fdt.size = i; @@ -284,7 +284,7 @@ gpgme_wait (GpgmeCtx ctx, GpgmeError *status, int hang) { free (fdt.fds); if (status) - *status = mk_error (File_Error); + *status = GPGME_File_Error; return NULL; } @@ -306,7 +306,7 @@ gpgme_wait (GpgmeCtx ctx, GpgmeError *status, int hang) err = item->handler (item->handler_value, fdt.fds[i].fd); if (!err && ictx->cancel) - err = mk_error (Canceled); + err = GPGME_Canceled; if (err) { /* An error occured. Close all fds in this context, diff --git a/gpgme/wait-private.c b/gpgme/wait-private.c index d0f801d4..75d44a72 100644 --- a/gpgme/wait-private.c +++ b/gpgme/wait-private.c @@ -88,7 +88,7 @@ _gpgme_wait_on_condition (GpgmeCtx ctx, volatile int *cond) signal it. */ int idx; - err = mk_error (File_Error); + err = GPGME_File_Error; for (idx = 0; idx < ctx->fdt.size; idx++) if (ctx->fdt.fds[idx].fd != -1) _gpgme_io_close (ctx->fdt.fds[idx].fd); @@ -111,7 +111,7 @@ _gpgme_wait_on_condition (GpgmeCtx ctx, volatile int *cond) err = item->handler (item->handler_value, ctx->fdt.fds[i].fd); if (!err && ctx->cancel) - err = mk_error (Canceled); + err = GPGME_Canceled; if (err) { /* An error occured. Close all fds in this context, diff --git a/gpgme/wait.c b/gpgme/wait.c index daf009b8..6d5f2723 100644 --- a/gpgme/wait.c +++ b/gpgme/wait.c @@ -69,7 +69,7 @@ fd_table_put (fd_table_t fdt, int fd, int dir, void *opaque, int *idx) new_fds = realloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE) * sizeof (*new_fds)); if (!new_fds) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; fdt->fds = new_fds; fdt->size += FDT_ALLOCSIZE; @@ -110,7 +110,7 @@ _gpgme_add_io_cb (void *data, int fd, int dir, GpgmeIOCb fnc, void *fnc_data, tag = malloc (sizeof *tag); if (!tag) - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; tag->ctx = ctx; /* Allocate a structure to hold information about the handler. */ @@ -118,7 +118,7 @@ _gpgme_add_io_cb (void *data, int fd, int dir, GpgmeIOCb fnc, void *fnc_data, if (!item) { free (tag); - return mk_error (Out_Of_Core); + return GPGME_Out_Of_Core; } item->ctx = ctx; item->dir = dir;