00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef GRU_URI_H
00017 #define GRU_URI_H
00018
00019 #include <inttypes.h>
00020 #include <stdbool.h>
00021
00022
00023 #if !defined(_WIN32) && !defined(_WIN64)
00024 #include <arpa/inet.h>
00025 #else
00026 #include <winsock2.h>
00027 #include <ws2tcpip.h>
00028 #endif
00029
00030 #include <common/gru_portable.h>
00031 #include <common/gru_status.h>
00032 #include <string/gru_alt.h>
00033 #include <common/gru_keypair.h>
00034 #include <common/gru_variant.h>
00035
00036 #include <uriparser/Uri.h>
00037 #include <collection/gru_list.h>
00038
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042
00047 typedef enum gru_uri_parse_opt_t_ {
00048 GRU_URI_PARSE_DEFAULT = 0,
00049 GRU_URI_PARSE_STRIP = 1,
00050 } gru_uri_parse_opt_t;
00051
00052 typedef enum gru_uri_format_opt_t_ {
00053 GRU_URI_FORMAT_NONE = 0,
00054 GRU_URI_FORMAT_PORT = 1,
00055 GRU_URI_FORMAT_PATH = 2,
00056 GRU_URI_FORMAT_DEFAULT =
00057 GRU_URI_FORMAT_PORT | GRU_URI_FORMAT_PATH,
00058 } gru_uri_format_opt_t;
00059
00060 typedef struct gru_uri_t_ {
00061 char *scheme;
00062 char *host;
00063 char *path;
00064 uint16_t port;
00065 gru_list_t *query;
00066 } gru_uri_t;
00067
00074 gru_export gru_uri_t gru_uri_parse(const char *gru_restrict uri,
00075 gru_status_t *gru_restrict status);
00076
00084 gru_export gru_uri_t gru_uri_parse_ex(const char *gru_restrict url,
00085 gru_uri_parse_opt_t parseopt,
00086 gru_status_t *gru_restrict status);
00087
00094 gru_export char *gru_uri_simple_format(const gru_uri_t *gru_restrict uri,
00095 gru_status_t *gru_restrict status);
00096
00104 gru_export char *gru_uri_format(const gru_uri_t *gru_restrict uri,
00105 gru_uri_format_opt_t fopt,
00106 gru_status_t *gru_restrict status);
00107
00114 gru_export bool gru_uri_set_scheme(gru_uri_t *uri, const char *scheme);
00115
00122 gru_export bool gru_uri_set_path(gru_uri_t *uri, const char *path);
00123
00131 gru_export gru_uri_t gru_uri_clone(gru_uri_t other, gru_status_t *status);
00132
00137 gru_export void gru_uri_cleanup(gru_uri_t *uri);
00138
00139 #ifdef __cplusplus
00140 }
00141 #endif
00142
00143 #endif