From 6f3d10a3ec09cc278041ced4d4e506cb89a7c69a Mon Sep 17 00:00:00 2001 From: Ali Fardan Date: Wed, 18 Nov 2020 10:55:20 +0300 Subject: initial commit; todo: thorough testing --- yuri.h | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 yuri.h (limited to 'yuri.h') diff --git a/yuri.h b/yuri.h new file mode 100644 index 0000000..1a3fa63 --- /dev/null +++ b/yuri.h @@ -0,0 +1,64 @@ +#define YURI_HOST_NAME 1 +#define YURI_HOST_IP4 2 +#define YURI_HOST_IP6 3 +#define YURI_HOST_IPFUTURE 4 + +struct uri { + char *scheme; + struct { + int type; + char *user; + char *host; + int port; + } authority; + int npath; + char **path; + char *query; + char *fragment; +}; + +/* yuri.c */ +struct uri *uri_new(void); +int uri_set_scheme(struct uri *, const char *); +int uri_set_authority(struct uri *, int, const char *, const char *, int); +int uri_set_authority_type(struct uri *, int); +int uri_set_authority_user(struct uri *, const char *); +int uri_set_authority_host(struct uri *, const char *); +int uri_set_authority_port(struct uri *, int); +int uri_append_path(struct uri *, const char *); +int uri_set_query(struct uri *, const char *); +int uri_set_fragment(struct uri *, const char *); +void uri_unset_scheme(struct uri *); +void uri_unset_authority(struct uri *); +void uri_unset_authority_type(struct uri *); +void uri_unset_authority_user(struct uri *); +void uri_unset_authority_host(struct uri *); +void uri_unset_authority_port(struct uri *); +void uri_unset_path(struct uri *); +void uri_unset_query(struct uri *); +void uri_unset_fragment(struct uri *); +const char *uri_get_scheme(struct uri *); +int uri_get_authority_type(struct uri *); +const char *uri_get_authority_user(struct uri *); +const char *uri_get_authority_host(struct uri *); +int uri_get_authority_port(struct uri *); +const char **uri_get_path(struct uri *); +int uri_get_npath(struct uri *); +const char *uri_get_query(struct uri *); +const char *uri_get_fragment(struct uri *); +void uri_free(struct uri *); + +/* decode.c */ +struct uri *uri_decode(const char *); + +/* encode.c */ +char *uri_encode(struct uri *); + +/* normalize.c */ +int uri_normalize(struct uri *); + +/* strlcat.c/strlcpy.c */ +#undef strlcpy +#undef strlcat +size_t strlcpy(const char *, char *, size_t); +size_t strlcat(const char *, char *, size_t); -- cgit 1.4.1-2-gfad0