1 /* gpgme.c - GnuPG Made Easy
2 * Copyright (C) 2000 Werner Koch (dd9jn)
4 * This file is part of GPGME.
6 * GPGME 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 * GPGME 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
29 #define my_isdigit(a) ( (a) >='0' && (a) <= '9' )
30 #define my_isxdigit(a) ( my_isdigit((a)) \
31 || ((a) >= 'A' && (a) <= 'F') \
32 || ((a) >= 'f' && (a) <= 'f') )
36 * @r_ctx: Returns the new context
38 * Create a new context to be used with most of the other GPGME
39 * functions. Use gpgme_release_contect() to release all resources
41 * Return value: An error code
44 gpgme_new (GpgmeCtx *r_ctx)
48 c = xtrycalloc ( 1, sizeof *c );
50 return mk_error (Out_Of_Core);
52 c->use_armor = 1; /* fixme: reset this to 0 */
59 * @c: Context to be released.
61 * Release all resources associated with the given context.
64 gpgme_release ( GpgmeCtx c )
67 _gpgme_gpg_release ( c->gpg );
68 _gpgme_release_result ( c );
69 _gpgme_key_release ( c->tmp_key );
70 gpgme_data_release ( c->notation );
71 /* fixme: release the key_queue */
77 _gpgme_release_result ( GpgmeCtx c )
79 switch (c->result_type) {
80 case RESULT_TYPE_NONE:
82 case RESULT_TYPE_VERIFY:
83 _gpgme_release_verify_result ( c->result.verify );
85 case RESULT_TYPE_DECRYPT:
86 _gpgme_release_decrypt_result ( c->result.decrypt );
88 case RESULT_TYPE_SIGN:
89 _gpgme_release_sign_result ( c->result.sign );
93 c->result.verify = NULL;
94 c->result_type = RESULT_TYPE_NONE;
102 * If there is notation data available from the last signature check, this
103 * function may be used to return this notation data as a string. The string
104 * is an XML represantaton of that data embedded in a %<notation> container.
106 * Return value: An XML string or NULL if no notation data is available.
109 gpgme_get_notation ( GpgmeCtx c )
113 return _gpgme_data_get_as_string ( c->notation );
120 * @yes: boolean value to set or clear that flag
122 * Enable or disable the use of an ascii armor for all output.
125 gpgme_set_armor ( GpgmeCtx c, int yes )
133 * gpgme_set_textmode:
135 * @yes: boolean flag whether textmode should be enabled
137 * Enable or disable the use of the special textmode. Textmode is for example
138 * used for MIME (RFC2015) signatures
141 gpgme_set_textmode ( GpgmeCtx c, int yes )
145 c->use_textmode = yes;
150 gpgme_set_passphrase_cb ( GpgmeCtx c, GpgmePassphraseCb fnc, void *fncval )
153 c->passphrase_cb = fnc;
154 c->passphrase_cb_value = fncval;