* gpg.texi (GPG Esoteric Options): Tweak mention of Tempest font to
[gnupg.git] / keyserver / ksutil.h
blob3068592e877d85ca386e53f9f3c1254b76a829dd
1 /* ksutil.h
2 * Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG 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 3 of the License, or
9 * (at your option) any later version.
11 * GnuPG 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, see <http://www.gnu.org/licenses/>.
19 * In addition, as a special exception, the Free Software Foundation
20 * gives permission to link the code of the keyserver helper tools:
21 * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL
22 * project's "OpenSSL" library (or with modified versions of it that
23 * use the same license as the "OpenSSL" library), and distribute the
24 * linked executables. You must obey the GNU General Public License
25 * in all respects for all of the code used other than "OpenSSL". If
26 * you modify this file, you may extend this exception to your version
27 * of the file, but you are not obligated to do so. If you do not
28 * wish to do so, delete this exception statement from your version.
31 #ifndef _KSUTIL_H_
32 #define _KSUTIL_H_
34 #ifdef HAVE_LIBCURL
35 #include <curl/curl.h>
36 #else
37 #include "curl-shim.h"
38 #endif
40 /* MAX_LINE must be at least 1 larger than the largest item we expect
41 to receive, including the name tag ("COMMAND", "PORT", etc) and
42 space between. In practice, that means it should be
43 strlen("OPAQUE")+1+sizeof_opaque+1 */
44 #define MAX_LINE (6+1+1024+1)
46 #define MAX_COMMAND 7
47 #define MAX_OPTION 256
48 #define MAX_SCHEME 20
49 #define MAX_OPAQUE 1024
50 #define MAX_AUTH 128
51 #define MAX_HOST 80
52 #define MAX_PORT 10
53 #define URLMAX_PATH 1024
54 #define MAX_PROXY 128
55 #define MAX_URL (MAX_SCHEME+1+3+MAX_AUTH+1+1+MAX_HOST+1+1 \
56 +MAX_PORT+1+1+URLMAX_PATH+1+50)
58 #define STRINGIFY(x) #x
59 #define MKSTRING(x) STRINGIFY(x)
61 #define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----"
62 #define END "-----END PGP PUBLIC KEY BLOCK-----"
64 #ifdef __riscos__
65 #define HTTP_PROXY_ENV "GnuPG$HttpProxy"
66 #else
67 #define HTTP_PROXY_ENV "http_proxy"
68 #endif
70 struct keylist
72 char str[MAX_LINE];
73 struct keylist *next;
76 /* 2 minutes seems reasonable */
77 #define DEFAULT_KEYSERVER_TIMEOUT 120
79 unsigned int set_timeout(unsigned int seconds);
80 int register_timeout(void);
82 enum ks_action {KS_UNKNOWN=0,KS_GET,KS_GETNAME,KS_SEND,KS_SEARCH};
84 enum ks_search_type {KS_SEARCH_SUBSTR,KS_SEARCH_EXACT,
85 KS_SEARCH_MAIL,KS_SEARCH_MAILSUB,
86 KS_SEARCH_KEYID_LONG,KS_SEARCH_KEYID_SHORT};
88 struct ks_options
90 enum ks_action action;
91 char *host;
92 char *port;
93 char *scheme;
94 char *auth;
95 char *path;
96 char *opaque;
97 struct
99 unsigned int include_disabled:1;
100 unsigned int include_revoked:1;
101 unsigned int include_subkeys:1;
102 unsigned int check_cert:1;
103 } flags;
104 unsigned int verbose;
105 unsigned int debug;
106 unsigned int timeout;
107 char *ca_cert_file;
110 struct ks_options *init_ks_options(void);
111 void free_ks_options(struct ks_options *opt);
112 int parse_ks_options(char *line,struct ks_options *opt);
113 const char *ks_action_to_string(enum ks_action action);
114 void print_nocr(FILE *stream,const char *str);
115 enum ks_search_type classify_ks_search(const char **search);
117 int curl_err_to_gpg_err(CURLcode error);
119 struct curl_writer_ctx
121 struct
123 unsigned int initialized:1;
124 unsigned int begun:1;
125 unsigned int done:1;
126 unsigned int armor:1;
127 } flags;
129 int armor_remaining;
130 unsigned char armor_ctx[3];
131 int markeridx,linelen;
132 const char *marker;
133 FILE *stream;
136 size_t curl_writer(const void *ptr,size_t size,size_t nmemb,void *cw_ctx);
137 void curl_writer_finalize(struct curl_writer_ctx *ctx);
139 int ks_hextobyte (const char *s);
140 int ks_toupper (int c);
141 int ks_strcasecmp (const char *a, const char *b);
144 #endif /* !_KSUTIL_H_ */