new
[libcurl.git] / include / curl / curl.h
blobd4bdc41501107e19512e4e4b3dd660ddcdc64d68
1 #ifndef __URL_H
2 #define __URL_H
3 /*****************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
17 * License for the specific language governing rights and limitations
18 * under the License.
20 * The Original Code is Curl.
22 * The Initial Developer of the Original Code is Daniel Stenberg.
24 * Portions created by the Initial Developer are Copyright (C) 1998.
25 * All Rights Reserved.
27 * ------------------------------------------------------------
28 * Main author:
29 * - Daniel Stenberg <Daniel.Stenberg@haxx.nu>
31 * http://curl.haxx.nu
33 * $Source: /cvsroot/curl/curl/include/curl/curl.h,v $
34 * $Revision: 1.1.1.1 $
35 * $Date: 1999-12-29 14:21:15 $
36 * $Author: bagder $
37 * $State: Exp $
38 * $Locker: $
40 * ------------------------------------------------------------
41 ****************************************************************************/
42 #ifndef TRUE
43 #define TRUE 1
44 #endif
45 #ifndef FALSE
46 #define FALSE 0
47 #endif
50 #define CONF_DEFAULT 0
51 #define CONF_PROXY (1<<0) /* set if proxy is in use */
52 #define CONF_PORT (1<<1) /* set if different port than protcol-defines is
53 used */
54 #define CONF_HTTP (1<<2) /* http get */
55 #define CONF_GOPHER (1<<3) /* gopher get */
56 #define CONF_FTP (1<<4) /* ftp get (binary mode) */
57 #define CONF_VERBOSE (1<<5) /* talk a lot */
59 #define CONF_TELNET (1<<6)
61 #define CONF_HEADER (1<<8) /* throw the header out too */
62 #define CONF_USERPWD (1<<9) /* user+passwd has been specified */
63 #define CONF_NOPROGRESS (1<<10) /* shut off the progress meter (auto)
64 see also _MUTE */
65 #define CONF_NOBODY (1<<11) /* use HEAD to get http document */
66 #define CONF_FAILONERROR (1<<12) /* Makes urlget() fail with a return code
67 WITHOUT writing anything to the output if
68 a return code >=300 is returned from the
69 server. */
70 #define CONF_RANGE (1<<13) /* Byte-range request, specified parameter is set */
71 #define CONF_UPLOAD (1<<14) /* this is an upload, only supported for ftp
72 currently */
74 #define CONF_POST (1<<15) /* HTTP POST method */
76 /* When getting an FTP directory, this switch makes the listing only show file
77 names and nothing else. Makes machine parsing of the output possible. This
78 enforces the NLST command to the ftp server, compared to the otherwise
79 used: LIST. */
80 #define CONF_FTPLISTONLY (1<<16)
82 /* Set the referer string */
83 #define CONF_REFERER (1<<17)
84 #define CONF_PROXYUSERPWD (1<<18) /* Proxy user+passwd has been specified */
86 /* For FTP, use PORT instead of PASV! */
87 #define CONF_FTPPORT (1<<19)
89 /* FTP: Append instead of overwrite on upload! */
90 #define CONF_FTPAPPEND (1<<20)
92 #define CONF_HTTPS (1<<21) /* Use SSLeay for encrypted communication */
94 #define CONF_NETRC (1<<22) /* read user+password from .netrc */
96 #define CONF_FOLLOWLOCATION (1<<23) /* get the page that the Location: tells
97 us to get */
99 #define CONF_FTPASCII (1<<24) /* use TYPE A for transfer */
101 #define CONF_HTTPPOST (1<<25) /* this causes a multipart/form-data
102 HTTP POST */
103 #define CONF_NOPROT (1<<26) /* host name specified without protocol */
105 #define CONF_PUT (1<<27) /* PUT the input file */
107 #define CONF_MUTE (1<<28) /* force NOPROGRESS */
109 #define CONF_DICT (1<<29) /* DICT:// protocol */
111 #define CONF_FILE (1<<30) /* FILE:// protocol */
113 #define CONF_LDAP (1<<31) /* LDAP:// protocol */
115 #ifdef MULTIDOC
116 struct MoreDoc {
117 struct MoreDoc *next; /* next entry in the list */
118 char *path; /* pointer to allocated path */
119 FILE *store; /* where to put the doc */
121 #endif
123 struct HttpHeader {
124 struct HttpHeader *next; /* next entry in the list */
125 char *header; /* pointer to allocated line without newline */
128 struct HttpPost {
129 struct HttpPost *next; /* next entry in the list */
130 char *name; /* pointer to allocated name */
131 char *contents; /* pointer to allocated data contents */
132 char *contenttype; /* Content-Type */
133 struct HttpPost *more; /* if one field name has more than one file, this
134 link should link to following files */
135 long flags; /* as defined below */
136 #define HTTPPOST_FILENAME (1<<0) /* specified content is a file name */
140 /* All possible error codes from this version of urlget(). Future versions
141 may return other values, stay prepared. */
143 typedef enum {
144 URG_OK = 0,
145 URG_UNSUPPORTED_PROTOCOL,
146 URG_FAILED_INIT,
147 URG_URL_MALFORMAT,
148 URG_URL_MALFORMAT_USER,
149 URG_COULDNT_RESOLVE_PROXY,
150 URG_COULDNT_RESOLVE_HOST,
151 URG_COULDNT_CONNECT,
152 URG_FTP_WEIRD_SERVER_REPLY,
153 URG_FTP_ACCESS_DENIED,
154 URG_FTP_USER_PASSWORD_INCORRECT,
155 URG_FTP_WEIRD_PASS_REPLY,
156 URG_FTP_WEIRD_USER_REPLY,
157 URG_FTP_WEIRD_PASV_REPLY,
158 URG_FTP_WEIRD_227_FORMAT,
159 URG_FTP_CANT_GET_HOST,
160 URG_FTP_CANT_RECONNECT,
161 URG_FTP_COULDNT_SET_BINARY,
162 URG_PARTIAL_FILE,
163 URG_FTP_COULDNT_RETR_FILE,
164 URG_FTP_WRITE_ERROR,
165 URG_FTP_QUOTE_ERROR,
166 URG_HTTP_NOT_FOUND,
167 URG_WRITE_ERROR,
169 URG_MALFORMAT_USER, /* the user name is illegally specified */
170 URG_FTP_COULDNT_STOR_FILE, /* failed FTP upload */
171 URG_READ_ERROR, /* could open/read from file */
173 URG_OUT_OF_MEMORY,
174 URG_OPERATION_TIMEOUTED, /* the timeout time was reached */
175 URG_FTP_COULDNT_SET_ASCII, /* TYPE A failed */
177 URG_FTP_PORT_FAILED, /* FTP PORT operation failed */
179 URG_FTP_COULDNT_USE_REST, /* the REST command failed */
180 URG_FTP_COULDNT_GET_SIZE, /* the SIZE command failed */
182 URG_HTTP_RANGE_ERROR, /* The RANGE "command" didn't seem to work */
184 URG_HTTP_POST_ERROR,
186 URG_SSL_CONNECT_ERROR, /* something was wrong when connecting with SSL */
188 URG_FTP_BAD_DOWNLOAD_RESUME, /* couldn't resume download */
190 URG_FILE_COULDNT_READ_FILE,
192 URG_LDAP_CANNOT_BIND,
193 URG_LDAP_SEARCH_FAILED,
194 URG_LIBRARY_NOT_FOUND,
195 URG_FUNCTION_NOT_FOUND,
197 URL_LAST
198 } UrgError;
200 /* This is just to make older programs not break: */
201 #define URG_FTP_PARTIAL_FILE URG_PARTIAL_FILE
203 #define URGTAG_DONE -1
204 #define URGTAG_LAST -1
205 #define URGTAG_END -1
207 #define URLGET_ERROR_SIZE 256
209 /* maximum URL length we deal with */
210 #define URL_MAX_LENGTH 4096
211 #define URL_MAX_LENGTH_TXT "4095"
213 /* name is uppercase URGTAG_<name>,
214 type is one of the defined URGTYPE_<type>
215 number is unique identifier */
216 #define T(name,type,number) URGTAG_ ## name = URGTYPE_ ## type + number
218 /* long may be 32 or 64 bits, but we should never depend on anything else
219 but 32 */
220 #define URGTYPE_LONG 0
221 #define URGTYPE_OBJECTPOINT 10000
222 #define URGTYPE_FUNCTIONPOINT 20000
224 typedef enum {
225 URGTAG_NOTHING, /* the first unused */
227 /* This is the FILE * the regular output should be written to. */
228 T(FILE, OBJECTPOINT, 1),
230 /* The full URL to get/put */
231 T(URL, OBJECTPOINT, 2),
233 /* Port number to connect to, if other than default. Specify the CONF_PORT
234 flag in the URGTAG_FLAGS to activate this */
235 T(PORT, LONG, 3),
237 /* Name of proxy to use. Specify the CONF_PROXY flag in the URGTAG_FLAGS to
238 activate this */
239 T(PROXY, OBJECTPOINT, 4),
241 /* Name and password to use when fetching. Specify the CONF_USERPWD flag in
242 the URGTAG_FLAGS to activate this */
243 T(USERPWD, OBJECTPOINT, 5),
245 /* Name and password to use with Proxy. Specify the CONF_PROXYUSERPWD
246 flag in the URGTAG_FLAGS to activate this */
247 T(PROXYUSERPWD, OBJECTPOINT, 6),
249 /* Range to get, specified as an ASCII string. Specify the CONF_RANGE flag
250 in the URGTAG_FLAGS to activate this */
251 T(RANGE, OBJECTPOINT, 7),
253 /* Configuration flags */
254 T(FLAGS, LONG, 8),
256 /* Specified file stream to upload from (use as input): */
257 T(INFILE, OBJECTPOINT, 9),
259 /* Buffer to receive error messages in, must be at least URLGET_ERROR_SIZE
260 bytes big. If this is not used, error messages go to stderr instead: */
261 T(ERRORBUFFER, OBJECTPOINT, 10),
263 /* Function that will be called to store the output (instead of fwrite). The
264 parameters will use fwrite() syntax, make sure to follow them. */
265 T(WRITEFUNCTION, FUNCTIONPOINT, 11),
267 /* Function that will be called to read the input (instead of fread). The
268 parameters will use fread() syntax, make sure to follow them. */
269 T(READFUNCTION, FUNCTIONPOINT, 12),
271 /* Time-out the read operation after this amount of seconds */
272 T(TIMEOUT, LONG, 13),
274 /* If the URGTAG_INFILE is used, this can be used to inform urlget about how
275 large the file being sent really is. That allows better error checking
276 and better verifies that the upload was succcessful. -1 means unknown
277 size. */
278 T(INFILESIZE, LONG, 14),
280 /* POST input fields. */
281 T(POSTFIELDS, OBJECTPOINT, 15),
283 /* Set the referer page (needed by some CGIs) */
284 T(REFERER, OBJECTPOINT, 16),
286 /* Set the FTP PORT string (interface name, named or numerical IP address)
287 Use i.e '-' to use default address. */
288 T(FTPPORT, OBJECTPOINT, 17),
290 /* Set the User-Agent string (examined by some CGIs) */
291 T(USERAGENT, OBJECTPOINT, 18),
293 /* If the download receives less than "low speed limit" bytes/second
294 * during "low speed time" seconds, the operations is aborted.
295 * You could i.e if you have a pretty high speed connection, abort if
296 * it is less than 2000 bytes/sec during 20 seconds.
299 /* Set the "low speed limit" */
300 T(LOW_SPEED_LIMIT, LONG , 19),
302 /* Set the "low speed time" */
303 T(LOW_SPEED_TIME, LONG, 20),
305 /* Set the continuation offset */
306 T(RESUME_FROM, LONG, 21),
308 /* Set cookie in request: */
309 T(COOKIE, OBJECTPOINT, 22),
311 /* This points to a linked list of headers, struct HttpHeader kind */
312 T(HTTPHEADER, OBJECTPOINT, 23),
314 /* This points to a linked list of post entries, struct HttpPost */
315 T(HTTPPOST, OBJECTPOINT, 24),
317 /* name of the file keeping your private SSL-certificate */
318 T(SSLCERT, OBJECTPOINT, 25),
320 /* password for the SSL-certificate */
321 T(SSLCERTPASSWD, OBJECTPOINT, 26),
323 /* send TYPE parameter? */
324 T(CRLF, LONG, 27),
326 /* send linked-list of QUOTE commands */
327 T(QUOTE, OBJECTPOINT, 28),
329 /* send FILE * to store headers to */
330 T(WRITEHEADER, OBJECTPOINT, 29),
332 #ifdef MULTIDOC
333 /* send linked list of MoreDoc structs */
334 T(MOREDOCS, OBJECTPOINT, 30),
335 #endif
337 /* point to a file to read the initial cookies from, also enables
338 "cookie awareness" */
339 T(COOKIEFILE, OBJECTPOINT, 31),
341 /* What version to specifly try to use.
342 3 = SSLv3, 2 = SSLv2, all else makes it try v3 first then v2 */
343 T(SSLVERSION, LONG, 32),
345 /* What kind of HTTP time condition to use, see defines */
346 T(TIMECONDITION, LONG, 33),
348 /* Time to use with the above condition. Specified in number of seconds
349 since 1 Jan 1970 */
350 T(TIMEVALUE, LONG, 34),
352 /* HTTP request, for odd commands like DELETE, TRACE and others */
353 /* OBSOLETE DEFINE, left for tradition only */
354 T(HTTPREQUEST, OBJECTPOINT, 35),
356 /* Custom request, for customizing the get command like
357 HTTP: DELETE, TRACE and others
358 FTP: to use a different list command
360 T(CUSTOMREQUEST, OBJECTPOINT, 35),
362 /* HTTP request, for odd commands like DELETE, TRACE and others */
363 T(STDERR, OBJECTPOINT, 36),
365 /* Progress mode sets alternative progress mode displays, the only
366 one defined today is 1 which makes the #-style progress bar. */
367 T(PROGRESSMODE, LONG, 37),
369 URGTAG_LASTENTRY /* the last unusued */
370 } UrgTag;
372 #define CURL_PROGRESS_STATS 0 /* default progress display */
373 #define CURL_PROGRESS_BAR 1
375 typedef enum {
376 TIMECOND_NONE,
378 TIMECOND_IFMODSINCE,
379 TIMECOND_IFUNMODSINCE,
380 TIMECOND_LASTMOD,
382 TIMECOND_LAST
383 } TimeCond;
385 #ifdef __BEOS__
386 #include <support/SupportDefs.h>
387 #else
388 #ifndef __cplusplus /* (rabe) */
389 typedef char bool;
390 #endif /* (rabe) */
391 #endif
393 /**********************************************************************
395 * >>> urlget() interface #defines changed in v5! <<<
397 * You enter parameters as tags. Tags are specified as a pair of parameters.
398 * The first parameter in a pair is the tag identifier, telling urlget what
399 * kind of tag it is, and the second is the data. The tags may come in any
400 * order but MUST ALWAYS BE TERMINATED with an ending URGTAG_DONE (which
401 * needs no data).
403 * _Very_ simple example:
405 * curl_urlget(URGTAG_URL, "http://www.fts.frontec.se/~dast/", URGTAG_DONE);
407 ***********************************************************************/
409 UrgError curl_urlget(UrgTag, ...);
411 /* external form function */
412 int curl_FormParse(char *string,
413 struct HttpPost **httppost,
414 struct HttpPost **last_post);
416 /* Unix and Win32 getenv function call */
417 char *curl_GetEnv(char *variable);
419 /* returns ascii string of the libcurl version */
420 char *curl_version(void);
422 /* This is the version number */
423 #define LIBCURL_VERSION "6.3.1"
425 /* linked-list structure for QUOTE */
426 struct curl_slist {
427 char *data;
428 struct curl_slist *next;
431 struct curl_slist *curl_slist_append(struct curl_slist *list, char *data);
432 void curl_slist_free_all(struct curl_slist *list);
434 #endif /* __URLGET_H */