1 | #ifndef __CURL_URLAPI_H
|
---|
2 | #define __CURL_URLAPI_H
|
---|
3 | /***************************************************************************
|
---|
4 | * _ _ ____ _
|
---|
5 | * Project ___| | | | _ \| |
|
---|
6 | * / __| | | | |_) | |
|
---|
7 | * | (__| |_| | _ <| |___
|
---|
8 | * \___|\___/|_| \_\_____|
|
---|
9 | *
|
---|
10 | * Copyright (C) 2018 - 2019, Daniel Stenberg, <[email protected]>, et al.
|
---|
11 | *
|
---|
12 | * This software is licensed as described in the file COPYING, which
|
---|
13 | * you should have received as part of this distribution. The terms
|
---|
14 | * are also available at https://curl.haxx.se/docs/copyright.html.
|
---|
15 | *
|
---|
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
---|
17 | * copies of the Software, and permit persons to whom the Software is
|
---|
18 | * furnished to do so, under the terms of the COPYING file.
|
---|
19 | *
|
---|
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
---|
21 | * KIND, either express or implied.
|
---|
22 | *
|
---|
23 | ***************************************************************************/
|
---|
24 |
|
---|
25 | #include "curl.h"
|
---|
26 |
|
---|
27 | #ifdef __cplusplus
|
---|
28 | extern "C" {
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | /* the error codes for the URL API */
|
---|
32 | typedef enum {
|
---|
33 | CURLUE_OK,
|
---|
34 | CURLUE_BAD_HANDLE, /* 1 */
|
---|
35 | CURLUE_BAD_PARTPOINTER, /* 2 */
|
---|
36 | CURLUE_MALFORMED_INPUT, /* 3 */
|
---|
37 | CURLUE_BAD_PORT_NUMBER, /* 4 */
|
---|
38 | CURLUE_UNSUPPORTED_SCHEME, /* 5 */
|
---|
39 | CURLUE_URLDECODE, /* 6 */
|
---|
40 | CURLUE_OUT_OF_MEMORY, /* 7 */
|
---|
41 | CURLUE_USER_NOT_ALLOWED, /* 8 */
|
---|
42 | CURLUE_UNKNOWN_PART, /* 9 */
|
---|
43 | CURLUE_NO_SCHEME, /* 10 */
|
---|
44 | CURLUE_NO_USER, /* 11 */
|
---|
45 | CURLUE_NO_PASSWORD, /* 12 */
|
---|
46 | CURLUE_NO_OPTIONS, /* 13 */
|
---|
47 | CURLUE_NO_HOST, /* 14 */
|
---|
48 | CURLUE_NO_PORT, /* 15 */
|
---|
49 | CURLUE_NO_QUERY, /* 16 */
|
---|
50 | CURLUE_NO_FRAGMENT /* 17 */
|
---|
51 | } CURLUcode;
|
---|
52 |
|
---|
53 | typedef enum {
|
---|
54 | CURLUPART_URL,
|
---|
55 | CURLUPART_SCHEME,
|
---|
56 | CURLUPART_USER,
|
---|
57 | CURLUPART_PASSWORD,
|
---|
58 | CURLUPART_OPTIONS,
|
---|
59 | CURLUPART_HOST,
|
---|
60 | CURLUPART_PORT,
|
---|
61 | CURLUPART_PATH,
|
---|
62 | CURLUPART_QUERY,
|
---|
63 | CURLUPART_FRAGMENT
|
---|
64 | } CURLUPart;
|
---|
65 |
|
---|
66 | #define CURLU_DEFAULT_PORT (1<<0) /* return default port number */
|
---|
67 | #define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,
|
---|
68 | if the port number matches the
|
---|
69 | default for the scheme */
|
---|
70 | #define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if
|
---|
71 | missing */
|
---|
72 | #define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */
|
---|
73 | #define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */
|
---|
74 | #define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */
|
---|
75 | #define CURLU_URLDECODE (1<<6) /* URL decode on get */
|
---|
76 | #define CURLU_URLENCODE (1<<7) /* URL encode on set */
|
---|
77 | #define CURLU_APPENDQUERY (1<<8) /* append a form style part */
|
---|
78 | #define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
|
---|
79 |
|
---|
80 | typedef struct Curl_URL CURLU;
|
---|
81 |
|
---|
82 | /*
|
---|
83 | * curl_url() creates a new CURLU handle and returns a pointer to it.
|
---|
84 | * Must be freed with curl_url_cleanup().
|
---|
85 | */
|
---|
86 | CURL_EXTERN CURLU *curl_url(void);
|
---|
87 |
|
---|
88 | /*
|
---|
89 | * curl_url_cleanup() frees the CURLU handle and related resources used for
|
---|
90 | * the URL parsing. It will not free strings previously returned with the URL
|
---|
91 | * API.
|
---|
92 | */
|
---|
93 | CURL_EXTERN void curl_url_cleanup(CURLU *handle);
|
---|
94 |
|
---|
95 | /*
|
---|
96 | * curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
|
---|
97 | * handle must also be freed with curl_url_cleanup().
|
---|
98 | */
|
---|
99 | CURL_EXTERN CURLU *curl_url_dup(CURLU *in);
|
---|
100 |
|
---|
101 | /*
|
---|
102 | * curl_url_get() extracts a specific part of the URL from a CURLU
|
---|
103 | * handle. Returns error code. The returned pointer MUST be freed with
|
---|
104 | * curl_free() afterwards.
|
---|
105 | */
|
---|
106 | CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what,
|
---|
107 | char **part, unsigned int flags);
|
---|
108 |
|
---|
109 | /*
|
---|
110 | * curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
|
---|
111 | * error code. The passed in string will be copied. Passing a NULL instead of
|
---|
112 | * a part string, clears that part.
|
---|
113 | */
|
---|
114 | CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
|
---|
115 | const char *part, unsigned int flags);
|
---|
116 |
|
---|
117 |
|
---|
118 | #ifdef __cplusplus
|
---|
119 | } /* end of extern "C" */
|
---|
120 | #endif
|
---|
121 |
|
---|
122 | #endif
|
---|