/[winpt]/trunk/MyGPGME/context.h
ViewVC logotype

Annotation of /trunk/MyGPGME/context.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (hide annotations)
Mon Apr 4 07:01:43 2005 UTC (19 years, 10 months ago) by twoaday
File MIME type: text/plain
File size: 9611 byte(s)
2005-03-22  Timo Schulz  <twoaday@freakmail.de>
                                                                                
        * editcard.c: Support new status-fd entries SC_OP_SUCCESS
        and SC_OP_FAILURE.
        * editkey.c (cmd_addrev_handler): Check if context != NULL.
        * import.c (import_command_handler): Wrong function signature.
        Noted by Kurt Fitzner.
        * types.h: Fixed encrypt_result_s. Noted by Kurt.
        * gpgme.h (gpgme_editkey_addrev_set): Changed return type.
        Kudos to Kurt.
        * key.c: Removed some unreachable code. By Kurt.
                                                                                


1 twoaday 2 /* context.h
2     * Copyright (C) 2000 Werner Koch (dd9jn)
3     * Copyright (C) 2002, 2003, 2004 Timo Schulz
4     *
5     * This file is part of MyGPGME.
6     *
7     * MyGPGME is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * MyGPGME is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20     */
21    
22     #ifndef CONTEXT_H
23     #define CONTEXT_H
24    
25     #include "gpgme.h"
26     #include "types.h"
27     #include "rungpg.h" /* for _gpg_object_t */
28     #include "common-status.h"
29    
30     typedef enum {
31     RESULT_TYPE_NONE = 0,
32     RESULT_TYPE_VERIFY,
33     RESULT_TYPE_DECRYPT,
34     RESULT_TYPE_SIGN,
35     RESULT_TYPE_SIGN_ENCRYPT,
36     RESULT_TYPE_IMPORT,
37     RESULT_TYPE_ENCRYPT,
38     RESULT_TYPE_SYMENC,
39     RESULT_TYPE_EDITKEY,
40     } result_type_t;
41    
42    
43     struct key_queue_item_s {
44     struct key_queue_item_s *next;
45     gpgme_key_t key;
46     };
47    
48    
49     /* Currently we need it at several places, so we put the definition
50     * into this header file
51     */
52     struct gpgme_context_s {
53     int initialized;
54     int pending; /* a gpg request is still pending */
55    
56     /* at some points we need to allocate memory but we are not
57     * able to handle a malloc problem at that point, so we set this
58     * flag to indicate this condition */
59     int out_of_core;
60     int cancel; /* cancel operation request */
61    
62     _gpg_object_t gpg; /* the running gpg process */
63    
64     unsigned int use_throwkeyid:1; /* anonymous packets (without keyids) */
65     unsigned int use_armor:1;
66     unsigned int use_textmode:1;
67     unsigned int use_file:1;
68     unsigned int use_tmpfiles:1;
69     unsigned int use_pass_fd:1;
70     unsigned int use_logging:1;
71     unsigned int interactive:1;
72     unsigned int pipemode:1;
73    
74     int keylist_mode;
75     int list_opts;
76    
77     unsigned int force_trust:1; /* force to --always-trust */
78     unsigned int force_opt:1; /* some special options */
79     unsigned int force_mdc:1;
80    
81     int problem;
82     gpgme_wipe_t wipe_fnc;
83     unsigned int with_secret_key:1; /* for --export */
84    
85     int signers_size; /* size of the following array */
86     gpgme_key_t * signers;
87    
88     result_type_t result_type;
89     union {
90     _verify_result_t verify;
91     _decrypt_result_t decrypt;
92     _sign_result_t sign;
93     _import_result_t import;
94     _sign_encrypt_result_t sign_enc;
95     _encrypt_result_t encrypt;
96     _symenc_result_t symenc;
97     _editkey_result_t editk;
98     } result;
99    
100     gpgme_data_t notation; /* last signature notation */
101     gpgme_data_t logging;
102    
103     gpgme_key_t tmp_key; /* used by keylist.c */
104     int tmp_i;
105     char * tmp_id;
106     char tmp_keyid[16+1];
107    
108     void * tmp_res;
109    
110     volatile int key_cond; /* something new is available */
111     struct key_queue_item_s * key_queue;
112     struct trust_queue_item_s * trust_queue;
113    
114     const char * passphrase_value;
115    
116     struct {
117     gpgme_passphrase_cb_t passphrase;
118     void * passphrase_value;
119    
120     gpgme_progress_cb_t progress;
121     void * progress_value;
122     int progress_value_int;
123     int progess_tmp;
124    
125     gpgme_interactive_cb_t interactiv;
126     void * interactiv_value;
127     } cb;
128    
129     /* interface for --card-edit and --edit-key */
130     void * edit_opaque;
131     int edit_cmd;
132    
133     gpgme_card_t card;
134    
135     void * key_lookup;
136    
137     gpgme_data_t help_data_1;
138    
139     int cipher_algo;
140     struct {
141     int digest_algo;
142     int mode;
143     unsigned used:1;
144     } s2k;
145    
146     gpgme_recipients_t enc_to;
147    
148     char * locusr;
149    
150     char * keygen_fpr;
151    
152     char * comment;
153    
154 twoaday 7 char * homedir;
155    
156 twoaday 2 int no_compress;
157     unsigned long proc_rc;
158     };
159    
160    
161     struct gpgme_data_s {
162     size_t len;
163     const char *data;
164     gpgme_data_type_t type;
165     gpgme_data_mode_t mode;
166    
167     int (*read_cb)( void *, char *, size_t, size_t *);
168     void *read_cb_value;
169     int read_cb_eof;
170    
171     size_t readpos;
172     size_t writepos;
173     size_t private_len;
174     char *private_buffer;
175     };
176    
177     struct user_id_flag_s {
178     unsigned int revoked:1;
179     unsigned int invalid:1;
180     unsigned int primary:1;
181     unsigned mdc:1;
182     unsigned no_ks_modify:1;
183     };
184    
185     struct user_id_s {
186     struct user_id_s *next;
187     struct user_id_flag_s flags;
188     gpgme_validity_t validity;
189     unsigned long created;
190     char * hash;
191     const char * name_part; /* all 3 point into strings behind name */
192     const char * email_part; /* or to read-only strings */
193     const char * comment_part;
194     char name[1];
195     };
196    
197     struct gpgme_recipients_s {
198     struct user_id_s * list;
199     int checked; /* wether the recipients are all valid */
200     int count;
201     };
202    
203     struct user_id_info_s {
204     struct user_id_info_s *next;
205     struct user_id_flag_s flags;
206     int validity;
207     char * name;
208     char * prefs;
209     int idx;
210     };
211    
212     struct gpgme_user_id_info_s {
213     struct user_id_info_s * list;
214     };
215    
216    
217     struct keycache_s {
218     struct keycache_s * next;
219     int flags;
220     gpgme_key_t key;
221     gpgme_key_t pubpart;
222     };
223    
224     struct gpgme_keycache_s {
225     struct keycache_s * item;
226     struct keycache_s * tmp;
227     int secret;
228     int pos;
229     void (*cb) (void *, const char *, int, unsigned, unsigned);
230     void * cb_value;
231     int cb_value2;
232     };
233    
234     struct gpgme_signature_s {
235     struct gpgme_signature_s * next;
236     int ref_count;
237     gpgme_key_t key;
238     gpgme_sigstat_t sigstat;
239     ulong created;
240     ulong expired;
241     gpgme_pk_cipher_t key_algo;
242     gpgme_md_t md_algo;
243 twoaday 7 int sigclass;
244 twoaday 2 int trust;
245     char id[41];
246     char * notation;
247     char * user_id;
248     char * policy_url;
249     char * file_name;
250     char * key_server;
251     struct {
252     unsigned expired:1;
253     } flags;
254     };
255    
256     struct gpgme_editcard_s {
257     union {
258     struct {
259     const char * surname;
260     const char * givenname;
261     const char * keyurl;
262     const char * login;
263     const char * lang;
264     char sex;
265     } edit;
266     struct {
267     const char * pinold;
268     const char * pinnew;
269     } pin;
270     } u;
271     struct {
272     char * name;
273     char * email;
274     char * comment;
275     char * expdate;
276     const char * passwd;
277     int flags;
278     } keygen;
279     const char * apin;
280     const char * upin;
281     int type;
282     int cnt;
283     int cancel;
284     const char *(*card_cb) (int code, void * opaque);
285     void * cb_value;
286     };
287    
288    
289     struct gpgme_card_s {
290     char * aid;
291     char * version;
292 twoaday 7 char ver[6];
293 twoaday 2 char * vendor;
294     char * serial;
295     char * surname;
296     char * givenname;
297     char * lang;
298     char sex;
299     char * url;
300     char * login;
301     int force_pin;
302     char * maxpinlen[3];
303     int sig_count;
304     char * fpr[3];
305     };
306    
307     struct gpgme_editkey_s {
308     int key_pair;
309     int type;
310    
311     union {
312     struct {
313     const char * trust_val;
314     } trust;
315     struct {
316     int sig_class;
317     int sig_type;
318     struct {
319     const char * val;
320     const char * depth;
321     const char * regexp;
322     } trust;
323     const char * exp_date;
324     const char * passwd;
325     } sign;
326     struct {
327     char * name;
328     char * email;
329     char * comment;
330     int use_comment;
331     const char * passwd;
332     } adduid;
333     struct {
334     const char * uid;
335     const char * passwd;
336     } addrev;
337     struct {
338     const char * jpg;
339     const char * passwd;
340     } addphoto;
341     struct {
342     int id;
343     } deluid;
344     struct {
345     int id;
346     } delkey;
347     struct {
348     int algo;
349     int size;
350     int valid;
351     const char * passwd;
352     } addkey;
353     struct {
354     const char * old_passwd;
355     const char * new_passwd;
356     int send_old;
357     int allow_empty;
358     } passwd;
359     struct {
360     const char * uid;
361     const char * reason_id;
362     char * reason_text;
363     int reason_sent;
364     const char * passwd;
365     unsigned int pgp:1;
366     } revoke;
367     struct {
368     int id;
369     const char * passwd;
370     } primary;
371     struct {
372     int id;
373     int days;
374     const char * date;
375     const char * passwd;
376     } expire;
377     struct {
378     int id;
379     const char * passwd;
380     } revsig;
381     struct {
382     int id;
383     int reason;
384     const char * passwd;
385     } revkey;
386     struct {
387     const char * new_prefs;
388     const char * passwd;
389     int uid_idx;
390     int id;
391     } pref;
392     struct {
393     int uid;
394     int signo;
395     int currno;
396     } delsig;
397     struct {
398     const char * passwd;
399     const char * url;
400     } keyserv;
401     } u;
402     };
403    
404     struct gpgme_rev_cert_s {
405     long timestamp;
406     char keyid[16+1];
407     char *reason;
408     unsigned char code;
409     };
410    
411     #define fail_on_pending_request(c) \
412     do { \
413     if (!(c)) return GPGME_Invalid_Value; \
414     if ((c)->pending) return GPGME_Busy; \
415     } while (0)
416    
417     #define wait_on_request_or_fail(c) \
418     do { \
419     if (!(c)) return GPGME_Invalid_Value;\
420     if (!(c)->pending) return GPGME_No_Request; \
421     gpgme_wait ((c), 1); \
422     } while (0)
423    
424    
425    
426     #endif /* CONTEXT_H */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26