Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lexborisov/Modest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlexborisov <lex.borisov@gmail.com>2017-03-01 21:09:36 +0300
committerlexborisov <lex.borisov@gmail.com>2017-03-01 21:09:36 +0300
commit1e572ffe233a3fe8eddbc359817508dd2044e7ee (patch)
treeee8cd266b56232474310ed1feb17fc6f36709449
parent6c61d435b449ca6a58b0a9c49eaa5a174fa5eee3 (diff)
Fixed problem with make
-rw-r--r--Makefile9
-rw-r--r--devel/osx/Modest.xcodeproj/project.xcworkspace/xcuserdata/alexanderborisov.xcuserdatad/UserInterfaceState.xcuserstatebin145470 -> 145519 bytes
-rw-r--r--examples/Makefile5
-rwxr-xr-xexamples/myurl/url_databin52488 -> 0 bytes
-rwxr-xr-xexamples/myurl/url_parsebin52488 -> 0 bytes
-rwxr-xr-xexamples/myurl/url_relativebin52496 -> 0 bytes
-rw-r--r--include/myurl/host.h105
-rw-r--r--include/myurl/myosi.h77
-rw-r--r--include/myurl/parser.h103
-rw-r--r--include/myurl/path.h67
-rw-r--r--include/myurl/punycode.h48
-rw-r--r--include/myurl/resources.h180
-rw-r--r--include/myurl/scheme.h78
-rw-r--r--include/myurl/scheme_const.h43
-rw-r--r--include/myurl/scheme_resources.h64
-rw-r--r--include/myurl/serialization.h47
-rw-r--r--include/myurl/url.h195
-rw-r--r--include/myurl/utils.h73
-rw-r--r--source/myurl/parser.c2
-rw-r--r--source/myurl/url.h8
20 files changed, 1092 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 136c764..068b7be 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,6 @@ MODEST_OPTIMIZATION_LEVEL ?= -O2
CFLAGS ?= -Wall -Werror
CFLAGS += $(MODEST_OPTIMIZATION_LEVEL) -Wno-unused-variable --std=c99 -I$(SRCDIR)
-LDFLAGS ?= -lm
ifneq ($(OS),Windows_NT)
CFLAGS += -fPIC
@@ -57,16 +56,16 @@ all: create shared static
include $(TARGET)/myhtml/Makefile.mk
include $(TARGET)/mycss/Makefile.mk
include $(TARGET)/myfont/Makefile.mk
-#include $(TARGET)/myurl/Makefile.mk
+include $(TARGET)/myurl/Makefile.mk
include $(TARGET)/modest/Makefile.mk
OBJS := $(patsubst %.c,%.o,$(SRCS))
shared: $(OBJS)
- $(CC) -shared $(IMP_FLAG) $(OBJS) -o $(LIB_TMP)/lib$(LIBNAME)$(LIBPOSTFIX) $(LDFLAGS)
+ $(CC) -shared $(IMP_FLAG) $(LDFLAGS) $(OBJS) -o $(LIB_TMP)/lib$(LIBNAME)$(LIBPOSTFIX)
static: shared
- $(AR) crus $(LIB_TMP)/lib$(LIBNAME)$(LIBSTATIC_POSTFIX).a $(OBJS)
+ $(AR) crus $(LIB_TMP)/lib$(LIBNAME)$(LIBSTATIC_POSTFIX).a $(OBJS)
create:
mkdir -p lib bin
@@ -80,7 +79,7 @@ clean:
clean_include:
rm -rf $(INCLUDE_TMP)
-clone: create clean_include myhtml_clone mycss_clone modest_clone myfont_clone
+clone: create clean_include myhtml_clone mycss_clone modest_clone myfont_clone myurl_clone
find include -name "*.h" -exec sed -i '.bak' -E 's/^[ \t]*#[ \t]*include[ \t]*"([^"]+)"/#include <\1>/g' {} \;
find include -name "*.h.bak" -exec rm -f {} \;
diff --git a/devel/osx/Modest.xcodeproj/project.xcworkspace/xcuserdata/alexanderborisov.xcuserdatad/UserInterfaceState.xcuserstate b/devel/osx/Modest.xcodeproj/project.xcworkspace/xcuserdata/alexanderborisov.xcuserdatad/UserInterfaceState.xcuserstate
index a292377..e075541 100644
--- a/devel/osx/Modest.xcodeproj/project.xcworkspace/xcuserdata/alexanderborisov.xcuserdatad/UserInterfaceState.xcuserstate
+++ b/devel/osx/Modest.xcodeproj/project.xcworkspace/xcuserdata/alexanderborisov.xcuserdatad/UserInterfaceState.xcuserstate
Binary files differ
diff --git a/examples/Makefile b/examples/Makefile
index d719435..c426338 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -3,7 +3,6 @@ SRCDIR := examples
CC ?= gcc
LIBS := ../lib/libmodest_static.a
-LDLIBS := $(LIBS)
INCLUDE_TMP := include
@@ -31,12 +30,14 @@ else
else
CFLAGS += -D_POSIX_C_SOURCE=199309L
endif
+
+ LDLIBS += $(LIBS) -lm
endif
find_files_h = $(wildcard $(dir)/*.h)
find_files_c = $(wildcard $(dir)/*.c)
-SUBDIRS := selectors declarations myfont modest mycss myhtml
+SUBDIRS := selectors declarations myfont modest mycss myhtml myurl
HDRS += $(foreach dir,$(SUBDIRS),$(find_files_h))
SRCS += $(foreach dir,$(SUBDIRS),$(find_files_c))
diff --git a/examples/myurl/url_data b/examples/myurl/url_data
deleted file mode 100755
index d28ecdf..0000000
--- a/examples/myurl/url_data
+++ /dev/null
Binary files differ
diff --git a/examples/myurl/url_parse b/examples/myurl/url_parse
deleted file mode 100755
index 33ee232..0000000
--- a/examples/myurl/url_parse
+++ /dev/null
Binary files differ
diff --git a/examples/myurl/url_relative b/examples/myurl/url_relative
deleted file mode 100755
index f8d799b..0000000
--- a/examples/myurl/url_relative
+++ /dev/null
Binary files differ
diff --git a/include/myurl/host.h b/include/myurl/host.h
new file mode 100644
index 0000000..a1df82b
--- /dev/null
+++ b/include/myurl/host.h
@@ -0,0 +1,105 @@
+/*
+ Copyright (C) 2016-2017 Alexander Borisov
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyURL_HOST_H
+#define MyURL_HOST_H
+#pragma once
+
+#include <myurl/myosi.h>
+#include <myhtml/mystring.h>
+
+#include <myurl/parser.h>
+#include <myurl/utils.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum myurl_host_type {
+ MyURL_HOST_TYPE_UNDEF = 0x00,
+ MyURL_HOST_TYPE_DOMAIN = 0x01,
+ MyURL_HOST_TYPE_IPv4 = 0x02,
+ MyURL_HOST_TYPE_IPv6 = 0x03,
+ MyURL_HOST_TYPE_OPAQUE = 0x04,
+}
+typedef myurl_host_type_t;
+
+enum myurl_host_ipv_type {
+ MyURL_HOST_TYPE_IP_UNDEF = 0x00,
+ MyURL_HOST_TYPE_IP_v4 = 0x01,
+ MyURL_HOST_TYPE_IP_v6 = 0x02,
+}
+typedef myurl_host_ipv_type_t;
+
+enum myurl_host_idna_processing_option {
+ MyURL_HOST_IDNA_PROCESSING_OPTION_UNDEF = 0x00,
+ MyURL_HOST_IDNA_PROCESSING_OPTION_TRANSITIONAL = 0x01,
+ MyURL_HOST_IDNA_PROCESSING_OPTION_NONTRANSITIONAL = 0x02,
+}
+typedef myurl_host_idna_processing_option_t;
+
+struct myurl_host_ipv {
+ unsigned int pieces[9];
+ myurl_host_ipv_type_t type;
+}
+typedef myurl_host_ipv_t;
+
+struct myurl_host_opaque {
+ char* value;
+ size_t length;
+}
+typedef myurl_host_opaque_t;
+
+struct myurl_host_domain {
+ char* value;
+ size_t length;
+}
+typedef myurl_host_domain_t;
+
+struct myurl_host {
+ union {
+ myurl_host_ipv_t ipv;
+ myurl_host_opaque_t opaque;
+ myurl_host_domain_t domain;
+ };
+
+ myurl_host_type_t type;
+}
+typedef myurl_host_t;
+
+myurl_host_t * myurl_host_create(myurl_t* url);
+myurl_status_t myurl_host_init(myurl_t* url);
+void myurl_host_clean(myurl_t* url, myurl_host_t* host);
+
+myurl_host_t * myurl_host_destroy(myurl_t* url, myurl_host_t* host, bool destroy_self);
+myurl_status_t myurl_host_copy(myurl_t* url, myurl_host_t* host_from, myurl_host_t* host_to);
+
+myurl_status_t myurl_host_parser(myurl_t* url, myurl_host_t* host, const char* data, size_t data_size, bool is_special);
+myurl_status_t myurl_host_ipv4_parser(myurl_host_ipv_t* ipv, const char* data, size_t data_size, bool* failure);
+myurl_status_t myurl_host_ipv6_parser(myurl_host_ipv_t* ipv, const char* data, size_t data_size);
+myurl_status_t myurl_host_ipv6_ipv4_parser(myurl_host_ipv_t* ipv, const char* data, size_t data_size, unsigned int** piece_pointer);
+myurl_status_t myurl_host_opaque_host_parser(myurl_t* url, myurl_host_opaque_t* opaque, const char* data, size_t data_size);
+myurl_status_t myurl_host_domain_to_ascii(myurl_t* url, char** return_domain, size_t* return_domain_size, char* domain, size_t domain_size, bool UseSTD3ASCIIRules, bool VerifyDnsLength, myurl_host_idna_processing_option_t opt);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyURL_HOST_H */
diff --git a/include/myurl/myosi.h b/include/myurl/myosi.h
new file mode 100644
index 0000000..88e2363
--- /dev/null
+++ b/include/myurl/myosi.h
@@ -0,0 +1,77 @@
+/*
+ Copyright (C) 2016-2017 Alexander Borisov
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyURL_MYOSI_H
+#define MyURL_MYOSI_H
+#pragma once
+
+#include <myhtml/myosi.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct myhtml_url myurl_t;
+typedef struct myurl_entry myurl_entry_t;
+
+typedef size_t (*myurl_state_f)(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+typedef void (*myurl_callback_serialization_func_f)(myurl_entry_t* url_entry, myhtml_callback_serialize_f callback, void* ctx);
+
+typedef void * (*myurl_callback_malloc_f)(size_t size, void *ctx);
+typedef void * (*myurl_callback_realloc_f)(void* value, size_t size, void *ctx);
+typedef void * (*myurl_callback_free_f)(void* value, void *ctx);
+
+enum myurl_flags {
+ MyURL_FLAGS_UNDEF = 0x00,
+ MyURL_FLAGS_AT = 0x01,
+ MyURL_FLAGS_BRACKET = 0x02,
+ MyURL_FLAGS_CANNOT_BE_BASE_URL = 0x04
+}
+typedef myurl_flags_t;
+
+/*
+ See all senments of statuses in modest/myosi.h
+ for myurl 038888..0388ff; MyURL_STATUS_OK == 0x000000
+*/
+enum myurl_status {
+ MyURL_STATUS_OK = 0x000000,
+ MyURL_STATUS_ERROR = 0x038888,
+ MyURL_STATUS_ERROR_MEMORY_ALLOCATION = 0x038889,
+ MyURL_STATUS_FAILURE_SCHEME_START = 0x03888a,
+ MyURL_STATUS_FAILURE_SCHEME_STATE = 0x03888b,
+ MyURL_STATUS_FAILURE_NO_SCHEME_BASE_NULL_OR_NOT_HASH = 0x03888c,
+ MyURL_STATUS_FAILURE_AUTHORITY_HOST_AFTER_AUTH = 0x03888d,
+ MyURL_STATUS_FAILURE_UNEXPECTED_ENDING = 0x03888e,
+ MyURL_STATUS_FAILURE_BAD_HOSTNAME = 0x03888f,
+ MyURL_STATUS_FAILURE_BAD_PORT = 0x038890,
+ MyURL_STATUS_LAST_SEGMENT_ENTRY = 0x0388ff
+}
+typedef myurl_status_t;
+
+void * myurl_callback_malloc(size_t size, void* ctx);
+void * myurl_callback_realloc(void* value, size_t size, void* ctx);
+void * myurl_callback_free(void* value, void* ctx);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyURL_MYOSI_H */
diff --git a/include/myurl/parser.h b/include/myurl/parser.h
new file mode 100644
index 0000000..47a2ad3
--- /dev/null
+++ b/include/myurl/parser.h
@@ -0,0 +1,103 @@
+/*
+ Copyright (C) 2016 Alexander Borisov
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyURL_PARSER_H
+#define MyURL_PARSER_H
+#pragma once
+
+#include <myurl/myosi.h>
+#include <myurl/utils.h>
+
+#define myurl_parser_digit(onechar) (onechar >= 0x30 && onechar <= 0x39)
+#define myurl_parser_alpha_upper(onechar) (onechar >= 0x41 && onechar <= 0x5A)
+#define myurl_parser_alpha_lower(onechar) (onechar >= 0x61 && onechar <= 0x7A)
+#define myurl_parser_alpha(onechar) (myurl_parser_alpha_upper(onechar) || myurl_parser_alpha_lower(onechar))
+
+#define myurl_parser_alphanumeric(onechar) (myurl_parser_digit(onechar) || myurl_parser_alpha(onechar))
+
+#define myurl_parser_swap_path(url, base) \
+ if(url->path) \
+ myurl_utils_data_list_destroy(url->path, true); \
+ url->path = base->path
+
+#define myurl_parser_copy_scheme(parser, to, from) \
+ to->scheme.scheme = from->scheme.scheme; \
+ myurl_utils_data_copy(parser, &to->scheme.origin, &from->scheme.origin)
+
+#define myurl_parser_copy_path(parser, to, from) \
+ myurl_utils_data_list_copy(parser, to->path, from->path)
+
+#define myurl_parser_copy_attr(url, from, to, attr) \
+ myurl_utils_data_copy_set(url, from->attr, from->attr ## _length, &to->attr, &to->attr ## _length)
+
+#define myurl_parser_copy_buffer(url, data, data_length, to) \
+ myurl_utils_data_copy_set(url, &data[ url->begin ], (data_length - url->begin), &to, &to ## _length)
+
+#define myurl_parser_append_buffer(url, data, begin, data_length, to) \
+ myurl_utils_data_copy_append(url, &data[ begin ], (data_length - begin), &to, &to ## _length)
+
+#define myurl_parser_is_includes_credentials(url_entry) (url_entry->username_length || url_entry->password_length)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+size_t myurl_parser_begin(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_size);
+
+size_t myurl_parser_state_undef(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_scheme_start(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_scheme(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_no_scheme(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_special_relative_or_authority(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_path_or_authority(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_relative(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_relative_slash(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_special_authority_slashes(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_special_authority_ignore_slashes(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_authority(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_host_hostname(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_port(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_file(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_file_slash(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_file_host(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_path_start(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_path(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_cannot_be_a_base_URL_path(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_query(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_fragment(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+
+/* ends */
+size_t myurl_parser_state_relative_end(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_authority_end(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_host_hostname_end(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_port_end(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_file_end(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_file_host_end(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_path_start_end(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_path_end(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_cannot_be_a_base_URL_path_end(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+size_t myurl_parser_state_query_end(myurl_t* url, myurl_entry_t* url_entry, myurl_entry_t* url_base, const char* data, size_t data_length, size_t data_size);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyURL_PARSER_H */
diff --git a/include/myurl/path.h b/include/myurl/path.h
new file mode 100644
index 0000000..1e9bb75
--- /dev/null
+++ b/include/myurl/path.h
@@ -0,0 +1,67 @@
+/*
+ Copyright (C) 2016-2017 Alexander Borisov
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#include <myurl/myosi.h>
+#include <myurl/scheme_const.h>
+#include <myurl/utils.h>
+#include <myhtml/mystring.h>
+
+#ifndef MyURL_PATH_H
+#define MyURL_PATH_H
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct myurl_path_entry {
+ char* data;
+ size_t length;
+}
+typedef myurl_path_entry_t;
+
+struct myurl_path_t {
+ myurl_path_entry_t* list;
+ size_t length;
+ size_t size;
+}
+typedef myurl_path_t;
+
+myurl_path_t * myurl_path_create(myurl_t* url);
+myurl_status_t myurl_path_init(myurl_t* url, myurl_path_t* path, size_t begin_size);
+void myurl_path_clean(myurl_t* url, myurl_path_t* path);
+myurl_path_t * myurl_path_destroy(myurl_t* url, myurl_path_t* path, bool destroy_self);
+
+myurl_path_entry_t * myurl_path_append(myurl_t* url, myurl_path_t* path, const char* data, size_t length);
+myurl_path_entry_t * myurl_path_push(myurl_t* url, myurl_path_t* path, char* data, size_t length);
+myurl_path_entry_t * myurl_path_push_to_index(myurl_t* url, myurl_path_t* path, size_t index, char* data, size_t length);
+myurl_path_entry_t * myurl_path_current(myurl_path_t* path);
+myurl_path_entry_t * myurl_path_pop(myurl_path_t* path);
+myurl_status_t myurl_path_copy(myurl_t* url, myurl_path_t* path_from, myurl_path_t* path_to);
+
+void myurl_path_remove_by_index(myurl_t* url, myurl_path_t* path, size_t index);
+
+void myurl_path_shorten(myurl_path_t* path, myurl_scheme_id_t scheme_id);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyURL_PATH_H */
diff --git a/include/myurl/punycode.h b/include/myurl/punycode.h
new file mode 100644
index 0000000..41da57a
--- /dev/null
+++ b/include/myurl/punycode.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2016 Alexander Borisov
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyURL_PUNYCODE_H
+#define MyURL_PUNYCODE_H
+#pragma once
+
+#include <myurl/myosi.h>
+#include <myhtml/mystring.h>
+#include <myhtml/encoding.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum myurl_punycode_const {
+ MyURL_PUNYCODE_CONST_BASE = 36,
+ MyURL_PUNYCODE_CONST_TMIN = 1,
+ MyURL_PUNYCODE_CONST_TMAX = 26,
+ MyURL_PUNYCODE_CONST_SKEW = 38,
+ MyURL_PUNYCODE_CONST_DAMP = 700,
+ MyURL_PUNYCODE_CONST_INITIAL_BIAS = 72,
+ MyURL_PUNYCODE_CONST_INITIAL_N = 0x80,
+ MyURL_PUNYCODE_CONST_DELIMITER = 0x2D
+};
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyURL_PUNYCODE_H */
diff --git a/include/myurl/resources.h b/include/myurl/resources.h
new file mode 100644
index 0000000..7b3e626
--- /dev/null
+++ b/include/myurl/resources.h
@@ -0,0 +1,180 @@
+/*
+ Copyright (C) 2016 Alexander Borisov
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyURL_RESOURCES_H
+#define MyURL_RESOURCES_H
+#pragma once
+
+static const unsigned char myurl_resources_static_map_query_charset[] =
+{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
+ 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
+ 0x00, 0x3d, 0x00, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
+ 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
+ 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63,
+ 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static const unsigned char myurl_resources_static_map_forbidden_host_code_point[] =
+{
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x20, 0xff, 0x22, 0x23, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x3c, 0xff, 0x3e, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x60, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x7b, 0xff, 0x7d, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+};
+
+/* A C0 control is a code point in the range U+0000 to U+001F, inclusive. The C0 control percent-encode set are C0 controls and all code points greater than U+007E. */
+static const unsigned char myurl_resources_static_map_C0[] =
+{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
+ 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
+ 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
+ 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
+ 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63,
+ 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* The path percent-encode set is the myurl_resources_static_map_path and code points U+0020, '"', "#", "<", ">", "?", "`", "{", and "}". */
+static const unsigned char myurl_resources_static_map_path[] =
+{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
+ 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
+ 0x00, 0x3d, 0x00, 0x00, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
+ 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
+ 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x00, 0x61, 0x62, 0x63,
+ 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x00, 0x7c, 0x00, 0x7e, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/* The userinfo percent-encode set is the myurl_resources_static_map_path and code points "/", ":", ";", "=", "@", "[", "\", "]", "^", and "|". */
+static const unsigned char myurl_resources_static_map_userinfo[] =
+{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x00, 0x30, 0x31,
+ 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x42, 0x43, 0x44, 0x45,
+ 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
+ 0x5a, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x61, 0x62, 0x63,
+ 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
+ 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static const char *myurl_resources_static_map_digits = "0123456789abcdefghijklmnopqrstuvwxyz";
+
+#endif /* MyURL_RESOURCES_H */
diff --git a/include/myurl/scheme.h b/include/myurl/scheme.h
new file mode 100644
index 0000000..a500906
--- /dev/null
+++ b/include/myurl/scheme.h
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2016 Alexander Borisov
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyURL_SCHEME_H
+#define MyURL_SCHEME_H
+#pragma once
+
+#include <myurl/myosi.h>
+#include <myurl/scheme_const.h>
+#include <myhtml/utils.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum myurl_scheme_type {
+ MyURL_SCHEME_TYPE_UNDEF = 0x00,
+ MyURL_SCHEME_TYPE_SPECIAL = 0x01,
+ MyURL_SCHEME_TYPE_LOCAL = 0x02,
+ MyURL_SCHEME_TYPE_HTTP_S = 0x04,
+ MyURL_SCHEME_TYPE_NETWORK = 0x08,
+ MyURL_SCHEME_TYPE_FETCH = 0x10
+}
+typedef myurl_scheme_type_t;
+
+struct myurl_scheme {
+ char* name;
+ size_t length;
+ size_t port;
+
+ myurl_scheme_id_t sid;
+ myurl_scheme_type_t type;
+}
+typedef myurl_scheme_t;
+
+struct myurl_scheme_entry {
+ const char* name;
+ size_t name_length;
+
+ myurl_scheme_id_t m_id;
+ size_t port;
+ myurl_scheme_type_t type;
+
+ size_t next;
+ size_t curr;
+}
+typedef myurl_scheme_entry_t;
+
+void myurl_scheme_clean(myurl_t* url, myurl_scheme_t* scheme);
+myurl_scheme_t * myurl_scheme_destroy(myurl_t* url, myurl_scheme_t* scheme, bool self_destroy);
+
+const myurl_scheme_entry_t * myurl_scheme_find_entry(const char* name, size_t length);
+myurl_scheme_id_t myurl_scheme_id_by_name(const char *name, size_t length);
+
+myurl_status_t myurl_scheme_copy(myurl_t* url, myurl_scheme_t* from, myurl_scheme_t* to);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyURL_SCHEME_H */
diff --git a/include/myurl/scheme_const.h b/include/myurl/scheme_const.h
new file mode 100644
index 0000000..faf7e90
--- /dev/null
+++ b/include/myurl/scheme_const.h
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2016 Alexander Borisov
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyURL_SCHEME_CONST_H
+#define MyURL_SCHEME_CONST_H
+#pragma once
+
+enum myurl_scheme_id {
+ MyURL_SCHEME_ID_UNDEF = 0x0000,
+ MyURL_SCHEME_ID_ABOUT = 0x0001,
+ MyURL_SCHEME_ID_BLOB = 0x0002,
+ MyURL_SCHEME_ID_DATA = 0x0003,
+ MyURL_SCHEME_ID_FILE = 0x0004,
+ MyURL_SCHEME_ID_FILESYSTEM = 0x0005,
+ MyURL_SCHEME_ID_FTP = 0x0006,
+ MyURL_SCHEME_ID_GOPHER = 0x0007,
+ MyURL_SCHEME_ID_HTTP = 0x0008,
+ MyURL_SCHEME_ID_HTTPS = 0x0009,
+ MyURL_SCHEME_ID_WS = 0x000a,
+ MyURL_SCHEME_ID_WSS = 0x000b,
+ MyURL_SCHEME_ID_LAST_ENTRY = 0x000c
+}
+typedef myurl_scheme_id_t;
+
+
+#endif /* MyURL_SCHEME_CONST_H */
diff --git a/include/myurl/scheme_resources.h b/include/myurl/scheme_resources.h
new file mode 100644
index 0000000..740635d
--- /dev/null
+++ b/include/myurl/scheme_resources.h
@@ -0,0 +1,64 @@
+/*
+ Copyright (C) 2016 Alexander Borisov
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyURL_SCHEME_RESOURCES_H
+#define MyURL_SCHEME_RESOURCES_H
+#pragma once
+
+#define MyURL_SCHEME_STATIC_INDEX_LENGTH 31
+
+static const myurl_scheme_entry_t myurl_scheme_entry_static_index[] =
+{
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {"https", 5, MyURL_SCHEME_ID_HTTPS, 443, MyURL_SCHEME_TYPE_SPECIAL|MyURL_SCHEME_TYPE_HTTP_S, 0, 2},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {"blob", 4, MyURL_SCHEME_ID_BLOB, 0, MyURL_SCHEME_TYPE_LOCAL|MyURL_SCHEME_TYPE_FETCH, 0, 8},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {"file", 4, MyURL_SCHEME_ID_FILE, 0, MyURL_SCHEME_TYPE_SPECIAL|MyURL_SCHEME_TYPE_FETCH, 0, 10},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {"wss", 3, MyURL_SCHEME_ID_WSS, 443, MyURL_SCHEME_TYPE_SPECIAL, 0, 12},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {"filesystem", 10, MyURL_SCHEME_ID_FILESYSTEM, 0, MyURL_SCHEME_TYPE_LOCAL|MyURL_SCHEME_TYPE_FETCH, 0, 15},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {"ftp", 3, MyURL_SCHEME_ID_FTP, 21, MyURL_SCHEME_TYPE_SPECIAL|MyURL_SCHEME_TYPE_NETWORK, 0, 18},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {"data", 4, MyURL_SCHEME_ID_DATA, 0, MyURL_SCHEME_TYPE_LOCAL|MyURL_SCHEME_TYPE_FETCH, 0, 20},
+ {"gopher", 6, MyURL_SCHEME_ID_GOPHER, 70, MyURL_SCHEME_TYPE_SPECIAL, 0, 21},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {"about", 5, MyURL_SCHEME_ID_ABOUT, 0, MyURL_SCHEME_TYPE_LOCAL|MyURL_SCHEME_TYPE_FETCH, 0, 27},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {"ws", 2, MyURL_SCHEME_ID_WS, 80, MyURL_SCHEME_TYPE_SPECIAL, 0, 29},
+ {NULL, 0, MyURL_SCHEME_ID_UNDEF, 0, MyURL_SCHEME_TYPE_UNDEF, 0, 0},
+ {"http", 4, MyURL_SCHEME_ID_HTTP, 80, MyURL_SCHEME_TYPE_SPECIAL|MyURL_SCHEME_TYPE_HTTP_S, 0, 31},
+};
+
+
+#endif /* MyURL_SCHEME_RESOURCES_H */
diff --git a/include/myurl/serialization.h b/include/myurl/serialization.h
new file mode 100644
index 0000000..af1ef44
--- /dev/null
+++ b/include/myurl/serialization.h
@@ -0,0 +1,47 @@
+/*
+ Copyright (C) 2016-2017 Alexander Borisov
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyURL_SERIALIZATION_H
+#define MyURL_SERIALIZATION_H
+#pragma once
+
+#include <math.h>
+
+#include <myurl/myosi.h>
+#include <myurl/utils.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void myurl_serialization_authority(myurl_entry_t* url_entry, myhtml_callback_serialize_f callback, void* ctx);
+void myurl_serialization_host(myurl_entry_t* url_entry, myhtml_callback_serialize_f callback, void* ctx);
+void myurl_serialization_auth_host_port(myurl_entry_t* url_entry, myhtml_callback_serialize_f callback, void* ctx);
+void myurl_serialization_path(myurl_entry_t* url_entry, myhtml_callback_serialize_f callback, void* ctx);
+void myurl_serialization_fragment(myurl_entry_t* url_entry, myhtml_callback_serialize_f callback, void* ctx);
+void myurl_serialization_with_fragment(myurl_entry_t* url_entry, myhtml_callback_serialize_f callback, void* ctx);
+void myurl_serialization_without_fragment(myurl_entry_t* url_entry, myhtml_callback_serialize_f callback, void* ctx);
+void myurl_serialization(myurl_entry_t* url_entry, bool exclude_fragment_flag, myhtml_callback_serialize_f callback, void* ctx);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyURL_SERIALIZATION_H */
diff --git a/include/myurl/url.h b/include/myurl/url.h
new file mode 100644
index 0000000..4dd4231
--- /dev/null
+++ b/include/myurl/url.h
@@ -0,0 +1,195 @@
+/*
+ Copyright (C) 2016-2107 Alexander Borisov
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyURL_H
+#define MyURL_H
+#pragma once
+
+#include <myurl/myosi.h>
+#include <myhtml/mystring.h>
+#include <myurl/scheme.h>
+#include <myurl/host.h>
+#include <myurl/path.h>
+#include <myurl/utils.h>
+#include <myurl/serialization.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct myurl_entry {
+ myurl_scheme_t scheme;
+ myurl_host_t host;
+ myurl_path_t path;
+
+ char* username;
+ size_t username_length;
+
+ char* password;
+ size_t password_length;
+
+ unsigned int port;
+ bool port_is_set;
+
+ char* query;
+ size_t query_length;
+
+ char* fragment;
+ size_t fragment_length;
+
+ myurl_flags_t flags;
+ myurl_status_t status;
+
+ myurl_t* url_ref;
+};
+
+struct myhtml_url {
+ /* parser */
+ myurl_state_f state;
+ myurl_state_f state_override;
+ myhtml_encoding_t encoding;
+
+ /* memory */
+ myurl_callback_malloc_f callback_malloc;
+ myurl_callback_realloc_f callback_realloc;
+ myurl_callback_free_f callback_free;
+ void* callback_ctx;
+
+ /* work variables */
+ size_t begin;
+ /* if URL include '\t' or '\n',
+ then buffer copied removing all '\t' and '\n' */
+ char *copy;
+};
+
+myurl_t * myurl_create(void);
+myurl_status_t myurl_init(myurl_t* url);
+void myurl_clean(myurl_t* url);
+myurl_t * myurl_destroy(myurl_t* url, bool self_destroy);
+
+myurl_entry_t * myurl_parse(myurl_t* url, const char* data_url, size_t data_url_size, myurl_entry_t* base_url, myurl_status_t* status);
+
+myurl_entry_t * myurl_entry_create_and_init(myurl_t* url);
+void myurl_entry_clean(myurl_entry_t* url_entry);
+myurl_entry_t * myurl_entry_destroy(myurl_entry_t* url_entry, bool self_destroy);
+
+/* api */
+/* callback */
+void myurl_callback_memory_set(myurl_t* url, myurl_callback_malloc_f callback_malloc, myurl_callback_realloc_f callback_realloc, myurl_callback_free_f callback_free, void* ctx);
+void * myurl_callback_memory_context(myurl_t* url);
+
+/* api entry */
+/* for read */
+myurl_status_t myurl_entry_status(myurl_entry_t* url_entry);
+myurl_flags_t myurl_entry_flags(myurl_entry_t* url_entry);
+myurl_t * myurl_entry_url(myurl_entry_t* url_entry);
+
+/* don't forget call 'myurl_entry_free_string' after use */
+char * myurl_entry_as_string(myurl_entry_t* url_entry, size_t *length);
+
+/* scheme */
+myurl_scheme_t * myurl_entry_scheme(myurl_entry_t* url_entry);
+const char * myurl_entry_scheme_name(myurl_entry_t* url_entry, size_t* length);
+unsigned int myurl_entry_scheme_port(myurl_entry_t* url_entry);
+myurl_scheme_id_t myurl_entry_scheme_id(myurl_entry_t* url_entry);
+myurl_scheme_type_t myurl_entry_scheme_type(myurl_entry_t* url_entry);
+
+/* authority */
+/* don't forget call 'myurl_entry_free_string' after use */
+char * myurl_entry_authority_as_string(myurl_entry_t* url_entry, size_t* length);
+
+const char * myurl_entry_username(myurl_entry_t* url_entry, size_t* length);
+const char * myurl_entry_password(myurl_entry_t* url_entry, size_t* length);
+
+/* host */
+myurl_host_t * myurl_entry_host(myurl_entry_t* url_entry);
+
+/* don't forget call 'myurl_entry_free_string' after use */
+char * myurl_entry_host_as_string(myurl_entry_t* url_entry, size_t *length);
+
+myurl_host_type_t myurl_entry_host_type(myurl_entry_t* url_entry);
+const char * myurl_entry_host_domain(myurl_entry_t* url_entry, size_t* length);
+const char * myurl_entry_host_opaque(myurl_entry_t* url_entry, size_t* length);
+unsigned int myurl_entry_host_ipv4(myurl_entry_t* url_entry);
+unsigned int * myurl_entry_host_ipv6(myurl_entry_t* url_entry);
+
+/* port */
+bool myurl_entry_port_is_defined(myurl_entry_t* url_entry);
+unsigned int myurl_entry_port(myurl_entry_t* url_entry);
+
+/* path */
+myurl_path_t * myurl_entry_path(myurl_entry_t* url_entry);
+
+/* don't forget call 'myurl_entry_free_string' after use */
+char * myurl_entry_path_as_string(myurl_entry_t* url_entry, size_t* length);
+
+size_t myurl_entry_path_length(myurl_entry_t* url_entry);
+const char * myurl_entry_path_entry(myurl_entry_t* url_entry, size_t index, size_t* length);
+
+/* query */
+const char * myurl_entry_query(myurl_entry_t* url_entry, size_t* length);
+
+/* fragment */
+const char * myurl_entry_fragment(myurl_entry_t* url_entry, size_t* length);
+
+/*
+ For changes
+*/
+/* scheme */
+const char * myurl_entry_scheme_name_set(myurl_entry_t* url_entry, const char* name, size_t length);
+void myurl_entry_scheme_port_set(myurl_entry_t* url_entry, unsigned int port);
+void myurl_entry_scheme_id_set(myurl_entry_t* url_entry, myurl_scheme_id_t sid);
+void myurl_entry_scheme_type_set(myurl_entry_t* url_entry, myurl_scheme_type_t type);
+void myurl_entry_scheme_clean(myurl_entry_t* url_entry);
+
+/* authority */
+const char * myurl_entry_username_set(myurl_entry_t* url_entry, const char* username, size_t length);
+const char * myurl_entry_password_set(myurl_entry_t* url_entry, const char* password, size_t length);
+
+/* host */
+myurl_status_t myurl_entry_host_set(myurl_entry_t* url_entry, const char* host, size_t length);
+
+/* port */
+void myurl_entry_port_set(myurl_entry_t* url_entry, unsigned int port);
+
+/* path */
+myurl_status_t myurl_entry_path_set(myurl_entry_t* url_entry, const char* path, size_t length);
+myurl_status_t myurl_entry_path_append_entry(myurl_entry_t* url_entry, const char* entry, size_t length);
+void myurl_entry_path_pop_entry(myurl_entry_t* url_entry);
+myurl_status_t myurl_entry_path_replace_entry(myurl_entry_t* url_entry, size_t index, const char* entry, size_t length);
+void myurl_entry_path_remove_entry(myurl_entry_t* url_entry, size_t index);
+void myurl_entry_path_clean(myurl_entry_t* url_entry);
+
+/* query */
+const char * myurl_entry_query_set(myurl_entry_t* url_entry, const char* query, size_t length);
+
+/* fragment */
+const char * myurl_entry_fragment_set(myurl_entry_t* url_entry, const char* fragment, size_t length);
+
+/* for free resources for char* */
+void myurl_entry_free_string(myurl_entry_t* url_entry, char* string);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyURL_H */
+
+
diff --git a/include/myurl/utils.h b/include/myurl/utils.h
new file mode 100644
index 0000000..3aa29ba
--- /dev/null
+++ b/include/myurl/utils.h
@@ -0,0 +1,73 @@
+/*
+ Copyright (C) 2016 Alexander Borisov
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyURL_UTILS_H
+#define MyURL_UTILS_H
+#pragma once
+
+typedef struct myurl_utils_data_list myurl_utils_data_list_t;
+
+#include <myurl/myosi.h>
+#include <myurl/parser.h>
+#include <myhtml/mystring.h>
+
+#include <math.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct myurl_utils_serialization_ctx {
+ char* data;
+ size_t size;
+ size_t length;
+
+ myurl_t* url;
+ bool error;
+}
+typedef myurl_utils_serialization_ctx_t;
+
+char * myurl_utils_data_copy(myurl_t* url, const char* data, size_t size);
+myurl_status_t myurl_utils_data_copy_set(myurl_t* url, const char* data, size_t size, char** to, size_t* to_length);
+myurl_status_t myurl_utils_data_copy_append(myurl_t* url, const char* data, size_t size, char** to, size_t* to_length);
+void myurl_utils_data_set_null(myurl_t* url, char** to, size_t* length);
+void myurl_utils_data_set_empty(myurl_t* url, char** to, size_t* length);
+char * myurl_utils_percent_encode(myurl_t* url, const char* data, size_t size, const unsigned char* encode_set, size_t* return_length);
+size_t myurl_utils_percent_decode_bytes_in_data(char* data, size_t size);
+
+bool myurl_utils_is_windows_drive_letter(const char* data, size_t length, size_t size);
+bool myurl_utils_is_double_dot_path_segment(const char* data, size_t length);
+bool myurl_utils_is_single_dot_path_segment(const char* data, size_t length);
+
+size_t myurl_convert_integer_to_data_without_check_buffer(long digit, char* return_str);
+size_t myurl_convert_integer_to_hex_data_without_check_buffer(long digit, char* return_str);
+
+//void myurl_utils_data_set(myurl_parser_t* parser, myurl_parser_data_t* parse_data, const unsigned char* data, size_t length);
+//void myurl_utils_data_append(myurl_parser_t* parser, myurl_parser_data_t* parse_data, const unsigned char* data, size_t length);
+//void myurl_utils_data_copy(myurl_parser_t* parser, myurl_parser_data_t* to, const myurl_parser_data_t* from);
+//void myurl_utils_data_destroy(myurl_parser_t* parser, myurl_parser_data_t* parse_data, bool self_destroy);
+
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyURL_UTILS_H */
diff --git a/source/myurl/parser.c b/source/myurl/parser.c
index 680f9e5..96230a6 100644
--- a/source/myurl/parser.c
+++ b/source/myurl/parser.c
@@ -212,7 +212,7 @@ size_t myurl_parser_state_scheme(myurl_t* url, myurl_entry_t* url_entry, myurl_e
{
/* 1 and 4 */
if(myurl_parser_alphanumeric(data[data_length]) == false &&
- data[data_length] != '+' && data[data_length] != '-' & data[data_length] != '.')
+ data[data_length] != '+' && data[data_length] != '-' && data[data_length] != '.')
{
/* 2 */
if(data[data_length] == ':')
diff --git a/source/myurl/url.h b/source/myurl/url.h
index 7ed24ac..93659f8 100644
--- a/source/myurl/url.h
+++ b/source/myurl/url.h
@@ -22,10 +22,6 @@
#define MyURL_H
#pragma once
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include "myurl/myosi.h"
#include "myhtml/mystring.h"
#include "myurl/scheme.h"
@@ -34,6 +30,10 @@ extern "C" {
#include "myurl/utils.h"
#include "myurl/serialization.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct myurl_entry {
myurl_scheme_t scheme;
myurl_host_t host;