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 #include <common/gru_status.h>
00023 #include <string/gru_alt.h>
00024
00025 #include <uriparser/Uri.h>
00026
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030
00035 typedef enum gru_uri_parse_opt_t_ {
00036 GRU_URI_PARSE_DEFAULT = 0,
00037 GRU_URI_PARSE_STRIP = 1,
00038 } gru_uri_parse_opt_t;
00039
00040 typedef enum gru_uri_format_opt_t_ {
00041 GRU_URI_FORMAT_NONE = 0,
00042 GRU_URI_FORMAT_PORT = 1,
00043 GRU_URI_FORMAT_PATH = 2,
00044 GRU_URI_FORMAT_DEFAULT =
00045 GRU_URI_FORMAT_PORT | GRU_URI_FORMAT_PATH,
00046 } gru_uri_format_opt_t;
00047
00048 typedef struct gru_uri_t_ {
00049 char *scheme;
00050 char *host;
00051 char *path;
00052 uint16_t port;
00053 } gru_uri_t;
00054
00061 gru_export gru_uri_t gru_uri_parse(
00062 const char *gru_restrict uri, gru_status_t *gru_restrict status);
00063
00071 gru_export gru_uri_t gru_uri_parse_ex(const char *gru_restrict url,
00072 gru_uri_parse_opt_t parseopt, gru_status_t *gru_restrict status);
00073
00080 gru_export char *gru_uri_simple_format(
00081 const gru_uri_t *gru_restrict uri, gru_status_t *gru_restrict status);
00082
00090 gru_export char *gru_uri_format(const gru_uri_t *gru_restrict uri,
00091 gru_uri_format_opt_t fopt, gru_status_t *gru_restrict status);
00092
00099 gru_export bool gru_uri_set_scheme(gru_uri_t *uri, const char *scheme);
00100
00107 gru_export bool gru_uri_set_path(gru_uri_t *uri, const char *path);
00108
00116 gru_export gru_uri_t gru_uri_clone(gru_uri_t other, gru_status_t *status);
00117
00122 gru_export void gru_uri_cleanup(gru_uri_t *uri);
00123
00124 #ifdef __cplusplus
00125 }
00126 #endif
00127
00128 #endif