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

Annotation of /trunk/MyGPGME/context.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations)
Mon Jan 31 11:02:21 2005 UTC (20 years, 1 month ago) by twoaday
File MIME type: text/plain
File size: 9567 byte(s)
WinPT initial checkin.


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     int no_compress;
155     unsigned long proc_rc;
156     };
157    
158    
159     struct gpgme_data_s {
160     size_t len;
161     const char *data;
162     gpgme_data_type_t type;
163     gpgme_data_mode_t mode;
164    
165     int (*read_cb)( void *, char *, size_t, size_t *);
166     void *read_cb_value;
167     int read_cb_eof;
168    
169     size_t readpos;
170     size_t writepos;
171     size_t private_len;
172     char *private_buffer;
173     };
174    
175     struct user_id_flag_s {
176     unsigned int revoked:1;
177     unsigned int invalid:1;
178     unsigned int primary:1;
179     unsigned mdc:1;
180     unsigned no_ks_modify:1;
181     };
182    
183     struct user_id_s {
184     struct user_id_s *next;
185     struct user_id_flag_s flags;
186     gpgme_validity_t validity;
187     unsigned long created;
188     char * hash;
189     const char * name_part; /* all 3 point into strings behind name */
190     const char * email_part; /* or to read-only strings */
191     const char * comment_part;
192     char name[1];
193     };
194    
195     struct gpgme_recipients_s {
196     struct user_id_s * list;
197     int checked; /* wether the recipients are all valid */
198     int count;
199     };
200    
201     struct user_id_info_s {
202     struct user_id_info_s *next;
203     struct user_id_flag_s flags;
204     int validity;
205     char * name;
206     char * prefs;
207     int idx;
208     };
209    
210     struct gpgme_user_id_info_s {
211     struct user_id_info_s * list;
212     };
213    
214    
215     struct keycache_s {
216     struct keycache_s * next;
217     int flags;
218     gpgme_key_t key;
219     gpgme_key_t pubpart;
220     };
221    
222     struct gpgme_keycache_s {
223     struct keycache_s * item;
224     struct keycache_s * tmp;
225     int secret;
226     int pos;
227     void (*cb) (void *, const char *, int, unsigned, unsigned);
228     void * cb_value;
229     int cb_value2;
230     };
231    
232     struct gpgme_signature_s {
233     struct gpgme_signature_s * next;
234     int ref_count;
235     gpgme_key_t key;
236     gpgme_sigstat_t sigstat;
237     ulong created;
238     ulong expired;
239     gpgme_pk_cipher_t key_algo;
240     gpgme_md_t md_algo;
241     int class;
242     int trust;
243     char id[41];
244     char * notation;
245     char * user_id;
246     char * policy_url;
247     char * file_name;
248     char * key_server;
249     struct {
250     unsigned expired:1;
251     } flags;
252     };
253    
254     struct gpgme_editcard_s {
255     union {
256     struct {
257     const char * surname;
258     const char * givenname;
259     const char * keyurl;
260     const char * login;
261     const char * lang;
262     char sex;
263     } edit;
264     struct {
265     const char * pinold;
266     const char * pinnew;
267     } pin;
268     } u;
269     struct {
270     char * name;
271     char * email;
272     char * comment;
273     char * expdate;
274     const char * passwd;
275     int flags;
276     } keygen;
277     const char * apin;
278     const char * upin;
279     int type;
280     int cnt;
281     int cancel;
282     const char *(*card_cb) (int code, void * opaque);
283     void * cb_value;
284     };
285    
286    
287     struct gpgme_card_s {
288     char * aid;
289     char * version;
290     char * vendor;
291     char * serial;
292     char * surname;
293     char * givenname;
294     char * lang;
295     char sex;
296     char * url;
297     char * login;
298     int force_pin;
299     char * maxpinlen[3];
300     int sig_count;
301     char * fpr[3];
302     };
303    
304     struct gpgme_editkey_s {
305     int key_pair;
306     int type;
307    
308     union {
309     struct {
310     const char * trust_val;
311     } trust;
312     struct {
313     int sig_class;
314     int sig_type;
315     struct {
316     const char * val;
317     const char * depth;
318     const char * regexp;
319     } trust;
320     const char * exp_date;
321     const char * passwd;
322     } sign;
323     struct {
324     char * name;
325     char * email;
326     char * comment;
327     int use_comment;
328     const char * passwd;
329     } adduid;
330     struct {
331     const char * uid;
332     const char * passwd;
333     } addrev;
334     struct {
335     const char * jpg;
336     const char * passwd;
337     } addphoto;
338     struct {
339     int id;
340     } deluid;
341     struct {
342     int id;
343     } delkey;
344     struct {
345     int algo;
346     int size;
347     int valid;
348     const char * passwd;
349     } addkey;
350     struct {
351     const char * old_passwd;
352     const char * new_passwd;
353     int send_old;
354     int allow_empty;
355     } passwd;
356     struct {
357     const char * uid;
358     const char * reason_id;
359     char * reason_text;
360     int reason_sent;
361     const char * passwd;
362     unsigned int pgp:1;
363     } revoke;
364     struct {
365     int id;
366     const char * passwd;
367     } primary;
368     struct {
369     int id;
370     int days;
371     const char * date;
372     const char * passwd;
373     } expire;
374     struct {
375     int id;
376     const char * passwd;
377     } revsig;
378     struct {
379     int id;
380     int reason;
381     const char * passwd;
382     } revkey;
383     struct {
384     const char * new_prefs;
385     const char * passwd;
386     int uid_idx;
387     int id;
388     } pref;
389     struct {
390     int uid;
391     int signo;
392     int currno;
393     } delsig;
394     struct {
395     const char * passwd;
396     const char * url;
397     } keyserv;
398     } u;
399     };
400    
401     struct gpgme_rev_cert_s {
402     long timestamp;
403     char keyid[16+1];
404     char *reason;
405     unsigned char code;
406     };
407    
408     #define fail_on_pending_request(c) \
409     do { \
410     if (!(c)) return GPGME_Invalid_Value; \
411     if ((c)->pending) return GPGME_Busy; \
412     } while (0)
413    
414     #define wait_on_request_or_fail(c) \
415     do { \
416     if (!(c)) return GPGME_Invalid_Value;\
417     if (!(c)->pending) return GPGME_No_Request; \
418     gpgme_wait ((c), 1); \
419     } while (0)
420    
421    
422    
423     #endif /* CONTEXT_H */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26