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