Line data Source code
1 : #ifndef HEADER_fd_src_waltz_h2_fd_url_h 2 : #define HEADER_fd_src_waltz_h2_fd_url_h 3 : 4 : /* fd_url.h provides an API for handling URLs. 5 : 6 : This API is by no means compliant. Works only for basic strings. */ 7 : 8 : #include "../../util/fd_util_base.h" 9 : 10 : /* fd_url_t holds a bunch of pointers into an URL string. */ 11 : 12 : struct fd_url { 13 : char const * scheme; 14 : ulong scheme_len; 15 : 16 : char const * host; 17 : ulong host_len; /* <=255 */ 18 : 19 : char const * port; 20 : ulong port_len; 21 : 22 : char const * tail; /* path, query, fragment */ 23 : ulong tail_len; 24 : }; 25 : 26 : typedef struct fd_url fd_url_t; 27 : 28 0 : #define FD_URL_SUCCESS 0 29 0 : #define FD_URL_ERR_SCHEME 1 30 0 : #define FD_URL_ERR_HOST_OVERSZ 2 31 0 : #define FD_URL_ERR_USERINFO 3 32 : 33 : FD_PROTOTYPES_BEGIN 34 : 35 : /* fd_url_parse_cstr is a basic URL parser. It is not RFC compliant. 36 : 37 : Non-exhaustive list of what this function cannot do: 38 : - Schemes other than http and https are not supported 39 : - userinfo (e.g. 'user:pass@') is not supported 40 : - Anything after the authority is ignored 41 : 42 : If opt_err!=NULL, on return *opt_err holds an FD_URL_ERR_{...} code. */ 43 : 44 : fd_url_t * 45 : fd_url_parse_cstr( fd_url_t * url, 46 : char const * url_str, 47 : ulong url_str_len, 48 : int * opt_err ); 49 : 50 : FD_PROTOTYPES_END 51 : 52 : #endif /* HEADER_fd_src_waltz_h2_fd_url_h */