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

Contents of /trunk/MyGPGME/context.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (show annotations)
Fri Sep 30 10:10:16 2005 UTC (19 years, 5 months ago) by twoaday
File MIME type: text/plain
File size: 9659 byte(s)
Almost finished phase 1 of the WinPT GPGME port.
Still need more cleanup, comments and tests.


1 /* context.h
2 * Copyright (C) 2000 Werner Koch (dd9jn)
3 * Copyright (C) 2002, 2003, 2004, 2005 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 use_interactive:1;
72 unsigned int use_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 void * tmp_res;
108
109 volatile int key_cond; /* something new is available */
110 struct key_queue_item_s * key_queue;
111 struct trust_queue_item_s * trust_queue;
112
113 const char * passphrase_value;
114
115 struct {
116 gpgme_passphrase_cb_t passphrase;
117 void * passphrase_value;
118
119 gpgme_progress_cb_t progress;
120 void * progress_value;
121 int progress_value_int;
122 int progess_tmp;
123
124 gpgme_interactive_cb_t interactiv;
125 void * interactiv_value;
126 } cb;
127
128 /* interface for --card-edit and --edit-key */
129 void * edit_opaque;
130 int edit_cmd;
131
132 gpgme_card_t card;
133
134 void * key_lookup;
135
136 gpgme_data_t help_data_1;
137
138 int cipher_algo;
139 struct {
140 int digest_algo;
141 int mode;
142 unsigned used:1;
143 } s2k;
144
145 gpgme_recipients_t enc_to;
146
147 char * locusr;
148
149 char * keygen_fpr;
150
151 char * comment;
152
153 char * homedir;
154
155 int no_compress;
156
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 *email;
209 char *prefs;
210 int idx;
211 };
212
213 struct gpgme_user_id_info_s {
214 struct user_id_info_s * list;
215 };
216
217
218 struct keycache_s {
219 struct keycache_s * next;
220 int flags;
221 gpgme_key_t key;
222 gpgme_key_t pubpart;
223 };
224
225 struct gpgme_keycache_s {
226 struct keycache_s * item;
227 struct keycache_s * tmp;
228 int secret;
229 int pos;
230 void (*cb) (void *, const char *, int, unsigned, unsigned);
231 void * cb_value;
232 int cb_value2;
233 };
234
235 struct gpgme_signature_s {
236 struct gpgme_signature_s * next;
237 int ref_count;
238 gpgme_key_t key;
239 gpgme_sigstat_t sigstat;
240 ulong created;
241 ulong expired;
242 gpgme_pk_cipher_t key_algo;
243 gpgme_md_t md_algo;
244 int sigclass;
245 int trust;
246 char id[41];
247 char * notation;
248 char * user_id;
249 char * policy_url;
250 char * file_name;
251 char * key_server;
252 struct {
253 unsigned expired:1;
254 } flags;
255 };
256
257 struct gpgme_editcard_s {
258 union {
259 struct {
260 const char * surname;
261 const char * givenname;
262 const char * keyurl;
263 const char * login;
264 const char * lang;
265 char sex;
266 } edit;
267 struct {
268 const char * pinold;
269 const char * pinnew;
270 } pin;
271 } u;
272 struct {
273 char * name;
274 char * email;
275 char * comment;
276 char * expdate;
277 const char * passwd;
278 int flags;
279 } keygen;
280 const char * apin;
281 const char * upin;
282 int type;
283 int cnt;
284 int cancel;
285 const char *(*card_cb) (int code, void * opaque);
286 void * cb_value;
287 };
288
289
290 struct gpgme_card_s {
291 char * aid;
292 char * version;
293 char ver[6];
294 char * vendor;
295 char * serial;
296 char * surname;
297 char * givenname;
298 char * lang;
299 char sex;
300 char * url;
301 char * login;
302 int force_pin;
303 char * maxpinlen[3];
304 int sig_count;
305 char * fpr[3];
306 };
307
308 struct gpgme_editkey_s {
309 int key_pair;
310 int type;
311
312 union {
313 struct {
314 const char * trust_val;
315 } trust;
316 struct {
317 int sig_class;
318 int sig_type;
319 struct {
320 const char * val;
321 const char * depth;
322 const char * regexp;
323 } trust;
324 const char * exp_date;
325 const char * passwd;
326 } sign;
327 struct {
328 char * name;
329 char * email;
330 char * comment;
331 int use_comment;
332 const char * passwd;
333 } adduid;
334 struct {
335 const char * uid;
336 const char * passwd;
337 } addrev;
338 struct {
339 const char * jpg;
340 const char * passwd;
341 } addphoto;
342 struct {
343 int id;
344 } deluid;
345 struct {
346 int id;
347 } delkey;
348 struct {
349 int algo;
350 int size;
351 int valid;
352 const char * passwd;
353 } addkey;
354 struct {
355 const char * old_passwd;
356 const char * new_passwd;
357 int send_old;
358 int allow_empty;
359 } passwd;
360 struct {
361 const char * uid;
362 const char * reason_id;
363 char * reason_text;
364 int reason_sent;
365 const char * passwd;
366 unsigned int pgp:1;
367 } revoke;
368 struct {
369 int id;
370 const char * passwd;
371 } primary;
372 struct {
373 int id;
374 int days;
375 const char * date;
376 const char * passwd;
377 } expire;
378 struct {
379 int id;
380 const char * passwd;
381 } revsig;
382 struct {
383 int id;
384 int reason;
385 const char * passwd;
386 } revkey;
387 struct {
388 const char * new_prefs;
389 const char * passwd;
390 int uid_idx;
391 int id;
392 } pref;
393 struct {
394 int uid;
395 int signo;
396 int currno;
397 } delsig;
398 struct {
399 int uid_idx;
400 const char * passwd;
401 const char * url;
402 } keyserv;
403 } u;
404 };
405
406 struct gpgme_rev_cert_s {
407 long timestamp;
408 char keyid[16+1];
409 char *reason;
410 unsigned char code;
411 };
412
413 #define fail_on_pending_request(c) \
414 do { \
415 if (!(c)) return GPGME_Invalid_Value; \
416 if ((c)->pending) return GPGME_Busy; \
417 } while (0)
418
419 #define wait_on_request_or_fail(c) \
420 do { \
421 if (!(c)) return GPGME_Invalid_Value;\
422 if (!(c)->pending) return GPGME_No_Request; \
423 gpgme_wait ((c), 1); \
424 } while (0)
425
426
427
428 #endif /* CONTEXT_H */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26