* 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.
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 (gpgme_context_s): Remove member ERROR.
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;
}
_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;
}
int err = 0;
if (!dh || !buffer)
- return mk_error (Invalid_Value);
+ return GPGME_Invalid_Value;
do
{
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;
if (fname)
fclose (stream);
errno = saved_errno;
- return mk_error (File_Error);
+ return GPGME_File_Error;
}
}
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);
}
{
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:
gpgme_data_rewind (GpgmeData dh)
{
return (gpgme_data_seek (dh, 0, SEEK_SET) == -1)
- ? mk_error (File_Error) : 0;
+ ? GPGME_File_Error : 0;
}
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;
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;
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);
{
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);
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);
{
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:
/* 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;
}
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;
GpgmeError err = 0;
if (!fnc)
- return mk_error (Invalid_Value);
+ return GPGME_Invalid_Value;
err = _gpgme_op_reset (ctx, synchronous);
if (err)
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;
/* Check the supplied data. */
if (!out)
{
- err = mk_error (Invalid_Value);
+ err = GPGME_Invalid_Value;
goto leave;
}
/* 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;
}
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:
symmetric = 1;
else if (!gpgme_recipients_count (recp))
{
- err = mk_error (No_Recipients);
+ err = GPGME_No_Recipients;
goto leave;
}
/* 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;
}
gpgsm_check_version (void)
{
return _gpgme_compare_versions (gpgsm_get_version (), NEED_GPGSM_VERSION)
- ? 0 : mk_error (Invalid_Engine);
+ ? 0 : GPGME_Invalid_Engine;
}
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:
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:
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:
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:
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;
}
}
gpgsm = calloc (1, sizeof *gpgsm);
if (!gpgsm)
{
- err = mk_error (Out_Of_Core);
+ err = GPGME_Out_Of_Core;
return err;
}
if (_gpgme_io_pipe (fds, 0) < 0)
{
- err = mk_error (Pipe_Error);
+ err = GPGME_Pipe_Error;
goto leave;
}
gpgsm->input_cb.fd = fds[1];
if (_gpgme_io_pipe (fds, 1) < 0)
{
- err = mk_error (Pipe_Error);
+ err = GPGME_Pipe_Error;
goto leave;
}
gpgsm->output_cb.fd = fds[0];
if (_gpgme_io_pipe (fds, 0) < 0)
{
- err = mk_error (Pipe_Error);
+ err = GPGME_Pipe_Error;
goto leave;
}
gpgsm->message_cb.fd = fds[1];
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
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;
{
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,
{
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,
{
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,
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,
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,
|| _gpgme_io_set_close_notify (gpgsm->message_cb.fd,
close_notify_handler, gpgsm)))
{
- err = mk_error (General_Error);
+ err = GPGME_General_Error;
goto leave;
}
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);
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'
unsigned char *newline = realloc (*aline,
*alinelen + linelen + 1);
if (!newline)
- err = mk_error (Out_Of_Core);
+ err = GPGME_Out_Of_Core;
else
{
*aline = newline;
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");
int length = 8; /* "DELKEYS " */
if (!fpr)
- return mk_error (Invalid_Key);
+ return GPGME_Invalid_Key;
while (*linep)
{
line = malloc (length);
if (!line)
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
strcpy (line, "DELKEYS ");
linep = &line[8];
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)
{
if (! newline)
{
free (line);
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
line = newline;
linelen = newlen;
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,
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;
if (!newcmd)
{
free (cmd);
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
cmd = newcmd;
cmdlen *= 2;
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,
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,
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)
/* 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 ");
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)
}
line = malloc (length);
if (!line)
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
if (secret_only)
{
strcpy (line, "LISTSECRETKEYS ");
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)
gpgsm_trustlist (void *engine, const char *pattern)
{
/* FIXME */
- return mk_error (Not_Implemented);
+ return GPGME_Not_Implemented;
}
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,
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) ();
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)
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);
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);
_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);
}
_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);
}
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);
}
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);
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);
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);
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);
_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);
}
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);
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);
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);
_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);
}
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);
}
if (!keydata)
{
- err = mk_error (Invalid_Value);
+ err = GPGME_Invalid_Value;
goto leave;
}
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;
/* 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:
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;
{
*fpr = strdup (ctx->result.genkey->fpr);
if (!*fpr)
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
else
*fpr = NULL;
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;
gpgme_set_protocol (GpgmeCtx ctx, GpgmeProtocol protocol)
{
if (!ctx)
- return mk_error (Invalid_Value);
+ return GPGME_Invalid_Value;
switch (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;
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;
/* Check the supplied data */
if (!keydata)
{
- err = mk_error (No_Data);
+ err = GPGME_No_Data;
goto leave;
}
*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)
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;
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)
{
/* 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);
{
/* 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);
{
/* 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);
{
/* 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);
{
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:
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])
{
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). */
{
key->chain_id = strdup (field[12]);
if (!key->chain_id)
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
break;
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)
if (!q)
{
gpgme_key_release (key);
- /* FIXME return mk_error (Out_Of_Core); */
+ /* FIXME return GPGME_Out_Of_Core; */
return;
}
q->key = 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)
{
if (!ctx->key_cond)
{
ctx->pending = 0;
- return mk_error (EOF);
+ return GPGME_EOF;
}
ctx->key_cond = 0;
assert (ctx->key_queue);
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;
{ \
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)
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:
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:
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:
{
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)
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);
args_cpy = strdup (args);
if (!args_cpy)
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
p = strchr (args_cpy, ' ');
if (p)
rset = calloc ( 1, sizeof *rset );
if (!rset)
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
*r_rset = rset;
return 0;
}
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 = "";
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;
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;
}
if (!a)
{
gpg->arg_error = 1;
- return mk_error(Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
a->next = NULL;
a->data = NULL;
if (!a)
{
gpg->arg_error = 1;
- return mk_error(Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
a->next = NULL;
a->data = data;
gpg_check_version (void)
{
return _gpgme_compare_versions (gpg_get_version (), NEED_GPG_VERSION)
- ? 0 : mk_error (Invalid_Engine);
+ ? 0 : GPGME_Invalid_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;
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],
|| _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;
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;
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;
{
free (fd_data_map);
free_argv (argv);
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
argc++;
if (need_special)
{
free (fd_data_map);
free_argv (argv);
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
argc++;
}
{
free (fd_data_map);
free_argv (argv);
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
argc++;
}
{
free (fd_data_map);
free_argv (argv);
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
argc++;
}
{
free (fd_data_map);
free_argv (argv);
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
argc++;
argv[argc] = strdup ("");
{
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)
{
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)
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)
{
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",
{
free (fd_data_map);
free_argv (argv);
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
argc++;
}
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)
{
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. */
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)
{
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)
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 */
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 );*/
{
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);
}
{
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);
}
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)
GpgmeError err;
if (reserved)
- return mk_error (Invalid_Value);
+ return GPGME_Invalid_Value;
err = add_arg (gpg, "--with-colons");
if (!err)
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:
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)
/* 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;
}
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)
{
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;
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 */
case 9: /* user ID */
item->name = strdup (p);
if (!item->name)
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
break;
}
}
{
gpgme_trust_item_release (item);
/* FIXME */
- /* ctx->error = mk_error (Out_Of_Core); */
+ /* ctx->error = GPGME_Out_Of_Core; */
return;
}
q->item = item;
GpgmeError err = 0;
if (!pattern || !*pattern)
- return mk_error (Invalid_Value);
+ return GPGME_Invalid_Value;
err = _gpgme_op_reset (ctx, 2);
if (err)
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)
{
if (!ctx->key_cond)
{
ctx->pending = 0;
- return mk_error (EOF);
+ return GPGME_EOF;
}
ctx->key_cond = 0;
assert (ctx->trust_queue);
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;
/* 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
#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)
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, " <notation>\n");
}
/* 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;
/* 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);
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);
}
{
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);
{
UNLOCK (ctx_list_lock);
if (status)
- *status = mk_error (Out_Of_Core);
+ *status = GPGME_Out_Of_Core;
return NULL;
}
fdt.size = i;
{
free (fdt.fds);
if (status)
- *status = mk_error (File_Error);
+ *status = GPGME_File_Error;
return NULL;
}
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,
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);
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,
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;
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. */
if (!item)
{
free (tag);
- return mk_error (Out_Of_Core);
+ return GPGME_Out_Of_Core;
}
item->ctx = ctx;
item->dir = dir;