2003-01-29 Marcus Brinkmann <marcus@g10code.de>

* 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.
This commit is contained in:
Marcus Brinkmann 2003-01-29 16:10:35 +00:00
parent ff5dfd9c9c
commit 6912c46a77
30 changed files with 275 additions and 270 deletions

View File

@ -1,5 +1,13 @@
2003-01-29 Marcus Brinkmann <marcus@g10code.de> 2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* 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 (wait_on_request_or_fail): Remove macro.
* context.h (gpgme_context_s): Remove member ERROR. * context.h (gpgme_context_s): Remove member ERROR.

View File

@ -76,7 +76,7 @@ _gpgme_decode_c_string (const char *src, char **destp, int len)
string will never be larger. */ string will never be larger. */
dest = malloc (strlen (src) + 1); dest = malloc (strlen (src) + 1);
if (!dest) if (!dest)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
*destp = dest; *destp = dest;
} }
@ -158,13 +158,13 @@ GpgmeError
_gpgme_data_append (GpgmeData dh, const char *buffer, size_t length) _gpgme_data_append (GpgmeData dh, const char *buffer, size_t length)
{ {
if (!dh || !buffer) if (!dh || !buffer)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
do do
{ {
ssize_t amt = gpgme_data_write (dh, buffer, length); ssize_t amt = gpgme_data_write (dh, buffer, length);
if (amt == 0 || (amt < 0 && errno != EINTR)) if (amt == 0 || (amt < 0 && errno != EINTR))
return mk_error (File_Error); return GPGME_File_Error;
buffer += amt; buffer += amt;
length -= amt; length -= amt;
} }
@ -192,7 +192,7 @@ _gpgme_data_append_for_xml (GpgmeData dh, const char *buffer, size_t len)
int err = 0; int err = 0;
if (!dh || !buffer) if (!dh || !buffer)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
do do
{ {

View File

@ -40,12 +40,12 @@ gpgme_data_new_from_filepart (GpgmeData *dh, const char *fname, FILE *stream,
char *buf = NULL; char *buf = NULL;
if (stream && fname) if (stream && fname)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (fname) if (fname)
stream = fopen (fname, "rb"); stream = fopen (fname, "rb");
if (!stream) if (!stream)
return mk_error (File_Error); return GPGME_File_Error;
if (fseek (stream, offset, SEEK_SET)) if (fseek (stream, offset, SEEK_SET))
goto ferr; goto ferr;
@ -85,7 +85,7 @@ gpgme_data_new_from_filepart (GpgmeData *dh, const char *fname, FILE *stream,
if (fname) if (fname)
fclose (stream); fclose (stream);
errno = saved_errno; 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; struct stat statbuf;
if (!fname || !copy) if (!fname || !copy)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (stat (fname, &statbuf) < 0) 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); 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) switch (err)
{ {
case mk_error (EOF): case GPGME_EOF:
return 0; return 0;
case mk_error (Out_Of_Core): case GPGME_Out_Of_Core:
errno = ENOMEM; errno = ENOMEM;
return -1; return -1;
case mk_error (Invalid_Value): case GPGME_Invalid_Value:
errno = EINVAL; errno = EINVAL;
return -1; return -1;
case mk_error (Busy): case GPGME_Busy:
errno = EBUSY; errno = EBUSY;
return -1; return -1;
case mk_error (Not_Implemented): case GPGME_Not_Implemented:
errno = EOPNOTSUPP; errno = EOPNOTSUPP;
return -1; return -1;
default: default:
@ -188,5 +188,5 @@ GpgmeError
gpgme_data_rewind (GpgmeData dh) gpgme_data_rewind (GpgmeData dh)
{ {
return (gpgme_data_seek (dh, 0, SEEK_SET) == -1) return (gpgme_data_seek (dh, 0, SEEK_SET) == -1)
? mk_error (File_Error) : 0; ? GPGME_File_Error : 0;
} }

View File

@ -39,12 +39,12 @@ _gpgme_data_new (GpgmeData *r_dh, struct gpgme_data_cbs *cbs)
GpgmeData dh; GpgmeData dh;
if (!r_dh) if (!r_dh)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
*r_dh = NULL; *r_dh = NULL;
dh = calloc (1, sizeof (*dh)); dh = calloc (1, sizeof (*dh));
if (!dh) if (!dh)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
dh->cbs = cbs; dh->cbs = cbs;
@ -149,7 +149,7 @@ GpgmeError
gpgme_data_set_encoding (GpgmeData dh, GpgmeDataEncoding enc) gpgme_data_set_encoding (GpgmeData dh, GpgmeDataEncoding enc)
{ {
if (!dh) if (!dh)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (enc < 0 || enc > GPGME_DATA_ENCODING_ARMOR) if (enc < 0 || enc > GPGME_DATA_ENCODING_ARMOR)
return GPGME_Invalid_Value; return GPGME_Invalid_Value;
dh->encoding = enc; dh->encoding = enc;
@ -170,7 +170,7 @@ _gpgme_data_inbound_handler (void *opaque, int fd)
buflen = read (fd, buffer, BUFFER_SIZE); buflen = read (fd, buffer, BUFFER_SIZE);
if (buflen < 0) if (buflen < 0)
return mk_error (File_Error); return GPGME_File_Error;
if (buflen == 0) if (buflen == 0)
{ {
_gpgme_io_close (fd); _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); ssize_t amt = gpgme_data_read (dh, dh->pending, BUFFER_SIZE);
if (amt < 0) if (amt < 0)
return mk_error (File_Error); return GPGME_File_Error;
if (amt == 0) if (amt == 0)
{ {
_gpgme_io_close (fd); _gpgme_io_close (fd);
@ -207,7 +207,7 @@ _gpgme_data_outbound_handler (void *opaque, int fd)
return 0; return 0;
if (nwritten <= 0) if (nwritten <= 0)
return mk_error (File_Error); return GPGME_File_Error;
if (nwritten < dh->pending_len) if (nwritten < dh->pending_len)
memmove (dh->pending, dh->pending + nwritten, dh->pending_len - nwritten); memmove (dh->pending, dh->pending + nwritten, dh->pending_len - nwritten);

View File

@ -100,9 +100,9 @@ _gpgme_decrypt_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
{ {
case GPGME_STATUS_EOF: case GPGME_STATUS_EOF:
if (ctx->result.decrypt->failed) if (ctx->result.decrypt->failed)
return mk_error (Decryption_Failed); return GPGME_Decryption_Failed;
else if (!ctx->result.decrypt->okay) else if (!ctx->result.decrypt->okay)
return mk_error (No_Data); return GPGME_No_Data;
break; break;
case GPGME_STATUS_DECRYPTION_OKAY: case GPGME_STATUS_DECRYPTION_OKAY:
@ -172,12 +172,12 @@ _gpgme_decrypt_start (GpgmeCtx ctx, int synchronous,
/* Check the supplied data. */ /* Check the supplied data. */
if (!ciph) if (!ciph)
{ {
err = mk_error (No_Data); err = GPGME_No_Data;
goto leave; goto leave;
} }
if (!plain) if (!plain)
{ {
err = mk_error (Invalid_Value); err = GPGME_Invalid_Value;
goto leave; goto leave;
} }

View File

@ -65,15 +65,15 @@ delete_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
case DELETE_No_Problem: case DELETE_No_Problem:
break; break;
case DELETE_No_Such_Key: case DELETE_No_Such_Key:
return mk_error(Invalid_Key); return GPGME_Invalid_Key;
break; break;
case DELETE_Must_Delete_Secret_Key: case DELETE_Must_Delete_Secret_Key:
return mk_error(Conflict); return GPGME_Conflict;
break; break;
case DELETE_Ambiguous_Specification: case DELETE_Ambiguous_Specification:
/* XXX Need better error value. Fall through. */ /* XXX Need better error value. Fall through. */
default: default:
return mk_error(General_Error); return GPGME_General_Error;
break; break;
} }
break; break;

View File

@ -83,7 +83,7 @@ _gpgme_op_edit_start (GpgmeCtx ctx, int synchronous,
GpgmeError err = 0; GpgmeError err = 0;
if (!fnc) if (!fnc)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
err = _gpgme_op_reset (ctx, synchronous); err = _gpgme_op_reset (ctx, synchronous);
if (err) if (err)
@ -93,7 +93,7 @@ _gpgme_op_edit_start (GpgmeCtx ctx, int synchronous,
ctx->result.edit = malloc (sizeof *ctx->result.edit); ctx->result.edit = malloc (sizeof *ctx->result.edit);
if (!ctx->result.edit) if (!ctx->result.edit)
{ {
err = mk_error (Out_Of_Core); err = GPGME_Out_Of_Core;
goto leave; goto leave;
} }
ctx->result.edit->fnc = fnc; ctx->result.edit->fnc = fnc;
@ -102,7 +102,7 @@ _gpgme_op_edit_start (GpgmeCtx ctx, int synchronous,
/* Check the supplied data. */ /* Check the supplied data. */
if (!out) if (!out)
{ {
err = mk_error (Invalid_Value); err = GPGME_Invalid_Value;
goto leave; goto leave;
} }

View File

@ -64,12 +64,12 @@ _gpgme_op_encrypt_sign_start (GpgmeCtx ctx, int synchronous,
/* Check the supplied data */ /* Check the supplied data */
if (!plain) if (!plain)
{ {
err = mk_error (No_Data); err = GPGME_No_Data;
goto leave; goto leave;
} }
if (!cipher) if (!cipher)
{ {
err = mk_error (Invalid_Value); err = GPGME_Invalid_Value;
goto leave; goto leave;
} }

View File

@ -112,9 +112,9 @@ _gpgme_encrypt_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
ctx->result.encrypt->xmlinfo = NULL; ctx->result.encrypt->xmlinfo = NULL;
} }
if (ctx->result.encrypt->no_valid_recipients) if (ctx->result.encrypt->no_valid_recipients)
return mk_error (No_Recipients); return GPGME_No_Recipients;
else if (ctx->result.encrypt->invalid_recipients) else if (ctx->result.encrypt->invalid_recipients)
return mk_error (Invalid_Recipients); return GPGME_Invalid_Recipients;
break; break;
case GPGME_STATUS_INV_RECP: case GPGME_STATUS_INV_RECP:
@ -153,7 +153,7 @@ _gpgme_op_encrypt_start (GpgmeCtx ctx, int synchronous,
symmetric = 1; symmetric = 1;
else if (!gpgme_recipients_count (recp)) else if (!gpgme_recipients_count (recp))
{ {
err = mk_error (No_Recipients); err = GPGME_No_Recipients;
goto leave; goto leave;
} }
@ -178,12 +178,12 @@ _gpgme_op_encrypt_start (GpgmeCtx ctx, int synchronous,
/* Check the supplied data */ /* Check the supplied data */
if (!plain) if (!plain)
{ {
err = mk_error (No_Data); err = GPGME_No_Data;
goto leave; goto leave;
} }
if (!ciph) if (!ciph)
{ {
err = mk_error (Invalid_Value); err = GPGME_Invalid_Value;
goto leave; goto leave;
} }

View File

@ -117,7 +117,7 @@ static GpgmeError
gpgsm_check_version (void) gpgsm_check_version (void)
{ {
return _gpgme_compare_versions (gpgsm_get_version (), NEED_GPGSM_VERSION) 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) switch (err)
{ {
case ASSUAN_No_Error: case ASSUAN_No_Error:
return mk_error (No_Error); return GPGME_No_Error;
case ASSUAN_General_Error: case ASSUAN_General_Error:
return mk_error (General_Error); return GPGME_General_Error;
case ASSUAN_Out_Of_Core: case ASSUAN_Out_Of_Core:
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
case ASSUAN_Invalid_Value: case ASSUAN_Invalid_Value:
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
case ASSUAN_Read_Error: case ASSUAN_Read_Error:
return mk_error (Read_Error); return GPGME_Read_Error;
case ASSUAN_Write_Error: case ASSUAN_Write_Error:
return mk_error (Write_Error); return GPGME_Write_Error;
case ASSUAN_Timeout: case ASSUAN_Timeout:
case ASSUAN_Problem_Starting_Server: case ASSUAN_Problem_Starting_Server:
@ -182,18 +182,18 @@ map_assuan_error (AssuanError err)
case ASSUAN_No_Inquire_Callback: case ASSUAN_No_Inquire_Callback:
case ASSUAN_Connect_Failed: case ASSUAN_Connect_Failed:
case ASSUAN_Accept_Failed: case ASSUAN_Accept_Failed:
return mk_error (General_Error); return GPGME_General_Error;
/* The following error codes are meant as status codes. */ /* The following error codes are meant as status codes. */
case ASSUAN_Not_Implemented: case ASSUAN_Not_Implemented:
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
case ASSUAN_Canceled: case ASSUAN_Canceled:
return mk_error (Canceled); return GPGME_Canceled;
case ASSUAN_Unsupported_Algorithm: case ASSUAN_Unsupported_Algorithm:
return mk_error (Not_Implemented); /* XXX Argh. */ return GPGME_Not_Implemented; /* XXX Argh. */
case ASSUAN_No_Data_Available: case ASSUAN_No_Data_Available:
return mk_error (EOF); return GPGME_EOF;
/* These are errors internal to GPGME. */ /* These are errors internal to GPGME. */
case ASSUAN_No_Input: case ASSUAN_No_Input:
@ -216,7 +216,7 @@ map_assuan_error (AssuanError err)
case ASSUAN_Unexpected_Data: case ASSUAN_Unexpected_Data:
case ASSUAN_Invalid_Status: case ASSUAN_Invalid_Status:
case ASSUAN_Not_Confirmed: case ASSUAN_Not_Confirmed:
return mk_error (General_Error); return GPGME_General_Error;
/* These are errors in the server. */ /* These are errors in the server. */
case ASSUAN_Server_Fault: case ASSUAN_Server_Fault:
@ -225,7 +225,7 @@ map_assuan_error (AssuanError err)
case ASSUAN_Server_Bug: case ASSUAN_Server_Bug:
case ASSUAN_No_Agent: case ASSUAN_No_Agent:
case ASSUAN_Agent_Error: 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:
case ASSUAN_Bad_Certificate_Path: case ASSUAN_Bad_Certificate_Path:
@ -238,19 +238,19 @@ map_assuan_error (AssuanError err)
case ASSUAN_No_PKCS15_App: /* XXX: Oh well. */ case ASSUAN_No_PKCS15_App: /* XXX: Oh well. */
case ASSUAN_Card_Not_Present: /* XXX: Oh well. */ case ASSUAN_Card_Not_Present: /* XXX: Oh well. */
case ASSUAN_Invalid_Id: /* XXX: Oh well. */ case ASSUAN_Invalid_Id: /* XXX: Oh well. */
return mk_error (Invalid_Key); return GPGME_Invalid_Key;
case ASSUAN_Bad_Signature: 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_Cert_Revoked:
case ASSUAN_No_CRL_For_Cert: case ASSUAN_No_CRL_For_Cert:
case ASSUAN_CRL_Too_Old: case ASSUAN_CRL_Too_Old:
case ASSUAN_Not_Trusted: 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: default:
return mk_error (General_Error); return GPGME_General_Error;
} }
} }
@ -299,7 +299,7 @@ gpgsm_new (void **engine)
gpgsm = calloc (1, sizeof *gpgsm); gpgsm = calloc (1, sizeof *gpgsm);
if (!gpgsm) if (!gpgsm)
{ {
err = mk_error (Out_Of_Core); err = GPGME_Out_Of_Core;
return err; return err;
} }
@ -331,7 +331,7 @@ gpgsm_new (void **engine)
if (_gpgme_io_pipe (fds, 0) < 0) if (_gpgme_io_pipe (fds, 0) < 0)
{ {
err = mk_error (Pipe_Error); err = GPGME_Pipe_Error;
goto leave; goto leave;
} }
gpgsm->input_cb.fd = fds[1]; gpgsm->input_cb.fd = fds[1];
@ -340,7 +340,7 @@ gpgsm_new (void **engine)
if (_gpgme_io_pipe (fds, 1) < 0) if (_gpgme_io_pipe (fds, 1) < 0)
{ {
err = mk_error (Pipe_Error); err = GPGME_Pipe_Error;
goto leave; goto leave;
} }
gpgsm->output_cb.fd = fds[0]; gpgsm->output_cb.fd = fds[0];
@ -349,7 +349,7 @@ gpgsm_new (void **engine)
if (_gpgme_io_pipe (fds, 0) < 0) if (_gpgme_io_pipe (fds, 0) < 0)
{ {
err = mk_error (Pipe_Error); err = GPGME_Pipe_Error;
goto leave; goto leave;
} }
gpgsm->message_cb.fd = fds[1]; gpgsm->message_cb.fd = fds[1];
@ -376,7 +376,7 @@ gpgsm_new (void **engine)
fdlist, DIM (fdlist)); fdlist, DIM (fdlist));
if (nfds < 1) if (nfds < 1)
{ {
err = mk_error (General_Error); /* FIXME */ err = GPGME_General_Error; /* FIXME */
goto leave; goto leave;
} }
/* We duplicate the file descriptor, so we can close it without /* 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]); gpgsm->status_cb.fd = dup (fdlist[0]);
if (gpgsm->status_cb.fd < 0) if (gpgsm->status_cb.fd < 0)
{ {
err = mk_error (General_Error); /* FIXME */ err = GPGME_General_Error; /* FIXME */
goto leave; goto leave;
} }
gpgsm->status_cb.dir = 1; gpgsm->status_cb.dir = 1;
@ -398,7 +398,7 @@ gpgsm_new (void **engine)
{ {
if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0) if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
{ {
err = mk_error (Out_Of_Core); err = GPGME_Out_Of_Core;
goto leave; goto leave;
} }
err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, 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) if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
{ {
err = mk_error (Out_Of_Core); err = GPGME_Out_Of_Core;
goto leave; goto leave;
} }
err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, NULL, NULL, 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) if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0)
{ {
err = mk_error (Out_Of_Core); err = GPGME_Out_Of_Core;
goto leave; goto leave;
} }
err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, NULL, NULL, err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
@ -459,7 +459,7 @@ gpgsm_new (void **engine)
if (dft_lc) if (dft_lc)
{ {
if (asprintf (&optstr, "OPTION lc-ctype=%s", dft_lc) < 0) if (asprintf (&optstr, "OPTION lc-ctype=%s", dft_lc) < 0)
err = mk_error (Out_Of_Core); err = GPGME_Out_Of_Core;
else else
{ {
err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL,
@ -492,7 +492,7 @@ gpgsm_new (void **engine)
if (dft_lc) if (dft_lc)
{ {
if (asprintf (&optstr, "OPTION lc-messages=%s", dft_lc) < 0) if (asprintf (&optstr, "OPTION lc-messages=%s", dft_lc) < 0)
err = mk_error (Out_Of_Core); err = GPGME_Out_Of_Core;
else else
{ {
err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, NULL, NULL, 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, || _gpgme_io_set_close_notify (gpgsm->message_cb.fd,
close_notify_handler, gpgsm))) close_notify_handler, gpgsm)))
{ {
err = mk_error (General_Error); err = GPGME_General_Error;
goto leave; goto leave;
} }
@ -593,10 +593,10 @@ gpgsm_assuan_simple_command (ASSUAN_CONTEXT ctx, char *cmd, GpgmeStatusHandler s
if (r >= 0 && status_fnc) if (r >= 0 && status_fnc)
status_fnc (status_fnc_value, r, rest); status_fnc (status_fnc_value, r, rest);
else else
err = mk_error (General_Error); err = GPGME_General_Error;
} }
else else
err = mk_error (General_Error); err = GPGME_General_Error;
} }
while (!err); while (!err);
@ -685,7 +685,7 @@ status_handler (void *opaque, int fd)
if (line[3] == ' ') if (line[3] == ' ')
err = map_assuan_error (atoi (&line[4])); err = map_assuan_error (atoi (&line[4]));
else else
err = mk_error (General_Error); err = GPGME_General_Error;
} }
else if (linelen >= 2 else if (linelen >= 2
&& line[0] == 'O' && line[1] == 'K' && line[0] == 'O' && line[1] == 'K'
@ -730,7 +730,7 @@ status_handler (void *opaque, int fd)
unsigned char *newline = realloc (*aline, unsigned char *newline = realloc (*aline,
*alinelen + linelen + 1); *alinelen + linelen + 1);
if (!newline) if (!newline)
err = mk_error (Out_Of_Core); err = GPGME_Out_Of_Core;
else else
{ {
*aline = newline; *aline = newline;
@ -856,17 +856,17 @@ gpgsm_decrypt (void *engine, GpgmeData ciph, GpgmeData plain)
GpgmeError err; GpgmeError err;
if (!gpgsm) if (!gpgsm)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
gpgsm->input_cb.data = ciph; gpgsm->input_cb.data = ciph;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
map_input_enc (gpgsm->input_cb.data)); map_input_enc (gpgsm->input_cb.data));
if (err) if (err)
return mk_error (General_Error); /* FIXME */ return GPGME_General_Error; /* FIXME */
gpgsm->output_cb.data = plain; gpgsm->output_cb.data = plain;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, 0); err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, 0);
if (err) if (err)
return mk_error (General_Error); /* FIXME */ return GPGME_General_Error; /* FIXME */
_gpgme_io_close (gpgsm->message_cb.fd); _gpgme_io_close (gpgsm->message_cb.fd);
err = start (engine, "DECRYPT"); err = start (engine, "DECRYPT");
@ -885,7 +885,7 @@ gpgsm_delete (void *engine, GpgmeKey key, int allow_secret)
int length = 8; /* "DELKEYS " */ int length = 8; /* "DELKEYS " */
if (!fpr) if (!fpr)
return mk_error (Invalid_Key); return GPGME_Invalid_Key;
while (*linep) while (*linep)
{ {
@ -898,7 +898,7 @@ gpgsm_delete (void *engine, GpgmeKey key, int allow_secret)
line = malloc (length); line = malloc (length);
if (!line) if (!line)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
strcpy (line, "DELKEYS "); strcpy (line, "DELKEYS ");
linep = &line[8]; linep = &line[8];
@ -954,7 +954,7 @@ set_recipients (GpgsmObject gpgsm, GpgmeRecipients recp)
linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */ linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */
line = malloc (10 + 40 + 1); line = malloc (10 + 40 + 1);
if (!line) if (!line)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
strcpy (line, "RECIPIENT "); strcpy (line, "RECIPIENT ");
for (r = recp->list; r; r = r->next) for (r = recp->list; r; r = r->next)
{ {
@ -965,7 +965,7 @@ set_recipients (GpgsmObject gpgsm, GpgmeRecipients recp)
if (! newline) if (! newline)
{ {
free (line); free (line);
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
line = newline; line = newline;
linelen = newlen; linelen = newlen;
@ -997,9 +997,9 @@ gpgsm_encrypt (void *engine, GpgmeRecipients recp, GpgmeData plain,
GpgmeError err; GpgmeError err;
if (!gpgsm) if (!gpgsm)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!recp) if (!recp)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
gpgsm->input_cb.data = plain; gpgsm->input_cb.data = plain;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 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; int cmdlen = 32;
if (!gpgsm) if (!gpgsm)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
cmd = malloc (cmdlen); cmd = malloc (cmdlen);
if (!cmd) if (!cmd)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
strcpy (cmd, "EXPORT"); strcpy (cmd, "EXPORT");
cmdi = 6; cmdi = 6;
@ -1057,7 +1057,7 @@ gpgsm_export (void *engine, GpgmeRecipients recp, GpgmeData keydata,
if (!newcmd) if (!newcmd)
{ {
free (cmd); free (cmd);
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
cmd = newcmd; cmd = newcmd;
cmdlen *= 2; cmdlen *= 2;
@ -1094,7 +1094,7 @@ gpgsm_genkey (void *engine, GpgmeData help_data, int use_armor,
GpgmeError err; GpgmeError err;
if (!gpgsm || !pubkey || seckey) if (!gpgsm || !pubkey || seckey)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
gpgsm->input_cb.data = help_data; gpgsm->input_cb.data = help_data;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
@ -1120,7 +1120,7 @@ gpgsm_import (void *engine, GpgmeData keydata)
GpgmeError err; GpgmeError err;
if (!gpgsm) if (!gpgsm)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
gpgsm->input_cb.data = keydata; gpgsm->input_cb.data = keydata;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 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 = ""; pattern = "";
if (asprintf (&line, "OPTION list-mode=%d", (keylist_mode & 3)) < 0) 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); err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL);
free (line); free (line);
if (err) if (err)
@ -1156,7 +1156,7 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only,
/* Length is "LISTSECRETKEYS " + p + '\0'. */ /* Length is "LISTSECRETKEYS " + p + '\0'. */
line = malloc (15 + strlen (pattern) + 1); line = malloc (15 + strlen (pattern) + 1);
if (!line) if (!line)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
if (secret_only) if (secret_only)
{ {
strcpy (line, "LISTSECRETKEYS "); strcpy (line, "LISTSECRETKEYS ");
@ -1190,10 +1190,10 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only,
char *linep; char *linep;
if (reserved) if (reserved)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (asprintf (&line, "OPTION list-mode=%d", (keylist_mode & 3)) < 0) 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); err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL);
free (line); free (line);
if (err) if (err)
@ -1221,7 +1221,7 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only,
} }
line = malloc (length); line = malloc (length);
if (!line) if (!line)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
if (secret_only) if (secret_only)
{ {
strcpy (line, "LISTSECRETKEYS "); strcpy (line, "LISTSECRETKEYS ");
@ -1291,10 +1291,10 @@ gpgsm_sign (void *engine, GpgmeData in, GpgmeData out, GpgmeSigMode mode,
GpgmeKey key; GpgmeKey key;
if (!gpgsm) if (!gpgsm)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (asprintf (&assuan_cmd, "OPTION include-certs %i", include_certs) < 0) 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); err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, assuan_cmd, NULL,NULL);
free (assuan_cmd); free (assuan_cmd);
if (err) if (err)
@ -1347,7 +1347,7 @@ static GpgmeError
gpgsm_trustlist (void *engine, const char *pattern) gpgsm_trustlist (void *engine, const char *pattern)
{ {
/* FIXME */ /* 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; GpgmeError err;
if (!gpgsm) if (!gpgsm)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
gpgsm->input_cb.data = sig; gpgsm->input_cb.data = sig;
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,

View File

@ -83,10 +83,10 @@ GpgmeError
gpgme_engine_check_version (GpgmeProtocol proto) gpgme_engine_check_version (GpgmeProtocol proto)
{ {
if (proto > sizeof (engine_ops) / sizeof (engine_ops[0])) if (proto > sizeof (engine_ops) / sizeof (engine_ops[0]))
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine_ops[proto]) if (!engine_ops[proto])
return mk_error (Invalid_Engine); return GPGME_Invalid_Engine;
if (engine_ops[proto]->check_version) if (engine_ops[proto]->check_version)
return (*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; const char *version;
if (proto > sizeof (engine_ops) / sizeof (engine_ops[0])) if (proto > sizeof (engine_ops) / sizeof (engine_ops[0]))
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine_ops[proto]) if (!engine_ops[proto])
return mk_error (Invalid_Engine); return GPGME_Invalid_Engine;
path = _gpgme_engine_get_path (proto); path = _gpgme_engine_get_path (proto);
version = _gpgme_engine_get_version (proto); version = _gpgme_engine_get_version (proto);
if (!path || !version) if (!path || !version)
return mk_error (Invalid_Engine); return GPGME_Invalid_Engine;
engine = calloc (1, sizeof *engine); engine = calloc (1, sizeof *engine);
if (!engine) if (!engine)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
engine->ops = engine_ops[proto]; engine->ops = engine_ops[proto];
if (engine_ops[proto]->new) if (engine_ops[proto]->new)
@ -216,10 +216,10 @@ _gpgme_engine_set_command_handler (EngineObject engine,
GpgmeData linked_data) GpgmeData linked_data)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->set_command_handler) if (!engine->ops->set_command_handler)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->set_command_handler) (engine->engine, return (*engine->ops->set_command_handler) (engine->engine,
fnc, fnc_value, linked_data); fnc, fnc_value, linked_data);
@ -230,10 +230,10 @@ GpgmeError _gpgme_engine_set_colon_line_handler (EngineObject engine,
void *fnc_value) void *fnc_value)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->set_colon_line_handler) 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, return (*engine->ops->set_colon_line_handler) (engine->engine,
fnc, fnc_value); fnc, fnc_value);
@ -243,10 +243,10 @@ GpgmeError
_gpgme_engine_op_decrypt (EngineObject engine, GpgmeData ciph, GpgmeData plain) _gpgme_engine_op_decrypt (EngineObject engine, GpgmeData ciph, GpgmeData plain)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->decrypt) if (!engine->ops->decrypt)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->decrypt) (engine->engine, ciph, plain); return (*engine->ops->decrypt) (engine->engine, ciph, plain);
} }
@ -255,10 +255,10 @@ GpgmeError
_gpgme_engine_op_delete (EngineObject engine, GpgmeKey key, int allow_secret) _gpgme_engine_op_delete (EngineObject engine, GpgmeKey key, int allow_secret)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->delete) if (!engine->ops->delete)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->delete) (engine->engine, key, allow_secret); 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 */) GpgmeCtx ctx /* FIXME */)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->edit) if (!engine->ops->edit)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->edit) (engine->engine, key, out, ctx); 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) GpgmeData plain, GpgmeData ciph, int use_armor)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->encrypt) if (!engine->ops->encrypt)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->encrypt) (engine->engine, recp, plain, ciph, return (*engine->ops->encrypt) (engine->engine, recp, plain, ciph,
use_armor); use_armor);
@ -299,10 +299,10 @@ _gpgme_engine_op_encrypt_sign (EngineObject engine, GpgmeRecipients recp,
GpgmeCtx ctx /* FIXME */) GpgmeCtx ctx /* FIXME */)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->encrypt_sign) if (!engine->ops->encrypt_sign)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->encrypt_sign) (engine->engine, recp, plain, ciph, return (*engine->ops->encrypt_sign) (engine->engine, recp, plain, ciph,
use_armor, ctx); use_armor, ctx);
@ -314,10 +314,10 @@ _gpgme_engine_op_export (EngineObject engine, GpgmeRecipients recp,
GpgmeData keydata, int use_armor) GpgmeData keydata, int use_armor)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->export) if (!engine->ops->export)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->export) (engine->engine, recp, keydata, return (*engine->ops->export) (engine->engine, recp, keydata,
use_armor); use_armor);
@ -329,10 +329,10 @@ _gpgme_engine_op_genkey (EngineObject engine, GpgmeData help_data,
int use_armor, GpgmeData pubkey, GpgmeData seckey) int use_armor, GpgmeData pubkey, GpgmeData seckey)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->genkey) if (!engine->ops->genkey)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->genkey) (engine->engine, help_data, use_armor, return (*engine->ops->genkey) (engine->engine, help_data, use_armor,
pubkey, seckey); pubkey, seckey);
@ -343,10 +343,10 @@ GpgmeError
_gpgme_engine_op_import (EngineObject engine, GpgmeData keydata) _gpgme_engine_op_import (EngineObject engine, GpgmeData keydata)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->import) if (!engine->ops->import)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->import) (engine->engine, keydata); 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) int secret_only, int keylist_mode)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->keylist) if (!engine->ops->keylist)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->keylist) (engine->engine, pattern, secret_only, return (*engine->ops->keylist) (engine->engine, pattern, secret_only,
keylist_mode); keylist_mode);
@ -372,10 +372,10 @@ _gpgme_engine_op_keylist_ext (EngineObject engine, const char *pattern[],
int secret_only, int reserved, int keylist_mode) int secret_only, int reserved, int keylist_mode)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->keylist_ext) if (!engine->ops->keylist_ext)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->keylist_ext) (engine->engine, pattern, secret_only, return (*engine->ops->keylist_ext) (engine->engine, pattern, secret_only,
reserved, keylist_mode); reserved, keylist_mode);
@ -389,10 +389,10 @@ _gpgme_engine_op_sign (EngineObject engine, GpgmeData in, GpgmeData out,
GpgmeCtx ctx /* FIXME */) GpgmeCtx ctx /* FIXME */)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->sign) if (!engine->ops->sign)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->sign) (engine->engine, in, out, mode, use_armor, return (*engine->ops->sign) (engine->engine, in, out, mode, use_armor,
use_textmode, include_certs, ctx); use_textmode, include_certs, ctx);
@ -403,10 +403,10 @@ GpgmeError
_gpgme_engine_op_trustlist (EngineObject engine, const char *pattern) _gpgme_engine_op_trustlist (EngineObject engine, const char *pattern)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->trustlist) if (!engine->ops->trustlist)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->trustlist) (engine->engine, pattern); return (*engine->ops->trustlist) (engine->engine, pattern);
} }
@ -417,10 +417,10 @@ _gpgme_engine_op_verify (EngineObject engine, GpgmeData sig,
GpgmeData signed_text, GpgmeData plaintext) GpgmeData signed_text, GpgmeData plaintext)
{ {
if (!engine) if (!engine)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!engine->ops->verify) if (!engine->ops->verify)
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
return (*engine->ops->verify) (engine->engine, sig, signed_text, plaintext); return (*engine->ops->verify) (engine->engine, sig, signed_text, plaintext);
} }

