00001 #ifndef HEADER_CURL_TOOL_SETOPT_H
00002 #define HEADER_CURL_TOOL_SETOPT_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "tool_setup.h"
00025
00026
00027
00028
00029
00030 #define SETOPT_CHECK(v) do { \
00031 result = (v); \
00032 if(result) \
00033 goto show_error; \
00034 } WHILE_FALSE
00035
00036 #ifndef CURL_DISABLE_LIBCURL_OPTION
00037
00038
00039 typedef struct {
00040 const char *name;
00041 long value;
00042 } NameValue;
00043
00044 typedef struct {
00045 const char *name;
00046 unsigned long value;
00047 } NameValueUnsigned;
00048
00049 extern const NameValue setopt_nv_CURLPROXY[];
00050 extern const NameValue setopt_nv_CURL_SOCKS_PROXY[];
00051 extern const NameValue setopt_nv_CURL_HTTP_VERSION[];
00052 extern const NameValue setopt_nv_CURL_SSLVERSION[];
00053 extern const NameValue setopt_nv_CURL_TIMECOND[];
00054 extern const NameValue setopt_nv_CURLFTPSSL_CCC[];
00055 extern const NameValue setopt_nv_CURLUSESSL[];
00056 extern const NameValueUnsigned setopt_nv_CURLSSLOPT[];
00057 extern const NameValue setopt_nv_CURL_NETRC[];
00058 extern const NameValue setopt_nv_CURLPROTO[];
00059 extern const NameValueUnsigned setopt_nv_CURLAUTH[];
00060
00061
00062 #define setopt_nv_CURLOPT_HTTP_VERSION setopt_nv_CURL_HTTP_VERSION
00063 #define setopt_nv_CURLOPT_HTTPAUTH setopt_nv_CURLAUTH
00064 #define setopt_nv_CURLOPT_SSLVERSION setopt_nv_CURL_SSLVERSION
00065 #define setopt_nv_CURLOPT_PROXY_SSLVERSION setopt_nv_CURL_SSLVERSION
00066 #define setopt_nv_CURLOPT_TIMECONDITION setopt_nv_CURL_TIMECOND
00067 #define setopt_nv_CURLOPT_FTP_SSL_CCC setopt_nv_CURLFTPSSL_CCC
00068 #define setopt_nv_CURLOPT_USE_SSL setopt_nv_CURLUSESSL
00069 #define setopt_nv_CURLOPT_SSL_OPTIONS setopt_nv_CURLSSLOPT
00070 #define setopt_nv_CURLOPT_NETRC setopt_nv_CURL_NETRC
00071 #define setopt_nv_CURLOPT_PROTOCOLS setopt_nv_CURLPROTO
00072 #define setopt_nv_CURLOPT_REDIR_PROTOCOLS setopt_nv_CURLPROTO
00073 #define setopt_nv_CURLOPT_PROXYTYPE setopt_nv_CURLPROXY
00074 #define setopt_nv_CURLOPT_SOCKS_PROXYTYPE setopt_nv_CURL_SOCKS_PROXY
00075 #define setopt_nv_CURLOPT_PROXYAUTH setopt_nv_CURLAUTH
00076
00077
00078
00079 CURLcode tool_setopt_enum(CURL *curl, struct GlobalConfig *config,
00080 const char *name, CURLoption tag,
00081 const NameValue *nv, long lval);
00082 CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config,
00083 const char *name, CURLoption tag,
00084 const NameValue *nv, long lval);
00085 CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config,
00086 const char *name, CURLoption tag,
00087 const NameValueUnsigned *nv, long lval);
00088 CURLcode tool_setopt_httppost(CURL *curl, struct GlobalConfig *config,
00089 const char *name, CURLoption tag,
00090 struct curl_httppost *httppost);
00091 CURLcode tool_setopt_slist(CURL *curl, struct GlobalConfig *config,
00092 const char *name, CURLoption tag,
00093 struct curl_slist *list);
00094 CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *config,
00095 const char *name, CURLoption tag, ...);
00096
00097 #define my_setopt(x,y,z) \
00098 SETOPT_CHECK(tool_setopt(x, FALSE, global, #y, y, z))
00099
00100 #define my_setopt_str(x,y,z) \
00101 SETOPT_CHECK(tool_setopt(x, TRUE, global, #y, y, z))
00102
00103 #define my_setopt_enum(x,y,z) \
00104 SETOPT_CHECK(tool_setopt_enum(x, global, #y, y, setopt_nv_ ## y, z))
00105
00106 #define my_setopt_flags(x,y,z) \
00107 SETOPT_CHECK(tool_setopt_flags(x, global, #y, y, setopt_nv_ ## y, z))
00108
00109 #define my_setopt_bitmask(x,y,z) \
00110 SETOPT_CHECK(tool_setopt_bitmask(x, global, #y, y, setopt_nv_ ## y, z))
00111
00112 #define my_setopt_httppost(x,y,z) \
00113 SETOPT_CHECK(tool_setopt_httppost(x, global, #y, y, z))
00114
00115 #define my_setopt_slist(x,y,z) \
00116 SETOPT_CHECK(tool_setopt_slist(x, global, #y, y, z))
00117
00118 #define res_setopt(x,y,z) tool_setopt(x, FALSE, global, #y, y, z)
00119
00120 #define res_setopt_str(x,y,z) tool_setopt(x, TRUE, global, #y, y, z)
00121
00122 #else
00123
00124
00125
00126 #define my_setopt(x,y,z) \
00127 SETOPT_CHECK(curl_easy_setopt(x, y, z))
00128
00129 #define my_setopt_str(x,y,z) \
00130 SETOPT_CHECK(curl_easy_setopt(x, y, z))
00131
00132 #define my_setopt_enum(x,y,z) \
00133 SETOPT_CHECK(curl_easy_setopt(x, y, z))
00134
00135 #define my_setopt_flags(x,y,z) \
00136 SETOPT_CHECK(curl_easy_setopt(x, y, z))
00137
00138 #define my_setopt_bitmask(x,y,z) \
00139 SETOPT_CHECK(curl_easy_setopt(x, y, z))
00140
00141 #define my_setopt_httppost(x,y,z) \
00142 SETOPT_CHECK(curl_easy_setopt(x, y, z))
00143
00144 #define my_setopt_slist(x,y,z) \
00145 SETOPT_CHECK(curl_easy_setopt(x, y, z))
00146
00147 #define res_setopt(x,y,z) curl_easy_setopt(x,y,z)
00148
00149 #define res_setopt_str(x,y,z) curl_easy_setopt(x,y,z)
00150
00151 #endif
00152
00153 #endif