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.
35 #include <curl/curl.h>
37 #include "curl-shim.h"
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)
47 #define MAX_OPTION 256
49 #define MAX_OPAQUE 1024
53 #define URLMAX_PATH 1024
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-----"
65 #define HTTP_PROXY_ENV "GnuPG$HttpProxy"
67 #define HTTP_PROXY_ENV "http_proxy"
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
};
90 enum ks_action action
;
99 unsigned int include_disabled
:1;
100 unsigned int include_revoked
:1;
101 unsigned int include_subkeys
:1;
102 unsigned int check_cert
:1;
104 unsigned int verbose
;
106 unsigned int timeout
;
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
123 unsigned int initialized
:1;
124 unsigned int begun
:1;
126 unsigned int armor
:1;
130 unsigned char armor_ctx
[3];
131 int markeridx
,linelen
;
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_ */