View File

@ -49,7 +49,7 @@ _gpgme_op_export_start (GpgmeCtx ctx, int synchronous,
if (!keydata) if (!keydata)
{ {
err = mk_error (Invalid_Value); err = GPGME_Invalid_Value;
goto leave; goto leave;
} }

View File

@ -72,7 +72,7 @@ genkey_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
free (ctx->result.genkey->fpr); free (ctx->result.genkey->fpr);
ctx->result.genkey->fpr = strdup (&args[2]); ctx->result.genkey->fpr = strdup (&args[2]);
if (!ctx->result.genkey->fpr) if (!ctx->result.genkey->fpr)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
} }
break; break;
@ -81,7 +81,7 @@ genkey_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
/* FIXME: Should return some more useful error value. */ /* FIXME: Should return some more useful error value. */
if (!ctx->result.genkey->created_primary if (!ctx->result.genkey->created_primary
&& !ctx->result.genkey->created_sub) && !ctx->result.genkey->created_sub)
return mk_error (General_Error); return GPGME_General_Error;
break; break;
default: 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); err = gpgme_data_new_from_mem (&ctx->help_data_1, s, s2-s, 1);
} }
else else
err = mk_error (Invalid_Value); err = GPGME_Invalid_Value;
if (err) if (err)
goto leave; goto leave;
@ -216,7 +216,7 @@ gpgme_op_genkey (GpgmeCtx ctx, const char *parms,
{ {
*fpr = strdup (ctx->result.genkey->fpr); *fpr = strdup (ctx->result.genkey->fpr);
if (!*fpr) if (!*fpr)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
else else
*fpr = NULL; *fpr = NULL;

View File

@ -46,11 +46,11 @@ gpgme_new (GpgmeCtx *r_ctx)
GpgmeCtx ctx; GpgmeCtx ctx;
if (!r_ctx) if (!r_ctx)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
*r_ctx = 0; *r_ctx = 0;
ctx = calloc (1, sizeof *ctx); ctx = calloc (1, sizeof *ctx);
if (!ctx) if (!ctx)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL; ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL;
ctx->verbosity = 1; ctx->verbosity = 1;
ctx->include_certs = 1; ctx->include_certs = 1;
@ -199,7 +199,7 @@ GpgmeError
gpgme_set_protocol (GpgmeCtx ctx, GpgmeProtocol protocol) gpgme_set_protocol (GpgmeCtx ctx, GpgmeProtocol protocol)
{ {
if (!ctx) if (!ctx)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
switch (protocol) switch (protocol)
{ {
@ -210,9 +210,9 @@ gpgme_set_protocol (GpgmeCtx ctx, GpgmeProtocol protocol)
ctx->use_cms = 1; ctx->use_cms = 1;
break; break;
case GPGME_PROTOCOL_AUTO: case GPGME_PROTOCOL_AUTO:
return mk_error (Not_Implemented); return GPGME_Not_Implemented;
default: default:
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
} }
return 0; return 0;
@ -345,12 +345,12 @@ GpgmeError
gpgme_set_keylist_mode (GpgmeCtx ctx, int mode) gpgme_set_keylist_mode (GpgmeCtx ctx, int mode)
{ {
if (!ctx) if (!ctx)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!((mode & GPGME_KEYLIST_MODE_LOCAL) if (!((mode & GPGME_KEYLIST_MODE_LOCAL)
|| (mode & GPGME_KEYLIST_MODE_EXTERN) || (mode & GPGME_KEYLIST_MODE_EXTERN)
|| (mode & GPGME_KEYLIST_MODE_SIGS))) || (mode & GPGME_KEYLIST_MODE_SIGS)))
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
ctx->keylist_mode = mode; ctx->keylist_mode = mode;
return 0; return 0;

View File

@ -186,7 +186,7 @@ _gpgme_op_import_start (GpgmeCtx ctx, int synchronous, GpgmeData keydata)
/* Check the supplied data */ /* Check the supplied data */
if (!keydata) if (!keydata)
{ {
err = mk_error (No_Data); err = GPGME_No_Data;
goto leave; goto leave;
} }

View File

@ -333,7 +333,7 @@ key_new (GpgmeKey *r_key, int secret)
*r_key = NULL; *r_key = NULL;
key = calloc (1, sizeof *key); key = calloc (1, sizeof *key);
if (!key) if (!key)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
key->ref_count = 1; key->ref_count = 1;
*r_key = key; *r_key = key;
if (secret) 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. */ size, so that we are able to store the parsed stuff there too. */
uid = malloc (sizeof (*uid) + 2 * src_len + 3); uid = malloc (sizeof (*uid) + 2 * src_len + 3);
if (!uid) if (!uid)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
memset (uid, 0, sizeof *uid); memset (uid, 0, sizeof *uid);
dst = uid->name; dst = uid->name;
@ -1199,12 +1199,12 @@ gpgme_get_key (GpgmeCtx ctx, const char *fpr, GpgmeKey *r_key,
GpgmeError err; GpgmeError err;
if (!ctx || !r_key) if (!ctx || !r_key)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (ctx->pending) if (ctx->pending)
return mk_error (Busy); return GPGME_Busy;
if (strlen (fpr) < 16) /* We have at least a key ID. */ if (strlen (fpr) < 16) /* We have at least a key ID. */
return mk_error (Invalid_Key); return GPGME_Invalid_Key;
if (!force_update) if (!force_update)
{ {

View File

@ -384,21 +384,21 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
/* Start a new subkey. */ /* Start a new subkey. */
rectype = RT_SUB; rectype = RT_SUB;
if (!(subkey = _gpgme_key_add_subkey (key))) 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) else if (!strcmp (field[0], "ssb") && key)
{ {
/* Start a new secret subkey. */ /* Start a new secret subkey. */
rectype = RT_SSB; rectype = RT_SSB;
if (!(subkey = _gpgme_key_add_secret_subkey (key))) 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")) else if (!strcmp (field[0], "pub"))
{ {
/* Start a new keyblock. */ /* Start a new keyblock. */
if (_gpgme_key_new (&key)) if (_gpgme_key_new (&key))
/* The only kind of error we can get. */ /* The only kind of error we can get. */
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
rectype = RT_PUB; rectype = RT_PUB;
finish_key (ctx); finish_key (ctx);
assert (!ctx->tmp_key); assert (!ctx->tmp_key);
@ -408,7 +408,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
{ {
/* Start a new keyblock, */ /* Start a new keyblock, */
if (_gpgme_key_new_secret (&key)) if (_gpgme_key_new_secret (&key))
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
rectype = RT_SEC; rectype = RT_SEC;
finish_key (ctx); finish_key (ctx);
assert (!ctx->tmp_key); assert (!ctx->tmp_key);
@ -418,7 +418,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
{ {
/* Start a new certificate. */ /* Start a new certificate. */
if (_gpgme_key_new (&key)) if (_gpgme_key_new (&key))
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
key->x509 = 1; key->x509 = 1;
rectype = RT_CRT; rectype = RT_CRT;
finish_key (ctx); finish_key (ctx);
@ -429,7 +429,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
{ {
/* Start a new certificate. */ /* Start a new certificate. */
if (_gpgme_key_new_secret (&key)) if (_gpgme_key_new_secret (&key))
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
key->x509 = 1; key->x509 = 1;
rectype = RT_CRS; rectype = RT_CRS;
finish_key (ctx); finish_key (ctx);
@ -456,14 +456,14 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
{ {
key->issuer_serial = strdup (field[7]); key->issuer_serial = strdup (field[7]);
if (!key->issuer_serial) 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 /* Field 10 is not used for gpg due to --fixed-list-mode option
but GPGSM stores the issuer name. */ but GPGSM stores the issuer name. */
if (fields >= 10 && _gpgme_decode_c_string (field[9], if (fields >= 10 && _gpgme_decode_c_string (field[9],
&key->issuer_name, 0)) &key->issuer_name, 0))
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
/* Fall through! */ /* Fall through! */
case RT_PUB: case RT_PUB:
@ -563,7 +563,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
if (fields >= 10) if (fields >= 10)
{ {
if (_gpgme_key_append_name (key, field[9])) if (_gpgme_key_append_name (key, field[9]))
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
else else
{ {
if (field[1]) if (field[1])
@ -579,7 +579,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
{ {
key->keys.fingerprint = strdup (field[9]); key->keys.fingerprint = strdup (field[9]);
if (!key->keys.fingerprint) 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). */ /* 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]); key->chain_id = strdup (field[12]);
if (!key->chain_id) if (!key->chain_id)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
break; break;
@ -600,7 +600,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
assert (ctx->tmp_uid == key->last_uid); assert (ctx->tmp_uid == key->last_uid);
certsig = _gpgme_key_add_certsig (key, (fields >= 10) ? field[9] : NULL); certsig = _gpgme_key_add_certsig (key, (fields >= 10) ? field[9] : NULL);
if (!certsig) if (!certsig)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
/* Field 2 has the calculated trust ('!', '-', '?', '%'). */ /* Field 2 has the calculated trust ('!', '-', '?', '%'). */
if (fields >= 2) if (fields >= 2)
@ -686,7 +686,7 @@ _gpgme_op_keylist_event_cb (void *data, GpgmeEventIO type, void *type_data)
if (!q) if (!q)
{ {
gpgme_key_release (key); gpgme_key_release (key);
/* FIXME return mk_error (Out_Of_Core); */ /* FIXME return GPGME_Out_Of_Core; */
return; return;
} }
q->key = key; q->key = key;
@ -825,12 +825,12 @@ gpgme_op_keylist_next (GpgmeCtx ctx, GpgmeKey *r_key)
struct key_queue_item_s *queue_item; struct key_queue_item_s *queue_item;
if (!r_key) if (!r_key)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
*r_key = NULL; *r_key = NULL;
if (!ctx) if (!ctx)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!ctx->pending) if (!ctx->pending)
return mk_error (No_Request); return GPGME_No_Request;
if (!ctx->key_queue) if (!ctx->key_queue)
{ {
@ -852,7 +852,7 @@ gpgme_op_keylist_next (GpgmeCtx ctx, GpgmeKey *r_key)
if (!ctx->key_cond) if (!ctx->key_cond)
{ {
ctx->pending = 0; ctx->pending = 0;
return mk_error (EOF); return GPGME_EOF;
} }
ctx->key_cond = 0; ctx->key_cond = 0;
assert (ctx->key_queue); assert (ctx->key_queue);
@ -879,9 +879,9 @@ GpgmeError
gpgme_op_keylist_end (GpgmeCtx ctx) gpgme_op_keylist_end (GpgmeCtx ctx)
{ {
if (!ctx) if (!ctx)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!ctx->pending) if (!ctx->pending)
return mk_error (No_Request); return GPGME_No_Request;
ctx->pending = 0; ctx->pending = 0;
return 0; return 0;

View File

@ -32,7 +32,7 @@
{ \ { \
ctx->result.field = calloc (1, sizeof *ctx->result.field); \ ctx->result.field = calloc (1, sizeof *ctx->result.field); \
if (!ctx->result.field) \ if (!ctx->result.field) \
return mk_error (Out_Of_Core); \ return GPGME_Out_Of_Core; \
} \ } \
} \ } \
while (0) while (0)

View File

@ -62,7 +62,7 @@ _gpgme_passphrase_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args
case GPGME_STATUS_USERID_HINT: case GPGME_STATUS_USERID_HINT:
free (ctx->result.passphrase->userid_hint); free (ctx->result.passphrase->userid_hint);
if (!(ctx->result.passphrase->userid_hint = strdup (args))) if (!(ctx->result.passphrase->userid_hint = strdup (args)))
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
break; break;
case GPGME_STATUS_BAD_PASSPHRASE: 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); free (ctx->result.passphrase->passphrase_info);
ctx->result.passphrase->passphrase_info = strdup (args); ctx->result.passphrase->passphrase_info = strdup (args);
if (!ctx->result.passphrase->passphrase_info) if (!ctx->result.passphrase->passphrase_info)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
break; break;
case GPGME_STATUS_MISSING_PASSPHRASE: case GPGME_STATUS_MISSING_PASSPHRASE:
@ -91,7 +91,7 @@ _gpgme_passphrase_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args
case GPGME_STATUS_EOF: case GPGME_STATUS_EOF:
if (ctx->result.passphrase->no_passphrase if (ctx->result.passphrase->no_passphrase
|| ctx->result.passphrase->bad_passphrase) || ctx->result.passphrase->bad_passphrase)
return mk_error (No_Passphrase); return GPGME_No_Passphrase;
break; break;
default: default:
@ -112,7 +112,7 @@ _gpgme_passphrase_command_handler (void *opaque, GpgmeStatusCode code,
{ {
ctx->result.passphrase = calloc (1, sizeof *ctx->result.passphrase); ctx->result.passphrase = calloc (1, sizeof *ctx->result.passphrase);
if (!ctx->result.passphrase) if (!ctx->result.passphrase)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
if (!code) if (!code)
@ -149,7 +149,7 @@ _gpgme_passphrase_command_handler (void *opaque, GpgmeStatusCode code,
buf = malloc (20 + strlen (userid_hint) buf = malloc (20 + strlen (userid_hint)
+ strlen (passphrase_info) + 3); + strlen (passphrase_info) + 3);
if (!buf) if (!buf)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
sprintf (buf, "%s\n%s\n%s", sprintf (buf, "%s\n%s\n%s",
bad_passphrase ? "TRY_AGAIN":"ENTER", bad_passphrase ? "TRY_AGAIN":"ENTER",
userid_hint, passphrase_info); userid_hint, passphrase_info);

View File

@ -42,7 +42,7 @@ _gpgme_progress_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
args_cpy = strdup (args); args_cpy = strdup (args);
if (!args_cpy) if (!args_cpy)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
p = strchr (args_cpy, ' '); p = strchr (args_cpy, ' ');
if (p) if (p)

View File

@ -44,7 +44,7 @@ gpgme_recipients_new (GpgmeRecipients *r_rset)
rset = calloc ( 1, sizeof *rset ); rset = calloc ( 1, sizeof *rset );
if (!rset) if (!rset)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
*r_rset = rset; *r_rset = rset;
return 0; return 0;
} }
@ -111,10 +111,10 @@ gpgme_recipients_add_name_with_validity (GpgmeRecipients rset,
struct user_id_s *r; struct user_id_s *r;
if (!name || !rset ) if (!name || !rset )
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
r = malloc ( sizeof *r + strlen (name) ); r = malloc ( sizeof *r + strlen (name) );
if (!r) if (!r)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
r->validity = val; r->validity = val;
r->name_part = ""; r->name_part = "";
r->email_part = ""; r->email_part = "";
@ -164,7 +164,7 @@ GpgmeError
gpgme_recipients_enum_open ( const GpgmeRecipients rset, void **ctx ) gpgme_recipients_enum_open ( const GpgmeRecipients rset, void **ctx )
{ {
if (!rset || !ctx) if (!rset || !ctx)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
*ctx = rset->list; *ctx = rset->list;
return 0; return 0;
@ -217,7 +217,7 @@ GpgmeError
gpgme_recipients_enum_close ( const GpgmeRecipients rset, void **ctx ) gpgme_recipients_enum_close ( const GpgmeRecipients rset, void **ctx )
{ {
if (!rset || !ctx) if (!rset || !ctx)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
*ctx = NULL; *ctx = NULL;
return 0; return 0;
} }

View File

@ -190,7 +190,7 @@ add_arg (GpgObject gpg, const char *arg)
if (!a) if (!a)
{ {
gpg->arg_error = 1; gpg->arg_error = 1;
return mk_error(Out_Of_Core); return GPGME_Out_Of_Core;
} }
a->next = NULL; a->next = NULL;
a->data = NULL; a->data = NULL;
@ -213,7 +213,7 @@ add_data (GpgObject gpg, GpgmeData data, int dup_to, int inbound)
if (!a) if (!a)
{ {
gpg->arg_error = 1; gpg->arg_error = 1;
return mk_error(Out_Of_Core); return GPGME_Out_Of_Core;
} }
a->next = NULL; a->next = NULL;
a->data = data; a->data = data;
@ -252,7 +252,7 @@ static GpgmeError
gpg_check_version (void) gpg_check_version (void)
{ {
return _gpgme_compare_versions (gpg_get_version (), NEED_GPG_VERSION) 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); gpg = calloc (1, sizeof *gpg);
if (!gpg) if (!gpg)
{ {
rc = mk_error (Out_Of_Core); rc = GPGME_Out_Of_Core;
goto leave; goto leave;
} }
gpg->argtail = &gpg->arglist; gpg->argtail = &gpg->arglist;
@ -354,14 +354,14 @@ gpg_new (void **engine)
gpg->status.buffer = malloc (gpg->status.bufsize); gpg->status.buffer = malloc (gpg->status.bufsize);
if (!gpg->status.buffer) if (!gpg->status.buffer)
{ {
rc = mk_error (Out_Of_Core); rc = GPGME_Out_Of_Core;
goto leave; goto leave;
} }
/* In any case we need a status pipe - create it right here and /* In any case we need a status pipe - create it right here and
don't handle it with our generic GpgmeData mechanism. */ don't handle it with our generic GpgmeData mechanism. */
if (_gpgme_io_pipe (gpg->status.fd, 1) == -1) if (_gpgme_io_pipe (gpg->status.fd, 1) == -1)
{ {
rc = mk_error (Pipe_Error); rc = GPGME_Pipe_Error;
goto leave; goto leave;
} }
if (_gpgme_io_set_close_notify (gpg->status.fd[0], 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], || _gpgme_io_set_close_notify (gpg->status.fd[1],
close_notify_handler, gpg)) close_notify_handler, gpg))
{ {
rc = mk_error (General_Error); rc = GPGME_General_Error;
goto leave; goto leave;
} }
gpg->status.eof = 0; gpg->status.eof = 0;
@ -425,18 +425,18 @@ gpg_set_colon_line_handler (void *engine, GpgmeColonLineHandler fnc,
gpg->colon.readpos = 0; gpg->colon.readpos = 0;
gpg->colon.buffer = malloc (gpg->colon.bufsize); gpg->colon.buffer = malloc (gpg->colon.bufsize);
if (!gpg->colon.buffer) if (!gpg->colon.buffer)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
if (_gpgme_io_pipe (gpg->colon.fd, 1) == -1) if (_gpgme_io_pipe (gpg->colon.fd, 1) == -1)
{ {
free (gpg->colon.buffer); free (gpg->colon.buffer);
gpg->colon.buffer = NULL; 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) if (_gpgme_io_set_close_notify (gpg->colon.fd[0], close_notify_handler, gpg)
|| _gpgme_io_set_close_notify (gpg->colon.fd[1], || _gpgme_io_set_close_notify (gpg->colon.fd[1],
close_notify_handler, gpg)) close_notify_handler, gpg))
return mk_error (General_Error); return GPGME_General_Error;
gpg->colon.eof = 0; gpg->colon.eof = 0;
gpg->colon.fnc = fnc; gpg->colon.fnc = fnc;
gpg->colon.fnc_value = fnc_value; gpg->colon.fnc_value = fnc_value;
@ -588,12 +588,12 @@ build_argv (GpgObject gpg)
argv = calloc (argc + 1, sizeof *argv); argv = calloc (argc + 1, sizeof *argv);
if (!argv) if (!argv)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
fd_data_map = calloc (datac + 1, sizeof *fd_data_map); fd_data_map = calloc (datac + 1, sizeof *fd_data_map);
if (!fd_data_map) if (!fd_data_map)
{ {
free_argv (argv); free_argv (argv);
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
argc = datac = 0; argc = datac = 0;
@ -602,7 +602,7 @@ build_argv (GpgObject gpg)
{ {
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
argc++; argc++;
if (need_special) if (need_special)
@ -612,7 +612,7 @@ build_argv (GpgObject gpg)
{ {
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
argc++; argc++;
} }
@ -623,7 +623,7 @@ build_argv (GpgObject gpg)
{ {
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
argc++; argc++;
} }
@ -634,7 +634,7 @@ build_argv (GpgObject gpg)
{ {
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
argc++; argc++;
} }
@ -643,7 +643,7 @@ build_argv (GpgObject gpg)
{ {
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
argc++; argc++;
argv[argc] = strdup (""); argv[argc] = strdup ("");
@ -651,7 +651,7 @@ build_argv (GpgObject gpg)
{ {
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
argc++; argc++;
for (a = gpg->arglist; a; a = a->next) for (a = gpg->arglist; a; a = a->next)
@ -670,7 +670,7 @@ build_argv (GpgObject gpg)
{ {
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return mk_error (Pipe_Error); return GPGME_Pipe_Error;
} }
if (_gpgme_io_set_close_notify (fds[0], if (_gpgme_io_set_close_notify (fds[0],
close_notify_handler, gpg) close_notify_handler, gpg)
@ -678,7 +678,7 @@ build_argv (GpgObject gpg)
close_notify_handler, close_notify_handler,
gpg)) gpg))
{ {
return mk_error (General_Error); return GPGME_General_Error;
} }
/* If the data_type is FD, we have to do a dup2 here. */ /* If the data_type is FD, we have to do a dup2 here. */
if (fd_data_map[datac].inbound) if (fd_data_map[datac].inbound)
@ -717,7 +717,7 @@ build_argv (GpgObject gpg)
{ {
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
sprintf (argv[argc], sprintf (argv[argc],
a->print_fd ? "%d" : "-&%d", a->print_fd ? "%d" : "-&%d",
@ -733,7 +733,7 @@ build_argv (GpgObject gpg)
{ {
free (fd_data_map); free (fd_data_map);
free_argv (argv); free_argv (argv);
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
argc++; argc++;
} }
@ -794,13 +794,13 @@ read_status (GpgObject gpg)
bufsize += 1024; bufsize += 1024;
buffer = realloc (buffer, bufsize); buffer = realloc (buffer, bufsize);
if (!buffer) if (!buffer)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
nread = _gpgme_io_read (gpg->status.fd[0], nread = _gpgme_io_read (gpg->status.fd[0],
buffer + readpos, bufsize-readpos); buffer + readpos, bufsize-readpos);
if (nread == -1) if (nread == -1)
return mk_error(Read_Error); return GPGME_Read_Error;
if (!nread) if (!nread)
{ {
@ -845,7 +845,7 @@ read_status (GpgObject gpg)
free (gpg->cmd.keyword); free (gpg->cmd.keyword);
gpg->cmd.keyword = strdup (rest); gpg->cmd.keyword = strdup (rest);
if (!gpg->cmd.keyword) if (!gpg->cmd.keyword)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
/* This should be the last thing we have /* This should be the last thing we have
received and the next thing will be that received and the next thing will be that
the command handler does its action. */ the command handler does its action. */
@ -964,12 +964,12 @@ read_colon_line (GpgObject gpg)
bufsize += 1024; bufsize += 1024;
buffer = realloc (buffer, bufsize); buffer = realloc (buffer, bufsize);
if (!buffer) 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); nread = _gpgme_io_read (gpg->colon.fd[0], buffer+readpos, bufsize-readpos);
if (nread == -1) if (nread == -1)
return mk_error (Read_Error); return GPGME_Read_Error;
if (!nread) if (!nread)
{ {
@ -1051,15 +1051,15 @@ start (GpgObject gpg)
struct spawn_fd_item_s *fd_child_list, *fd_parent_list; struct spawn_fd_item_s *fd_child_list, *fd_parent_list;
if (!gpg) if (!gpg)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (! _gpgme_get_gpg_path ()) 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 /* Kludge, so that we don't need to check the return code of all the
add_arg (). We bail out here instead. */ add_arg (). We bail out here instead. */
if (gpg->arg_error) if (gpg->arg_error)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
rc = build_argv (gpg); rc = build_argv (gpg);
if (rc) if (rc)
@ -1070,7 +1070,7 @@ start (GpgObject gpg)
n++; n++;
fd_child_list = calloc (n + n, sizeof *fd_child_list); fd_child_list = calloc (n + n, sizeof *fd_child_list);
if (!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; fd_parent_list = fd_child_list + n;
/* build the fd list for the child */ /* build the fd list for the child */
@ -1120,7 +1120,7 @@ start (GpgObject gpg)
gpg->argv, fd_child_list, fd_parent_list); gpg->argv, fd_child_list, fd_parent_list);
free (fd_child_list); free (fd_child_list);
if (status == -1) if (status == -1)
return mk_error (Exec_Error); return GPGME_Exec_Error;
/*_gpgme_register_term_handler ( closure, closure_value, pid );*/ /*_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); const char *s = gpgme_key_get_string_attr (key, GPGME_ATTR_FPR, NULL, 0);
if (!s) if (!s)
err = mk_error (Invalid_Key); err = GPGME_Invalid_Key;
else else
err = add_arg (gpg, s); 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); const char *s = gpgme_key_get_string_attr (key, GPGME_ATTR_FPR, NULL, 0);
if (!s) if (!s)
err = mk_error (Invalid_Key); err = GPGME_Invalid_Key;
else else
err = add_arg (gpg, s); err = add_arg (gpg, s);
} }
@ -1420,14 +1420,14 @@ gpg_genkey (void *engine, GpgmeData help_data, int use_armor,
GpgmeError err; GpgmeError err;
if (!gpg) 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 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 we can use this for the %pubring and %secring parameters. We
don't have this yet, so we implement only the adding to the don't have this yet, so we implement only the adding to the
standard keyrings. */ standard keyrings. */
if (pubkey || seckey) if (pubkey || seckey)
return err = mk_error (Not_Implemented); return err = GPGME_Not_Implemented;
err = add_arg (gpg, "--gen-key"); err = add_arg (gpg, "--gen-key");
if (!err && use_armor) if (!err && use_armor)
@ -1499,7 +1499,7 @@ gpg_keylist_ext (void *engine, const char *pattern[], int secret_only,
GpgmeError err; GpgmeError err;
if (reserved) if (reserved)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
err = add_arg (gpg, "--with-colons"); err = add_arg (gpg, "--with-colons");
if (!err) if (!err)

View File

@ -155,7 +155,7 @@ _gpgme_sign_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
ctx->result.sign->xmlinfo = NULL; ctx->result.sign->xmlinfo = NULL;
} }
if (!ctx->result.sign->okay) 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; break;
case GPGME_STATUS_SIG_CREATED: case GPGME_STATUS_SIG_CREATED:
@ -180,7 +180,7 @@ _gpgme_op_sign_start (GpgmeCtx ctx, int synchronous,
if (mode != GPGME_SIG_MODE_NORMAL if (mode != GPGME_SIG_MODE_NORMAL
&& mode != GPGME_SIG_MODE_DETACH && mode != GPGME_SIG_MODE_DETACH
&& mode != GPGME_SIG_MODE_CLEAR) && mode != GPGME_SIG_MODE_CLEAR)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
err = _gpgme_op_reset (ctx, synchronous); err = _gpgme_op_reset (ctx, synchronous);
if (err) if (err)
@ -189,12 +189,12 @@ _gpgme_op_sign_start (GpgmeCtx ctx, int synchronous,
/* Check the supplied data. */ /* Check the supplied data. */
if (!in) if (!in)
{ {
err = mk_error (No_Data); err = GPGME_No_Data;
goto leave; goto leave;
} }
if (!out) if (!out)
{ {
err = mk_error (Invalid_Value); err = GPGME_Invalid_Value;
goto leave; goto leave;
} }

View File

@ -74,7 +74,7 @@ GpgmeError
gpgme_signers_add (GpgmeCtx ctx, const GpgmeKey key) gpgme_signers_add (GpgmeCtx ctx, const GpgmeKey key)
{ {
if (!ctx || !key) if (!ctx || !key)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (ctx->signers_len == ctx->signers_size) 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)); newarr = realloc (ctx->signers, n * sizeof (*newarr));
if (!newarr) if (!newarr)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
for (j = ctx->signers_size; j < n; j++) for (j = ctx->signers_size; j < n; j++)
newarr[j] = NULL; newarr[j] = NULL;
ctx->signers = newarr; ctx->signers = newarr;

View File

@ -100,7 +100,7 @@ trustlist_colon_handler (GpgmeCtx ctx, char *line)
case 1: /* level */ case 1: /* level */
item = trust_item_new (); item = trust_item_new ();
if (!item) if (!item)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
item->level = atoi (p); item->level = atoi (p);
break; break;
case 2: /* long keyid */ case 2: /* long keyid */
@ -121,7 +121,7 @@ trustlist_colon_handler (GpgmeCtx ctx, char *line)
case 9: /* user ID */ case 9: /* user ID */
item->name = strdup (p); item->name = strdup (p);
if (!item->name) if (!item->name)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
break; break;
} }
} }
@ -146,7 +146,7 @@ _gpgme_op_trustlist_event_cb (void *data, GpgmeEventIO type, void *type_data)
{ {
gpgme_trust_item_release (item); gpgme_trust_item_release (item);
/* FIXME */ /* FIXME */
/* ctx->error = mk_error (Out_Of_Core); */ /* ctx->error = GPGME_Out_Of_Core; */
return; return;
} }
q->item = item; q->item = item;
@ -172,7 +172,7 @@ gpgme_op_trustlist_start (GpgmeCtx ctx, const char *pattern, int max_level)
GpgmeError err = 0; GpgmeError err = 0;
if (!pattern || !*pattern) if (!pattern || !*pattern)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
err = _gpgme_op_reset (ctx, 2); err = _gpgme_op_reset (ctx, 2);
if (err) if (err)
@ -204,12 +204,12 @@ gpgme_op_trustlist_next (GpgmeCtx ctx, GpgmeTrustItem *r_item)
struct trust_queue_item_s *q; struct trust_queue_item_s *q;
if (!r_item) if (!r_item)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
*r_item = NULL; *r_item = NULL;
if (!ctx) if (!ctx)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!ctx->pending) if (!ctx->pending)
return mk_error (No_Request); return GPGME_No_Request;
if (!ctx->trust_queue) if (!ctx->trust_queue)
{ {
@ -231,7 +231,7 @@ gpgme_op_trustlist_next (GpgmeCtx ctx, GpgmeTrustItem *r_item)
if (!ctx->key_cond) if (!ctx->key_cond)
{ {
ctx->pending = 0; ctx->pending = 0;
return mk_error (EOF); return GPGME_EOF;
} }
ctx->key_cond = 0; ctx->key_cond = 0;
assert (ctx->trust_queue); assert (ctx->trust_queue);
@ -256,9 +256,9 @@ GpgmeError
gpgme_op_trustlist_end (GpgmeCtx ctx) gpgme_op_trustlist_end (GpgmeCtx ctx)
{ {
if (!ctx) if (!ctx)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (!ctx->pending) if (!ctx->pending)
return mk_error (No_Request); return GPGME_No_Request;
ctx->pending = 0; ctx->pending = 0;
return 0; return 0;

View File

@ -1,23 +1,22 @@
/* util.h /* util.h
* Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2000 Werner Koch (dd9jn)
* Copyright (C) 2001 g10 Code GmbH Copyright (C) 2001, 2002, 2003 g10 Code GmbH
*
* This file is part of GPGME. This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify GPGME is free software; you can redistribute it and/or modify it
* it under the terms of the GNU General Public License as published by under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, GPGME is distributed in the hope that it will be useful, but
* but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* GNU General Public License for more details. General Public License for more details.
*
* You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software along with GPGME; if not, write to the Free Software Foundation,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
*/
#ifndef UTIL_H #ifndef UTIL_H
#define UTIL_H #define UTIL_H
@ -25,8 +24,6 @@
#include "types.h" #include "types.h"
#include "debug.h" #include "debug.h"
#define mk_error(a) ( GPGME_##a )
#define DIM(v) (sizeof(v)/sizeof((v)[0])) #define DIM(v) (sizeof(v)/sizeof((v)[0]))
#define DIMof(type,member) DIM(((type *)0)->member) #define DIMof(type,member) DIM(((type *)0)->member)

View File

@ -127,7 +127,7 @@ add_notation (GpgmeCtx ctx, GpgmeStatusCode code, const char *data)
if (!dh) if (!dh)
{ {
if (gpgme_data_new (&dh)) if (gpgme_data_new (&dh))
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
ctx->result.verify->notation = dh; ctx->result.verify->notation = dh;
_gpgme_data_append_string (dh, " <notation>\n"); _gpgme_data_append_string (dh, " <notation>\n");
} }
@ -184,7 +184,7 @@ finish_sig (GpgmeCtx ctx, int stop)
/* Create a new result structure. */ /* Create a new result structure. */
res2 = calloc (1, sizeof *res2); res2 = calloc (1, sizeof *res2);
if (!res2) if (!res2)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
res2->next = ctx->result.verify; res2->next = ctx->result.verify;
ctx->result.verify = res2; ctx->result.verify = res2;
@ -375,12 +375,12 @@ _gpgme_op_verify_start (GpgmeCtx ctx, int synchronous,
/* Check the supplied data. */ /* Check the supplied data. */
if (!sig) if (!sig)
{ {
err = mk_error (No_Data); err = GPGME_No_Data;
goto leave; goto leave;
} }
if (!signed_text && !plaintext) if (!signed_text && !plaintext)
{ {
err = mk_error (Invalid_Value); err = GPGME_Invalid_Value;
goto leave; goto leave;
} }
err = _gpgme_engine_op_verify (ctx->engine, sig, signed_text, plaintext); 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; VerifyResult result;
if (!ctx || !r_key) if (!ctx || !r_key)
return mk_error (Invalid_Value); return GPGME_Invalid_Value;
if (ctx->pending || !ctx->result.verify) if (ctx->pending || !ctx->result.verify)
return mk_error (Busy); return GPGME_Busy;
for (result = ctx->result.verify; for (result = ctx->result.verify;
result && idx > 0; result = result->next, idx--) result && idx > 0; result = result->next, idx--)
; ;
if (!result) if (!result)
return mk_error (EOF); return GPGME_EOF;
return gpgme_get_key (ctx, result->fpr, r_key, 0, 0); return gpgme_get_key (ctx, result->fpr, r_key, 0, 0);
} }

View File

@ -91,7 +91,7 @@ ctx_active (GpgmeCtx ctx)
{ {
struct ctx_list_item *li = malloc (sizeof (struct ctx_list_item)); struct ctx_list_item *li = malloc (sizeof (struct ctx_list_item));
if (!li) if (!li)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
li->ctx = ctx; li->ctx = ctx;
LOCK (ctx_list_lock); LOCK (ctx_list_lock);
@ -266,7 +266,7 @@ gpgme_wait (GpgmeCtx ctx, GpgmeError *status, int hang)
{ {
UNLOCK (ctx_list_lock); UNLOCK (ctx_list_lock);
if (status) if (status)
*status = mk_error (Out_Of_Core); *status = GPGME_Out_Of_Core;
return NULL; return NULL;
} }
fdt.size = i; fdt.size = i;
@ -284,7 +284,7 @@ gpgme_wait (GpgmeCtx ctx, GpgmeError *status, int hang)
{ {
free (fdt.fds); free (fdt.fds);
if (status) if (status)
*status = mk_error (File_Error); *status = GPGME_File_Error;
return NULL; return NULL;
} }
@ -306,7 +306,7 @@ gpgme_wait (GpgmeCtx ctx, GpgmeError *status, int hang)
err = item->handler (item->handler_value, fdt.fds[i].fd); err = item->handler (item->handler_value, fdt.fds[i].fd);
if (!err && ictx->cancel) if (!err && ictx->cancel)
err = mk_error (Canceled); err = GPGME_Canceled;
if (err) if (err)
{ {
/* An error occured. Close all fds in this context, /* An error occured. Close all fds in this context,

View File

@ -88,7 +88,7 @@ _gpgme_wait_on_condition (GpgmeCtx ctx, volatile int *cond)
signal it. */ signal it. */
int idx; int idx;
err = mk_error (File_Error); err = GPGME_File_Error;
for (idx = 0; idx < ctx->fdt.size; idx++) for (idx = 0; idx < ctx->fdt.size; idx++)
if (ctx->fdt.fds[idx].fd != -1) if (ctx->fdt.fds[idx].fd != -1)
_gpgme_io_close (ctx->fdt.fds[idx].fd); _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); err = item->handler (item->handler_value, ctx->fdt.fds[i].fd);
if (!err && ctx->cancel) if (!err && ctx->cancel)
err = mk_error (Canceled); err = GPGME_Canceled;
if (err) if (err)
{ {
/* An error occured. Close all fds in this context, /* An error occured. Close all fds in this context,

View File

@ -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) new_fds = realloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE)
* sizeof (*new_fds)); * sizeof (*new_fds));
if (!new_fds) if (!new_fds)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
fdt->fds = new_fds; fdt->fds = new_fds;
fdt->size += FDT_ALLOCSIZE; 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); tag = malloc (sizeof *tag);
if (!tag) if (!tag)
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
tag->ctx = ctx; tag->ctx = ctx;
/* Allocate a structure to hold information about the handler. */ /* 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) if (!item)
{ {
free (tag); free (tag);
return mk_error (Out_Of_Core); return GPGME_Out_Of_Core;
} }
item->ctx = ctx; item->ctx = ctx;
item->dir = dir; item->dir = dir;