#ifndef CURLINC_URLAPI_H1#define CURLINC_URLAPI_H2/***************************************************************************3* _ _ ____ _4* Project ___| | | | _ \| |5* / __| | | | |_) | |6* | (__| |_| | _ <| |___7* \___|\___/|_| \_\_____|8*9* Copyright (C) Daniel Stenberg, <[email protected]>, et al.10*11* This software is licensed as described in the file COPYING, which12* you should have received as part of this distribution. The terms13* are also available at https://curl.se/docs/copyright.html.14*15* You may opt to use, copy, modify, merge, publish, distribute and/or sell16* copies of the Software, and permit persons to whom the Software is17* furnished to do so, under the terms of the COPYING file.18*19* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY20* KIND, either express or implied.21*22* SPDX-License-Identifier: curl23*24***************************************************************************/2526#include "curl.h"2728#ifdef __cplusplus29extern "C" {30#endif3132/* the error codes for the URL API */33typedef enum {34CURLUE_OK,35CURLUE_BAD_HANDLE, /* 1 */36CURLUE_BAD_PARTPOINTER, /* 2 */37CURLUE_MALFORMED_INPUT, /* 3 */38CURLUE_BAD_PORT_NUMBER, /* 4 */39CURLUE_UNSUPPORTED_SCHEME, /* 5 */40CURLUE_URLDECODE, /* 6 */41CURLUE_OUT_OF_MEMORY, /* 7 */42CURLUE_USER_NOT_ALLOWED, /* 8 */43CURLUE_UNKNOWN_PART, /* 9 */44CURLUE_NO_SCHEME, /* 10 */45CURLUE_NO_USER, /* 11 */46CURLUE_NO_PASSWORD, /* 12 */47CURLUE_NO_OPTIONS, /* 13 */48CURLUE_NO_HOST, /* 14 */49CURLUE_NO_PORT, /* 15 */50CURLUE_NO_QUERY, /* 16 */51CURLUE_NO_FRAGMENT, /* 17 */52CURLUE_NO_ZONEID, /* 18 */53CURLUE_BAD_FILE_URL, /* 19 */54CURLUE_BAD_FRAGMENT, /* 20 */55CURLUE_BAD_HOSTNAME, /* 21 */56CURLUE_BAD_IPV6, /* 22 */57CURLUE_BAD_LOGIN, /* 23 */58CURLUE_BAD_PASSWORD, /* 24 */59CURLUE_BAD_PATH, /* 25 */60CURLUE_BAD_QUERY, /* 26 */61CURLUE_BAD_SCHEME, /* 27 */62CURLUE_BAD_SLASHES, /* 28 */63CURLUE_BAD_USER, /* 29 */64CURLUE_LACKS_IDN, /* 30 */65CURLUE_TOO_LARGE, /* 31 */66CURLUE_LAST67} CURLUcode;6869typedef enum {70CURLUPART_URL,71CURLUPART_SCHEME,72CURLUPART_USER,73CURLUPART_PASSWORD,74CURLUPART_OPTIONS,75CURLUPART_HOST,76CURLUPART_PORT,77CURLUPART_PATH,78CURLUPART_QUERY,79CURLUPART_FRAGMENT,80CURLUPART_ZONEID /* added in 7.65.0 */81} CURLUPart;8283#define CURLU_DEFAULT_PORT (1<<0) /* return default port number */84#define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,85if the port number matches the86default for the scheme */87#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if88missing */89#define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */90#define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */91#define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */92#define CURLU_URLDECODE (1<<6) /* URL decode on get */93#define CURLU_URLENCODE (1<<7) /* URL encode on set */94#define CURLU_APPENDQUERY (1<<8) /* append a form style part */95#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */96#define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the97scheme is unknown. */98#define CURLU_ALLOW_SPACE (1<<11) /* Allow spaces in the URL */99#define CURLU_PUNYCODE (1<<12) /* get the hostname in punycode */100#define CURLU_PUNY2IDN (1<<13) /* punycode => IDN conversion */101#define CURLU_GET_EMPTY (1<<14) /* allow empty queries and fragments102when extracting the URL or the103components */104#define CURLU_NO_GUESS_SCHEME (1<<15) /* for get, do not accept a guess */105106typedef struct Curl_URL CURLU;107108/*109* curl_url() creates a new CURLU handle and returns a pointer to it.110* Must be freed with curl_url_cleanup().111*/112CURL_EXTERN CURLU *curl_url(void);113114/*115* curl_url_cleanup() frees the CURLU handle and related resources used for116* the URL parsing. It will not free strings previously returned with the URL117* API.118*/119CURL_EXTERN void curl_url_cleanup(CURLU *handle);120121/*122* curl_url_dup() duplicates a CURLU handle and returns a new copy. The new123* handle must also be freed with curl_url_cleanup().124*/125CURL_EXTERN CURLU *curl_url_dup(const CURLU *in);126127/*128* curl_url_get() extracts a specific part of the URL from a CURLU129* handle. Returns error code. The returned pointer MUST be freed with130* curl_free() afterwards.131*/132CURL_EXTERN CURLUcode curl_url_get(const CURLU *handle, CURLUPart what,133char **part, unsigned int flags);134135/*136* curl_url_set() sets a specific part of the URL in a CURLU handle. Returns137* error code. The passed in string will be copied. Passing a NULL instead of138* a part string, clears that part.139*/140CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,141const char *part, unsigned int flags);142143/*144* curl_url_strerror() turns a CURLUcode value into the equivalent human145* readable error string. This is useful for printing meaningful error146* messages.147*/148CURL_EXTERN const char *curl_url_strerror(CURLUcode);149150#ifdef __cplusplus151} /* end of extern "C" */152#endif153154#endif /* CURLINC_URLAPI_H */155156157