00001 #ifndef PROTON_URL_H 00002 #define PROTON_URL_H 00003 /* 00004 * Licensed to the Apache Software Foundation (ASF) under one 00005 * or more contributor license agreements. See the NOTICE file 00006 * distributed with this work for additional information 00007 * regarding copyright ownership. The ASF licenses this file 00008 * to you under the Apache License, Version 2.0 (the 00009 * "License"); you may not use this file except in compliance 00010 * with the License. You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, 00015 * software distributed under the License is distributed on an 00016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00017 * KIND, either express or implied. See the License for the 00018 * specific language governing permissions and limitations 00019 * under the License. 00020 */ 00021 00022 #include <proton/import_export.h> 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 00029 /** @file 00030 * URL API for parsing URLs. 00031 * 00032 * @defgroup url URL 00033 * @{ 00034 */ 00035 00036 /** A parsed URL */ 00037 typedef struct pn_url_t pn_url_t; 00038 00039 /** Create an empty URL */ 00040 PN_EXTERN pn_url_t *pn_url(void); 00041 00042 /** Parse a string URL as a pn_url_t. 00043 *@param[in] url A URL string. 00044 *@return The parsed pn_url_t or NULL if url is not a valid URL string. 00045 */ 00046 PN_EXTERN pn_url_t *pn_url_parse(const char *url); 00047 00048 /** Free a URL */ 00049 PN_EXTERN void pn_url_free(pn_url_t *url); 00050 00051 /** Clear the contents of the URL. */ 00052 PN_EXTERN void pn_url_clear(pn_url_t *url); 00053 00054 /** 00055 * Return the string form of a URL. 00056 * 00057 * The returned string is owned by the pn_url_t and will become invalid if it 00058 * is modified. 00059 */ 00060 PN_EXTERN const char *pn_url_str(pn_url_t *url); 00061 00062 /** 00063 *@name Getters for parts of the URL. 00064 * 00065 *Values belong to the URL. May return NULL if the value is not set. 00066 * 00067 *@{ 00068 */ 00069 PN_EXTERN const char *pn_url_get_scheme(pn_url_t *url); 00070 PN_EXTERN const char *pn_url_get_username(pn_url_t *url); 00071 PN_EXTERN const char *pn_url_get_password(pn_url_t *url); 00072 PN_EXTERN const char *pn_url_get_host(pn_url_t *url); 00073 PN_EXTERN const char *pn_url_get_port(pn_url_t *url); 00074 PN_EXTERN const char *pn_url_get_path(pn_url_t *url); 00075 ///@} 00076 00077 /** 00078 *@name Setters for parts of the URL. 00079 * 00080 *Values are copied. Value can be NULL to indicate the part is not set. 00081 * 00082 *@{ 00083 */ 00084 PN_EXTERN void pn_url_set_scheme(pn_url_t *url, const char *scheme); 00085 PN_EXTERN void pn_url_set_username(pn_url_t *url, const char *username); 00086 PN_EXTERN void pn_url_set_password(pn_url_t *url, const char *password); 00087 PN_EXTERN void pn_url_set_host(pn_url_t *url, const char *host); 00088 PN_EXTERN void pn_url_set_port(pn_url_t *url, const char *port); 00089 PN_EXTERN void pn_url_set_path(pn_url_t *url, const char *path); 00090 ///@} 00091 00092 ///@} 00093 00094 #ifdef __cplusplus 00095 } 00096 #endif 00097 00098 #endif