Path: blob/master/cpp/linux/curl/urlapi.h
644 views
#ifndef __CURL_URLAPI_H1#define __CURL_URLAPI_H2/***************************************************************************3* _ _ ____ _4* Project ___| | | | _ \| |5* / __| | | | |_) | |6* | (__| |_| | _ <| |___7* \___|\___/|_| \_\_____|8*9* Copyright (C) 2018 - 2019, 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.haxx.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***************************************************************************/2324#include "curl.h"2526#ifdef __cplusplus27extern "C" {28#endif2930/* the error codes for the URL API */31typedef enum {32CURLUE_OK,33CURLUE_BAD_HANDLE, /* 1 */34CURLUE_BAD_PARTPOINTER, /* 2 */35CURLUE_MALFORMED_INPUT, /* 3 */36CURLUE_BAD_PORT_NUMBER, /* 4 */37CURLUE_UNSUPPORTED_SCHEME, /* 5 */38CURLUE_URLDECODE, /* 6 */39CURLUE_OUT_OF_MEMORY, /* 7 */40CURLUE_USER_NOT_ALLOWED, /* 8 */41CURLUE_UNKNOWN_PART, /* 9 */42CURLUE_NO_SCHEME, /* 10 */43CURLUE_NO_USER, /* 11 */44CURLUE_NO_PASSWORD, /* 12 */45CURLUE_NO_OPTIONS, /* 13 */46CURLUE_NO_HOST, /* 14 */47CURLUE_NO_PORT, /* 15 */48CURLUE_NO_QUERY, /* 16 */49CURLUE_NO_FRAGMENT /* 17 */50} CURLUcode;5152typedef enum {53CURLUPART_URL,54CURLUPART_SCHEME,55CURLUPART_USER,56CURLUPART_PASSWORD,57CURLUPART_OPTIONS,58CURLUPART_HOST,59CURLUPART_PORT,60CURLUPART_PATH,61CURLUPART_QUERY,62CURLUPART_FRAGMENT,63CURLUPART_ZONEID /* added in 7.65.0 */64} CURLUPart;6566#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,68if the port number matches the69default for the scheme */70#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if71missing */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 */7980typedef struct Curl_URL CURLU;8182/*83* curl_url() creates a new CURLU handle and returns a pointer to it.84* Must be freed with curl_url_cleanup().85*/86CURL_EXTERN CURLU *curl_url(void);8788/*89* curl_url_cleanup() frees the CURLU handle and related resources used for90* the URL parsing. It will not free strings previously returned with the URL91* API.92*/93CURL_EXTERN void curl_url_cleanup(CURLU *handle);9495/*96* curl_url_dup() duplicates a CURLU handle and returns a new copy. The new97* handle must also be freed with curl_url_cleanup().98*/99CURL_EXTERN CURLU *curl_url_dup(CURLU *in);100101/*102* curl_url_get() extracts a specific part of the URL from a CURLU103* handle. Returns error code. The returned pointer MUST be freed with104* curl_free() afterwards.105*/106CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what,107char **part, unsigned int flags);108109/*110* curl_url_set() sets a specific part of the URL in a CURLU handle. Returns111* error code. The passed in string will be copied. Passing a NULL instead of112* a part string, clears that part.113*/114CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,115const char *part, unsigned int flags);116117118#ifdef __cplusplus119} /* end of extern "C" */120#endif121122#endif123124125