proton  0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
url.h
Go to the documentation of this file.
1 #ifndef PROTON_URL_H
2 #define PROTON_URL_H
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements. See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership. The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License. You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied. See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  */
21 
22 #include <proton/import_export.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 
29 /** @file
30  * URL API for parsing URLs.
31  *
32  * @defgroup url URL
33  * @{
34  */
35 
36 /** A parsed URL */
37 typedef struct pn_url_t pn_url_t;
38 
39 /** Create an empty URL */
41 
42 /** Parse a string URL as a pn_url_t.
43  *@param[in] url A URL string.
44  *@return The parsed pn_url_t or NULL if url is not a valid URL string.
45  */
46 PN_EXTERN pn_url_t *pn_url_parse(const char *url);
47 
48 /** Free a URL */
49 PN_EXTERN void pn_url_free(pn_url_t *url);
50 
51 /** Clear the contents of the URL. */
53 
54 /**
55  * Return the string form of a URL.
56  *
57  * The returned string is owned by the pn_url_t and will become invalid if it
58  * is modified.
59  */
60 PN_EXTERN const char *pn_url_str(pn_url_t *url);
61 
62 /**
63  *@name Getters for parts of the URL.
64  *
65  *Values belong to the URL. May return NULL if the value is not set.
66  *
67  *@{
68  */
69 PN_EXTERN const char *pn_url_get_scheme(pn_url_t *url);
70 PN_EXTERN const char *pn_url_get_username(pn_url_t *url);
71 PN_EXTERN const char *pn_url_get_password(pn_url_t *url);
72 PN_EXTERN const char *pn_url_get_host(pn_url_t *url);
73 PN_EXTERN const char *pn_url_get_port(pn_url_t *url);
74 PN_EXTERN const char *pn_url_get_path(pn_url_t *url);
75 ///@}
76 
77 /**
78  *@name Setters for parts of the URL.
79  *
80  *Values are copied. Value can be NULL to indicate the part is not set.
81  *
82  *@{
83  */
84 PN_EXTERN void pn_url_set_scheme(pn_url_t *url, const char *scheme);
85 PN_EXTERN void pn_url_set_username(pn_url_t *url, const char *username);
86 PN_EXTERN void pn_url_set_password(pn_url_t *url, const char *password);
87 PN_EXTERN void pn_url_set_host(pn_url_t *url, const char *host);
88 PN_EXTERN void pn_url_set_port(pn_url_t *url, const char *port);
89 PN_EXTERN void pn_url_set_path(pn_url_t *url, const char *path);
90 ///@}
91 
92 ///@}
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif
PN_EXTERN const char * pn_url_get_host(pn_url_t *url)
PN_EXTERN void pn_url_set_scheme(pn_url_t *url, const char *scheme)
PN_EXTERN void pn_url_clear(pn_url_t *url)
Clear the contents of the URL.
PN_EXTERN const char * pn_url_get_scheme(pn_url_t *url)
#define PN_EXTERN
Definition: import_export.h:53
PN_EXTERN void pn_url_free(pn_url_t *url)
Free a URL.
PN_EXTERN const char * pn_url_get_password(pn_url_t *url)
PN_EXTERN const char * pn_url_get_username(pn_url_t *url)
PN_EXTERN void pn_url_set_username(pn_url_t *url, const char *username)
PN_EXTERN void pn_url_set_path(pn_url_t *url, const char *path)
PN_EXTERN void pn_url_set_port(pn_url_t *url, const char *port)
PN_EXTERN void pn_url_set_password(pn_url_t *url, const char *password)
PN_EXTERN pn_url_t * pn_url_parse(const char *url)
Parse a string URL as a pn_url_t.
struct pn_url_t pn_url_t
A parsed URL.
Definition: url.h:37
PN_EXTERN const char * pn_url_get_path(pn_url_t *url)
PN_EXTERN void pn_url_set_host(pn_url_t *url, const char *host)
PN_EXTERN const char * pn_url_get_port(pn_url_t *url)
PN_EXTERN pn_url_t * pn_url(void)
Create an empty URL.
PN_EXTERN const char * pn_url_str(pn_url_t *url)
Return the string form of a URL.