Make use of the *_NAME etc macros.
[gnupg.git] / keyserver / curl-shim.h
1 /* curl-shim.h
2  * Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
3  *
4  * This file is part of GNUPG.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 #ifndef _CURL_SHIM_H_
21 #define _CURL_SHIM_H_
22
23 #include "util.h"
24 #include "http.h"
25
26 typedef enum
27   {
28     CURLE_OK=0,
29     CURLE_UNSUPPORTED_PROTOCOL=1,
30     CURLE_COULDNT_CONNECT=7,
31     CURLE_FTP_COULDNT_RETR_FILE=19,
32     CURLE_HTTP_RETURNED_ERROR=22,
33     CURLE_WRITE_ERROR=23
34   } CURLcode;
35
36 typedef enum
37   {
38     CURLOPT_URL,
39     CURLOPT_USERPWD,
40     CURLOPT_WRITEFUNCTION,
41     CURLOPT_FILE,
42     CURLOPT_ERRORBUFFER,
43     CURLOPT_FOLLOWLOCATION,
44     CURLOPT_MAXREDIRS,
45     CURLOPT_STDERR,
46     CURLOPT_VERBOSE,
47     CURLOPT_SSL_VERIFYPEER,
48     CURLOPT_PROXY,
49     CURLOPT_CAINFO,
50     CURLOPT_POST,
51     CURLOPT_POSTFIELDS,
52     CURLOPT_FAILONERROR,
53     CURLOPT_HTTPHEADER,
54     CURLOPT_SRVTAG_GPG_HACK
55   } CURLoption;
56
57 typedef size_t (*write_func)(char *buffer,size_t size,
58                              size_t nitems,void *outstream);
59
60 typedef struct
61 {
62   char *url;
63   char *auth;
64   char *errorbuffer;
65   char *proxy;
66   write_func writer;
67   void *file;
68   char *postfields;
69   char *srvtag;
70   unsigned int status;
71   FILE *errors;
72   struct curl_slist *headers;
73   struct
74   {
75     unsigned int post:1;
76     unsigned int failonerror:1;
77     unsigned int verbose:1;
78   } flags;
79   http_t hd;
80 } CURL;
81
82 typedef struct
83 {
84   const char **protocols;
85 } curl_version_info_data;
86
87 #define CURL_ERROR_SIZE 256
88 #define CURL_GLOBAL_DEFAULT 0
89 #define CURLVERSION_NOW 0
90
91 CURLcode curl_global_init(long flags);
92 void curl_global_cleanup(void);
93 CURL *curl_easy_init(void);
94 CURLcode curl_easy_setopt(CURL *curl,CURLoption option,...);
95 CURLcode curl_easy_perform(CURL *curl);
96 void curl_easy_cleanup(CURL *curl);
97 char *curl_escape(char *str,int len);
98 #define curl_free(x) free(x)
99 #define curl_version() GNUPG_NAME" curl-shim"
100 curl_version_info_data *curl_version_info(int type);
101
102 struct curl_slist
103 {
104   strlist_t list;
105 };
106
107 struct curl_slist *curl_slist_append(struct curl_slist *list,
108                                      const char *string);
109 void curl_slist_free_all(struct curl_slist *list);
110
111 #endif /* !_CURL_SHIM_H_ */