jpayne@69: #ifndef CURLINC_URLAPI_H jpayne@69: #define CURLINC_URLAPI_H jpayne@69: /*************************************************************************** jpayne@69: * _ _ ____ _ jpayne@69: * Project ___| | | | _ \| | jpayne@69: * / __| | | | |_) | | jpayne@69: * | (__| |_| | _ <| |___ jpayne@69: * \___|\___/|_| \_\_____| jpayne@69: * jpayne@69: * Copyright (C) 2018 - 2022, Daniel Stenberg, , et al. jpayne@69: * jpayne@69: * This software is licensed as described in the file COPYING, which jpayne@69: * you should have received as part of this distribution. The terms jpayne@69: * are also available at https://curl.se/docs/copyright.html. jpayne@69: * jpayne@69: * You may opt to use, copy, modify, merge, publish, distribute and/or sell jpayne@69: * copies of the Software, and permit persons to whom the Software is jpayne@69: * furnished to do so, under the terms of the COPYING file. jpayne@69: * jpayne@69: * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY jpayne@69: * KIND, either express or implied. jpayne@69: * jpayne@69: * SPDX-License-Identifier: curl jpayne@69: * jpayne@69: ***************************************************************************/ jpayne@69: jpayne@69: #include "curl.h" jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /* the error codes for the URL API */ jpayne@69: typedef enum { jpayne@69: CURLUE_OK, jpayne@69: CURLUE_BAD_HANDLE, /* 1 */ jpayne@69: CURLUE_BAD_PARTPOINTER, /* 2 */ jpayne@69: CURLUE_MALFORMED_INPUT, /* 3 */ jpayne@69: CURLUE_BAD_PORT_NUMBER, /* 4 */ jpayne@69: CURLUE_UNSUPPORTED_SCHEME, /* 5 */ jpayne@69: CURLUE_URLDECODE, /* 6 */ jpayne@69: CURLUE_OUT_OF_MEMORY, /* 7 */ jpayne@69: CURLUE_USER_NOT_ALLOWED, /* 8 */ jpayne@69: CURLUE_UNKNOWN_PART, /* 9 */ jpayne@69: CURLUE_NO_SCHEME, /* 10 */ jpayne@69: CURLUE_NO_USER, /* 11 */ jpayne@69: CURLUE_NO_PASSWORD, /* 12 */ jpayne@69: CURLUE_NO_OPTIONS, /* 13 */ jpayne@69: CURLUE_NO_HOST, /* 14 */ jpayne@69: CURLUE_NO_PORT, /* 15 */ jpayne@69: CURLUE_NO_QUERY, /* 16 */ jpayne@69: CURLUE_NO_FRAGMENT, /* 17 */ jpayne@69: CURLUE_NO_ZONEID, /* 18 */ jpayne@69: CURLUE_BAD_FILE_URL, /* 19 */ jpayne@69: CURLUE_BAD_FRAGMENT, /* 20 */ jpayne@69: CURLUE_BAD_HOSTNAME, /* 21 */ jpayne@69: CURLUE_BAD_IPV6, /* 22 */ jpayne@69: CURLUE_BAD_LOGIN, /* 23 */ jpayne@69: CURLUE_BAD_PASSWORD, /* 24 */ jpayne@69: CURLUE_BAD_PATH, /* 25 */ jpayne@69: CURLUE_BAD_QUERY, /* 26 */ jpayne@69: CURLUE_BAD_SCHEME, /* 27 */ jpayne@69: CURLUE_BAD_SLASHES, /* 28 */ jpayne@69: CURLUE_BAD_USER, /* 29 */ jpayne@69: CURLUE_LAST jpayne@69: } CURLUcode; jpayne@69: jpayne@69: typedef enum { jpayne@69: CURLUPART_URL, jpayne@69: CURLUPART_SCHEME, jpayne@69: CURLUPART_USER, jpayne@69: CURLUPART_PASSWORD, jpayne@69: CURLUPART_OPTIONS, jpayne@69: CURLUPART_HOST, jpayne@69: CURLUPART_PORT, jpayne@69: CURLUPART_PATH, jpayne@69: CURLUPART_QUERY, jpayne@69: CURLUPART_FRAGMENT, jpayne@69: CURLUPART_ZONEID /* added in 7.65.0 */ jpayne@69: } CURLUPart; jpayne@69: jpayne@69: #define CURLU_DEFAULT_PORT (1<<0) /* return default port number */ jpayne@69: #define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set, jpayne@69: if the port number matches the jpayne@69: default for the scheme */ jpayne@69: #define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if jpayne@69: missing */ jpayne@69: #define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */ jpayne@69: #define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */ jpayne@69: #define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */ jpayne@69: #define CURLU_URLDECODE (1<<6) /* URL decode on get */ jpayne@69: #define CURLU_URLENCODE (1<<7) /* URL encode on set */ jpayne@69: #define CURLU_APPENDQUERY (1<<8) /* append a form style part */ jpayne@69: #define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */ jpayne@69: #define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the jpayne@69: scheme is unknown. */ jpayne@69: #define CURLU_ALLOW_SPACE (1<<11) /* Allow spaces in the URL */ jpayne@69: jpayne@69: typedef struct Curl_URL CURLU; jpayne@69: jpayne@69: /* jpayne@69: * curl_url() creates a new CURLU handle and returns a pointer to it. jpayne@69: * Must be freed with curl_url_cleanup(). jpayne@69: */ jpayne@69: CURL_EXTERN CURLU *curl_url(void); jpayne@69: jpayne@69: /* jpayne@69: * curl_url_cleanup() frees the CURLU handle and related resources used for jpayne@69: * the URL parsing. It will not free strings previously returned with the URL jpayne@69: * API. jpayne@69: */ jpayne@69: CURL_EXTERN void curl_url_cleanup(CURLU *handle); jpayne@69: jpayne@69: /* jpayne@69: * curl_url_dup() duplicates a CURLU handle and returns a new copy. The new jpayne@69: * handle must also be freed with curl_url_cleanup(). jpayne@69: */ jpayne@69: CURL_EXTERN CURLU *curl_url_dup(CURLU *in); jpayne@69: jpayne@69: /* jpayne@69: * curl_url_get() extracts a specific part of the URL from a CURLU jpayne@69: * handle. Returns error code. The returned pointer MUST be freed with jpayne@69: * curl_free() afterwards. jpayne@69: */ jpayne@69: CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what, jpayne@69: char **part, unsigned int flags); jpayne@69: jpayne@69: /* jpayne@69: * curl_url_set() sets a specific part of the URL in a CURLU handle. Returns jpayne@69: * error code. The passed in string will be copied. Passing a NULL instead of jpayne@69: * a part string, clears that part. jpayne@69: */ jpayne@69: CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what, jpayne@69: const char *part, unsigned int flags); jpayne@69: jpayne@69: /* jpayne@69: * curl_url_strerror() turns a CURLUcode value into the equivalent human jpayne@69: * readable error string. This is useful for printing meaningful error jpayne@69: * messages. jpayne@69: */ jpayne@69: CURL_EXTERN const char *curl_url_strerror(CURLUcode); jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } /* end of extern "C" */ jpayne@69: #endif jpayne@69: jpayne@69: #endif /* CURLINC_URLAPI_H */