2006-09-06 Marcus Brinkmann <marcus@g10code.de>
[gnupg.git] / common / simple-pwquery.h
blob5b941d06fe6887b7c3f9c067e244b0d026c1b6d6
1 /* simple-pwquery.c - A simple password query cleint for gpg-agent
2 * Copyright (C) 2002 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 * USA.
22 #ifndef SIMPLE_PWQUERY_H
23 #define SIMPLE_PWQUERY_H
25 #ifdef SIMPLE_PWQUERY_IMPLEMENTATION /* Begin configuration stuff. */
27 /* Include whatever files you need. */
28 #include <gcrypt.h>
29 #include "../jnlib/logging.h"
31 /* Try to write error message using the standard log mechanism. The
32 current implementation requires that the HAVE_JNLIB_LOGGING is also
33 defined. */
34 #define SPWQ_USE_LOGGING 1
36 /* Memory allocation functions used by the implementation. Note, that
37 the returned value is expected to be freed with
38 spwq_secure_free. */
39 #define spwq_malloc(a) gcry_malloc (a)
40 #define spwq_free(a) gcry_free (a)
41 #define spwq_secure_malloc(a) gcry_malloc_secure (a)
42 #define spwq_secure_free(a) gcry_free (a)
45 #endif /*SIMPLE_PWQUERY_IMPLEMENTATION*/ /* End configuration stuff. */
48 /* Ask the gpg-agent for a passphrase and present the user with a
49 DESCRIPTION, a PROMPT and optiaonlly with a TRYAGAIN extra text.
50 If a CACHEID is not NULL it is used to locate the passphrase in in
51 the cache and store it under this ID. If ERRORCODE is not NULL it
52 should point a variable receiving an errorcode; this errocode might
53 be 0 if the user canceled the operation. The function returns NULL
54 to indicate an error. */
55 char *simple_pwquery (const char *cacheid,
56 const char *tryagain,
57 const char *prompt,
58 const char *description,
59 int *errorcode);
61 /* Ask the gpg-agent to clear the passphrase for the cache ID CACHEID. */
62 int simple_pwclear (const char *cacheid);
64 /* Perform the simple query QUERY (which must be new-line and 0
65 terminated) and return the error code. */
66 int simple_query (const char *query);
68 #define SPWQ_OUT_OF_CORE 1
69 #define SPWQ_IO_ERROR 2
70 #define SPWQ_PROTOCOL_ERROR 3
71 #define SPWQ_ERR_RESPONSE 4
72 #define SPWQ_NO_AGENT 5
73 #define SPWQ_SYS_ERROR 6
74 #define SPWQ_GENERAL_ERROR 7
76 #endif /*SIMPLE_PWQUERY_H*/