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