librnr  1.14.5
RoadNarrows Robotics Common Library 1
uri.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 /*! \file
3  *
4  * \brief Uniform Resource Identifier (URI) parsing utilities declarations.
5  *
6  * URI Components: \c scheme://userinfo\@hostname:port/path?query
7  *
8  * \pkgsynopsis
9  * RoadNarrows Robotics Common Library 1
10  *
11  * \pkgcomponent{Library}
12  * librnr
13  *
14  * \pkgfile{rnr/uri.h}
15  *
16  * \author Robin Knight (robin.knight@roadnarrows.com)
17  *
18  * \pkgcopyright{2011-2018,RoadNarrows LLC.,http://www.roadnarrows.com}
19  *
20  * \license{MIT}
21  *
22  * \EulaBegin
23  * See the README and EULA files for any copyright and licensing information.
24  * \EulaEnd
25  */
26 ////////////////////////////////////////////////////////////////////////////////
27 
28 #ifndef _RNR_URI_H
29 #define _RNR_URI_H
30 
31 #include "rnr/rnrconfig.h"
32 
34 
35 #define URI_SEP_SCHEME "://" ///< scheme separator
36 #define URI_SEP_SCHEME_LEN 3 ///< scheme separator length
37 #define URI_SEP_USER_PASSWORD ":" ///< user info password separator
38 #define URI_SEP_USER_PASSWORD_LEN 1 ///< user info password separator length
39 #define URI_SEP_USER_INFO "@" ///< user info separator
40 #define URI_SEP_USER_INFO_LEN 1 ///< user info separator length
41 #define URI_SEP_PORT ":" ///< port number separator
42 #define URI_SEP_PORT_LEN 1 ///< port number separator length
43 #define URI_SEP_PATH "/" ///< absolute path separator and start
44 #define URI_SEP_PATH_LEN 1 ///< absolute path separator length
45 #define URI_SEP_QUERY "?" ///< query separator
46 #define URI_SEP_QUERY_LEN 1 ///< query separator length
47 
48 #define URI_PORT_MAX_LEN 5 ///< port max string length (2 bytes)
49 
50 #define URI_SCHEME_FILE "file" ///< file scheme
51 #define URI_LOCAL_HOST "localhost" ///< default local hostname
52 #define URI_PORT_NONE 0 ///< no port number
53 
54 
55 /*!
56  * URI Component Parts Structure.
57  */
58 typedef struct uri_struct_t
59 {
60  char *m_sScheme; ///< scheme
61  char *m_sUserInfo; ///< user info
62  char *m_sHostName; ///< host name (domain or address)
63  int m_nPortNum; ///< port number
64  char *m_sPath; ///< absolute file path
65  char *m_sQuery; ///< query
66 } Uri_T;
67 
68 
69 extern Uri_T *UriParseNew(const char *sUri);
70 
71 extern char *UriParseHostNew(const char *sHost,
72  char **pHostName,
73  int *pPortNum);
74 
75 extern void UriSetScheme(Uri_T *pUri, const char *sScheme);
76 
77 extern void UriSetHostName(Uri_T *pUri, const char *sHostName);
78 
79 extern void UriSetPortNum(Uri_T *pUri, int nPortNum);
80 
81 extern void UriSetPath(Uri_T *pUri, const char *sPath);
82 
83 extern char *UriStrNew(const Uri_T *pUri);
84 
85 extern void UriDelete(Uri_T *pUri);
86 
87 
89 
90 #endif // _RNR_URI_H
void UriSetPath(Uri_T *pUri, const char *sPath)
Set the file path.
Definition: uri.c:295
char * m_sScheme
scheme
Definition: uri.h:60
char * m_sQuery
query
Definition: uri.h:65
void UriSetHostName(Uri_T *pUri, const char *sHostName)
Set the hostname.
Definition: uri.c:254
struct uri_struct_t Uri_T
char * m_sPath
absolute file path
Definition: uri.h:64
void UriDelete(Uri_T *pUri)
Delete the URI compenent structure.
Definition: uri.c:397
char * m_sUserInfo
user info
Definition: uri.h:61
#define C_DECLS_BEGIN
C declaration block begin in C.
Definition: rnrconfig.h:71
char * UriParseHostNew(const char *sHost, char **pHostName, int *pPortNum)
Parse the host string.
Definition: uri.c:183
RoadNarrows Robotics common configuration file.
#define C_DECLS_END
C declaration block end in C.
Definition: rnrconfig.h:72
char * UriStrNew(const Uri_T *pUri)
Construct a new URI string from the given URI components.
Definition: uri.c:321
void UriSetScheme(Uri_T *pUri, const char *sScheme)
Set the scheme.
Definition: uri.c:229
void UriSetPortNum(Uri_T *pUri, int nPortNum)
Set the port number.
Definition: uri.c:279
char * m_sHostName
host name (domain or address)
Definition: uri.h:62
int m_nPortNum
port number
Definition: uri.h:63
Uri_T * UriParseNew(const char *sUri)
Parse a URI string.
Definition: uri.c:70