2008-02-09 Marcus Brinkmann <marcus@g10code.de>
[gnupg.git] / g10 / options.h
blobfac05b6ed8cf319a1ae205a74c73fe1e604430c8
1 /* options.h
2 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
3 * 2007 Free Software Foundation, Inc.
5 * This file is part of GnuPG.
7 * GnuPG 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 3 of the License, or
10 * (at your option) any later version.
12 * GnuPG 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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef G10_OPTIONS_H
21 #define G10_OPTIONS_H
23 #include <sys/types.h>
24 #include <types.h>
25 #include "main.h"
26 #include "packet.h"
28 #ifndef EXTERN_UNLESS_MAIN_MODULE
29 /* Norcraft can't cope with common symbols */
30 #if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
31 #define EXTERN_UNLESS_MAIN_MODULE extern
32 #else
33 #define EXTERN_UNLESS_MAIN_MODULE
34 #endif
35 #endif
37 EXTERN_UNLESS_MAIN_MODULE
38 struct
40 int verbose;
41 int quiet;
42 unsigned debug;
43 int armor;
44 char *outfile;
45 off_t max_output;
46 int dry_run;
47 int list_only;
48 int textmode;
49 int expert;
50 const char *def_sig_expire;
51 int ask_sig_expire;
52 const char *def_cert_expire;
53 int ask_cert_expire;
54 int batch; /* run in batch mode */
55 int answer_yes; /* answer yes on most questions */
56 int answer_no; /* answer no on most questions */
57 int check_sigs; /* check key signatures */
58 int with_colons;
59 int with_key_data;
60 int with_fingerprint; /* opt --with-fingerprint active */
61 int fingerprint; /* list fingerprints */
62 int list_sigs; /* list signatures */
63 int no_armor;
64 int list_packets; /* list-packets mode: 1=normal, 2=invoked by command*/
65 int def_cipher_algo;
66 int force_v3_sigs;
67 int force_v4_certs;
68 int force_mdc;
69 int disable_mdc;
70 int def_digest_algo;
71 int cert_digest_algo;
72 int compress_algo;
73 int compress_level;
74 int bz2_compress_level;
75 int bz2_decompress_lowmem;
76 const char *def_secret_key;
77 char *def_recipient;
78 int def_recipient_self;
79 int def_cert_level;
80 int min_cert_level;
81 int ask_cert_level;
82 int no_version;
83 int marginals_needed;
84 int completes_needed;
85 int max_cert_depth;
86 const char *homedir;
87 const char *agent_program;
88 char *display; /* 5 options to be passed to the gpg-agent */
89 char *ttyname;
90 char *ttytype;
91 char *lc_ctype;
92 char *lc_messages;
93 char *xauthority;
94 char *pinentry_user_data;
96 int skip_verify;
97 int compress_keys;
98 int compress_sigs;
99 /* TM_CLASSIC must be zero to accomodate trustdbs generated before
100 we started storing the trust model inside the trustdb. */
101 enum
103 TM_CLASSIC=0, TM_PGP=1, TM_EXTERNAL=2, TM_ALWAYS, TM_DIRECT, TM_AUTO
104 } trust_model;
105 int force_ownertrust;
106 enum
108 CO_GNUPG, CO_RFC4880, CO_RFC2440, CO_RFC1991, CO_PGP2,
109 CO_PGP6, CO_PGP7, CO_PGP8
110 } compliance;
111 enum
113 KF_SHORT, KF_LONG, KF_0xSHORT, KF_0xLONG
114 } keyid_format;
115 int pgp2_workarounds;
116 int shm_coprocess;
117 const char *set_filename;
118 strlist_t comments;
119 int throw_keyid;
120 const char *photo_viewer;
121 int s2k_mode;
122 int s2k_digest_algo;
123 int s2k_cipher_algo;
124 unsigned char s2k_count; /* This is the encoded form, not the raw
125 count */
126 int simple_sk_checksum; /* create the deprecated rfc2440 secret key
127 protection */
128 int not_dash_escaped;
129 int escape_from;
130 int lock_once;
131 struct keyserver_spec
133 char *uri;
134 char *scheme;
135 char *auth;
136 char *host;
137 char *port;
138 char *path;
139 char *opaque;
140 strlist_t options;
141 struct
143 unsigned int direct_uri:1;
144 } flags;
145 struct keyserver_spec *next;
146 } *keyserver;
147 struct
149 unsigned int options;
150 unsigned int import_options;
151 unsigned int export_options;
152 strlist_t other;
153 } keyserver_options;
154 int exec_disable;
155 int exec_path_set;
156 unsigned int import_options;
157 unsigned int export_options;
158 unsigned int list_options;
159 unsigned int verify_options;
160 const char *def_preference_list;
161 const char *def_keyserver_url;
162 prefitem_t *personal_cipher_prefs;
163 prefitem_t *personal_digest_prefs;
164 prefitem_t *personal_compress_prefs;
165 int no_perm_warn;
166 int no_mdc_warn;
167 char *temp_dir;
168 int no_encrypt_to;
169 int interactive;
170 struct notation *sig_notations;
171 struct notation *cert_notations;
172 strlist_t sig_policy_url;
173 strlist_t cert_policy_url;
174 strlist_t sig_keyserver_url;
175 strlist_t cert_subpackets;
176 strlist_t sig_subpackets;
177 int allow_non_selfsigned_uid;
178 int allow_freeform_uid;
179 int no_literal;
180 ulong set_filesize;
181 int fast_list_mode;
182 int fixed_list_mode;
183 int ignore_time_conflict;
184 int ignore_valid_from;
185 int ignore_crc_error;
186 int ignore_mdc_error;
187 int command_fd;
188 const char *override_session_key;
189 int show_session_key;
191 const char *gpg_agent_info;
192 int try_all_secrets;
193 int no_expensive_trust_checks;
194 int no_sig_cache;
195 int no_sig_create_check;
196 int no_auto_check_trustdb;
197 int preserve_permissions;
198 int no_homedir_creation;
199 struct groupitem *grouplist;
200 int mangle_dos_filenames;
201 int enable_progress_filter;
202 unsigned int screen_columns;
203 unsigned int screen_lines;
204 byte *show_subpackets;
205 int rfc2440_text;
207 /* If true, let write failures on the status-fd exit the process. */
208 int exit_on_status_write_error;
210 /* If > 0, limit the number of card insertion prompts to this
211 value. */
212 int limit_card_insert_tries;
214 #ifdef ENABLE_CARD_SUPPORT
215 /* FIXME: We don't needs this here as it is done in scdaemon. */
216 const char *ctapi_driver; /* Library to access the ctAPI. */
217 const char *pcsc_driver; /* Library to access the PC/SC system. */
218 int disable_ccid; /* Disable the use of the internal CCID driver. */
219 #endif /*ENABLE_CARD_SUPPORT*/
221 struct
223 /* If set, require an 0x19 backsig to be present on signatures
224 made by signing subkeys. If not set, a missing backsig is not
225 an error (but an invalid backsig still is). */
226 unsigned int require_cross_cert:1;
228 unsigned int use_embedded_filename:1;
229 unsigned int utf8_filename:1;
230 unsigned int dsa2:1;
231 unsigned int allow_multiple_messages:1;
232 } flags;
234 /* Linked list of ways to find a key if the key isn't on the local
235 keyring. */
236 struct akl
238 enum {AKL_CERT, AKL_PKA, AKL_LDAP, AKL_KEYSERVER, AKL_SPEC} type;
239 struct keyserver_spec *spec;
240 struct akl *next;
241 } *auto_key_locate;
243 int passwd_repeat;
244 } opt;
246 /* CTRL is used to keep some global variables we currently can't
247 avoid. Future concurrent versions of gpg will put it into a per
248 request structure CTRL. */
249 EXTERN_UNLESS_MAIN_MODULE
250 struct {
251 int in_auto_key_retrieve; /* True if we are doing an
252 auto_key_retrieve. */
253 } glo_ctrl;
255 #define DBG_PACKET_VALUE 1 /* debug packet reading/writing */
256 #define DBG_MPI_VALUE 2 /* debug mpi details */
257 #define DBG_CIPHER_VALUE 4 /* debug cipher handling */
258 /* (may reveal sensitive data) */
259 #define DBG_FILTER_VALUE 8 /* debug internal filter handling */
260 #define DBG_IOBUF_VALUE 16 /* debug iobuf stuff */
261 #define DBG_MEMORY_VALUE 32 /* debug memory allocation stuff */
262 #define DBG_CACHE_VALUE 64 /* debug the cacheing */
263 #define DBG_MEMSTAT_VALUE 128 /* show memory statistics */
264 #define DBG_TRUST_VALUE 256 /* debug the trustdb */
265 #define DBG_HASHING_VALUE 512 /* debug hashing operations */
266 #define DBG_EXTPROG_VALUE 1024 /* debug external program calls */
267 #define DBG_CARD_IO_VALUE 2048 /* debug smart card I/O. */
269 /* Fixme: For now alias this value. */
270 #define DBG_ASSUAN_VALUE DBG_EXTPROG_VALUE
273 /* Tests for the debugging flags. */
274 #define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
275 #define DBG_CIPHER (opt.debug & DBG_CIPHER_VALUE)
276 #define DBG_FILTER (opt.debug & DBG_FILTER_VALUE)
277 #define DBG_CACHE (opt.debug & DBG_CACHE_VALUE)
278 #define DBG_TRUST (opt.debug & DBG_TRUST_VALUE)
279 #define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
280 #define DBG_EXTPROG (opt.debug & DBG_EXTPROG_VALUE)
281 #define DBG_CARD_IO (opt.debug & DBG_CARD_IO_VALUE)
282 #define DBG_ASSUAN (opt.debug & DBG_ASSUAN_VALUE)
284 /* FIXME: We need to check whey we did not put this into opt. */
285 #define DBG_MEMORY memory_debug_mode
286 #define DBG_MEMSTAT memory_stat_debug_mode
288 EXTERN_UNLESS_MAIN_MODULE int memory_debug_mode;
289 EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
293 #define GNUPG (opt.compliance==CO_GNUPG)
294 #define RFC1991 (opt.compliance==CO_RFC1991 || opt.compliance==CO_PGP2)
295 #define RFC2440 (opt.compliance==CO_RFC2440)
296 #define RFC4880 (opt.compliance==CO_RFC4880)
297 #define PGP2 (opt.compliance==CO_PGP2)
298 #define PGP6 (opt.compliance==CO_PGP6)
299 #define PGP7 (opt.compliance==CO_PGP7)
300 #define PGP8 (opt.compliance==CO_PGP8)
301 #define PGPX (PGP2 || PGP6 || PGP7 || PGP8)
303 /* Various option flags. Note that there should be no common string
304 names between the IMPORT_ and EXPORT_ flags as they can be mixed in
305 the keyserver-options option. */
307 #define IMPORT_LOCAL_SIGS (1<<0)
308 #define IMPORT_REPAIR_PKS_SUBKEY_BUG (1<<1)
309 #define IMPORT_FAST (1<<2)
310 #define IMPORT_SK2PK (1<<3)
311 #define IMPORT_MERGE_ONLY (1<<4)
312 #define IMPORT_MINIMAL (1<<5)
313 #define IMPORT_CLEAN (1<<6)
315 #define EXPORT_LOCAL_SIGS (1<<0)
316 #define EXPORT_ATTRIBUTES (1<<1)
317 #define EXPORT_SENSITIVE_REVKEYS (1<<2)
318 #define EXPORT_RESET_SUBKEY_PASSWD (1<<3)
319 #define EXPORT_MINIMAL (1<<4)
320 #define EXPORT_CLEAN (1<<5)
321 #define EXPORT_SEXP_FORMAT (1<<6)
323 #define LIST_SHOW_PHOTOS (1<<0)
324 #define LIST_SHOW_POLICY_URLS (1<<1)
325 #define LIST_SHOW_STD_NOTATIONS (1<<2)
326 #define LIST_SHOW_USER_NOTATIONS (1<<3)
327 #define LIST_SHOW_NOTATIONS (LIST_SHOW_STD_NOTATIONS|LIST_SHOW_USER_NOTATIONS)
328 #define LIST_SHOW_KEYSERVER_URLS (1<<4)
329 #define LIST_SHOW_UID_VALIDITY (1<<5)
330 #define LIST_SHOW_UNUSABLE_UIDS (1<<6)
331 #define LIST_SHOW_UNUSABLE_SUBKEYS (1<<7)
332 #define LIST_SHOW_KEYRING (1<<8)
333 #define LIST_SHOW_SIG_EXPIRE (1<<9)
334 #define LIST_SHOW_SIG_SUBPACKETS (1<<10)
336 #define VERIFY_SHOW_PHOTOS (1<<0)
337 #define VERIFY_SHOW_POLICY_URLS (1<<1)
338 #define VERIFY_SHOW_STD_NOTATIONS (1<<2)
339 #define VERIFY_SHOW_USER_NOTATIONS (1<<3)
340 #define VERIFY_SHOW_NOTATIONS (VERIFY_SHOW_STD_NOTATIONS|VERIFY_SHOW_USER_NOTATIONS)
341 #define VERIFY_SHOW_KEYSERVER_URLS (1<<4)
342 #define VERIFY_SHOW_UID_VALIDITY (1<<5)
343 #define VERIFY_SHOW_UNUSABLE_UIDS (1<<6)
344 #define VERIFY_PKA_LOOKUPS (1<<7)
345 #define VERIFY_PKA_TRUST_INCREASE (1<<8)
346 #define VERIFY_SHOW_PRIMARY_UID_ONLY (1<<9)
348 #define KEYSERVER_USE_TEMP_FILES (1<<0)
349 #define KEYSERVER_KEEP_TEMP_FILES (1<<1)
350 #define KEYSERVER_ADD_FAKE_V3 (1<<2)
351 #define KEYSERVER_AUTO_KEY_RETRIEVE (1<<3)
352 #define KEYSERVER_HONOR_KEYSERVER_URL (1<<4)
353 #define KEYSERVER_HONOR_PKA_RECORD (1<<5)
355 #endif /*G10_OPTIONS_H*/