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-21 09:56:42 +0300
committerlexborisov <lex.borisov@gmail.com>2017-03-21 09:56:42 +0300
commit7024458c55c0baedfb29c2f9db213d3b0474c851 (patch)
tree7ec10676fc5a24bffed67d9f6f89ba14130ea781
parent0708dba577f51a9cb504db1feeb094aa9badd795 (diff)
Merge branch 'master' into coverity_scancoverity_scan
-rw-r--r--.gitignore5
-rw-r--r--.travis.yml15
-rw-r--r--CHANGELOG.mdbin696 -> 2687 bytes
-rw-r--r--INSTALL.md70
-rw-r--r--Makefile255
-rw-r--r--Makefile.bin.cfg53
-rw-r--r--Makefile.cfg151
-rw-r--r--README.md16
-rw-r--r--_config.yml1
-rw-r--r--api_breaking_changes.md7
-rw-r--r--devel/osx/Modest.xcodeproj/project.pbxproj393
-rw-r--r--devel/osx/Modest.xcodeproj/project.xcworkspace/xcuserdata/alexanderborisov.xcuserdatad/UserInterfaceState.xcuserstatebin134284 -> 149809 bytes
-rw-r--r--devel/osx/Modest.xcodeproj/xcuserdata/alexanderborisov.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist18
-rw-r--r--devel/osx/Modest.xcodeproj/xcuserdata/alexanderborisov.xcuserdatad/xcschemes/Modest.xcscheme1
-rw-r--r--devel/osx/Modest/main.c2306
-rw-r--r--documents/myhtml_life_cycle.xml1
-rw-r--r--documents/myhtml_life_cycle_with_thread.pngbin132726 -> 0 bytes
-rw-r--r--documents/myhtml_life_cycle_without_threads.pngbin56440 -> 0 bytes
-rw-r--r--documents/myhtml_life_cycle_without_threads.xml1
-rw-r--r--examples/Makefile103
-rw-r--r--examples/modest/Makefile.mk7
-rw-r--r--examples/modest/css_property_to_node.c13
-rw-r--r--examples/modest/css_real_and_default_property_to_node.c13
-rw-r--r--examples/modest/selectors_find_nodes_low_level.c17
-rw-r--r--examples/modest/selectors_prepare_low_level.c17
-rw-r--r--examples/modest/style_attr_low_level.c11
-rw-r--r--examples/mycss/Makefile.mk7
-rw-r--r--examples/mycss/css_low_level.c11
-rw-r--r--examples/mycss/declaration_low_level.c9
-rw-r--r--examples/mycss/detect_charset_encoding_high_level.c4
-rw-r--r--examples/mycss/example.h32
-rw-r--r--examples/mycss/incoming_buffer_high_level.c28
-rw-r--r--examples/mycss/selectors_low_level.c9
-rw-r--r--examples/mycss/stylesheet_low_level.c7
-rw-r--r--examples/mycss/token_type_convert_high_level.c20
-rw-r--r--examples/mycss/tokenizer_buffer_high_level.c16
-rw-r--r--examples/mycss/tokenizer_chunk_high_level.c10
-rw-r--r--examples/mycss/tokenizer_high_level.c8
-rw-r--r--examples/myencoding/Makefile.mk7
-rw-r--r--examples/myencoding/detect_encoding_by_trigrams.c (renamed from examples/myhtml/detect_encoding_high_level.c)33
-rw-r--r--examples/myencoding/detect_encoding_in_meta.c (renamed from examples/myhtml/detect_encoding_in_meta_high_level.c)13
-rw-r--r--examples/myencoding/encoding_by_name.c (renamed from examples/myhtml/encoding_by_name_high_level.c)8
-rw-r--r--examples/myencoding/example.h32
-rw-r--r--examples/myfont/Makefile.mk7
-rw-r--r--examples/myfont/glyph_metrics.c20
-rw-r--r--examples/myhtml/Makefile.mk7
-rw-r--r--examples/myhtml/attributes_high_level.c15
-rw-r--r--examples/myhtml/callback_tree_node_high_level.c6
-rw-r--r--examples/myhtml/chunks_high_level.c11
-rw-r--r--examples/myhtml/custom_tree_high_level.c22
-rw-r--r--examples/myhtml/example.h32
-rw-r--r--examples/myhtml/fragment_high_level.c9
-rw-r--r--examples/myhtml/get_title_high_level.c6
-rw-r--r--examples/myhtml/get_title_low_level.c10
-rw-r--r--examples/myhtml/html2sexpr.c8
-rw-r--r--examples/myhtml/insert_in_appropriate_place_high_level.c9
-rw-r--r--examples/myhtml/modify_and_serialize.c9
-rw-r--r--examples/myhtml/nodes_by_attr_key_high_level.c16
-rw-r--r--examples/myhtml/nodes_by_attr_value_high_level.c16
-rw-r--r--examples/myhtml/parse_without_whitespace.c14
-rw-r--r--examples/myhtml/print_tree_high_level.c6
-rw-r--r--examples/myhtml/serialization_high_level.c12
-rw-r--r--examples/myhtml/string_manipulate_high_level.c19
-rw-r--r--examples/myhtml/tokenizer_colorize_high_level.c18
-rw-r--r--examples/myhtml/tokenizer_colorize_low_level.c14
-rw-r--r--examples/myurl/Makefile.mk7
-rw-r--r--examples/myurl/url_data.c51
-rw-r--r--examples/myurl/url_parse.c72
-rw-r--r--examples/myurl/url_relative.c56
-rw-r--r--include/modest/declaration.h2
-rw-r--r--include/modest/finder/finder.h6
-rw-r--r--include/modest/finder/match.h2
-rw-r--r--include/modest/finder/myosi.h2
-rw-r--r--include/modest/finder/pseudo_class.h2
-rw-r--r--include/modest/finder/resource.h2
-rw-r--r--include/modest/finder/thread.h13
-rw-r--r--include/modest/finder/type.h4
-rw-r--r--include/modest/glue.h2
-rw-r--r--include/modest/layer/layer.h6
-rw-r--r--include/modest/modest.h14
-rw-r--r--include/modest/myosi.h17
-rw-r--r--include/modest/node/node.h8
-rw-r--r--include/modest/node/property.h2
-rw-r--r--include/modest/node/raw_property.h2
-rw-r--r--include/modest/node/serialization.h6
-rw-r--r--include/modest/render/begin.h2
-rw-r--r--include/modest/render/binding.h2
-rw-r--r--include/modest/render/tree.h8
-rw-r--r--include/modest/render/tree_node.h6
-rw-r--r--include/modest/style/default.h2
-rw-r--r--include/modest/style/default_entries.h2
-rw-r--r--include/modest/style/default_resources.h2
-rw-r--r--include/modest/style/map.h2
-rw-r--r--include/modest/style/map_resource.h2
-rw-r--r--include/modest/style/raw.h4
-rw-r--r--include/modest/style/sheet.h4
-rw-r--r--include/modest/style/type.h6
-rw-r--r--include/mycore/incoming.h (renamed from source/myhtml/incoming.h)49
-rw-r--r--include/mycore/myosi.h169
-rw-r--r--include/mycore/mystring.h125
-rw-r--r--include/mycore/mythread.h159
-rw-r--r--include/mycore/perf.h49
-rw-r--r--include/mycore/thread_queue.h110
-rw-r--r--include/mycore/utils.h (renamed from include/myhtml/utils.h)23
-rw-r--r--include/mycore/utils/avl_tree.h68
-rw-r--r--include/mycore/utils/mchar_async.h (renamed from include/myhtml/utils/mchar_async.h)20
-rw-r--r--include/mycore/utils/mcobject.h (renamed from source/myhtml/utils/mcobject.h)18
-rw-r--r--include/mycore/utils/mcobject_async.h (renamed from source/myhtml/utils/mcobject_async.h)10
-rw-r--r--include/mycore/utils/mcsimple.h (renamed from include/myhtml/utils/mcsimple.h)10
-rw-r--r--include/mycore/utils/mcsync.h (renamed from include/myhtml/utils/mcsync.h)62
-rw-r--r--include/mycore/utils/mctree.h (renamed from source/myhtml/utils/mctree.h)22
-rw-r--r--include/mycore/utils/mhash.h75
-rw-r--r--include/mycore/utils/resources.h (renamed from include/myhtml/utils/resources.h)126
-rw-r--r--include/mycss/an_plus_b.h8
-rw-r--r--include/mycss/api.h59
-rw-r--r--include/mycss/check.h2
-rw-r--r--include/mycss/convert.h4
-rw-r--r--include/mycss/declaration/default.h2
-rw-r--r--include/mycss/declaration/default_entries.h2
-rw-r--r--include/mycss/declaration/default_resources.h2
-rw-r--r--include/mycss/declaration/entry.h4
-rw-r--r--include/mycss/declaration/entry_destroy.h2
-rw-r--r--include/mycss/declaration/entry_destroy_resources.h2
-rw-r--r--include/mycss/declaration/init.h8
-rw-r--r--include/mycss/declaration/myosi.h4
-rw-r--r--include/mycss/declaration/parser.h2
-rw-r--r--include/mycss/declaration/serialization.h48
-rw-r--r--include/mycss/declaration/serialization_resources.h2
-rw-r--r--include/mycss/declaration/state.h2
-rw-r--r--include/mycss/entry.h26
-rw-r--r--include/mycss/media/init.h6
-rw-r--r--include/mycss/media/myosi.h3
-rw-r--r--include/mycss/media/state.h2
-rw-r--r--include/mycss/mycss.h36
-rw-r--r--include/mycss/myosi.h13
-rw-r--r--include/mycss/mystring.h25
-rw-r--r--include/mycss/namespace/init.h12
-rw-r--r--include/mycss/namespace/myosi.h10
-rw-r--r--include/mycss/namespace/parser.h4
-rw-r--r--include/mycss/namespace/serialization.h6
-rw-r--r--include/mycss/namespace/state.h4
-rw-r--r--include/mycss/parser.h4
-rw-r--r--include/mycss/property/const.h2
-rw-r--r--include/mycss/property/init.h4
-rw-r--r--include/mycss/property/myosi.h2
-rw-r--r--include/mycss/property/parser.h4
-rw-r--r--include/mycss/property/resources.h2
-rw-r--r--include/mycss/property/resources_name.h2
-rw-r--r--include/mycss/property/serialization.h6
-rw-r--r--include/mycss/property/shared.h66
-rw-r--r--include/mycss/selectors/function.h2
-rw-r--r--include/mycss/selectors/function_parser.h2
-rw-r--r--include/mycss/selectors/function_resource.h2
-rw-r--r--include/mycss/selectors/init.h10
-rw-r--r--include/mycss/selectors/list.h2
-rw-r--r--include/mycss/selectors/myosi.h6
-rw-r--r--include/mycss/selectors/myosi_resource.h2
-rw-r--r--include/mycss/selectors/parser.h2
-rw-r--r--include/mycss/selectors/pseudo.h2
-rw-r--r--include/mycss/selectors/pseudo_resource.h2
-rw-r--r--include/mycss/selectors/serialization.h8
-rw-r--r--include/mycss/selectors/state.h4
-rw-r--r--include/mycss/selectors/value.h10
-rw-r--r--include/mycss/selectors/value_resource.h2
-rw-r--r--include/mycss/stack.h6
-rw-r--r--include/mycss/stylesheet.h8
-rw-r--r--include/mycss/tokenizer.h12
-rw-r--r--include/mycss/tokenizer_end.h2
-rw-r--r--include/mycss/tokenizer_global.h2
-rw-r--r--include/mycss/tokenizer_resource.h2
-rw-r--r--include/mycss/values/color.h2
-rw-r--r--include/mycss/values/color_const.h2
-rw-r--r--include/mycss/values/color_parser.h4
-rw-r--r--include/mycss/values/color_resources.h2
-rw-r--r--include/mycss/values/consume.h2
-rw-r--r--include/mycss/values/destroy.h2
-rw-r--r--include/mycss/values/image.h2
-rw-r--r--include/mycss/values/image_resources.h2
-rw-r--r--include/mycss/values/resources.h2
-rw-r--r--include/mycss/values/serialization.h32
-rw-r--r--include/mycss/values/units.h4
-rw-r--r--include/mycss/values/units_resources.h2
-rw-r--r--include/mycss/values/values.h48
-rw-r--r--include/myencoding/detect_resource.h (renamed from include/myhtml/encoding_detect_resource.h)454
-rw-r--r--include/myencoding/encoding.h160
-rw-r--r--include/myencoding/myosi.h114
-rw-r--r--include/myencoding/mystring.h48
-rw-r--r--include/myencoding/resource.h (renamed from include/myhtml/encoding_resource.h)153
-rw-r--r--include/myfont/cmap.h6
-rw-r--r--include/myfont/glyf.h14
-rw-r--r--include/myfont/head.h6
-rw-r--r--include/myfont/hhea.h4
-rw-r--r--include/myfont/hmtx.h4
-rw-r--r--include/myfont/loca.h6
-rw-r--r--include/myfont/maxp.h4
-rw-r--r--include/myfont/myfont.h33
-rw-r--r--include/myfont/myosi.h3
-rw-r--r--include/myfont/name.h6
-rw-r--r--include/myfont/os_2.h6
-rw-r--r--include/myfont/pclt.h4
-rw-r--r--include/myfont/vhea.h4
-rw-r--r--include/myfont/vmtx.h4
-rwxr-xr-xinclude/myhtml/api.h578
-rw-r--r--include/myhtml/api_encoding.h71
-rw-r--r--include/myhtml/callback.h2
-rw-r--r--include/myhtml/charef.h2
-rw-r--r--include/myhtml/charef_resource.h2
-rw-r--r--include/myhtml/data_process.h24
-rw-r--r--include/myhtml/def.h2
-rw-r--r--include/myhtml/encoding.h163
-rw-r--r--include/myhtml/myhtml.h97
-rw-r--r--include/myhtml/mynamespace.h4
-rw-r--r--include/myhtml/mynamespace_resource.h2
-rw-r--r--include/myhtml/myosi.h260
-rw-r--r--include/myhtml/mystring.h128
-rw-r--r--include/myhtml/parser.h8
-rw-r--r--include/myhtml/rules.h6
-rw-r--r--include/myhtml/serialization.h14
-rw-r--r--include/myhtml/stream.h8
-rw-r--r--include/myhtml/tag.h20
-rw-r--r--include/myhtml/tag_const.h2
-rw-r--r--include/myhtml/thread.h224
-rw-r--r--include/myhtml/token.h26
-rw-r--r--include/myhtml/tokenizer.h18
-rw-r--r--include/myhtml/tokenizer_doctype.h4
-rw-r--r--include/myhtml/tokenizer_end.h2
-rw-r--r--include/myhtml/tokenizer_script.h4
-rw-r--r--include/myhtml/tree.h46
-rw-r--r--include/myhtml/utils/avl_tree.h68
-rw-r--r--include/myhtml/utils/mhash.h65
-rw-r--r--include/myunicode/myosi.h35
-rw-r--r--include/myurl/host.h105
-rw-r--r--include/myurl/myosi.h83
-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--modest.pc.in10
-rw-r--r--projects/CMakeLists.txt205
-rw-r--r--source/modest/Makefile.mk21
-rw-r--r--source/modest/declaration.c2
-rw-r--r--source/modest/declaration.h2
-rw-r--r--source/modest/finder/finder.c16
-rw-r--r--source/modest/finder/finder.h6
-rw-r--r--source/modest/finder/match.c69
-rw-r--r--source/modest/finder/match.h2
-rw-r--r--source/modest/finder/myosi.h2
-rw-r--r--source/modest/finder/pseudo_class.c16
-rw-r--r--source/modest/finder/pseudo_class.h2
-rw-r--r--source/modest/finder/resource.h2
-rw-r--r--source/modest/finder/thread.c157
-rw-r--r--source/modest/finder/thread.h13
-rw-r--r--source/modest/finder/type.c4
-rw-r--r--source/modest/finder/type.h4
-rw-r--r--source/modest/glue.c2
-rw-r--r--source/modest/glue.h2
-rw-r--r--source/modest/layer/layer.c2
-rw-r--r--source/modest/layer/layer.h6
-rw-r--r--source/modest/modest.c28
-rw-r--r--source/modest/modest.h14
-rw-r--r--source/modest/myosi.h17
-rw-r--r--source/modest/node/node.c12
-rw-r--r--source/modest/node/node.h8
-rw-r--r--source/modest/node/property.c2
-rw-r--r--source/modest/node/property.h2
-rw-r--r--source/modest/node/raw_property.c2
-rw-r--r--source/modest/node/raw_property.h2
-rw-r--r--source/modest/node/serialization.c12
-rw-r--r--source/modest/node/serialization.h6
-rw-r--r--source/modest/render/begin.c2
-rw-r--r--source/modest/render/begin.h2
-rw-r--r--source/modest/render/binding.c2
-rw-r--r--source/modest/render/binding.h2
-rw-r--r--source/modest/render/tree.c12
-rw-r--r--source/modest/render/tree.h8
-rw-r--r--source/modest/render/tree_node.c4
-rw-r--r--source/modest/render/tree_node.h6
-rw-r--r--source/modest/style/default.c2
-rw-r--r--source/modest/style/default.h2
-rw-r--r--source/modest/style/default_entries.h2
-rw-r--r--source/modest/style/default_resources.h2
-rw-r--r--source/modest/style/map.c2
-rw-r--r--source/modest/style/map.h2
-rw-r--r--source/modest/style/map_resource.h2
-rw-r--r--source/modest/style/raw.c2
-rw-r--r--source/modest/style/raw.h4
-rw-r--r--source/modest/style/sheet.c4
-rw-r--r--source/modest/style/sheet.h4
-rw-r--r--source/modest/style/type.c4
-rw-r--r--source/modest/style/type.h6
-rw-r--r--source/mycore/Makefile.mk13
-rw-r--r--source/mycore/incoming.c (renamed from source/myhtml/incoming.c)58
-rw-r--r--source/mycore/incoming.h (renamed from include/myhtml/incoming.h)49
-rw-r--r--source/mycore/myosi.c22
-rw-r--r--source/mycore/myosi.h169
-rw-r--r--source/mycore/mystring.c319
-rw-r--r--source/mycore/mystring.h125
-rw-r--r--source/mycore/mythread.c331
-rw-r--r--source/mycore/mythread.h159
-rw-r--r--source/mycore/perf.h49
-rw-r--r--source/mycore/thread_queue.c654
-rw-r--r--source/mycore/thread_queue.h110
-rw-r--r--source/mycore/utils.c (renamed from source/myhtml/utils.c)68
-rw-r--r--source/mycore/utils.h (renamed from source/myhtml/utils.h)23
-rw-r--r--source/mycore/utils/avl_tree.c (renamed from source/myhtml/utils/avl_tree.c)128
-rw-r--r--source/mycore/utils/avl_tree.h68
-rw-r--r--source/mycore/utils/mchar_async.c (renamed from source/myhtml/utils/mchar_async.c)157
-rw-r--r--source/mycore/utils/mchar_async.h (renamed from source/myhtml/utils/mchar_async.h)20
-rw-r--r--source/mycore/utils/mcobject.c (renamed from source/myhtml/utils/mcobject.c)52
-rw-r--r--source/mycore/utils/mcobject.h (renamed from include/myhtml/utils/mcobject.h)18
-rw-r--r--source/mycore/utils/mcobject_async.c (renamed from source/myhtml/utils/mcobject_async.c)63
-rw-r--r--source/mycore/utils/mcobject_async.h (renamed from include/myhtml/utils/mcobject_async.h)10
-rw-r--r--source/mycore/utils/mcsimple.c (renamed from source/myhtml/utils/mcsimple.c)18
-rw-r--r--source/mycore/utils/mcsimple.h (renamed from source/myhtml/utils/mcsimple.h)10
-rw-r--r--source/mycore/utils/mcsync.c99
-rw-r--r--source/mycore/utils/mcsync.h (renamed from source/myhtml/utils/mcsync.h)62
-rw-r--r--source/mycore/utils/mctree.c (renamed from source/myhtml/utils/mctree.c)25
-rw-r--r--source/mycore/utils/mctree.h (renamed from include/myhtml/utils/mctree.h)22
-rw-r--r--source/mycore/utils/mhash.c (renamed from source/myhtml/utils/mhash.c)98
-rw-r--r--source/mycore/utils/mhash.h75
-rw-r--r--source/mycore/utils/resources.h (renamed from source/myhtml/utils/resources.h)126
-rw-r--r--source/mycss/Makefile.mk19
-rw-r--r--source/mycss/an_plus_b.c114
-rw-r--r--source/mycss/an_plus_b.h8
-rw-r--r--source/mycss/api.h59
-rw-r--r--source/mycss/check.c8
-rw-r--r--source/mycss/check.h2
-rw-r--r--source/mycss/convert.c18
-rw-r--r--source/mycss/convert.h4
-rw-r--r--source/mycss/declaration/default.c2
-rw-r--r--source/mycss/declaration/default.h2
-rw-r--r--source/mycss/declaration/default_entries.h2
-rw-r--r--source/mycss/declaration/default_resources.h2
-rw-r--r--source/mycss/declaration/entry.c4
-rw-r--r--source/mycss/declaration/entry.h4
-rw-r--r--source/mycss/declaration/entry_destroy.c2
-rw-r--r--source/mycss/declaration/entry_destroy.h2
-rw-r--r--source/mycss/declaration/entry_destroy_resources.h2
-rw-r--r--source/mycss/declaration/init.c14
-rw-r--r--source/mycss/declaration/init.h8
-rw-r--r--source/mycss/declaration/myosi.h4
-rw-r--r--source/mycss/declaration/parser.c6
-rw-r--r--source/mycss/declaration/parser.h2
-rw-r--r--source/mycss/declaration/serialization.c60
-rw-r--r--source/mycss/declaration/serialization.h48
-rw-r--r--source/mycss/declaration/serialization_resources.h2
-rw-r--r--source/mycss/declaration/state.c10
-rw-r--r--source/mycss/declaration/state.h2
-rw-r--r--source/mycss/entry.c64
-rw-r--r--source/mycss/entry.h26
-rw-r--r--source/mycss/media/init.c10
-rw-r--r--source/mycss/media/init.h6
-rw-r--r--source/mycss/media/myosi.h3
-rw-r--r--source/mycss/media/state.h2
-rw-r--r--source/mycss/mycss.c48
-rw-r--r--source/mycss/mycss.h36
-rw-r--r--source/mycss/myosi.h13
-rw-r--r--source/mycss/mystring.c74
-rw-r--r--source/mycss/mystring.h25
-rw-r--r--source/mycss/namespace/init.c44
-rw-r--r--source/mycss/namespace/init.h12
-rw-r--r--source/mycss/namespace/myosi.h10
-rw-r--r--source/mycss/namespace/parser.c10
-rw-r--r--source/mycss/namespace/parser.h4
-rw-r--r--source/mycss/namespace/serialization.c8
-rw-r--r--source/mycss/namespace/serialization.h6
-rw-r--r--source/mycss/namespace/state.c16
-rw-r--r--source/mycss/namespace/state.h4
-rw-r--r--source/mycss/parser.c8
-rw-r--r--source/mycss/parser.h4
-rw-r--r--source/mycss/property/const.h2
-rw-r--r--source/mycss/property/init.c16
-rw-r--r--source/mycss/property/init.h4
-rw-r--r--source/mycss/property/myosi.h2
-rw-r--r--source/mycss/property/parser.c140
-rw-r--r--source/mycss/property/parser.h4
-rw-r--r--source/mycss/property/parser_background.c46
-rw-r--r--source/mycss/property/parser_image.c40
-rw-r--r--source/mycss/property/parser_text_decoration.c16
-rw-r--r--source/mycss/property/parser_url.c4
-rw-r--r--source/mycss/property/resources.h2
-rw-r--r--source/mycss/property/resources_name.h2
-rw-r--r--source/mycss/property/serialization.c6
-rw-r--r--source/mycss/property/serialization.h6
-rw-r--r--source/mycss/property/shared.c108
-rw-r--r--source/mycss/property/shared.h66
-rw-r--r--source/mycss/selectors/function.c10
-rw-r--r--source/mycss/selectors/function.h2
-rw-r--r--source/mycss/selectors/function_parser.c20
-rw-r--r--source/mycss/selectors/function_parser.h2
-rw-r--r--source/mycss/selectors/function_resource.h2
-rw-r--r--source/mycss/selectors/init.c20
-rw-r--r--source/mycss/selectors/init.h10
-rw-r--r--source/mycss/selectors/list.c2
-rw-r--r--source/mycss/selectors/list.h2
-rw-r--r--source/mycss/selectors/myosi.h6
-rw-r--r--source/mycss/selectors/myosi_resource.h2
-rw-r--r--source/mycss/selectors/parser.c32
-rw-r--r--source/mycss/selectors/parser.h2
-rw-r--r--source/mycss/selectors/pseudo.c10
-rw-r--r--source/mycss/selectors/pseudo.h2
-rw-r--r--source/mycss/selectors/pseudo_resource.h2
-rw-r--r--source/mycss/selectors/serialization.c14
-rw-r--r--source/mycss/selectors/serialization.h8
-rw-r--r--source/mycss/selectors/state.c44
-rw-r--r--source/mycss/selectors/state.h4
-rw-r--r--source/mycss/selectors/value.c22
-rw-r--r--source/mycss/selectors/value.h10
-rw-r--r--source/mycss/selectors/value_resource.h2
-rw-r--r--source/mycss/stack.c16
-rw-r--r--source/mycss/stack.h6
-rw-r--r--source/mycss/stylesheet.c16
-rw-r--r--source/mycss/stylesheet.h8
-rw-r--r--source/mycss/tokenizer.c42
-rw-r--r--source/mycss/tokenizer.h12
-rw-r--r--source/mycss/tokenizer_end.c2
-rw-r--r--source/mycss/tokenizer_end.h2
-rw-r--r--source/mycss/tokenizer_global.c8
-rw-r--r--source/mycss/tokenizer_global.h2
-rw-r--r--source/mycss/tokenizer_resource.h2
-rw-r--r--source/mycss/values/color.c16
-rw-r--r--source/mycss/values/color.h2
-rw-r--r--source/mycss/values/color_const.h2
-rw-r--r--source/mycss/values/color_parser.c152
-rw-r--r--source/mycss/values/color_parser.h4
-rw-r--r--source/mycss/values/color_resources.h2
-rw-r--r--source/mycss/values/consume.c20
-rw-r--r--source/mycss/values/consume.h2
-rw-r--r--source/mycss/values/destroy.c40
-rw-r--r--source/mycss/values/destroy.h2
-rw-r--r--source/mycss/values/image.c30
-rw-r--r--source/mycss/values/image.h2
-rw-r--r--source/mycss/values/image_resources.h2
-rw-r--r--source/mycss/values/resources.h2
-rw-r--r--source/mycss/values/serialization.c188
-rw-r--r--source/mycss/values/serialization.h32
-rw-r--r--source/mycss/values/units.c10
-rw-r--r--source/mycss/values/units.h4
-rw-r--r--source/mycss/values/units_resources.h2
-rw-r--r--source/mycss/values/values.c2
-rw-r--r--source/mycss/values/values.h48
-rw-r--r--source/myencoding/Makefile.mk13
-rw-r--r--source/myencoding/detect.c (renamed from source/myhtml/encoding_detect.c)233
-rw-r--r--source/myencoding/detect_resource.h (renamed from source/myhtml/encoding_detect_resource.h)454
-rw-r--r--source/myencoding/encoding.c (renamed from source/myhtml/encoding.c)440
-rw-r--r--source/myencoding/encoding.h160
-rw-r--r--source/myencoding/myosi.h114
-rw-r--r--source/myencoding/mystring.c89
-rw-r--r--source/myencoding/mystring.h48
-rw-r--r--source/myencoding/resource.h (renamed from source/myhtml/encoding_resource.h)153
-rw-r--r--source/myfont/Makefile.mk21
-rw-r--r--source/myfont/cmap.c40
-rw-r--r--source/myfont/cmap.h6
-rw-r--r--source/myfont/glyf.c48
-rw-r--r--source/myfont/glyf.h14
-rw-r--r--source/myfont/head.c8
-rw-r--r--source/myfont/head.h6
-rw-r--r--source/myfont/hhea.c8
-rw-r--r--source/myfont/hhea.h4
-rw-r--r--source/myfont/hmtx.c8
-rw-r--r--source/myfont/hmtx.h4
-rw-r--r--source/myfont/loca.c14
-rw-r--r--source/myfont/loca.h6
-rw-r--r--source/myfont/maxp.c12
-rw-r--r--source/myfont/maxp.h4
-rw-r--r--source/myfont/myfont.c172
-rw-r--r--source/myfont/myfont.h33
-rw-r--r--source/myfont/myosi.c2
-rw-r--r--source/myfont/myosi.h3
-rw-r--r--source/myfont/name.c14
-rw-r--r--source/myfont/name.h6
-rw-r--r--source/myfont/os_2.c14
-rw-r--r--source/myfont/os_2.h6
-rw-r--r--source/myfont/pclt.c8
-rw-r--r--source/myfont/pclt.h4
-rw-r--r--source/myfont/vhea.c8
-rw-r--r--source/myfont/vhea.h4
-rw-r--r--source/myfont/vmtx.c10
-rw-r--r--source/myfont/vmtx.h4
-rw-r--r--source/myhtml/Makefile.mk21
-rwxr-xr-xsource/myhtml/api.h578
-rw-r--r--source/myhtml/api_encoding.h71
-rw-r--r--source/myhtml/callback.c2
-rw-r--r--source/myhtml/callback.h2
-rw-r--r--source/myhtml/charef.c2
-rw-r--r--source/myhtml/charef.h2
-rw-r--r--source/myhtml/charef_resource.h2
-rw-r--r--source/myhtml/data_process.c54
-rw-r--r--source/myhtml/data_process.h24
-rw-r--r--source/myhtml/def.h2
-rw-r--r--source/myhtml/encoding.h163
-rw-r--r--source/myhtml/myhtml.c409
-rw-r--r--source/myhtml/myhtml.h97
-rw-r--r--source/myhtml/mynamespace.c10
-rw-r--r--source/myhtml/mynamespace.h4
-rw-r--r--source/myhtml/mynamespace_resource.h2
-rw-r--r--source/myhtml/myosi.h260
-rw-r--r--source/myhtml/mystring.c449
-rw-r--r--source/myhtml/mystring.h128
-rw-r--r--source/myhtml/parser.c66
-rw-r--r--source/myhtml/parser.h8
-rw-r--r--source/myhtml/perf.c288
-rw-r--r--source/myhtml/rules.c69
-rw-r--r--source/myhtml/rules.h6
-rwxr-xr-xsource/myhtml/serialization.c326
-rw-r--r--source/myhtml/serialization.h14
-rw-r--r--source/myhtml/stream.c26
-rw-r--r--source/myhtml/stream.h8
-rwxr-xr-xsource/myhtml/tag.c45
-rw-r--r--source/myhtml/tag.h20
-rw-r--r--source/myhtml/tag_const.h2
-rwxr-xr-xsource/myhtml/tag_init.c12
-rw-r--r--source/myhtml/thread.c1185
-rw-r--r--source/myhtml/thread.h224
-rw-r--r--source/myhtml/token.c294
-rw-r--r--source/myhtml/token.h26
-rw-r--r--source/myhtml/tokenizer.c122
-rw-r--r--source/myhtml/tokenizer.h18
-rw-r--r--source/myhtml/tokenizer_doctype.c6
-rw-r--r--source/myhtml/tokenizer_doctype.h4
-rw-r--r--source/myhtml/tokenizer_end.c2
-rw-r--r--source/myhtml/tokenizer_end.h2
-rw-r--r--source/myhtml/tokenizer_script.c18
-rw-r--r--source/myhtml/tokenizer_script.h4
-rw-r--r--source/myhtml/tree.c440
-rw-r--r--source/myhtml/tree.h46
-rw-r--r--source/myhtml/utils/avl_tree.h68
-rw-r--r--source/myhtml/utils/mcsync.c155
-rw-r--r--source/myhtml/utils/mhash.h65
-rw-r--r--source/myport/posix/Makefile.mk9
-rw-r--r--source/myport/posix/Rules.mk27
-rw-r--r--source/myport/posix/mycore/io.c69
-rw-r--r--source/myport/posix/mycore/memory.c (renamed from source/myhtml/myosi.c)22
-rw-r--r--source/myport/posix/mycore/perf.c136
-rw-r--r--source/myport/posix/mycore/thread.c160
-rw-r--r--source/myport/posix/mycore/utils/mcsync.c149
-rw-r--r--source/myport/windows_nt/Makefile.mk9
-rw-r--r--source/myport/windows_nt/Rules.mk21
-rw-r--r--source/myport/windows_nt/mycore/io.c71
-rw-r--r--source/myport/windows_nt/mycore/memory.c42
-rw-r--r--source/myport/windows_nt/mycore/perf.c92
-rw-r--r--source/myport/windows_nt/mycore/thread.c131
-rw-r--r--source/myport/windows_nt/mycore/utils/mcsync.c117
-rw-r--r--source/myunicode/Makefile.mk13
-rw-r--r--source/myunicode/myosi.c36
-rw-r--r--source/myunicode/myosi.h35
-rw-r--r--source/myurl/Makefile.mk13
-rw-r--r--source/myurl/host.c631
-rw-r--r--source/myurl/host.h105
-rw-r--r--source/myurl/myosi.c38
-rw-r--r--source/myurl/myosi.h83
-rw-r--r--source/myurl/parser.c1164
-rw-r--r--source/myurl/parser.h103
-rw-r--r--source/myurl/parser_end.c347
-rw-r--r--source/myurl/path.c286
-rw-r--r--source/myurl/path.h67
-rw-r--r--source/myurl/punycode.c395
-rw-r--r--source/myurl/punycode.h48
-rw-r--r--source/myurl/resources.h180
-rw-r--r--source/myurl/scheme.c104
-rw-r--r--source/myurl/scheme.h78
-rw-r--r--source/myurl/scheme_const.h43
-rw-r--r--source/myurl/scheme_resources.h64
-rw-r--r--source/myurl/serialization.c221
-rw-r--r--source/myurl/serialization.h47
-rw-r--r--source/myurl/url.c649
-rw-r--r--source/myurl/url.h195
-rw-r--r--source/myurl/utils.c461
-rw-r--r--source/myurl/utils.h73
-rw-r--r--test/Makefile110
-rw-r--r--test/mycore/Makefile.mk7
-rw-r--r--test/mycore/data/encoding/detect_meta.html (renamed from test/myhtml/data/encoding/detect_meta.html)0
-rw-r--r--test/mycore/encoding_detect_meta.c (renamed from test/myhtml/encoding_detect_meta.c)12
-rw-r--r--test/mycore/utils/avl_tree.c (renamed from test/myhtml/utils/avl_tree.c)436
-rw-r--r--test/mycss/Makefile.mk9
-rw-r--r--test/mycss/declaration.c66
-rw-r--r--test/myencoding/Makefile.mk9
-rw-r--r--test/myencoding/data/encoding/detect_meta.html736
-rw-r--r--test/myencoding/encoding_detect_meta.c178
-rw-r--r--test/myhtml/Makefile.mk7
-rw-r--r--test/myhtml/commoncrawl.c294
-rw-r--r--test/myurl/Makefile.mk9
-rw-r--r--test/myurl/data/fragment.test25
-rw-r--r--test/myurl/data/hostname.test19
-rw-r--r--test/myurl/data/ipv4.test161
-rw-r--r--test/myurl/data/ipv6.test176
-rw-r--r--test/myurl/data/mailto.test28
-rw-r--r--test/myurl/data/miscellaneous.test43
-rw-r--r--test/myurl/data/path.test183
-rw-r--r--test/myurl/data/port.test34
-rw-r--r--test/myurl/data/query.test26
-rw-r--r--test/myurl/data/relative.test208
-rw-r--r--test/myurl/data/relative_win.test77
-rw-r--r--test/myurl/data/scheme.test100
-rw-r--r--test/myurl/url.c514
-rwxr-xr-xutils/MyHTML/encoding_name.pl29
-rw-r--r--utils/MyHTML/url_resources.pl66
603 files changed, 23840 insertions, 10462 deletions
diff --git a/.gitignore b/.gitignore
index 496ee2c..c2365ae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
-.DS_Store \ No newline at end of file
+.DS_Store
+*.o
+*.exe
+*~
diff --git a/.travis.yml b/.travis.yml
index 6b9b061..a058837 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,19 +3,4 @@ compiler:
- clang
- gcc
install: false
-
-env:
- global:
- - secure: "gNSRCjo+hi14yLpCDEmwZfzy0DFoOR+9BmkdpJhTK8NjUvIy+RmFtXgT98QHgh+fow8v/YXl8hSnyDT2+oSmsKN9P113ssgYihwoB4IuIBLSIrAf9KPfhIh6LZC23lKltQUrP9yPo3jzdD1dte1xv2tKRImDZ1Cze987EjDBbSwuVP/Gj3JlWMAafEPrh48jCM/O4DXR4podcd1biXbyX8+lbYJSFVaIq0SuagzK5Kjv8nDAFYlNk27RdhQGemmZOsM5xQM4PpgKpcQVHh0YuObCryf/O+orCDh7dOu9QlbMijabYxz/Jx7fZ1mLQGm7Kj6ETdCcf80MrrDechjJgh7uyFE/+VPDfkdaSCm1vMJCNBRgFSM0bxXqtLAyNs9TNOIJ3TUv3M4eN98Feh7I3ip9eTU/0R36HKU7sk+yotmOuAMDaMikbTQ2UuHekKev3TD0dA5O6xatyDF3jCnTJ+8aYQ096A79ZSabWUiLe6IyV/NauqSfY+mOz2NA+TxqzW92HqStdvmeOuSqCGdkGi3o2z77jEez795l2bqnIziuZhojfxjtvc/ryaZaBMYWqjSlOzRcix/SwIt8ccDCXJ4F/aNi16mYuDdL5c2mQaxtZ5Xz1IZduU87f6pWHdhLPoRMqpd/XChJVwKSFxbKmRWynUfHTcwJePSSyn5GRNA="
-
-addons:
- coverity_scan:
- project:
- name: "lexborisov/Modest"
- description: "Build submitted via Travis CI"
- notification_email: lex.borisov@gmail.com
- build_command_prepend: ""
- build_command: "make -j4"
- branch_pattern: coverity_scan
-
script: make -j4 \ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6340e65..e27ca9b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
Binary files differ
diff --git a/INSTALL.md b/INSTALL.md
index c8ac12e..0464370 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -1,51 +1,47 @@
# Modest: Build and Installation
-## make
+## GNU Make
-In root directory:
+In root directory of project (`/`):
```bash
make
+make test
+sudo make install
```
-If successful copy lib/* and include/* at the right place for you
-
Flags that can be passed to make:
-- `MODEST_OPTIMIZATION_LEVEL=-O2` set compiler optimization level. Default: -O2
-- `MODEST_BUILD_WITHOUT_THREADS=YES` build without POSIX Threads. Default: NO
-
-*for example*
-```bash
-make MODEST_BUILD_WITHOUT_THREADS=NO
-```
-
-and copy to the right place for you
+- `prefix`, default /usr/local
+- `OS`, if not defined try to get from "uname -s"
+- `PROJECT_OPTIMIZATION_LEVEL`, default -O2
+- `MyCORE_BUILD_WITHOUT_THREADS`, YES or (NO or undefined), default undefined
+- `MyCORE_BUILD_DEBUG`, YES or (NO or undefined), default undefined
+- `MyCORE_WITH_PERF`, YES or (NO or undefined), default undefined, try build with timers (rdtsc or some), OS dependent, may not work on some systems,
+- `PROJECT_INSTALL_HEADER`, default "include"
+- `PROJECT_INSTALL_LIBRARY`, default "lib"
+- `PROJECT_INSTALL_WITHOUT_HEADERS`, YES or (NO or undefined), default undefined
+
+*for example*:
```bash
-cp lib/* /usr/local/lib
-cp -r include/* /usr/local/include
-```
-
-## cmake
-
-In `project` directory:
-```bash
-cmake .
-make
+make -j4 prefix=/usr MyCORE_BUILD_WITHOUT_THREADS=YES
sudo make install
```
-Flags that can be passed to CMake:
-- `MODEST_OPTIMIZATION_LEVEL=-O2` set compiler optimization level. Default: -O2
-- `CMAKE_INSTALL_LIBDIR=lib` set path to install created library. Default: lib
-- `MODEST_BUILD_SHARED=ON` build shared library. Default: ON
-- `MODEST_BUILD_STATIC=ON` build static library. Default: ON
-- `MODEST_INSTALL_HEADER=OFF` install header files. Default OFF
-- `MODEST_BUILD_WITHOUT_THREADS=YES` build without POSIX Threads. Default: NO
-- `MODEST_EXTERN_MALLOC=my_malloc_func` set extern malloc function. Default: UNDEFINED
-- `MODEST_EXTERN_REALLOC=my_realloc_func` set extern realloc function. Default: UNDEFINED
-- `MODEST_EXTERN_CALLOC=my_calloc_func` set extern calloc function. Default: UNDEFINED
-- `MODEST_EXTERN_FREE=my_free_func` set extern free function. Default: UNDEFINED
-
-*for example*
+Makefile rules:
+- `all` —- build all components (libraries, examples, tests) (default)
+- `library` -- build only static and shared library
+- `shared` -- build only shared library
+- `static` -- build only static library
+- `clean` -- clean up current build directory
+- `clone` -- copy all headers from source to include directories and modify local include (`#include "..."`) to global (`#include <...>`)
+- `clean_api` -- remove all headers from include directory
+- `create` -- create directories for binary, libraries, tests
+- `test` -- run all tests
+- `modules` -- print modules name, description, dependencies
+- `install` -- install libraries and headers on your system
+- `uninstall` -- delete libraries and headers on your system
+- `make-pc-file` -- create pkg-config file
+
+*for example*:
```bash
-cmake . -DCMAKE_INSTALL_LIBDIR=lib64 -DMODEST_INSTALL_HEADER=ON
+make shared
```
diff --git a/Makefile b/Makefile
index 2a8d87c..504fd0d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,83 +1,206 @@
TARGET := source
SRCDIR := source
-TSTDIR := test
CC ?= gcc
-LIBNAME := modest
-LIBPOSTFIX := .so
-LIBSTATIC_POSTFIX := _static
-LIB_TMP := lib
-INCLUDE_TMP := include
-BIN_TMP := bin
-
-MODEST_OPTIMIZATION_LEVEL ?= -O2
-
-CFLAGS ?= -Wall -Werror
-CFLAGS += $(MODEST_OPTIMIZATION_LEVEL) -Wno-unused-variable -fPIC --std=c99 -I$(SRCDIR)
-
-ifdef MODEST_BUILD_DEBUG
- CFLAGS += -g
+# make rules
+# all —- build all components (libraries, examples, tests) (default)
+# library -- build only static and shared library
+# shared -- build only shared library
+# static -- build only static library
+# clean -- clean up current build directory
+# clone -- copy all headers from source to include directories and modify local include (#include "...") to global (#include <...>)
+# clean_api -- remove all headers from include directory
+# create -- create directories for binary, libraries, tests
+# install -- install libraries and headers on your system
+# uninstall -- delete libraries and headers on your system
+# test -- run all tests
+# modules -- print modules list: Module name, Description, Dependencies
+# make-pc-file -- create pkg-config file
+#
+# ARGS
+# prefix, default /usr/local
+# OS, if not defined try to get from "uname -s"
+# PROJECT_OPTIMIZATION_LEVEL, default -O2
+# MyCORE_BUILD_WITHOUT_THREADS, YES or (NO or undefined), default undefined
+# MyCORE_BUILD_DEBUG, YES or (NO or undefined), default undefined
+# MyCORE_WITH_PERF, YES or (NO or undefined), default undefined, try build with timers (rdtsc or some), OS dependent, may not work on some systems,
+# PROJECT_INSTALL_HEADER, default "include"
+# PROJECT_INSTALL_LIBRARY, default "lib"
+# PROJECT_INSTALL_WITHOUT_HEADERS, YES or (NO or undefined), default undefined
+#
+# If OS build rules not exists we try make library with POSIX threads
+
+.DEFAULT_GOAL := all
+
+DESCRIPTION := fast HTML renderer library with no outside dependency
+
+#********************
+# other Makefile
+#***************
+include Makefile.cfg
+
+#********************
+# Build
+#***************
+MODEST_BUILD_MODULES ?= $(dir $(wildcard $(SRCDIR)/*/))
+MODEST_BUILD_MODULES := $(patsubst %myport/,%myport/$(strip $(MODEST_PORT_NAME))/,$(MODEST_BUILD_MODULES))
+MODEST_BUILD_MODULES_LIST := $(foreach dir,$(MODEST_BUILD_MODULES),$(word 2, $(subst $(MODEST_DIR_SEPARATOR), , $(dir))) )
+MODEST_BUILD_MODULES_LIST_WITHOUT_PORT := $(strip $(foreach dir,$(MODEST_BUILD_MODULES_LIST),$(patsubst myport,,$(dir))))
+MODEST_BUILD_MODULES_MAKEFILES_LIST := $(foreach dir,$(MODEST_BUILD_MODULES),$(dir)Makefile.mk)
+
+#********************
+# Targets
+#***************
+MODEST_BUILD_MODULES_TARGET := $(MODEST_BUILD_MODULES_LIST)
+MODEST_BUILD_MODULES_TARGET_ALL := $(foreach dir,$(MODEST_BUILD_MODULES_TARGET),$(dir)_all)
+MODEST_BUILD_MODULES_TARGET_CLEAN := $(foreach dir,$(MODEST_BUILD_MODULES_TARGET),$(dir)_clean) $(myport_clean)
+MODEST_BUILD_MODULES_TARGET_CLONE := $(foreach dir,$(MODEST_BUILD_MODULES_TARGET),$(dir)_clone)
+
+#********************
+# Utils
+#***************
+MODEST_UTILS_HDRS = $(foreach dir,$2,$(wildcard $(SRCDIR)/$1/$(dir)/*.h))
+MODEST_UTILS_OBJS = $(patsubst %.c,%.o,$(foreach dir,$2,$(wildcard $(SRCDIR)/$1/$(dir)/*.c)))
+MODEST_UTILS_HDRS_CLONE_CMND = $(foreach path,$(foreach dir,$2,$(wildcard $(SRCDIR)/$1/$(dir)/*.h)), cp $(path) $(patsubst $(SRCDIR)%,$(INCLUDE_DIR_API)%,$(path)) $(MODEST_UTILS_NEW_LINE))
+MODEST_UTILS_HDRS_CLONE_GDIR = $(foreach dir,$2,$(INCLUDE_DIR_API)/$1/$(dir)/)
+MODEST_UTILS_HDRS_CLONE_DIRS = $(foreach dir,$(strip $(patsubst %./,%,$(foreach path,$(call MODEST_UTILS_HDRS_CLONE_GDIR,$1,$2),$(dir $(path))))),mkdir -p $(dir) $(MODEST_UTILS_NEW_LINE))
+MODEST_UTILS_HDRS_CLONE = $(info Clone for $1) $(call MODEST_UTILS_HDRS_CLONE_DIRS,$1,$2) $(MODEST_UTILS_NEW_LINE) $(call MODEST_UTILS_HDRS_CLONE_CMND,$1,$2)
+
+#********************
+# MyPORT
+#***************
+MyPORT_SELECTED_PORT = myport/$(strip $(MODEST_PORT_NAME))
+
+#********************
+# Include all modules Makefile.mk
+#***************
+include $(MODEST_BUILD_MODULES_MAKEFILES_LIST)
+
+#********************
+# Modules info
+#***************
+MODEST_BUILD_MODULES_INFO_DEP = $(foreach dep,$(strip $($1_dependencies)), $(dep))
+MODEST_BUILD_MODULES_INFO := $(foreach name,$(MODEST_BUILD_MODULES_LIST_WITHOUT_PORT),$(MODEST_UTILS_NEW_LINE)Module: $(name)$(MODEST_UTILS_NEW_LINE)Description: $($(name)_description)$(MODEST_UTILS_NEW_LINE)Dependencies:$(call MODEST_BUILD_MODULES_INFO_DEP,$(name))$(MODEST_UTILS_NEW_LINE))
+
+#********************
+# Set ARGS for flags
+#***************
+MODEST_CFLAGS += -DMODEST_BUILD_OS=$(MODEST_BUILD_OS)
+MODEST_CFLAGS += -DMODEST_PORT_NAME=$(MODEST_PORT_NAME)
+MODEST_CFLAGS += $(patsubst -DMY%,-DMy%,$(call MODEST_UTILS_TO_UPCASE,-DMyCORE_OS_$(MODEST_BUILD_OS)))
+
+override CFLAGS += $(MODEST_CFLAGS)
+override LDFLAGS += $(MODEST_LDFLAGS)
+
+#********************
+# Objects
+#***************
+MODEST_BUILD_OBJECT_SHARED ?= $(CC) -shared $(LDFLAGS) $(MODEST_LDFLAGS) $1 -o $2
+MODEST_BUILD_OBJECT_STATIC ?= $(AR) crus $2 $1
+MODEST_BUILD_OBJECT_MODULES := $(foreach dir,$(MODEST_BUILD_MODULES_TARGET),$($(dir)_objs))
+MODEST_BUILD_OBJECT_MODULES := $(foreach dir,$(MODEST_BUILD_MODULES_TARGET),$($(dir)_objs))
+
+#********************
+# Sub Directories
+#***************
+BUILD_SUB_DIRS := examples $(TEST_DIR)
+
+#********************
+# Install
+#***************
+PROJECT_INSTALL_LIBRARY := lib
+PROJECT_INSTALL_HEADER := include
+
+libdir ?= $(prefix)/$(PROJECT_INSTALL_LIBRARY)
+includedir ?= $(prefix)/$(PROJECT_INSTALL_HEADER)
+
+MODEST_INSTALL_CREATE_DIR := mkdir -p $(prefix)/$(PROJECT_INSTALL_LIBRARY)
+MODEST_INSTALL_COMMAND := $(MODEST_INSTALL_CREATE_DIR) $(MODEST_UTILS_NEW_LINE) cp -av $(LIB_DIR_BASE)/* $(libdir)
+
+ifneq ($(PROJECT_INSTALL_WITHOUT_HEADERS),YES)
+ MODEST_INSTALL_CREATE_DIR += $(prefix)/$(PROJECT_INSTALL_HEADER)
+ MODEST_INSTALL_COMMAND += $(MODEST_UTILS_NEW_LINE) cp -av $(INCLUDE_DIR_API)/* $(includedir)
endif
-MODEST_BUILD_WITHOUT_THREADS ?= NO
-ifeq ($(MODEST_BUILD_WITHOUT_THREADS),YES)
- $(info Build without POSIX Threads)
- CFLAGS += -DMODEST_BUILD_WITHOUT_THREADS -DMyHTML_BUILD_WITHOUT_THREADS
-else
- $(info Build with POSIX Threads)
- CFLAGS += -pthread
-endif
+#********************
+# Uninstall
+#***************
+MODEST_UNINSTALL_MK_COMMAND :=
+MODEST_UNINSTALL_FILE := uninstal.mk
-ifeq ($(OS),Windows_NT)
-else
- UNAM := $(shell uname -s)
- ifeq ($(UNAM),Darwin)
- LIBPOSTFIX := .dylib
- else
- CFLAGS += -D_POSIX_C_SOURCE=199309L
- endif
+ifneq ($(PROJECT_INSTALL_WITHOUT_HEADERS),YES)
+ MODEST_UNINSTALL_HEADERS := $(foreach name,$(MODEST_BUILD_MODULES_LIST_WITHOUT_PORT),rm -rf $(includedir)/$(name) \$$(MODEST_UTILS_NEW_LINE))
endif
-SRCS :=
-HDRS :=
-EXTDIRS := examples test
-
-all: create shared static
- for f in $(EXTDIRS); do $(MAKE) -C $$f all; done
-
-include $(TARGET)/myhtml/Makefile.mk
-include $(TARGET)/mycss/Makefile.mk
-include $(TARGET)/myfont/Makefile.mk
-include $(TARGET)/modest/Makefile.mk
-
-OBJS := $(patsubst %.c,%.o,$(SRCS))
-
-shared: $(OBJS)
- $(CC) -shared $(LDFLAGS) $(OBJS) -o $(LIB_TMP)/lib$(LIBNAME)$(LIBPOSTFIX)
-
-static: shared
- $(AR) crus $(LIB_TMP)/lib$(LIBNAME)$(LIBSTATIC_POSTFIX).a $(OBJS)
+MODEST_UNINSTALL_LIBRARY := $(foreach path,$(wildcard $(LIB_DIR_BASE)/lib*),rm -rf $(libdir)/$(notdir $(path)) \$$(MODEST_UTILS_NEW_LINE))
+MODEST_UNINSTALL_COMMAND = echo "MODEST_UNINSTALL_MK_COMMAND = $(MODEST_UNINSTALL_HEADERS) $(MODEST_UNINSTALL_LIBRARY)" > $(MODEST_UNINSTALL_FILE)
+
+-include $(MODEST_UNINSTALL_FILE)
+
+#********************
+# PKG-CONFIG
+#***************
+MODEST_PKG_CONFIG_FILE := modest.pc
+MODEST_PKG_CONFIG_CFLAGS := $(foreach name,$(MODEST_BUILD_MODULES_LIST_WITHOUT_PORT),-I$\{includedir}/$(name))
+MODEST_PKG_CONFIG_PROCESS = \
+$(SED) \
+-e 's,@version\@,$(PROJECT_VERSION_STRING),g' \
+-e 's,@prefix\@,$(prefix),g' \
+-e 's,@exec_prefix\@,$(exec_prefix),g' \
+-e 's,@libdir\@,$(PROJECT_INSTALL_LIBRARY),g' \
+-e 's,@includedir\@,$(PROJECT_INSTALL_HEADER),g' \
+-e 's,@cflags\@,$(MODEST_PKG_CONFIG_CFLAGS),g' \
+-e 's,@libname\@,$(LIB_NAME),g' \
+-e 's,@description\@,$(DESCRIPTION),g' \
+$1 > $2
+
+#********************
+# Target options
+#***************
+all: library
+ for f in $(BUILD_SUB_DIRS); do $(MAKE) -C $$f all; done
+
+library: shared static
+
+shared: make-pc-file create $(MODEST_BUILD_MODULES_TARGET_ALL)
+ $(call MODEST_BUILD_OBJECT_SHARED,$(MODEST_BUILD_OBJECT_MODULES),$(call MODEST_LIBRARY_WITH_VERSION))
+ $(call MODEST_BUILD_SHARED_AFTER)
+
+static: make-pc-file create $(MODEST_BUILD_MODULES_TARGET_ALL)
+ $(call MODEST_BUILD_OBJECT_STATIC,$(MODEST_BUILD_OBJECT_MODULES),$(call MODEST_LIBRARY_STATIC))
+ $(call MODEST_BUILD_STATIC_AFTER)
+
+clean: $(MODEST_BUILD_MODULES_TARGET_CLEAN)
+ rm -f $(call MODEST_LIBRARY_WITH_VERSION) && rm -f $(call MODEST_LIBRARY_STATIC)
+ rm -rf $(TEST_DIR_BASE)
+ $(call MODEST_BUILD_CLEAN_AFTER)
+ for f in $(BUILD_SUB_DIRS); do $(MAKE) -C $$f clean; done
+
+clone: clean_api $(MODEST_BUILD_MODULES_TARGET_CLONE)
+ $(call MODEST_CLONE_SED_HEADER_COMMAND)
+ find $(INCLUDE_DIR_API) -name "*.h.bak" -exec rm -f {} \;
+
+clean_api:
+ rm -rf $(INCLUDE_DIR_API)
create:
- mkdir -p lib bin
+ mkdir -p $(BINARY_DIR_BASE) $(LIB_DIR_BASE) $(TEST_DIR_BASE)
+
+install:
+ $(MODEST_INSTALL_COMMAND)
+ $(MODEST_UNINSTALL_COMMAND)
-clean:
- for f in $(EXTDIRS); do $(MAKE) -C $$f clean; done
- rm -f $(OBJS)
- rm -f $(LIB_TMP)/*
- rm -f $(BIN_TMP)/*
+uninstall:
+ $(MODEST_UNINSTALL_MK_COMMAND)
-clean_include:
- rm -rf $(INCLUDE_TMP)
+test: library
+ $(MAKE) -C $(TEST_DIR) run
-clone: create clean_include myhtml_clone mycss_clone modest_clone myfont_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 {} \;
+make-pc-file:
+ $(call MODEST_PKG_CONFIG_PROCESS,$(MODEST_PKG_CONFIG_FILE).in, $(MODEST_PKG_CONFIG_FILE))
-test:
- test/mycss/declaration test/mycss/data/declaration
- test/myhtml/utils/avl_tree
- test/myhtml/encoding_detect_meta test/myhtml/data/encoding/detect_meta.html
+modules:
+ $(info $(MODEST_BUILD_MODULES_INFO))
-.PHONY: all clean clone test \ No newline at end of file
+.PHONY: all clean clone test $(MODEST_BUILD_MODULES_TARGET_ALL)
diff --git a/Makefile.bin.cfg b/Makefile.bin.cfg
new file mode 100644
index 0000000..ec40261
--- /dev/null
+++ b/Makefile.bin.cfg
@@ -0,0 +1,53 @@
+BINARY_BUILD_OS := UNDEF
+
+# library config
+BINARY_PATH_RELATIVE ?= .
+include $(BINARY_PATH_RELATIVE)/Makefile.cfg
+
+# uses
+BINARY_LIBRARIES += $(BINARY_PATH_RELATIVE)/$(call MODEST_LIBRARY_STATIC)
+
+# flags
+BINARY_OPTIMIZATION_LEVEL ?= -O2
+BINARY_CFLAGS += -I$(BINARY_PATH_RELATIVE)/$(INCLUDE_DIR_API)
+BINARY_LDFLAGS +=
+BINARY_BUILD_OS ?= UNDEF
+
+#*******************************
+# Windows_NT
+#*******************
+ifeq ($(OS),Windows_NT)
+ BINARY_CFLAGS += -Wno-unused-variable -Wno-unused-function -std=c99
+
+ BINARY_BUILD_OS := $(OS)
+endif
+# end of Windows_NT
+
+#*******************************
+# Darwin, Mac OS X
+#*******************
+ifeq ($(OS),Darwin)
+ BINARY_CFLAGS += -fPIC
+ BINARY_CFLAGS += $(BINARY_OPTIMIZATION_LEVEL) -Wno-unused-variable -Wno-unused-function -std=c99
+
+ BINARY_BUILD_OS := $(OS)
+endif
+# end of Darwin, Mac OS X
+
+#*******************************
+# POSIX
+#*******************
+ifeq ($(BINARY_BUILD_OS),UNDEF)
+ BINARY_CFLAGS += -fPIC
+ BINARY_CFLAGS += -D_POSIX_C_SOURCE=199309L
+ BINARY_CFLAGS += $(BINARY_OPTIMIZATION_LEVEL) -Wno-unused-variable -Wno-unused-function -std=c99
+ BINARY_LIBRARIES += -lm
+
+# build without threads
+ifneq ($(MODEST_BUILD_WITHOUT_THREADS),YES)
+ BINARY_LIBRARIES += -pthread
+endif
+
+ BINARY_BUILD_OS := $(OS)
+endif
+# end of POSIX
diff --git a/Makefile.cfg b/Makefile.cfg
new file mode 100644
index 0000000..92d425d
--- /dev/null
+++ b/Makefile.cfg
@@ -0,0 +1,151 @@
+MODEST_BUILD_OS := UNDEF
+
+#********************
+# Version
+#***************
+PROJECT_VERSION_MAJOR := 0
+PROJECT_VERSION_MINOR := 0
+PROJECT_VERSION_PATCH := 6
+
+PROJECT_VERSION_STRING := $(PROJECT_VERSION_MAJOR).$(PROJECT_VERSION_MINOR).$(PROJECT_VERSION_PATCH)
+
+#********************
+# Flags
+#***************
+MODEST_CFLAGS ?= -Wall -Werror -pipe -pedantic
+MODEST_LFLAGS ?=
+
+#********************
+# Include
+#***************
+# include dirs
+INCLUDE_DIR := $(TARGET)
+INCLUDE_DIR_API := include
+
+#********************
+# Libraries
+#***************
+# lib name
+LIB_NAME := modest
+LIB_NAME_SUFFIX := .so
+LIB_NAME_SUFFIX_STATIC := _static.a
+
+# lib dirs
+LIB_DIR_BASE := lib
+
+# This variables used with "call" $(call MODEST_LIBRARY_WITH_VERSION),
+# for use actual variables like a LIB_NAME_SUFFIX
+MODEST_LIBRARY_NAME ?= lib$(LIB_NAME)$(LIB_NAME_SUFFIX)
+MODEST_LIBRARY_NAME_STATIC ?=lib$(LIB_NAME)$(LIB_NAME_SUFFIX_STATIC)
+MODEST_LIBRARY_NAME_WITH_VERSION = lib$(LIB_NAME)-$(PROJECT_VERSION_STRING)$(LIB_NAME_SUFFIX)
+
+MODEST_LIBRARY ?= $(LIB_DIR_BASE)/$(MODEST_LIBRARY_NAME)
+MODEST_LIBRARY_STATIC ?= $(LIB_DIR_BASE)/$(MODEST_LIBRARY_NAME_STATIC)
+MODEST_LIBRARY_WITH_VERSION = $(LIB_DIR_BASE)/$(MODEST_LIBRARY_NAME_WITH_VERSION)
+
+MODEST_LIBRARY_WITH_VERSION_MAJOR = $(LIB_DIR_BASE)/lib$(LIB_NAME)-$(PROJECT_VERSION_MAJOR)$(LIB_NAME_SUFFIX)
+MODEST_LIBRARY_WITH_VERSION_MAJOR_MINOR = $(LIB_DIR_BASE)/lib$(LIB_NAME)-$(PROJECT_VERSION_MAJOR).$(PROJECT_VERSION_MINOR)$(LIB_NAME_SUFFIX)
+
+#********************
+# Binaries
+#***************
+# binaries dirs
+BINARY_DIR_BASE := bin
+
+#********************
+# Test
+#***************
+TEST_DIR := test
+TEST_DIR_BASE := test_suite
+
+#********************
+# Build
+#***************
+MODEST_SOURCE ?= $(SRCDIR)
+MODEST_BUILD_SHARED_AFTER :=
+MODEST_BUILD_STATIC_AFTER :=
+
+MODEST_BUILD_CLEAN_AFTER :=
+
+#********************
+# DEFAULT
+#***************
+SED ?= sed
+
+MODEST_DIR_SEPARATOR ?= /
+
+# flags
+PROJECT_OPTIMIZATION_LEVEL ?= -O2
+MODEST_CFLAGS += -I$(INCLUDE_DIR)
+MODEST_LDFLAGS +=
+
+OS ?= $(shell uname -s)
+prefix ?= /usr/local
+exec_prefix ?= $(prefix)
+
+MODEST_CLONE_SED_HEADER_COMMAND = find $(INCLUDE_DIR_API) -name "*.h" -exec sed -i.bak -e 's,\s*\#\s*include\s*"\([^"]*\)",\#include <\1>,g' {} \;
+
+#********************
+# Set -D
+#***************
+ifeq ($(MyCORE_BUILD_DEBUG),YES)
+ override PROJECT_OPTIMIZATION_LEVEL :=
+ MODEST_CFLAGS += -g3 -ggdb3 -O0 -fno-omit-frame-pointer -DMyCORE_BUILD_DEBUG
+endif
+
+ifeq ($(MyCORE_BUILD_WITHOUT_THREADS),YES)
+ MODEST_CFLAGS += -DMyCORE_BUILD_WITHOUT_THREADS
+endif
+
+ifeq ($(MyCORE_WITH_PERF),YES)
+ MODEST_CFLAGS += -DMyCORE_WITH_PERF
+endif
+
+#********************
+# Utils
+#***************
+define MODEST_UTILS_NEW_LINE
+
+
+endef
+MODEST_UTILS_TO_UPCASE = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1))))))))))))))))))))))))))
+
+#*******************************
+# Load platform specific rules for build
+# We try to include all Rules.mk file in /source/myport/*/Rules.mk
+#*******************
+ifndef MODEST_PORT_NAME
+ MYPORT_BUILD_RULES := $(foreach path,$(wildcard $(MODEST_SOURCE)/myport/*/),$(dir $(path))Rules.mk)
+ -include $(MYPORT_BUILD_RULES)
+else
+ MYPORT_BUILD_RULES := $(MODEST_SOURCE)/myport/$(MODEST_PORT_NAME)/Rules.mk
+ -include $(MYPORT_BUILD_RULES)
+endif # def MODEST_PORT_NAME
+
+#*******************************
+# POSIX
+#*******************
+ifeq ($(MODEST_BUILD_OS),UNDEF)
+ MODEST_CFLAGS += -fPIC
+ MODEST_CFLAGS += -D_POSIX_C_SOURCE=199309L
+ MODEST_CFLAGS += $(PROJECT_OPTIMIZATION_LEVEL) -Wno-unused-variable -Wno-unused-function -std=c99
+
+ MODEST_BUILD_SHARED_AFTER += ln -sf $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY) $(MODEST_UTILS_NEW_LINE)
+ MODEST_BUILD_SHARED_AFTER += ln -sf $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY_WITH_VERSION_MAJOR) $(MODEST_UTILS_NEW_LINE)
+ MODEST_BUILD_SHARED_AFTER += ln -sf $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY_WITH_VERSION_MAJOR_MINOR) $(MODEST_UTILS_NEW_LINE)
+
+ MODEST_BUILD_CLEAN_AFTER += rm -f $(call MODEST_LIBRARY) $(MODEST_UTILS_NEW_LINE)
+ MODEST_BUILD_CLEAN_AFTER += rm -f $(call MODEST_LIBRARY_WITH_VERSION_MAJOR) $(MODEST_UTILS_NEW_LINE)
+ MODEST_BUILD_CLEAN_AFTER += rm -f $(call MODEST_LIBRARY_WITH_VERSION_MAJOR_MINOR) $(MODEST_UTILS_NEW_LINE)
+
+# build without threads
+ifneq ($(MyCORE_BUILD_WITHOUT_THREADS),YES)
+ MODEST_LDFLAGS += -pthread
+endif
+
+ # Need set
+ MODEST_BUILD_OS := $(OS)
+ # this name eq source/myport/<namedir>
+ MODEST_PORT_NAME := posix
+endif
+# end of POSIX
diff --git a/README.md b/README.md
index d526bb6..c75e150 100644
--- a/README.md
+++ b/README.md
@@ -8,15 +8,25 @@ Modest is a fast HTML renderer implemented as a pure C99 library with no outside
* Mailing List: [https://groups.google.com/forum/#!forum/modest-engine](https://groups.google.com/forum/#!forum/modest-engine)
* IRC: [#modest-engine on `irc.freenode.net <http://freenode.net>`](http://webchat.freenode.net?channels=%23modest-engine)
-* Or you can ask questions on [stackoverflow.com](https://stackoverflow.com/questions/ask?tags=modest) by modest tag
* Public [tracker by trello](https://trello.com/b/sdqpT8Ep/modest)
## Now
```text
-The current version is 0.0.5 - devel
+The current version is 0.0.6 - devel
```
+## Features
+
+* MyCORE — base module, it is used by all other modules
+* MyHTML — HTML parser by [specification](https://html.spec.whatwg.org/multipage/)
+* MyCSS —  CSS parser and modules by [specification](https://drafts.csswg.org/)
+* MyENCODING — work with character encodings, detecting encoding, convert encodings by [specification](https://encoding.spec.whatwg.org/)
+* MyFONT — work with font, metrics, calculating size and more by [specification](https://www.microsoft.com/en-us/Typography/SpecificationsOverview.aspx)
+* MyURL — URL parser by [specification](https://url.spec.whatwg.org/)
+* MyPORT — system depended code: threads (if build with threads, default), work with memory, io, timers
+* Modest — calculating, compare, renderer
+
## Introduction
[Introduction](https://lexborisov.github.io/Modest/)
@@ -42,7 +52,7 @@ Alexander Borisov <lex.borisov@gmail.com>
## COPYRIGHT AND LICENSE
-Copyright (C) 2015-2016 Alexander Borisov
+Copyright (C) 2015-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.
diff --git a/_config.yml b/_config.yml
deleted file mode 100644
index c419263..0000000
--- a/_config.yml
+++ /dev/null
@@ -1 +0,0 @@
-theme: jekyll-theme-cayman \ No newline at end of file
diff --git a/api_breaking_changes.md b/api_breaking_changes.md
index 0efa133..f807f0c 100644
--- a/api_breaking_changes.md
+++ b/api_breaking_changes.md
@@ -1,3 +1,10 @@
+0.0.5 => 0.0.6
+===========
+* MyHTML split to MyHTML and MyCORE
+* Removed all io print functions to file: ```myhtml_tree_print_by_node```, ```myhtml_tree_print_node_children```, ```myhtml_tree_print_node```; Use serializations instead of their
+* If you use encoding enum, like ```MyHTML_ENCODING_UTF8```, now it ```MyENCODING_UTF_8```, i.e ```MyHTML_ENCODING_* => MyENCODING_*```
+* Functions migrated to MyCORE from MyHTML: ```myhtml_incoming_buffer_*``` => ```mycore_incoming_buffer_*```, ```myhtml_string*``` => ```mycore_string*```, ```myhtml_utils*``` => ```mycore_utils*```
+
0.0.1 => 0.0.4
===========
Removed all depending on the Tree. Now you can get a tree of nodes ```myhtml_node_tree```
diff --git a/devel/osx/Modest.xcodeproj/project.pbxproj b/devel/osx/Modest.xcodeproj/project.pbxproj
index 7ee968f..4fd9526 100644
--- a/devel/osx/Modest.xcodeproj/project.pbxproj
+++ b/devel/osx/Modest.xcodeproj/project.pbxproj
@@ -18,8 +18,16 @@
0E0C91961DB1064E007A0501 /* serialization.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E0C91941DB1064E007A0501 /* serialization.c */; };
0E0C91991DB107E7007A0501 /* property.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E0C91971DB107E7007A0501 /* property.c */; };
0E0C919C1DB10866007A0501 /* raw_property.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E0C919A1DB10866007A0501 /* raw_property.c */; };
- 0E0D5D011E003A5E00EBFDD6 /* avl_tree.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E0D5CFF1E003A5E00EBFDD6 /* avl_tree.c */; };
- 0E0D738C1E2F67DB00FC97DE /* mhash.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E0D738A1E2F67DB00FC97DE /* mhash.c */; };
+ 0E10FEE11E5F720200242B61 /* host.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E10FECB1E5F720200242B61 /* host.c */; };
+ 0E10FEE21E5F720200242B61 /* myosi.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E10FECD1E5F720200242B61 /* myosi.c */; };
+ 0E10FEE31E5F720200242B61 /* parser_end.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E10FECF1E5F720200242B61 /* parser_end.c */; };
+ 0E10FEE41E5F720200242B61 /* parser.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E10FED01E5F720200242B61 /* parser.c */; };
+ 0E10FEE51E5F720200242B61 /* path.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E10FED21E5F720200242B61 /* path.c */; };
+ 0E10FEE61E5F720200242B61 /* punycode.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E10FED41E5F720200242B61 /* punycode.c */; };
+ 0E10FEE71E5F720200242B61 /* scheme.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E10FED91E5F720200242B61 /* scheme.c */; };
+ 0E10FEE81E5F720200242B61 /* serialization.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E10FEDB1E5F720200242B61 /* serialization.c */; };
+ 0E10FEE91E5F720200242B61 /* url.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E10FEDD1E5F720200242B61 /* url.c */; };
+ 0E10FEEA1E5F720200242B61 /* utils.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E10FEDF1E5F720200242B61 /* utils.c */; };
0E4B525C1DC13BBB0095026A /* parser_text_decoration.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E4B525A1DC13BBB0095026A /* parser_text_decoration.c */; };
0E5AA4BD1DA9689700FF5358 /* shared.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E5AA4BB1DA9689700FF5358 /* shared.c */; };
0E5E2AAB1DC53CC1007836AB /* entry_destroy.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E5E2AA91DC53CC1007836AB /* entry_destroy.c */; };
@@ -83,34 +91,20 @@
0E750FE71D9AF27F00337E9B /* callback.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FA41D9AF27F00337E9B /* callback.c */; };
0E750FE81D9AF27F00337E9B /* charef.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FA71D9AF27F00337E9B /* charef.c */; };
0E750FE91D9AF27F00337E9B /* data_process.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FA91D9AF27F00337E9B /* data_process.c */; };
- 0E750FEA1D9AF27F00337E9B /* encoding_detect.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FAD1D9AF27F00337E9B /* encoding_detect.c */; };
- 0E750FEB1D9AF27F00337E9B /* encoding.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FAF1D9AF27F00337E9B /* encoding.c */; };
- 0E750FEC1D9AF27F00337E9B /* incoming.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FB11D9AF27F00337E9B /* incoming.c */; };
0E750FED1D9AF27F00337E9B /* myhtml.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FB31D9AF27F00337E9B /* myhtml.c */; };
0E750FEE1D9AF27F00337E9B /* mynamespace.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FB61D9AF27F00337E9B /* mynamespace.c */; };
- 0E750FEF1D9AF27F00337E9B /* myosi.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FB81D9AF27F00337E9B /* myosi.c */; };
- 0E750FF01D9AF27F00337E9B /* mystring.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FBA1D9AF27F00337E9B /* mystring.c */; };
0E750FF11D9AF27F00337E9B /* parser.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FBC1D9AF27F00337E9B /* parser.c */; };
- 0E750FF21D9AF27F00337E9B /* perf.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FBE1D9AF27F00337E9B /* perf.c */; };
0E750FF31D9AF27F00337E9B /* rules.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FBF1D9AF27F00337E9B /* rules.c */; };
0E750FF41D9AF27F00337E9B /* serialization.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FC11D9AF27F00337E9B /* serialization.c */; };
0E750FF51D9AF27F00337E9B /* stream.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FC31D9AF27F00337E9B /* stream.c */; };
0E750FF61D9AF27F00337E9B /* tag_init.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FC61D9AF27F00337E9B /* tag_init.c */; };
0E750FF71D9AF27F00337E9B /* tag.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FC71D9AF27F00337E9B /* tag.c */; };
- 0E750FF81D9AF27F00337E9B /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FC91D9AF27F00337E9B /* thread.c */; };
0E750FF91D9AF27F00337E9B /* token.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FCB1D9AF27F00337E9B /* token.c */; };
0E750FFA1D9AF27F00337E9B /* tokenizer_doctype.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FCD1D9AF27F00337E9B /* tokenizer_doctype.c */; };
0E750FFB1D9AF27F00337E9B /* tokenizer_end.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FCF1D9AF27F00337E9B /* tokenizer_end.c */; };
0E750FFC1D9AF27F00337E9B /* tokenizer_script.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FD11D9AF27F00337E9B /* tokenizer_script.c */; };
0E750FFD1D9AF27F00337E9B /* tokenizer.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FD31D9AF27F00337E9B /* tokenizer.c */; };
0E750FFE1D9AF27F00337E9B /* tree.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FD51D9AF27F00337E9B /* tree.c */; };
- 0E750FFF1D9AF27F00337E9B /* mchar_async.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FD81D9AF27F00337E9B /* mchar_async.c */; };
- 0E7510001D9AF27F00337E9B /* mcobject.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FDA1D9AF27F00337E9B /* mcobject.c */; };
- 0E7510011D9AF27F00337E9B /* mcobject_async.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FDC1D9AF27F00337E9B /* mcobject_async.c */; };
- 0E7510021D9AF27F00337E9B /* mcsimple.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FDE1D9AF27F00337E9B /* mcsimple.c */; };
- 0E7510031D9AF27F00337E9B /* mcsync.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FE01D9AF27F00337E9B /* mcsync.c */; };
- 0E7510041D9AF27F00337E9B /* mctree.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FE21D9AF27F00337E9B /* mctree.c */; };
- 0E7510051D9AF27F00337E9B /* utils.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E750FE51D9AF27F00337E9B /* utils.c */; };
0E79EE951DC8E270004FF5DC /* stack.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E79EE931DC8E270004FF5DC /* stack.c */; };
0E7F78351DD3E0D5003B6053 /* begin.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E7F78331DD3E0D5003B6053 /* begin.c */; };
0E7F78381DD3E2E5003B6053 /* glue.c in Sources */ = {isa = PBXBuildFile; fileRef = 0E7F78361DD3E2E5003B6053 /* glue.c */; };
@@ -124,6 +118,28 @@
0EF2D5ED1E01E04A000570B6 /* declaration.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF2D5EB1E01E04A000570B6 /* declaration.c */; };
0EF2D5F21E01E089000570B6 /* default.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF2D5F01E01E089000570B6 /* default.c */; };
0EF2D5F71E01E0BD000570B6 /* default.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF2D5F51E01E0BD000570B6 /* default.c */; };
+ 0EF5D1581E680D880048E3D1 /* incoming.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D14D1E680D880048E3D1 /* incoming.c */; };
+ 0EF5D15A1E680D880048E3D1 /* mystring.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1511E680D880048E3D1 /* mystring.c */; };
+ 0EF5D15C1E680D880048E3D1 /* mythread.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1541E680D880048E3D1 /* mythread.c */; };
+ 0EF5D15D1E680D880048E3D1 /* utils.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1561E680D880048E3D1 /* utils.c */; };
+ 0EF5D1701E680DA50048E3D1 /* avl_tree.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1601E680DA50048E3D1 /* avl_tree.c */; };
+ 0EF5D1711E680DA50048E3D1 /* mchar_async.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1621E680DA50048E3D1 /* mchar_async.c */; };
+ 0EF5D1721E680DA50048E3D1 /* mcobject_async.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1641E680DA50048E3D1 /* mcobject_async.c */; };
+ 0EF5D1731E680DA50048E3D1 /* mcobject.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1661E680DA50048E3D1 /* mcobject.c */; };
+ 0EF5D1741E680DA50048E3D1 /* mcsimple.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1681E680DA50048E3D1 /* mcsimple.c */; };
+ 0EF5D1751E680DA50048E3D1 /* mcsync.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D16A1E680DA50048E3D1 /* mcsync.c */; };
+ 0EF5D1761E680DA50048E3D1 /* mctree.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D16C1E680DA50048E3D1 /* mctree.c */; };
+ 0EF5D1771E680DA50048E3D1 /* mhash.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D16E1E680DA50048E3D1 /* mhash.c */; };
+ 0EF5D1791E680EA10048E3D1 /* myosi.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1781E680EA10048E3D1 /* myosi.c */; };
+ 0EF5D17F1E6819E80048E3D1 /* detect.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D17B1E6819E80048E3D1 /* detect.c */; };
+ 0EF5D1801E6819E80048E3D1 /* encoding.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D17D1E6819E80048E3D1 /* encoding.c */; };
+ 0EF5D1841E6822BD0048E3D1 /* mystring.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1821E6822BD0048E3D1 /* mystring.c */; };
+ 0EF5D1871E68362D0048E3D1 /* mystring.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1851E68362D0048E3D1 /* mystring.c */; };
+ 0EF5D19E1E6AE8BF0048E3D1 /* thread_queue.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D19C1E6AE8BF0048E3D1 /* thread_queue.c */; };
+ 0EF5D1A71E6DDDC20048E3D1 /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1A31E6DDDC20048E3D1 /* thread.c */; };
+ 0EF5D1A81E6DDDC20048E3D1 /* io.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1A41E6DDDC20048E3D1 /* io.c */; };
+ 0EF5D1A91E6DDDC20048E3D1 /* memory.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1A51E6DDDC20048E3D1 /* memory.c */; };
+ 0EF5D1AC1E6DDDCD0048E3D1 /* mcsync.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5D1AB1E6DDDCD0048E3D1 /* mcsync.c */; };
0EF68DCE1DBF6CF000B0DEA4 /* color_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF68DCC1DBF6CF000B0DEA4 /* color_parser.c */; };
0EF808A31D9FF3BC001AF6EF /* sheet.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF808A11D9FF3BC001AF6EF /* sheet.c */; };
0EF808A61DA08BBE001AF6EF /* map.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF808A41DA08BBE001AF6EF /* map.c */; };
@@ -167,10 +183,28 @@
0E0C91981DB107E7007A0501 /* property.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = property.h; path = ../../../source/modest/node/property.h; sourceTree = "<group>"; };
0E0C919A1DB10866007A0501 /* raw_property.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = raw_property.c; path = ../../../source/modest/node/raw_property.c; sourceTree = "<group>"; };
0E0C919B1DB10866007A0501 /* raw_property.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = raw_property.h; path = ../../../source/modest/node/raw_property.h; sourceTree = "<group>"; };
- 0E0D5CFF1E003A5E00EBFDD6 /* avl_tree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = avl_tree.c; sourceTree = "<group>"; };
- 0E0D5D001E003A5E00EBFDD6 /* avl_tree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = avl_tree.h; sourceTree = "<group>"; };
- 0E0D738A1E2F67DB00FC97DE /* mhash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mhash.c; sourceTree = "<group>"; };
- 0E0D738B1E2F67DB00FC97DE /* mhash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mhash.h; sourceTree = "<group>"; };
+ 0E10FECB1E5F720200242B61 /* host.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = host.c; path = ../../source/myurl/host.c; sourceTree = "<group>"; };
+ 0E10FECC1E5F720200242B61 /* host.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = host.h; path = ../../source/myurl/host.h; sourceTree = "<group>"; };
+ 0E10FECD1E5F720200242B61 /* myosi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = myosi.c; path = ../../source/myurl/myosi.c; sourceTree = "<group>"; };
+ 0E10FECE1E5F720200242B61 /* myosi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = myosi.h; path = ../../source/myurl/myosi.h; sourceTree = "<group>"; };
+ 0E10FECF1E5F720200242B61 /* parser_end.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = parser_end.c; path = ../../source/myurl/parser_end.c; sourceTree = "<group>"; };
+ 0E10FED01E5F720200242B61 /* parser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = parser.c; path = ../../source/myurl/parser.c; sourceTree = "<group>"; };
+ 0E10FED11E5F720200242B61 /* parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = parser.h; path = ../../source/myurl/parser.h; sourceTree = "<group>"; };
+ 0E10FED21E5F720200242B61 /* path.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = path.c; path = ../../source/myurl/path.c; sourceTree = "<group>"; };
+ 0E10FED31E5F720200242B61 /* path.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = path.h; path = ../../source/myurl/path.h; sourceTree = "<group>"; };
+ 0E10FED41E5F720200242B61 /* punycode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = punycode.c; path = ../../source/myurl/punycode.c; sourceTree = "<group>"; };
+ 0E10FED51E5F720200242B61 /* punycode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = punycode.h; path = ../../source/myurl/punycode.h; sourceTree = "<group>"; };
+ 0E10FED61E5F720200242B61 /* resources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = resources.h; path = ../../source/myurl/resources.h; sourceTree = "<group>"; };
+ 0E10FED71E5F720200242B61 /* scheme_const.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = scheme_const.h; path = ../../source/myurl/scheme_const.h; sourceTree = "<group>"; };
+ 0E10FED81E5F720200242B61 /* scheme_resources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = scheme_resources.h; path = ../../source/myurl/scheme_resources.h; sourceTree = "<group>"; };
+ 0E10FED91E5F720200242B61 /* scheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = scheme.c; path = ../../source/myurl/scheme.c; sourceTree = "<group>"; };
+ 0E10FEDA1E5F720200242B61 /* scheme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = scheme.h; path = ../../source/myurl/scheme.h; sourceTree = "<group>"; };
+ 0E10FEDB1E5F720200242B61 /* serialization.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = serialization.c; path = ../../source/myurl/serialization.c; sourceTree = "<group>"; };
+ 0E10FEDC1E5F720200242B61 /* serialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = serialization.h; path = ../../source/myurl/serialization.h; sourceTree = "<group>"; };
+ 0E10FEDD1E5F720200242B61 /* url.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = url.c; path = ../../source/myurl/url.c; sourceTree = "<group>"; };
+ 0E10FEDE1E5F720200242B61 /* url.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = url.h; path = ../../source/myurl/url.h; sourceTree = "<group>"; };
+ 0E10FEDF1E5F720200242B61 /* utils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = utils.c; path = ../../source/myurl/utils.c; sourceTree = "<group>"; };
+ 0E10FEE01E5F720200242B61 /* utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = utils.h; path = ../../source/myurl/utils.h; sourceTree = "<group>"; };
0E4B525A1DC13BBB0095026A /* parser_text_decoration.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = parser_text_decoration.c; sourceTree = "<group>"; };
0E5AA4BB1DA9689700FF5358 /* shared.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = shared.c; sourceTree = "<group>"; };
0E5AA4BC1DA9689700FF5358 /* shared.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shared.h; sourceTree = "<group>"; };
@@ -309,7 +343,6 @@
0E750F7D1D9AF27200337E9B /* units_resources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = units_resources.h; sourceTree = "<group>"; };
0E750F7E1D9AF27200337E9B /* values.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = values.c; sourceTree = "<group>"; };
0E750F7F1D9AF27200337E9B /* values.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = values.h; sourceTree = "<group>"; };
- 0E750FA21D9AF27F00337E9B /* api_encoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = api_encoding.h; path = ../../source/myhtml/api_encoding.h; sourceTree = "<group>"; };
0E750FA31D9AF27F00337E9B /* api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = api.h; path = ../../source/myhtml/api.h; sourceTree = "<group>"; };
0E750FA41D9AF27F00337E9B /* callback.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = callback.c; path = ../../source/myhtml/callback.c; sourceTree = "<group>"; };
0E750FA51D9AF27F00337E9B /* callback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = callback.h; path = ../../source/myhtml/callback.h; sourceTree = "<group>"; };
@@ -319,25 +352,14 @@
0E750FA91D9AF27F00337E9B /* data_process.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = data_process.c; path = ../../source/myhtml/data_process.c; sourceTree = "<group>"; };
0E750FAA1D9AF27F00337E9B /* data_process.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = data_process.h; path = ../../source/myhtml/data_process.h; sourceTree = "<group>"; };
0E750FAB1D9AF27F00337E9B /* def.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = def.h; path = ../../source/myhtml/def.h; sourceTree = "<group>"; };
- 0E750FAC1D9AF27F00337E9B /* encoding_detect_resource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = encoding_detect_resource.h; path = ../../source/myhtml/encoding_detect_resource.h; sourceTree = "<group>"; };
- 0E750FAD1D9AF27F00337E9B /* encoding_detect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = encoding_detect.c; path = ../../source/myhtml/encoding_detect.c; sourceTree = "<group>"; };
- 0E750FAE1D9AF27F00337E9B /* encoding_resource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = encoding_resource.h; path = ../../source/myhtml/encoding_resource.h; sourceTree = "<group>"; };
- 0E750FAF1D9AF27F00337E9B /* encoding.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = encoding.c; path = ../../source/myhtml/encoding.c; sourceTree = "<group>"; };
- 0E750FB01D9AF27F00337E9B /* encoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = encoding.h; path = ../../source/myhtml/encoding.h; sourceTree = "<group>"; };
- 0E750FB11D9AF27F00337E9B /* incoming.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = incoming.c; path = ../../source/myhtml/incoming.c; sourceTree = "<group>"; };
- 0E750FB21D9AF27F00337E9B /* incoming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = incoming.h; path = ../../source/myhtml/incoming.h; sourceTree = "<group>"; };
0E750FB31D9AF27F00337E9B /* myhtml.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = myhtml.c; path = ../../source/myhtml/myhtml.c; sourceTree = "<group>"; };
0E750FB41D9AF27F00337E9B /* myhtml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = myhtml.h; path = ../../source/myhtml/myhtml.h; sourceTree = "<group>"; };
0E750FB51D9AF27F00337E9B /* mynamespace_resource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mynamespace_resource.h; path = ../../source/myhtml/mynamespace_resource.h; sourceTree = "<group>"; };
0E750FB61D9AF27F00337E9B /* mynamespace.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mynamespace.c; path = ../../source/myhtml/mynamespace.c; sourceTree = "<group>"; };
0E750FB71D9AF27F00337E9B /* mynamespace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mynamespace.h; path = ../../source/myhtml/mynamespace.h; sourceTree = "<group>"; };
- 0E750FB81D9AF27F00337E9B /* myosi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = myosi.c; path = ../../source/myhtml/myosi.c; sourceTree = "<group>"; };
0E750FB91D9AF27F00337E9B /* myosi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = myosi.h; path = ../../source/myhtml/myosi.h; sourceTree = "<group>"; };
- 0E750FBA1D9AF27F00337E9B /* mystring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mystring.c; path = ../../source/myhtml/mystring.c; sourceTree = "<group>"; };
- 0E750FBB1D9AF27F00337E9B /* mystring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mystring.h; path = ../../source/myhtml/mystring.h; sourceTree = "<group>"; };
0E750FBC1D9AF27F00337E9B /* parser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = parser.c; path = ../../source/myhtml/parser.c; sourceTree = "<group>"; };
0E750FBD1D9AF27F00337E9B /* parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = parser.h; path = ../../source/myhtml/parser.h; sourceTree = "<group>"; };
- 0E750FBE1D9AF27F00337E9B /* perf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = perf.c; path = ../../source/myhtml/perf.c; sourceTree = "<group>"; };
0E750FBF1D9AF27F00337E9B /* rules.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rules.c; path = ../../source/myhtml/rules.c; sourceTree = "<group>"; };
0E750FC01D9AF27F00337E9B /* rules.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = rules.h; path = ../../source/myhtml/rules.h; sourceTree = "<group>"; };
0E750FC11D9AF27F00337E9B /* serialization.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = serialization.c; path = ../../source/myhtml/serialization.c; sourceTree = "<group>"; };
@@ -348,8 +370,6 @@
0E750FC61D9AF27F00337E9B /* tag_init.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tag_init.c; path = ../../source/myhtml/tag_init.c; sourceTree = "<group>"; };
0E750FC71D9AF27F00337E9B /* tag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tag.c; path = ../../source/myhtml/tag.c; sourceTree = "<group>"; };
0E750FC81D9AF27F00337E9B /* tag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tag.h; path = ../../source/myhtml/tag.h; sourceTree = "<group>"; };
- 0E750FC91D9AF27F00337E9B /* thread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = thread.c; path = ../../source/myhtml/thread.c; sourceTree = "<group>"; };
- 0E750FCA1D9AF27F00337E9B /* thread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = thread.h; path = ../../source/myhtml/thread.h; sourceTree = "<group>"; };
0E750FCB1D9AF27F00337E9B /* token.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = token.c; path = ../../source/myhtml/token.c; sourceTree = "<group>"; };
0E750FCC1D9AF27F00337E9B /* token.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = token.h; path = ../../source/myhtml/token.h; sourceTree = "<group>"; };
0E750FCD1D9AF27F00337E9B /* tokenizer_doctype.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tokenizer_doctype.c; path = ../../source/myhtml/tokenizer_doctype.c; sourceTree = "<group>"; };
@@ -362,21 +382,6 @@
0E750FD41D9AF27F00337E9B /* tokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tokenizer.h; path = ../../source/myhtml/tokenizer.h; sourceTree = "<group>"; };
0E750FD51D9AF27F00337E9B /* tree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tree.c; path = ../../source/myhtml/tree.c; sourceTree = "<group>"; };
0E750FD61D9AF27F00337E9B /* tree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tree.h; path = ../../source/myhtml/tree.h; sourceTree = "<group>"; };
- 0E750FD81D9AF27F00337E9B /* mchar_async.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mchar_async.c; sourceTree = "<group>"; };
- 0E750FD91D9AF27F00337E9B /* mchar_async.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mchar_async.h; sourceTree = "<group>"; };
- 0E750FDA1D9AF27F00337E9B /* mcobject.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mcobject.c; sourceTree = "<group>"; };
- 0E750FDB1D9AF27F00337E9B /* mcobject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mcobject.h; sourceTree = "<group>"; };
- 0E750FDC1D9AF27F00337E9B /* mcobject_async.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mcobject_async.c; sourceTree = "<group>"; };
- 0E750FDD1D9AF27F00337E9B /* mcobject_async.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mcobject_async.h; sourceTree = "<group>"; };
- 0E750FDE1D9AF27F00337E9B /* mcsimple.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mcsimple.c; sourceTree = "<group>"; };
- 0E750FDF1D9AF27F00337E9B /* mcsimple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mcsimple.h; sourceTree = "<group>"; };
- 0E750FE01D9AF27F00337E9B /* mcsync.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mcsync.c; sourceTree = "<group>"; };
- 0E750FE11D9AF27F00337E9B /* mcsync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mcsync.h; sourceTree = "<group>"; };
- 0E750FE21D9AF27F00337E9B /* mctree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mctree.c; sourceTree = "<group>"; };
- 0E750FE31D9AF27F00337E9B /* mctree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mctree.h; sourceTree = "<group>"; };
- 0E750FE41D9AF27F00337E9B /* resources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = resources.h; sourceTree = "<group>"; };
- 0E750FE51D9AF27F00337E9B /* utils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = utils.c; path = ../../source/myhtml/utils.c; sourceTree = "<group>"; };
- 0E750FE61D9AF27F00337E9B /* utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = utils.h; path = ../../source/myhtml/utils.h; sourceTree = "<group>"; };
0E79EE931DC8E270004FF5DC /* stack.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = stack.c; path = ../../source/mycss/stack.c; sourceTree = "<group>"; };
0E79EE941DC8E270004FF5DC /* stack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = stack.h; path = ../../source/mycss/stack.h; sourceTree = "<group>"; };
0E7F782C1DD3DF6C003B6053 /* layer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = layer.h; path = ../../../source/modest/layer/layer.h; sourceTree = "<group>"; };
@@ -407,6 +412,49 @@
0EF2D5F41E01E0BD000570B6 /* default_resources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = default_resources.h; sourceTree = "<group>"; };
0EF2D5F51E01E0BD000570B6 /* default.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = default.c; sourceTree = "<group>"; };
0EF2D5F61E01E0BD000570B6 /* default.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = default.h; sourceTree = "<group>"; };
+ 0EF5D14D1E680D880048E3D1 /* incoming.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = incoming.c; path = ../../source/mycore/incoming.c; sourceTree = "<group>"; };
+ 0EF5D14E1E680D880048E3D1 /* incoming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = incoming.h; path = ../../source/mycore/incoming.h; sourceTree = "<group>"; };
+ 0EF5D1501E680D880048E3D1 /* myosi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = myosi.h; path = ../../source/mycore/myosi.h; sourceTree = "<group>"; };
+ 0EF5D1511E680D880048E3D1 /* mystring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mystring.c; path = ../../source/mycore/mystring.c; sourceTree = "<group>"; };
+ 0EF5D1521E680D880048E3D1 /* mystring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mystring.h; path = ../../source/mycore/mystring.h; sourceTree = "<group>"; };
+ 0EF5D1541E680D880048E3D1 /* mythread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mythread.c; path = ../../source/mycore/mythread.c; sourceTree = "<group>"; };
+ 0EF5D1551E680D880048E3D1 /* mythread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mythread.h; path = ../../source/mycore/mythread.h; sourceTree = "<group>"; };
+ 0EF5D1561E680D880048E3D1 /* utils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = utils.c; path = ../../source/mycore/utils.c; sourceTree = "<group>"; };
+ 0EF5D1571E680D880048E3D1 /* utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = utils.h; path = ../../source/mycore/utils.h; sourceTree = "<group>"; };
+ 0EF5D15F1E680DA50048E3D1 /* resources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = resources.h; path = ../../source/mycore/utils/resources.h; sourceTree = "<group>"; };
+ 0EF5D1601E680DA50048E3D1 /* avl_tree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = avl_tree.c; path = ../../source/mycore/utils/avl_tree.c; sourceTree = "<group>"; };
+ 0EF5D1611E680DA50048E3D1 /* avl_tree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = avl_tree.h; path = ../../source/mycore/utils/avl_tree.h; sourceTree = "<group>"; };
+ 0EF5D1621E680DA50048E3D1 /* mchar_async.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mchar_async.c; path = ../../source/mycore/utils/mchar_async.c; sourceTree = "<group>"; };
+ 0EF5D1631E680DA50048E3D1 /* mchar_async.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mchar_async.h; path = ../../source/mycore/utils/mchar_async.h; sourceTree = "<group>"; };
+ 0EF5D1641E680DA50048E3D1 /* mcobject_async.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mcobject_async.c; path = ../../source/mycore/utils/mcobject_async.c; sourceTree = "<group>"; };
+ 0EF5D1651E680DA50048E3D1 /* mcobject_async.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mcobject_async.h; path = ../../source/mycore/utils/mcobject_async.h; sourceTree = "<group>"; };
+ 0EF5D1661E680DA50048E3D1 /* mcobject.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mcobject.c; path = ../../source/mycore/utils/mcobject.c; sourceTree = "<group>"; };
+ 0EF5D1671E680DA50048E3D1 /* mcobject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mcobject.h; path = ../../source/mycore/utils/mcobject.h; sourceTree = "<group>"; };
+ 0EF5D1681E680DA50048E3D1 /* mcsimple.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mcsimple.c; path = ../../source/mycore/utils/mcsimple.c; sourceTree = "<group>"; };
+ 0EF5D1691E680DA50048E3D1 /* mcsimple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mcsimple.h; path = ../../source/mycore/utils/mcsimple.h; sourceTree = "<group>"; };
+ 0EF5D16A1E680DA50048E3D1 /* mcsync.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mcsync.c; path = ../../source/mycore/utils/mcsync.c; sourceTree = "<group>"; };
+ 0EF5D16B1E680DA50048E3D1 /* mcsync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mcsync.h; path = ../../source/mycore/utils/mcsync.h; sourceTree = "<group>"; };
+ 0EF5D16C1E680DA50048E3D1 /* mctree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mctree.c; path = ../../source/mycore/utils/mctree.c; sourceTree = "<group>"; };
+ 0EF5D16D1E680DA50048E3D1 /* mctree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mctree.h; path = ../../source/mycore/utils/mctree.h; sourceTree = "<group>"; };
+ 0EF5D16E1E680DA50048E3D1 /* mhash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mhash.c; path = ../../source/mycore/utils/mhash.c; sourceTree = "<group>"; };
+ 0EF5D16F1E680DA50048E3D1 /* mhash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mhash.h; path = ../../source/mycore/utils/mhash.h; sourceTree = "<group>"; };
+ 0EF5D1781E680EA10048E3D1 /* myosi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = myosi.c; path = ../../source/mycore/myosi.c; sourceTree = "<group>"; };
+ 0EF5D17A1E6819E80048E3D1 /* detect_resource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = detect_resource.h; path = ../../source/myencoding/detect_resource.h; sourceTree = "<group>"; };
+ 0EF5D17B1E6819E80048E3D1 /* detect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = detect.c; path = ../../source/myencoding/detect.c; sourceTree = "<group>"; };
+ 0EF5D17C1E6819E80048E3D1 /* resource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = resource.h; path = ../../source/myencoding/resource.h; sourceTree = "<group>"; };
+ 0EF5D17D1E6819E80048E3D1 /* encoding.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = encoding.c; path = ../../source/myencoding/encoding.c; sourceTree = "<group>"; };
+ 0EF5D17E1E6819E80048E3D1 /* encoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = encoding.h; path = ../../source/myencoding/encoding.h; sourceTree = "<group>"; };
+ 0EF5D1811E681FC90048E3D1 /* myosi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = myosi.h; path = ../../source/myencoding/myosi.h; sourceTree = "<group>"; };
+ 0EF5D1821E6822BD0048E3D1 /* mystring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mystring.c; path = ../../source/myencoding/mystring.c; sourceTree = "<group>"; };
+ 0EF5D1831E6822BD0048E3D1 /* mystring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mystring.h; path = ../../source/myencoding/mystring.h; sourceTree = "<group>"; };
+ 0EF5D1851E68362D0048E3D1 /* mystring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mystring.c; path = ../../source/myhtml/mystring.c; sourceTree = "<group>"; };
+ 0EF5D1861E68362D0048E3D1 /* mystring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mystring.h; path = ../../source/myhtml/mystring.h; sourceTree = "<group>"; };
+ 0EF5D19C1E6AE8BF0048E3D1 /* thread_queue.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = thread_queue.c; path = ../../source/mycore/thread_queue.c; sourceTree = "<group>"; };
+ 0EF5D19D1E6AE8BF0048E3D1 /* thread_queue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = thread_queue.h; path = ../../source/mycore/thread_queue.h; sourceTree = "<group>"; };
+ 0EF5D1A31E6DDDC20048E3D1 /* thread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = thread.c; path = ../../source/myport/posix/mycore/thread.c; sourceTree = "<group>"; };
+ 0EF5D1A41E6DDDC20048E3D1 /* io.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = io.c; path = ../../source/myport/posix/mycore/io.c; sourceTree = "<group>"; };
+ 0EF5D1A51E6DDDC20048E3D1 /* memory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = memory.c; path = ../../source/myport/posix/mycore/memory.c; sourceTree = "<group>"; };
+ 0EF5D1AB1E6DDDCD0048E3D1 /* mcsync.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mcsync.c; path = ../../source/myport/posix/mycore/utils/mcsync.c; sourceTree = "<group>"; };
0EF68DCC1DBF6CF000B0DEA4 /* color_parser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = color_parser.c; sourceTree = "<group>"; };
0EF68DCD1DBF6CF000B0DEA4 /* color_parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = color_parser.h; sourceTree = "<group>"; };
0EF808A11D9FF3BC001AF6EF /* sheet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sheet.c; sourceTree = "<group>"; };
@@ -463,14 +511,47 @@
name = node;
sourceTree = "<group>";
};
+ 0E10FECA1E5F71CF00242B61 /* myurl */ = {
+ isa = PBXGroup;
+ children = (
+ 0E10FECE1E5F720200242B61 /* myosi.h */,
+ 0E10FECD1E5F720200242B61 /* myosi.c */,
+ 0E10FEDE1E5F720200242B61 /* url.h */,
+ 0E10FEDD1E5F720200242B61 /* url.c */,
+ 0E10FECC1E5F720200242B61 /* host.h */,
+ 0E10FECB1E5F720200242B61 /* host.c */,
+ 0E10FED31E5F720200242B61 /* path.h */,
+ 0E10FED21E5F720200242B61 /* path.c */,
+ 0E10FED11E5F720200242B61 /* parser.h */,
+ 0E10FED01E5F720200242B61 /* parser.c */,
+ 0E10FECF1E5F720200242B61 /* parser_end.c */,
+ 0E10FED51E5F720200242B61 /* punycode.h */,
+ 0E10FED41E5F720200242B61 /* punycode.c */,
+ 0E10FED71E5F720200242B61 /* scheme_const.h */,
+ 0E10FEDA1E5F720200242B61 /* scheme.h */,
+ 0E10FED91E5F720200242B61 /* scheme.c */,
+ 0E10FED81E5F720200242B61 /* scheme_resources.h */,
+ 0E10FEDC1E5F720200242B61 /* serialization.h */,
+ 0E10FEDB1E5F720200242B61 /* serialization.c */,
+ 0E10FEE01E5F720200242B61 /* utils.h */,
+ 0E10FEDF1E5F720200242B61 /* utils.c */,
+ 0E10FED61E5F720200242B61 /* resources.h */,
+ );
+ name = myurl;
+ sourceTree = "<group>";
+ };
0E750ED61D9AF1D500337E9B = {
isa = PBXGroup;
children = (
0E750EE21D9AF1D500337E9B /* main.c */,
+ 0EF5D14A1E6805C90048E3D1 /* mycore */,
+ 0EF5D14C1E6805D70048E3D1 /* myencoding */,
0E750EE11D9AF1D500337E9B /* Modest */,
0E750EEB1D9AF22E00337E9B /* myfont */,
0E750EEA1D9AF22500337E9B /* mycss */,
0E750EE91D9AF21C00337E9B /* myhtml */,
+ 0E10FECA1E5F71CF00242B61 /* myurl */,
+ 0EF5D1A01E6DDD8E0048E3D1 /* posix */,
0E750EE01D9AF1D500337E9B /* Products */,
);
sourceTree = "<group>";
@@ -507,9 +588,7 @@
children = (
0E750FAB1D9AF27F00337E9B /* def.h */,
0E750FA31D9AF27F00337E9B /* api.h */,
- 0E750FA21D9AF27F00337E9B /* api_encoding.h */,
0E750FB91D9AF27F00337E9B /* myosi.h */,
- 0E750FB81D9AF27F00337E9B /* myosi.c */,
0E750FB41D9AF27F00337E9B /* myhtml.h */,
0E750FB31D9AF27F00337E9B /* myhtml.c */,
0E750FA51D9AF27F00337E9B /* callback.h */,
@@ -519,21 +598,13 @@
0E750FA61D9AF27F00337E9B /* charef_resource.h */,
0E750FAA1D9AF27F00337E9B /* data_process.h */,
0E750FA91D9AF27F00337E9B /* data_process.c */,
- 0E750FB01D9AF27F00337E9B /* encoding.h */,
- 0E750FAF1D9AF27F00337E9B /* encoding.c */,
- 0E750FAD1D9AF27F00337E9B /* encoding_detect.c */,
- 0E750FAC1D9AF27F00337E9B /* encoding_detect_resource.h */,
- 0E750FAE1D9AF27F00337E9B /* encoding_resource.h */,
- 0E750FB21D9AF27F00337E9B /* incoming.h */,
- 0E750FB11D9AF27F00337E9B /* incoming.c */,
0E750FB71D9AF27F00337E9B /* mynamespace.h */,
0E750FB61D9AF27F00337E9B /* mynamespace.c */,
0E750FB51D9AF27F00337E9B /* mynamespace_resource.h */,
- 0E750FBB1D9AF27F00337E9B /* mystring.h */,
- 0E750FBA1D9AF27F00337E9B /* mystring.c */,
+ 0EF5D1861E68362D0048E3D1 /* mystring.h */,
+ 0EF5D1851E68362D0048E3D1 /* mystring.c */,
0E750FBD1D9AF27F00337E9B /* parser.h */,
0E750FBC1D9AF27F00337E9B /* parser.c */,
- 0E750FBE1D9AF27F00337E9B /* perf.c */,
0E750FC01D9AF27F00337E9B /* rules.h */,
0E750FBF1D9AF27F00337E9B /* rules.c */,
0E750FC21D9AF27F00337E9B /* serialization.h */,
@@ -544,8 +615,6 @@
0E750FC71D9AF27F00337E9B /* tag.c */,
0E750FC61D9AF27F00337E9B /* tag_init.c */,
0E750FC51D9AF27F00337E9B /* tag_const.h */,
- 0E750FCA1D9AF27F00337E9B /* thread.h */,
- 0E750FC91D9AF27F00337E9B /* thread.c */,
0E750FCC1D9AF27F00337E9B /* token.h */,
0E750FCB1D9AF27F00337E9B /* token.c */,
0E750FD41D9AF27F00337E9B /* tokenizer.h */,
@@ -558,9 +627,6 @@
0E750FD11D9AF27F00337E9B /* tokenizer_script.c */,
0E750FD61D9AF27F00337E9B /* tree.h */,
0E750FD51D9AF27F00337E9B /* tree.c */,
- 0E750FE61D9AF27F00337E9B /* utils.h */,
- 0E750FE51D9AF27F00337E9B /* utils.c */,
- 0E750FD71D9AF27F00337E9B /* utils */,
);
name = myhtml;
sourceTree = "<group>";
@@ -608,34 +674,34 @@
0E750EEB1D9AF22E00337E9B /* myfont */ = {
isa = PBXGroup;
children = (
- 0E750EFC1D9AF26300337E9B /* cmap.c */,
+ 0E750F0B1D9AF26300337E9B /* myfont.h */,
+ 0E750F0A1D9AF26300337E9B /* myfont.c */,
0E750EFD1D9AF26300337E9B /* cmap.h */,
- 0E750EFE1D9AF26300337E9B /* glyf.c */,
+ 0E750EFC1D9AF26300337E9B /* cmap.c */,
0E750EFF1D9AF26300337E9B /* glyf.h */,
- 0E750F001D9AF26300337E9B /* head.c */,
+ 0E750EFE1D9AF26300337E9B /* glyf.c */,
0E750F011D9AF26300337E9B /* head.h */,
- 0E750F021D9AF26300337E9B /* hhea.c */,
+ 0E750F001D9AF26300337E9B /* head.c */,
0E750F031D9AF26300337E9B /* hhea.h */,
- 0E750F041D9AF26300337E9B /* hmtx.c */,
+ 0E750F021D9AF26300337E9B /* hhea.c */,
0E750F051D9AF26300337E9B /* hmtx.h */,
- 0E750F061D9AF26300337E9B /* loca.c */,
+ 0E750F041D9AF26300337E9B /* hmtx.c */,
0E750F071D9AF26300337E9B /* loca.h */,
- 0E750F081D9AF26300337E9B /* maxp.c */,
+ 0E750F061D9AF26300337E9B /* loca.c */,
0E750F091D9AF26300337E9B /* maxp.h */,
- 0E750F0A1D9AF26300337E9B /* myfont.c */,
- 0E750F0B1D9AF26300337E9B /* myfont.h */,
- 0E750F0C1D9AF26300337E9B /* myosi.c */,
+ 0E750F081D9AF26300337E9B /* maxp.c */,
0E750F0D1D9AF26300337E9B /* myosi.h */,
- 0E750F0E1D9AF26300337E9B /* name.c */,
+ 0E750F0C1D9AF26300337E9B /* myosi.c */,
0E750F0F1D9AF26300337E9B /* name.h */,
- 0E750F101D9AF26300337E9B /* os_2.c */,
+ 0E750F0E1D9AF26300337E9B /* name.c */,
0E750F111D9AF26300337E9B /* os_2.h */,
- 0E750F121D9AF26300337E9B /* pclt.c */,
+ 0E750F101D9AF26300337E9B /* os_2.c */,
0E750F131D9AF26300337E9B /* pclt.h */,
- 0E750F141D9AF26300337E9B /* vhea.c */,
+ 0E750F121D9AF26300337E9B /* pclt.c */,
0E750F151D9AF26300337E9B /* vhea.h */,
- 0E750F161D9AF26300337E9B /* vmtx.c */,
+ 0E750F141D9AF26300337E9B /* vhea.c */,
0E750F171D9AF26300337E9B /* vmtx.h */,
+ 0E750F161D9AF26300337E9B /* vmtx.c */,
);
name = myfont;
sourceTree = "<group>";
@@ -801,31 +867,6 @@
path = ../../source/mycss/values;
sourceTree = "<group>";
};
- 0E750FD71D9AF27F00337E9B /* utils */ = {
- isa = PBXGroup;
- children = (
- 0E0D738B1E2F67DB00FC97DE /* mhash.h */,
- 0E0D738A1E2F67DB00FC97DE /* mhash.c */,
- 0E0D5D001E003A5E00EBFDD6 /* avl_tree.h */,
- 0E0D5CFF1E003A5E00EBFDD6 /* avl_tree.c */,
- 0E750FD91D9AF27F00337E9B /* mchar_async.h */,
- 0E750FD81D9AF27F00337E9B /* mchar_async.c */,
- 0E750FDA1D9AF27F00337E9B /* mcobject.c */,
- 0E750FDB1D9AF27F00337E9B /* mcobject.h */,
- 0E750FDC1D9AF27F00337E9B /* mcobject_async.c */,
- 0E750FDD1D9AF27F00337E9B /* mcobject_async.h */,
- 0E750FDE1D9AF27F00337E9B /* mcsimple.c */,
- 0E750FDF1D9AF27F00337E9B /* mcsimple.h */,
- 0E750FE01D9AF27F00337E9B /* mcsync.c */,
- 0E750FE11D9AF27F00337E9B /* mcsync.h */,
- 0E750FE21D9AF27F00337E9B /* mctree.c */,
- 0E750FE31D9AF27F00337E9B /* mctree.h */,
- 0E750FE41D9AF27F00337E9B /* resources.h */,
- );
- name = utils;
- path = ../../source/myhtml/utils;
- sourceTree = "<group>";
- };
0E7F782A1DD3DF3E003B6053 /* layer */ = {
isa = PBXGroup;
children = (
@@ -850,6 +891,92 @@
name = render;
sourceTree = "<group>";
};
+ 0EF5D14A1E6805C90048E3D1 /* mycore */ = {
+ isa = PBXGroup;
+ children = (
+ 0EF5D1501E680D880048E3D1 /* myosi.h */,
+ 0EF5D1781E680EA10048E3D1 /* myosi.c */,
+ 0EF5D14E1E680D880048E3D1 /* incoming.h */,
+ 0EF5D14D1E680D880048E3D1 /* incoming.c */,
+ 0EF5D1521E680D880048E3D1 /* mystring.h */,
+ 0EF5D1511E680D880048E3D1 /* mystring.c */,
+ 0EF5D1551E680D880048E3D1 /* mythread.h */,
+ 0EF5D1541E680D880048E3D1 /* mythread.c */,
+ 0EF5D19D1E6AE8BF0048E3D1 /* thread_queue.h */,
+ 0EF5D19C1E6AE8BF0048E3D1 /* thread_queue.c */,
+ 0EF5D1571E680D880048E3D1 /* utils.h */,
+ 0EF5D1561E680D880048E3D1 /* utils.c */,
+ 0EF5D15E1E680D8D0048E3D1 /* utils */,
+ );
+ name = mycore;
+ sourceTree = "<group>";
+ };
+ 0EF5D14C1E6805D70048E3D1 /* myencoding */ = {
+ isa = PBXGroup;
+ children = (
+ 0EF5D1811E681FC90048E3D1 /* myosi.h */,
+ 0EF5D17E1E6819E80048E3D1 /* encoding.h */,
+ 0EF5D17D1E6819E80048E3D1 /* encoding.c */,
+ 0EF5D1831E6822BD0048E3D1 /* mystring.h */,
+ 0EF5D1821E6822BD0048E3D1 /* mystring.c */,
+ 0EF5D17B1E6819E80048E3D1 /* detect.c */,
+ 0EF5D17A1E6819E80048E3D1 /* detect_resource.h */,
+ 0EF5D17C1E6819E80048E3D1 /* resource.h */,
+ );
+ name = myencoding;
+ sourceTree = "<group>";
+ };
+ 0EF5D15E1E680D8D0048E3D1 /* utils */ = {
+ isa = PBXGroup;
+ children = (
+ 0EF5D1611E680DA50048E3D1 /* avl_tree.h */,
+ 0EF5D1601E680DA50048E3D1 /* avl_tree.c */,
+ 0EF5D1631E680DA50048E3D1 /* mchar_async.h */,
+ 0EF5D1621E680DA50048E3D1 /* mchar_async.c */,
+ 0EF5D1651E680DA50048E3D1 /* mcobject_async.h */,
+ 0EF5D1641E680DA50048E3D1 /* mcobject_async.c */,
+ 0EF5D1671E680DA50048E3D1 /* mcobject.h */,
+ 0EF5D1661E680DA50048E3D1 /* mcobject.c */,
+ 0EF5D1691E680DA50048E3D1 /* mcsimple.h */,
+ 0EF5D1681E680DA50048E3D1 /* mcsimple.c */,
+ 0EF5D16B1E680DA50048E3D1 /* mcsync.h */,
+ 0EF5D16A1E680DA50048E3D1 /* mcsync.c */,
+ 0EF5D16D1E680DA50048E3D1 /* mctree.h */,
+ 0EF5D16C1E680DA50048E3D1 /* mctree.c */,
+ 0EF5D16F1E680DA50048E3D1 /* mhash.h */,
+ 0EF5D16E1E680DA50048E3D1 /* mhash.c */,
+ 0EF5D15F1E680DA50048E3D1 /* resources.h */,
+ );
+ name = utils;
+ sourceTree = "<group>";
+ };
+ 0EF5D1A01E6DDD8E0048E3D1 /* posix */ = {
+ isa = PBXGroup;
+ children = (
+ 0EF5D1A11E6DDDA50048E3D1 /* mycore */,
+ );
+ name = posix;
+ sourceTree = "<group>";
+ };
+ 0EF5D1A11E6DDDA50048E3D1 /* mycore */ = {
+ isa = PBXGroup;
+ children = (
+ 0EF5D1A31E6DDDC20048E3D1 /* thread.c */,
+ 0EF5D1A41E6DDDC20048E3D1 /* io.c */,
+ 0EF5D1A51E6DDDC20048E3D1 /* memory.c */,
+ 0EF5D1A21E6DDDAF0048E3D1 /* utils */,
+ );
+ name = mycore;
+ sourceTree = "<group>";
+ };
+ 0EF5D1A21E6DDDAF0048E3D1 /* utils */ = {
+ isa = PBXGroup;
+ children = (
+ 0EF5D1AB1E6DDDCD0048E3D1 /* mcsync.c */,
+ );
+ name = utils;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -907,42 +1034,51 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 0EF5D1771E680DA50048E3D1 /* mhash.c in Sources */,
0EA033771DB6AFBA009CB2B9 /* raw.c in Sources */,
+ 0EF5D1AC1E6DDDCD0048E3D1 /* mcsync.c in Sources */,
0EF2D5E91E01DFD5000570B6 /* tree_node.c in Sources */,
0E750FF71D9AF27F00337E9B /* tag.c in Sources */,
- 0E750FF21D9AF27F00337E9B /* perf.c in Sources */,
- 0E750FFF1D9AF27F00337E9B /* mchar_async.c in Sources */,
0E750F1C1D9AF26300337E9B /* hmtx.c in Sources */,
0E750F981D9AF27200337E9B /* state.c in Sources */,
0E0239881D9FEBE10084A81A /* modest.c in Sources */,
0E0239851D9FEAB90084A81A /* node.c in Sources */,
+ 0EF5D1741E680DA50048E3D1 /* mcsimple.c in Sources */,
0E750F201D9AF26300337E9B /* myosi.c in Sources */,
+ 0EF5D1A91E6DDDC20048E3D1 /* memory.c in Sources */,
0E750F181D9AF26300337E9B /* cmap.c in Sources */,
0E750F911D9AF27200337E9B /* parser.c in Sources */,
- 0E750FEC1D9AF27F00337E9B /* incoming.c in Sources */,
0E750F931D9AF27200337E9B /* function_parser.c in Sources */,
0E750FF91D9AF27F00337E9B /* token.c in Sources */,
+ 0E10FEE51E5F720200242B61 /* path.c in Sources */,
0E750F841D9AF27200337E9B /* init.c in Sources */,
0E750F891D9AF27200337E9B /* state.c in Sources */,
+ 0E10FEE91E5F720200242B61 /* url.c in Sources */,
0E750F1A1D9AF26300337E9B /* head.c in Sources */,
+ 0EF5D15C1E680D880048E3D1 /* mythread.c in Sources */,
0E750F1B1D9AF26300337E9B /* hhea.c in Sources */,
0E0C91991DB107E7007A0501 /* property.c in Sources */,
0E750EFB1D9AF25300337E9B /* type.c in Sources */,
0E5E2AB21DC76D67007836AB /* parser_image.c in Sources */,
0E750F191D9AF26300337E9B /* glyf.c in Sources */,
0E750F8B1D9AF27200337E9B /* mystring.c in Sources */,
- 0E7510031D9AF27F00337E9B /* mcsync.c in Sources */,
+ 0EF5D1761E680DA50048E3D1 /* mctree.c in Sources */,
+ 0EF5D1581E680D880048E3D1 /* incoming.c in Sources */,
+ 0EF5D1A81E6DDDC20048E3D1 /* io.c in Sources */,
0E750F231D9AF26300337E9B /* pclt.c in Sources */,
0E750F8C1D9AF27200337E9B /* init.c in Sources */,
+ 0E10FEE11E5F720200242B61 /* host.c in Sources */,
0EF68DCE1DBF6CF000B0DEA4 /* color_parser.c in Sources */,
+ 0E10FEE81E5F720200242B61 /* serialization.c in Sources */,
0E750F1F1D9AF26300337E9B /* myfont.c in Sources */,
- 0E750FF81D9AF27F00337E9B /* thread.c in Sources */,
0E750FE71D9AF27F00337E9B /* callback.c in Sources */,
+ 0EF5D1791E680EA10048E3D1 /* myosi.c in Sources */,
0EF2D5EA1E01DFD5000570B6 /* tree.c in Sources */,
+ 0EF5D1721E680DA50048E3D1 /* mcobject_async.c in Sources */,
0E79EE951DC8E270004FF5DC /* stack.c in Sources */,
0E750F8D1D9AF27200337E9B /* parser.c in Sources */,
+ 0EF5D1701E680DA50048E3D1 /* avl_tree.c in Sources */,
0E750F971D9AF27200337E9B /* pseudo.c in Sources */,
- 0E750FEA1D9AF27F00337E9B /* encoding_detect.c in Sources */,
0E750EFA1D9AF25300337E9B /* pseudo_class.c in Sources */,
0E0C91961DB1064E007A0501 /* serialization.c in Sources */,
0E5E2AB01DC7682A007836AB /* parser_url.c in Sources */,
@@ -959,66 +1095,72 @@
0E0C918C1DAECB56007A0501 /* serialization.c in Sources */,
0E750FFE1D9AF27F00337E9B /* tree.c in Sources */,
0E750FEE1D9AF27F00337E9B /* mynamespace.c in Sources */,
- 0E7510021D9AF27F00337E9B /* mcsimple.c in Sources */,
0E750F861D9AF27200337E9B /* state.c in Sources */,
0E750F251D9AF26300337E9B /* vmtx.c in Sources */,
0E750F801D9AF27200337E9B /* an_plus_b.c in Sources */,
- 0E750FEF1D9AF27F00337E9B /* myosi.c in Sources */,
- 0E0D738C1E2F67DB00FC97DE /* mhash.c in Sources */,
0E750F9B1D9AF27200337E9B /* tokenizer_end.c in Sources */,
0E750F851D9AF27200337E9B /* parser.c in Sources */,
+ 0EF5D1A71E6DDDC20048E3D1 /* thread.c in Sources */,
0E750F871D9AF27200337E9B /* entry.c in Sources */,
0E818EF61DAE6F8F005B0C77 /* serialization.c in Sources */,
0E0239811D9FE8EC0084A81A /* type.c in Sources */,
0E750F811D9AF27200337E9B /* check.c in Sources */,
- 0E0D5D011E003A5E00EBFDD6 /* avl_tree.c in Sources */,
0E750EF91D9AF25300337E9B /* match.c in Sources */,
0E7F78351DD3E0D5003B6053 /* begin.c in Sources */,
0E750F9E1D9AF27200337E9B /* consume.c in Sources */,
0E750F9A1D9AF27200337E9B /* stylesheet.c in Sources */,
0E750F9D1D9AF27200337E9B /* tokenizer.c in Sources */,
+ 0EF5D1871E68362D0048E3D1 /* mystring.c in Sources */,
+ 0EF5D1751E680DA50048E3D1 /* mcsync.c in Sources */,
0E750FF11D9AF27F00337E9B /* parser.c in Sources */,
0E750F221D9AF26300337E9B /* os_2.c in Sources */,
0E0460221DBE1B0D00685A80 /* color.c in Sources */,
0E750F991D9AF27200337E9B /* value.c in Sources */,
0E0C919C1DB10866007A0501 /* raw_property.c in Sources */,
- 0E750FF01D9AF27F00337E9B /* mystring.c in Sources */,
0E750F961D9AF27200337E9B /* parser.c in Sources */,
0E5AA4BD1DA9689700FF5358 /* shared.c in Sources */,
- 0E7510041D9AF27F00337E9B /* mctree.c in Sources */,
0E750F9F1D9AF27200337E9B /* serialization.c in Sources */,
0E750FF51D9AF27F00337E9B /* stream.c in Sources */,
+ 0E10FEEA1E5F720200242B61 /* utils.c in Sources */,
0E750F951D9AF27200337E9B /* list.c in Sources */,
- 0E7510051D9AF27F00337E9B /* utils.c in Sources */,
0E750F881D9AF27200337E9B /* init.c in Sources */,
- 0E7510001D9AF27F00337E9B /* mcobject.c in Sources */,
+ 0E10FEE41E5F720200242B61 /* parser.c in Sources */,
0E750FFB1D9AF27F00337E9B /* tokenizer_end.c in Sources */,
+ 0EF5D1841E6822BD0048E3D1 /* mystring.c in Sources */,
0E750FA01D9AF27200337E9B /* units.c in Sources */,
+ 0E10FEE71E5F720200242B61 /* scheme.c in Sources */,
0E750F211D9AF26300337E9B /* name.c in Sources */,
0E750F241D9AF26300337E9B /* vhea.c in Sources */,
+ 0EF5D1731E680DA50048E3D1 /* mcobject.c in Sources */,
0EF2D5F71E01E0BD000570B6 /* default.c in Sources */,
0E750F831D9AF27200337E9B /* entry.c in Sources */,
+ 0E10FEE61E5F720200242B61 /* punycode.c in Sources */,
0E750FF31D9AF27F00337E9B /* rules.c in Sources */,
0E750FFD1D9AF27F00337E9B /* tokenizer.c in Sources */,
0EF2D5E81E01DFD5000570B6 /* binding.c in Sources */,
+ 0E10FEE31E5F720200242B61 /* parser_end.c in Sources */,
0E750FF41D9AF27F00337E9B /* serialization.c in Sources */,
0EF808A61DA08BBE001AF6EF /* map.c in Sources */,
0E750F8F1D9AF27200337E9B /* parser.c in Sources */,
0E750FA11D9AF27200337E9B /* values.c in Sources */,
0E0C918F1DAED006007A0501 /* serialization.c in Sources */,
+ 0EF5D15D1E680D880048E3D1 /* utils.c in Sources */,
0E750FED1D9AF27F00337E9B /* myhtml.c in Sources */,
0E750F821D9AF27200337E9B /* convert.c in Sources */,
0E750FE91D9AF27F00337E9B /* data_process.c in Sources */,
+ 0EF5D15A1E680D880048E3D1 /* mystring.c in Sources */,
+ 0EF5D1711E680DA50048E3D1 /* mchar_async.c in Sources */,
0E4B525C1DC13BBB0095026A /* parser_text_decoration.c in Sources */,
0EF2D5F21E01E089000570B6 /* default.c in Sources */,
- 0E7510011D9AF27F00337E9B /* mcobject_async.c in Sources */,
+ 0EF5D1801E6819E80048E3D1 /* encoding.c in Sources */,
0E750FE81D9AF27F00337E9B /* charef.c in Sources */,
0EE852811DC94891003BB21C /* parser_background.c in Sources */,
0E750EE31D9AF1D500337E9B /* main.c in Sources */,
0E750F941D9AF27200337E9B /* init.c in Sources */,
+ 0EF5D19E1E6AE8BF0048E3D1 /* thread_queue.c in Sources */,
0E750F1E1D9AF26300337E9B /* maxp.c in Sources */,
0E750F8A1D9AF27200337E9B /* mycss.c in Sources */,
- 0E750FEB1D9AF27F00337E9B /* encoding.c in Sources */,
+ 0E10FEE21E5F720200242B61 /* myosi.c in Sources */,
0E0C91921DAED0F5007A0501 /* serialization.c in Sources */,
0EF2D5ED1E01E04A000570B6 /* declaration.c in Sources */,
0E7F78381DD3E2E5003B6053 /* glue.c in Sources */,
@@ -1027,6 +1169,7 @@
0E0239731D9D97150084A81A /* thread.c in Sources */,
0E750FFC1D9AF27F00337E9B /* tokenizer_script.c in Sources */,
0E750EF81D9AF25300337E9B /* finder.c in Sources */,
+ 0EF5D17F1E6819E80048E3D1 /* detect.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1060,7 +1203,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
- GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_C_LANGUAGE_STANDARD = c99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
@@ -1082,8 +1225,8 @@
HEADER_SEARCH_PATHS = ../../source;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
- "-DMyHTML_WITH_PERF",
- "-DMyHTML_FORCE_RDTSC",
+ "-DMyCORE_WITH_PERF",
+ "-DMyCORE_FORCE_RDTSC",
);
PRODUCT_NAME = "$(TARGET_NAME)";
};
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 023649e..17a24bd 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/devel/osx/Modest.xcodeproj/xcuserdata/alexanderborisov.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/devel/osx/Modest.xcodeproj/xcuserdata/alexanderborisov.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
index fe2b454..d238ccc 100644
--- a/devel/osx/Modest.xcodeproj/xcuserdata/alexanderborisov.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+++ b/devel/osx/Modest.xcodeproj/xcuserdata/alexanderborisov.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
@@ -2,4 +2,22 @@
<Bucket
type = "1"
version = "2.0">
+ <Breakpoints>
+ <BreakpointProxy
+ BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+ <BreakpointContent
+ shouldBeEnabled = "Yes"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ filePath = "../../source/myfont/glyf.c"
+ timestampString = "511106642.54925"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "71"
+ endingLineNumber = "71"
+ landmarkName = "myfont_glyf_load_data()"
+ landmarkType = "9">
+ </BreakpointContent>
+ </BreakpointProxy>
+ </Breakpoints>
</Bucket>
diff --git a/devel/osx/Modest.xcodeproj/xcuserdata/alexanderborisov.xcuserdatad/xcschemes/Modest.xcscheme b/devel/osx/Modest.xcodeproj/xcuserdata/alexanderborisov.xcuserdatad/xcschemes/Modest.xcscheme
index 448dc8b..2fcec69 100644
--- a/devel/osx/Modest.xcodeproj/xcuserdata/alexanderborisov.xcuserdatad/xcschemes/Modest.xcscheme
+++ b/devel/osx/Modest.xcodeproj/xcuserdata/alexanderborisov.xcuserdatad/xcschemes/Modest.xcscheme
@@ -49,7 +49,6 @@
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
- enableAddressSanitizer = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
diff --git a/devel/osx/Modest/main.c b/devel/osx/Modest/main.c
index aea9220..0dbda23 100644
--- a/devel/osx/Modest/main.c
+++ b/devel/osx/Modest/main.c
@@ -16,20 +16,24 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
+ */
-#include "myhtml/myhtml.h"
-#include "mycss/mycss.h"
-#include "modest/modest.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+<<<<<<< Updated upstream
#include "mycss/selectors/serialization.h"
#include "mycss/declaration/init.h"
#include "modest/finder/finder.h"
#include "modest/finder/thread.h"
-#include "myhtml/encoding.h"
+#include "myencoding/encoding.h"
#include "myfont/myfont.h"
#include "modest/node/serialization.h"
+#include "myurl/url.h"
+#include "myurl/serialization.h"
+
struct res_data {
char *data;
size_t size;
@@ -43,7 +47,7 @@ struct res_data load_data(const char* filename)
long l = ftell(f);
fseek(f, 0L, SEEK_SET);
- char *html = (char*)myhtml_malloc(l);
+ char *html = (char*)mycore_malloc(l);
if(fread(html, 1, l, f) != l) {
exit(1);
}
@@ -52,245 +56,2157 @@ struct res_data load_data(const char* filename)
struct res_data res = {html, (size_t)l};
return res;
+=======
+#include <myfont/myfont.h>
+#include <myhtml/encoding.h>
+
+void usage(const char *path, float font_size, size_t codepoint)
+{
+ printf("Usage:\n");
+ printf("\tprogram [char in UTF-8] [font fize in px] [font path]\n");
+ printf("\tdefault: program \"x\" %.f %s\n\n", font_size, path);
+>>>>>>> Stashed changes
}
-void serialization_callback(const char* data, size_t len, void* ctx)
+int main(int argc, const char * argv[])
{
+<<<<<<< Updated upstream
printf("%.*s", (int)len, data);
}
-myhtml_tree_t * myhtml(const char* data, size_t data_size, bool is_file, bool print_result, myhtml_callback_tree_node_f cai, void* cai_ctx)
+//myhtml_tree_t * myhtml(const char* data, size_t data_size, bool is_file, bool print_result, myhtml_callback_tree_node_f cai, void* cai_ctx)
+//{
+// setbuf(stdout, NULL);
+//
+// myhtml_t* myhtml = myhtml_create();
+// myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);
+//
+//// uint64_t all_start = mycore_hperf_clock(NULL);
+//// uint64_t tree_init_start = mycore_hperf_clock(NULL);
+//
+// myhtml_tree_t* tree = myhtml_tree_create();
+// myhtml_tree_init(tree, myhtml);
+//
+// myhtml_callback_tree_node_insert_set(tree, cai, cai_ctx);
+//
+//// uint64_t tree_init_stop = mycore_hperf_clock(NULL);
+//// uint64_t parse_start = mycore_hperf_clock(NULL);
+//
+// if(is_file) {
+// struct res_data res = load_data(data);
+//
+// myencoding_t encoding = myencoding_prescan_stream_to_determine_encoding(res.data, res.size);
+//
+// if(encoding == MyENCODING_NOT_DETERMINED)
+// encoding = MyENCODING_UTF_8;
+//
+// myhtml_parse(tree, encoding, res.data, res.size);
+// free(res.data);
+// }
+// else {
+// myhtml_parse(tree, MyENCODING_UTF_8, data, data_size);
+// }
+//
+//// uint64_t parse_stop = mycore_hperf_clock(NULL);
+//// uint64_t all_stop = mycore_hperf_clock(NULL);
+//
+// if(print_result) {
+// myhtml_tree_print_node_children(tree, tree->document, stdout, 0);
+// }
+//
+// printf("\n\nMyHTML Information:\n");
+//// printf("\tTicks/sec: %llu\n", (unsigned long long) mycore_hperf_res(NULL));
+//// mycore_hperf_print("\tFirst Tree init", tree_init_start, tree_init_stop, stdout);
+//// mycore_hperf_print("\tParse html", parse_start, parse_stop, stdout);
+//// mycore_hperf_print("\tTotal", all_start, all_stop, stdout);
+//// printf("\n");
+//
+// //myhtml_tree_destroy(tree);
+// //myhtml_destroy(myhtml);
+//
+// return tree;
+//}
+//
+//mycss_entry_t * mycss(const char* data, size_t data_size, bool is_file, bool print_result)
+//{
+// // base init
+// mycss_t *mycss = mycss_create();
+// mycss_init(mycss);
+//
+// // currenr entry work init
+// mycss_entry_t *entry = mycss_entry_create();
+// mycss_entry_init(mycss, entry);
+//
+// uint64_t parse_start = mycore_hperf_clock(NULL);
+//
+// if(is_file) {
+// struct res_data res = load_data(data);
+// mycss_parse(entry, MyENCODING_UTF_8, res.data, res.size);
+// free(res.data);
+// }
+// else {
+// mycss_parse(entry, MyENCODING_UTF_8, data, data_size);
+// }
+//
+// uint64_t parse_stop = mycore_hperf_clock(NULL);
+//
+// if(print_result) {
+// printf("\n");
+// mycss_stylesheet_t *stylesheet = mycss_entry_stylesheet(entry);
+// mycss_selectors_serialization_list(entry->selectors, stylesheet->sel_list_first, serialization_callback, NULL);
+// }
+//
+// printf("\n------------\nMyCSS Information:\n");
+// printf("\tTicks/sec: %llu\n", (unsigned long long) mycore_hperf_res(NULL));
+// mycore_hperf_print("\tParse css", parse_start, parse_stop, stdout);
+//
+// //mycss_entry_destroy(entry, true);
+// //mycss_destroy(mycss, true);
+//
+// return entry;
+//}
+//
+//void print_tree_after_all(modest_t* modest, myhtml_tree_t* myhtml_tree, myhtml_tree_node_t* scope_node, mycss_entry_t *mycss_entry)
+//{
+// myhtml_tree_node_t* node = scope_node;
+//
+// while(node) {
+// modest_node_t *m_node = (modest_node_t*)node->data;
+//
+// myhtml_tree_print_node(myhtml_tree, node, stdout);
+//
+// if(m_node) {
+// printf("\tstyles: ");
+//
+// modest_node_raw_serialization(modest, m_node, serialization_callback, NULL);
+//
+// printf("\n");
+// }
+//
+// if(node->child)
+// node = node->child;
+// else {
+// while(node != scope_node && node->next == NULL)
+// node = node->parent;
+//
+// if(node == scope_node)
+// break;
+//
+// node = node->next;
+// }
+// }
+//}
+//
+//size_t count = 0;
+//
+//void modest_callback_for_create_mnode(myhtml_tree_t* tree, myhtml_tree_node_t* node, void* ctx)
+//{
+// if(node->tag_id == MyHTML_TAG__TEXT) {
+// return;
+// }
+//
+// modest_t *modest = (modest_t*)ctx;
+//
+// /* create modest node */
+// modest_node_t *m_node = modest_node_create(modest);
+// if(m_node == NULL)
+// return;
+//
+// modest_node_init(modest, m_node);
+//
+// node->data = (void*)m_node;
+//}
+//
+//int main2222(int argc, const char * argv[])
+//{
+// const char* data_base = "https://lenta.ru/news/2017/........./02/23/minsk_docs/";
+// const char* data_rel = "/comments//news/2017/02/23/minsk_docs/";
+//
+// printf("base: %s\n", data_base);
+// printf("rela: %s\n", data_rel);
+//
+// myurl_t *url = myurl_create();
+// myurl_init(url);
+//
+// mystatus_t status;
+// myurl_entry_t *url_base = myurl_parse(url, data_base, strlen(data_base), NULL, &status);
+// myurl_entry_t *url_entry = myurl_parse(url, data_rel, strlen(data_rel), url_base, &status);
+//
+// printf("result: ");
+// myurl_serialization(url_entry, false, serialization_callback, NULL);
+// printf("\n");
+//
+// if(status) {
+// exit(1);
+// }
+//
+// myurl_destroy(url, true);
+//
+// return 0;
+//}
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//#include <time.h>
+//#include <sys/stat.h>
+//
+//#include <stdbool.h>
+//
+//
+//
+//#include <stdio.h>
+//#include <stdlib.h>
+//#include <dirent.h>
+//#include <string.h>
+//#include <unistd.h>
+//
+//
+//struct res_html_test {
+// char *html;
+// size_t len;
+// size_t size;
+//};
+//
+//struct chunk_res_test {
+// struct res_html_test data;
+// struct res_html_test result;
+//};
+//
+//struct chunk_res_result {
+// myhtml_tree_t *tree;
+// size_t good;
+// size_t bad;
+//
+// bool is_fragment;
+// bool enabled_script;
+// myhtml_tag_id_t tag_id;
+// enum myhtml_namespace ns;
+//};
+//
+//typedef void (*chunk_test_f)(struct chunk_res_test *res_test, struct chunk_res_result *result);
+//
+//size_t read_line(char *html, size_t size)
+//{
+// size_t len;
+// for (len = 0; len < size; len++) {
+// if(html[len] == '\n')
+// break;
+// }
+//
+// return len;
+//}
+//
+//void init_res_test_data(struct res_html_test* data)
+//{
+// data->len = 0;
+// data->size = 4096;
+// data->html = malloc(sizeof(char) * data->size);
+//
+// if(data->html == NULL) {
+// fprintf(stderr, "Can't init resurces for test object\n");
+// exit(EXIT_FAILURE);
+// }
+//}
+//
+//void init_res_test(struct chunk_res_test* res_test)
+//{
+// init_res_test_data(&res_test->data);
+// init_res_test_data(&res_test->result);
+//}
+//
+//void clean_res_test(struct chunk_res_test* res_test)
+//{
+// res_test->data.len = 0;
+// res_test->result.len = 0;
+//}
+//
+//void append_to_test(struct res_html_test* data, const char *text, size_t len, bool add_newline, bool to_lowercase)
+//{
+// if(text == NULL)
+// return;
+//
+// if((data->len + len + 2) >= data->size) {
+// data->size = data->size + len + 2048;
+// data->html = realloc(data->html, data->size);
+//
+// if(data->html == NULL) {
+// fprintf(stderr, "Can't realloc resurces for test object\n");
+// exit(EXIT_FAILURE);
+// }
+// }
+//
+// if(add_newline && data->len) {
+// data->html[data->len] = '\n';
+// data->len++;
+// }
+//
+// memcpy(&data->html[data->len], text, len);
+//
+// if(to_lowercase) {
+// for(size_t i = data->len; i < (data->len + len); i++) {
+// if(data->html[i] > 0x40 && data->html[i] < 0x5b)
+// data->html[i] |= 0x60;
+// }
+// }
+//
+// data->len += len;
+// data->html[data->len] = '\0';
+//}
+//
+//bool sort_text(myhtml_tree_attr_t *attr1, size_t size, myhtml_tree_attr_t **list, size_t i, size_t *len)
+//{
+// unsigned char *fisrt = (unsigned char*)attr1->key.data;
+// unsigned char *sec = (unsigned char*)list[i]->key.data;
+//
+// for (size_t j = 0; j < size; j++)
+// {
+// if(fisrt[j] > sec[j]) {
+// break;
+// }
+// else if(fisrt[j] < sec[j]) {
+// memmove(&list[(i + 1)], &list[i], sizeof(myhtml_tree_attr_t*));
+// list[i] = attr1;
+// (*len)++;
+// return true;
+// }
+// }
+//
+// return false;
+//}
+//
+//myhtml_tree_attr_t ** sort_attr(myhtml_tree_node_t *node)
+//{
+// myhtml_tree_attr_t *attr = myhtml_node_attribute_first(node);
+// myhtml_tree_attr_t **list = calloc(1024, sizeof(myhtml_tree_attr_t*));
+// size_t len = 1;
+// size_t i;
+//
+// list[0] = attr;
+// attr = attr->next;
+//
+// while (attr) {
+// for (i = 0; i < len; i++) {
+// if(attr->key.length > list[i]->key.length)
+// {
+// if(sort_text(attr, list[i]->key.length, list, i, &len))
+// break;
+// }
+// else {
+// if(sort_text(attr, attr->key.length, list, i, &len))
+// break;
+// }
+// }
+//
+// if(i == len) {
+// list[i] = attr;
+// len++;
+// }
+//
+// attr = attr->next;
+// }
+//
+// return list;
+//}
+//
+//void print_node_attr(myhtml_tree_node_t *node, struct res_html_test* data, size_t inc)
+//{
+// if(myhtml_node_attribute_first(node) == NULL)
+// return;
+//
+// myhtml_tree_attr_t **list_attr = sort_attr(node);
+//
+// size_t len = 0;
+// while (*list_attr != NULL)
+// {
+// myhtml_tree_attr_t *attr = *list_attr;
+//
+// const char *name = myhtml_attribute_key(attr, &len);
+//
+// if(name) {
+// append_to_test(data, "\n", 1, false, false);
+//
+// for(size_t i = 0; i < inc; i++)
+// append_to_test(data, " ", 2, false, false);
+//
+// if(attr->ns == MyHTML_NAMESPACE_XML) {
+// append_to_test(data, "xml ", 4, false, false);
+// }
+// else if(attr->ns == MyHTML_NAMESPACE_XMLNS) {
+// append_to_test(data, "xmlns ", 6, false, false);
+// }
+// else if(attr->ns == MyHTML_NAMESPACE_XLINK) {
+// append_to_test(data, "xlink ", 6, false, false);
+// }
+//
+// append_to_test(data, name, len, false, false);
+//
+// const char *value = myhtml_attribute_value(attr, &len);
+//
+// if(value) {
+// append_to_test(data, "=\"", 2, false, false);
+// append_to_test(data, value, len, false, false);
+// append_to_test(data, "\"", 1, false, false);
+// }
+// else {
+// append_to_test(data, "=\"\"", 3, false, false);
+// }
+// }
+//
+// //attr = myhtml_attribute_next(attr);
+// list_attr++;
+// }
+//}
+//
+//void print_tree(myhtml_tree_t* tree, myhtml_tree_node_t *node, struct res_html_test* data, size_t inc)
+//{
+// while (node)
+// {
+// if(data->len)
+// append_to_test(data, "\n", 1, false, false);
+//
+// for(size_t i = 0; i < inc; i++)
+// append_to_test(data, " ", 2, false, false);
+//
+// size_t len = 0;
+//
+// if(myhtml_node_tag_id(node) == MyHTML_TAG__TEXT)
+// {
+// const char *text = myhtml_node_text(node, &len);
+//
+// append_to_test(data, "\"", 1, false, false);
+// append_to_test(data, text, len, false, false);
+// append_to_test(data, "\"", 1, false, false);
+// }
+// else if(myhtml_node_tag_id(node) == MyHTML_TAG__COMMENT)
+// {
+// const char *text = myhtml_node_text(node, &len);
+//
+// append_to_test(data, "<!-- ", 5, false, false);
+// append_to_test(data, text, len, false, false);
+// append_to_test(data, " -->", 4, false, false);
+// }
+// else if(myhtml_node_tag_id(node) == MyHTML_TAG__DOCTYPE)
+// {
+// append_to_test(data, "<!DOCTYPE", strlen("<!DOCTYPE"), false, false);
+//
+// if(tree->doctype.attr_name) {
+// append_to_test(data, " ", 1, false, false);
+// append_to_test(data, tree->doctype.attr_name, strlen(tree->doctype.attr_name), false, false);
+// }
+//
+// if(tree->doctype.attr_public) {
+// append_to_test(data, " \"", 2, false, false);
+// append_to_test(data, tree->doctype.attr_public, strlen(tree->doctype.attr_public), false, false);
+// append_to_test(data, "\"", 1, false, false);
+// }
+//
+// if(tree->doctype.attr_system) {
+// append_to_test(data, " \"", 2, false, false);
+// append_to_test(data, tree->doctype.attr_system, strlen(tree->doctype.attr_system), false, false);
+// append_to_test(data, "\"", 1, false, false);
+// }
+//
+// append_to_test(data, ">", 1, false, false);
+// }
+// else {
+// const char *tag_name = myhtml_tag_name_by_id(tree, myhtml_node_tag_id(node), &len);
+//
+// if(tag_name) {
+// append_to_test(data, "<", 1, false, false);
+//
+// switch (myhtml_node_namespace(node)) {
+// case MyHTML_NAMESPACE_SVG:
+// append_to_test(data, "svg ", 4, false, false);
+// append_to_test(data, tag_name, len, false, false);
+// break;
+//
+// case MyHTML_NAMESPACE_MATHML:
+// append_to_test(data, "math ", 5, false, false);
+// append_to_test(data, tag_name, len, false, true);
+// break;
+//
+// default:
+// append_to_test(data, tag_name, len, false, false);
+// break;
+// }
+// }
+// else
+// // it can not be
+// printf("<!something is wrong!");
+//
+// // if(myhtml_node_is_close_self(node))
+// // append_to_test(data, " /", 2, false);
+//
+// append_to_test(data, ">", 1, false, false);
+//
+// if(myhtml_node_tag_id(node) == MyHTML_TAG_TEMPLATE &&
+// myhtml_node_namespace(node) == MyHTML_NAMESPACE_HTML)
+// {
+// append_to_test(data, "\n", 1, false, false);
+//
+// for(size_t i = 0; i <= inc; i++)
+// append_to_test(data, " ", 2, false, false);
+//
+// append_to_test(data, "content", 7, false, false);
+//
+// print_tree(tree, myhtml_node_child(node), data, (inc + 2));
+// node = myhtml_node_next(node);
+//
+// continue;
+// }
+//
+// // print node attributes
+// print_node_attr(node, data, (inc + 1));
+// }
+//
+// // print childs
+// print_tree(tree, myhtml_node_child(node), data, (inc + 1));
+// node = myhtml_node_next(node);
+// }
+//}
+//
+//void chunk_process(struct chunk_res_test *res_test, struct chunk_res_result *result)
+//{
+// struct res_html_test data;
+// init_res_test_data(&data);
+//
+// if(result->enabled_script)
+// result->tree->flags |= MyHTML_TREE_FLAGS_SCRIPT;
+//
+// //printf("%.*s\n", res_test->data.len, res_test->data.html);
+//
+// if(result->is_fragment == false) {
+// myhtml_parse_single(result->tree, MyENCODING_UTF_8, res_test->data.html, res_test->data.len);
+// print_tree(result->tree, result->tree->document->child, &data, 0);
+// }
+// else {
+// myhtml_parse_fragment_single(result->tree, MyENCODING_UTF_8, res_test->data.html, res_test->data.len, result->tag_id, result->ns);
+// print_tree(result->tree, result->tree->document->child->child, &data, 0);
+// }
+//
+// if(res_test->result.len != data.len) {
+// result->bad++;
+//
+// printf("Error:\n");
+// printf("Original raw:\n%.*s\n", (int)res_test->data.len, res_test->data.html);
+// printf("Original:\n%s\n", res_test->result.html);
+// printf("Result:\n%s\n", data.html);
+// }
+// else if(strcmp(res_test->result.html, data.html) == 0) {
+// result->good++;
+// printf("Done\n");
+// }
+// else {
+// result->bad++;
+// printf("Error with len ==:\n");
+// printf("Original raw:\n%.*s\n", (int)res_test->data.len, res_test->data.html);
+// printf("Original:\n%s\n", res_test->result.html);
+// printf("Result:\n%s\n", data.html);
+// }
+//
+// myhtml_tree_clean(result->tree);
+// //mythread_clean(result->tree->myhtml->thread);
+//
+// free(data.html);
+//}
+//
+//void read_chunk(struct res_data* res, chunk_test_f func, struct chunk_res_result *result)
+//{
+// struct chunk_res_test res_test;
+// init_res_test(&res_test);
+//
+// result->is_fragment = false;
+//
+// size_t i = 0; size_t state = 0;
+// while (i < res->size)
+// {
+// size_t line_len = read_line(&res->data[i], (res->size - i));
+//
+// if(line_len == 0 && state != 1) {
+// if((i + 1) < res->size && res->data[(i + 1)] != '#') {
+// append_to_test(&res_test.result, "\n", 1, true, false);
+// i++;
+// continue;
+// }
+//
+// if(res_test.data.len)
+// func(&res_test, result);
+//
+// state = 0;
+// result->is_fragment = false;
+// result->enabled_script = false;
+// clean_res_test(&res_test);
+// }
+// else if(res->data[i] == '#') {
+//
+// if(line_len == strlen("#script-on") && strncmp(&res->data[i], "#script-on", strlen("#script-on")) == 0) {
+// result->enabled_script = true;
+// }
+// else if(state == 0) {
+// if(strncmp(&res->data[i], "#data", line_len) == 0) {
+// state = 1;
+// }
+// }
+// else if(state == 1) {
+// if(strncmp(&res->data[i], "#errors", line_len) == 0) {
+// state = 2;
+// }
+// }
+// else if(state == 2 && line_len > 9) {
+// if(strncmp(&res->data[i], "#document-fragment", line_len) == 0) {
+// state = 3;
+// result->is_fragment = true;
+// }
+// }
+// else if(state == 2 || state == 3) {
+// if(strncmp(&res->data[i], "#document", line_len) == 0) {
+// state = 4;
+// }
+// }
+// else {
+// fprintf(stderr, "Bad position in text\n");
+// exit(EXIT_FAILURE);
+// }
+//
+// i += line_len;
+// }
+// else if(state == 1) {
+// append_to_test(&res_test.data, &res->data[i], line_len, true, false);
+// i += line_len;
+// }
+// else if(state == 3) {
+// const char *data = &res->data[i];
+// size_t j;
+//
+// for(j = 0; j < line_len; j++)
+// {
+// if(data[j] == ' ')
+// {
+// while(j < line_len) {
+// if(data[j] != ' ' && data[j] != '\n' && data[j] != '\t' && data[j] != '\r')
+// break;
+//
+// j++;
+// }
+//
+// break;
+// }
+// }
+//
+// if(j == line_len) {
+// result->tag_id = myhtml_tag_id_by_name(result->tree, data, line_len);
+// result->ns = MyHTML_NAMESPACE_HTML;
+// }
+// else {
+// result->tag_id = myhtml_tag_id_by_name(result->tree, &data[j], (line_len - j));
+//
+// if(strncasecmp("math", data, 4) == 0) {
+// result->ns = MyHTML_NAMESPACE_MATHML;
+// }
+// else if(strncasecmp("svg", data, 3) == 0) {
+// result->ns = MyHTML_NAMESPACE_SVG;
+// }
+// else {
+// result->ns = MyHTML_NAMESPACE_HTML;
+// }
+// }
+//
+// i += line_len;
+// }
+// else if(state == 4) {
+// if(res->data[i] == '|') {
+// append_to_test(&res_test.result, &res->data[(i + 2)], (line_len - 2), true, false);
+// }
+// else if(res->data[i] != '\n') {
+// append_to_test(&res_test.result, &res->data[i], line_len, true, false);
+// }
+//
+// i += line_len;
+// }
+// else {
+// i += line_len;
+// }
+//
+// i++;
+// }
+//}
+//
+//void read_dir(const char* from_dir)
+//{
+// myhtml_t* myhtml = myhtml_create();
+// myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);
+//
+// myhtml_tree_t* tree = myhtml_tree_create();
+// myhtml_tree_init(tree, myhtml);
+//
+// DIR *dir;
+// struct dirent *ent;
+// struct stat path_stat;
+//
+// size_t count = 0;
+// size_t from_dir_len = strlen(from_dir);
+//
+// char path[4096];
+// strncpy(path, from_dir, from_dir_len);
+//
+// if((dir = opendir(from_dir)) == NULL) {
+// fprintf(stderr, "Can't open directory: %s\n", from_dir);
+// }
+//
+// struct chunk_res_result result = {tree, 0, 0};
+//
+// while((ent = readdir(dir)) != NULL)
+// {
+// sprintf(&path[from_dir_len], "%s", ent->d_name);
+// stat(path, &path_stat);
+//
+// if(ent->d_name[0] != '.' && !S_ISDIR(path_stat.st_mode) &&
+// ent->d_namlen > 4 &&
+// strcmp(".dat", &ent->d_name[ (ent->d_namlen - 4) ]) == 0)
+// {
+// count++;
+//
+// struct res_data res = load_data(path);
+// read_chunk(&res, chunk_process, &result);
+// free(res.data);
+// }
+// }
+//
+// closedir (dir);
+//
+// myhtml_tree_destroy(tree);
+// myhtml_destroy(myhtml);
+//
+// printf("\nGood: %zu; Bad: %zu\n\n", result.good, result.bad);
+//}
+
+//#include "myhtml/serialization.h"
+//
+//int main(int argc, const char * argv[])
+//{
+// setbuf(stdout, 0);
+//
+//// read_dir("/new/C-git/tree-construction/");
+//// return 0;
+//
+// const char* path = "/new/test.html";
+// struct res_data res = load_data(path);
+//
+// size_t i = 0;
+//
+// myhtml_t* myhtml = myhtml_create();
+// myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);
+//
+// myhtml_tree_t* tree = myhtml_tree_create();
+// mystatus_t status = myhtml_tree_init(tree, myhtml);
+// if(status) {
+// fprintf(stderr, "Init Tree return BAD status!!!\n");
+// exit(EXIT_FAILURE);
+// }
+//
+// while(i < 1000) {
+// if(myhtml_parse(tree, MyENCODING_UTF_8, res.data, res.size)) {
+// fprintf(stderr, "Parser return BAD status!!!\n");
+// exit(EXIT_FAILURE);
+// }
+//
+// //myhtml_serialization_tree_callback(tree->document, serialization_callback, NULL);
+// //printf("%zu\n", i);
+// i++;
+// }
+//
+// myhtml_tree_destroy(tree);
+// myhtml_destroy(myhtml);
+//}
+
+
+
+
+
+
+
+
+
+
+
+/*
+ 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)
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <myfont/myfont.h>
+#include <myencoding/encoding.h>
+
+void usage(const char *path, float font_size, size_t codepoint)
+{
+ printf("Usage:\n");
+ printf("\tprogram [char in UTF-8] [font fize in px] [font path]\n");
+ printf("\tdefault: program \"x\" %.f %s\n\n", font_size, path);
+}
+
+int main(int argc, const char * argv[])
{
- setbuf(stdout, NULL);
+ /* set and get params */
+ const char *path = "/new/C-git/Modest/third_party/font/Arkhip.ttf";
+ float font_size = 200.0f;
- myhtml_t* myhtml = myhtml_create();
- myhtml_init(myhtml, MyHTML_OPTIONS_PARSE_MODE_SINGLE, 1, 0);
+ size_t codepoint;
+ myencoding_ascii_utf_8_to_codepoint((unsigned char*)"x", &codepoint);
- uint64_t all_start = myhtml_hperf_clock(NULL);
- uint64_t tree_init_start = myhtml_hperf_clock(NULL);
+ if (argc == 2) {
+ if(myencoding_ascii_utf_8_to_codepoint((const unsigned char*)argv[1], &codepoint) == 0) {
+=======
+ /* set and get params */
+ const char *path = "/new/C-git/Modest/third_party/font/Arkhip.ttf";
+ float font_size = 200.0f;
- myhtml_tree_t* tree = myhtml_tree_create();
- myhtml_tree_init(tree, myhtml);
+ size_t codepoint;
+ myhtml_encoding_ascii_utf_8_to_codepoint((unsigned char*)"x", &codepoint);
- myhtml_callback_tree_node_insert_set(tree, cai, cai_ctx);
-
- uint64_t tree_init_stop = myhtml_hperf_clock(NULL);
- uint64_t parse_start = myhtml_hperf_clock(NULL);
-
- if(is_file) {
- struct res_data res = load_data(data);
-
- myhtml_encoding_t encoding = myhtml_encoding_prescan_stream_to_determine_encoding(res.data, res.size);
+ if (argc == 2) {
+ if(myhtml_encoding_ascii_utf_8_to_codepoint((const unsigned char*)argv[1], &codepoint) == 0) {
+>>>>>>> Stashed changes
+ fprintf(stderr, "Bad char code point\n");
+ return EXIT_FAILURE;
+ }
+ }
+ else if (argc == 3) {
+ long num = strtol(argv[2], NULL, 0);
- if(encoding == MyHTML_ENCODING_NOT_DETERMINED)
- encoding = MyHTML_ENCODING_UTF_8;
+ if(num < 1) {
+ fprintf(stderr, "To small font size param\n");
+ return EXIT_FAILURE;
+ }
- myhtml_parse(tree, encoding, res.data, res.size);
- free(res.data);
+ font_size = (float)num;
+<<<<<<< Updated upstream
+ }
+ else if (argc == 4) {
+ path = argv[3];
}
else {
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, data, data_size);
+ usage(path, font_size, codepoint);
}
- uint64_t parse_stop = myhtml_hperf_clock(NULL);
- uint64_t all_stop = myhtml_hperf_clock(NULL);
+ myfont_font_t *mf = myfont_create();
+ myfont_init(mf);
- if(print_result) {
- myhtml_tree_print_node_children(tree, tree->document, stdout, 0);
- }
+ uint8_t *font_data;
+ mystatus_t mf_status = myfont_load_from_file(mf, path, &font_data, NULL);
- printf("\n\nMyHTML Information:\n");
- printf("\tTicks/sec: %llu\n", (unsigned long long) myhtml_hperf_res(NULL));
- myhtml_hperf_print("\tFirst Tree init", tree_init_start, tree_init_stop, stdout);
- myhtml_hperf_print("\tParse html", parse_start, parse_stop, stdout);
- myhtml_hperf_print("\tTotal", all_start, all_stop, stdout);
- printf("\n");
+ if(mf_status) {
+ myfont_destroy(mf, true);
+
+ if(mf_status == MyFONT_STATUS_ERROR_FILE_OPEN) {
+ fprintf(stderr, "Can't open font file %s\n", path);
+ }
+ else {
+ fprintf(stderr, "Can't load font file %s\n", path);
+ }
+
+ return EXIT_FAILURE;
+ }
- //myhtml_tree_destroy(tree);
- //myhtml_destroy(myhtml);
+ char data[5];
+ size_t len = myencoding_codepoint_to_ascii_utf_8(codepoint, data);
+ data[len] = '\0';
- return tree;
-}
-
-mycss_entry_t * mycss(const char* data, size_t data_size, bool is_file, bool print_result)
-{
- // base init
- mycss_t *mycss = mycss_create();
- mycss_init(mycss);
+ /* work code */
+ uint16_t glyph_index = myfont_glyph_index_by_codepoint(mf, codepoint, NULL);
- // currenr entry work init
- mycss_entry_t *entry = mycss_entry_create();
- mycss_entry_init(mycss, entry);
+ float baseline = myfont_metrics_baseline(mf, font_size);
+ float ascender = myfont_metrics_ascender(mf, font_size);
+ float descender = myfont_metrics_descender(mf, font_size);
+ float x_height = myfont_metrics_x_height(mf, font_size);
+ float cap_height = myfont_metrics_cap_height(mf, font_size);
+ float offset = myfont_metrics_glyph_offset_y(mf, codepoint, font_size, NULL);
+ float width = myfont_metrics_width(mf, codepoint, font_size, NULL);
+ float height = myfont_metrics_height(mf, codepoint, font_size, NULL);
- uint64_t parse_start = myhtml_hperf_clock(NULL);
+ /* print result */
+ printf("Font file: %s\n", path);
+ printf("Font size: %.fpx\n\n", font_size);
- if(is_file) {
- struct res_data res = load_data(data);
- mycss_parse(entry, MyHTML_ENCODING_UTF_8, res.data, res.size);
- free(res.data);
+ printf("Metrics for code point " MyCORE_FORMAT_Z " (%s):\n", codepoint, data);
+=======
}
- else {
- mycss_parse(entry, MyHTML_ENCODING_UTF_8, data, data_size);
+ else if (argc == 4) {
+ path = argv[3];
}
-
- uint64_t parse_stop = myhtml_hperf_clock(NULL);
-
- if(print_result) {
- printf("\n");
- mycss_stylesheet_t *stylesheet = mycss_entry_stylesheet(entry);
- mycss_selectors_serialization_list(entry->selectors, stylesheet->sel_list_first, serialization_callback, NULL);
+ else {
+ usage(path, font_size, codepoint);
}
- printf("\n------------\nMyCSS Information:\n");
- printf("\tTicks/sec: %llu\n", (unsigned long long) myhtml_hperf_res(NULL));
- myhtml_hperf_print("\tParse css", parse_start, parse_stop, stdout);
+ myfont_font_t *mf = myfont_create();
+ myfont_init(mf);
- //mycss_entry_destroy(entry, true);
- //mycss_destroy(mycss, true);
-
- return entry;
-}
-
-void print_tree_after_all(modest_t* modest, myhtml_tree_t* myhtml_tree, myhtml_tree_node_t* scope_node, mycss_entry_t *mycss_entry)
-{
- myhtml_tree_node_t* node = scope_node;
+ myfont_status_t mf_status = myfont_load(mf, path);
- while(node) {
- modest_node_t *m_node = (modest_node_t*)node->data;
-
- myhtml_tree_print_node(myhtml_tree, node, stdout);
+ if(mf_status) {
+ myfont_destroy(mf, true);
- if(m_node) {
- printf("\tstyles: ");
-
- modest_node_raw_serialization(modest, m_node, serialization_callback, NULL);
-
- printf("\n");
+ if(mf_status == MyFONT_STATUS_ERROR_FILE_OPEN) {
+ fprintf(stderr, "Can't open font file %s\n", path);
}
-
- if(node->child)
- node = node->child;
else {
- while(node != scope_node && node->next == NULL)
- node = node->parent;
-
- if(node == scope_node)
- break;
-
- node = node->next;
+ fprintf(stderr, "Can't load font file %s\n", path);
}
+
+ return EXIT_FAILURE;
}
-}
-
-size_t count = 0;
-
-void modest_callback_for_create_mnode(myhtml_tree_t* tree, myhtml_tree_node_t* node, void* ctx)
-{
- if(node->tag_id == MyHTML_TAG__TEXT) {
- return;
- }
-
- modest_t *modest = (modest_t*)ctx;
-
- /* create modest node */
- modest_node_t *m_node = modest_node_create(modest);
- if(m_node == NULL)
- return;
-
- modest_node_init(modest, m_node);
-
- node->data = (void*)m_node;
-}
-
-int main(int argc, const char * argv[]) {
- setbuf(stdout, NULL);
-
- //char *html_f = "/new/C-git/lexbor/test/test.html";
- char *html_f = "/new/C-git/habr/1.html";
- //char *html_f = "/new/C-git/HTML_BENTCHMARK/booking.com.html";
-
- //char *css_f = "/new/C-git/habr/1_glob.css";
- char *css_f = "/new/C-git/CSS_BENCHMARK/baseguide.css";
-
- //char *css_f = "/new/C-git/bootstrap.css";
-
- char *html = "Привет UTF8! <br><br>";
- char *css = ".radio input[type=\"radio\"]:checked + label::before {} .checkbox input[type=\"checkbox\"]:checked + label::before {}";
-
- char *selector = "menu";
-
- modest_t *modest = modest_create();
- modest_init(modest);
-
- myhtml_tree_t *myhtml_tree = myhtml(html_f, strlen(html_f), true, false, modest_callback_for_create_mnode, (void*)modest);
- mycss_entry_t *mycss_entry = mycss(css_f, strlen(css_f), true, false);
-
-// myhtml_tree_t *myhtml_tree = myhtml(html, strlen(html), false, true, modest_callback_for_create_mnode, (void*)modest);
-// mycss_entry_t *mycss_entry = mycss(css, strlen(css), false, false);
-
- modest->myhtml_tree = myhtml_tree;
- modest->mycss_entry = mycss_entry;
-
- mycss_stylesheet_t *stylesheet = mycss_entry_stylesheet(mycss_entry);
- /* simple api */
- uint64_t parse_simple_start = myhtml_hperf_clock(NULL);
- uint64_t parse_simple_stop = myhtml_hperf_clock(NULL);
+ char data[5];
+ size_t len = myhtml_encoding_codepoint_to_ascii_utf_8(codepoint, data);
+ data[len] = '\0';
+ /* work code */
+ uint16_t glyph_index = myfont_glyph_index_by_codepoint(mf, codepoint, NULL);
+ float baseline = myfont_metrics_baseline(mf, font_size);
+ float ascender = myfont_metrics_ascender(mf, font_size);
+ float descender = myfont_metrics_descender(mf, font_size);
+ float x_height = myfont_metrics_x_height(mf, font_size);
+ float cap_height = myfont_metrics_cap_height(mf, font_size);
+ float offset = myfont_metrics_glyph_offset_y(mf, codepoint, font_size, NULL);
+ float width = myfont_metrics_width(mf, codepoint, font_size, NULL);
+ float height = myfont_metrics_height(mf, codepoint, font_size, NULL);
- /* full api */
- uint64_t parse_start = myhtml_hperf_clock(NULL);
+ /* print result */
+ printf("Font file: %s\n", path);
+ printf("Font size: %.fpx\n\n", font_size);
+ printf("Metrics for code point " MyHTML_FMT_Z " (%s):\n", codepoint, data);
+>>>>>>> Stashed changes
+ printf("\tBaseline: %.05f\n", baseline);
+ printf("\tAscender: %.05f\n", ascender);
+ printf("\tDescender: %.05f\n", descender);
+ printf("\tX-Height: %.05f\n", x_height);
+ printf("\tCap-Height: %.05f\n", cap_height);
+ printf("\tWidth: %.05f\n", width);
+ printf("\tHeight: %.05f\n", height);
- modest_finder_t* finder = modest_finder_create();
- modest_finder_init(finder);
+ /* print html svg */
+ printf("\n<svg width=\"%f\" height=\"%f\">\n", width + 4.0f, descender + 4.0f);
+ printf("\t<line x1=%f y1=%f x2=%f y2=%f style=\"stroke:rgb(0,124,110);stroke-width:1\" />\n", 0.0f, ascender, width, ascender);
+ printf("\t<line x1=%f y1=%f x2=%f y2=%f style=\"stroke:rgb(140,0,110);stroke-width:1\" />\n", 0.0f, cap_height, width, cap_height);
+ printf("\t<line x1=%f y1=%f x2=%f y2=%f style=\"stroke:rgb(140,124,110);stroke-width:1\" />\n", 0.0f, x_height, width, x_height);
+ printf("\t<line x1=%f y1=%f x2=%f y2=%f style=\"stroke:rgb(0,255,0);stroke-width:1\" />\n", 0.0f, baseline, width, baseline);
+ printf("\t<line x1=%f y1=%f x2=%f y2=%f style=\"stroke:rgb(255,0,0);stroke-width:1\" />\n", 0.0f, descender, width, descender);
-// threads
- modest_finder_thread_t *finder_thread = modest_finder_thread_create();
- modest_finder_thread_init(finder, finder_thread, 4);
-
- modest_finder_thread_process(modest, finder_thread, myhtml_tree->node_html, stylesheet->sel_list_first);
-
- finder_thread = modest_finder_thread_destroy(finder_thread, true);
- finder = modest_finder_destroy(finder, true);
-
-
- uint64_t parse_stop = myhtml_hperf_clock(NULL);
-
-// print_tree_after_all(modest, myhtml_tree, myhtml_tree->node_html, mycss_entry);
-
- printf("\n\n------------\nInformation:\n");
- printf("\tTicks/sec: %llu\n", (unsigned long long) myhtml_hperf_res(NULL));
- myhtml_hperf_print("\tFound selectors", parse_start, parse_stop, stdout);
- myhtml_hperf_print("\tParse and Found Simple selectors", parse_simple_start, parse_simple_stop, stdout);
- printf("\n");
-
-// printf("\nPrint result:\n");
-// for(size_t i = 0; i < full_collection->length; i++) {
-// myhtml_tree_print_node(myhtml_tree, full_collection->list[i], stdout);
-// }
-// printf("\nFound: %zu\n", full_collection->length);
-// printf("\n");
-//
-// modest_finder_destroy(finder_full, true);
-
- modest = modest_destroy(modest, true);
+ if(glyph_index < mf->table_maxp.numGlyphs) {
+ myfont_table_glyph_t *glyph = &mf->table_glyf.cache[glyph_index];
+
+ printf("\t<polyline points=\"");
+ for(size_t i = 0; i < glyph->pointCount; i++) {
+
+ float x = (float)((glyph->head.xMax + glyph->simple.xCoordinates[i]) - glyph->head.xMax) * font_size / ((float)mf->table_head.unitsPerEm);
+ float y = (float)((glyph->head.yMax - glyph->simple.yCoordinates[i])) * font_size / ((float)mf->table_head.unitsPerEm);
+
+ printf("%f,%f ", x, (y + offset));
+ }
+ printf("\" />\n");
+ }
- mycss_t* mycss = mycss_entry->mycss;
- mycss_stylesheet_destroy(stylesheet, true);
- mycss_entry_destroy(mycss_entry, true);
- mycss_destroy(mycss, true);
+ printf("</svg>\n");
- myhtml_t* myhtml = myhtml_tree->myhtml;
- myhtml_tree_destroy(myhtml_tree);
- myhtml_destroy(myhtml);
+<<<<<<< Updated upstream
+ myfont_destroy_font_data(mf, font_data);
+=======
+>>>>>>> Stashed changes
+ myfont_destroy(mf, true);
return 0;
}
+<<<<<<< Updated upstream
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//int mainsdfsfd(int argc, const char * argv[])
+//{
+// setbuf(stdout, NULL);
+//
+// //char *html_f = "/new/C-git/lexbor/test/test.html";
+// char *html_f = "/new/C-git/habr/1.html";
+// //char *html_f = "/new/C-git/HTML_BENTCHMARK/booking.com.html";
+//
+// //char *css_f = "/new/C-git/habr/1_glob.css";
+// char *css_f = "/new/C-git/CSS_BENCHMARK/baseguide.css";
+//
+// //char *css_f = "/new/C-git/bootstrap.css";
+//
+// char *html = "Привет UTF8! <br><br>";
+// char *css = ".radio input[type=\"radio\"]:checked + label::before {} .checkbox input[type=\"checkbox\"]:checked + label::before {}";
+//
+// char *selector = "menu";
+//
+// modest_t *modest = modest_create();
+// modest_init(modest);
+//
+// myhtml_tree_t *myhtml_tree = myhtml(html_f, strlen(html_f), true, false, modest_callback_for_create_mnode, (void*)modest);
+// mycss_entry_t *mycss_entry = mycss(css_f, strlen(css_f), true, false);
+//
+//// myhtml_tree_t *myhtml_tree = myhtml(html, strlen(html), false, true, modest_callback_for_create_mnode, (void*)modest);
+//// mycss_entry_t *mycss_entry = mycss(css, strlen(css), false, false);
+//
+// modest->myhtml_tree = myhtml_tree;
+// modest->mycss_entry = mycss_entry;
+//
+// mycss_stylesheet_t *stylesheet = mycss_entry_stylesheet(mycss_entry);
+//
+// /* simple api */
+// uint64_t parse_simple_start = mycore_hperf_clock(NULL);
+// uint64_t parse_simple_stop = mycore_hperf_clock(NULL);
+//
+//
+//
+// /* full api */
+// uint64_t parse_start = mycore_hperf_clock(NULL);
+//
+//
+// modest_finder_t* finder = modest_finder_create();
+// modest_finder_init(finder);
+//
+//// threads
+// modest_finder_thread_t *finder_thread = modest_finder_thread_create();
+// modest_finder_thread_init(finder, finder_thread, 4);
+//
+//#ifndef MyCORE_BUILD_WITHOUT_THREADS
+// modest_finder_thread_process(modest, finder_thread, myhtml_tree->node_html, stylesheet->sel_list_first);
+//#endif
+//
+// finder_thread = modest_finder_thread_destroy(finder_thread, true);
+// finder = modest_finder_destroy(finder, true);
+//
+//
+// uint64_t parse_stop = mycore_hperf_clock(NULL);
+//
+//// print_tree_after_all(modest, myhtml_tree, myhtml_tree->node_html, mycss_entry);
+//
+// printf("\n\n------------\nInformation:\n");
+// printf("\tTicks/sec: %llu\n", (unsigned long long) mycore_hperf_res(NULL));
+// mycore_hperf_print("\tFound selectors", parse_start, parse_stop, stdout);
+// mycore_hperf_print("\tParse and Found Simple selectors", parse_simple_start, parse_simple_stop, stdout);
+// printf("\n");
+//
+//// printf("\nPrint result:\n");
+//// for(size_t i = 0; i < full_collection->length; i++) {
+//// myhtml_tree_print_node(myhtml_tree, full_collection->list[i], stdout);
+//// }
+//// printf("\nFound: %zu\n", full_collection->length);
+//// printf("\n");
+////
+//// modest_finder_destroy(finder_full, true);
+//
+// modest = modest_destroy(modest, true);
+//
+// mycss_t* mycss = mycss_entry->mycss;
+// mycss_stylesheet_destroy(stylesheet, true);
+// mycss_entry_destroy(mycss_entry, true);
+// mycss_destroy(mycss, true);
+//
+// myhtml_t* myhtml = myhtml_tree->myhtml;
+// myhtml_tree_destroy(myhtml_tree);
+// myhtml_destroy(myhtml);
+//
+// return 0;
+//}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+///*
+// Copyright (C) 2015-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/url.h>
+//#include <myurl/serialization.h>
+//#include <myhtml/mystring.h>
+//#include <myhtml/utils/mchar_async.h>
+//
+//#include <sys/types.h>
+//#include <sys/stat.h>
+//#include <dirent.h>
+//
+//struct test_res {
+// char* data;
+// size_t size;
+//}
+//typedef test_res_t;
+//
+//struct test_pos {
+// size_t begin;
+// size_t length;
+//}
+//typedef test_pos_t;
+//
+//enum test_type {
+// TEST_TYPE_UNDEF = 0x00,
+// TEST_TYPE_FIRST = '1',
+// TEST_TYPE_SECOND = '2',
+// TEST_TYPE_THIRD = '3',
+// TEST_TYPE_FOURTH = '4'
+//};
+//
+//static mchar_async_t* MCharOBJ = NULL;
+//static size_t MCharOBJNode = 0;
+//
+//test_pos_t test_get_value(const char *data, size_t* length, size_t data_size, const char* some);
+//
+//test_res_t test_load_file(const char* filename)
+//{
+// FILE *fh = fopen(filename, "rb");
+// if(fh == NULL) {
+// fprintf(stderr, "Can't open file: %s\n", filename);
+// exit(EXIT_FAILURE);
+// }
+//
+// if(fseek(fh, 0L, SEEK_END) != 0) {
+// fprintf(stderr, "Can't set position (fseek) in file: %s\n", filename);
+// exit(EXIT_FAILURE);
+// }
+//
+// long size = ftell(fh);
+//
+// if(fseek(fh, 0L, SEEK_SET) != 0) {
+// fprintf(stderr, "Can't set position (fseek) in file: %s\n", filename);
+// exit(EXIT_FAILURE);
+// }
+//
+// if(size <= 0) {
+// fprintf(stderr, "Can't get file size or file is empty: %s\n", filename);
+// exit(EXIT_FAILURE);
+// }
+//
+// char *file_data = (char*)malloc(size + 1);
+// if(file_data == NULL) {
+// fprintf(stderr, "Can't allocate mem for file: %s\n", filename);
+// exit(EXIT_FAILURE);
+// }
+//
+// size_t nread = fread(file_data, 1, size, fh);
+// if (nread != size) {
+// fprintf(stderr, "Could not read %ld bytes (%zu bytes done)\n", size, nread);
+// exit(EXIT_FAILURE);
+// }
+//
+// fclose(fh);
+//
+// return (test_res_t){file_data, (size_t)size};
+//}
+//
+//void test_serialization_callback(const char* data, size_t len, void* ctx)
+//{
+// mycore_string_t *str = ctx;
+// mycore_string_append(str, data, len);
+//}
+//
+//myurl_entry_t * test_parse_url(const char *data, size_t length, myurl_entry_t* base_url)
+//{
+// myurl_t *url = myurl_create();
+// if(url == NULL) {
+// fprintf(stderr, "Could create url object\n");
+// exit(EXIT_FAILURE);
+// }
+//
+// if(myurl_init(url)) {
+// fprintf(stderr, "Could init url object\n");
+// exit(EXIT_FAILURE);
+// }
+//
+// myurl_entry_t *url_entry = myurl_parse(url, data, length, base_url, NULL);
+//
+// if(url_entry == NULL) {
+// myurl_destroy(url, true);
+// return NULL;
+// }
+//
+// return url_entry;
+//}
+//
+//void test_destroy_url(myurl_entry_t* entry_url)
+//{
+// if(entry_url) {
+// myurl_t *url = entry_url->url_ref;
+// myurl_entry_destroy(entry_url, true);
+// myurl_destroy(url, true);
+// }
+//}
+//
+//myurl_host_type_t test_host_type_from_data(const char *data, size_t length)
+//{
+// if(strncmp("IPv4", data, length) == 0) {
+// return MyURL_HOST_TYPE_IPv4;
+// }
+// else if(strncmp("IPv6", data, length) == 0) {
+// return MyURL_HOST_TYPE_IPv6;
+// }
+// else if(strncmp("DOMAIN", data, length) == 0) {
+// return MyURL_HOST_TYPE_DOMAIN;
+// }
+// else if(strncmp("OPAQUE", data, length) == 0) {
+// return MyURL_HOST_TYPE_OPAQUE;
+// }
+//
+// return MyURL_HOST_TYPE_UNDEF;
+//}
+//
+//myurl_host_type_t test_get_domain_type(const char *data, size_t* length, size_t data_size)
+//{
+// test_pos_t domain_type = test_get_value(data, length, data_size, "%DOMAIN_TYPE:");
+// myurl_host_type_t domain_type_int = test_host_type_from_data(&data[domain_type.begin], domain_type.length);
+//
+// return domain_type_int;
+//}
+//
+//test_pos_t test_get_value(const char *data, size_t* length, size_t data_size, const char* some)
+//{
+// test_pos_t pos = {0};
+// size_t some_len = strlen(some);
+//
+// size_t len = *length + some_len;
+//
+// if(len >= data_size)
+// return pos;
+//
+// if(strncmp(some, &data[ *length ], some_len))
+// return pos;
+//
+// pos.begin = len;
+//
+// while(len < data_size) {
+// if(data[len] == '%')
+// {
+// size_t bpos = len;
+// bpos++;
+//
+// while(bpos < data_size) {
+// if((bpos - 1) > len && (data[bpos] < 'A' || data[bpos] > 'Z') && data[bpos] != '_') {
+// if(data[bpos] == ':') {
+// if(strncmp("%URL", &data[len], 4) == 0)
+// pos.length = ((len - pos.begin) - 2);
+// else
+// pos.length = ((len - pos.begin) - 1);
+//
+// *length = len;
+// return pos;
+// }
+//
+// break;
+// }
+//
+// bpos++;
+// }
+// }
+//
+// len++;
+// }
+//
+// *length = len;
+// pos.length = ((len - pos.begin) - 1);
+//
+// return pos;
+//}
+//
+///* FIRST */
+//bool test_for_type_first_entry(const char *data, size_t* length, size_t data_size)
+//{
+// test_pos_t url = test_get_value(data, length, data_size, "%URL:");
+// if(url.length == 0)
+// return true;
+//
+// //printf("%.*s\n", (int)url.length, &data[ url.begin ]);
+//
+// myurl_entry_t *url_entry = test_parse_url(&data[ url.begin ], url.length, NULL);
+//
+// /* get expected */
+// test_pos_t expect = test_get_value(data, length, data_size, "%EXPECT:");
+// if(expect.length == 0) {
+// if(url_entry == NULL)
+// return true;
+// }
+//
+// if(url_entry == NULL) {
+// fprintf(stderr, "Test FAILURE!\n");
+// fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+// fprintf(stderr, "\tResult:\n");
+// fprintf(stderr, "\tExpect: %.*s\n\n", (int)expect.length, &data[expect.begin]);
+//
+// test_destroy_url(url_entry);
+// return true;
+// }
+//
+// mycore_string_t cmp_str = {0};
+// mycore_string_init(MCharOBJ, MCharOBJNode, &cmp_str, 1024);
+//
+// myurl_serialization(url_entry, false, test_serialization_callback, &cmp_str);
+//
+// /* compare */
+// if(cmp_str.length != expect.length || strncmp(cmp_str.data, &data[expect.begin], cmp_str.length))
+// {
+// fprintf(stderr, "Test FAILURE!\n");
+// fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+// fprintf(stderr, "\tResult: %.*s\n", (int)cmp_str.length, cmp_str.data);
+// fprintf(stderr, "\tExpect: %.*s\n\n", (int)expect.length, &data[expect.begin]);
+//
+// mycore_string_destroy(&cmp_str, false);
+// test_destroy_url(url_entry);
+// return true;
+// }
+//
+// mycore_string_destroy(&cmp_str, false);
+// test_destroy_url(url_entry);
+//
+// return true;
+//}
+//
+//bool test_for_type_first(const char *data, size_t length, size_t data_size)
+//{
+// while(length < data_size) {
+// if(test_for_type_first_entry(data, &length, data_size) == false)
+// return false;
+// }
+//
+// return true;
+//}
+//
+///* SECOND */
+//bool test_for_type_second_entry(const char *data, size_t* length, size_t data_size)
+//{
+// test_pos_t url = test_get_value(data, length, data_size, "%URL:");
+// if(url.length == 0)
+// return true;
+//
+// /* get domain_type */
+// myurl_host_type_t domain_type = test_get_domain_type(data, length, data_size);
+//
+// //printf("%.*s\n", (int)url.length, &data[ url.begin ]);
+//
+// myurl_entry_t *url_entry = test_parse_url(&data[ url.begin ], url.length, NULL);
+//
+// /* get expected */
+// test_pos_t expect = test_get_value(data, length, data_size, "%EXPECT:");
+// if(expect.length == 0) {
+// if(url_entry == NULL)
+// return true;
+// }
+//
+// if(url_entry == NULL) {
+// fprintf(stderr, "Test FAILURE!\n");
+// fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+// fprintf(stderr, "\tResult:\n");
+// fprintf(stderr, "\tExpect: %.*s\n\n", (int)expect.length, &data[expect.begin]);
+//
+// test_destroy_url(url_entry);
+// return true;
+// }
+//
+// if(url_entry->host.type != domain_type) {
+// fprintf(stderr, "Test FAILURE!\n");
+// fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+// fprintf(stderr, "\tDomain Type: %d\n", url_entry->host.type);
+// fprintf(stderr, "\tDomain Ip Version Type: %d\n", url_entry->host.ipv.type);
+// fprintf(stderr, "\tExpect Domain Type: %d\n\n", domain_type);
+//
+// test_destroy_url(url_entry);
+// return true;
+// }
+//
+// mycore_string_t cmp_str = {0};
+// mycore_string_init(MCharOBJ, MCharOBJNode, &cmp_str, 1024);
+//
+// myurl_serialization(url_entry, false, test_serialization_callback, &cmp_str);
+//
+// /* compare */
+// if(cmp_str.length != expect.length || strncmp(cmp_str.data, &data[expect.begin], cmp_str.length))
+// {
+// fprintf(stderr, "Test FAILURE!\n");
+// fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+// fprintf(stderr, "\tResult: %.*s\n", (int)cmp_str.length, cmp_str.data);
+// fprintf(stderr, "\tExpect: %.*s\n\n", (int)expect.length, &data[expect.begin]);
+//
+// mycore_string_destroy(&cmp_str, false);
+// test_destroy_url(url_entry);
+// return true;
+// }
+//
+// mycore_string_destroy(&cmp_str, false);
+// test_destroy_url(url_entry);
+//
+// return true;
+//}
+//
+//bool test_for_type_second(const char *data, size_t length, size_t data_size)
+//{
+// while(length < data_size) {
+// if(test_for_type_second_entry(data, &length, data_size) == false)
+// return false;
+// }
+//
+// return true;
+//}
+//
+///* THIRD */
+//bool test_for_type_third_entry(const char *data, size_t* length, size_t data_size)
+//{
+// test_pos_t url = test_get_value(data, length, data_size, "%URL:");
+// if(url.length == 0)
+// return true;
+//
+// /* get base */
+// test_pos_t base = test_get_value(data, length, data_size, "%BASE:");
+// if(base.length == 0)
+// return true;
+//
+// myurl_entry_t *base_entry = test_parse_url(&data[ base.begin ], base.length, NULL);
+// myurl_entry_t *url_entry = test_parse_url(&data[ url.begin ], url.length, base_entry);
+//
+// /* get expected */
+// test_pos_t expect = test_get_value(data, length, data_size, "%EXPECT:");
+// if(expect.length == 0) {
+// if(url_entry == NULL)
+// return true;
+// }
+//
+// if(url_entry == NULL) {
+// fprintf(stderr, "Test FAILURE!\n");
+// fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+// fprintf(stderr, "\tBASE: %.*s\n", (int)base.length, &data[ base.begin ]);
+// fprintf(stderr, "\tResult:\n");
+// fprintf(stderr, "\tExpect: %.*s\n\n", (int)expect.length, &data[expect.begin]);
+//
+// test_destroy_url(url_entry);
+// return true;
+// }
+//
+// mycore_string_t cmp_str = {0};
+// mycore_string_init(MCharOBJ, MCharOBJNode, &cmp_str, 1024);
+//
+// myurl_serialization(url_entry, false, test_serialization_callback, &cmp_str);
+//
+// /* compare */
+// if(cmp_str.length != expect.length || strncmp(cmp_str.data, &data[expect.begin], cmp_str.length))
+// {
+// fprintf(stderr, "Test FAILURE!\n");
+// fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+// fprintf(stderr, "\tBASE: %.*s\n", (int)base.length, &data[ base.begin ]);
+// fprintf(stderr, "\tResult: %.*s\n", (int)cmp_str.length, cmp_str.data);
+// fprintf(stderr, "\tExpect: %.*s\n\n", (int)expect.length, &data[expect.begin]);
+//
+// mycore_string_destroy(&cmp_str, false);
+// test_destroy_url(url_entry);
+// return true;
+// }
+//
+// mycore_string_destroy(&cmp_str, false);
+// test_destroy_url(url_entry);
+//
+// return true;
+//}
+//
+//bool test_for_type_third(const char *data, size_t length, size_t data_size)
+//{
+// while(length < data_size) {
+// if(test_for_type_third_entry(data, &length, data_size) == false)
+// return false;
+// }
+//
+// return true;
+//}
+//
+//void test_by_type(const char *data, size_t data_size, const char* filename)
+//{
+// printf("Test file: %s\n", filename);
+//
+// size_t length = 8;
+//
+// if(data_size <= length || strncmp("type ", data, 5)) {
+// fprintf(stderr, "Could not read type form %s\n", filename);
+// exit(EXIT_FAILURE);
+// }
+//
+// switch ((unsigned char)data[5]) {
+// case TEST_TYPE_FIRST:
+// test_for_type_first(&data[8], 0, (data_size - 8));
+// break;
+//
+// case TEST_TYPE_SECOND:
+// test_for_type_second(&data[8], 0, (data_size - 8));
+// break;
+//
+// case TEST_TYPE_THIRD:
+// test_for_type_third(&data[8], 0, (data_size - 8));
+// break;
+//
+// default:
+// break;
+// }
+//}
+//
+//void test(const char* filename)
+//{
+// test_res_t test_data = test_load_file(filename);
+// test_by_type(test_data.data, test_data.size, filename);
+//
+// if(test_data.data)
+// free(test_data.data);
+//}
+//
+//void test_read_dir(const char* dir_path)
+//{
+// char path[(4096 * 4)];
+// sprintf(path, "%s", dir_path);
+//
+// printf("Tests in directory: %s\n", path);
+//
+// size_t path_len = strlen(dir_path);
+//
+// DIR *dir;
+// struct dirent *ent;
+// struct stat path_stat;
+//
+// if((dir = opendir(dir_path)) != NULL)
+// {
+// while((ent = readdir(dir)) != NULL)
+// {
+// sprintf(&path[path_len], "/%s", ent->d_name);
+//
+// if(stat(path, &path_stat) != 0) {
+// fprintf(stderr, "Can't get status for file: %s\n", path);
+// exit(EXIT_FAILURE);
+// }
+//
+// if(ent->d_name[0] == '.' || S_ISDIR(path_stat.st_mode))
+// continue;
+//
+// test(path);
+// }
+//
+// closedir (dir);
+// }
+//}
+//
+//int main(int argc, const char * argv[])
+//{
+// setbuf(stdout, NULL);
+//
+//// if (argc < 2) {
+//// printf("Bad ARGV!\nUse: url <test_file_path>\n");
+//// exit(EXIT_FAILURE);
+//// }
+//
+// MCharOBJ = mchar_async_create(4, 4096);
+// if(MCharOBJ == NULL)
+// return EXIT_FAILURE;
+//
+// MCharOBJNode = mchar_async_node_add(MCharOBJ);
+//
+// //test_read_dir(argv[1]);
+// test_read_dir("/new/C-git/Modest/test/myurl/data");
+//
+// mchar_async_destroy(MCharOBJ, true);
+//
+// return EXIT_SUCCESS;
+//}
+//
+//
+//
+//void test_serialization_callback_for_aim(const char* data, size_t len, void* ctx)
+//{
+// printf("%.*s", (int)len, data);
+//}
+//
+//int mainkj(int argc, const char * argv[])
+//{
+// setbuf(stdout, NULL);
+//
+// //const char* data_base = "http://[::1.]/";
+// //const char* data_base = "file://localhost/C:/foo";
+// const char* data_rel = "https://lenta.ru/news/2017/02/28/visa/";
+//
+// //printf("base: %s\n", data_base);
+// // printf("rela: %s\n", data_rel);
+//
+// myurl_t *url = myurl_create();
+// myurl_init(url);
+//
+// for(size_t i = 0; i < 10000; i++)
+// {
+//
+//
+// //myurl_entry_t *url_base = myurl_parse(url, data_base, strlen(data_base), NULL, NULL);
+// myurl_entry_t *url_entry = myurl_parse(url, data_rel, strlen(data_rel), NULL, NULL);
+//
+//// printf("result: ");
+//// myurl_serialization(url_entry, false, test_serialization_callback_for_aim, NULL);
+//// printf("\n");
+////
+////
+//// if(myurl_entry_host_set(url_entry, "192.168.", strlen("192.168."))) {
+//// printf("after changes host: ERROR\n");
+//// exit(0);
+//// }
+////
+//// if(myurl_entry_path_set(url_entry, "new/path", strlen("new/path"))) {
+//// printf("after change path: ERROR\n");
+//// exit(0);
+//// }
+////
+//// if(myurl_entry_path_append_entry(url_entry, "lalaлвappendpath", strlen("lalaлвappendpath"))) {
+//// printf("after append path: ERROR\n");
+//// exit(0);
+//// }
+////
+//// if(myurl_entry_path_replace_entry(url_entry, 1, "beb#ebe", strlen("beb#ebe"))) {
+//// printf("after append path: ERROR\n");
+//// exit(0);
+//// }
+////
+//// printf("befor delete path entry by index 2: ");
+//// myurl_serialization(url_entry, false, test_serialization_callback_for_aim, NULL);
+//// printf("\n");
+////
+//// myurl_entry_path_remove_entry(url_entry, 2);
+////
+//// myurl_entry_query_set(url_entry, "lalala", 4);
+//// myurl_entry_fragment_set(url_entry, "anch4", 5);
+////
+//// printf("after changes: ");
+//// myurl_serialization(url_entry, false, test_serialization_callback_for_aim, NULL);
+//// printf("\n");
+//
+//// char *host_data = myurl_entry_host_as_string(url_entry, NULL);
+////
+////// printf("HOST: %s\n", host_data);
+////
+//// myurl_entry_host_free_string(url_entry, host_data);
+//
+//
+// myurl_entry_destroy(url_entry, true);
+//
+//// printf("result: ");
+////
+//// if(url_entry) {
+//// myurl_serialization(url_entry, false, test_serialization_callback_for_aim, NULL);
+//// printf("\n");
+//// }
+//// else {
+//// printf("ERROR\n");
+//// }
+//
+//
+// }
+//
+// myurl_destroy(url, true);
+//
+// return 1;
+//}
+
+
+=======
+>>>>>>> Stashed changes
+
+
+<<<<<<< Updated upstream
+
+
+
+
+
+
+
+
+
+
+///*
+// Copyright (C) 2017 Alexander Borisov
+=======
+///*
+// Copyright (C) 2016 Alexander Borisov
+>>>>>>> Stashed changes
+//
+// 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)
+<<<<<<< Updated upstream
+// */
+//
+//#include <string.h>
+//#include <myurl/url.h>
+//
+//int main(int argc, const char * argv[])
+//{
+// const char* data_base = "http://lalal.ru/";
+//
+// myurl_t *url = myurl_create();
+// if(url == NULL) {
+// printf("Can't create URL object\n");
+// return EXIT_FAILURE;
+// }
+//
+// if(myurl_init(url)) {
+// printf("Can't init URL object\n");
+// return EXIT_FAILURE;
+// }
+//
+// printf("Parse url \"%s\":\n", data_base);
+//
+// myurl_entry_t *url_base = myurl_parse(url, data_base, strlen(data_base), NULL, NULL);
+// myurl_entry_t *url_relative = myurl_parse(url, "bla.ru/", strlen("bla.ru/"), url_base, NULL);
+//
+// const char *scheme = myurl_entry_scheme_name(url_base, NULL);
+// char *authority = myurl_entry_authority_as_string(url_base, NULL);
+// const char *username = myurl_entry_username(url_base, NULL);
+// const char *password = myurl_entry_password(url_base, NULL);
+// char *host = myurl_entry_host_as_string(url_base, NULL);
+// char *path = myurl_entry_path_as_string(url_base, NULL);
+// const char *query = myurl_entry_query(url_base, NULL);
+// const char *fragment = myurl_entry_fragment(url_base, NULL);
+//
+// printf("\tScheme: %s\n" , (scheme ? scheme : ""));
+// printf("\tScheme port: %u\n" , myurl_entry_scheme_port(url_base));
+// printf("\tAuthority (%s):\n" , authority);
+// printf("\t\tUsername: %s\n" , username);
+// printf("\t\tPassword: %s\n" , password);
+// printf("\tHost: %s\n" , host);
+// printf("\tPort is defined: %s\n", (myurl_entry_port_is_defined(url_base) ? "true" : "false"));
+// printf("\tPort: %u\n" , myurl_entry_port(url_base));
+// printf("\tPath: %s\n" , path);
+// printf("\tQuery: %s\n" , (query ? query : ""));
+// printf("\tFragment: %s\n" , (fragment ? fragment : ""));
+//
+// myurl_entry_free_string(url_base, authority);
+// myurl_entry_free_string(url_base, host);
+// myurl_entry_free_string(url_base, path);
+//
+// myurl_entry_destroy(url_base, true);
+// myurl_destroy(url, true);
+=======
+//*/
+//
+//#include "myhtml/myhtml.h"
+//#include "mycss/mycss.h"
+//#include "modest/modest.h"
+//
+//#include "mycss/selectors/serialization.h"
+//#include "mycss/declaration/init.h"
+//#include "modest/finder/finder.h"
+//#include "modest/finder/thread.h"
+//#include "myhtml/encoding.h"
+//#include "myfont/myfont.h"
+//#include "modest/node/serialization.h"
+//
+//struct res_data {
+// char *data;
+// size_t size;
+//};
+//
+//struct res_data load_data(const char* filename)
+//{
+// FILE *f = fopen(filename, "rb");
+// fseek(f, 0L, SEEK_END);
+//
+// long l = ftell(f);
+// fseek(f, 0L, SEEK_SET);
+//
+// char *html = (char*)myhtml_malloc(l);
+// if(fread(html, 1, l, f) != l) {
+// exit(1);
+// }
+//
+// fclose(f);
+//
+// struct res_data res = {html, (size_t)l};
+// return res;
+//}
+//
+//void serialization_callback(const char* data, size_t len, void* ctx)
+//{
+// printf("%.*s", (int)len, data);
+//}
+//
+//myhtml_tree_t * myhtml(const char* data, size_t data_size, bool is_file, bool print_result, myhtml_callback_tree_node_f cai, void* cai_ctx)
+//{
+// setbuf(stdout, NULL);
+//
+// myhtml_t* myhtml = myhtml_create();
+// myhtml_init(myhtml, MyHTML_OPTIONS_PARSE_MODE_SINGLE, 1, 0);
+//
+// uint64_t all_start = myhtml_hperf_clock(NULL);
+// uint64_t tree_init_start = myhtml_hperf_clock(NULL);
+//
+// myhtml_tree_t* tree = myhtml_tree_create();
+// myhtml_tree_init(tree, myhtml);
+//
+// myhtml_callback_tree_node_insert_set(tree, cai, cai_ctx);
+//
+// uint64_t tree_init_stop = myhtml_hperf_clock(NULL);
+// uint64_t parse_start = myhtml_hperf_clock(NULL);
+//
+// if(is_file) {
+// struct res_data res = load_data(data);
+//
+// myhtml_encoding_t encoding = myhtml_encoding_prescan_stream_to_determine_encoding(res.data, res.size);
+//
+// if(encoding == MyHTML_ENCODING_NOT_DETERMINED)
+// encoding = MyHTML_ENCODING_UTF_8;
+//
+// myhtml_parse(tree, encoding, res.data, res.size);
+// free(res.data);
+// }
+// else {
+// myhtml_parse(tree, MyHTML_ENCODING_UTF_8, data, data_size);
+// }
+//
+// uint64_t parse_stop = myhtml_hperf_clock(NULL);
+// uint64_t all_stop = myhtml_hperf_clock(NULL);
+//
+// if(print_result) {
+// myhtml_tree_print_node_children(tree, tree->document, stdout, 0);
+// }
+//
+// printf("\n\nMyHTML Information:\n");
+// printf("\tTicks/sec: %llu\n", (unsigned long long) myhtml_hperf_res(NULL));
+// myhtml_hperf_print("\tFirst Tree init", tree_init_start, tree_init_stop, stdout);
+// myhtml_hperf_print("\tParse html", parse_start, parse_stop, stdout);
+// myhtml_hperf_print("\tTotal", all_start, all_stop, stdout);
+// printf("\n");
+//
+// //myhtml_tree_destroy(tree);
+// //myhtml_destroy(myhtml);
+//
+// return tree;
+//}
+//
+//mycss_entry_t * mycss(const char* data, size_t data_size, bool is_file, bool print_result)
+//{
+// // base init
+// mycss_t *mycss = mycss_create();
+// mycss_init(mycss);
+//
+// // currenr entry work init
+// mycss_entry_t *entry = mycss_entry_create();
+// mycss_entry_init(mycss, entry);
+//
+// uint64_t parse_start = myhtml_hperf_clock(NULL);
+//
+// if(is_file) {
+// struct res_data res = load_data(data);
+// mycss_parse(entry, MyHTML_ENCODING_UTF_8, res.data, res.size);
+// free(res.data);
+// }
+// else {
+// mycss_parse(entry, MyHTML_ENCODING_UTF_8, data, data_size);
+// }
+//
+// uint64_t parse_stop = myhtml_hperf_clock(NULL);
+//
+// if(print_result) {
+// printf("\n");
+// mycss_stylesheet_t *stylesheet = mycss_entry_stylesheet(entry);
+// mycss_selectors_serialization_list(entry->selectors, stylesheet->sel_list_first, serialization_callback, NULL);
+// }
+//
+// printf("\n------------\nMyCSS Information:\n");
+// printf("\tTicks/sec: %llu\n", (unsigned long long) myhtml_hperf_res(NULL));
+// myhtml_hperf_print("\tParse css", parse_start, parse_stop, stdout);
+//
+// //mycss_entry_destroy(entry, true);
+// //mycss_destroy(mycss, true);
+//
+// return entry;
+//}
+//
+//void print_tree_after_all(modest_t* modest, myhtml_tree_t* myhtml_tree, myhtml_tree_node_t* scope_node, mycss_entry_t *mycss_entry)
+//{
+// myhtml_tree_node_t* node = scope_node;
+//
+// while(node) {
+// modest_node_t *m_node = (modest_node_t*)node->data;
+//
+// myhtml_tree_print_node(myhtml_tree, node, stdout);
+//
+// if(m_node) {
+// printf("\tstyles: ");
+//
+// modest_node_raw_serialization(modest, m_node, serialization_callback, NULL);
+//
+// printf("\n");
+// }
+//
+// if(node->child)
+// node = node->child;
+// else {
+// while(node != scope_node && node->next == NULL)
+// node = node->parent;
+//
+// if(node == scope_node)
+// break;
+//
+// node = node->next;
+// }
+// }
+//}
+//
+//size_t count = 0;
+//
+//void modest_callback_for_create_mnode(myhtml_tree_t* tree, myhtml_tree_node_t* node, void* ctx)
+//{
+// if(node->tag_id == MyHTML_TAG__TEXT) {
+// return;
+// }
+//
+// modest_t *modest = (modest_t*)ctx;
+//
+// /* create modest node */
+// modest_node_t *m_node = modest_node_create(modest);
+// if(m_node == NULL)
+// return;
+//
+// modest_node_init(modest, m_node);
+//
+// node->data = (void*)m_node;
+//}
+//
+//int main(int argc, const char * argv[]) {
+// setbuf(stdout, NULL);
+//
+// //char *html_f = "/new/C-git/lexbor/test/test.html";
+// char *html_f = "/new/C-git/habr/1.html";
+// //char *html_f = "/new/C-git/HTML_BENTCHMARK/booking.com.html";
+//
+// //char *css_f = "/new/C-git/habr/1_glob.css";
+// char *css_f = "/new/C-git/CSS_BENCHMARK/baseguide.css";
+//
+// //char *css_f = "/new/C-git/bootstrap.css";
+//
+// char *html = "Привет UTF8! <br><br>";
+// char *css = ".radio input[type=\"radio\"]:checked + label::before {} .checkbox input[type=\"checkbox\"]:checked + label::before {}";
+//
+// char *selector = "menu";
+//
+// modest_t *modest = modest_create();
+// modest_init(modest);
+//
+// myhtml_tree_t *myhtml_tree = myhtml(html_f, strlen(html_f), true, false, modest_callback_for_create_mnode, (void*)modest);
+// mycss_entry_t *mycss_entry = mycss(css_f, strlen(css_f), true, false);
+//
+//// myhtml_tree_t *myhtml_tree = myhtml(html, strlen(html), false, true, modest_callback_for_create_mnode, (void*)modest);
+//// mycss_entry_t *mycss_entry = mycss(css, strlen(css), false, false);
+//
+// modest->myhtml_tree = myhtml_tree;
+// modest->mycss_entry = mycss_entry;
+//
+// mycss_stylesheet_t *stylesheet = mycss_entry_stylesheet(mycss_entry);
+//
+// /* simple api */
+// uint64_t parse_simple_start = myhtml_hperf_clock(NULL);
+// uint64_t parse_simple_stop = myhtml_hperf_clock(NULL);
+//
+//
+//
+// /* full api */
+// uint64_t parse_start = myhtml_hperf_clock(NULL);
+//
+//
+// modest_finder_t* finder = modest_finder_create();
+// modest_finder_init(finder);
+//
+//// threads
+// modest_finder_thread_t *finder_thread = modest_finder_thread_create();
+// modest_finder_thread_init(finder, finder_thread, 4);
+//
+// modest_finder_thread_process(modest, finder_thread, myhtml_tree->node_html, stylesheet->sel_list_first);
+//
+// finder_thread = modest_finder_thread_destroy(finder_thread, true);
+// finder = modest_finder_destroy(finder, true);
+//
+//
+// uint64_t parse_stop = myhtml_hperf_clock(NULL);
+//
+//// print_tree_after_all(modest, myhtml_tree, myhtml_tree->node_html, mycss_entry);
+//
+// printf("\n\n------------\nInformation:\n");
+// printf("\tTicks/sec: %llu\n", (unsigned long long) myhtml_hperf_res(NULL));
+// myhtml_hperf_print("\tFound selectors", parse_start, parse_stop, stdout);
+// myhtml_hperf_print("\tParse and Found Simple selectors", parse_simple_start, parse_simple_stop, stdout);
+// printf("\n");
+//
+//// printf("\nPrint result:\n");
+//// for(size_t i = 0; i < full_collection->length; i++) {
+//// myhtml_tree_print_node(myhtml_tree, full_collection->list[i], stdout);
+//// }
+//// printf("\nFound: %zu\n", full_collection->length);
+//// printf("\n");
+////
+//// modest_finder_destroy(finder_full, true);
+//
+// modest = modest_destroy(modest, true);
+//
+// mycss_t* mycss = mycss_entry->mycss;
+// mycss_stylesheet_destroy(stylesheet, true);
+// mycss_entry_destroy(mycss_entry, true);
+// mycss_destroy(mycss, true);
+//
+// myhtml_t* myhtml = myhtml_tree->myhtml;
+// myhtml_tree_destroy(myhtml_tree);
+// myhtml_destroy(myhtml);
+>>>>>>> Stashed changes
+//
+// return 0;
+//}
+//
+<<<<<<< Updated upstream
+
+
+
+
+=======
+//
+//
+//
+//
+//
+>>>>>>> Stashed changes
diff --git a/documents/myhtml_life_cycle.xml b/documents/myhtml_life_cycle.xml
deleted file mode 100644
index d2615d0..0000000
--- a/documents/myhtml_life_cycle.xml
+++ /dev/null
@@ -1 +0,0 @@
-<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36" version="6.0.2.6" editor="www.draw.io" type="device"><diagram name="Страница 1">7VvLcuI6EP0alqEsyzbxMpBkZjFJTVVSNXeWChagO8bi2iLAfP2VbMm2kEIAP8g8sgioLUt2d5+jVrcYwMly+ylFq8UDjXA8cJ1oO4C3A9e99iH/LwS7QhD4YSGYpyQqRKASPJGfWAodKV2TCGdaR0ZpzMhKF05pkuAp02QoTelG7zajsT7rCs2xIXiaotiUfiMRW8jXcoNK/hmT+ULNDAL5fi9o+mOe0nUi5xu4cJb/FZeXSI0lXzRboIhuaiJ4N4CTlFJWfFtuJzgWqlVqK+67f+Nq+dwpTtgxN7jFDa8oXstXf9h9fn74wmVfyAzzj8luGovPDeGP7jrPixSjKBu4QcwnGEfklX+di69ATOM6IFDXeLN2Wb4v2ykdM7wV8gVbxlwA+NeMpfQHntCYplyS0IT3HM9IHO+JUEzmCW+mhQXGrzhlhBvvRsqXJIrELOPNgjD8tEJTMeWGe2r5HHUNSaWJUfC2JpIa+4TpErN0x7vIq34orae8G/pFe1P5SmnhRc1PoJQh6Z7zcujKRPyLtJLdYiNDkTjiviubNGULOqcJiu8q6Th3SCwGcHSNcx2ku3+kPG98F42hz5v/YsZ2EppozSgXVaN/oXQlx5jRhMluwDuk4Iyu06l8ZskPDKVzLHtJbIm3OWiEFMeIkVcdqU00Ct12VRrdCAaq3JVL7omYPe96rlpFW+GAs0oY3t9DmIMGpUzNOI1RlpGpEstpQQOrKH9rzyz5rfyB0a7WYUVJwrLayF+FoIIc9HXIKcKtTFyMWBm8fLTjfMDgQY3har4R/LcW5DwW9HUlmehGLEVcsTitrivee+aUlnA7pkfSYuVY4A0GqzmbYkI5ufQaOZhzCjiPZz83hJopRiOD/ICN/IIWyM//6OSHt4TlQw5Dx5ftalTR+opTwt9bWCuf+ChgeiYwYc+41Ex0Grg8A1y3iCEuGe8YzgyTFmGAirvAXoywQCvRb7mdi8hzOIvpZrrgXDeMxJh2xOxbyYBNxvuTZM5FbjsgAUDnKxtIvI5AEhjqfsSbPILmTNSMb0zTvKvaFpTpjd5XZleMExrKLCLggvQfEDE1aga2Kc7IT/RSsrJEFe/tjwf+rVAb55hMqrGmxRjPbAEuE/yjnPY5J6Mrz2KMFnS/t+7C0FS9Y1G924LqFYTe0D0YDh//KN27vmcoP+xK99eWgKi9pbfTvQWwrJag9TD2aE2aq1/+guYG+hsiIuJN6mTdfsh4mMLdjigcXHs6jwBzy9wZh7smkfw6zjyyOHN4MWceGZr8mtIpzngU5xRB3a8XXuz7pterbwJDZR92S1Pf0BydU7AlFRQnXjip4Hq64d3Qr5vO6A/8Zv2h5++5RrOkBTCD0ycs5n8uFg9nFqO5LVV7KxJTva8tfeHX7xW/rmGDYlPgsCJW5Qs6FTbJcCIaKOHDB2gpNJe8ZEVG2jAQSWY0XXLXp/lINL+RsoXIIsmBs+HZefazQ+LSahcMiqFKtqtMYGhJvgOLtb02rB10wtZlozlbv5Umfi8tfT6Xtx6MnJcghnsk0DLXWjPEe64Qk1yxOgt6us1XtfSfKBa+cGPUUoIWLNI1EwNPylKnLa9rTQTbywX1Ghu/EgSTiXPQA05gYl9PDbshMJn42jWxCVrAJuwokirCHoXOS5R4jsOmZaPQeknNjr39eijwR/oQxXPKuyqLnopxH9rneSv+eqd/c04wd0N/OcFYr43KXWDhBNARJ5isXU8hPg7csckav1UO0QOXSyKqSO1XzLvAwKRTeN02nx6tSbOm8wcmEf1LJhG93kJ/7USHDDDqxzkcPQSpznxUUci58HCbRiEKInXYeK1ne462mblAf7cUnM8i/Pe2xOUhtBi94HhcngusqVaeDHzXBE7+ZzWB8koDROXZSPkWg/r5Qhu4nCHQwCWN1jA0DLQxr3z9fjqbZZgZFj0tClPxRbdxv/PhgHnAK44FpnMpYPqK+2tnFOjvhEvllM1xeeUMXR1EoBkyWwUfNOvEj5jjiq/JRSDCaqlo/pF3caIcO/ddxiCwpxik12KRF3ZDdR89BimB1rAW5VlOBrRPgmflNrxgpPlV2/lL9epH7yAUcEmmANv7PqIrDHuOruteMQx7w/CFCr6ea4IMdpOJPBVkwYkFX//Egu9+/7YLvp7tIEuBymyFEoXJm9UqzpW5jsVux15t5HPV77EQwYzT72+fQ+i1WOy1WqLou0R4KGdxNjN0tPwa0Bzt/WrBG+3VKIqHalyjGHVch1Q6/FtzOATyHuuQvFn9XLMwaPWTWHj3Pw==</diagram></mxfile> \ No newline at end of file
diff --git a/documents/myhtml_life_cycle_with_thread.png b/documents/myhtml_life_cycle_with_thread.png
deleted file mode 100644
index 424d4a7..0000000
--- a/documents/myhtml_life_cycle_with_thread.png
+++ /dev/null
Binary files differ
diff --git a/documents/myhtml_life_cycle_without_threads.png b/documents/myhtml_life_cycle_without_threads.png
deleted file mode 100644
index 336e2e0..0000000
--- a/documents/myhtml_life_cycle_without_threads.png
+++ /dev/null
Binary files differ
diff --git a/documents/myhtml_life_cycle_without_threads.xml b/documents/myhtml_life_cycle_without_threads.xml
deleted file mode 100644
index b524636..0000000
--- a/documents/myhtml_life_cycle_without_threads.xml
+++ /dev/null
@@ -1 +0,0 @@
-<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36" version="6.0.2.6" editor="www.draw.io" type="device"><diagram name="Страница 1">3VhLc5swEP41HONBYGP76EfSHJJOZpKZtkcFZFAjIyrk2OTXdwUSDwsnmdjOtPHBoI/VStrdb3fB8Rfr3TeBs+SWR4Q5nhvtHH/peN4U+fCvgKICxoFbAbGgUQWhBrinL0SDRmxDI5J3BCXnTNKsC4Y8TUkoOxgWgm+7YivOuqtmOCYWcB9iZqM/aCSTCp14QYNfExonZmUUTKsnjzh8igXfpHo9x/NX5a96vMZGlz5onuCIb1uQf+n4C8G5rO7WuwVhyrTGbNW8qwNP630Lksr3TPCqCc+YbYjZccBg6jyiz2p/stA2Cf5s1KbmkuzkBWY0Th1/BhKiNEP9GO5ifS3V5BlODXZbXD/c3sCcG7oicFkUIVPXLZUJ34AS9yERBEe5mQz7bs9vweXuuuiRG0bKSp6LgkOreB3tnlILeCLXDACkjioFfyILzrgAJOUpSM5XlLE9SO9lychKaXgmQlIIvZmG1zSK1CLzbUIluc9wqFbcAs/qbagpZHfQ5agOJOAn4WsiRQEiesJoomNPc9M3sbhtIr2Oz6QV5b7GsCZXXKtuAgxudIz1x9vYsiOJgHl6yAUEQsxTzC4bdF7SiSgFbtfgcGBR/NR4OfilBoMRDH8TKQudWPBGcoAa7TecZ1rHiqdSi6FhbWC1qdfNC2fgGxFqKZ3uJBYx0VJBvxMEYVjS5672YyzqH83gEE5GhM2IB4jmFEwj3smIxk/oQPS2fGdIoBfXjtDK3IOOOSry/UnQifzx2Ap81Bf4wQkCf/SvBz7ZUVmqHEzdkR43WtXojggK51beKhf+GFWGNlX8I6lSTp0JgYuWQMZpKnPLRbX+d3ltaJFriSUGZF5IklsurSqA6RjQXnlIcKbk1rtY9UyDFePbMMFCDiKls58x+16yaAP1MaRpDJB3GpJ4rv8mSYbnIsmZykMVwjVPyloNhp+pTrGpyyV2RdXuNLEiIxEynOc0rEAtgj5INk+PTVcALaJb/j5MqcCmFBp/UvkJLIZ8J9uyXYficVyJsNn0JhtO0R4Fb8f/uYrE1DJm1RBXdfoWU9uidhsqSE5f8GNdSHUiBOnR3BktldkgUnNtxrf7Uami2OSZhzKkL4bnKdBo2LW9P7Vt7/bY3jtF7pmcNPeYampXUpOVkGPV7i+VldDYTktDt9//J09LZvEWle4ED0kORdutavj/n5rQZPJ5uWk0PQs/Bp1e85Wqjb4aP0wTdcpO+L3ONGv3vDW2P7jMsoyV62+Y6nYDvFY8SB/zrPs1pu8jTetNcQUWqzuC079Kvk5G70xk3H+ZPCcZYdh8EqxeY5rPrv7lXw==</diagram></mxfile> \ No newline at end of file
diff --git a/examples/Makefile b/examples/Makefile
index 48b161e..d919f52 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -1,49 +1,84 @@
TARGET := examples
-SRCDIR := examples
+SRCDIR := .
CC ?= gcc
-LIBS := ../lib/libmodest_static.a
-LDLIBS := $(LIBS)
-INCLUDE_TMP := include
+# ARGS
+#
+# BINARY_OPTIMIZATION_LEVEL, default -O2
+# MODEST_BUILD_WITHOUT_THREADS, YES or (NO or undefined), default undefined
+#
-MODEST_OPTIMIZATION_LEVEL ?= -O2
+.DEFAULT_GOAL := all
-CFLAGS ?= -Wall -Werror
-CFLAGS += $(MODEST_OPTIMIZATION_LEVEL) -Wno-unused-variable -fPIC --std=c99 -I../include
+#********************
+# other Makefile
+#***************
+BINARY_PATH_RELATIVE := ..
+MODEST_SOURCE := $(BINARY_PATH_RELATIVE)/source
+include $(BINARY_PATH_RELATIVE)/Makefile.bin.cfg
-MODEST_BUILD_WITHOUT_THREADS ?= NO
-ifeq ($(MODEST_BUILD_WITHOUT_THREADS),YES)
- $(info Build Examples without POSIX Threads)
-else
- $(info Build Examples with POSIX Threads)
- CFLAGS += -pthread
-endif
+BINARY_TO_DIR := $(BINARY_PATH_RELATIVE)/$(BINARY_DIR_BASE)
-ifeq ($(OS),Windows_NT)
-else
- UNAM := $(shell uname -s)
- ifeq ($(UNAM),Darwin)
- else
- CFLAGS += -D_POSIX_C_SOURCE=199309L
- endif
-endif
+#********************
+# Build
+#***************
+BINARY_BUILD_MODULES ?= $(dir $(wildcard $(SRCDIR)/*/))
+BINARY_BUILD_MODULES_LIST := $(strip $(foreach dir,$(BINARY_BUILD_MODULES),$(word 2, $(subst $(MODEST_DIR_SEPARATOR), , $(dir))) ))
+BINARY_BUILD_MODULES_MAKEFILES_LIST := $(foreach dir,$(BINARY_BUILD_MODULES_LIST),$(dir)/Makefile.mk)
-find_files_h = $(wildcard $(dir)/*.h)
-find_files_c = $(wildcard $(dir)/*.c)
+#********************
+# Targets
+#***************
+BINARY_BUILD_MODULES_TARGET := $(BINARY_BUILD_MODULES_LIST)
+BINARY_BUILD_MODULES_TARGET_ALL := $(foreach dir,$(BINARY_BUILD_MODULES_TARGET),$(dir)_all)
+BINARY_BUILD_MODULES_TARGET_CLEAN := $(foreach dir,$(BINARY_BUILD_MODULES_TARGET),$(dir)_clean)
-SUBDIRS := selectors declarations myfont modest mycss myhtml
-HDRS += $(foreach dir,$(SUBDIRS),$(find_files_h))
-SRCS += $(foreach dir,$(SUBDIRS),$(find_files_c))
+#********************
+# Utils
+#***************
+define BYNARY_UTILS_NEW_LINE
-OBJS := $(patsubst %.c,%,$(SRCS))
-all: $(TARGET)
+endef
+BINARY_UTILS_OBJS = $(patsubst %.c,%,$(foreach dir,$2,$(wildcard $(SRCDIR)/$1/$(dir)/*.c)))
+BINARY_UTILS_CREATE_DIRS = $(foreach dir,$(BINARY_BUILD_MODULES_LIST),mkdir -p $(BINARY_TO_DIR)/$(dir) $(BYNARY_UTILS_NEW_LINE))
-$(TARGET): $(OBJS)
- cp -r $(OBJS) ../bin/
+#********************
+# Include all modules Makefile.mk
+#***************
+include $(BINARY_BUILD_MODULES_MAKEFILES_LIST)
-clean:
- rm -f $(OBJS)
+#********************
+# Set ARGS for flags
+#***************
+override CFLAGS += $(BINARY_CFLAGS)
+override LDFLAGS += $(BINARY_LDFLAGS)
+override LDLIBS += $(BINARY_LIBRARIES)
-.PHONY: all \ No newline at end of file
+#********************
+# Objects
+#***************
+BINARY_BUILD_EXECUTE ?= $(foreach dir,$(BINARY_BUILD_MODULES_TARGET),$($(dir)_objs))
+BINARY_BUILD_EXECUTE_CLEAN := $(foreach path,$(BINARY_BUILD_EXECUTE),$(subst ./,,$(path)))
+BINARY_BUILD_EXECUTE_TO_CLEAN := $(foreach path,$(BINARY_BUILD_EXECUTE_CLEAN),rm -rf $(BINARY_TO_DIR)/$(path) $(BYNARY_UTILS_NEW_LINE))
+BINARY_BUILD_DIRS_TO_CLEAN := $(foreach path,$(BINARY_BUILD_MODULES_LIST),rm -rf $(BINARY_TO_DIR)/$(path) $(BYNARY_UTILS_NEW_LINE))
+BINARY_BUILD_EXECUTE_COPY := $(foreach path,$(BINARY_BUILD_EXECUTE_CLEAN),cp $(path) $(BINARY_TO_DIR)/$(dir $(path)) $(BYNARY_UTILS_NEW_LINE))
+BINARY_BUILD_EXECUTE_COPY_ALL := $(BINARY_UTILS_CREATE_DIRS) $(BINARY_BUILD_EXECUTE_COPY)
+
+#********************
+# Target options
+#***************
+all: build
+ $(BINARY_BUILD_EXECUTE_COPY_ALL)
+
+build: $(BINARY_BUILD_EXECUTE_CLEAN)
+
+clean: $(BINARY_BUILD_MODULES_TARGET_CLEAN)
+ $(BINARY_BUILD_EXECUTE_TO_CLEAN)
+ $(BINARY_BUILD_DIRS_TO_CLEAN)
+
+copy:
+ $(BINARY_BUILD_EXECUTE_COPY_ALL)
+
+.PHONY: all copy clean $(BINARY_BUILD_MODULES_TARGET_ALL)
diff --git a/examples/modest/Makefile.mk b/examples/modest/Makefile.mk
new file mode 100644
index 0000000..6527ed1
--- /dev/null
+++ b/examples/modest/Makefile.mk
@@ -0,0 +1,7 @@
+modest_dirs := .
+modest_objs := $(call BINARY_UTILS_OBJS,modest,$(modest_dirs))
+
+modest_all: $(modest_objs)
+
+modest_clean:
+ rm -f $(modest_objs)
diff --git a/examples/modest/css_property_to_node.c b/examples/modest/css_property_to_node.c
index c58e339..faf356d 100644
--- a/examples/modest/css_property_to_node.c
+++ b/examples/modest/css_property_to_node.c
@@ -31,7 +31,7 @@
myhtml_tree_t * parse_html(const char* data, size_t data_size, myhtml_callback_tree_node_f cai, void* cai_ctx)
{
myhtml_t* myhtml = myhtml_create();
- myhtml_status_t status = myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);
+ mystatus_t status = myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);
check_status("Can't init MyHTML object\n");
@@ -42,7 +42,7 @@ myhtml_tree_t * parse_html(const char* data, size_t data_size, myhtml_callback_t
myhtml_callback_tree_node_insert_set(tree, cai, cai_ctx);
- status = myhtml_parse(tree, MyHTML_ENCODING_UTF_8, data, data_size);
+ status = myhtml_parse(tree, MyENCODING_UTF_8, data, data_size);
check_status("Can't parse HTML:\n%s\n", data);
return tree;
@@ -52,7 +52,7 @@ mycss_entry_t * parse_css(const char* data, size_t data_size)
{
// base init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
check_status("Can't init MyCSS object\n");
@@ -62,15 +62,16 @@ mycss_entry_t * parse_css(const char* data, size_t data_size)
check_status("Can't init MyCSS Entry object\n");
- status = mycss_parse(entry, MyHTML_ENCODING_UTF_8, data, data_size);
+ status = mycss_parse(entry, MyENCODING_UTF_8, data, data_size);
check_status("Can't parse CSS:\n%s\n", data);
return entry;
}
-void serialization_callback(const char* data, size_t len, void* ctx)
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
}
void print_result(modest_t* modest, myhtml_tree_t* myhtml_tree, myhtml_tree_node_t* scope_node, mycss_entry_t *mycss_entry)
@@ -111,7 +112,7 @@ int main(int argc, const char * argv[])
/* init Modest */
modest_t *modest = modest_create();
- modest_status_t status = modest_init(modest);
+ mystatus_t status = modest_init(modest);
check_status("Can't init Modest object\n");
diff --git a/examples/modest/css_real_and_default_property_to_node.c b/examples/modest/css_real_and_default_property_to_node.c
index 59f5ab0..35f9d68 100644
--- a/examples/modest/css_real_and_default_property_to_node.c
+++ b/examples/modest/css_real_and_default_property_to_node.c
@@ -29,15 +29,16 @@
#define DIE(msg, ...) do { fprintf(stderr, msg, ##__VA_ARGS__); exit(EXIT_FAILURE); } while(0)
#define check_status(msg, ...) do {if(status) DIE(msg, ##__VA_ARGS__);} while(0)
-void serialization_callback(const char* data, size_t len, void* ctx)
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
}
myhtml_tree_t * parse_html(const char* data, size_t data_size, myhtml_callback_tree_node_f cai, void* cai_ctx)
{
myhtml_t* myhtml = myhtml_create();
- myhtml_status_t status = myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);
+ mystatus_t status = myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);
check_status("Can't init MyHTML object\n");
@@ -48,7 +49,7 @@ myhtml_tree_t * parse_html(const char* data, size_t data_size, myhtml_callback_t
myhtml_callback_tree_node_insert_set(tree, cai, cai_ctx);
- status = myhtml_parse(tree, MyHTML_ENCODING_UTF_8, data, data_size);
+ status = myhtml_parse(tree, MyENCODING_UTF_8, data, data_size);
check_status("Can't parse HTML:\n%s\n", data);
return tree;
@@ -58,7 +59,7 @@ mycss_entry_t * parse_css(const char* data, size_t data_size)
{
// base init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
check_status("Can't init MyCSS object\n");
@@ -68,7 +69,7 @@ mycss_entry_t * parse_css(const char* data, size_t data_size)
check_status("Can't init MyCSS Entry object\n");
- status = mycss_parse(entry, MyHTML_ENCODING_UTF_8, data, data_size);
+ status = mycss_parse(entry, MyENCODING_UTF_8, data, data_size);
check_status("Can't parse CSS:\n%s\n", data);
return entry;
@@ -108,7 +109,7 @@ int main(int argc, const char * argv[])
/* init Modest */
modest_t *modest = modest_create();
- modest_status_t status = modest_init(modest);
+ mystatus_t status = modest_init(modest);
check_status("Can't init Modest object\n");
diff --git a/examples/modest/selectors_find_nodes_low_level.c b/examples/modest/selectors_find_nodes_low_level.c
index 1879c49..94395e1 100644
--- a/examples/modest/selectors_find_nodes_low_level.c
+++ b/examples/modest/selectors_find_nodes_low_level.c
@@ -32,19 +32,22 @@
#define DIE(msg, ...) do { fprintf(stderr, msg, ##__VA_ARGS__); exit(EXIT_FAILURE); } while(0)
#define CHECK_STATUS(msg, ...) do {if(status) DIE(msg, ##__VA_ARGS__);} while(0)
-void serialization_callback(const char* data, size_t len, void* ctx)
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
}
-void serialization_bad_selectors(const char* buffer, size_t size, void* ctx) {
+mystatus_t serialization_bad_selectors(const char* buffer, size_t size, void* ctx)
+{
printf("%.*s", (int)size, buffer);
+ return MyCORE_STATUS_OK;
}
myhtml_tree_t * parse_html(const char* data, size_t data_size)
{
myhtml_t* myhtml = myhtml_create();
- myhtml_status_t status = myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);
+ mystatus_t status = myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);
CHECK_STATUS("Can't init MyHTML object\n");
@@ -53,7 +56,7 @@ myhtml_tree_t * parse_html(const char* data, size_t data_size)
CHECK_STATUS("Can't init MyHTML Tree object\n");
- status = myhtml_parse(tree, MyHTML_ENCODING_UTF_8, data, data_size);
+ status = myhtml_parse(tree, MyENCODING_UTF_8, data, data_size);
CHECK_STATUS("Can't parse HTML:\n%s\n", data);
return tree;
@@ -63,7 +66,7 @@ mycss_entry_t * create_css_parser(void)
{
// base init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
CHECK_STATUS("Can't init MyCSS object\n");
@@ -78,9 +81,9 @@ mycss_entry_t * create_css_parser(void)
mycss_selectors_list_t * prepare_selector(mycss_entry_t *css_entry, const char* selector, size_t selector_size)
{
- mycss_status_t out_status;
+ mystatus_t out_status;
mycss_selectors_list_t *list = mycss_selectors_parse(mycss_entry_selectors(css_entry),
- MyHTML_ENCODING_UTF_8,
+ MyENCODING_UTF_8,
selector, selector_size,
&out_status);
/* check parsing errors */
diff --git a/examples/modest/selectors_prepare_low_level.c b/examples/modest/selectors_prepare_low_level.c
index b8c313b..39b7e58 100644
--- a/examples/modest/selectors_prepare_low_level.c
+++ b/examples/modest/selectors_prepare_low_level.c
@@ -29,13 +29,16 @@
#include <mycss/selectors/init.h>
#include <mycss/selectors/serialization.h>
-void serialization_callback(const char* data, size_t len, void* ctx)
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
}
-void serialization_bad_selectors(const char* buffer, size_t size, void* ctx) {
- printf("%.*s", (int)size, buffer);
+mystatus_t serialization_bad_selectors(const char* data, size_t len, void* ctx)
+{
+ printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
}
myhtml_tree_t * parse_html(myhtml_t* myhtml, const char* data, size_t data_size)
@@ -43,7 +46,7 @@ myhtml_tree_t * parse_html(myhtml_t* myhtml, const char* data, size_t data_size)
myhtml_tree_t* tree = myhtml_tree_create();
myhtml_tree_init(tree, myhtml);
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, data, data_size);
+ myhtml_parse(tree, MyENCODING_UTF_8, data, data_size);
return tree;
}
@@ -52,7 +55,7 @@ mycss_entry_t * create_css_parser(void)
{
// base init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
if(status) {
fprintf(stderr, "Can't init CSS Parser\n");
@@ -73,9 +76,9 @@ mycss_entry_t * create_css_parser(void)
mycss_selectors_list_t * prepare_selector(mycss_entry_t *css_entry, const char* selector, size_t selector_size)
{
- mycss_status_t out_status;
+ mystatus_t out_status;
mycss_selectors_list_t *list = mycss_selectors_parse(mycss_entry_selectors(css_entry),
- MyHTML_ENCODING_UTF_8, selector, selector_size,
+ MyENCODING_UTF_8, selector, selector_size,
&out_status);
/* check parsing errors */
if(list == NULL || (list->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD)) {
diff --git a/examples/modest/style_attr_low_level.c b/examples/modest/style_attr_low_level.c
index 7ee96a7..549c8b3 100644
--- a/examples/modest/style_attr_low_level.c
+++ b/examples/modest/style_attr_low_level.c
@@ -33,15 +33,16 @@
#define DIE(msg, ...) do { fprintf(stderr, msg, ##__VA_ARGS__); exit(EXIT_FAILURE); } while(0)
#define CHECK_STATUS(msg, ...) do {if(status) DIE(msg, ##__VA_ARGS__);} while(0)
-void serialization_callback(const char* data, size_t len, void* ctx)
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
}
myhtml_tree_t * parse_html(const char* data, size_t data_size)
{
myhtml_t* myhtml = myhtml_create();
- myhtml_status_t status = myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);
+ mystatus_t status = myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);
CHECK_STATUS("Can't init MyHTML object\n");
@@ -50,7 +51,7 @@ myhtml_tree_t * parse_html(const char* data, size_t data_size)
CHECK_STATUS("Can't init MyHTML Tree object\n");
- status = myhtml_parse(tree, MyHTML_ENCODING_UTF_8, data, data_size);
+ status = myhtml_parse(tree, MyENCODING_UTF_8, data, data_size);
CHECK_STATUS("Can't parse HTML:\n%s\n", data);
return tree;
@@ -60,7 +61,7 @@ mycss_entry_t * create_css_parser(void)
{
// base init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
CHECK_STATUS("Can't init MyCSS object\n");
@@ -101,7 +102,7 @@ void parse_style_of_node_and_print(myhtml_tree_t *html_tree, mycss_entry_t *css_
myhtml_tree_attr_t *attr_style = myhtml_attribute_by_key(node, "style", 5);
if(attr_style) {
- mycss_declaration_entry_t *dec_entry = mycss_declaration_parse(css_entry->declaration, MyHTML_ENCODING_UTF_8,
+ mycss_declaration_entry_t *dec_entry = mycss_declaration_parse(css_entry->declaration, MyENCODING_UTF_8,
attr_style->value.data, attr_style->value.length, NULL);
if(dec_entry) {
diff --git a/examples/mycss/Makefile.mk b/examples/mycss/Makefile.mk
new file mode 100644
index 0000000..47db8cd
--- /dev/null
+++ b/examples/mycss/Makefile.mk
@@ -0,0 +1,7 @@
+mycss_dirs := .
+mycss_objs := $(call BINARY_UTILS_OBJS,mycss,$(mycss_dirs))
+
+mycss_all: $(mycss_objs)
+
+mycss_clean:
+ rm -f $(mycss_objs)
diff --git a/examples/mycss/css_low_level.c b/examples/mycss/css_low_level.c
index 0732853..199bb88 100644
--- a/examples/mycss/css_low_level.c
+++ b/examples/mycss/css_low_level.c
@@ -24,6 +24,8 @@
#include <mycss/mycss.h>
+#include "example.h"
+
struct res_data {
char *data;
size_t size;
@@ -62,7 +64,7 @@ struct res_data load_data_file(const char* filename)
size_t nread = fread(data, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -72,9 +74,10 @@ struct res_data load_data_file(const char* filename)
return res;
}
-void serialization_callback(const char* data, size_t len, void* ctx)
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
}
int main(int argc, const char * argv[])
@@ -93,14 +96,14 @@ int main(int argc, const char * argv[])
// basic init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
// current entry work init
mycss_entry_t *entry = mycss_entry_create();
status = mycss_entry_init(mycss, entry);
// parse selectors
- status = mycss_parse(entry, MyHTML_ENCODING_UTF_8, res.data, res.size);
+ status = mycss_parse(entry, MyENCODING_UTF_8, res.data, res.size);
if(status) {
fprintf(stderr, "Parse error!\n");
diff --git a/examples/mycss/declaration_low_level.c b/examples/mycss/declaration_low_level.c
index 030da3b..9d2aaf9 100644
--- a/examples/mycss/declaration_low_level.c
+++ b/examples/mycss/declaration_low_level.c
@@ -25,9 +25,10 @@
#include <mycss/mycss.h>
#include <mycss/declaration/init.h>
-void serialization_callback(const char* data, size_t len, void* ctx)
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
}
int main(int argc, const char * argv[])
@@ -36,7 +37,7 @@ int main(int argc, const char * argv[])
// basic init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
// check initialization
if (MyCSS_FAILED(status)) return EXIT_FAILURE;
@@ -50,8 +51,8 @@ int main(int argc, const char * argv[])
printf("\t%s", declaration);
printf("\n");
- mycss_status_t out_status;
- mycss_declaration_entry_t *dec_entry = mycss_declaration_parse(entry->declaration, MyHTML_ENCODING_UTF_8,
+ mystatus_t out_status;
+ mycss_declaration_entry_t *dec_entry = mycss_declaration_parse(entry->declaration, MyENCODING_UTF_8,
declaration, strlen(declaration), &out_status);
/* print result */
diff --git a/examples/mycss/detect_charset_encoding_high_level.c b/examples/mycss/detect_charset_encoding_high_level.c
index 247adda..3fdf53e 100644
--- a/examples/mycss/detect_charset_encoding_high_level.c
+++ b/examples/mycss/detect_charset_encoding_high_level.c
@@ -28,9 +28,9 @@ int main(int argc, const char * argv[])
{
char *css = "@charset \"cp1251\"; #best-id {}";
- myhtml_encoding_t encoding = mycss_encoding_check_charset_rule(css, strlen(css));
+ myencoding_t encoding = mycss_encoding_check_charset_rule(css, strlen(css));
- if(encoding == MyHTML_ENCODING_WINDOWS_1251)
+ if(encoding == MyENCODING_WINDOWS_1251)
printf("Detected Encoding: windows-1251\n");
else
printf("Detected Encoding: something wrong\n");
diff --git a/examples/mycss/example.h b/examples/mycss/example.h
new file mode 100644
index 0000000..c6b1dbd
--- /dev/null
+++ b/examples/mycss/example.h
@@ -0,0 +1,32 @@
+/*
+ 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: vincent.torri@gmail.com (Vincent Torri)
+*/
+
+#ifndef MyCSS_EXAMPLE_EXAMPLE_H
+#define MyCSS_EXAMPLE_EXAMPLE_H
+#pragma once
+
+/* Format */
+#ifdef _WIN32
+ #define MyCORE_FMT_Z "%Iu"
+#else
+ #define MyCORE_FMT_Z "%zu"
+#endif
+
+#endif /* MyCSS_EXAMPLE_EXAMPLE_H */
diff --git a/examples/mycss/incoming_buffer_high_level.c b/examples/mycss/incoming_buffer_high_level.c
index dc63fba..3feca2a 100644
--- a/examples/mycss/incoming_buffer_high_level.c
+++ b/examples/mycss/incoming_buffer_high_level.c
@@ -24,6 +24,8 @@
#include <mycss/api.h>
+#include "example.h"
+
// see tokenizer_buffer_high_level
mycss_token_t * token_ready_callback(mycss_entry_t* entry, mycss_token_t* token)
@@ -32,21 +34,21 @@ mycss_token_t * token_ready_callback(mycss_entry_t* entry, mycss_token_t* token)
size_t tokens_count = mycss_entry_token_count(entry);
mycss_token_type_t token_type = mycss_token_type(token);
- printf("Token %zu; %s; \"", tokens_count, mycss_token_name_by_type(token_type));
+ printf("Token " MyCORE_FMT_Z "; %s; \"", tokens_count, mycss_token_name_by_type(token_type));
// print data
- myhtml_incoming_buffer_t *buffer = mycss_entry_incoming_buffer_current(entry);
- buffer = myhtml_incoming_buffer_find_by_position(buffer, mycss_token_begin(token));
+ mycore_incoming_buffer_t *buffer = mycss_entry_incoming_buffer_current(entry);
+ buffer = mycore_incoming_buffer_find_by_position(buffer, mycss_token_begin(token));
//
size_t absolute_begin = mycss_token_begin(token);
- size_t relative_begin = absolute_begin - myhtml_incoming_buffer_offset(buffer);
+ size_t relative_begin = absolute_begin - mycore_incoming_buffer_offset(buffer);
size_t length = mycss_token_length(token);
// if token data length in one buffer then print them all at once
- if((relative_begin + length) <= myhtml_incoming_buffer_size(buffer))
+ if((relative_begin + length) <= mycore_incoming_buffer_size(buffer))
{
- const char *data = myhtml_incoming_buffer_data(buffer);
+ const char *data = mycore_incoming_buffer_data(buffer);
printf("%.*s\"\n", (int)length, &data[relative_begin]);
return token;
@@ -54,17 +56,17 @@ mycss_token_t * token_ready_callback(mycss_entry_t* entry, mycss_token_t* token)
// if the data are spread across multiple buffers that join them
while(buffer) {
- const char *data = myhtml_incoming_buffer_data(buffer);
+ const char *data = mycore_incoming_buffer_data(buffer);
- if((relative_begin + length) > myhtml_incoming_buffer_size(buffer))
+ if((relative_begin + length) > mycore_incoming_buffer_size(buffer))
{
- size_t relative_end = (myhtml_incoming_buffer_size(buffer) - relative_begin);
+ size_t relative_end = (mycore_incoming_buffer_size(buffer) - relative_begin);
length -= relative_end;
printf("%.*s", (int)relative_end, &data[relative_begin]);
relative_begin = 0;
- buffer = myhtml_incoming_buffer_next(buffer);
+ buffer = mycore_incoming_buffer_next(buffer);
}
else {
printf("%.*s", (int)length, &data[relative_begin]);
@@ -86,7 +88,7 @@ int main(int argc, const char * argv[])
// basic init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
// check initialization
if (MyCSS_FAILED(status)) return EXIT_FAILURE;
@@ -98,8 +100,8 @@ int main(int argc, const char * argv[])
// set custom callback for token is ready
mycss_entry_token_ready_callback(entry, token_ready_callback);
- // this is example, you can not specify, dy default MyHTML_ENCODING_UTF_8
- mycss_encoding_set(entry, MyHTML_ENCODING_UTF_8);
+ // this is example, you can not specify, dy default MyENCODING_UTF_8
+ mycss_encoding_set(entry, MyENCODING_UTF_8);
// parse css chunks
mycss_parse_chunk(entry, css_chunk_1, strlen(css_chunk_1));
diff --git a/examples/mycss/selectors_low_level.c b/examples/mycss/selectors_low_level.c
index df91be8..0137adb 100644
--- a/examples/mycss/selectors_low_level.c
+++ b/examples/mycss/selectors_low_level.c
@@ -25,9 +25,10 @@
#include <mycss/mycss.h>
#include <mycss/selectors/init.h>
-void serialization_callback(const char* data, size_t len, void* ctx)
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
}
int main(int argc, const char * argv[])
@@ -36,7 +37,7 @@ int main(int argc, const char * argv[])
// basic init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
// check initialization
if (MyCSS_FAILED(status)) return EXIT_FAILURE;
@@ -50,8 +51,8 @@ int main(int argc, const char * argv[])
printf("\t%s", selector);
printf("\n");
- mycss_status_t out_status;
- mycss_selectors_list_t *list = mycss_selectors_parse(entry->selectors, MyHTML_ENCODING_UTF_8, selector, strlen(selector), &out_status);
+ mystatus_t out_status;
+ mycss_selectors_list_t *list = mycss_selectors_parse(entry->selectors, MyENCODING_UTF_8, selector, strlen(selector), &out_status);
/* print result */
printf("Result:\n\t");
diff --git a/examples/mycss/stylesheet_low_level.c b/examples/mycss/stylesheet_low_level.c
index 2e19abe..92369cb 100644
--- a/examples/mycss/stylesheet_low_level.c
+++ b/examples/mycss/stylesheet_low_level.c
@@ -24,9 +24,10 @@
#include <mycss/mycss.h>
-void serialization_callback(const char* data, size_t len, void* ctx)
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
{
printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
}
int main(int argc, const char * argv[])
@@ -39,7 +40,7 @@ body > div[id*=mu i]:not(:nth-child(2n+1)) {width: 1.4%}";
// basic init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
// check initialization
if (MyCSS_FAILED(status)) return EXIT_FAILURE;
@@ -53,7 +54,7 @@ body > div[id*=mu i]:not(:nth-child(2n+1)) {width: 1.4%}";
printf("%s", css);
printf("\n\n");
- status = mycss_parse(entry, MyHTML_ENCODING_UTF_8, css, strlen(css));
+ status = mycss_parse(entry, MyENCODING_UTF_8, css, strlen(css));
/* print result */
printf("Result:\n");
diff --git a/examples/mycss/token_type_convert_high_level.c b/examples/mycss/token_type_convert_high_level.c
index 9767854..6f4ece9 100644
--- a/examples/mycss/token_type_convert_high_level.c
+++ b/examples/mycss/token_type_convert_high_level.c
@@ -24,31 +24,33 @@
#include <mycss/api.h>
+#include "example.h"
+
mycss_token_t * token_ready_callback(mycss_entry_t* entry, mycss_token_t* token)
{
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true);
if(mycss_token_type(token) == MyCSS_TOKEN_TYPE_NUMBER)
{
double return_num;
- mycss_convert_data_to_double(myhtml_string_data(&str), myhtml_string_length(&str), &return_num, NULL);
+ mycss_convert_data_to_double(mycore_string_data(&str), mycore_string_length(&str), &return_num, NULL);
- printf("Number %s: %f\n", myhtml_string_data(&str), return_num);
+ printf("Number %s: %f\n", mycore_string_data(&str), return_num);
}
else if(mycss_token_type(token) == MyCSS_TOKEN_TYPE_UNICODE_RANGE)
{
size_t start, end;
- mycss_convert_unicode_range_to_codepoint(myhtml_string_data(&str), myhtml_string_length(&str),
+ mycss_convert_unicode_range_to_codepoint(mycore_string_data(&str), mycore_string_length(&str),
&start, &end);
if(end)
- printf("Unicode range U+%s: %zu-%zu\n", myhtml_string_data(&str), start, end);
+ printf("Unicode range U+%s: " MyCORE_FMT_Z "-" MyCORE_FMT_Z "\n", mycore_string_data(&str), start, end);
else
- printf("Unicode range U+%s: %zu\n", myhtml_string_data(&str), start);
+ printf("Unicode range U+%s: " MyCORE_FMT_Z "\n", mycore_string_data(&str), start);
}
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
return token;
}
@@ -59,7 +61,7 @@ int main(int argc, const char * argv[])
// basic init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
// check initialization
if (MyCSS_FAILED(status)) return EXIT_FAILURE;
@@ -72,7 +74,7 @@ int main(int argc, const char * argv[])
mycss_entry_token_ready_callback(entry, token_ready_callback);
// parse css
- mycss_parse(entry, MyHTML_ENCODING_UTF_8, css, strlen(css));
+ mycss_parse(entry, MyENCODING_UTF_8, css, strlen(css));
// release resurces
mycss_entry_destroy(entry, true);
diff --git a/examples/mycss/tokenizer_buffer_high_level.c b/examples/mycss/tokenizer_buffer_high_level.c
index b47f254..4945a34 100644
--- a/examples/mycss/tokenizer_buffer_high_level.c
+++ b/examples/mycss/tokenizer_buffer_high_level.c
@@ -24,20 +24,22 @@
#include <mycss/api.h>
+#include "example.h"
+
mycss_token_t * token_ready_callback(mycss_entry_t* entry, mycss_token_t* token)
{
// print token name
size_t tokens_count = mycss_entry_token_count(entry);
mycss_token_type_t token_type = mycss_token_type(token);
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true);
- printf("Token %zu; %s; \"%s\"\n", tokens_count,
+ printf("Token " MyCORE_FMT_Z "; %s; \"%s\"\n", tokens_count,
mycss_token_name_by_type(token_type),
- myhtml_string_data(&str));
+ mycore_string_data(&str));
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
return token;
}
@@ -50,7 +52,7 @@ int main(int argc, const char * argv[])
// basic init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
// check initialization
if (MyCSS_FAILED(status)) return EXIT_FAILURE;
@@ -62,8 +64,8 @@ int main(int argc, const char * argv[])
// set custom callback for token is ready
mycss_entry_token_ready_callback(entry, token_ready_callback);
- // this is example, you can not specify, dy default MyHTML_ENCODING_UTF_8
- mycss_encoding_set(entry, MyHTML_ENCODING_UTF_8);
+ // this is example, you can not specify, dy default MyENCODING_UTF_8
+ mycss_encoding_set(entry, MyENCODING_UTF_8);
// parse css chunks
mycss_parse_chunk(entry, css_chunk_1, strlen(css_chunk_1));
diff --git a/examples/mycss/tokenizer_chunk_high_level.c b/examples/mycss/tokenizer_chunk_high_level.c
index e319095..be12438 100644
--- a/examples/mycss/tokenizer_chunk_high_level.c
+++ b/examples/mycss/tokenizer_chunk_high_level.c
@@ -24,12 +24,14 @@
#include <mycss/api.h>
+#include "example.h"
+
mycss_token_t * token_ready_callback(mycss_entry_t* entry, mycss_token_t* token)
{
size_t tokens_count = mycss_entry_token_count(entry);
mycss_token_type_t token_type = mycss_token_type(token);
- printf("Token %zu: <%s>\n", tokens_count, mycss_token_name_by_type(token_type));
+ printf("Token " MyCORE_FMT_Z ": <%s>\n", tokens_count, mycss_token_name_by_type(token_type));
return token;
}
@@ -42,7 +44,7 @@ int main(int argc, const char * argv[])
// basic init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
// check initialization
if (MyCSS_FAILED(status)) return EXIT_FAILURE;
@@ -54,8 +56,8 @@ int main(int argc, const char * argv[])
// set custom callback for token is ready
mycss_entry_token_ready_callback(entry, token_ready_callback);
- // this is example, you can not specify, dy default MyHTML_ENCODING_UTF_8
- mycss_encoding_set(entry, MyHTML_ENCODING_UTF_8);
+ // this is example, you can not specify, dy default MyENCODING_UTF_8
+ mycss_encoding_set(entry, MyENCODING_UTF_8);
// parse css chunks
mycss_parse_chunk(entry, css_chunk_1, strlen(css_chunk_1));
diff --git a/examples/mycss/tokenizer_high_level.c b/examples/mycss/tokenizer_high_level.c
index a42282d..e99a68b 100644
--- a/examples/mycss/tokenizer_high_level.c
+++ b/examples/mycss/tokenizer_high_level.c
@@ -24,12 +24,14 @@
#include <mycss/api.h>
+#include "example.h"
+
mycss_token_t * token_ready_callback(mycss_entry_t* entry, mycss_token_t* token)
{
size_t tokens_count = mycss_entry_token_count(entry);
mycss_token_type_t token_type = mycss_token_type(token);
- printf("Token %zu: <%s>\n", tokens_count, mycss_token_name_by_type(token_type));
+ printf("Token " MyCORE_FMT_Z ": <%s>\n", tokens_count, mycss_token_name_by_type(token_type));
return token;
}
@@ -40,7 +42,7 @@ int main(int argc, const char * argv[])
// basic init
mycss_t *mycss = mycss_create();
- mycss_status_t status = mycss_init(mycss);
+ mystatus_t status = mycss_init(mycss);
// check initialization
if (MyCSS_FAILED(status)) return EXIT_FAILURE;
@@ -53,7 +55,7 @@ int main(int argc, const char * argv[])
mycss_entry_token_ready_callback(entry, token_ready_callback);
// parse css
- mycss_parse(entry, MyHTML_ENCODING_UTF_8, css, strlen(css));
+ mycss_parse(entry, MyENCODING_UTF_8, css, strlen(css));
// release resurces
mycss_entry_destroy(entry, true);
diff --git a/examples/myencoding/Makefile.mk b/examples/myencoding/Makefile.mk
new file mode 100644
index 0000000..0da1183
--- /dev/null
+++ b/examples/myencoding/Makefile.mk
@@ -0,0 +1,7 @@
+myencoding_dirs := .
+myencoding_objs := $(call BINARY_UTILS_OBJS,myencoding,$(myencoding_dirs))
+
+myencoding_all: $(myencoding_objs)
+
+myencoding_clean:
+ rm -f $(myencoding_objs)
diff --git a/examples/myhtml/detect_encoding_high_level.c b/examples/myencoding/detect_encoding_by_trigrams.c
index 73b8a18..70ba0ac 100644
--- a/examples/myhtml/detect_encoding_high_level.c
+++ b/examples/myencoding/detect_encoding_by_trigrams.c
@@ -20,7 +20,10 @@
#include <stdio.h>
#include <stdlib.h>
-#include <myhtml/api.h>
+
+#include <myencoding/encoding.h>
+
+#include "example.h"
struct res_html {
char *html;
@@ -60,7 +63,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -70,19 +73,19 @@ struct res_html load_html_file(const char* filename)
return res;
}
-void print_encoding(myhtml_encoding_t encoding)
+void print_encoding(myencoding_t encoding)
{
printf("Character encoding is ");
switch (encoding) {
- case MyHTML_ENCODING_UTF_8: printf("UTF-8"); break;
- case MyHTML_ENCODING_UTF_16LE: printf("UTF_16LE"); break;
- case MyHTML_ENCODING_UTF_16BE: printf("UTF_16BE"); break;
- case MyHTML_ENCODING_KOI8_R: printf("KOI8_R"); break;
- case MyHTML_ENCODING_WINDOWS_1251: printf("WINDOWS_1251"); break;
- case MyHTML_ENCODING_X_MAC_CYRILLIC: printf("X_MAC_CYRILLIC"); break;
- case MyHTML_ENCODING_IBM866: printf("IBM866"); break;
- case MyHTML_ENCODING_ISO_8859_5: printf("ISO_8859_5"); break;
+ case MyENCODING_UTF_8: printf("UTF-8"); break;
+ case MyENCODING_UTF_16LE: printf("UTF_16LE"); break;
+ case MyENCODING_UTF_16BE: printf("UTF_16BE"); break;
+ case MyENCODING_KOI8_R: printf("KOI8_R"); break;
+ case MyENCODING_WINDOWS_1251: printf("WINDOWS_1251"); break;
+ case MyENCODING_X_MAC_CYRILLIC: printf("X_MAC_CYRILLIC"); break;
+ case MyENCODING_IBM866: printf("IBM866"); break;
+ case MyENCODING_ISO_8859_5: printf("ISO_8859_5"); break;
default:
printf("UNKNOWN");
break;
@@ -105,14 +108,14 @@ int main(int argc, const char * argv[])
struct res_html res = load_html_file(path);
- myhtml_encoding_t encoding;
+ myencoding_t encoding;
// try detect by BOM
- if (myhtml_encoding_detect_bom(res.html, res.size, &encoding)) {
+ if (myencoding_detect_bom(res.html, res.size, &encoding)) {
print_encoding(encoding);
- } else if (myhtml_encoding_detect(res.html, res.size, &encoding)) {
+ } else if (myencoding_detect(res.html, res.size, &encoding)) {
print_encoding(encoding);
- } else if (encoding != MyHTML_ENCODING_DEFAULT) {
+ } else if (encoding != MyENCODING_DEFAULT) {
printf("It is possible that ");
print_encoding(encoding);
} else {
diff --git a/examples/myhtml/detect_encoding_in_meta_high_level.c b/examples/myencoding/detect_encoding_in_meta.c
index 72a9cc4..e2e652d 100644
--- a/examples/myhtml/detect_encoding_in_meta_high_level.c
+++ b/examples/myencoding/detect_encoding_in_meta.c
@@ -20,7 +20,10 @@
#include <stdio.h>
#include <stdlib.h>
-#include <myhtml/api.h>
+
+#include <myencoding/encoding.h>
+
+#include "example.h"
struct res_html {
char *html;
@@ -60,7 +63,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -79,13 +82,13 @@ int main(int argc, const char * argv[])
struct res_html res = load_html_file(argv[1]);
- myhtml_encoding_t encoding = myhtml_encoding_prescan_stream_to_determine_encoding(res.html, res.size);
+ myencoding_t encoding = myencoding_prescan_stream_to_determine_encoding(res.html, res.size);
- if(encoding == MyHTML_ENCODING_NOT_DETERMINED) {
+ if(encoding == MyENCODING_NOT_DETERMINED) {
printf("Can't detect encoding\n");
}
else {
- const char *encoding_name = myhtml_encoding_name_by_id(encoding, NULL);
+ const char *encoding_name = myencoding_name_by_id(encoding, NULL);
printf("Encoding: %s\n", encoding_name);
}
diff --git a/examples/myhtml/encoding_by_name_high_level.c b/examples/myencoding/encoding_by_name.c
index 4e669b0..e2650b9 100644
--- a/examples/myhtml/encoding_by_name_high_level.c
+++ b/examples/myencoding/encoding_by_name.c
@@ -22,16 +22,16 @@
#include <stdlib.h>
#include <string.h>
-#include <myhtml/api.h>
+#include <myencoding/encoding.h>
int main(int argc, const char * argv[])
{
const char *name = "cp1251";
- myhtml_encoding_t encoding;
+ myencoding_t encoding;
- if(myhtml_encoding_by_name(name, strlen(name), &encoding))
+ if(myencoding_by_name(name, strlen(name), &encoding))
{
- if(encoding == MyHTML_ENCODING_WINDOWS_1251) {
+ if(encoding == MyENCODING_WINDOWS_1251) {
printf("Detected Encoding: windows-1251\n");
return 0;
}
diff --git a/examples/myencoding/example.h b/examples/myencoding/example.h
new file mode 100644
index 0000000..27f7ec8
--- /dev/null
+++ b/examples/myencoding/example.h
@@ -0,0 +1,32 @@
+/*
+ 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: vincent.torri@gmail.com (Vincent Torri)
+*/
+
+#ifndef MyHTML_EXAMPLE_EXAMPLE_H
+#define MyHTML_EXAMPLE_EXAMPLE_H
+#pragma once
+
+/* Format */
+#ifdef _WIN32
+ #define MyCORE_FMT_Z "%Iu"
+#else
+ #define MyCORE_FMT_Z "%zu"
+#endif
+
+#endif /* MyHTML_EXAMPLE_EXAMPLE_H */
diff --git a/examples/myfont/Makefile.mk b/examples/myfont/Makefile.mk
new file mode 100644
index 0000000..4362b6a
--- /dev/null
+++ b/examples/myfont/Makefile.mk
@@ -0,0 +1,7 @@
+myfont_dirs := .
+myfont_objs := $(call BINARY_UTILS_OBJS,myfont,$(myfont_dirs))
+
+myfont_all: $(myfont_objs)
+
+myfont_clean:
+ rm -f $(myfont_objs)
diff --git a/examples/myfont/glyph_metrics.c b/examples/myfont/glyph_metrics.c
index 9a39b5e..606bd4d 100644
--- a/examples/myfont/glyph_metrics.c
+++ b/examples/myfont/glyph_metrics.c
@@ -23,9 +23,9 @@
#include <string.h>
#include <myfont/myfont.h>
-#include <myhtml/encoding.h>
+#include <myencoding/encoding.h>
-void usage(const char *path, float font_size, unsigned long codepoint)
+void usage(const char *path, float font_size, size_t codepoint)
{
printf("Usage:\n");
printf("\tprogram [char in UTF-8] [font fize in px] [font path]\n");
@@ -35,14 +35,14 @@ void usage(const char *path, float font_size, unsigned long codepoint)
int main(int argc, const char * argv[])
{
/* set and get params */
- const char *path = "../third_party/font/Arkhip.ttf";
+ const char *path = "third_party/font/Arkhip.ttf";
float font_size = 200.0f;
- unsigned long codepoint;
- myhtml_encoding_ascii_utf_8_to_codepoint((unsigned char*)"x", &codepoint);
+ size_t codepoint;
+ myencoding_ascii_utf_8_to_codepoint((unsigned char*)"x", &codepoint);
if (argc == 2) {
- if(myhtml_encoding_ascii_utf_8_to_codepoint((const unsigned char*)argv[1], &codepoint) == 0) {
+ if(myencoding_ascii_utf_8_to_codepoint((const unsigned char*)argv[1], &codepoint) == 0) {
fprintf(stderr, "Bad char code point\n");
return EXIT_FAILURE;
}
@@ -67,7 +67,8 @@ int main(int argc, const char * argv[])
myfont_font_t *mf = myfont_create();
myfont_init(mf);
- myfont_status_t mf_status = myfont_load(mf, path);
+ uint8_t *font_data;
+ mystatus_t mf_status = myfont_load_from_file(mf, path, &font_data, NULL);
if(mf_status) {
myfont_destroy(mf, true);
@@ -83,7 +84,7 @@ int main(int argc, const char * argv[])
}
char data[5];
- size_t len = myhtml_encoding_codepoint_to_ascii_utf_8(codepoint, data);
+ size_t len = myencoding_codepoint_to_ascii_utf_8(codepoint, data);
data[len] = '\0';
/* work code */
@@ -102,7 +103,7 @@ int main(int argc, const char * argv[])
printf("Font file: %s\n", path);
printf("Font size: %.fpx\n\n", font_size);
- printf("Metrics for code point %lu (%s):\n", codepoint, data);
+ printf("Metrics for code point " MyCORE_FORMAT_Z " (%s):\n", codepoint, data);
printf("\tBaseline: %.05f\n", baseline);
printf("\tAscender: %.05f\n", ascender);
printf("\tDescender: %.05f\n", descender);
@@ -135,6 +136,7 @@ int main(int argc, const char * argv[])
printf("</svg>\n");
+ myfont_destroy_font_data(mf, font_data);
myfont_destroy(mf, true);
return 0;
diff --git a/examples/myhtml/Makefile.mk b/examples/myhtml/Makefile.mk
new file mode 100644
index 0000000..f6fc0c7
--- /dev/null
+++ b/examples/myhtml/Makefile.mk
@@ -0,0 +1,7 @@
+myhtml_dirs := .
+myhtml_objs := $(call BINARY_UTILS_OBJS,myhtml,$(myhtml_dirs))
+
+myhtml_all: $(myhtml_objs)
+
+myhtml_clean:
+ rm -f $(myhtml_objs)
diff --git a/examples/myhtml/attributes_high_level.c b/examples/myhtml/attributes_high_level.c
index fc1a0a5..f47df26 100644
--- a/examples/myhtml/attributes_high_level.c
+++ b/examples/myhtml/attributes_high_level.c
@@ -23,6 +23,11 @@
#include <string.h>
#include <myhtml/api.h>
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
+{
+ printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
+}
int main(int argc, const char * argv[])
{
@@ -37,7 +42,7 @@ int main(int argc, const char * argv[])
myhtml_tree_init(tree, myhtml);
// parse html
- myhtml_parse_fragment(tree, MyHTML_ENCODING_UTF_8, html, strlen(html), MyHTML_TAG_DIV, MyHTML_NAMESPACE_HTML);
+ myhtml_parse_fragment(tree, MyENCODING_UTF_8, html, strlen(html), MyHTML_TAG_DIV, MyHTML_NAMESPACE_HTML);
// get first DIV from index
myhtml_collection_t *div_list = myhtml_get_nodes_by_name(tree, NULL, "div", 3, NULL);
@@ -45,19 +50,19 @@ int main(int argc, const char * argv[])
// print original tree
printf("Original tree:\n");
- myhtml_tree_print_node_children(tree, myhtml_tree_get_document(tree), stdout, 0);
+ myhtml_serialization_tree_callback(myhtml_tree_get_node_html(tree), serialization_callback, NULL);
printf("For a test; Create and delete 100000 attrs...\n");
for(size_t j = 0; j < 100000; j++) {
- myhtml_tree_attr_t *attr = myhtml_attribute_add(node, "key", 3, "value", 5, MyHTML_ENCODING_UTF_8);
+ myhtml_tree_attr_t *attr = myhtml_attribute_add(node, "key", 3, "value", 5, MyENCODING_UTF_8);
myhtml_attribute_delete(tree, node, attr);
}
// add first attr in first div in tree
- myhtml_attribute_add(node, "key", 3, "value", 5, MyHTML_ENCODING_UTF_8);
+ myhtml_attribute_add(node, "key", 3, "value", 5, MyENCODING_UTF_8);
printf("Modified tree:\n");
- myhtml_tree_print_node_children(tree, myhtml_tree_get_document(tree), stdout, 0);
+ myhtml_serialization_tree_callback(myhtml_tree_get_node_html(tree), serialization_callback, NULL);
// get attr by key name
myhtml_tree_attr_t *gets_attr = myhtml_attribute_by_key(node, "key", 3);
diff --git a/examples/myhtml/callback_tree_node_high_level.c b/examples/myhtml/callback_tree_node_high_level.c
index c0fe589..b41d1fe 100644
--- a/examples/myhtml/callback_tree_node_high_level.c
+++ b/examples/myhtml/callback_tree_node_high_level.c
@@ -23,6 +23,8 @@
#include <myhtml/api.h>
+#include "example.h"
+
struct res_html {
char *html;
size_t size;
@@ -61,7 +63,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -115,7 +117,7 @@ int main(int argc, const char * argv[])
myhtml_callback_tree_node_remove_set(tree, callback_node_remove, NULL);
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, res.html, res.size);
+ myhtml_parse(tree, MyENCODING_UTF_8, res.html, res.size);
// release resources
myhtml_tree_destroy(tree);
diff --git a/examples/myhtml/chunks_high_level.c b/examples/myhtml/chunks_high_level.c
index 6a952e5..6be8295 100644
--- a/examples/myhtml/chunks_high_level.c
+++ b/examples/myhtml/chunks_high_level.c
@@ -21,8 +21,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
#include <myhtml/api.h>
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
+{
+ printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
+}
+
int main(int argc, const char * argv[])
{
char html[][64] = {
@@ -53,7 +60,7 @@ int main(int argc, const char * argv[])
myhtml_tree_t* tree = myhtml_tree_create();
myhtml_tree_init(tree, myhtml);
- myhtml_encoding_set(tree, MyHTML_ENCODING_UTF_8);
+ myhtml_encoding_set(tree, MyENCODING_UTF_8);
for(size_t i = 0; html[i][0]; i++)
{
@@ -67,7 +74,7 @@ int main(int argc, const char * argv[])
myhtml_parse_chunk_end(tree);
// print fragment
- myhtml_tree_print_node_children(tree, myhtml_tree_get_document(tree), stdout, 0);
+ myhtml_serialization_tree_callback(myhtml_tree_get_document(tree), serialization_callback, NULL);
// release resources
myhtml_tree_destroy(tree);
diff --git a/examples/myhtml/custom_tree_high_level.c b/examples/myhtml/custom_tree_high_level.c
index a457215..1a42ecc 100644
--- a/examples/myhtml/custom_tree_high_level.c
+++ b/examples/myhtml/custom_tree_high_level.c
@@ -24,6 +24,14 @@
#include <myhtml/api.h>
+#include "example.h"
+
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
+{
+ printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
+}
+
int main(int argc, const char * argv[])
{
// basic init
@@ -36,7 +44,7 @@ int main(int argc, const char * argv[])
myhtml_tree_t* tree = myhtml_tree_create();
myhtml_tree_init(tree, myhtml);
- myhtml_encoding_set(tree, MyHTML_ENCODING_UTF_8);
+ myhtml_encoding_set(tree, MyENCODING_UTF_8);
// create nodes
printf("Create DIV element\n");
@@ -55,19 +63,19 @@ int main(int argc, const char * argv[])
myhtml_tree_node_t* new_text_node = myhtml_node_create(tree, MyHTML_TAG__TEXT, MyHTML_NAMESPACE_HTML);
myhtml_node_append_child(new_p_node, new_text_node);
- sprintf(tmp_buf_key, "best_key_for_%zu", i);
- sprintf(tmp_buf_value, "for best value %zu", i);
- sprintf(tmp_buf_text, "Text! Entity &#x26;#%zu = &#%zu", i, i);
+ sprintf(tmp_buf_key, "best_key_for_" MyCORE_FMT_Z, i);
+ sprintf(tmp_buf_value, "for best value " MyCORE_FMT_Z, i);
+ sprintf(tmp_buf_text, "Text! Entity &#x26;#" MyCORE_FMT_Z " = &#" MyCORE_FMT_Z, i, i);
- myhtml_node_text_set_with_charef(new_text_node, tmp_buf_text, strlen(tmp_buf_text), MyHTML_ENCODING_UTF_8);
+ myhtml_node_text_set_with_charef(new_text_node, tmp_buf_text, strlen(tmp_buf_text), MyENCODING_UTF_8);
myhtml_attribute_add(new_p_node, tmp_buf_key, strlen(tmp_buf_key),
- tmp_buf_value, strlen(tmp_buf_value), MyHTML_ENCODING_UTF_8);
+ tmp_buf_value, strlen(tmp_buf_value), MyENCODING_UTF_8);
}
// print
printf("Print result:\n");
- myhtml_tree_print_node_children(tree, myhtml_tree_get_document(tree), stdout, 0);
+ myhtml_serialization_tree_callback(myhtml_tree_get_document(tree), serialization_callback, NULL);
// release resources
myhtml_tree_destroy(tree);
diff --git a/examples/myhtml/example.h b/examples/myhtml/example.h
new file mode 100644
index 0000000..27f7ec8
--- /dev/null
+++ b/examples/myhtml/example.h
@@ -0,0 +1,32 @@
+/*
+ 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: vincent.torri@gmail.com (Vincent Torri)
+*/
+
+#ifndef MyHTML_EXAMPLE_EXAMPLE_H
+#define MyHTML_EXAMPLE_EXAMPLE_H
+#pragma once
+
+/* Format */
+#ifdef _WIN32
+ #define MyCORE_FMT_Z "%Iu"
+#else
+ #define MyCORE_FMT_Z "%zu"
+#endif
+
+#endif /* MyHTML_EXAMPLE_EXAMPLE_H */
diff --git a/examples/myhtml/fragment_high_level.c b/examples/myhtml/fragment_high_level.c
index 8c032f0..4c8b084 100644
--- a/examples/myhtml/fragment_high_level.c
+++ b/examples/myhtml/fragment_high_level.c
@@ -23,6 +23,11 @@
#include <string.h>
#include <myhtml/api.h>
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
+{
+ printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
+}
int main(int argc, const char * argv[])
{
@@ -37,10 +42,10 @@ int main(int argc, const char * argv[])
myhtml_tree_init(tree, myhtml);
// parse html
- myhtml_parse_fragment(tree, MyHTML_ENCODING_UTF_8, html, strlen(html), MyHTML_TAG_DIV, MyHTML_NAMESPACE_HTML);
+ myhtml_parse_fragment(tree, MyENCODING_UTF_8, html, strlen(html), MyHTML_TAG_DIV, MyHTML_NAMESPACE_HTML);
// print fragment
- myhtml_tree_print_node_children(tree, myhtml_tree_get_document(tree), stdout, 0);
+ myhtml_serialization_tree_callback(myhtml_tree_get_document(tree), serialization_callback, NULL);
// release resources
myhtml_tree_destroy(tree);
diff --git a/examples/myhtml/get_title_high_level.c b/examples/myhtml/get_title_high_level.c
index a05fdd0..cf07340 100644
--- a/examples/myhtml/get_title_high_level.c
+++ b/examples/myhtml/get_title_high_level.c
@@ -22,6 +22,8 @@
#include <stdlib.h>
#include <myhtml/api.h>
+#include "example.h"
+
struct res_html {
char *html;
size_t size;
@@ -60,7 +62,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -93,7 +95,7 @@ int main(int argc, const char * argv[])
myhtml_tree_init(tree, myhtml);
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, res.html, res.size);
+ myhtml_parse(tree, MyENCODING_UTF_8, res.html, res.size);
// parse html
myhtml_collection_t *collection = myhtml_get_nodes_by_tag_id(tree, NULL, MyHTML_TAG_TITLE, NULL);
diff --git a/examples/myhtml/get_title_low_level.c b/examples/myhtml/get_title_low_level.c
index 9c918d2..996911c 100644
--- a/examples/myhtml/get_title_low_level.c
+++ b/examples/myhtml/get_title_low_level.c
@@ -23,6 +23,8 @@
#include <myhtml/myhtml.h>
#include <myhtml/serialization.h>
+#include "example.h"
+
struct res_html {
char *html;
size_t size;
@@ -61,7 +63,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -94,18 +96,18 @@ int main(int argc, const char * argv[])
myhtml_tree_init(tree, myhtml);
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, res.html, res.size);
+ myhtml_parse(tree, MyENCODING_UTF_8, res.html, res.size);
// get title from index
myhtml_collection_t *titles_list = myhtml_get_nodes_by_tag_id(tree, NULL, MyHTML_TAG_TITLE, NULL);
if(titles_list && titles_list->length != 0 && titles_list->list[0]->child) {
- myhtml_string_raw_t str = {0};
+ mycore_string_raw_t str = {0};
myhtml_serialization_node(titles_list->list[0]->child, &str);
printf("%s\n", str.data);
- myhtml_string_raw_destroy(&str, false);
+ mycore_string_raw_destroy(&str, false);
}
// release resources
diff --git a/examples/myhtml/html2sexpr.c b/examples/myhtml/html2sexpr.c
index 92669ad..7570381 100644
--- a/examples/myhtml/html2sexpr.c
+++ b/examples/myhtml/html2sexpr.c
@@ -28,6 +28,8 @@
#include <myhtml/api.h>
+#include "example.h"
+
#define DIE(msg, ...) do { fprintf(stderr, msg, ##__VA_ARGS__); exit(EXIT_FAILURE); } while(0)
static bool filter_node(myhtml_tree_node_t* node)
@@ -117,7 +119,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- DIE("could not read %ld bytes (%zu bytes done)\n", size, nread);
+ DIE("could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
}
fclose(fh);
@@ -139,7 +141,7 @@ int main(int argc, char** argv)
}
struct res_html data = load_html_file(argv[1]);
- myhtml_status_t res;
+ mystatus_t res;
// basic init
myhtml_t* myhtml = myhtml_create();
@@ -164,7 +166,7 @@ int main(int argc, char** argv)
}
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, data.html, data.size);
+ myhtml_parse(tree, MyENCODING_UTF_8, data.html, data.size);
walk_subtree(tree, myhtml_tree_get_node_html(tree), 0);
printf("\n");
diff --git a/examples/myhtml/insert_in_appropriate_place_high_level.c b/examples/myhtml/insert_in_appropriate_place_high_level.c
index 68a7b4b..ef11f5d 100644
--- a/examples/myhtml/insert_in_appropriate_place_high_level.c
+++ b/examples/myhtml/insert_in_appropriate_place_high_level.c
@@ -23,6 +23,11 @@
#include <string.h>
#include <myhtml/api.h>
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
+{
+ printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
+}
int main(int argc, const char * argv[])
{
@@ -37,7 +42,7 @@ int main(int argc, const char * argv[])
myhtml_tree_init(tree, myhtml);
// parse html
- myhtml_parse_fragment(tree, MyHTML_ENCODING_UTF_8, html, strlen(html), MyHTML_TAG_DIV, MyHTML_NAMESPACE_HTML);
+ myhtml_parse_fragment(tree, MyENCODING_UTF_8, html, strlen(html), MyHTML_TAG_DIV, MyHTML_NAMESPACE_HTML);
// get text node by index
myhtml_collection_t *collection = myhtml_get_nodes_by_tag_id(tree, NULL, MyHTML_TAG_TABLE, NULL);
@@ -51,7 +56,7 @@ int main(int argc, const char * argv[])
}
// print fragment
- myhtml_tree_print_node_children(tree, myhtml_tree_get_document(tree), stdout, 0);
+ myhtml_serialization_tree_callback(myhtml_tree_get_document(tree), serialization_callback, NULL);
// release resources
myhtml_collection_destroy(collection);
diff --git a/examples/myhtml/modify_and_serialize.c b/examples/myhtml/modify_and_serialize.c
index f434095..cbd3a83 100644
--- a/examples/myhtml/modify_and_serialize.c
+++ b/examples/myhtml/modify_and_serialize.c
@@ -22,9 +22,10 @@
* @param size
* @param ptr
*/
-void write_output(const char *buffer, size_t size, void *ptr)
+mystatus_t write_output(const char* data, size_t len, void* ctx)
{
- fwrite(buffer, 1, size, stdout);
+ printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
}
/**
@@ -45,7 +46,7 @@ int main()
const char *input = "<html><head></head><body><a href=http://nu.nl></body></html>";
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, input, strlen(input));
+ myhtml_parse(tree, MyENCODING_UTF_8, input, strlen(input));
// collection of links
myhtml_collection_t *collection = myhtml_get_nodes_by_name(tree, NULL, "a", 1, NULL);
@@ -54,7 +55,7 @@ int main()
for (size_t i = 0; i < collection->length; ++i)
{
// add attribute
- myhtml_attribute_add(collection->list[i], "title", 5, "my value", 8, MyHTML_ENCODING_UTF_8);
+ myhtml_attribute_add(collection->list[i], "title", 5, "my value", 8, MyENCODING_UTF_8);
}
diff --git a/examples/myhtml/nodes_by_attr_key_high_level.c b/examples/myhtml/nodes_by_attr_key_high_level.c
index 7787031..0521f46 100644
--- a/examples/myhtml/nodes_by_attr_key_high_level.c
+++ b/examples/myhtml/nodes_by_attr_key_high_level.c
@@ -24,6 +24,8 @@
#include <myhtml/api.h>
+#include "example.h"
+
struct res_html {
char *html;
size_t size;
@@ -62,7 +64,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -72,6 +74,12 @@ struct res_html load_html_file(const char* filename)
return res;
}
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
+{
+ printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
+}
+
int main(int argc, const char * argv[])
{
const char* path;
@@ -97,15 +105,15 @@ int main(int argc, const char * argv[])
myhtml_tree_init(tree, myhtml);
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, res.html, res.size);
+ myhtml_parse(tree, MyENCODING_UTF_8, res.html, res.size);
// get and print
myhtml_collection_t *collection = myhtml_get_nodes_by_attribute_key(tree, NULL, NULL, attr_key, strlen(attr_key), NULL);
for(size_t i = 0; i < collection->length; i++)
- myhtml_tree_print_node(tree, collection->list[i], stdout);
+ myhtml_serialization_node_callback(collection->list[i], serialization_callback, NULL);
- printf("Total found: %zu\n", collection->length);
+ printf("Total found: " MyCORE_FMT_Z "\n", collection->length);
myhtml_collection_destroy(collection);
diff --git a/examples/myhtml/nodes_by_attr_value_high_level.c b/examples/myhtml/nodes_by_attr_value_high_level.c
index 587252f..a113973 100644
--- a/examples/myhtml/nodes_by_attr_value_high_level.c
+++ b/examples/myhtml/nodes_by_attr_value_high_level.c
@@ -26,6 +26,8 @@
#include <myhtml/api.h>
+#include "example.h"
+
struct res_html {
char *html;
size_t size;
@@ -73,7 +75,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -155,6 +157,12 @@ struct res_argv get_argv(int len, int argc, const char ** argv)
return rargv;
}
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
+{
+ printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
+}
+
int main(int argc, const char * argv[])
{
const char* path;
@@ -184,7 +192,7 @@ int main(int argc, const char * argv[])
myhtml_tree_init(tree, myhtml);
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, res.html, res.size);
+ myhtml_parse(tree, MyENCODING_UTF_8, res.html, res.size);
// get and print
myhtml_collection_t* collection = NULL;
@@ -228,9 +236,9 @@ int main(int argc, const char * argv[])
if(collection) {
for(size_t i = 0; i < collection->length; i++)
- myhtml_tree_print_node(tree, collection->list[i], stdout);
+ myhtml_serialization_node_callback(collection->list[i], serialization_callback, NULL);
- printf("Total found: %zu\n", collection->length);
+ printf("Total found: " MyCORE_FMT_Z "\n", collection->length);
}
myhtml_collection_destroy(collection);
diff --git a/examples/myhtml/parse_without_whitespace.c b/examples/myhtml/parse_without_whitespace.c
index 3eab61d..f5455c9 100644
--- a/examples/myhtml/parse_without_whitespace.c
+++ b/examples/myhtml/parse_without_whitespace.c
@@ -23,6 +23,8 @@
#include <myhtml/api.h>
+#include "example.h"
+
struct res_html {
char *html;
size_t size;
@@ -61,7 +63,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -71,6 +73,12 @@ struct res_html load_html_file(const char* filename)
return res;
}
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
+{
+ printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
+}
+
int main(int argc, const char * argv[])
{
const char* path;
@@ -99,10 +107,10 @@ int main(int argc, const char * argv[])
MyHTML_TREE_PARSE_FLAGS_WITHOUT_DOCTYPE_IN_TREE);
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, res.html, res.size);
+ myhtml_parse(tree, MyENCODING_UTF_8, res.html, res.size);
if(myhtml_tree_get_node_html(tree))
- myhtml_tree_print_by_node(tree, myhtml_tree_get_node_html(tree), stdout, 0);
+ myhtml_serialization_tree_callback(myhtml_tree_get_node_html(tree), serialization_callback, NULL);
// release resources
myhtml_tree_destroy(tree);
diff --git a/examples/myhtml/print_tree_high_level.c b/examples/myhtml/print_tree_high_level.c
index fbdba87..eecd7d6 100644
--- a/examples/myhtml/print_tree_high_level.c
+++ b/examples/myhtml/print_tree_high_level.c
@@ -22,6 +22,8 @@
#include <stdlib.h>
#include <myhtml/api.h>
+#include "example.h"
+
struct res_html {
char *html;
size_t size;
@@ -60,7 +62,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -151,7 +153,7 @@ int main(int argc, const char * argv[])
myhtml_tree_init(tree, myhtml);
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, res.html, res.size);
+ myhtml_parse(tree, MyENCODING_UTF_8, res.html, res.size);
// print tree
myhtml_tree_node_t *node = myhtml_tree_get_document(tree);
diff --git a/examples/myhtml/serialization_high_level.c b/examples/myhtml/serialization_high_level.c
index c4cc70e..62a1265 100644
--- a/examples/myhtml/serialization_high_level.c
+++ b/examples/myhtml/serialization_high_level.c
@@ -22,6 +22,8 @@
#include <stdlib.h>
#include <myhtml/api.h>
+#include "example.h"
+
struct res_html {
char *html;
size_t size;
@@ -60,7 +62,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -93,10 +95,10 @@ int main(int argc, const char * argv[])
myhtml_tree_init(tree, myhtml);
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, res.html, res.size);
+ myhtml_parse(tree, MyENCODING_UTF_8, res.html, res.size);
- myhtml_string_raw_t str_raw;
- myhtml_string_raw_clean_all(&str_raw);
+ mycore_string_raw_t str_raw;
+ mycore_string_raw_clean_all(&str_raw);
if(myhtml_serialization_tree_buffer(myhtml_tree_get_document(tree), &str_raw)) {
/*
@@ -105,7 +107,7 @@ int main(int argc, const char * argv[])
*/
printf("%s", str_raw.data);
- myhtml_string_raw_destroy(&str_raw, false);
+ mycore_string_raw_destroy(&str_raw, false);
}
// release resources
diff --git a/examples/myhtml/string_manipulate_high_level.c b/examples/myhtml/string_manipulate_high_level.c
index 5e515ee..ca6d74b 100644
--- a/examples/myhtml/string_manipulate_high_level.c
+++ b/examples/myhtml/string_manipulate_high_level.c
@@ -23,6 +23,11 @@
#include <string.h>
#include <myhtml/api.h>
+mystatus_t serialization_callback(const char* data, size_t len, void* ctx)
+{
+ printf("%.*s", (int)len, data);
+ return MyCORE_STATUS_OK;
+}
int main(int argc, const char * argv[])
{
@@ -37,11 +42,11 @@ int main(int argc, const char * argv[])
myhtml_tree_init(tree, myhtml);
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, html, strlen(html));
+ myhtml_parse(tree, MyENCODING_UTF_8, html, strlen(html));
// print original tree
printf("Original Tree:\n");
- myhtml_tree_print_node_children(tree, myhtml_tree_get_document(tree), stdout, 0);
+ myhtml_serialization_tree_callback(myhtml_tree_get_node_html(tree), serialization_callback, NULL);
printf("Change word: manipulate => test\n");
@@ -51,18 +56,18 @@ int main(int argc, const char * argv[])
if(collection && collection->list && collection->length)
{
myhtml_tree_node_t *text_node = collection->list[0];
- myhtml_string_t *str = myhtml_node_string(text_node);
+ mycore_string_t *str = myhtml_node_string(text_node);
// change data
- char *data = myhtml_string_data(str);
+ char *data = mycore_string_data(str);
- for (size_t i = 0; i < myhtml_string_length(str); i++)
+ for (size_t i = 0; i < mycore_string_length(str); i++)
{
if(data[i] == 'm') {
sprintf(&data[i], "test");
// set new length
- myhtml_string_length_set(str, (i + 4));
+ mycore_string_length_set(str, (i + 4));
break;
}
}
@@ -70,7 +75,7 @@ int main(int argc, const char * argv[])
printf("Changed Tree:\n");
// print tree
- myhtml_tree_print_node_children(tree, myhtml_tree_get_document(tree), stdout, 0);
+ myhtml_serialization_tree_callback(myhtml_tree_get_node_html(tree), serialization_callback, NULL);
// release resources
myhtml_tree_destroy(tree);
diff --git a/examples/myhtml/tokenizer_colorize_high_level.c b/examples/myhtml/tokenizer_colorize_high_level.c
index 8149d1b..05ee28f 100644
--- a/examples/myhtml/tokenizer_colorize_high_level.c
+++ b/examples/myhtml/tokenizer_colorize_high_level.c
@@ -23,6 +23,8 @@
#include <myhtml/api.h>
+#include "example.h"
+
struct res_html {
char *html;
size_t size;
@@ -61,7 +63,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -71,19 +73,19 @@ struct res_html load_html_file(const char* filename)
return res;
}
-void colorize_print(myhtml_incoming_buffer_t *inc_buf, size_t begin, size_t length, const char* color)
+void colorize_print(mycore_incoming_buffer_t *inc_buf, size_t begin, size_t length, const char* color)
{
if(length) {
- inc_buf = myhtml_incoming_buffer_find_by_position(inc_buf, begin);
+ inc_buf = mycore_incoming_buffer_find_by_position(inc_buf, begin);
- size_t between_begin = (begin - myhtml_incoming_buffer_offset(inc_buf));
- const char* between_data = myhtml_incoming_buffer_data(inc_buf);
+ size_t between_begin = (begin - mycore_incoming_buffer_offset(inc_buf));
+ const char* between_data = mycore_incoming_buffer_data(inc_buf);
printf("%s%.*s\e[0m", color, (int)length, &between_data[between_begin]);
}
}
-size_t colorize_print_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* attr, myhtml_incoming_buffer_t *inc_buf, size_t last_pos)
+size_t colorize_print_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* attr, mycore_incoming_buffer_t *inc_buf, size_t last_pos)
{
while(attr)
{
@@ -133,7 +135,7 @@ size_t colorize_print_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* attr,
void * colorize_callback_before_token_done(myhtml_tree_t* tree, myhtml_token_node_t* token, void* ctx)
{
- myhtml_incoming_buffer_t *inc_buf = myhtml_tree_incoming_buffer_first(tree);
+ mycore_incoming_buffer_t *inc_buf = myhtml_tree_incoming_buffer_first(tree);
myhtml_position_t token_pos = myhtml_token_node_raw_pasition(token);
myhtml_position_t token_element_pos = myhtml_token_node_element_pasition(token);
@@ -210,7 +212,7 @@ int main(int argc, const char * argv[])
myhtml_callback_before_token_done_set(tree, colorize_callback_before_token_done, NULL);
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, res.html, res.size);
+ myhtml_parse(tree, MyENCODING_UTF_8, res.html, res.size);
printf("\n");
diff --git a/examples/myhtml/tokenizer_colorize_low_level.c b/examples/myhtml/tokenizer_colorize_low_level.c
index e59cb19..f14fba7 100644
--- a/examples/myhtml/tokenizer_colorize_low_level.c
+++ b/examples/myhtml/tokenizer_colorize_low_level.c
@@ -23,6 +23,8 @@
#include <myhtml/myhtml.h>
+#include "example.h"
+
struct res_html {
char *html;
size_t size;
@@ -61,7 +63,7 @@ struct res_html load_html_file(const char* filename)
size_t nread = fread(html, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -71,15 +73,15 @@ struct res_html load_html_file(const char* filename)
return res;
}
-void colorize_print(myhtml_incoming_buffer_t *inc_buf, size_t begin, size_t length, const char* color)
+void colorize_print(mycore_incoming_buffer_t *inc_buf, size_t begin, size_t length, const char* color)
{
if(length) {
- inc_buf = myhtml_incoming_buffer_find_by_position(inc_buf, begin);
+ inc_buf = mycore_incoming_buffer_find_by_position(inc_buf, begin);
printf("%s%.*s\e[0m", color, (int)length, &inc_buf->data[(begin - inc_buf->offset)]);
}
}
-size_t colorize_print_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* attr, myhtml_incoming_buffer_t *inc_buf, size_t last_pos)
+size_t colorize_print_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* attr, mycore_incoming_buffer_t *inc_buf, size_t last_pos)
{
while(attr) {
if(attr->raw_key_length)
@@ -125,7 +127,7 @@ size_t colorize_print_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* attr,
void * colorize_callback_before_token_done(myhtml_tree_t* tree, myhtml_token_node_t* token, void* ctx)
{
- myhtml_incoming_buffer_t *inc_buf = tree->incoming_buf_first;
+ mycore_incoming_buffer_t *inc_buf = tree->incoming_buf_first;
size_t last_pos = token->raw_begin + token->raw_length;
@@ -200,7 +202,7 @@ int main(int argc, const char * argv[])
myhtml_callback_before_token_done_set(tree, colorize_callback_before_token_done, NULL);
// parse html
- myhtml_parse(tree, MyHTML_ENCODING_UTF_8, res.html, res.size);
+ myhtml_parse(tree, MyENCODING_UTF_8, res.html, res.size);
printf("\n");
diff --git a/examples/myurl/Makefile.mk b/examples/myurl/Makefile.mk
new file mode 100644
index 0000000..56ffcca
--- /dev/null
+++ b/examples/myurl/Makefile.mk
@@ -0,0 +1,7 @@
+myurl_dirs := .
+myurl_objs := $(call BINARY_UTILS_OBJS,myurl,$(myurl_dirs))
+
+myurl_all: $(myurl_objs)
+
+myurl_clean:
+ rm -f $(myurl_objs)
diff --git a/examples/myurl/url_data.c b/examples/myurl/url_data.c
new file mode 100644
index 0000000..f6f6c2f
--- /dev/null
+++ b/examples/myurl/url_data.c
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 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 <string.h>
+#include <myurl/url.h>
+
+int main(int argc, const char * argv[])
+{
+ const char* data_base = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAYAAAAmL5yKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGlSURBVDhPnZDfS1NhGMfff8oLEUE0FBfqmrigi/DKrvKqiNDEKYjCUJdH3I/Q5WoLdYmlU1FP0LQoEclYOCcoMbJuDAUVA/v0vK8/QssL98AH3u97zud7Ho4ajr8i2P8sJ2JDcVSwf5BcR7sqEHpqQpF/60ro0e5Zwb1FiPyAoW14tAIVE5fjGDPKaUHYhOQhTO1DYu+Y/4mn/C0Io3oDAyasCYtHsPALRmUL5+R56j9AdwbsA4jJpnq0q6y+JyboO11ibUBt8jxpuV8VPgn6I5M7cpDRrhSETKiXf3BXuPP+X8Zlo3V5JyUs/4aZXaNIQQj12AqY0CBPL9KW+kIwbWF/b2MqW8d09iZzW27mf0aNo13lOynwpPZpTHpotstpfVOK9105oeUKnqeqiK06iWduMLbhIvG1Gvub2zjaVV09fhPqRgq5nyimYaaEptlrtCfL6Fu6TvhzJREpeZF28nLdxevNamazNcbRrvJ2WiY4/Hm4w/ncihRwO1pwVqjLWuxS2t+W0SVbWR8dDK5UGke7qsPrMyGX0a7y9fSaQy48eNjIH2VPyHZqSIx2AAAAAElFTkSuQmCC";
+
+ myurl_t *url = myurl_create();
+ if(url == NULL) {
+ printf("Can't create URL object\n");
+ return EXIT_FAILURE;
+ }
+
+ if(myurl_init(url)) {
+ printf("Can't init URL object\n");
+ return EXIT_FAILURE;
+ }
+
+ printf("Parse URL: %s\n\n", data_base);
+
+ myurl_entry_t *url_base = myurl_parse(url, data_base, strlen(data_base), NULL, NULL);
+ char *path = myurl_entry_path_as_string(url_base, NULL);
+
+ printf("Result data from URL: %s\n", path);
+
+ myurl_entry_free_string(url_base, path);
+ myurl_entry_destroy(url_base, true);
+ myurl_destroy(url, true);
+
+ return EXIT_SUCCESS;
+}
diff --git a/examples/myurl/url_parse.c b/examples/myurl/url_parse.c
new file mode 100644
index 0000000..b59df93
--- /dev/null
+++ b/examples/myurl/url_parse.c
@@ -0,0 +1,72 @@
+/*
+ Copyright (C) 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 <string.h>
+#include <myurl/url.h>
+
+int main(int argc, const char * argv[])
+{
+ const char* data_base = "https://lastmac:12345@www.emaple.com:4433/programming/?id=777888999#somehash";
+
+ myurl_t *url = myurl_create();
+ if(url == NULL) {
+ printf("Can't create URL object\n");
+ return EXIT_FAILURE;
+ }
+
+ if(myurl_init(url)) {
+ printf("Can't init URL object\n");
+ return EXIT_FAILURE;
+ }
+
+ printf("Parse url \"%s\":\n", data_base);
+
+ myurl_entry_t *url_base = myurl_parse(url, data_base, strlen(data_base), NULL, NULL);
+
+ const char *scheme = myurl_entry_scheme_name(url_base, NULL);
+ char *authority = myurl_entry_authority_as_string(url_base, NULL);
+ const char *username = myurl_entry_username(url_base, NULL);
+ const char *password = myurl_entry_password(url_base, NULL);
+ char *host = myurl_entry_host_as_string(url_base, NULL);
+ char *path = myurl_entry_path_as_string(url_base, NULL);
+ const char *query = myurl_entry_query(url_base, NULL);
+ const char *fragment = myurl_entry_fragment(url_base, NULL);
+
+ printf("\tScheme: %s\n" , (scheme ? scheme : ""));
+ printf("\tScheme port: %u\n" , myurl_entry_scheme_port(url_base));
+ printf("\tAuthority (%s):\n" , authority);
+ printf("\t\tUsername: %s\n" , username);
+ printf("\t\tPassword: %s\n" , password);
+ printf("\tHost: %s\n" , host);
+ printf("\tPort is defined: %s\n", (myurl_entry_port_is_defined(url_base) ? "true" : "false"));
+ printf("\tPort: %u\n" , myurl_entry_port(url_base));
+ printf("\tPath: %s\n" , path);
+ printf("\tQuery: %s\n" , (query ? query : ""));
+ printf("\tFragment: %s\n" , (fragment ? fragment : ""));
+
+ myurl_entry_free_string(url_base, authority);
+ myurl_entry_free_string(url_base, host);
+ myurl_entry_free_string(url_base, path);
+
+ myurl_entry_destroy(url_base, true);
+ myurl_destroy(url, true);
+
+ return 0;
+}
diff --git a/examples/myurl/url_relative.c b/examples/myurl/url_relative.c
new file mode 100644
index 0000000..8a0b801
--- /dev/null
+++ b/examples/myurl/url_relative.c
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 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 <string.h>
+#include <myurl/url.h>
+
+int main(int argc, const char * argv[])
+{
+ const char* data_base = "https://www.reddit.com/r/programming/";
+ const char* data_relative = "../gaming/?count=25";
+
+ myurl_t *url = myurl_create();
+ if(url == NULL) {
+ printf("Can't create URL object\n");
+ return EXIT_FAILURE;
+ }
+
+ if(myurl_init(url)) {
+ printf("Can't init URL object\n");
+ return EXIT_FAILURE;
+ }
+
+ myurl_entry_t *url_base = myurl_parse(url, data_base, strlen(data_base), NULL, NULL);
+ myurl_entry_t *url_relative = myurl_parse(url, data_relative, strlen(data_relative), url_base, NULL);
+
+ char *result = myurl_entry_as_string(url_relative, NULL);
+
+ printf("Relative URL: %s\n", data_relative);
+ printf("Base URL: %s\n", data_base);
+ printf("Result URL: %s\n", result);
+
+ myurl_entry_free_string(url_base, result);
+
+ myurl_entry_destroy(url_base, true);
+ myurl_entry_destroy(url_relative, true);
+ myurl_destroy(url, true);
+
+ return EXIT_SUCCESS;
+}
diff --git a/include/modest/declaration.h b/include/modest/declaration.h
index 7c19334..f0c5837 100644
--- a/include/modest/declaration.h
+++ b/include/modest/declaration.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/finder/finder.h b/include/modest/finder/finder.h
index ff9da35..b002e14 100644
--- a/include/modest/finder/finder.h
+++ b/include/modest/finder/finder.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -38,7 +38,7 @@ typedef myhtml_tree_node_t * (*modest_finder_selector_combinator_f)(modest_finde
/* init */
modest_finder_t * modest_finder_create(void);
-modest_status_t modest_finder_init(modest_finder_t* finder);
+mystatus_t modest_finder_init(modest_finder_t* finder);
void modest_finder_clean(modest_finder_t* finder);
modest_finder_t * modest_finder_destroy(modest_finder_t* finder, bool self_destroy);
@@ -59,7 +59,7 @@ void modest_finder_specificity_inc(mycss_selectors_entry_t* selector, mycss_sele
/* base api */
modest_finder_t * modest_finder_by_stylesheet(mycss_stylesheet_t *stylesheet, myhtml_collection_t** collection, myhtml_tree_node_t* base_node);
-modest_status_t modest_finder_by_selectors_list(modest_finder_t* finder, myhtml_tree_node_t* scope_node,
+mystatus_t modest_finder_by_selectors_list(modest_finder_t* finder, myhtml_tree_node_t* scope_node,
mycss_selectors_list_t* selector_list, myhtml_collection_t** collection);
/* process */
diff --git a/include/modest/finder/match.h b/include/modest/finder/match.h
index 568f8af..629459d 100644
--- a/include/modest/finder/match.h
+++ b/include/modest/finder/match.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/finder/myosi.h b/include/modest/finder/myosi.h
index 7dea0fe..63b91d9 100644
--- a/include/modest/finder/myosi.h
+++ b/include/modest/finder/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/finder/pseudo_class.h b/include/modest/finder/pseudo_class.h
index 05fd578..f9425ed 100644
--- a/include/modest/finder/pseudo_class.h
+++ b/include/modest/finder/pseudo_class.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/finder/resource.h b/include/modest/finder/resource.h
index 839914a..0d312ba 100644
--- a/include/modest/finder/resource.h
+++ b/include/modest/finder/resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/finder/thread.h b/include/modest/finder/thread.h
index 7c5ac44..de0bac6 100644
--- a/include/modest/finder/thread.h
+++ b/include/modest/finder/thread.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -29,8 +29,8 @@
#include <modest/finder/myosi.h>
#include <modest/finder/finder.h>
-#include <myhtml/thread.h>
-#include <myhtml/utils/mcobject_async.h>
+#include <mycore/mythread.h>
+#include <mycore/utils/mcobject_async.h>
#include <mycss/declaration/myosi.h>
@@ -85,13 +85,16 @@ struct modest_finder_thread_found_context {
modest_finder_thread_t * modest_finder_thread_create(void);
-modest_status_t modest_finder_thread_init(modest_finder_t* finder, modest_finder_thread_t* finder_thread, size_t thread_count);
+mystatus_t modest_finder_thread_init(modest_finder_t* finder, modest_finder_thread_t* finder_thread, size_t thread_count);
void modest_finder_thread_clean(modest_finder_thread_t* finder_thread, bool self_destroy);
modest_finder_thread_t * modest_finder_thread_destroy(modest_finder_thread_t* finder_thread, bool self_destroy);
-modest_status_t modest_finder_thread_process(modest_t* modest, modest_finder_thread_t* finder_thread, myhtml_tree_node_t* scope_node, mycss_selectors_list_t* selector_list);
+mystatus_t modest_finder_thread_process(modest_t* modest, modest_finder_thread_t* finder_thread, myhtml_tree_node_t* scope_node, mycss_selectors_list_t* selector_list);
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
void modest_finder_thread_wait_for_all_done(modest_finder_thread_t* finder_thread);
+#endif
+
bool modest_finder_thread_spec_is_up(modest_style_raw_specificity_t* spec_f, modest_style_raw_specificity_t* spec_t);
#ifdef __cplusplus
diff --git a/include/modest/finder/type.h b/include/modest/finder/type.h
index 3497852..72cc1ef 100644
--- a/include/modest/finder/type.h
+++ b/include/modest/finder/type.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -27,7 +27,7 @@
#include <modest/finder/pseudo_class.h>
#include <modest/finder/match.h>
#include <myhtml/tree.h>
-#include <myhtml/utils.h>
+#include <mycore/utils.h>
#include <mycss/selectors/value.h>
#ifdef __cplusplus
diff --git a/include/modest/glue.h b/include/modest/glue.h
index d8b53f3..39c2372 100644
--- a/include/modest/glue.h
+++ b/include/modest/glue.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/layer/layer.h b/include/modest/layer/layer.h
index 4843bc5..e57a348 100644
--- a/include/modest/layer/layer.h
+++ b/include/modest/layer/layer.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -23,7 +23,7 @@
#pragma once
#include <modest/myosi.h>
-#include <myhtml/utils/mcobject.h>
+#include <mycore/utils/mcobject.h>
#ifdef __cplusplus
extern "C" {
@@ -47,7 +47,7 @@ struct modest_layout {
};
modest_layout_t * modest_layers_create(void);
-modest_status_t modest_layers_init(modest_layout_t* layout);
+mystatus_t modest_layers_init(modest_layout_t* layout);
void modest_layers_clean_all(modest_layout_t* layout);
modest_layout_t * modest_layers_destroy(modest_layout_t* layout, bool self_destroy);
diff --git a/include/modest/modest.h b/include/modest/modest.h
index bedd93d..ff7fb0d 100644
--- a/include/modest/modest.h
+++ b/include/modest/modest.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -24,10 +24,10 @@
#include <modest/myosi.h>
#include <modest/layer/layer.h>
-#include <myhtml/utils/mcobject.h>
-#include <myhtml/utils/mcobject_async.h>
-#include <myhtml/utils/mchar_async.h>
-#include <myhtml/utils/avl_tree.h>
+#include <mycore/utils/mcobject.h>
+#include <mycore/utils/mcobject_async.h>
+#include <mycore/utils/mchar_async.h>
+#include <mycore/utils/avl_tree.h>
#ifdef __cplusplus
extern "C" {
@@ -47,7 +47,7 @@ struct modest {
modest_layout_t* layout;
- myhtml_utils_avl_tree_t* style_avl_tree;
+ mycore_utils_avl_tree_t* style_avl_tree;
/* refs */
myhtml_tree_t* myhtml_tree;
@@ -56,7 +56,7 @@ struct modest {
modest_t * modest_create(void);
-modest_status_t modest_init(modest_t* modest);
+mystatus_t modest_init(modest_t* modest);
void modest_clean(modest_t* modest);
modest_t * modest_destroy(modest_t* modest, bool self_destroy);
diff --git a/include/modest/myosi.h b/include/modest/myosi.h
index e53d718..10f8a8c 100644
--- a/include/modest/myosi.h
+++ b/include/modest/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -22,9 +22,16 @@
#define MODEST_MYOSI_H
#pragma once
+#include <mycore/myosi.h>
#include <myhtml/myhtml.h>
#include <mycss/mycss.h>
+#define MODEST_VERSION_MAJOR 0
+#define MODEST_VERSION_MINOR 0
+#define MODEST_VERSION_PATCH 6
+
+#define MODEST_VERSION_STRING MyCORE_STR(MODEST_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MODEST_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MODEST_VERSION_PATCH)
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -36,12 +43,14 @@ extern "C" {
for myhtml 0..00ffff; MyHTML_STATUS_OK == 0x000000
for mycss and modules 010000..01ffff; MyCSS_STATUS_OK == 0x000000
for modest 020000..02ffff; MODEST_STATUS_OK == 0x000000
- for myrender 030000..03ffff; MyRENDER_STATUS_OK == 0x000000
+ for myrender 030000..037777; MyRENDER_STATUS_OK == 0x000000
+ for myurl 038888..0388ff; MyURL_STATUS_OK == 0x000000
+ for myunicode 038900..038bff; MyUNICODE_STATUS_OK == 0x000000
+ not occupied 038c00..03ffff;
for mydom 040000..04ffff; MyDOM_STATUS_OK == 0x000000
for mynetwork 050000..05ffff; MyNETWORK_STATUS_OK == 0x000000
for myecma 060000..06ffff; MyECMA_STATUS_OK == 0x000000
- for myfont 070000..07ffff; MyFONT_STATUS_OK == 0x000000
- not occupied 080000..
+ not occupied 070000..
*/
enum modest_status {
MODEST_STATUS_OK = 0x000000,
diff --git a/include/modest/node/node.h b/include/modest/node/node.h
index 726a3d1..cd3d914 100644
--- a/include/modest/node/node.h
+++ b/include/modest/node/node.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -26,7 +26,7 @@
#include <modest/modest.h>
#include <modest/style/raw.h>
#include <modest/render/tree_node.h>
-#include <myhtml/utils/avl_tree.h>
+#include <mycore/utils/avl_tree.h>
#ifdef __cplusplus
extern "C" {
@@ -35,7 +35,7 @@ extern "C" {
struct modest_node {
modest_style_sheet_t* stylesheet;
#ifndef MODEST_NODE_FULL_RAW
- myhtml_utils_avl_tree_node_t *avl_tree_node;
+ mycore_utils_avl_tree_node_t *avl_tree_node;
#else
modest_style_raw_declaration_t * raw_declaration[MyCSS_PROPERTY_TYPE_LAST_ENTRY];
#endif /* MODEST_NODE_FULL_RAW */
@@ -44,7 +44,7 @@ struct modest_node {
};
modest_node_t * modest_node_create(modest_t* modest);
-modest_status_t modest_node_init(modest_t* modest, modest_node_t *mnode);
+mystatus_t modest_node_init(modest_t* modest, modest_node_t *mnode);
mycss_declaration_entry_t * modest_node_declaration_by_type(modest_t* modest, modest_node_t *mnode, mycss_property_type_t type);
diff --git a/include/modest/node/property.h b/include/modest/node/property.h
index 7f04f00..c497b6b 100644
--- a/include/modest/node/property.h
+++ b/include/modest/node/property.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/node/raw_property.h b/include/modest/node/raw_property.h
index 8a42f85..8d19073 100644
--- a/include/modest/node/raw_property.h
+++ b/include/modest/node/raw_property.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/node/serialization.h b/include/modest/node/serialization.h
index 7d2d354..e512e48 100644
--- a/include/modest/node/serialization.h
+++ b/include/modest/node/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -34,13 +34,13 @@ extern "C" {
struct modest_node_serialization_context {
modest_t* modest;
- mycss_callback_serialization_f callback;
+ mycore_callback_serialize_f callback;
void* context;
bool is_use;
}
typedef modest_node_serialization_context_t;
-bool modest_node_raw_serialization(modest_t* modest, modest_node_t* mnode, mycss_callback_serialization_f callback, void* context);
+bool modest_node_raw_serialization(modest_t* modest, modest_node_t* mnode, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/modest/render/begin.h b/include/modest/render/begin.h
index 6805d9b..0c5fb5a 100644
--- a/include/modest/render/begin.h
+++ b/include/modest/render/begin.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/render/binding.h b/include/modest/render/binding.h
index 24a53ce..e865e30 100644
--- a/include/modest/render/binding.h
+++ b/include/modest/render/binding.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/render/tree.h b/include/modest/render/tree.h
index 3bc5123..2f71fc4 100644
--- a/include/modest/render/tree.h
+++ b/include/modest/render/tree.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -25,7 +25,7 @@
typedef struct modest_render_tree modest_render_tree_t;
#include <modest/modest.h>
-#include <myhtml/utils/mcobject.h>
+#include <mycore/utils/mcobject.h>
#include <modest/render/tree_node.h>
#ifdef __cplusplus
@@ -37,12 +37,12 @@ struct modest_render_tree {
};
modest_render_tree_t * modest_render_tree_create(void);
-modest_status_t modest_render_tree_init(modest_render_tree_t* render_tree);
+mystatus_t modest_render_tree_init(modest_render_tree_t* render_tree);
void modest_render_tree_clean_all(modest_render_tree_t* render_tree);
modest_render_tree_t * modest_render_tree_destroy(modest_render_tree_t* render_tree, bool self_destroy);
void modest_render_tree_serialization(myhtml_tree_t* html_tree, modest_render_tree_t* tree,
- modest_render_tree_node_t* scope_node, mycss_callback_serialization_f callback, void* context);
+ modest_render_tree_node_t* scope_node, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/modest/render/tree_node.h b/include/modest/render/tree_node.h
index 4c39d9d..01717b3 100644
--- a/include/modest/render/tree_node.h
+++ b/include/modest/render/tree_node.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -28,7 +28,7 @@ typedef struct modest_render_tree_node modest_render_tree_node_t;
#include <modest/render/tree.h>
#include <myhtml/tree.h>
-#include <myhtml/utils/mcobject.h>
+#include <mycore/utils/mcobject.h>
#ifdef __cplusplus
extern "C" {
@@ -62,7 +62,7 @@ void modest_render_tree_node_remove(modest_render_tree_node_t* node);
void modest_render_tree_node_append_after(modest_render_tree_node_t* target, modest_render_tree_node_t* node);
void modest_render_tree_node_append_before(modest_render_tree_node_t* target, modest_render_tree_node_t* node);
-void modest_render_tree_node_serialization(myhtml_tree_t* html_tree, modest_render_tree_node_t* node, mycss_callback_serialization_f callback, void* context);
+void modest_render_tree_node_serialization(myhtml_tree_t* html_tree, modest_render_tree_node_t* node, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/modest/style/default.h b/include/modest/style/default.h
index 3382ae5..e73754e 100644
--- a/include/modest/style/default.h
+++ b/include/modest/style/default.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/style/default_entries.h b/include/modest/style/default_entries.h
index 0558e81..5545415 100644
--- a/include/modest/style/default_entries.h
+++ b/include/modest/style/default_entries.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/style/default_resources.h b/include/modest/style/default_resources.h
index 5971d73..4182914 100644
--- a/include/modest/style/default_resources.h
+++ b/include/modest/style/default_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/style/map.h b/include/modest/style/map.h
index f142439..086495a 100644
--- a/include/modest/style/map.h
+++ b/include/modest/style/map.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/style/map_resource.h b/include/modest/style/map_resource.h
index bb2eca2..9938dd8 100644
--- a/include/modest/style/map_resource.h
+++ b/include/modest/style/map_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/modest/style/raw.h b/include/modest/style/raw.h
index ab625e9..d5c5bc5 100644
--- a/include/modest/style/raw.h
+++ b/include/modest/style/raw.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -24,7 +24,7 @@
#include <modest/myosi.h>
#include <modest/modest.h>
-#include <myhtml/utils/mcobject.h>
+#include <mycore/utils/mcobject.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/modest/style/sheet.h b/include/modest/style/sheet.h
index 2c48827..20162db 100644
--- a/include/modest/style/sheet.h
+++ b/include/modest/style/sheet.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -53,7 +53,7 @@ struct modest_style_sheet {
};
modest_style_sheet_t * modest_style_sheet_create(modest_t* modest);
-modest_status_t modest_style_sheet_init(modest_t* modest, modest_style_sheet_t* m_stylesheet);
+mystatus_t modest_style_sheet_init(modest_t* modest, modest_style_sheet_t* m_stylesheet);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/modest/style/type.h b/include/modest/style/type.h
index e5f6305..0e99cf9 100644
--- a/include/modest/style/type.h
+++ b/include/modest/style/type.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -25,7 +25,7 @@
#include <modest/myosi.h>
#include <modest/modest.h>
#include <mycss/declaration/myosi.h>
-#include <myhtml/utils/mchar_async.h>
+#include <mycore/utils/mchar_async.h>
#ifdef __cplusplus
extern "C" {
@@ -44,7 +44,7 @@ struct modest_style_type_display {
void * modest_style_type_create(modest_t* modest, size_t size);
-modest_status_t modest_style_type_init(modest_t* modest, void *data);
+mystatus_t modest_style_type_init(modest_t* modest, void *data);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myhtml/incoming.h b/include/mycore/incoming.h
index 6e35389..145666c 100644
--- a/source/myhtml/incoming.h
+++ b/include/mycore/incoming.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -18,51 +18,48 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_INCOMING_H
-#define MyHTML_INCOMING_H
+#ifndef MyCORE_INCOMING_H
+#define MyCORE_INCOMING_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-#include "myhtml/myosi.h"
-#include "myhtml/tree.h"
-#include "myhtml/utils/mcobject.h"
+#include <mycore/myosi.h>
+#include <mycore/utils/mcobject.h>
-struct myhtml_incoming_buffer {
+struct mycore_incoming_buffer {
const char* data;
size_t length; // use of data
size_t size; // size of data
size_t offset; // begin global offset
- struct myhtml_incoming_buffer* prev;
- struct myhtml_incoming_buffer* next;
+ struct mycore_incoming_buffer* prev;
+ struct mycore_incoming_buffer* next;
};
+mycore_incoming_buffer_t * mycore_incoming_buffer_add(mycore_incoming_buffer_t *current, mcobject_t *mcobject, const char *html, size_t html_size);
+void mycore_incoming_buffer_clean(mycore_incoming_buffer_t *current);
+mycore_incoming_buffer_t * mycore_incoming_buffer_split(mycore_incoming_buffer_t *current, mcobject_t *mcobject, size_t global_pos);
-// incoming buffer
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_add(myhtml_incoming_buffer_t *current, mcobject_t *mcobject, const char *html, size_t html_size);
-void myhtml_incoming_buffer_clean(myhtml_incoming_buffer_t *current);
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_split(myhtml_incoming_buffer_t *current, mcobject_t *mcobject, size_t global_pos);
+mycore_incoming_buffer_t * mycore_incoming_buffer_find_by_position(mycore_incoming_buffer_t *inc_buf, size_t begin);
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_find_by_position(myhtml_incoming_buffer_t *inc_buf, size_t begin);
+const char * mycore_incoming_buffer_data(mycore_incoming_buffer_t *inc_buf);
+size_t mycore_incoming_buffer_length(mycore_incoming_buffer_t *inc_buf);
+size_t mycore_incoming_buffer_size(mycore_incoming_buffer_t *inc_buf);
+size_t mycore_incoming_buffer_offset(mycore_incoming_buffer_t *inc_buf);
+size_t mycore_incoming_buffer_relative_begin(mycore_incoming_buffer_t *inc_buf, size_t begin);
+size_t mycore_incoming_buffer_available_length(mycore_incoming_buffer_t *inc_buf, size_t relative_begin, size_t length);
-const char * myhtml_incoming_buffer_data(myhtml_incoming_buffer_t *inc_buf);
-size_t myhtml_incoming_buffer_length(myhtml_incoming_buffer_t *inc_buf);
-size_t myhtml_incoming_buffer_size(myhtml_incoming_buffer_t *inc_buf);
-size_t myhtml_incoming_buffer_offset(myhtml_incoming_buffer_t *inc_buf);
-size_t myhtml_incoming_buffer_relative_begin(myhtml_incoming_buffer_t *inc_buf, size_t begin);
-size_t myhtml_incoming_buffer_available_length(myhtml_incoming_buffer_t *inc_buf, size_t relative_begin, size_t length);
+mycore_incoming_buffer_t * mycore_incoming_buffer_next(mycore_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_t * mycore_incoming_buffer_prev(mycore_incoming_buffer_t *inc_buf);
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_next(myhtml_incoming_buffer_t *inc_buf);
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_prev(myhtml_incoming_buffer_t *inc_buf);
-
-size_t myhtml_incoming_buffer_convert_one_escaped_to_code_point(myhtml_incoming_buffer_t **inc_buf, size_t *relative_pos);
-size_t myhtml_incoming_buffer_escaped_case_cmp(myhtml_incoming_buffer_t **inc_buf, const char *to, size_t to_size, size_t *relative_pos);
+size_t mycore_incoming_buffer_convert_one_escaped_to_code_point(mycore_incoming_buffer_t **inc_buf, size_t *relative_pos);
+size_t mycore_incoming_buffer_escaped_case_cmp(mycore_incoming_buffer_t **inc_buf, const char *to, size_t to_size, size_t *relative_pos);
#ifdef __cplusplus
} /* extern "C" */
#endif
-#endif /* MyHTML_INCOMING_H */
+#endif /* MyCORE_INCOMING_H */
diff --git a/include/mycore/myosi.h b/include/mycore/myosi.h
new file mode 100644
index 0000000..563c44e
--- /dev/null
+++ b/include/mycore/myosi.h
@@ -0,0 +1,169 @@
+/*
+ Copyright (C) 2015-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 MyCORE_MYOSI_H
+#define MyCORE_MYOSI_H
+#pragma once
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#define MyCORE_STR_HELPER(x) #x
+#define MyCORE_STR(x) MyCORE_STR_HELPER(x)
+
+#define MyCORE_VERSION_MAJOR 0
+#define MyCORE_VERSION_MINOR 1
+#define MyCORE_VERSION_PATCH 0
+
+#define MyCORE_VERSION_STRING MyCORE_STR(MyCORE_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyCORE_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyCORE_VERSION_PATCH)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Format */
+#ifdef MyCORE_OS_WINDOWS_NT
+#define MyCORE_FORMAT_Z "%Iu"
+#else
+#define MyCORE_FORMAT_Z "%zu"
+#endif
+
+#if defined(_MSC_VER)
+# define MyCORE_DEPRECATED(func) __declspec(deprecated) func
+#elif defined(__GNUC__) || defined(__INTEL_COMPILER)
+# define MyCORE_DEPRECATED(func) func __attribute__((deprecated))
+#else
+# define MyCORE_DEPRECATED(func) func
+#endif
+
+/* Debug */
+#define MyCORE_DEBUG(...) do {} while(0)
+#define MyCORE_DEBUG_ERROR(...) do {} while(0)
+
+#define MyCORE_FAILED(_status_) ((_status_) != MyCORE_STATUS_OK)
+
+// base
+/*
+ Very important!!!
+
+ for mycore 0..008fff; MyCORE_STATUS_OK == 0x000000
+ for myhtml 009000..0093ff; MyHTML_STATUS_OK == 0x000000
+ for myencoding 009400..00942f; MyENCODING_STATUS_OK == 0x000000
+ not occupied 009430..00ffff;
+ for mycss and modules 010000..01ffff; MyCSS_STATUS_OK == 0x000000
+ for modest 020000..02ffff; MODEST_STATUS_OK == 0x000000
+ for myrender 030000..037777; MyRENDER_STATUS_OK == 0x000000
+ for myurl 038888..0388ff; MyURL_STATUS_OK == 0x000000
+ for myunicode 038900..038bff; MyUNICODE_STATUS_OK == 0x000000
+ not occupied 038c00..03ffff;
+ for mydom 040000..04ffff; MyDOM_STATUS_OK == 0x000000
+ for mynetwork 050000..05ffff; MyNETWORK_STATUS_OK == 0x000000
+ for myecma 060000..06ffff; MyECMA_STATUS_OK == 0x000000
+ not occupied 070000..
+*/
+enum mycore_status {
+ MyCORE_STATUS_OK = 0x0000,
+ MyCORE_STATUS_ERROR = 0x0001,
+ MyCORE_STATUS_ERROR_MEMORY_ALLOCATION = 0x0002,
+ MyCORE_STATUS_THREAD_ERROR_MEMORY_ALLOCATION = 0x0009,
+ MyCORE_STATUS_THREAD_ERROR_LIST_INIT = 0x000a,
+ MyCORE_STATUS_THREAD_ERROR_ATTR_MALLOC = 0x000b,
+ MyCORE_STATUS_THREAD_ERROR_ATTR_INIT = 0x000c,
+ MyCORE_STATUS_THREAD_ERROR_ATTR_SET = 0x000d,
+ MyCORE_STATUS_THREAD_ERROR_ATTR_DESTROY = 0x000e,
+ MyCORE_STATUS_THREAD_ERROR_NO_SLOTS = 0x000f,
+ MyCORE_STATUS_THREAD_ERROR_BATCH_INIT = 0x0010,
+ MyCORE_STATUS_THREAD_ERROR_WORKER_MALLOC = 0x0011,
+ MyCORE_STATUS_THREAD_ERROR_WORKER_SEM_CREATE = 0x0012,
+ MyCORE_STATUS_THREAD_ERROR_WORKER_THREAD_CREATE = 0x0013,
+ MyCORE_STATUS_THREAD_ERROR_MASTER_THREAD_CREATE = 0x0014,
+ MyCORE_STATUS_THREAD_ERROR_SEM_PREFIX_MALLOC = 0x0032,
+ MyCORE_STATUS_THREAD_ERROR_SEM_CREATE = 0x0033,
+ MyCORE_STATUS_THREAD_ERROR_QUEUE_MALLOC = 0x003c,
+ MyCORE_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC = 0x003d,
+ MyCORE_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC = 0x003e,
+ MyCORE_STATUS_THREAD_ERROR_MUTEX_MALLOC = 0x0046,
+ MyCORE_STATUS_THREAD_ERROR_MUTEX_INIT = 0x0047,
+ MyCORE_STATUS_THREAD_ERROR_MUTEX_LOCK = 0x0048,
+ MyCORE_STATUS_THREAD_ERROR_MUTEX_UNLOCK = 0x0049,
+ MyCORE_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF = 0x0050,
+ MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK = 0x0051,
+ MyCORE_STATUS_MCOBJECT_ERROR_CACHE_CREATE = 0x0055,
+ MyCORE_STATUS_MCOBJECT_ERROR_CHUNK_CREATE = 0x0056,
+ MyCORE_STATUS_MCOBJECT_ERROR_CHUNK_INIT = 0x0057,
+ MyCORE_STATUS_MCOBJECT_ERROR_CACHE_REALLOC = 0x0058,
+ MyCORE_STATUS_ASYNC_ERROR_LOCK = 0x0060,
+ MyCORE_STATUS_ASYNC_ERROR_UNLOCK = 0x0061,
+ MyCORE_STATUS_ERROR_NO_FREE_SLOT = 0x0062,
+}
+typedef mycore_status_t;
+
+typedef unsigned int mystatus_t;
+
+/* thread */
+typedef struct mythread_queue_list_entry mythread_queue_list_entry_t;
+typedef struct mythread_queue_thread_param mythread_queue_thread_param_t;
+typedef struct mythread_queue_list mythread_queue_list_t;
+typedef struct mythread_queue_node mythread_queue_node_t;
+typedef struct mythread_queue mythread_queue_t;
+
+typedef size_t mythread_id_t;
+typedef struct mythread_context mythread_context_t;
+typedef struct mythread_entry mythread_entry_t;
+typedef struct mythread mythread_t;
+
+/* mystring */
+typedef struct mycore_string_raw mycore_string_raw_t;
+typedef struct mycore_string mycore_string_t;
+
+/* incoming buffer */
+typedef struct mycore_incoming_buffer mycore_incoming_buffer_t;
+
+/* callbacks */
+typedef mystatus_t (*mycore_callback_serialize_f)(const char* buffer, size_t size, void* ctx);
+
+void * mycore_malloc(size_t size);
+void * mycore_realloc(void* dst, size_t size);
+void * mycore_calloc(size_t num, size_t size);
+void * mycore_free(void* dst);
+
+/* io */
+FILE * mycore_fopen(const char *filename, const char *mode);
+int mycore_fclose(FILE *stream);
+
+size_t mycore_fread(void *buffer, size_t size, size_t count, FILE *stream);
+size_t mycore_fwrite(const void *buffer, size_t size, size_t count, FILE *stream);
+int mycore_fflush(FILE *stream);
+int mycore_fseek(FILE* stream, long offset, int origin);
+long mycore_ftell(FILE* stream);
+int mycore_ferror(FILE *stream);
+
+void mycore_setbuf(FILE *stream, char *buffer);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyCORE_MYOSI_H */
+
diff --git a/include/mycore/mystring.h b/include/mycore/mystring.h
new file mode 100644
index 0000000..d333583
--- /dev/null
+++ b/include/mycore/mystring.h
@@ -0,0 +1,125 @@
+/*
+ Copyright (C) 2015-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 MyCORE_MYSTRING_H
+#define MyCORE_MYSTRING_H
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <mycore/myosi.h>
+#include <mycore/utils/mchar_async.h>
+#include <mycore/utils.h>
+
+#define mycore_string_get(str, attr) str->attr
+#define mycore_string_set(str, attr) mycore_string_get(str, attr)
+#define mycore_string_len(str) mycore_string_get(str, length)
+
+#define MyCORE_STRING_PREPROCESSOR_CHECK_BUFFER_SIZE(str, unsigned_data) \
+ if(str->length >= str->size) { \
+ mycore_string_realloc(str, (str->length + 5)); \
+ \
+ unsigned_data = (unsigned char*)str->data; \
+ }
+
+#define MyCORE_STRING_REALLOC_IF_NEED(str, need_length, upto) \
+ if((str->length + need_length) >= str->size) { \
+ mycore_string_realloc(str, (str->length + need_length + upto)); \
+ } \
+
+#define MyCORE_STRING_APPEND_BYTE_WITHOUT_REALLOC(onechar, str) \
+ str->data[str->length] = onechar; \
+ str->length++
+
+#define MyCORE_STRING_APPEND_BYTE_WITHOUT_INCREMENT(onechar, str, upto) \
+ if(str->length >= str->size) { \
+ mycore_string_realloc(str, (str->length + upto)); \
+ } \
+ str->data[str->length] = onechar
+
+#define MyCORE_STRING_APPEND_BYTE_WITHOUT_INCREMENT_REALLOC(onechar, str) \
+ str->data[str->length] = onechar
+
+#define MyCORE_STRING_APPEND_BYTE(onechar, str, upto) \
+ MyCORE_STRING_APPEND_BYTE_WITHOUT_INCREMENT(onechar, str, upto); \
+ str->length++
+
+struct mycore_string {
+ char* data;
+ size_t size;
+ size_t length;
+
+ mchar_async_t *mchar;
+ size_t node_idx;
+};
+
+struct mycore_string_raw {
+ char* data;
+ size_t size;
+ size_t length;
+};
+
+typedef size_t mycore_string_index_t;
+
+char * mycore_string_init(mchar_async_t *mchar, size_t node_idx, mycore_string_t* str, size_t size);
+char * mycore_string_realloc(mycore_string_t *str, size_t new_size);
+
+void mycore_string_clean(mycore_string_t* str);
+void mycore_string_clean_all(mycore_string_t* str);
+mycore_string_t * mycore_string_destroy(mycore_string_t* str, bool destroy_obj);
+
+void mycore_string_raw_clean(mycore_string_raw_t* str_raw);
+void mycore_string_raw_clean_all(mycore_string_raw_t* str_raw);
+mycore_string_raw_t * mycore_string_raw_destroy(mycore_string_raw_t* str_raw, bool destroy_obj);
+
+/* basic api */
+char * mycore_string_data_alloc(mchar_async_t *mchar, size_t node_id, size_t size);
+char * mycore_string_data_realloc(mchar_async_t *mchar, size_t node_id, char *data, size_t len_to_copy, size_t size);
+void mycore_string_data_free(mchar_async_t *mchar, size_t node_id, char *data);
+
+char * mycore_string_data(mycore_string_t *str);
+size_t mycore_string_length(mycore_string_t *str);
+size_t mycore_string_size(mycore_string_t *str);
+char * mycore_string_data_set(mycore_string_t *str, char *data);
+size_t mycore_string_size_set(mycore_string_t *str, size_t size);
+size_t mycore_string_length_set(mycore_string_t *str, size_t length);
+
+/* append */
+void mycore_string_append(mycore_string_t* str, const char* data, size_t length);
+void mycore_string_append_one(mycore_string_t* str, const char data);
+void mycore_string_append_lowercase(mycore_string_t* str, const char* data, size_t length);
+void mycore_string_append_with_replacement_null_characters(mycore_string_t* str, const char* buff, size_t length);
+
+size_t mycore_string_raw_set_replacement_character(mycore_string_t* target, size_t position);
+
+/* other functions */
+void mycore_string_copy(mycore_string_t* dest, mycore_string_t* target);
+size_t mycore_string_raw_copy(char* str1, const char* str2, size_t size);
+void mycore_string_stay_only_whitespace(mycore_string_t* target);
+size_t mycore_string_crop_whitespace_from_begin(mycore_string_t* target);
+size_t mycore_string_whitespace_from_begin(mycore_string_t* target);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* mycore_mystring_h */
diff --git a/include/mycore/mythread.h b/include/mycore/mythread.h
new file mode 100644
index 0000000..65096ec
--- /dev/null
+++ b/include/mycore/mythread.h
@@ -0,0 +1,159 @@
+/*
+ Copyright (C) 2015-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 MyCORE_THREAD_H
+#define MyCORE_THREAD_H
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <mycore/myosi.h>
+#include <mycore/mystring.h>
+
+#ifdef MyCORE_BUILD_WITHOUT_THREADS
+
+struct mythread {
+ int sys_last_error;
+};
+
+#else
+/* functions */
+typedef void (*mythread_callback_before_entry_join_f)(mythread_t* mythread, mythread_entry_t* entry, void* ctx);
+typedef void * (*mythread_process_f)(void* arg);
+typedef void (*mythread_work_f)(mythread_id_t thread_id, void* arg);
+
+void * mythread_function_queue_stream(void *arg);
+void * mythread_function_queue_batch(void *arg);
+void * mythread_function(void *arg);
+
+enum mythread_thread_opt {
+ MyTHREAD_OPT_UNDEF = 0x00,
+ MyTHREAD_OPT_WAIT = 0x01,
+ MyTHREAD_OPT_QUIT = 0x02,
+ MyTHREAD_OPT_STOP = 0x04,
+ MyTHREAD_OPT_DONE = 0x08
+}
+typedef mythread_thread_opt_t;
+
+enum mythread_type {
+ MyTHREAD_TYPE_STREAM = 0x00,
+ MyTHREAD_TYPE_BATCH = 0x01
+}
+typedef mythread_type_t;
+
+// thread
+struct mythread_context {
+ mythread_id_t id;
+ mythread_work_f func;
+
+ volatile size_t t_count;
+ volatile mythread_thread_opt_t opt;
+
+ mystatus_t status;
+
+ void* mutex;
+ void* timespec;
+ mythread_t* mythread;
+};
+
+struct mythread_entry {
+ void* thread;
+
+ mythread_context_t context;
+ mythread_process_f process_func;
+};
+
+struct mythread {
+ mythread_entry_t *entries;
+ size_t entries_length;
+ size_t entries_size;
+ size_t id_increase;
+
+ void* context;
+ void* attr;
+ void* timespec;
+
+ int sys_last_error;
+
+ mythread_type_t type;
+ volatile mythread_thread_opt_t opt;
+};
+
+mythread_t * mythread_create(void);
+mystatus_t mythread_init(mythread_t *mythread, mythread_type_t type, size_t threads_count, size_t id_increase);
+void mythread_clean(mythread_t *mythread);
+mythread_t * mythread_destroy(mythread_t *mythread, mythread_callback_before_entry_join_f before_join, void* ctx, bool self_destroy);
+
+mythread_id_t myhread_increase_id_by_entry_id(mythread_t* mythread, mythread_id_t thread_id);
+
+/* set for all threads */
+mystatus_t mythread_join(mythread_t *mythread, mythread_callback_before_entry_join_f before_join, void* ctx);
+mystatus_t mythread_quit(mythread_t *mythread, mythread_callback_before_entry_join_f before_join, void* ctx);
+mystatus_t mythread_stop(mythread_t *mythread);
+mystatus_t mythread_resume(mythread_t *mythread, mythread_thread_opt_t send_opt);
+mystatus_t mythread_suspend(mythread_t *mythread);
+mystatus_t mythread_check_status(mythread_t *mythread);
+
+mythread_thread_opt_t mythread_option(mythread_t *mythread);
+void mythread_option_set(mythread_t *mythread, mythread_thread_opt_t opt);
+
+/* Entries */
+mystatus_t myhread_entry_create(mythread_t *mythread, mythread_process_f process_func, mythread_work_f func, mythread_thread_opt_t opt);
+
+mystatus_t mythread_entry_join(mythread_entry_t* entry, mythread_callback_before_entry_join_f before_join, void* ctx);
+mystatus_t mythread_entry_quit(mythread_entry_t* entry, mythread_callback_before_entry_join_f before_join, void* ctx);
+mystatus_t mythread_entry_stop(mythread_entry_t* entry);
+mystatus_t mythread_entry_resume(mythread_entry_t* entry, mythread_thread_opt_t send_opt);
+mystatus_t mythread_entry_suspend(mythread_entry_t* entry);
+mystatus_t mythread_entry_status(mythread_entry_t* entry);
+mythread_t * mythread_entry_mythread(mythread_entry_t* entry);
+
+/* API for ports */
+void * mythread_thread_create(mythread_t *mythread, mythread_process_f process_func, void* ctx);
+mystatus_t mythread_thread_join(mythread_t *mythread, void* thread);
+mystatus_t mythread_thread_cancel(mythread_t *mythread, void* thread);
+mystatus_t mythread_thread_destroy(mythread_t *mythread, void* thread);
+
+void * mythread_thread_attr_init(mythread_t *mythread);
+void mythread_thread_attr_clean(mythread_t *mythread, void* attr);
+void mythread_thread_attr_destroy(mythread_t *mythread, void* attr);
+
+void * mythread_mutex_create(mythread_t *mythread);
+mystatus_t mythread_mutex_post(mythread_t *mythread, void* mutex);
+mystatus_t mythread_mutex_wait(mythread_t *mythread, void* mutex);
+void mythread_mutex_close(mythread_t *mythread, void* mutex);
+
+void * mythread_nanosleep_create(mythread_t* mythread);
+void mythread_nanosleep_clean(void* timespec);
+void mythread_nanosleep_destroy(void* timespec);
+mystatus_t mythread_nanosleep_sleep(void* timespec);
+
+/* callback */
+void mythread_callback_quit(mythread_t* mythread, mythread_entry_t* entry, void* ctx);
+
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyCORE_THREAD_H */
diff --git a/include/mycore/perf.h b/include/mycore/perf.h
new file mode 100644
index 0000000..99e5f7e
--- /dev/null
+++ b/include/mycore/perf.h
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2015-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 MyCORE_PERF_H
+#define MyCORE_PERF_H
+#pragma once
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <mycore/myosi.h>
+
+#ifdef MyCORE_WITH_PERF
+void * mycore_perf_create(void);
+void mycore_perf_clean(void* perf);
+void mycore_perf_destroy(void* perf);
+
+mycore_status_t myhtml_perf_begin(void* perf);
+mycore_status_t myhtml_perf_end(void* perf);
+double myhtml_perf_in_sec(void* perf);
+
+unsigned long long mycore_perf_clock(void);
+unsigned long long mycore_perf_frequency(void);
+#endif /* MyCORE_WITH_PERF */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyCORE_PERF_H */
diff --git a/include/mycore/thread_queue.h b/include/mycore/thread_queue.h
new file mode 100644
index 0000000..e833b35
--- /dev/null
+++ b/include/mycore/thread_queue.h
@@ -0,0 +1,110 @@
+/*
+ Copyright (C) 2015-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 MyCORE_THREAD_QUEUE_H
+#define MyCORE_THREAD_QUEUE_H
+#pragma once
+
+#include <mycore/myosi.h>
+#include <mycore/mythread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// queue
+struct mythread_queue_node {
+ void* context;
+ void* args;
+
+ mythread_queue_node_t* prev;
+};
+
+struct mythread_queue_thread_param {
+ volatile size_t use;
+};
+
+struct mythread_queue_list_entry {
+ mythread_queue_t* queue;
+ mythread_queue_thread_param_t* thread_param;
+ size_t thread_param_size;
+
+ mythread_queue_list_entry_t* next;
+ mythread_queue_list_entry_t* prev;
+};
+
+struct mythread_queue_list {
+ mythread_queue_list_entry_t *first;
+ mythread_queue_list_entry_t *last;
+
+ volatile size_t count;
+};
+
+struct mythread_queue {
+ mythread_queue_node_t **nodes;
+
+ size_t nodes_pos;
+ size_t nodes_pos_size;
+ size_t nodes_length;
+
+ volatile size_t nodes_uses;
+ volatile size_t nodes_size;
+ volatile size_t nodes_root;
+};
+
+mythread_queue_t * mythread_queue_create(void);
+mystatus_t mythread_queue_init(mythread_queue_t* queue, size_t size);
+void mythread_queue_clean(mythread_queue_t* queue);
+mythread_queue_t * mythread_queue_destroy(mythread_queue_t* token);
+
+void mythread_queue_node_clean(mythread_queue_node_t* qnode);
+size_t mythread_queue_count_used_node(mythread_queue_t* queue);
+
+mythread_queue_node_t * mythread_queue_get_first_node(mythread_queue_t* queue);
+mythread_queue_node_t * mythread_queue_get_prev_node(mythread_queue_node_t* qnode);
+mythread_queue_node_t * mythread_queue_get_current_node(mythread_queue_t* queue);
+
+mythread_queue_node_t * mythread_queue_node_malloc(mythread_t *mythread, mythread_queue_t* queue, mystatus_t *status);
+mythread_queue_node_t * mythread_queue_node_malloc_limit(mythread_t *mythread, mythread_queue_t* queue, size_t limit, mystatus_t *status);
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+mythread_queue_node_t * mythread_queue_node_malloc_round(mythread_t *mythread, mythread_queue_list_entry_t *entry, mystatus_t *status);
+#endif
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+mythread_queue_list_t * mythread_queue_list_create(mystatus_t *status);
+void mythread_queue_list_destroy(mythread_queue_list_t* queue_list);
+size_t mythread_queue_list_get_count(mythread_queue_list_t* queue_list);
+
+void mythread_queue_list_wait_for_done(mythread_t* mythread, mythread_queue_list_t* queue_list);
+bool mythread_queue_list_see_for_done(mythread_t* mythread, mythread_queue_list_t* queue_list);
+bool mythread_queue_list_see_for_done_by_thread(mythread_t* mythread, mythread_queue_list_t* queue_list, mythread_id_t thread_id);
+
+mythread_queue_list_entry_t * mythread_queue_list_entry_push(mythread_t** mythread_list, size_t list_size, mythread_queue_list_t* queue_list, mythread_queue_t* queue, size_t thread_param_size, mystatus_t* status);
+mythread_queue_list_entry_t * mythread_queue_list_entry_delete(mythread_t** mythread_list, size_t list_size, mythread_queue_list_t *queue_list, mythread_queue_list_entry_t *entry, bool destroy_queue);
+void mythread_queue_list_entry_clean(mythread_queue_list_entry_t *entry);
+void mythread_queue_list_entry_wait_for_done(mythread_t *mythread, mythread_queue_list_entry_t *entry);
+void mythread_queue_list_entry_make_batch(mythread_t* mythread, mythread_queue_list_entry_t* entry, size_t from, size_t length);
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyCORE_THREAD_QUEUE_H */
diff --git a/include/myhtml/utils.h b/include/mycore/utils.h
index 1b12b2e..e4a7e9f 100644
--- a/include/myhtml/utils.h
+++ b/include/mycore/utils.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,29 +18,30 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_H
-#define MyHTML_UTILS_H
+#ifndef MyCORE_UTILS_H
+#define MyCORE_UTILS_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-#include <myhtml/myosi.h>
+#include <mycore/myosi.h>
-#define myhtml_utils_whithspace(onechar, action, logic) \
+#define mycore_utils_whithspace(onechar, action, logic) \
(onechar action ' ' logic \
onechar action '\t' logic \
onechar action '\n' logic \
onechar action '\f' logic \
onechar action '\r')
-size_t myhtml_strncasecmp(const char* str1, const char* str2, size_t size);
-size_t myhtml_strcasecmp(const char* str1, const char* str2);
-size_t myhtml_strncmp(const char* str1, const char* str2, size_t size);
-size_t myhtml_strcmp(const char* str1, const char* str2);
-size_t myhtml_strcmp_ws(const char* str1, const char* str2);
-bool myhtml_ustrcasecmp_without_checks_by_secondary(const unsigned char* ustr1, const unsigned char* ustr2);
+size_t mycore_power(size_t t, size_t k);
+size_t mycore_strncasecmp(const char* str1, const char* str2, size_t size);
+size_t mycore_strcasecmp(const char* str1, const char* str2);
+size_t mycore_strncmp(const char* str1, const char* str2, size_t size);
+size_t mycore_strcmp(const char* str1, const char* str2);
+size_t mycore_strcmp_ws(const char* str1, const char* str2);
+bool mycore_ustrcasecmp_without_checks_by_secondary(const unsigned char* ustr1, const unsigned char* ustr2);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/mycore/utils/avl_tree.h b/include/mycore/utils/avl_tree.h
new file mode 100644
index 0000000..5242468
--- /dev/null
+++ b/include/mycore/utils/avl_tree.h
@@ -0,0 +1,68 @@
+/*
+ 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 avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyCORE_UTILS_AVL_TREE_H
+#define MyCORE_UTILS_AVL_TREE_H
+#pragma once
+
+#include <mycore/myosi.h>
+#include <mycore/utils/mcobject.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct mycore_utils_avl_tree_node mycore_utils_avl_tree_node_t;
+typedef void (*mycore_utils_avl_tree_node_callback_f)(mycore_utils_avl_tree_node_t* avl_tree_node, void* ctx);
+
+struct mycore_utils_avl_tree_node {
+ void *value;
+ size_t type;
+
+ mycore_utils_avl_tree_node_t* left;
+ mycore_utils_avl_tree_node_t* right;
+ mycore_utils_avl_tree_node_t* parent;
+
+ short height;
+};
+
+struct mycore_utils_avl_tree {
+ mcobject_t* mc_nodes;
+}
+typedef mycore_utils_avl_tree_t;
+
+mycore_utils_avl_tree_t * mycore_utils_avl_tree_create(void);
+mystatus_t mycore_utils_avl_tree_init(mycore_utils_avl_tree_t* avl_tree);
+void mycore_utils_avl_tree_clean(mycore_utils_avl_tree_t* avl_tree);
+mycore_utils_avl_tree_t * mycore_utils_avl_tree_destroy(mycore_utils_avl_tree_t* avl_tree, bool self_destroy);
+
+mycore_utils_avl_tree_node_t * mycore_utils_avl_tree_node_create_root(mycore_utils_avl_tree_t* avl_tree, size_t type, void* value);
+
+void mycore_utils_avl_tree_add(mycore_utils_avl_tree_t* avl_tree, mycore_utils_avl_tree_node_t** root, size_t type, void* value);
+void * mycore_utils_avl_tree_delete(mycore_utils_avl_tree_t *avl_tree, mycore_utils_avl_tree_node_t** root, size_t type);
+mycore_utils_avl_tree_node_t * mycore_utils_avl_tree_search_by_type(mycore_utils_avl_tree_t *avl_tree, mycore_utils_avl_tree_node_t* node, size_t type);
+
+void mycore_utils_avl_tree_list_all_nodes(mycore_utils_avl_tree_t *avl_tree, mycore_utils_avl_tree_node_t* root, mycore_utils_avl_tree_node_callback_f callback, void* ctx);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyCORE_UTILS_AVL_TREE_H */
diff --git a/include/myhtml/utils/mchar_async.h b/include/mycore/utils/mchar_async.h
index 11057a2..45a346c 100644
--- a/include/myhtml/utils/mchar_async.h
+++ b/include/mycore/utils/mchar_async.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,16 +18,16 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_MCHAR_ASYNC_H
-#define MyHTML_UTILS_MCHAR_ASYNC_H
+#ifndef MyCORE_UTILS_MCHAR_ASYNC_H
+#define MyCORE_UTILS_MCHAR_ASYNC_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-#include <myhtml/myosi.h>
-#include <myhtml/utils/mcsync.h>
+#include <mycore/myosi.h>
+#include <mycore/utils/mcsync.h>
#define mchar_async_cache_has_nodes(cache) cache.count
@@ -96,16 +96,16 @@ struct mchar_async {
typedef mchar_async_t;
-mchar_async_t * mchar_async_create(size_t pos_size, size_t size);
-void mchar_async_init(mchar_async_t *mchar_async, size_t chunk_len, size_t char_size);
-void mchar_async_clean(mchar_async_t *mchar_async);
+mchar_async_t * mchar_async_create(void);
+mystatus_t mchar_async_init(mchar_async_t *mchar_async, size_t chunk_len, size_t char_size);
+mystatus_t mchar_async_clean(mchar_async_t *mchar_async);
mchar_async_t * mchar_async_destroy(mchar_async_t *mchar_async, int destroy_self);
char * mchar_async_malloc(mchar_async_t *mchar_async, size_t node_idx, size_t size);
char * mchar_async_realloc(mchar_async_t *mchar_async, size_t node_idx, char *data, size_t data_len, size_t new_size);
void mchar_async_free(mchar_async_t *mchar_async, size_t node_idx, char *entry);
-size_t mchar_async_node_add(mchar_async_t *mchar_async);
+size_t mchar_async_node_add(mchar_async_t *mchar_async, mystatus_t* status);
void mchar_async_node_clean(mchar_async_t *mchar_async, size_t node_idx);
void mchar_async_node_delete(mchar_async_t *mchar_async, size_t node_idx);
@@ -116,7 +116,7 @@ char * mchar_async_crop_first_chars_without_cache(char *data, size_t crop_len);
size_t mchar_async_get_size_by_data(const char *data);
// cache
-void mchar_async_cache_init(mchar_async_cache_t *cache);
+mystatus_t mchar_async_cache_init(mchar_async_cache_t *cache);
mchar_async_cache_t * mchar_async_cache_destroy(mchar_async_cache_t *cache, bool self_destroy);
void mchar_async_cache_clean(mchar_async_cache_t *cache);
diff --git a/source/myhtml/utils/mcobject.h b/include/mycore/utils/mcobject.h
index b68935b..1ba6893 100644
--- a/source/myhtml/utils/mcobject.h
+++ b/include/mycore/utils/mcobject.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,15 +18,15 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_MCOBJECT_H
-#define MyHTML_UTILS_MCOBJECT_H
+#ifndef MyCORE_UTILS_MCOBJECT_H
+#define MyCORE_UTILS_MCOBJECT_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-#include "myhtml/myosi.h"
+#include <mycore/myosi.h>
struct mcobject_chunk {
unsigned char *begin;
@@ -52,19 +52,19 @@ typedef mcobject_t;
mcobject_t * mcobject_create(void);
-myhtml_status_t mcobject_init(mcobject_t *mcobject, size_t chunk_size, size_t struct_size);
+mystatus_t mcobject_init(mcobject_t *mcobject, size_t chunk_size, size_t struct_size);
void mcobject_clean(mcobject_t *mcobject);
mcobject_t * mcobject_destroy(mcobject_t *mcobject, bool destroy_self);
-void mcobject_chunk_malloc(mcobject_t* mcobject, myhtml_status_t* status);
+void mcobject_chunk_malloc(mcobject_t* mcobject, mystatus_t* status);
-void * mcobject_malloc(mcobject_t *mcobject, myhtml_status_t* status);
-myhtml_status_t mcobject_free(mcobject_t *mcobject, void *entry);
+void * mcobject_malloc(mcobject_t *mcobject, mystatus_t* status);
+mystatus_t mcobject_free(mcobject_t *mcobject, void *entry);
#ifdef __cplusplus
} /* extern "C" */
#endif
-#endif /* MyHTML_UTILS_MCOBJECT_H */
+#endif /* MyCORE_UTILS_MCOBJECT_H */
diff --git a/source/myhtml/utils/mcobject_async.h b/include/mycore/utils/mcobject_async.h
index 8ee1c78..2b09b3c 100644
--- a/source/myhtml/utils/mcobject_async.h
+++ b/include/mycore/utils/mcobject_async.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,16 +18,16 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_MCOBJECT_ASYNC_H
-#define MyHTML_UTILS_MCOBJECT_ASYNC_H
+#ifndef MyCORE_UTILS_MCOBJECT_ASYNC_H
+#define MyCORE_UTILS_MCOBJECT_ASYNC_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-#include "myhtml/myosi.h"
-#include "myhtml/utils/mcsync.h"
+#include <mycore/myosi.h>
+#include <mycore/utils/mcsync.h>
enum mcobject_async_status {
MCOBJECT_ASYNC_STATUS_OK = 0,
diff --git a/include/myhtml/utils/mcsimple.h b/include/mycore/utils/mcsimple.h
index 76a0294..90fd87d 100644
--- a/include/myhtml/utils/mcsimple.h
+++ b/include/mycore/utils/mcsimple.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,15 +18,15 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_MCSIMPLE_H
-#define MyHTML_UTILS_MCSIMPLE_H
+#ifndef MyCORE_UTILS_MCSIMPLE_H
+#define MyCORE_UTILS_MCSIMPLE_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-#include <myhtml/myosi.h>
+#include <mycore/myosi.h>
struct mcsimple {
size_t struct_size;
@@ -57,5 +57,5 @@ void * mcsimple_get_by_absolute_position(mcsimple_t *mcsimple, size_t pos);
} /* extern "C" */
#endif
-#endif /* MyHTML_UTILS_MCSIMPLE_H */
+#endif /* MyCORE_UTILS_MCSIMPLE_H */
diff --git a/include/myhtml/utils/mcsync.h b/include/mycore/utils/mcsync.h
index b9e268b..1e272e0 100644
--- a/include/myhtml/utils/mcsync.h
+++ b/include/mycore/utils/mcsync.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,41 +18,26 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_MCSYNC_H
-#define MyHTML_UTILS_MCSYNC_H
+#ifndef MyCORE_UTILS_MCSYNC_H
+#define MyCORE_UTILS_MCSYNC_H
#pragma once
+#include <mycore/myosi.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-
-#include <myhtml/myosi.h>
-
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS)
-#if defined(IS_OS_WINDOWS)
- typedef CRITICAL_SECTION pthread_mutex_t;
- typedef unsigned long pthread_mutexattr_t;
-#else
-# include <pthread.h>
-#endif
-#endif
enum mcsync_status {
- MCSYNC_STATUS_OK = 0,
- MCSYNC_STATUS_NOT_OK = 1,
- MCSYNC_STATUS_ERROR_MEM_ALLOCATE = 2
+ MCSYNC_STATUS_OK = 0x00,
+ MCSYNC_STATUS_NOT_OK = 0x01,
+ MCSYNC_STATUS_ERROR_MEM_ALLOCATE = 0x02
}
typedef mcsync_status_t;
struct mcsync {
- int spinlock;
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS)
- pthread_mutex_t *mutex;
-#endif
+ int* spinlock;
+ void* mutex;
}
typedef mcsync_t;
@@ -61,17 +46,26 @@ mcsync_status_t mcsync_init(mcsync_t* mcsync);
void mcsync_clean(mcsync_t* mcsync);
mcsync_t * mcsync_destroy(mcsync_t* mcsync, int destroy_self);
-mcsync_status_t mcsync_lock(mcsync_t* mclock);
-mcsync_status_t mcsync_unlock(mcsync_t* mclock);
+mcsync_status_t mcsync_lock(mcsync_t* mcsync);
+mcsync_status_t mcsync_unlock(mcsync_t* mcsync);
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+mcsync_status_t mcsync_spin_lock(void* spinlock);
+mcsync_status_t mcsync_spin_unlock(void* spinlock);
+
+mcsync_status_t mcsync_mutex_lock(void* mutex);
+mcsync_status_t mcsync_mutex_try_lock(void* mutex);
+mcsync_status_t mcsync_mutex_unlock(void* mutex);
-mcsync_status_t mcsync_mutex_lock(mcsync_t* mclock);
-mcsync_status_t mcsync_mutex_unlock(mcsync_t* mclock);
+void * mcsync_spin_create(void);
+mcsync_status_t mcsync_spin_init(void* spinlock);
+void mcsync_spin_clean(void* spinlock);
+void mcsync_spin_destroy(void* spinlock);
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && defined(IS_OS_WINDOWS)
- static int pthread_mutex_lock(pthread_mutex_t *mutex);
- static int pthread_mutex_unlock(pthread_mutex_t *mutex);
- static int pthread_mutex_init(pthread_mutex_t *m, pthread_mutexattr_t *a);
- static int pthread_mutex_destroy(pthread_mutex_t *m);
+void * mcsync_mutex_create(void);
+mcsync_status_t mcsync_mutex_init(void* mutex);
+void mcsync_mutex_clean(void* mutex);
+void mcsync_mutex_destroy(void* mutex);
#endif
#ifdef __cplusplus
diff --git a/source/myhtml/utils/mctree.h b/include/mycore/utils/mctree.h
index bd3054f..98bb6ba 100644
--- a/source/myhtml/utils/mctree.h
+++ b/include/mycore/utils/mctree.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,21 +18,21 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_MCTREE_H
-#define MyHTML_UTILS_MCTREE_H
+#ifndef MyCORE_UTILS_MCTREE_H
+#define MyCORE_UTILS_MCTREE_H
#pragma once
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "myhtml/myosi.h"
-#include "myhtml/utils.h"
+#include <mycore/myosi.h>
+#include <mycore/utils.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define mctree_node_get_free_id(mctree) mctree->nodes_length
#define mctree_node_clean(mctree, idx) \
@@ -47,13 +47,13 @@ extern "C" {
mctree->nodes_length++; \
if(mctree->nodes_length >= mctree->nodes_size) { \
mctree->nodes_size = mctree->nodes_length + 4096; \
- mctree->nodes = (mctree_node_t*)myhtml_realloc(mctree->nodes, \
+ mctree->nodes = (mctree_node_t*)mycore_realloc(mctree->nodes, \
sizeof(mctree_node_t) * mctree->nodes_size); \
} \
mctree_node_clean(mctree, mctree->nodes_length)
#define mctree_make_first_idx(mctree, key, size) \
- ((myhtml_string_chars_lowercase_map[ (const unsigned char)(key[0]) ] + myhtml_string_chars_lowercase_map[ (const unsigned char)(key[size - 1]) ]) % mctree->start_size) + 1
+ ((mycore_string_chars_lowercase_map[ (const unsigned char)(key[0]) ] + mycore_string_chars_lowercase_map[ (const unsigned char)(key[size - 1]) ]) % mctree->start_size) + 1
typedef size_t mctree_index_t;
diff --git a/include/mycore/utils/mhash.h b/include/mycore/utils/mhash.h
new file mode 100644
index 0000000..0d968f7
--- /dev/null
+++ b/include/mycore/utils/mhash.h
@@ -0,0 +1,75 @@
+/*
+ Copyright (C) 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 avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyCORE_UTILS_MHASH_H
+#define MyCORE_UTILS_MHASH_H
+
+#include <string.h>
+
+#include <mycore/myosi.h>
+#include <mycore/utils/mchar_async.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct mycore_utils_mhash_entry mycore_utils_mhash_entry_t;
+
+struct mycore_utils_mhash_entry {
+ char* key;
+ size_t key_length;
+
+ void *value;
+
+ mycore_utils_mhash_entry_t* next;
+};
+
+struct mycore_utils_mhash {
+ mchar_async_t* mchar_obj;
+ size_t mchar_node;
+
+ mycore_utils_mhash_entry_t** table;
+ size_t table_size;
+ size_t table_length;
+
+ size_t table_max_depth;
+}
+typedef mycore_utils_mhash_t;
+
+mycore_utils_mhash_t * mycore_utils_mhash_create(void);
+mystatus_t mycore_utils_mhash_init(mycore_utils_mhash_t* mhash, size_t table_size, size_t depth);
+void mycore_utils_mhash_clean(mycore_utils_mhash_t* mhash);
+mycore_utils_mhash_t * mycore_utils_mhash_destroy(mycore_utils_mhash_t* mhash, bool self_destroy);
+mycore_utils_mhash_entry_t * mycore_utils_mhash_create_entry(mycore_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
+
+mycore_utils_mhash_entry_t * mycore_utils_mhash_add(mycore_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
+mycore_utils_mhash_entry_t * mycore_utils_mhash_search(mycore_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
+mycore_utils_mhash_entry_t * mycore_utils_mhash_add_with_choice(mycore_utils_mhash_t* mhash, const char* key, size_t key_size);
+
+mycore_utils_mhash_entry_t * mycore_utils_mhash_entry_by_id(mycore_utils_mhash_t* mhash, size_t id);
+size_t mycore_utils_mhash_get_table_size(mycore_utils_mhash_t* mhash);
+
+mycore_utils_mhash_entry_t ** mycore_utils_mhash_rebuld(mycore_utils_mhash_t* mhash);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyCORE_UTILS_MHASH_H */
diff --git a/include/myhtml/utils/resources.h b/include/mycore/utils/resources.h
index beee061..da99a00 100644
--- a/include/myhtml/utils/resources.h
+++ b/include/mycore/utils/resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,17 +18,17 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_RESOURCES_H
-#define MyHTML_UTILS_RESOURCES_H
+#ifndef MyCORE_UTILS_RESOURCES_H
+#define MyCORE_UTILS_RESOURCES_H
#pragma once
#include <stddef.h>
-#define MyHTML_TOKENIZER_CHAR_OTHER '\000'
-#define MyHTML_TOKENIZER_CHAR_A_Z_a_z '\001'
-#define MyHTML_TOKENIZER_CHAR_WHITESPACE '\002'
+#define MyCORE_STRING_MAP_CHAR_OTHER '\000'
+#define MyCORE_STRING_MAP_CHAR_A_Z_a_z '\001'
+#define MyCORE_STRING_MAP_CHAR_WHITESPACE '\002'
-static const unsigned char myhtml_string_chars_num_map[] = {
+static const unsigned char mycore_string_chars_num_map[] = {
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,
@@ -60,7 +60,7 @@ static const unsigned char myhtml_string_chars_num_map[] = {
0xff, 0xff, 0xff, 0xff
};
-static const unsigned char myhtml_string_chars_hex_map[] = {
+static const unsigned char mycore_string_chars_hex_map[] = {
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,
@@ -92,7 +92,7 @@ static const unsigned char myhtml_string_chars_hex_map[] = {
0xff, 0xff, 0xff, 0xff
};
-static const unsigned char myhtml_string_chars_lowercase_map[] = {
+static const unsigned char mycore_string_chars_lowercase_map[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
@@ -124,6 +124,38 @@ static const unsigned char myhtml_string_chars_lowercase_map[] = {
0xfc, 0xfd, 0xfe, 0xff
};
+static const unsigned char mycore_string_chars_uppercase_map[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
+ 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
+ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 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, 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, 0x7b, 0x7c, 0x7d,
+ 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86,
+ 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
+ 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1,
+ 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa,
+ 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3,
+ 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc,
+ 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5,
+ 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce,
+ 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0,
+ 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
+ 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2,
+ 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb,
+ 0xfc, 0xfd, 0xfe, 0xff
+};
+
static const size_t replacement_character[] = {
65533, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17,
@@ -145,7 +177,7 @@ static const size_t replacement_character[] = {
8482, 353, 8250, 339, 157, 382, 376
};
-static const size_t myhtml_string_alphanumeric_character[] = {
+static const size_t mycore_string_alphanumeric_character[] = {
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,
@@ -177,7 +209,39 @@ static const size_t myhtml_string_alphanumeric_character[] = {
0xff, 0xff, 0xff, 0xff
};
-static const unsigned char myhtml_tokenizer_chars_map[] = {
+static const size_t mycore_string_alpha_character[] = {
+ 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, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a,
+ 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d,
+ 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a,
+ 0x0b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x0d,
+ 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a,
+ 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d,
+ 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d, 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, 0xff, 0xff, 0xff
+};
+
+static const unsigned char mycore_tokenizer_chars_map[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -209,9 +273,45 @@ static const unsigned char myhtml_tokenizer_chars_map[] = {
0x00, 0x00, 0x00, 0x00
};
-static const unsigned char myhtml_string_hex_to_char_map[] = {
+static const unsigned char mycore_string_hex_to_char_map[] = {
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x00
};
-#endif /* MyHTML_UTILS_RESOURCES_H */
+static const char * mycore_string_char_to_two_hex_value[257] = {
+ "00", "01", "02", "03", "04", "05", "06", "07",
+ "08", "09", "0A", "0B", "0C", "0D", "0E", "0F",
+ "10", "11", "12", "13", "14", "15", "16", "17",
+ "18", "19", "1A", "1B", "1C", "1D", "1E", "1F",
+ "20", "21", "22", "23", "24", "25", "26", "27",
+ "28", "29", "2A", "2B", "2C", "2D", "2E", "2F",
+ "30", "31", "32", "33", "34", "35", "36", "37",
+ "38", "39", "3A", "3B", "3C", "3D", "3E", "3F",
+ "40", "41", "42", "43", "44", "45", "46", "47",
+ "48", "49", "4A", "4B", "4C", "4D", "4E", "4F",
+ "50", "51", "52", "53", "54", "55", "56", "57",
+ "58", "59", "5A", "5B", "5C", "5D", "5E", "5F",
+ "60", "61", "62", "63", "64", "65", "66", "67",
+ "68", "69", "6A", "6B", "6C", "6D", "6E", "6F",
+ "70", "71", "72", "73", "74", "75", "76", "77",
+ "78", "79", "7A", "7B", "7C", "7D", "7E", "7F",
+ "80", "81", "82", "83", "84", "85", "86", "87",
+ "88", "89", "8A", "8B", "8C", "8D", "8E", "8F",
+ "90", "91", "92", "93", "94", "95", "96", "97",
+ "98", "99", "9A", "9B", "9C", "9D", "9E", "9F",
+ "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
+ "A8", "A9", "AA", "AB", "AC", "AD", "AE", "AF",
+ "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7",
+ "B8", "B9", "BA", "BB", "BC", "BD", "BE", "BF",
+ "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7",
+ "C8", "C9", "CA", "CB", "CC", "CD", "CE", "CF",
+ "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
+ "D8", "D9", "DA", "DB", "DC", "DD", "DE", "DF",
+ "E0", "E1", "E2", "E3", "E4", "E5", "E6", "E7",
+ "E8", "E9", "EA", "EB", "EC", "ED", "EE", "EF",
+ "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7",
+ "F8", "F9", "FA", "FB", "FC", "FD", "FE", "FF",
+ NULL
+};
+
+#endif /* MyCORE_UTILS_RESOURCES_H */
diff --git a/include/mycss/an_plus_b.h b/include/mycss/an_plus_b.h
index b3d72e5..7308fc3 100644
--- a/include/mycss/an_plus_b.h
+++ b/include/mycss/an_plus_b.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -45,15 +45,15 @@ struct mycss_an_plus_b_entry {
};
mycss_an_plus_b_t * mycss_an_plus_b_create(void);
-mycss_status_t mycss_an_plus_b_init(mycss_entry_t* entry, mycss_an_plus_b_t* anb);
-mycss_status_t mycss_an_plus_b_clean_all(mycss_an_plus_b_t* anb);
+mystatus_t mycss_an_plus_b_init(mycss_entry_t* entry, mycss_an_plus_b_t* anb);
+mystatus_t mycss_an_plus_b_clean_all(mycss_an_plus_b_t* anb);
mycss_an_plus_b_t * mycss_an_plus_b_destroy(mycss_an_plus_b_t* anb, bool self_destroy);
mycss_an_plus_b_entry_t * mycss_an_plus_b_entry_create(mycss_entry_t* entry);
void mycss_an_plus_b_entry_clean_all(mycss_an_plus_b_entry_t* anb_entry);
mycss_an_plus_b_entry_t * mycss_an_plus_b_entry_destroy(mycss_entry_t* entry, mycss_an_plus_b_entry_t* anb_entry, bool self_destroy);
-void mycss_an_plus_b_serialization(mycss_an_plus_b_entry_t* anb_entry, mycss_callback_serialization_f callback, void* context);
+void mycss_an_plus_b_serialization(mycss_an_plus_b_entry_t* anb_entry, mycore_callback_serialize_f callback, void* context);
void mycss_an_plus_b_parser_expectations_error(mycss_entry_t* entry);
diff --git a/include/mycss/api.h b/include/mycss/api.h
index 02a8594..9daef46 100644
--- a/include/mycss/api.h
+++ b/include/mycss/api.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -36,10 +36,14 @@
*/
#define MyCSS_VERSION_MAJOR 0
-#define MyCSS_VERSION_MINOR 0
-#define MyCSS_VERSION_PATCH 9
+#define MyCSS_VERSION_MINOR 1
+#define MyCSS_VERSION_PATCH 0
-#include <myhtml/api.h>
+#include <mycore/myosi.h>
+#include <mycore/incoming.h>
+#include <mycore/mystring.h>
+#include <mycore/utils/mchar_async.h>
+#include <myencoding/myosi.h>
#ifdef __cplusplus
extern "C" {
@@ -52,7 +56,6 @@ extern "C" {
// base
/*
Very important!!!
- see modest/myosi.h:modest_status_tv
*/
enum mycss_status {
MyCSS_STATUS_OK = 0x000000,
@@ -185,7 +188,7 @@ mycss_create(void);
*
* @return MyCSS_STATUS_OK if successful, otherwise an error status value.
*/
-mycss_status_t
+mystatus_t
mycss_init(mycss_t* mycss);
/**
@@ -203,7 +206,7 @@ mycss_destroy(mycss_t* mycss, bool self_destroy);
* Parsing CSS
*
* @param[in] previously created structure mycss_entry_t*
- * @param[in] Now is not working! Coming Soon. Input character encoding; Default: MyHTML_ENCODING_UTF_8 or MyHTML_ENCODING_DEFAULT or 0
+ * @param[in] Now is not working! Coming Soon. Input character encoding; Default: MyENCODING_UTF_8 or MyENCODING_DEFAULT or 0
* @param[in] CSS data
* @param[in] CSS data size
*
@@ -211,8 +214,8 @@ mycss_destroy(mycss_t* mycss, bool self_destroy);
*
* @return MyCSS_STATUS_OK if successful, otherwise an error status
*/
-mycss_status_t
-mycss_parse(mycss_entry_t* entry, myhtml_encoding_t encoding, const char* css, size_t css_size);
+mystatus_t
+mycss_parse(mycss_entry_t* entry, myencoding_t encoding, const char* css, size_t css_size);
/**
* Parsing CSS chunk. For End Parsing call mycss_parse_chunk_end function
@@ -225,7 +228,7 @@ mycss_parse(mycss_entry_t* entry, myhtml_encoding_t encoding, const char* css, s
*
* @return MyCSS_STATUS_OK if successful, otherwise an error status
*/
-mycss_status_t
+mystatus_t
mycss_parse_chunk(mycss_entry_t* entry, const char* css, size_t css_size);
/**
@@ -235,7 +238,7 @@ mycss_parse_chunk(mycss_entry_t* entry, const char* css, size_t css_size);
*
* @return MyCSS_STATUS_OK if successful, otherwise an error status
*/
-mycss_status_t
+mystatus_t
mycss_parse_chunk_end(mycss_entry_t* entry);
/***********************************************************************************
@@ -260,7 +263,7 @@ mycss_entry_create(void);
*
* @return MyCSS_STATUS_OK if successful, otherwise an error status value.
*/
-mycss_status_t
+mystatus_t
mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry);
/**
@@ -270,7 +273,7 @@ mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry);
*
* @return MyCSS_STATUS_OK if successful, otherwise an error status value.
*/
-mycss_status_t
+mystatus_t
mycss_entry_clean_all(mycss_entry_t* entry);
/**
@@ -321,9 +324,9 @@ mycss_entry_token_count(mycss_entry_t* entry);
*
* @param[in] mycss_entry_t*
*
- * @return myhtml_incoming_buffer_t* if successful, otherwise an NULL value.
+ * @return mycore_incoming_buffer_t* if successful, otherwise an NULL value.
*/
-myhtml_incoming_buffer_t*
+mycore_incoming_buffer_t*
mycss_entry_incoming_buffer_current(mycss_entry_t* entry);
/**
@@ -332,9 +335,9 @@ mycss_entry_incoming_buffer_current(mycss_entry_t* entry);
*
* @param[in] mycss_entry_t*
*
- * @return myhtml_incoming_buffer_t* if successful, otherwise an NULL value.
+ * @return mycore_incoming_buffer_t* if successful, otherwise an NULL value.
*/
-myhtml_incoming_buffer_t*
+mycore_incoming_buffer_t*
mycss_entry_incoming_buffer_first(mycss_entry_t* entry);
/***********************************************************************************
@@ -400,14 +403,14 @@ mycss_token_name_by_type(mycss_token_type_t type);
*
* @param[in] mycss_entry_t*
* @param[in] mycss_token_t*, token from which data will be obtained
- * @param[in] myhtml_string_t*, a pointer to the row in which the data will be written
- * @param[in] initialization myhtml_string_t* object
+ * @param[in] mycore_string_t*, a pointer to the row in which the data will be written
+ * @param[in] initialization mycore_string_t* object
*
* @return length of processed data
*/
size_t
mycss_token_data_to_string(mycss_entry_t* entry, mycss_token_t* token,
- myhtml_string_t* str, bool init_string);
+ mycore_string_t* str, bool init_string);
/***********************************************************************************
*
@@ -424,20 +427,20 @@ mycss_token_data_to_string(mycss_entry_t* entry, mycss_token_t* token,
* @param[in] mycss_entry_t*
* @param[in] Input character encoding.
* See https://github.com/lexborisov/myhtml/blob/master/source/myhtml/api.h
- * myhtml_encoding_t
+ * myencoding_t
*
*/
void
-mycss_encoding_set(mycss_entry_t* entry, myhtml_encoding_t encoding);
+mycss_encoding_set(mycss_entry_t* entry, myencoding_t encoding);
/**
* Get character encoding for current stream
*
* @param[in] mycss_entry_t*
*
- * @return myhtml_encoding_t
+ * @return myencoding_t
*/
-myhtml_encoding_t
+myencoding_t
mycss_encoding_get(mycss_entry_t* entry);
/**
@@ -446,16 +449,16 @@ mycss_encoding_get(mycss_entry_t* entry);
* See for information:
* https://www.w3.org/TR/css-syntax-3/#get-an-encoding
* https://www.w3.org/TR/css-syntax-3/#charset-rule
- * myhtml_encoding_by_name in https://github.com/lexborisov/myhtml/blob/master/source/myhtml/api.h
+ * myencoding_by_name in https://github.com/lexborisov/myhtml/blob/master/source/myhtml/api.h
*
- * If @charset rule is missing or encoding not found return MyHTML_ENCODING_UTF_8 by default
+ * If @charset rule is missing or encoding not found return MyENCODING_UTF_8 by default
*
* @param[in] css data stream
* @param[in] css data stream size
*
- * @return myhtml_encoding_t
+ * @return myencoding_t
*/
-myhtml_encoding_t
+myencoding_t
mycss_encoding_check_charset_rule(const char* css, size_t size);
/***********************************************************************************
diff --git a/include/mycss/check.h b/include/mycss/check.h
index 2f8f39c..8b07b9e 100644
--- a/include/mycss/check.h
+++ b/include/mycss/check.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/convert.h b/include/mycss/convert.h
index 49e72d6..d36c452 100644
--- a/include/mycss/convert.h
+++ b/include/mycss/convert.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -30,7 +30,7 @@ extern "C" {
#include <mycss/entry.h>
#include <myhtml/mystring.h>
-const char * mycss_convert_split_dimension_string(myhtml_string_t* str, double* value, bool* is_float);
+const char * mycss_convert_split_dimension_string(mycore_string_t* str, double* value, bool* is_float);
size_t mycss_convert_data_to_integer(const char* data, size_t size, long* return_num);
size_t mycss_convert_data_to_double(const char *data, size_t size, double *return_num, bool* is_float);
diff --git a/include/mycss/declaration/default.h b/include/mycss/declaration/default.h
index 565e7e9..ca78c4b 100644
--- a/include/mycss/declaration/default.h
+++ b/include/mycss/declaration/default.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/declaration/default_entries.h b/include/mycss/declaration/default_entries.h
index f1d0df5..5016ec3 100644
--- a/include/mycss/declaration/default_entries.h
+++ b/include/mycss/declaration/default_entries.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/declaration/default_resources.h b/include/mycss/declaration/default_resources.h
index 9c96d47..97d6348 100644
--- a/include/mycss/declaration/default_resources.h
+++ b/include/mycss/declaration/default_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/declaration/entry.h b/include/mycss/declaration/entry.h
index 9b0d741..8975d89 100644
--- a/include/mycss/declaration/entry.h
+++ b/include/mycss/declaration/entry.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -31,7 +31,7 @@
extern "C" {
#endif
-mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, myhtml_status_t* status);
+mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, mystatus_t* status);
void mycss_declaration_entry_clean(mycss_declaration_entry_t* entry);
void mycss_declaration_entry_clean_all(mycss_declaration_entry_t* entry);
mycss_declaration_entry_t * mycss_declaration_entry_destroy(mycss_declaration_t* declaration, mycss_declaration_entry_t* decl_entry, bool self_destroy);
diff --git a/include/mycss/declaration/entry_destroy.h b/include/mycss/declaration/entry_destroy.h
index 3e6e774..454457d 100644
--- a/include/mycss/declaration/entry_destroy.h
+++ b/include/mycss/declaration/entry_destroy.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/declaration/entry_destroy_resources.h b/include/mycss/declaration/entry_destroy_resources.h
index 6d21555..206fafe 100644
--- a/include/mycss/declaration/entry_destroy_resources.h
+++ b/include/mycss/declaration/entry_destroy_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/declaration/init.h b/include/mycss/declaration/init.h
index 448290e..6db94dd 100644
--- a/include/mycss/declaration/init.h
+++ b/include/mycss/declaration/init.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -30,18 +30,18 @@ extern "C" {
#endif
mycss_declaration_t * mycss_declaration_create(void);
-mycss_status_t mycss_declaration_init(mycss_entry_t* entry, mycss_declaration_t* declaration);
+mystatus_t mycss_declaration_init(mycss_entry_t* entry, mycss_declaration_t* declaration);
void mycss_declaration_clean_all(mycss_declaration_t* declaration);
void mycss_declaration_clean(mycss_declaration_t* declaration);
mycss_declaration_t * mycss_declaration_destroy(mycss_declaration_t* declaration, bool self_destroy);
void mycss_declaration_entry_clean(mycss_declaration_entry_t* entry);
-mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, myhtml_status_t* status);
+mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, mystatus_t* status);
void mycss_declaration_entry_clean_all(mycss_declaration_entry_t* entry);
void mycss_declaration_entry_append_to_current(mycss_declaration_t* declaration, mycss_declaration_entry_t* dec_entry);
-mycss_declaration_entry_t * mycss_declaration_parse(mycss_declaration_t* declaration, myhtml_encoding_t encoding, const char* data, size_t data_size, mycss_status_t* out_status);
+mycss_declaration_entry_t * mycss_declaration_parse(mycss_declaration_t* declaration, myencoding_t encoding, const char* data, size_t data_size, mystatus_t* out_status);
mycss_token_type_t mycss_declaration_ending_token_type(mycss_declaration_t* declaration);
void mycss_declaration_ending_token_type_set(mycss_declaration_t* declaration, mycss_token_type_t ending_token_type);
diff --git a/include/mycss/declaration/myosi.h b/include/mycss/declaration/myosi.h
index b696a9e..726f001 100644
--- a/include/mycss/declaration/myosi.h
+++ b/include/mycss/declaration/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -26,7 +26,7 @@
#include <mycss/stack.h>
#include <mycss/values/units.h>
#include <mycss/property/myosi.h>
-#include <myhtml/utils/mcobject.h>
+#include <mycore/utils/mcobject.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/mycss/declaration/parser.h b/include/mycss/declaration/parser.h
index ab4e4c2..eae2ad7 100644
--- a/include/mycss/declaration/parser.h
+++ b/include/mycss/declaration/parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/declaration/serialization.h b/include/mycss/declaration/serialization.h
index 04f92e8..54a8715 100644
--- a/include/mycss/declaration/serialization.h
+++ b/include/mycss/declaration/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -32,31 +32,31 @@ extern "C" {
#endif
typedef bool (*mycss_declaration_serialization_f)(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context);
+ mycore_callback_serialize_f callback, void* context);
-bool mycss_declaration_serialization_entry(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-void mycss_declaration_serialization_entries(mycss_entry_t* entry, mycss_declaration_entry_t* first_dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_entry_only_value(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_entry_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_property_type_t property_type, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_entry_only_value_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_property_type_t property_type, mycss_callback_serialization_f callback, void* context);
+bool mycss_declaration_serialization_entry(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+void mycss_declaration_serialization_entries(mycss_entry_t* entry, mycss_declaration_entry_t* first_dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_entry_only_value(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_entry_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_property_type_t property_type, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_entry_only_value_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_property_type_t property_type, mycore_callback_serialize_f callback, void* context);
-bool mycss_declaration_serialization_undef(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_shorthand_four(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_shorthand_two(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_shorthand_two_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_type_list(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_border_radius(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_text_decoration(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_text_decoration_line(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_text_decoration_skip(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_font_family(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_font(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_background(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_background_image(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_background_repeat(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_background_position(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_background_size(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_border_x(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
+bool mycss_declaration_serialization_undef(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_shorthand_four(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_shorthand_two(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_shorthand_two_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_type_list(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_border_radius(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_text_decoration(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_text_decoration_line(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_text_decoration_skip(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_font_family(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_font(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_background(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_background_image(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_background_repeat(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_background_position(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_background_size(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_border_x(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/mycss/declaration/serialization_resources.h b/include/mycss/declaration/serialization_resources.h
index a9fa1a1..09ff31b 100644
--- a/include/mycss/declaration/serialization_resources.h
+++ b/include/mycss/declaration/serialization_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/declaration/state.h b/include/mycss/declaration/state.h
index 4616196..ce991ca 100644
--- a/include/mycss/declaration/state.h
+++ b/include/mycss/declaration/state.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/entry.h b/include/mycss/entry.h
index 35abcee..fb080d3 100644
--- a/include/mycss/entry.h
+++ b/include/mycss/entry.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -40,8 +40,8 @@ extern "C" {
#include <mycss/declaration/entry.h>
#include <mycss/media/myosi.h>
#include <mycss/media/init.h>
-#include <myhtml/utils/mcobject.h>
-#include <myhtml/utils/mchar_async.h>
+#include <mycore/utils/mcobject.h>
+#include <mycore/utils/mchar_async.h>
struct mycss_entry_parser_list_entry {
mycss_parser_token_f parser;
@@ -83,12 +83,12 @@ struct mycss_entry {
/* incoming buffer */
mcobject_t* mcobject_incoming_buffer;
- myhtml_incoming_buffer_t* first_buffer;
- myhtml_incoming_buffer_t* current_buffer;
+ mycore_incoming_buffer_t* first_buffer;
+ mycore_incoming_buffer_t* current_buffer;
/* options */
mycss_entry_type_t type;
- myhtml_encoding_t encoding;
+ myencoding_t encoding;
/* tokenizer */
mycss_tokenizer_state_t state;
@@ -112,9 +112,9 @@ struct mycss_entry {
};
mycss_entry_t * mycss_entry_create(void);
-mycss_status_t mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry);
-mycss_status_t mycss_entry_clean(mycss_entry_t* entry);
-mycss_status_t mycss_entry_clean_all(mycss_entry_t* entry);
+mystatus_t mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry);
+mystatus_t mycss_entry_clean(mycss_entry_t* entry);
+mystatus_t mycss_entry_clean_all(mycss_entry_t* entry);
mycss_entry_t * mycss_entry_destroy(mycss_entry_t* entry, bool self_destroy);
void mycss_entry_end(mycss_entry_t* entry);
@@ -125,10 +125,10 @@ mycss_selectors_t * mycss_entry_selectors(mycss_entry_t* entry);
mycss_token_ready_callback_f mycss_entry_token_ready_callback(mycss_entry_t* entry, mycss_token_ready_callback_f callback_f);
size_t mycss_entry_token_count(mycss_entry_t* entry);
-myhtml_incoming_buffer_t * mycss_entry_incoming_buffer_current(mycss_entry_t* entry);
-myhtml_incoming_buffer_t * mycss_entry_incoming_buffer_first(mycss_entry_t* entry);
+mycore_incoming_buffer_t * mycss_entry_incoming_buffer_current(mycss_entry_t* entry);
+mycore_incoming_buffer_t * mycss_entry_incoming_buffer_first(mycss_entry_t* entry);
-myhtml_string_t * mycss_entry_string_create_and_init(mycss_entry_t* entry, size_t string_size);
+mycore_string_t * mycss_entry_string_create_and_init(mycss_entry_t* entry, size_t string_size);
mycss_stylesheet_t * mycss_entry_stylesheet(mycss_entry_t* entry);
mycss_selectors_list_t * mycss_entry_current_selectors_list(mycss_entry_t* entry);
@@ -142,7 +142,7 @@ mycss_entry_parser_list_t * mycss_entry_parser_list_create_and_init(size_t size)
void mycss_entry_parser_list_clean(mycss_entry_parser_list_t* parser_list);
mycss_entry_parser_list_t * mycss_entry_parser_list_destroy(mycss_entry_parser_list_t* parser_list, bool self_destroy);
-mycss_status_t mycss_entry_parser_list_push(mycss_entry_t* entry, mycss_parser_token_f parser_func,
+mystatus_t mycss_entry_parser_list_push(mycss_entry_t* entry, mycss_parser_token_f parser_func,
mycss_parser_token_f parser_switch, mycss_token_type_t ending_token,
bool is_local);
diff --git a/include/mycss/media/init.h b/include/mycss/media/init.h
index 78c6915..9e9e8c6 100644
--- a/include/mycss/media/init.h
+++ b/include/mycss/media/init.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -29,8 +29,8 @@ extern "C" {
#endif
mycss_media_t * mycss_media_create(void);
-mycss_status_t mycss_media_init(mycss_entry_t* entry, mycss_media_t* media);
-mycss_status_t mycss_media_clean_all(mycss_media_t* media);
+mystatus_t mycss_media_init(mycss_entry_t* entry, mycss_media_t* media);
+mystatus_t mycss_media_clean_all(mycss_media_t* media);
mycss_media_t * mycss_media_destroy(mycss_media_t* media, bool self_destroy);
#ifdef __cplusplus
diff --git a/include/mycss/media/myosi.h b/include/mycss/media/myosi.h
index ef45cc3..1656c6e 100644
--- a/include/mycss/media/myosi.h
+++ b/include/mycss/media/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -32,6 +32,7 @@ typedef struct mycss_media mycss_media_t;
struct mycss_media {
+ mystatus_t error;
};
diff --git a/include/mycss/media/state.h b/include/mycss/media/state.h
index 29a4f87..439d19f 100644
--- a/include/mycss/media/state.h
+++ b/include/mycss/media/state.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/mycss.h b/include/mycss/mycss.h
index 46a34bf..701d122 100644
--- a/include/mycss/mycss.h
+++ b/include/mycss/mycss.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -26,51 +26,37 @@
extern "C" {
#endif
-#ifdef MyCSS_DEBUG
- #define MyCSS_DEBUG_MESSAGE(format, ...) \
- myhtml_print(stderr, "DEBUG: "format"\n", ##__VA_ARGS__)
-#else
- #define MyCSS_DEBUG_MESSAGE(format, ...)
-#endif
-
-#ifdef DEBUG_MODE
-#define MyHTML_DEBUG_ERROR(format, ...) \
-myhtml_print(stderr, "DEBUG ERROR: "format"\n", ##__VA_ARGS__)
-#else
-#define MyHTML_DEBUG_ERROR(format, ...)
-#endif
-
#include <mycss/myosi.h>
#include <mycss/entry.h>
#include <mycss/tokenizer.h>
#include <myhtml/myhtml.h>
-#include <myhtml/utils/mcobject_async.h>
+#include <mycore/utils/mcobject_async.h>
struct mycss {
mycss_tokenizer_state_f* parse_state_func;
};
mycss_t * mycss_create(void);
-mycss_status_t mycss_init(mycss_t* mycss);
+mystatus_t mycss_init(mycss_t* mycss);
mycss_t * mycss_destroy(mycss_t* mycss, bool self_destroy);
-mycss_status_t mycss_parse(mycss_entry_t* entry, myhtml_encoding_t encoding, const char* css, size_t css_size);
-mycss_status_t mycss_parse_chunk(mycss_entry_t* entry, const char* css, size_t css_size);
-mycss_status_t mycss_parse_chunk_end(mycss_entry_t* entry);
+mystatus_t mycss_parse(mycss_entry_t* entry, myencoding_t encoding, const char* css, size_t css_size);
+mystatus_t mycss_parse_chunk(mycss_entry_t* entry, const char* css, size_t css_size);
+mystatus_t mycss_parse_chunk_end(mycss_entry_t* entry);
size_t mycss_token_begin(mycss_token_t* token);
size_t mycss_token_length(mycss_token_t* token);
size_t mycss_token_position(mycss_token_t* token, size_t *return_length);
mycss_token_type_t mycss_token_type(mycss_token_t* token);
const char * mycss_token_name_by_type(mycss_token_type_t type);
-size_t mycss_token_data_to_string(mycss_entry_t* entry, mycss_token_t* token, myhtml_string_t* str, bool init_string, bool case_insensitive);
+size_t mycss_token_data_to_string(mycss_entry_t* entry, mycss_token_t* token, mycore_string_t* str, bool init_string, bool case_insensitive);
-myhtml_incoming_buffer_t * mycss_token_buffer_first(mycss_entry_t* entry, mycss_token_t* token);
+mycore_incoming_buffer_t * mycss_token_buffer_first(mycss_entry_t* entry, mycss_token_t* token);
// encoding
-void mycss_encoding_set(mycss_entry_t* entry, myhtml_encoding_t encoding);
-myhtml_encoding_t mycss_encoding_get(mycss_entry_t* entry);
-myhtml_encoding_t mycss_encoding_check_charset_rule(const char* css, size_t size);
+void mycss_encoding_set(mycss_entry_t* entry, myencoding_t encoding);
+myencoding_t mycss_encoding_get(mycss_entry_t* entry);
+myencoding_t mycss_encoding_check_charset_rule(const char* css, size_t size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/mycss/myosi.h b/include/mycss/myosi.h
index 5b61995..f754a0c 100644
--- a/include/mycss/myosi.h
+++ b/include/mycss/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -22,6 +22,12 @@
#define MyHTML_MyCSS_MYOSI_H
#pragma once
+#define MyCSS_VERSION_MAJOR 0
+#define MyCSS_VERSION_MINOR 1
+#define MyCSS_VERSION_PATCH 0
+
+#define MyCSS_VERSION_STRING MyCORE_STR(MyCSS_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyCSS_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyCSS_VERSION_PATCH)
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -31,7 +37,7 @@ extern "C" {
// base
/*
Very important!!!
- see modest/myosi.h:modest_status_t
+ see modest/myosi.h:mystatus_t
*/
enum mycss_status {
MyCSS_STATUS_OK = 0x000000,
@@ -260,10 +266,9 @@ typedef struct mycss_string_res mycss_string_res_t;
typedef size_t (*mycss_tokenizer_state_f)(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size);
typedef mycss_token_t * (*mycss_token_ready_callback_f)(mycss_entry_t* entry, mycss_token_t* token);
-typedef size_t (*mycss_string_process_state_f)(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
+typedef size_t (*mycss_string_process_state_f)(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
typedef bool (*mycss_parser_token_f)(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
typedef bool (*mycss_an_plus_b_state_f)(mycss_entry_t* entry, mycss_an_plus_b_t* anb, mycss_an_plus_b_entry_t* anb_entry, mycss_token_t* token);
-typedef void (*mycss_callback_serialization_f)(const char* buffer, size_t size, void* ctx);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/mycss/mystring.h b/include/mycss/mystring.h
index 7f109c0..b71c68a 100644
--- a/include/mycss/mystring.h
+++ b/include/mycss/mystring.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -27,9 +27,10 @@ extern "C" {
#endif
#include <mycss/myosi.h>
-#include <myhtml/incoming.h>
-#include <myhtml/mystring.h>
-
+#include <mycore/incoming.h>
+#include <mycore/mystring.h>
+#include <myencoding/encoding.h>
+
enum mycss_string_process_state {
MyCSS_STRING_PROCESS_STATE_DATA = 0x00,
MyCSS_STRING_PROCESS_STATE_ESCAPED = 0x01,
@@ -46,18 +47,18 @@ struct mycss_string_res {
mycss_string_escaped_res_t escaped;
mycss_string_process_state_t state;
- myhtml_encoding_t encoding;
- myhtml_encoding_result_t encoding_res;
+ myencoding_t encoding;
+ myencoding_result_t encoding_res;
bool case_insensitive;
};
-size_t mycss_string_data_process(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
-void mycss_string_data_process_end(myhtml_string_t* str, mycss_string_res_t *out_res);
+size_t mycss_string_data_process(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
+void mycss_string_data_process_end(mycore_string_t* str, mycss_string_res_t *out_res);
-size_t mycss_string_process_state_data(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
-size_t mycss_string_process_state_data_utf_8(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
-size_t mycss_string_process_state_escaped(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
-size_t mycss_string_process_state_escaped_utf_8(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
+size_t mycss_string_process_state_data(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
+size_t mycss_string_process_state_data_utf_8(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
+size_t mycss_string_process_state_escaped(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
+size_t mycss_string_process_state_escaped_utf_8(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
void mycss_string_res_clean(mycss_string_res_t* res);
void mycss_string_escaped_res_clean(mycss_string_escaped_res_t* res);
diff --git a/include/mycss/namespace/init.h b/include/mycss/namespace/init.h
index 0f1669a..dbdf139 100644
--- a/include/mycss/namespace/init.h
+++ b/include/mycss/namespace/init.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -31,16 +31,16 @@ extern "C" {
#include <myhtml/mynamespace.h>
mycss_namespace_t * mycss_namespace_create(void);
-mycss_status_t mycss_namespace_init(mycss_entry_t* entry, mycss_namespace_t* ns);
+mystatus_t mycss_namespace_init(mycss_entry_t* entry, mycss_namespace_t* ns);
void mycss_namespace_clean(mycss_namespace_t* ns);
-mycss_status_t mycss_namespace_clean_all(mycss_namespace_t* ns);
+mystatus_t mycss_namespace_clean_all(mycss_namespace_t* ns);
mycss_namespace_t * mycss_namespace_destroy(mycss_namespace_t* ns, bool self_destroy);
-mycss_status_t mycss_namespace_stylesheet_init(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry);
-mycss_status_t mycss_namespace_stylesheet_clean(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry);
+mystatus_t mycss_namespace_stylesheet_init(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry);
+mystatus_t mycss_namespace_stylesheet_clean(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry);
mycss_namespace_stylesheet_t * mycss_namespace_stylesheet_destroy(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry, bool self_destroy);
-mycss_status_t mycss_namespace_stylesheet_init_default(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry, const char* url, size_t url_length, myhtml_namespace_t def_ns);
+mystatus_t mycss_namespace_stylesheet_init_default(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry, const char* url, size_t url_length, myhtml_namespace_t def_ns);
void mycss_namespace_stylesheet_append_default(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_namespace_entry_t* ns_entry);
void mycss_namespace_stylesheet_destroy_default(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry);
diff --git a/include/mycss/namespace/myosi.h b/include/mycss/namespace/myosi.h
index 906ed18..6a50ee7 100644
--- a/include/mycss/namespace/myosi.h
+++ b/include/mycss/namespace/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -28,16 +28,16 @@ extern "C" {
#include <mycss/myosi.h>
#include <myhtml/mystring.h>
-#include <myhtml/utils/mctree.h>
-#include <myhtml/utils/mcobject.h>
+#include <mycore/utils/mctree.h>
+#include <mycore/utils/mcobject.h>
typedef struct mycss_namespace mycss_namespace_t;
typedef struct mycss_namespace_entry mycss_namespace_entry_t;
typedef struct mycss_namespace_stylesheet mycss_namespace_stylesheet_t;
struct mycss_namespace_entry {
- myhtml_string_t* name;
- myhtml_string_t* url;
+ mycore_string_t* name;
+ mycore_string_t* url;
myhtml_namespace_t ns_id;
size_t mctree_id;
diff --git a/include/mycss/namespace/parser.h b/include/mycss/namespace/parser.h
index bfec173..7f1531f 100644
--- a/include/mycss/namespace/parser.h
+++ b/include/mycss/namespace/parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -29,7 +29,7 @@ extern "C" {
#include <mycss/entry.h>
#include <mycss/namespace/myosi.h>
#include <myhtml/mynamespace.h>
-#include <myhtml/utils/mctree.h>
+#include <mycore/utils/mctree.h>
void mycss_namespace_parser_begin(mycss_entry_t* entry);
diff --git a/include/mycss/namespace/serialization.h b/include/mycss/namespace/serialization.h
index 0dd5c15..35cb036 100644
--- a/include/mycss/namespace/serialization.h
+++ b/include/mycss/namespace/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -29,8 +29,8 @@
extern "C" {
#endif
-void mycss_namespace_serialization_stylesheet(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_callback_serialization_f callback, void* context);
-void mycss_namespace_serialization_entry(mycss_namespace_t* ns, mycss_namespace_entry_t* ns_entry, mycss_callback_serialization_f callback, void* context, bool with_vbar);
+void mycss_namespace_serialization_stylesheet(mycss_namespace_stylesheet_t* ns_stylesheet, mycore_callback_serialize_f callback, void* context);
+void mycss_namespace_serialization_entry(mycss_namespace_t* ns, mycss_namespace_entry_t* ns_entry, mycore_callback_serialize_f callback, void* context, bool with_vbar);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/mycss/namespace/state.h b/include/mycss/namespace/state.h
index ee3003f..1581e11 100644
--- a/include/mycss/namespace/state.h
+++ b/include/mycss/namespace/state.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -29,7 +29,7 @@ extern "C" {
#include <mycss/entry.h>
#include <mycss/namespace/myosi.h>
#include <mycss/namespace/parser.h>
-#include <myhtml/utils.h>
+#include <mycore/utils.h>
bool mycss_namespace_state_namespace(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_namespace_state_namespace_namespace(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
diff --git a/include/mycss/parser.h b/include/mycss/parser.h
index f4c660c..6057b16 100644
--- a/include/mycss/parser.h
+++ b/include/mycss/parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -35,7 +35,7 @@ extern "C" {
#include <mycss/selectors/state.h>
#include <mycss/selectors/parser.h>
#include <mycss/declaration/state.h>
-#include <myhtml/incoming.h>
+#include <mycore/incoming.h>
mycss_token_t * mycss_parser_token_ready_callback_function(mycss_entry_t* entry, mycss_token_t* token);
diff --git a/include/mycss/property/const.h b/include/mycss/property/const.h
index cd430ea..8881359 100644
--- a/include/mycss/property/const.h
+++ b/include/mycss/property/const.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/include/mycss/property/init.h b/include/mycss/property/init.h
index 62a36c0..ad5b208 100644
--- a/include/mycss/property/init.h
+++ b/include/mycss/property/init.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -25,7 +25,7 @@
#include <mycss/property/myosi.h>
#include <mycss/property/parser.h>
#include <mycss/values/serialization.h>
-#include <myhtml/utils.h>
+#include <mycore/utils.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/mycss/property/myosi.h b/include/mycss/property/myosi.h
index 1dce753..7f32e55 100644
--- a/include/mycss/property/myosi.h
+++ b/include/mycss/property/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/property/parser.h b/include/mycss/property/parser.h
index 3ff15e5..76694ea 100644
--- a/include/mycss/property/parser.h
+++ b/include/mycss/property/parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -34,7 +34,7 @@ extern "C" {
/* custom added */
bool mycss_property_parser_background_position_check(mycss_values_background_position_t *position);
-bool mycss_property_parser_destroy_string(myhtml_string_t* str, bool return_value);
+bool mycss_property_parser_destroy_string(mycore_string_t* str, bool return_value);
bool mycss_property_parser_switcher_to_find_important(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_property_parser_text_decoration_line_not_none(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_property_parser_text_decoration_line_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
diff --git a/include/mycss/property/resources.h b/include/mycss/property/resources.h
index dd9d86a..b42e068 100644
--- a/include/mycss/property/resources.h
+++ b/include/mycss/property/resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/property/resources_name.h b/include/mycss/property/resources_name.h
index ad25497..45a04de 100644
--- a/include/mycss/property/resources_name.h
+++ b/include/mycss/property/resources_name.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/property/serialization.h b/include/mycss/property/serialization.h
index 748d52d..9a88c62 100644
--- a/include/mycss/property/serialization.h
+++ b/include/mycss/property/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -30,8 +30,8 @@
extern "C" {
#endif
-void mycss_property_serialization_type_name(mycss_property_type_t prop_type, mycss_callback_serialization_f callback, void* context);
-void mycss_property_serialization_value(unsigned int value_type, void* value, mycss_callback_serialization_f callback, void* context);
+void mycss_property_serialization_type_name(mycss_property_type_t prop_type, mycore_callback_serialize_f callback, void* context);
+void mycss_property_serialization_value(unsigned int value_type, void* value, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/mycss/property/shared.h b/include/mycss/property/shared.h
index dd05f10..eaa0bbf 100644
--- a/include/mycss/property/shared.h
+++ b/include/mycss/property/shared.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -27,7 +27,7 @@
#include <mycss/values/values.h>
#include <mycss/values/color.h>
#include <mycss/values/image.h>
-#include <myhtml/utils.h>
+#include <mycore/utils.h>
#ifdef __cplusplus
extern "C" {
@@ -37,42 +37,42 @@ bool mycss_property_shared_switch_to_find_important(mycss_entry_t* entry);
bool mycss_property_shared_switch_to_parse_error(mycss_entry_t* entry);
bool mycss_property_shared_check_declaration_end(mycss_entry_t* entry, mycss_token_t* token);
-bool mycss_property_shared_number(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_length(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_percentage(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_length_percentage(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_resolution(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
+bool mycss_property_shared_number(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_length(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_percentage(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_length_percentage(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_resolution(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
bool mycss_property_shared_custom_ident(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type);
-bool mycss_property_shared_color(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str, bool* parser_changed);
-bool mycss_property_shared_default(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-unsigned int mycss_property_shared_get_value_type(mycss_entry_t* entry, mycss_token_t* token, myhtml_string_t* str);
-bool mycss_property_shared_by_value_type(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, unsigned int check_type, myhtml_string_t* str);
-bool mycss_property_shared_width(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_height(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_line_width(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_line_height(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_line_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_text_decoration_skip(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value, unsigned int* value_type, myhtml_string_t* str, bool with_global);
-bool mycss_property_shared_text_decoration_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_text_decoration_line(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value, unsigned int* value_type, myhtml_string_t* str, bool with_global);
+bool mycss_property_shared_color(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str, bool* parser_changed);
+bool mycss_property_shared_default(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+unsigned int mycss_property_shared_get_value_type(mycss_entry_t* entry, mycss_token_t* token, mycore_string_t* str);
+bool mycss_property_shared_by_value_type(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, unsigned int check_type, mycore_string_t* str);
+bool mycss_property_shared_width(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_height(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_line_width(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_line_height(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_line_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_text_decoration_skip(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value, unsigned int* value_type, mycore_string_t* str, bool with_global);
+bool mycss_property_shared_text_decoration_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_text_decoration_line(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value, unsigned int* value_type, mycore_string_t* str, bool with_global);
-bool mycss_property_shared_font_ends(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_font_weight(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_font_size(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_font_stretch(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_font_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_font_family(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, bool *dont_destroy_str, myhtml_string_t* str);
+bool mycss_property_shared_font_ends(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_font_weight(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_font_size(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_font_stretch(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_font_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_font_family(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, bool *dont_destroy_str, mycore_string_t* str);
-bool mycss_property_shared_image(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str, bool* parser_changed);
+bool mycss_property_shared_image(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str, bool* parser_changed);
-bool mycss_property_shared_background_repeat_one(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_background_repeat_two(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_background_attachment(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_background_position(mycss_entry_t* entry, mycss_token_t* token, void* value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_background_clip(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_background_size(mycss_entry_t* entry, mycss_token_t* token, void* value, unsigned int* value_type, myhtml_string_t* str);
+bool mycss_property_shared_background_repeat_one(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_background_repeat_two(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_background_attachment(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_background_position(mycss_entry_t* entry, mycss_token_t* token, void* value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_background_clip(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_background_size(mycss_entry_t* entry, mycss_token_t* token, void* value, unsigned int* value_type, mycore_string_t* str);
-void mycss_property_shared_destroy_string(myhtml_string_t* str);
+void mycss_property_shared_destroy_string(mycore_string_t* str);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/mycss/selectors/function.h b/include/mycss/selectors/function.h
index 7f73f05..7b2d4d3 100644
--- a/include/mycss/selectors/function.h
+++ b/include/mycss/selectors/function.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/selectors/function_parser.h b/include/mycss/selectors/function_parser.h
index f619dd3..2a7e690 100644
--- a/include/mycss/selectors/function_parser.h
+++ b/include/mycss/selectors/function_parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/selectors/function_resource.h b/include/mycss/selectors/function_resource.h
index a3a369e..67c48ac 100644
--- a/include/mycss/selectors/function_resource.h
+++ b/include/mycss/selectors/function_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/selectors/init.h b/include/mycss/selectors/init.h
index 0004125..a2f6f21 100644
--- a/include/mycss/selectors/init.h
+++ b/include/mycss/selectors/init.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -31,9 +31,9 @@ extern "C" {
#include <mycss/selectors/list.h>
mycss_selectors_t * mycss_selectors_create(void);
-mycss_status_t mycss_selectors_init(mycss_entry_t* entry, mycss_selectors_t* selectors);
+mystatus_t mycss_selectors_init(mycss_entry_t* entry, mycss_selectors_t* selectors);
void mycss_selectors_clean(mycss_selectors_t* selectors);
-mycss_status_t mycss_selectors_clean_all(mycss_selectors_t* selectors);
+mystatus_t mycss_selectors_clean_all(mycss_selectors_t* selectors);
mycss_selectors_t * mycss_selectors_destroy(mycss_selectors_t* selectors, bool self_destroy);
void mycss_selectors_entry_clean(mycss_selectors_entry_t* sel_entry);
@@ -41,8 +41,8 @@ mycss_selectors_entry_t * mycss_selectors_entry_destroy(mycss_selectors_t* selec
void * mycss_selectors_entry_value_destroy(mycss_entry_t* entry, mycss_selectors_entry_t* selector_entry, bool destroy_self);
-mycss_selectors_list_t * mycss_selectors_parse(mycss_selectors_t* selectors, myhtml_encoding_t encoding, const char* data, size_t data_size, mycss_status_t* out_status);
-mycss_selectors_list_t * mycss_selectors_parse_by_function(mycss_selectors_t* selectors, mycss_parser_token_f func, myhtml_encoding_t encoding, const char* data, size_t data_size, mycss_status_t* out_status);
+mycss_selectors_list_t * mycss_selectors_parse(mycss_selectors_t* selectors, myencoding_t encoding, const char* data, size_t data_size, mystatus_t* out_status);
+mycss_selectors_list_t * mycss_selectors_parse_by_function(mycss_selectors_t* selectors, mycss_parser_token_f func, myencoding_t encoding, const char* data, size_t data_size, mystatus_t* out_status);
mycss_selectors_entry_t * mycss_selectors_entry_find_first(mycss_selectors_entry_t* selector);
diff --git a/include/mycss/selectors/list.h b/include/mycss/selectors/list.h
index 1320494..a46d519 100644
--- a/include/mycss/selectors/list.h
+++ b/include/mycss/selectors/list.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/selectors/myosi.h b/include/mycss/selectors/myosi.h
index a255e75..525bf00 100644
--- a/include/mycss/selectors/myosi.h
+++ b/include/mycss/selectors/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -36,7 +36,7 @@ typedef struct mycss_selectors_specificity mycss_selectors_specificity_t;
#include <mycss/mystring.h>
#include <mycss/namespace/myosi.h>
#include <mycss/declaration/myosi.h>
-#include <myhtml/utils/mcobject.h>
+#include <mycore/utils/mcobject.h>
typedef bool (*mycss_selectors_state_f)(mycss_entry_t* entry, mycss_selectors_t* selectors, mycss_selectors_entry_t* selector, mycss_token_t* token);
typedef void (*mycss_callback_selector_done_f)(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector);
@@ -218,7 +218,7 @@ struct mycss_selectors_entry {
mycss_namespace_entry_t* ns_entry;
- myhtml_string_t* key;
+ mycore_string_t* key;
void* value;
mycss_selectors_combinator_t combinator;
diff --git a/include/mycss/selectors/myosi_resource.h b/include/mycss/selectors/myosi_resource.h
index 70a0b6a..21baa67 100644
--- a/include/mycss/selectors/myosi_resource.h
+++ b/include/mycss/selectors/myosi_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/selectors/parser.h b/include/mycss/selectors/parser.h
index f8be137..6eab0e9 100644
--- a/include/mycss/selectors/parser.h
+++ b/include/mycss/selectors/parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/selectors/pseudo.h b/include/mycss/selectors/pseudo.h
index 470ba8d..c16fb0d 100644
--- a/include/mycss/selectors/pseudo.h
+++ b/include/mycss/selectors/pseudo.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/selectors/pseudo_resource.h b/include/mycss/selectors/pseudo_resource.h
index 4bb9994..9a8ce37 100644
--- a/include/mycss/selectors/pseudo_resource.h
+++ b/include/mycss/selectors/pseudo_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/selectors/serialization.h b/include/mycss/selectors/serialization.h
index e2038d5..c0bd64e 100644
--- a/include/mycss/selectors/serialization.h
+++ b/include/mycss/selectors/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -30,9 +30,9 @@ extern "C" {
#include <mycss/namespace/serialization.h>
#include <mycss/declaration/serialization.h>
-void mycss_selectors_serialization_chain(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector, mycss_callback_serialization_f callback, void* context);
-bool mycss_selectors_serialization_list(mycss_selectors_t* selectors, mycss_selectors_list_t* selectors_list, mycss_callback_serialization_f callback, void* context);
-bool mycss_selectors_serialization_selector(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector, mycss_callback_serialization_f callback, void* context);
+void mycss_selectors_serialization_chain(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector, mycore_callback_serialize_f callback, void* context);
+bool mycss_selectors_serialization_list(mycss_selectors_t* selectors, mycss_selectors_list_t* selectors_list, mycore_callback_serialize_f callback, void* context);
+bool mycss_selectors_serialization_selector(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/mycss/selectors/state.h b/include/mycss/selectors/state.h
index 5753e7a..62f7fc8 100644
--- a/include/mycss/selectors/state.h
+++ b/include/mycss/selectors/state.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -29,7 +29,7 @@ extern "C" {
#include <mycss/entry.h>
#include <mycss/selectors/myosi.h>
#include <mycss/selectors/parser.h>
-#include <myhtml/utils.h>
+#include <mycore/utils.h>
void mycss_selectors_state_end(mycss_entry_t* entry);
bool mycss_selectors_state_function_skip_all(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
diff --git a/include/mycss/selectors/value.h b/include/mycss/selectors/value.h
index 35c93cc..f7db204 100644
--- a/include/mycss/selectors/value.h
+++ b/include/mycss/selectors/value.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -23,7 +23,7 @@
#pragma once
#define mycss_selector_value_attribute(obj) ((mycss_selectors_object_attribute_t*)(obj))
-#define mycss_selector_value_string(obj) ((myhtml_string_t*)(obj))
+#define mycss_selector_value_string(obj) ((mycore_string_t*)(obj))
#define mycss_selector_value_an_plus_b(obj) ((mycss_an_plus_b_entry_t*)(obj))
#define mycss_selector_value_drop(obj) ((mycss_selectors_function_drop_type_t)(obj))
#define mycss_selector_value_lang(obj) ((mycss_selectors_value_lang_t*)(obj))
@@ -36,13 +36,13 @@ extern "C" {
#include <mycss/entry.h>
#include <mycss/selectors/myosi.h>
-#include <myhtml/utils/mchar_async.h>
+#include <mycore/utils/mchar_async.h>
typedef void * (*mycss_selectors_value_destroy_f)(mycss_entry_t* entry, mycss_selectors_type_t type, int sub_type, void* value, bool self_destroy);
typedef void * (*mycss_selectors_value_function_destroy_f)(mycss_entry_t* entry, void* value, bool self_destroy);
struct mycss_selectors_value_attribute {
- myhtml_string_t* value;
+ mycore_string_t* value;
mycss_selectors_match_t match;
mycss_selectors_mod_t mod;
@@ -50,7 +50,7 @@ struct mycss_selectors_value_attribute {
typedef mycss_selectors_object_attribute_t;
struct mycss_selectors_value_lang {
- myhtml_string_t str;
+ mycore_string_t str;
struct mycss_selectors_value_lang* next;
}
typedef mycss_selectors_value_lang_t;
diff --git a/include/mycss/selectors/value_resource.h b/include/mycss/selectors/value_resource.h
index f40fdb0..7bbc06d 100644
--- a/include/mycss/selectors/value_resource.h
+++ b/include/mycss/selectors/value_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/stack.h b/include/mycss/stack.h
index 7a272d7..b50fb0f 100644
--- a/include/mycss/stack.h
+++ b/include/mycss/stack.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -42,11 +42,11 @@ struct mycss_stack {
typedef mycss_stack_t;
mycss_stack_t * mycss_stack_create(void);
-mycss_status_t mycss_stack_init(mycss_stack_t *stack, size_t size);
+mystatus_t mycss_stack_init(mycss_stack_t *stack, size_t size);
void mycss_stack_clean(mycss_stack_t *stack);
mycss_stack_t * mycss_stack_destroy(mycss_stack_t *stack, bool self_destroy);
-mycss_status_t mycss_stack_push(mycss_stack_t *stack, void* value, mycss_parser_token_f parser);
+mystatus_t mycss_stack_push(mycss_stack_t *stack, void* value, mycss_parser_token_f parser);
mycss_stack_entry_t * mycss_stack_pop(mycss_stack_t *stack);
mycss_stack_entry_t * mycss_stack_current(mycss_stack_t *stack);
diff --git a/include/mycss/stylesheet.h b/include/mycss/stylesheet.h
index 523d3d1..7b3fb7e 100644
--- a/include/mycss/stylesheet.h
+++ b/include/mycss/stylesheet.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -45,11 +45,11 @@ struct mycss_stylesheet {
};
mycss_stylesheet_t * mycss_stylesheet_create(void);
-mycss_status_t mycss_stylesheet_init(mycss_stylesheet_t* stylesheet, mycss_entry_t* entry);
-mycss_status_t mycss_stylesheet_clean_all(mycss_stylesheet_t* stylesheet);
+mystatus_t mycss_stylesheet_init(mycss_stylesheet_t* stylesheet, mycss_entry_t* entry);
+mystatus_t mycss_stylesheet_clean_all(mycss_stylesheet_t* stylesheet);
mycss_stylesheet_t * mycss_stylesheet_destroy(mycss_stylesheet_t* stylesheet, bool self_destroy);
-void mycss_stylesheet_serialization(mycss_stylesheet_t* stylesheet, mycss_callback_serialization_f callback, void* context);
+void mycss_stylesheet_serialization(mycss_stylesheet_t* stylesheet, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/mycss/tokenizer.h b/include/mycss/tokenizer.h
index 1fa7609..fac9b84 100644
--- a/include/mycss/tokenizer.h
+++ b/include/mycss/tokenizer.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -33,7 +33,7 @@ extern "C" {
#include <mycss/tokenizer_global.h>
#include <mycss/tokenizer_end.h>
-#include <myhtml/incoming.h>
+#include <mycore/incoming.h>
#define MyCSS_TOKEN_READY_CALLBACK_FUNCTION(ENTRY, TOKEN) \
++ENTRY->token_counter; \
@@ -53,12 +53,12 @@ struct mycss_token {
const char* data;
};
-mycss_status_t mycss_tokenizer_state_init(mycss_t* mycss);
+mystatus_t mycss_tokenizer_state_init(mycss_t* mycss);
void mycss_tokenizer_state_destroy(mycss_t* mycss);
-mycss_status_t mycss_tokenizer_chunk(mycss_entry_t* entry, const char* css, size_t css_length);
-mycss_status_t mycss_tokenizer_process(mycss_entry_t* entry, const char* css, size_t css_length);
-mycss_status_t mycss_tokenizer_end(mycss_entry_t* entry);
+mystatus_t mycss_tokenizer_chunk(mycss_entry_t* entry, const char* css, size_t css_length);
+mystatus_t mycss_tokenizer_process(mycss_entry_t* entry, const char* css, size_t css_length);
+mystatus_t mycss_tokenizer_end(mycss_entry_t* entry);
size_t mycss_tokenizer_run_state_single(mycss_entry_t* entry, mycss_tokenizer_state_t state, const char* css, size_t css_offset, size_t css_size);
size_t mycss_tokenizer_state_set_current_buffer_for_continue(mycss_entry_t* entry, size_t css_offset, size_t css_minus_offset);
diff --git a/include/mycss/tokenizer_end.h b/include/mycss/tokenizer_end.h
index f7c4e61..6daafce 100644
--- a/include/mycss/tokenizer_end.h
+++ b/include/mycss/tokenizer_end.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/tokenizer_global.h b/include/mycss/tokenizer_global.h
index 4a9d5da..30f3691 100644
--- a/include/mycss/tokenizer_global.h
+++ b/include/mycss/tokenizer_global.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/tokenizer_resource.h b/include/mycss/tokenizer_resource.h
index 623a904..4d39109 100644
--- a/include/mycss/tokenizer_resource.h
+++ b/include/mycss/tokenizer_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/values/color.h b/include/mycss/values/color.h
index fa92a7e..35e1919 100644
--- a/include/mycss/values/color.h
+++ b/include/mycss/values/color.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/values/color_const.h b/include/mycss/values/color_const.h
index fb28243..0c614b8 100644
--- a/include/mycss/values/color_const.h
+++ b/include/mycss/values/color_const.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/include/mycss/values/color_parser.h b/include/mycss/values/color_parser.h
index 0261c4e..bb26830 100644
--- a/include/mycss/values/color_parser.h
+++ b/include/mycss/values/color_parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -55,7 +55,7 @@ bool mycss_values_color_parser_hsl_lightness(mycss_entry_t* entry, mycss_token_t
bool mycss_values_color_parser_hsl_before_alpha(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_values_color_parser_hsl_alpha(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
-bool mycss_values_color_parser_hex(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
+bool mycss_values_color_parser_hex(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
bool mycss_values_color_parser_hwb(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_values_color_parser_hwb_before_whiteness(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
diff --git a/include/mycss/values/color_resources.h b/include/mycss/values/color_resources.h
index b06cba3..108a410 100644
--- a/include/mycss/values/color_resources.h
+++ b/include/mycss/values/color_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/values/consume.h b/include/mycss/values/consume.h
index 2113db7..5c69578 100644
--- a/include/mycss/values/consume.h
+++ b/include/mycss/values/consume.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/values/destroy.h b/include/mycss/values/destroy.h
index 29670a0..651ec76 100644
--- a/include/mycss/values/destroy.h
+++ b/include/mycss/values/destroy.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/values/image.h b/include/mycss/values/image.h
index ed6b9dc..efa5632 100644
--- a/include/mycss/values/image.h
+++ b/include/mycss/values/image.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/values/image_resources.h b/include/mycss/values/image_resources.h
index a612ec7..02863c9 100644
--- a/include/mycss/values/image_resources.h
+++ b/include/mycss/values/image_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/values/resources.h b/include/mycss/values/resources.h
index 1c7efd4..faf67a5 100644
--- a/include/mycss/values/resources.h
+++ b/include/mycss/values/resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/values/serialization.h b/include/mycss/values/serialization.h
index 5ff89bf..871ccdb 100644
--- a/include/mycss/values/serialization.h
+++ b/include/mycss/values/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -30,21 +30,21 @@ extern "C" {
#include <mycss/values/color.h>
#include <mycss/property/const.h>
-void mycss_values_serialization_string(myhtml_string_t* str, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_number(mycss_values_number_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_length(mycss_values_length_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_angle(mycss_values_angle_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_resolution(mycss_values_resolution_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_percentage(mycss_values_percentage_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_type_length_percentage(mycss_values_type_length_percentage_entry_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_color_alpha(mycss_values_color_alpha_value_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_text_decoration_line(mycss_values_text_decoration_line_t value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_text_decoration_skip(mycss_values_text_decoration_skip_t value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_url(mycss_values_url_t* url, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_image(mycss_values_image_t* image, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_background_size_entry(mycss_values_background_size_entry_t* bg_size_entry, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_border(mycss_values_border_t* border, mycss_callback_serialization_f callback, void* context);
+void mycss_values_serialization_string(mycore_string_t* str, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_number(mycss_values_number_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_length(mycss_values_length_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_angle(mycss_values_angle_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_resolution(mycss_values_resolution_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_percentage(mycss_values_percentage_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_type_length_percentage(mycss_values_type_length_percentage_entry_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_color(mycss_values_color_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_color_alpha(mycss_values_color_alpha_value_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_text_decoration_line(mycss_values_text_decoration_line_t value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_text_decoration_skip(mycss_values_text_decoration_skip_t value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_url(mycss_values_url_t* url, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_image(mycss_values_image_t* image, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_background_size_entry(mycss_values_background_size_entry_t* bg_size_entry, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_border(mycss_values_border_t* border, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/mycss/values/units.h b/include/mycss/values/units.h
index 4d1a7ef..e506f84 100644
--- a/include/mycss/values/units.h
+++ b/include/mycss/values/units.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -23,7 +23,7 @@
#pragma once
#include <mycss/myosi.h>
-#include <myhtml/utils.h>
+#include <mycore/utils.h>
#define mycss_units_is_angel_type(type) (type >= 1 && type <= 4)
#define mycss_units_is_frequency_type(type) (type >= 5 && type <= 6)
diff --git a/include/mycss/values/units_resources.h b/include/mycss/values/units_resources.h
index 7d7c8e1..e602fac 100644
--- a/include/mycss/values/units_resources.h
+++ b/include/mycss/values/units_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/include/mycss/values/values.h b/include/mycss/values/values.h
index 5dfe23f..d05cc9f 100644
--- a/include/mycss/values/values.h
+++ b/include/mycss/values/values.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -26,7 +26,7 @@
#include <mycss/values/units.h>
#include <mycss/values/color_const.h>
#include <mycss/property/const.h>
-#include <myhtml/utils/mchar_async.h>
+#include <mycore/utils/mchar_async.h>
#include <myhtml/mystring.h>
#include <mycss/declaration/myosi.h>
@@ -115,12 +115,13 @@ struct mycss_values_type_list {
size_t entries_length;
};
-struct mycss_values_type_length_percentage_entry {
- union {
- mycss_values_percentage_t* percentage;
- mycss_values_length_t* length;
- };
+union mycss_values_type_length_percentage_union {
+ mycss_values_percentage_t* percentage;
+ mycss_values_length_t* length;
+};
+struct mycss_values_type_length_percentage_entry {
+ union mycss_values_type_length_percentage_union value;
unsigned int type;
};
@@ -128,7 +129,7 @@ struct mycss_values_number {
union {
int i;
float f;
- };
+ } value;
bool is_float;
};
@@ -137,9 +138,10 @@ struct mycss_values_length {
union {
int i;
float f;
- };
+ } value;
bool is_float;
+
mycss_units_type_t type;
};
@@ -147,7 +149,7 @@ struct mycss_values_percentage {
union {
int i;
float f;
- };
+ } value;
bool is_float;
};
@@ -156,7 +158,7 @@ struct mycss_values_angle {
union {
int i;
float f;
- };
+ } value;
bool is_float;
mycss_units_type_t type;
@@ -166,14 +168,14 @@ struct mycss_values_resolution {
union {
int i;
float f;
- };
+ } value;
bool is_float;
mycss_units_type_t type;
};
struct mycss_values_custom_ident {
- myhtml_string_t str;
+ mycore_string_t str;
};
/*
@@ -211,7 +213,7 @@ struct mycss_values_color_alpha_value {
union {
mycss_values_number_t number;
mycss_values_percentage_t percentage;
- };
+ } value;
mycss_values_color_type_value_t type_value;
};
@@ -220,7 +222,7 @@ struct mycss_values_color_hue_value {
union {
mycss_values_number_t number;
mycss_values_angle_t angle;
- };
+ } value;
mycss_values_color_type_value_t type_value;
};
@@ -267,7 +269,7 @@ struct mycss_values_color {
mycss_values_color_hwb_t hwb;
mycss_values_color_gray_t gray;
mycss_values_color_id_t name_id;
- };
+ } value;
mycss_values_color_type_t type;
mycss_values_color_type_value_t type_value;
@@ -287,7 +289,7 @@ struct mycss_values_color_stop_list {
URL
*/
struct mycss_values_url {
- myhtml_string_t str;
+ mycore_string_t str;
};
/*
@@ -308,7 +310,7 @@ struct mycss_values_image {
mycss_values_image_image_set_t* ii_set;
mycss_values_element_t* element;
mycss_values_cross_fade_t* cross_fade;
- };
+ } value;
mycss_property_value_t type;
};
@@ -320,14 +322,14 @@ struct mycss_values_image_list {
/* image() */
struct mycss_values_image_image {
- myhtml_string_t* str;
+ mycore_string_t* str;
mycss_values_image_t* image;
mycss_values_color_t* color;
};
/* image-set() */
struct mycss_values_image_image_set_option {
- myhtml_string_t* str;
+ mycore_string_t* str;
mycss_values_image_t* image;
mycss_values_resolution_t* resolution;
};
@@ -378,7 +380,7 @@ struct mycss_values_gradient_linear {
union {
mycss_values_angle_t angle;
mycss_values_gradient_side_or_corner_t side_or_corner;
- };
+ } value;
mycss_values_color_stop_list_t color_stop_list;
};
@@ -398,9 +400,9 @@ typedef mycss_values_font_family_type_t;
struct mycss_values_font_family_entry {
union {
- myhtml_string_t str;
+ mycore_string_t str;
mycss_property_font_family_t prop_type;
- };
+ } value;
mycss_values_font_family_type_t type;
};
diff --git a/include/myhtml/encoding_detect_resource.h b/include/myencoding/detect_resource.h
index 5fdea8b..3aba646 100644
--- a/include/myhtml/encoding_detect_resource.h
+++ b/include/myencoding/detect_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,19 +18,19 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_ENCODING_DETECT_RESOURCE_H
-#define MyHTML_ENCODING_DETECT_RESOURCE_H
+#ifndef MyENCODING_DETECT_RESOURCE_H
+#define MyENCODING_DETECT_RESOURCE_H
#pragma once
#ifdef __cplusplus
-//extern "C" {
+extern "C" {
#endif
-#define MyHTML_ENCODING_DETECT_NAME_STATIC_SIZE 419
+#define MyENCODING_DETECT_NAME_STATIC_SIZE 419
-#include <myhtml/encoding.h>
+#include <myencoding/encoding.h>
-static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_entry_static_list_index[] =
+static const myencoding_detect_name_entry_t myencoding_detect_name_entry_static_list_index[] =
{
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -39,21 +39,21 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1257", 12, "x-cp1257", 8, MyHTML_ENCODING_WINDOWS_1257, 0, 7},
+ {"windows-1257", 12, "x-cp1257", 8, MyENCODING_WINDOWS_1257, 0, 7},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-874", 11, "tis-620", 7, MyHTML_ENCODING_WINDOWS_874, 0, 10},
- {"iso-8859-3", 10, "iso8859-3", 9, MyHTML_ENCODING_ISO_8859_3, 420, 11},
+ {"windows-874", 11, "tis-620", 7, MyENCODING_WINDOWS_874, 0, 10},
+ {"iso-8859-3", 10, "iso8859-3", 9, MyENCODING_ISO_8859_3, 420, 11},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"shift_jis", 9, "ms932", 5, MyHTML_ENCODING_SHIFT_JIS, 0, 16},
- {"gbk", 3, "gb_2312", 7, MyHTML_ENCODING_GBK, 421, 17},
+ {"shift_jis", 9, "ms932", 5, MyENCODING_SHIFT_JIS, 0, 16},
+ {"gbk", 3, "gb_2312", 7, MyENCODING_GBK, 421, 17},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-7", 10, "iso8859-7", 9, MyHTML_ENCODING_ISO_8859_7, 422, 20},
- {"windows-1250", 12, "cp1250", 6, MyHTML_ENCODING_WINDOWS_1250, 423, 21},
+ {"iso-8859-7", 10, "iso8859-7", 9, MyENCODING_ISO_8859_7, 422, 20},
+ {"windows-1250", 12, "cp1250", 6, MyENCODING_WINDOWS_1250, 423, 21},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -62,9 +62,9 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"shift_jis", 9, "shift-jis", 9, MyHTML_ENCODING_SHIFT_JIS, 424, 30},
- {"ibm866", 6, "csibm866", 8, MyHTML_ENCODING_IBM866, 425, 31},
- {"euc-kr", 6, "windows-949", 11, MyHTML_ENCODING_EUC_KR, 0, 32},
+ {"shift_jis", 9, "shift-jis", 9, MyENCODING_SHIFT_JIS, 424, 30},
+ {"ibm866", 6, "csibm866", 8, MyENCODING_IBM866, 425, 31},
+ {"euc-kr", 6, "windows-949", 11, MyENCODING_EUC_KR, 0, 32},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -72,33 +72,33 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-2022-jp", 11, "csiso2022jp", 11, MyHTML_ENCODING_ISO_2022_JP, 0, 40},
+ {"iso-2022-jp", 11, "csiso2022jp", 11, MyENCODING_ISO_2022_JP, 0, 40},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-15", 11, "iso-8859-15", 11, MyHTML_ENCODING_ISO_8859_15, 426, 42},
+ {"iso-8859-15", 11, "iso-8859-15", 11, MyENCODING_ISO_8859_15, 426, 42},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-kr", 6, "ksc_5601", 8, MyHTML_ENCODING_EUC_KR, 0, 45},
+ {"euc-kr", 6, "ksc_5601", 8, MyENCODING_EUC_KR, 0, 45},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"gbk", 3, "csiso58gb231280", 15, MyHTML_ENCODING_GBK, 0, 51},
+ {"gbk", 3, "csiso58gb231280", 15, MyENCODING_GBK, 0, 51},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-5", 10, "cyrillic", 8, MyHTML_ENCODING_ISO_8859_5, 0, 56},
+ {"iso-8859-5", 10, "cyrillic", 8, MyENCODING_ISO_8859_5, 0, 56},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1255", 12, "cp1255", 6, MyHTML_ENCODING_WINDOWS_1255, 427, 58},
+ {"windows-1255", 12, "cp1255", 6, MyENCODING_WINDOWS_1255, 427, 58},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1254", 12, "x-cp1254", 8, MyHTML_ENCODING_WINDOWS_1254, 0, 60},
+ {"windows-1254", 12, "x-cp1254", 8, MyENCODING_WINDOWS_1254, 0, 60},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-15", 11, "csisolatin9", 11, MyHTML_ENCODING_ISO_8859_15, 0, 62},
- {"koi8-u", 6, "koi8-ru", 7, MyHTML_ENCODING_KOI8_U, 0, 63},
- {"iso-8859-4", 10, "csisolatin4", 11, MyHTML_ENCODING_ISO_8859_4, 0, 64},
+ {"iso-8859-15", 11, "csisolatin9", 11, MyENCODING_ISO_8859_15, 0, 62},
+ {"koi8-u", 6, "koi8-ru", 7, MyENCODING_KOI8_U, 0, 63},
+ {"iso-8859-4", 10, "csisolatin4", 11, MyENCODING_ISO_8859_4, 0, 64},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"shift_jis", 9, "windows-31j", 11, MyHTML_ENCODING_SHIFT_JIS, 0, 66},
+ {"shift_jis", 9, "windows-31j", 11, MyENCODING_SHIFT_JIS, 0, 66},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -111,14 +111,14 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"utf-8", 5, "utf-8", 5, MyHTML_ENCODING_UTF_8, 0, 79},
+ {"utf-8", 5, "utf-8", 5, MyENCODING_UTF_8, 0, 79},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"ibm866", 6, "ibm866", 6, MyHTML_ENCODING_IBM866, 0, 82},
+ {"ibm866", 6, "ibm866", 6, MyENCODING_IBM866, 0, 82},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"koi8-r", 6, "koi8", 4, MyHTML_ENCODING_KOI8_R, 0, 86},
+ {"koi8-r", 6, "koi8", 4, MyENCODING_KOI8_R, 0, 86},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -126,62 +126,62 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"gbk", 3, "x-gbk", 5, MyHTML_ENCODING_GBK, 428, 94},
- {"iso-8859-7", 10, "csisolatingreek", 15, MyHTML_ENCODING_ISO_8859_7, 0, 95},
+ {"gbk", 3, "x-gbk", 5, MyENCODING_GBK, 428, 94},
+ {"iso-8859-7", 10, "csisolatingreek", 15, MyENCODING_ISO_8859_7, 0, 95},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "iso88591", 8, MyHTML_ENCODING_WINDOWS_1252, 0, 99},
+ {"windows-1252", 12, "iso88591", 8, MyENCODING_WINDOWS_1252, 0, 99},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "iso88592", 8, MyHTML_ENCODING_ISO_8859_2, 0, 101},
+ {"iso-8859-2", 10, "iso88592", 8, MyENCODING_ISO_8859_2, 0, 101},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-3", 10, "iso88593", 8, MyHTML_ENCODING_ISO_8859_3, 0, 103},
+ {"iso-8859-3", 10, "iso88593", 8, MyENCODING_ISO_8859_3, 0, 103},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-4", 10, "iso88594", 8, MyHTML_ENCODING_ISO_8859_4, 0, 105},
+ {"iso-8859-4", 10, "iso88594", 8, MyENCODING_ISO_8859_4, 0, 105},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"shift_jis", 9, "sjis", 4, MyHTML_ENCODING_SHIFT_JIS, 430, 107},
+ {"shift_jis", 9, "sjis", 4, MyENCODING_SHIFT_JIS, 430, 107},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-6", 10, "iso88596", 8, MyHTML_ENCODING_ISO_8859_6, 431, 109},
- {"windows-1252", 12, "l1", 2, MyHTML_ENCODING_WINDOWS_1252, 432, 110},
- {"macintosh", 9, "mac", 3, MyHTML_ENCODING_MACINTOSH, 433, 111},
+ {"iso-8859-6", 10, "iso88596", 8, MyENCODING_ISO_8859_6, 431, 109},
+ {"windows-1252", 12, "l1", 2, MyENCODING_WINDOWS_1252, 432, 110},
+ {"macintosh", 9, "mac", 3, MyENCODING_MACINTOSH, 433, 111},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-8", 10, "iso88598", 8, MyHTML_ENCODING_ISO_8859_8, 435, 113},
- {"koi8-u", 6, "koi8-u", 6, MyHTML_ENCODING_KOI8_U, 0, 114},
- {"windows-1254", 12, "iso88599", 8, MyHTML_ENCODING_WINDOWS_1254, 0, 115},
+ {"iso-8859-8", 10, "iso88598", 8, MyENCODING_ISO_8859_8, 435, 113},
+ {"koi8-u", 6, "koi8-u", 6, MyENCODING_KOI8_U, 0, 114},
+ {"windows-1254", 12, "iso88599", 8, MyENCODING_WINDOWS_1254, 0, 115},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-6", 10, "ecma-114", 8, MyHTML_ENCODING_ISO_8859_6, 0, 117},
- {"iso-8859-4", 10, "iso8859-4", 9, MyHTML_ENCODING_ISO_8859_4, 436, 118},
+ {"iso-8859-6", 10, "ecma-114", 8, MyENCODING_ISO_8859_6, 0, 117},
+ {"iso-8859-4", 10, "iso8859-4", 9, MyENCODING_ISO_8859_4, 436, 118},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-4", 10, "iso-ir-110", 10, MyHTML_ENCODING_ISO_8859_4, 437, 121},
+ {"iso-8859-4", 10, "iso-ir-110", 10, MyENCODING_ISO_8859_4, 437, 121},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-3", 10, "l3", 2, MyHTML_ENCODING_ISO_8859_3, 0, 123},
+ {"iso-8859-3", 10, "l3", 2, MyENCODING_ISO_8859_3, 0, 123},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "iso-8859-2", 10, MyHTML_ENCODING_ISO_8859_2, 439, 126},
- {"windows-1253", 12, "cp1253", 6, MyHTML_ENCODING_WINDOWS_1253, 440, 127},
+ {"iso-8859-2", 10, "iso-8859-2", 10, MyENCODING_ISO_8859_2, 439, 126},
+ {"windows-1253", 12, "cp1253", 6, MyENCODING_WINDOWS_1253, 440, 127},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1258", 12, "x-cp1258", 8, MyHTML_ENCODING_WINDOWS_1258, 0, 129},
+ {"windows-1258", 12, "x-cp1258", 8, MyENCODING_WINDOWS_1258, 0, 129},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-4", 10, "iso-8859-4", 10, MyHTML_ENCODING_ISO_8859_4, 443, 131},
+ {"iso-8859-4", 10, "iso-8859-4", 10, MyENCODING_ISO_8859_4, 443, 131},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-10", 11, "iso-8859-10", 11, MyHTML_ENCODING_ISO_8859_10, 0, 133},
+ {"iso-8859-10", 11, "iso-8859-10", 11, MyENCODING_ISO_8859_10, 0, 133},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1254", 12, "l5", 2, MyHTML_ENCODING_WINDOWS_1254, 446, 136},
+ {"windows-1254", 12, "l5", 2, MyENCODING_WINDOWS_1254, 446, 136},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "latin2", 6, MyHTML_ENCODING_ISO_8859_2, 0, 138},
+ {"iso-8859-2", 10, "latin2", 6, MyENCODING_ISO_8859_2, 0, 138},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-8", 10, "iso-8859-8", 10, MyHTML_ENCODING_ISO_8859_8, 449, 141},
+ {"iso-8859-8", 10, "iso-8859-8", 10, MyENCODING_ISO_8859_8, 449, 141},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "cp819", 5, MyHTML_ENCODING_WINDOWS_1252, 0, 143},
- {"iso-8859-14", 11, "iso-8859-14", 11, MyHTML_ENCODING_ISO_8859_14, 0, 144},
+ {"windows-1252", 12, "cp819", 5, MyENCODING_WINDOWS_1252, 0, 143},
+ {"iso-8859-14", 11, "iso-8859-14", 11, MyENCODING_ISO_8859_14, 0, 144},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-10", 11, "csisolatin6", 11, MyHTML_ENCODING_ISO_8859_10, 0, 147},
+ {"iso-8859-10", 11, "csisolatin6", 11, MyENCODING_ISO_8859_10, 0, 147},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "csisolatin1", 11, MyHTML_ENCODING_WINDOWS_1252, 0, 149},
+ {"windows-1252", 12, "csisolatin1", 11, MyENCODING_WINDOWS_1252, 0, 149},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -194,44 +194,44 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-15", 11, "l9", 2, MyHTML_ENCODING_ISO_8859_15, 0, 162},
+ {"iso-8859-15", 11, "l9", 2, MyENCODING_ISO_8859_15, 0, 162},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1258", 12, "cp1258", 6, MyHTML_ENCODING_WINDOWS_1258, 0, 164},
+ {"windows-1258", 12, "cp1258", 6, MyENCODING_WINDOWS_1258, 0, 164},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "windows-1252", 12, MyHTML_ENCODING_WINDOWS_1252, 0, 171},
+ {"windows-1252", 12, "windows-1252", 12, MyENCODING_WINDOWS_1252, 0, 171},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-7", 10, "sun_eu_greek", 12, MyHTML_ENCODING_ISO_8859_7, 0, 173},
+ {"iso-8859-7", 10, "sun_eu_greek", 12, MyENCODING_ISO_8859_7, 0, 173},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-jp", 6, "cseucpkdfmtjapanese", 19, MyHTML_ENCODING_EUC_JP, 0, 175},
+ {"euc-jp", 6, "cseucpkdfmtjapanese", 19, MyENCODING_EUC_JP, 0, 175},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-4", 10, "latin4", 6, MyHTML_ENCODING_ISO_8859_4, 0, 177},
+ {"iso-8859-4", 10, "latin4", 6, MyENCODING_ISO_8859_4, 0, 177},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1255", 12, "x-cp1255", 8, MyHTML_ENCODING_WINDOWS_1255, 452, 182},
+ {"windows-1255", 12, "x-cp1255", 8, MyENCODING_WINDOWS_1255, 452, 182},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"koi8-r", 6, "koi", 3, MyHTML_ENCODING_KOI8_R, 0, 186},
+ {"koi8-r", 6, "koi", 3, MyENCODING_KOI8_R, 0, 186},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1257", 12, "windows-1257", 12, MyHTML_ENCODING_WINDOWS_1257, 0, 188},
+ {"windows-1257", 12, "windows-1257", 12, MyENCODING_WINDOWS_1257, 0, 188},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-874", 11, "windows-874", 11, MyHTML_ENCODING_WINDOWS_874, 0, 191},
+ {"windows-874", 11, "windows-874", 11, MyENCODING_WINDOWS_874, 0, 191},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1251", 12, "cp1251", 6, MyHTML_ENCODING_WINDOWS_1251, 0, 196},
+ {"windows-1251", 12, "cp1251", 6, MyENCODING_WINDOWS_1251, 0, 196},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"utf-16le", 8, "utf-16", 6, MyHTML_ENCODING_UTF_16LE, 0, 199},
+ {"utf-16le", 8, "utf-16", 6, MyENCODING_UTF_16LE, 0, 199},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -239,35 +239,35 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-8", 10, "visual", 6, MyHTML_ENCODING_ISO_8859_8, 0, 207},
- {"macintosh", 9, "macintosh", 9, MyHTML_ENCODING_MACINTOSH, 0, 208},
+ {"iso-8859-8", 10, "visual", 6, MyENCODING_ISO_8859_8, 0, 207},
+ {"macintosh", 9, "macintosh", 9, MyENCODING_MACINTOSH, 0, 208},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "ansi_x3.4-1968", 14, MyHTML_ENCODING_WINDOWS_1252, 0, 210},
- {"iso-8859-3", 10, "iso_8859-3:1988", 15, MyHTML_ENCODING_ISO_8859_3, 453, 211},
- {"iso-8859-6", 10, "csiso88596e", 11, MyHTML_ENCODING_ISO_8859_6, 456, 212},
+ {"windows-1252", 12, "ansi_x3.4-1968", 14, MyENCODING_WINDOWS_1252, 0, 210},
+ {"iso-8859-3", 10, "iso_8859-3:1988", 15, MyENCODING_ISO_8859_3, 453, 211},
+ {"iso-8859-6", 10, "csiso88596e", 11, MyENCODING_ISO_8859_6, 456, 212},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"gbk", 3, "csgb2312", 8, MyHTML_ENCODING_GBK, 0, 215},
- {"iso-8859-6", 10, "arabic", 6, MyHTML_ENCODING_ISO_8859_6, 457, 216},
- {"iso-8859-7", 10, "greek", 5, MyHTML_ENCODING_ISO_8859_7, 0, 217},
+ {"gbk", 3, "csgb2312", 8, MyENCODING_GBK, 0, 215},
+ {"iso-8859-6", 10, "arabic", 6, MyENCODING_ISO_8859_6, 457, 216},
+ {"iso-8859-7", 10, "greek", 5, MyENCODING_ISO_8859_7, 0, 217},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"shift_jis", 9, "ms_kanji", 8, MyHTML_ENCODING_SHIFT_JIS, 0, 219},
+ {"shift_jis", 9, "ms_kanji", 8, MyENCODING_SHIFT_JIS, 0, 219},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-5", 10, "iso8859-5", 9, MyHTML_ENCODING_ISO_8859_5, 460, 225},
+ {"iso-8859-5", 10, "iso8859-5", 9, MyENCODING_ISO_8859_5, 460, 225},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "ascii", 5, MyHTML_ENCODING_WINDOWS_1252, 461, 227},
+ {"windows-1252", 12, "ascii", 5, MyENCODING_WINDOWS_1252, 461, 227},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-kr", 6, "korean", 6, MyHTML_ENCODING_EUC_KR, 0, 229},
+ {"euc-kr", 6, "korean", 6, MyENCODING_EUC_KR, 0, 229},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"utf-8", 5, "utf8", 4, MyHTML_ENCODING_UTF_8, 462, 231},
- {"iso-8859-3", 10, "csisolatin3", 11, MyHTML_ENCODING_ISO_8859_3, 0, 232},
- {"windows-1256", 12, "cp1256", 6, MyHTML_ENCODING_WINDOWS_1256, 464, 233},
- {"windows-1254", 12, "iso8859-9", 9, MyHTML_ENCODING_WINDOWS_1254, 0, 234},
- {"windows-1252", 12, "us-ascii", 8, MyHTML_ENCODING_WINDOWS_1252, 465, 235},
+ {"utf-8", 5, "utf8", 4, MyENCODING_UTF_8, 462, 231},
+ {"iso-8859-3", 10, "csisolatin3", 11, MyENCODING_ISO_8859_3, 0, 232},
+ {"windows-1256", 12, "cp1256", 6, MyENCODING_WINDOWS_1256, 464, 233},
+ {"windows-1254", 12, "iso8859-9", 9, MyENCODING_WINDOWS_1254, 0, 234},
+ {"windows-1252", 12, "us-ascii", 8, MyENCODING_WINDOWS_1252, 465, 235},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -278,44 +278,44 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"big5", 4, "big5", 4, MyHTML_ENCODING_BIG5, 466, 246},
+ {"big5", 4, "big5", 4, MyENCODING_BIG5, 466, 246},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1250", 12, "windows-1250", 12, MyHTML_ENCODING_WINDOWS_1250, 0, 248},
- {"euc-kr", 6, "ksc5601", 7, MyHTML_ENCODING_EUC_KR, 0, 249},
+ {"windows-1250", 12, "windows-1250", 12, MyENCODING_WINDOWS_1250, 0, 248},
+ {"euc-kr", 6, "ksc5601", 7, MyENCODING_EUC_KR, 0, 249},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-7", 10, "greek8", 6, MyHTML_ENCODING_ISO_8859_7, 467, 251},
+ {"iso-8859-7", 10, "greek8", 6, MyENCODING_ISO_8859_7, 467, 251},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-jp", 6, "x-euc-jp", 8, MyHTML_ENCODING_EUC_JP, 0, 257},
- {"shift_jis", 9, "x-sjis", 6, MyHTML_ENCODING_SHIFT_JIS, 0, 258},
+ {"euc-jp", 6, "x-euc-jp", 8, MyENCODING_EUC_JP, 0, 257},
+ {"shift_jis", 9, "x-sjis", 6, MyENCODING_SHIFT_JIS, 0, 258},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"utf-16be", 8, "utf-16be", 8, MyHTML_ENCODING_UTF_16BE, 468, 262},
+ {"utf-16be", 8, "utf-16be", 8, MyENCODING_UTF_16BE, 468, 262},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1255", 12, "windows-1255", 12, MyHTML_ENCODING_WINDOWS_1255, 0, 265},
+ {"windows-1255", 12, "windows-1255", 12, MyENCODING_WINDOWS_1255, 0, 265},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-kr", 6, "ks_c_5601-1987", 14, MyHTML_ENCODING_EUC_KR, 0, 267},
+ {"euc-kr", 6, "ks_c_5601-1987", 14, MyENCODING_EUC_KR, 0, 267},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"ibm866", 6, "866", 3, MyHTML_ENCODING_IBM866, 0, 274},
+ {"ibm866", 6, "866", 3, MyENCODING_IBM866, 0, 274},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"big5", 4, "cn-big5", 7, MyHTML_ENCODING_BIG5, 0, 277},
+ {"big5", 4, "cn-big5", 7, MyENCODING_BIG5, 0, 277},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"koi8-r", 6, "koi8-r", 6, MyHTML_ENCODING_KOI8_R, 469, 283},
+ {"koi8-r", 6, "koi8-r", 6, MyENCODING_KOI8_R, 469, 283},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -328,93 +328,93 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "ibm819", 6, MyHTML_ENCODING_WINDOWS_1252, 0, 296},
+ {"windows-1252", 12, "ibm819", 6, MyENCODING_WINDOWS_1252, 0, 296},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-6", 10, "asmo-708", 8, MyHTML_ENCODING_ISO_8859_6, 0, 300},
+ {"iso-8859-6", 10, "asmo-708", 8, MyENCODING_ISO_8859_6, 0, 300},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1254", 12, "cp1254", 6, MyHTML_ENCODING_WINDOWS_1254, 470, 302},
+ {"windows-1254", 12, "cp1254", 6, MyENCODING_WINDOWS_1254, 470, 302},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1256", 12, "x-cp1256", 8, MyHTML_ENCODING_WINDOWS_1256, 471, 304},
+ {"windows-1256", 12, "x-cp1256", 8, MyENCODING_WINDOWS_1256, 471, 304},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-2022-jp", 11, "iso-2022-jp", 11, MyHTML_ENCODING_ISO_2022_JP, 0, 309},
+ {"iso-2022-jp", 11, "iso-2022-jp", 11, MyENCODING_ISO_2022_JP, 0, 309},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "iso_8859-2:1987", 15, MyHTML_ENCODING_ISO_8859_2, 473, 312},
+ {"iso-8859-2", 10, "iso_8859-2:1987", 15, MyENCODING_ISO_8859_2, 473, 312},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"gbk", 3, "gb2312", 6, MyHTML_ENCODING_GBK, 0, 314},
- {"windows-1254", 12, "csisolatin5", 11, MyHTML_ENCODING_WINDOWS_1254, 0, 315},
- {"iso-8859-6", 10, "iso-8859-6-i", 12, MyHTML_ENCODING_ISO_8859_6, 476, 316},
+ {"gbk", 3, "gb2312", 6, MyENCODING_GBK, 0, 314},
+ {"windows-1254", 12, "csisolatin5", 11, MyENCODING_WINDOWS_1254, 0, 315},
+ {"iso-8859-6", 10, "iso-8859-6-i", 12, MyENCODING_ISO_8859_6, 476, 316},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "iso8859-2", 9, MyHTML_ENCODING_ISO_8859_2, 0, 323},
+ {"iso-8859-2", 10, "iso8859-2", 9, MyENCODING_ISO_8859_2, 0, 323},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "l2", 2, MyHTML_ENCODING_ISO_8859_2, 0, 326},
+ {"iso-8859-2", 10, "l2", 2, MyENCODING_ISO_8859_2, 0, 326},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "latin1", 6, MyHTML_ENCODING_WINDOWS_1252, 0, 328},
+ {"windows-1252", 12, "latin1", 6, MyENCODING_WINDOWS_1252, 0, 328},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-kr", 6, "ks_c_5601-1989", 14, MyHTML_ENCODING_EUC_KR, 0, 330},
+ {"euc-kr", 6, "ks_c_5601-1989", 14, MyENCODING_EUC_KR, 0, 330},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-6", 10, "iso8859-6", 9, MyHTML_ENCODING_ISO_8859_6, 0, 332},
- {"iso-8859-2", 10, "iso-ir-101", 10, MyHTML_ENCODING_ISO_8859_2, 477, 333},
- {"ibm866", 6, "cp866", 5, MyHTML_ENCODING_IBM866, 0, 334},
+ {"iso-8859-6", 10, "iso8859-6", 9, MyENCODING_ISO_8859_6, 0, 332},
+ {"iso-8859-2", 10, "iso-ir-101", 10, MyENCODING_ISO_8859_2, 477, 333},
+ {"ibm866", 6, "cp866", 5, MyENCODING_IBM866, 0, 334},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-3", 10, "iso-8859-3", 10, MyHTML_ENCODING_ISO_8859_3, 480, 338},
- {"iso-8859-4", 10, "l4", 2, MyHTML_ENCODING_ISO_8859_4, 0, 339},
+ {"iso-8859-3", 10, "iso-8859-3", 10, MyENCODING_ISO_8859_3, 480, 338},
+ {"iso-8859-4", 10, "l4", 2, MyENCODING_ISO_8859_4, 0, 339},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1253", 12, "windows-1253", 12, MyHTML_ENCODING_WINDOWS_1253, 0, 342},
- {"iso-8859-5", 10, "iso-8859-5", 10, MyHTML_ENCODING_ISO_8859_5, 482, 343},
+ {"windows-1253", 12, "windows-1253", 12, MyENCODING_WINDOWS_1253, 0, 342},
+ {"iso-8859-5", 10, "iso-8859-5", 10, MyENCODING_ISO_8859_5, 482, 343},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-6", 10, "iso-ir-127", 10, MyHTML_ENCODING_ISO_8859_6, 484, 348},
+ {"iso-8859-6", 10, "iso-ir-127", 10, MyENCODING_ISO_8859_6, 484, 348},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"utf-8", 5, "unicode-1-1-utf-8", 17, MyHTML_ENCODING_UTF_8, 0, 350},
+ {"utf-8", 5, "unicode-1-1-utf-8", 17, MyENCODING_UTF_8, 0, 350},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-10", 11, "l6", 2, MyHTML_ENCODING_ISO_8859_10, 0, 352},
- {"iso-8859-3", 10, "iso-ir-109", 10, MyHTML_ENCODING_ISO_8859_3, 487, 353},
+ {"iso-8859-10", 11, "l6", 2, MyENCODING_ISO_8859_10, 0, 352},
+ {"iso-8859-3", 10, "iso-ir-109", 10, MyENCODING_ISO_8859_3, 487, 353},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1253", 12, "x-cp1253", 8, MyHTML_ENCODING_WINDOWS_1253, 0, 357},
+ {"windows-1253", 12, "x-cp1253", 8, MyENCODING_WINDOWS_1253, 0, 357},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-16", 11, "iso-8859-16", 11, MyHTML_ENCODING_ISO_8859_16, 490, 359},
+ {"iso-8859-16", 11, "iso-8859-16", 11, MyENCODING_ISO_8859_16, 490, 359},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-8-i", 12, "logical", 7, MyHTML_ENCODING_ISO_8859_8_I, 0, 363},
+ {"iso-8859-8-i", 12, "logical", 7, MyENCODING_ISO_8859_8_I, 0, 363},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-8", 10, "csisolatinhebrew", 16, MyHTML_ENCODING_ISO_8859_8, 0, 366},
- {"iso-8859-3", 10, "latin3", 6, MyHTML_ENCODING_ISO_8859_3, 491, 367},
+ {"iso-8859-8", 10, "csisolatinhebrew", 16, MyENCODING_ISO_8859_8, 0, 366},
+ {"iso-8859-3", 10, "latin3", 6, MyENCODING_ISO_8859_3, 491, 367},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-kr", 6, "euc-kr", 6, MyHTML_ENCODING_EUC_KR, 0, 369},
+ {"euc-kr", 6, "euc-kr", 6, MyENCODING_EUC_KR, 0, 369},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "cp1252", 6, MyHTML_ENCODING_WINDOWS_1252, 0, 371},
+ {"windows-1252", 12, "cp1252", 6, MyENCODING_WINDOWS_1252, 0, 371},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-6", 10, "csiso88596i", 11, MyHTML_ENCODING_ISO_8859_6, 492, 378},
+ {"iso-8859-6", 10, "csiso88596i", 11, MyENCODING_ISO_8859_6, 492, 378},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"gbk", 3, "gbk", 3, MyHTML_ENCODING_GBK, 0, 382},
+ {"gbk", 3, "gbk", 3, MyENCODING_GBK, 0, 382},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -426,109 +426,109 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-kr", 6, "csksc56011987", 13, MyHTML_ENCODING_EUC_KR, 0, 394},
+ {"euc-kr", 6, "csksc56011987", 13, MyENCODING_EUC_KR, 0, 394},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"x-mac-cyrillic", 14, "x-mac-cyrillic", 14, MyHTML_ENCODING_X_MAC_CYRILLIC, 0, 397},
+ {"x-mac-cyrillic", 14, "x-mac-cyrillic", 14, MyENCODING_X_MAC_CYRILLIC, 0, 397},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "csisolatin2", 11, MyHTML_ENCODING_ISO_8859_2, 0, 400},
- {"x-user-defined", 14, "x-user-defined", 14, MyHTML_ENCODING_X_USER_DEFINED, 0, 401},
+ {"iso-8859-2", 10, "csisolatin2", 11, MyENCODING_ISO_8859_2, 0, 400},
+ {"x-user-defined", 14, "x-user-defined", 14, MyENCODING_X_USER_DEFINED, 0, 401},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1254", 12, "latin5", 6, MyHTML_ENCODING_WINDOWS_1254, 0, 406},
+ {"windows-1254", 12, "latin5", 6, MyENCODING_WINDOWS_1254, 0, 406},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1257", 12, "cp1257", 6, MyHTML_ENCODING_WINDOWS_1257, 0, 408},
- {"big5", 4, "big5-hkscs", 10, MyHTML_ENCODING_BIG5, 0, 409},
- {"windows-1250", 12, "x-cp1250", 8, MyHTML_ENCODING_WINDOWS_1250, 0, 410},
+ {"windows-1257", 12, "cp1257", 6, MyENCODING_WINDOWS_1257, 0, 408},
+ {"big5", 4, "big5-hkscs", 10, MyENCODING_BIG5, 0, 409},
+ {"windows-1250", 12, "x-cp1250", 8, MyENCODING_WINDOWS_1250, 0, 410},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-jp", 6, "euc-jp", 6, MyHTML_ENCODING_EUC_JP, 0, 414},
+ {"euc-jp", 6, "euc-jp", 6, MyENCODING_EUC_JP, 0, 414},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-7", 10, "ecma-118", 8, MyHTML_ENCODING_ISO_8859_7, 493, 416},
+ {"iso-8859-7", 10, "ecma-118", 8, MyENCODING_ISO_8859_7, 493, 416},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"gbk", 3, "gb_2312-80", 10, MyHTML_ENCODING_GBK, 0, 418},
- {"windows-1251", 12, "windows-1251", 12, MyHTML_ENCODING_WINDOWS_1251, 0, 419},
- {"iso-8859-13", 11, "iso885913", 9, MyHTML_ENCODING_ISO_8859_13, 0, 420},
- {"windows-1256", 12, "windows-1256", 12, MyHTML_ENCODING_WINDOWS_1256, 0, 421},
- {"iso-8859-5", 10, "csisolatincyrillic", 18, MyHTML_ENCODING_ISO_8859_5, 0, 422},
- {"gbk", 3, "chinese", 7, MyHTML_ENCODING_GBK, 0, 423},
- {"shift_jis", 9, "shift_jis", 9, MyHTML_ENCODING_SHIFT_JIS, 0, 424},
- {"windows-874", 11, "iso-8859-11", 11, MyHTML_ENCODING_WINDOWS_874, 0, 425},
- {"iso-8859-15", 11, "iso_8859-15", 11, MyHTML_ENCODING_ISO_8859_15, 0, 426},
- {"big5", 4, "csbig5", 6, MyHTML_ENCODING_BIG5, 0, 427},
- {"iso-8859-8", 10, "hebrew", 6, MyHTML_ENCODING_ISO_8859_8, 429, 428},
- {"windows-1254", 12, "windows-1254", 12, MyHTML_ENCODING_WINDOWS_1254, 0, 429},
- {"iso-8859-5", 10, "iso88595", 8, MyHTML_ENCODING_ISO_8859_5, 0, 430},
- {"iso-8859-10", 11, "iso885910", 9, MyHTML_ENCODING_ISO_8859_10, 0, 431},
- {"windows-1254", 12, "iso_8859-9:1989", 15, MyHTML_ENCODING_WINDOWS_1254, 0, 432},
- {"iso-8859-7", 10, "iso88597", 8, MyHTML_ENCODING_ISO_8859_7, 434, 433},
- {"iso-8859-6", 10, "csisolatinarabic", 16, MyHTML_ENCODING_ISO_8859_6, 0, 434},
- {"windows-1251", 12, "x-cp1251", 8, MyHTML_ENCODING_WINDOWS_1251, 0, 435},
- {"iso-8859-14", 11, "iso885914", 9, MyHTML_ENCODING_ISO_8859_14, 0, 436},
- {"iso-8859-10", 11, "iso8859-10", 10, MyHTML_ENCODING_ISO_8859_10, 438, 437},
- {"windows-1252", 12, "iso-ir-100", 10, MyHTML_ENCODING_WINDOWS_1252, 0, 438},
- {"iso-8859-2", 10, "iso_8859-2", 10, MyHTML_ENCODING_ISO_8859_2, 0, 439},
- {"iso-8859-8", 10, "iso8859-8", 9, MyHTML_ENCODING_ISO_8859_8, 441, 440},
- {"gbk", 3, "iso-ir-58", 9, MyHTML_ENCODING_GBK, 442, 441},
- {"macintosh", 9, "csmacintosh", 11, MyHTML_ENCODING_MACINTOSH, 0, 442},
- {"iso-8859-4", 10, "iso_8859-4", 10, MyHTML_ENCODING_ISO_8859_4, 444, 443},
- {"iso-8859-5", 10, "iso-ir-144", 10, MyHTML_ENCODING_ISO_8859_5, 445, 444},
- {"iso-8859-14", 11, "iso8859-14", 10, MyHTML_ENCODING_ISO_8859_14, 0, 445},
- {"iso-8859-6", 10, "iso-8859-6", 10, MyHTML_ENCODING_ISO_8859_6, 447, 446},
- {"iso-8859-6", 10, "iso_8859-6", 10, MyHTML_ENCODING_ISO_8859_6, 448, 447},
- {"iso-8859-7", 10, "iso-ir-126", 10, MyHTML_ENCODING_ISO_8859_7, 0, 448},
- {"iso-8859-8", 10, "iso-ir-138", 10, MyHTML_ENCODING_ISO_8859_8, 450, 449},
- {"iso-8859-8", 10, "iso_8859-8", 10, MyHTML_ENCODING_ISO_8859_8, 451, 450},
- {"windows-1254", 12, "iso-ir-148", 10, MyHTML_ENCODING_WINDOWS_1254, 0, 451},
- {"big5", 4, "x-x-big5", 8, MyHTML_ENCODING_BIG5, 0, 452},
- {"iso-8859-4", 10, "iso_8859-4:1988", 15, MyHTML_ENCODING_ISO_8859_4, 454, 453},
- {"iso-8859-5", 10, "iso_8859-5:1988", 15, MyHTML_ENCODING_ISO_8859_5, 455, 454},
- {"iso-8859-8", 10, "iso_8859-8:1988", 15, MyHTML_ENCODING_ISO_8859_8, 0, 455},
- {"iso-8859-8", 10, "csiso88598e", 11, MyHTML_ENCODING_ISO_8859_8, 0, 456},
- {"iso-8859-10", 11, "latin6", 6, MyHTML_ENCODING_ISO_8859_10, 458, 457},
- {"windows-874", 11, "iso885911", 9, MyHTML_ENCODING_WINDOWS_874, 459, 458},
- {"windows-1252", 12, "iso8859-1", 9, MyHTML_ENCODING_WINDOWS_1252, 0, 459},
- {"iso-8859-15", 11, "iso885915", 9, MyHTML_ENCODING_ISO_8859_15, 0, 460},
- {"macintosh", 9, "x-mac-roman", 11, MyHTML_ENCODING_MACINTOSH, 0, 461},
- {"koi8-r", 6, "cskoi8r", 7, MyHTML_ENCODING_KOI8_R, 463, 462},
- {"euc-kr", 6, "cseuckr", 7, MyHTML_ENCODING_EUC_KR, 0, 463},
- {"x-mac-cyrillic", 14, "x-mac-ukrainian", 15, MyHTML_ENCODING_X_MAC_CYRILLIC, 0, 464},
- {"windows-1252", 12, "x-cp1252", 8, MyHTML_ENCODING_WINDOWS_1252, 0, 465},
- {"iso-8859-13", 11, "iso-8859-13", 11, MyHTML_ENCODING_ISO_8859_13, 0, 466},
- {"gb18030", 7, "gb18030", 7, MyHTML_ENCODING_GB18030, 0, 467},
- {"utf-16le", 8, "utf-16le", 8, MyHTML_ENCODING_UTF_16LE, 0, 468},
- {"koi8-r", 6, "koi8_r", 6, MyHTML_ENCODING_KOI8_R, 0, 469},
- {"shift_jis", 9, "csshiftjis", 10, MyHTML_ENCODING_SHIFT_JIS, 0, 470},
- {"iso-8859-6", 10, "iso-8859-6-e", 12, MyHTML_ENCODING_ISO_8859_6, 472, 471},
- {"iso-8859-8", 10, "iso-8859-8-e", 12, MyHTML_ENCODING_ISO_8859_8, 0, 472},
- {"iso-8859-6", 10, "iso_8859-6:1987", 15, MyHTML_ENCODING_ISO_8859_6, 474, 473},
- {"iso-8859-7", 10, "iso_8859-7:1987", 15, MyHTML_ENCODING_ISO_8859_7, 475, 474},
- {"windows-1252", 12, "iso_8859-1:1987", 15, MyHTML_ENCODING_WINDOWS_1252, 0, 475},
- {"iso-8859-8-i", 12, "iso-8859-8-i", 12, MyHTML_ENCODING_ISO_8859_8_I, 0, 476},
- {"windows-874", 11, "iso8859-11", 10, MyHTML_ENCODING_WINDOWS_874, 478, 477},
- {"windows-1252", 12, "iso-8859-1", 10, MyHTML_ENCODING_WINDOWS_1252, 479, 478},
- {"windows-1252", 12, "iso_8859-1", 10, MyHTML_ENCODING_WINDOWS_1252, 0, 479},
- {"iso-8859-3", 10, "iso_8859-3", 10, MyHTML_ENCODING_ISO_8859_3, 481, 480},
- {"iso-8859-13", 11, "iso8859-13", 10, MyHTML_ENCODING_ISO_8859_13, 0, 481},
- {"iso-8859-5", 10, "iso_8859-5", 10, MyHTML_ENCODING_ISO_8859_5, 483, 482},
- {"iso-8859-15", 11, "iso8859-15", 10, MyHTML_ENCODING_ISO_8859_15, 0, 483},
- {"iso-8859-7", 10, "iso-8859-7", 10, MyHTML_ENCODING_ISO_8859_7, 485, 484},
- {"iso-8859-7", 10, "iso_8859-7", 10, MyHTML_ENCODING_ISO_8859_7, 486, 485},
- {"iso-8859-10", 11, "iso-ir-157", 10, MyHTML_ENCODING_ISO_8859_10, 0, 486},
- {"windows-1254", 12, "iso-8859-9", 10, MyHTML_ENCODING_WINDOWS_1254, 488, 487},
- {"windows-1254", 12, "iso_8859-9", 10, MyHTML_ENCODING_WINDOWS_1254, 489, 488},
- {"euc-kr", 6, "iso-ir-149", 10, MyHTML_ENCODING_EUC_KR, 0, 489},
- {"windows-1258", 12, "windows-1258", 12, MyHTML_ENCODING_WINDOWS_1258, 0, 490},
- {"windows-874", 11, "dos-874", 7, MyHTML_ENCODING_WINDOWS_874, 0, 491},
- {"iso-8859-8-i", 12, "csiso88598i", 11, MyHTML_ENCODING_ISO_8859_8_I, 0, 492},
- {"iso-8859-7", 10, "elot_928", 8, MyHTML_ENCODING_ISO_8859_7, 0, 493},
+ {"gbk", 3, "gb_2312-80", 10, MyENCODING_GBK, 0, 418},
+ {"windows-1251", 12, "windows-1251", 12, MyENCODING_WINDOWS_1251, 0, 419},
+ {"iso-8859-13", 11, "iso885913", 9, MyENCODING_ISO_8859_13, 0, 420},
+ {"windows-1256", 12, "windows-1256", 12, MyENCODING_WINDOWS_1256, 0, 421},
+ {"iso-8859-5", 10, "csisolatincyrillic", 18, MyENCODING_ISO_8859_5, 0, 422},
+ {"gbk", 3, "chinese", 7, MyENCODING_GBK, 0, 423},
+ {"shift_jis", 9, "shift_jis", 9, MyENCODING_SHIFT_JIS, 0, 424},
+ {"windows-874", 11, "iso-8859-11", 11, MyENCODING_WINDOWS_874, 0, 425},
+ {"iso-8859-15", 11, "iso_8859-15", 11, MyENCODING_ISO_8859_15, 0, 426},
+ {"big5", 4, "csbig5", 6, MyENCODING_BIG5, 0, 427},
+ {"iso-8859-8", 10, "hebrew", 6, MyENCODING_ISO_8859_8, 429, 428},
+ {"windows-1254", 12, "windows-1254", 12, MyENCODING_WINDOWS_1254, 0, 429},
+ {"iso-8859-5", 10, "iso88595", 8, MyENCODING_ISO_8859_5, 0, 430},
+ {"iso-8859-10", 11, "iso885910", 9, MyENCODING_ISO_8859_10, 0, 431},
+ {"windows-1254", 12, "iso_8859-9:1989", 15, MyENCODING_WINDOWS_1254, 0, 432},
+ {"iso-8859-7", 10, "iso88597", 8, MyENCODING_ISO_8859_7, 434, 433},
+ {"iso-8859-6", 10, "csisolatinarabic", 16, MyENCODING_ISO_8859_6, 0, 434},
+ {"windows-1251", 12, "x-cp1251", 8, MyENCODING_WINDOWS_1251, 0, 435},
+ {"iso-8859-14", 11, "iso885914", 9, MyENCODING_ISO_8859_14, 0, 436},
+ {"iso-8859-10", 11, "iso8859-10", 10, MyENCODING_ISO_8859_10, 438, 437},
+ {"windows-1252", 12, "iso-ir-100", 10, MyENCODING_WINDOWS_1252, 0, 438},
+ {"iso-8859-2", 10, "iso_8859-2", 10, MyENCODING_ISO_8859_2, 0, 439},
+ {"iso-8859-8", 10, "iso8859-8", 9, MyENCODING_ISO_8859_8, 441, 440},
+ {"gbk", 3, "iso-ir-58", 9, MyENCODING_GBK, 442, 441},
+ {"macintosh", 9, "csmacintosh", 11, MyENCODING_MACINTOSH, 0, 442},
+ {"iso-8859-4", 10, "iso_8859-4", 10, MyENCODING_ISO_8859_4, 444, 443},
+ {"iso-8859-5", 10, "iso-ir-144", 10, MyENCODING_ISO_8859_5, 445, 444},
+ {"iso-8859-14", 11, "iso8859-14", 10, MyENCODING_ISO_8859_14, 0, 445},
+ {"iso-8859-6", 10, "iso-8859-6", 10, MyENCODING_ISO_8859_6, 447, 446},
+ {"iso-8859-6", 10, "iso_8859-6", 10, MyENCODING_ISO_8859_6, 448, 447},
+ {"iso-8859-7", 10, "iso-ir-126", 10, MyENCODING_ISO_8859_7, 0, 448},
+ {"iso-8859-8", 10, "iso-ir-138", 10, MyENCODING_ISO_8859_8, 450, 449},
+ {"iso-8859-8", 10, "iso_8859-8", 10, MyENCODING_ISO_8859_8, 451, 450},
+ {"windows-1254", 12, "iso-ir-148", 10, MyENCODING_WINDOWS_1254, 0, 451},
+ {"big5", 4, "x-x-big5", 8, MyENCODING_BIG5, 0, 452},
+ {"iso-8859-4", 10, "iso_8859-4:1988", 15, MyENCODING_ISO_8859_4, 454, 453},
+ {"iso-8859-5", 10, "iso_8859-5:1988", 15, MyENCODING_ISO_8859_5, 455, 454},
+ {"iso-8859-8", 10, "iso_8859-8:1988", 15, MyENCODING_ISO_8859_8, 0, 455},
+ {"iso-8859-8", 10, "csiso88598e", 11, MyENCODING_ISO_8859_8, 0, 456},
+ {"iso-8859-10", 11, "latin6", 6, MyENCODING_ISO_8859_10, 458, 457},
+ {"windows-874", 11, "iso885911", 9, MyENCODING_WINDOWS_874, 459, 458},
+ {"windows-1252", 12, "iso8859-1", 9, MyENCODING_WINDOWS_1252, 0, 459},
+ {"iso-8859-15", 11, "iso885915", 9, MyENCODING_ISO_8859_15, 0, 460},
+ {"macintosh", 9, "x-mac-roman", 11, MyENCODING_MACINTOSH, 0, 461},
+ {"koi8-r", 6, "cskoi8r", 7, MyENCODING_KOI8_R, 463, 462},
+ {"euc-kr", 6, "cseuckr", 7, MyENCODING_EUC_KR, 0, 463},
+ {"x-mac-cyrillic", 14, "x-mac-ukrainian", 15, MyENCODING_X_MAC_CYRILLIC, 0, 464},
+ {"windows-1252", 12, "x-cp1252", 8, MyENCODING_WINDOWS_1252, 0, 465},
+ {"iso-8859-13", 11, "iso-8859-13", 11, MyENCODING_ISO_8859_13, 0, 466},
+ {"gb18030", 7, "gb18030", 7, MyENCODING_GB18030, 0, 467},
+ {"utf-16le", 8, "utf-16le", 8, MyENCODING_UTF_16LE, 0, 468},
+ {"koi8-r", 6, "koi8_r", 6, MyENCODING_KOI8_R, 0, 469},
+ {"shift_jis", 9, "csshiftjis", 10, MyENCODING_SHIFT_JIS, 0, 470},
+ {"iso-8859-6", 10, "iso-8859-6-e", 12, MyENCODING_ISO_8859_6, 472, 471},
+ {"iso-8859-8", 10, "iso-8859-8-e", 12, MyENCODING_ISO_8859_8, 0, 472},
+ {"iso-8859-6", 10, "iso_8859-6:1987", 15, MyENCODING_ISO_8859_6, 474, 473},
+ {"iso-8859-7", 10, "iso_8859-7:1987", 15, MyENCODING_ISO_8859_7, 475, 474},
+ {"windows-1252", 12, "iso_8859-1:1987", 15, MyENCODING_WINDOWS_1252, 0, 475},
+ {"iso-8859-8-i", 12, "iso-8859-8-i", 12, MyENCODING_ISO_8859_8_I, 0, 476},
+ {"windows-874", 11, "iso8859-11", 10, MyENCODING_WINDOWS_874, 478, 477},
+ {"windows-1252", 12, "iso-8859-1", 10, MyENCODING_WINDOWS_1252, 479, 478},
+ {"windows-1252", 12, "iso_8859-1", 10, MyENCODING_WINDOWS_1252, 0, 479},
+ {"iso-8859-3", 10, "iso_8859-3", 10, MyENCODING_ISO_8859_3, 481, 480},
+ {"iso-8859-13", 11, "iso8859-13", 10, MyENCODING_ISO_8859_13, 0, 481},
+ {"iso-8859-5", 10, "iso_8859-5", 10, MyENCODING_ISO_8859_5, 483, 482},
+ {"iso-8859-15", 11, "iso8859-15", 10, MyENCODING_ISO_8859_15, 0, 483},
+ {"iso-8859-7", 10, "iso-8859-7", 10, MyENCODING_ISO_8859_7, 485, 484},
+ {"iso-8859-7", 10, "iso_8859-7", 10, MyENCODING_ISO_8859_7, 486, 485},
+ {"iso-8859-10", 11, "iso-ir-157", 10, MyENCODING_ISO_8859_10, 0, 486},
+ {"windows-1254", 12, "iso-8859-9", 10, MyENCODING_WINDOWS_1254, 488, 487},
+ {"windows-1254", 12, "iso_8859-9", 10, MyENCODING_WINDOWS_1254, 489, 488},
+ {"euc-kr", 6, "iso-ir-149", 10, MyENCODING_EUC_KR, 0, 489},
+ {"windows-1258", 12, "windows-1258", 12, MyENCODING_WINDOWS_1258, 0, 490},
+ {"windows-874", 11, "dos-874", 7, MyENCODING_WINDOWS_874, 0, 491},
+ {"iso-8859-8-i", 12, "csiso88598i", 11, MyENCODING_ISO_8859_8_I, 0, 492},
+ {"iso-8859-7", 10, "elot_928", 8, MyENCODING_ISO_8859_7, 0, 493},
};
-static const myhtml_encoding_entry_name_index_t myhtml_encoding_entry_name_index_static_list_index[(MyHTML_ENCODING_LAST_ENTRY + 1)] =
+static const myencoding_entry_name_index_t myencoding_entry_name_index_static_list_index[(MyENCODING_LAST_ENTRY + 1)] =
{
{"UTF-8", 5},
{"AUTO", 4},
@@ -574,7 +574,7 @@ static const myhtml_encoding_entry_name_index_t myhtml_encoding_entry_name_index
{"", 0},
};
-static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_ibm866[] = {
+static const myencoding_trigram_t myencoding_detect_trigrams_index_ibm866[] = {
{{0xA5, 0xAD, 0xA8}, 991}, /* ени */
{{0xAE, 0xA3, 0xAE}, 806}, /* ого */
{{0xE1, 0xE2, 0xA2}, 659}, /* ств */
@@ -1583,7 +1583,7 @@ static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_ibm
{{0xAC, 0xAB, 0xA5}, 10}, /* мле */
};
-static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_iso_8859_5[] = {
+static const myencoding_trigram_t myencoding_detect_trigrams_index_iso_8859_5[] = {
{{0xD5, 0xDD, 0xD8}, 991}, /* ени */
{{0xDE, 0xD3, 0xDE}, 806}, /* ого */
{{0xE1, 0xE2, 0xD2}, 659}, /* ств */
@@ -2592,7 +2592,7 @@ static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_iso
{{0xDC, 0xDB, 0xD5}, 10}, /* мле */
};
-static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_koi8_r[] = {
+static const myencoding_trigram_t myencoding_detect_trigrams_index_koi8_r[] = {
{{0xC5, 0xCE, 0xC9}, 991}, /* ени */
{{0xCF, 0xC7, 0xCF}, 806}, /* ого */
{{0xD3, 0xD4, 0xD7}, 659}, /* ств */
@@ -3601,7 +3601,7 @@ static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_koi
{{0xCD, 0xCC, 0xC5}, 10}, /* мле */
};
-static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_windows_1251[] = {
+static const myencoding_trigram_t myencoding_detect_trigrams_index_windows_1251[] = {
{{0xE5, 0xED, 0xE8}, 991}, /* ени */
{{0xEE, 0xE3, 0xEE}, 806}, /* ого */
{{0xF1, 0xF2, 0xE2}, 659}, /* ств */
@@ -4610,7 +4610,7 @@ static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_win
{{0xEC, 0xEB, 0xE5}, 10}, /* мле */
};
-static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_x_mac_cyrillic[] = {
+static const myencoding_trigram_t myencoding_detect_trigrams_index_x_mac_cyrillic[] = {
{{0xE5, 0xED, 0xE8}, 991}, /* ени */
{{0xEE, 0xE3, 0xEE}, 806}, /* ого */
{{0xF1, 0xF2, 0xE2}, 659}, /* ств */
@@ -5623,4 +5623,4 @@ static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_x_m
} /* extern "C" */
#endif
-#endif /* MyHTML_ENCODING_DETECT_RESOURCE_H */
+#endif /* MyENCODING_DETECT_RESOURCE_H */
diff --git a/include/myencoding/encoding.h b/include/myencoding/encoding.h
new file mode 100644
index 0000000..e14911c
--- /dev/null
+++ b/include/myencoding/encoding.h
@@ -0,0 +1,160 @@
+/*
+ Copyright (C) 2015-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 MyENCODING_ENCODING_H
+#define MyENCODING_ENCODING_H
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+
+#include <myencoding/myosi.h>
+#include <mycore/utils.h>
+#include <mycore/mystring.h>
+
+struct myencoding_result {
+ unsigned long first;
+ unsigned long second;
+ unsigned long third;
+ unsigned long result;
+ unsigned long result_aux;
+ unsigned long flag;
+};
+
+struct myencoding_trigram {
+ const unsigned char trigram[3];
+ size_t value;
+};
+
+struct myencoding_trigram_result {
+ size_t count;
+ size_t value;
+};
+
+struct myencoding_unicode_result {
+ size_t count_ascii;
+ size_t count_good;
+ size_t count_bad;
+};
+
+struct myencoding_detect_name_entry {
+ const char* name;
+ size_t name_length;
+ const char* label;
+ size_t label_length;
+
+ myencoding_t encoding;
+
+ size_t next;
+ size_t curr;
+};
+
+struct myencoding_detect_attr {
+ size_t key_begin;
+ size_t key_length;
+ size_t value_begin;
+ size_t value_length;
+
+ myencoding_detect_attr_t *next;
+};
+
+struct myencoding_entry_name_index {
+ const char *name;
+ size_t length;
+};
+
+typedef myencoding_status_t (*myencoding_custom_f)(unsigned const char data, myencoding_result_t *res);
+
+myencoding_custom_f myencoding_get_function_by_id(myencoding_t idx);
+
+myencoding_status_t myencoding_decode_utf_8(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_ibm866(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_2(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_3(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_4(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_5(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_6(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_7(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_8(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_8_i(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_10(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_13(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_14(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_15(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_16(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_koi8_r(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_koi8_u(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_macintosh(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_874(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1250(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1251(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1252(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1253(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1254(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1255(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1256(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1257(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1258(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_x_mac_cyrillic(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_gbk(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_gb18030(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_big5(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_euc_jp(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_2022_jp(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_shift_jis(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_euc_kr(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_shared_utf_16(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_utf_16be(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_utf_16le(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_x_user_defined(unsigned const char data, myencoding_result_t *res);
+
+size_t myencoding_codepoint_ascii_length(size_t codepoint);
+size_t myencoding_ascii_utf_8_length(const unsigned char data);
+
+size_t myencoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data);
+size_t myencoding_codepoint_to_lowercase_ascii_utf_8(size_t codepoint, char *data);
+size_t myencoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data);
+size_t myencoding_ascii_utf_8_to_codepoint(const unsigned char* data, size_t* codepoint);
+
+void myencoding_result_clean(myencoding_result_t *res);
+
+bool myencoding_detect(const char *text, size_t length, myencoding_t *encoding);
+bool myencoding_detect_russian(const char *text, size_t length, myencoding_t *encoding);
+bool myencoding_detect_unicode(const char *text, size_t length, myencoding_t *encoding);
+bool myencoding_detect_bom(const char *text, size_t length, myencoding_t *encoding);
+bool myencoding_detect_and_cut_bom(const char *text, size_t length, myencoding_t *encoding, const char **new_text, size_t *new_size);
+
+size_t myencoding_convert_to_ascii_utf_8(mycore_string_raw_t* raw_str, const char* buff, size_t length, myencoding_t encoding);
+
+const myencoding_detect_name_entry_t * myencoding_name_entry_by_name(const char* name, size_t length);
+bool myencoding_by_name(const char *name, size_t length, myencoding_t *encoding);
+const char * myencoding_name_by_id(myencoding_t encoding, size_t *length);
+
+bool myencoding_extracting_character_encoding_from_charset(const char *data, size_t data_size, myencoding_t *encoding);
+myencoding_t myencoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyENCODING_ENCODING_H */
diff --git a/include/myencoding/myosi.h b/include/myencoding/myosi.h
new file mode 100644
index 0000000..5c2296e
--- /dev/null
+++ b/include/myencoding/myosi.h
@@ -0,0 +1,114 @@
+/*
+ Copyright (C) 2015-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 MyENCODING_MYOSI_H
+#define MyENCODING_MYOSI_H
+#pragma once
+
+#include <mycore/myosi.h>
+
+#define MyENCODING_VERSION_MAJOR 0
+#define MyENCODING_VERSION_MINOR 1
+#define MyENCODING_VERSION_PATCH 0
+
+#define MyENCODING_VERSION_STRING MyCORE_STR(MyENCODING_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyENCODING_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyENCODING_VERSION_PATCH)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// encoding
+// https://encoding.spec.whatwg.org/#the-encoding
+// https://encoding.spec.whatwg.org/#legacy-single-byte-encodings
+// https://encoding.spec.whatwg.org/#legacy-multi-byte-chinese-(simplified)-encodings
+// https://encoding.spec.whatwg.org/#legacy-multi-byte-chinese-(traditional)-encodings
+// https://encoding.spec.whatwg.org/#legacy-multi-byte-japanese-encodings
+// https://encoding.spec.whatwg.org/#legacy-multi-byte-korean-encodings
+// https://encoding.spec.whatwg.org/#legacy-miscellaneous-encodings
+
+enum myencoding_list {
+ MyENCODING_DEFAULT = 0x00,
+ //MyENCODING_AUTO = 0x01, // future
+ MyENCODING_NOT_DETERMINED = 0x02,
+ MyENCODING_UTF_8 = 0x00, // default encoding
+ MyENCODING_UTF_16LE = 0x04,
+ MyENCODING_UTF_16BE = 0x05,
+ MyENCODING_X_USER_DEFINED = 0x06,
+ MyENCODING_BIG5 = 0x07,
+ MyENCODING_EUC_JP = 0x08,
+ MyENCODING_EUC_KR = 0x09,
+ MyENCODING_GB18030 = 0x0a,
+ MyENCODING_GBK = 0x0b,
+ MyENCODING_IBM866 = 0x0c,
+ MyENCODING_ISO_2022_JP = 0x0d,
+ MyENCODING_ISO_8859_10 = 0x0e,
+ MyENCODING_ISO_8859_13 = 0x0f,
+ MyENCODING_ISO_8859_14 = 0x10,
+ MyENCODING_ISO_8859_15 = 0x11,
+ MyENCODING_ISO_8859_16 = 0x12,
+ MyENCODING_ISO_8859_2 = 0x13,
+ MyENCODING_ISO_8859_3 = 0x14,
+ MyENCODING_ISO_8859_4 = 0x15,
+ MyENCODING_ISO_8859_5 = 0x16,
+ MyENCODING_ISO_8859_6 = 0x17,
+ MyENCODING_ISO_8859_7 = 0x18,
+ MyENCODING_ISO_8859_8 = 0x19,
+ MyENCODING_ISO_8859_8_I = 0x1a,
+ MyENCODING_KOI8_R = 0x1b,
+ MyENCODING_KOI8_U = 0x1c,
+ MyENCODING_MACINTOSH = 0x1d,
+ MyENCODING_SHIFT_JIS = 0x1e,
+ MyENCODING_WINDOWS_1250 = 0x1f,
+ MyENCODING_WINDOWS_1251 = 0x20,
+ MyENCODING_WINDOWS_1252 = 0x21,
+ MyENCODING_WINDOWS_1253 = 0x22,
+ MyENCODING_WINDOWS_1254 = 0x23,
+ MyENCODING_WINDOWS_1255 = 0x24,
+ MyENCODING_WINDOWS_1256 = 0x25,
+ MyENCODING_WINDOWS_1257 = 0x26,
+ MyENCODING_WINDOWS_1258 = 0x27,
+ MyENCODING_WINDOWS_874 = 0x28,
+ MyENCODING_X_MAC_CYRILLIC = 0x29,
+ MyENCODING_LAST_ENTRY = 0x2a
+}
+typedef myencoding_t;
+
+enum myencoding_status {
+ MyENCODING_STATUS_OK = 0x0000,
+ MyENCODING_STATUS_ERROR = 0x0001,
+ MyENCODING_STATUS_CONTINUE = 0x0002,
+ MyENCODING_STATUS_DONE = 0x0004
+}
+typedef myencoding_status_t;
+
+typedef struct myencoding_result myencoding_result_t;
+typedef struct myencoding_trigram myencoding_trigram_t;
+typedef struct myencoding_trigram_result myencoding_trigram_result_t;
+typedef struct myencoding_unicode_result myencoding_unicode_result_t;
+typedef struct myencoding_detect_name_entry myencoding_detect_name_entry_t;
+typedef struct myencoding_detect_attr myencoding_detect_attr_t;
+typedef struct myencoding_entry_name_index myencoding_entry_name_index_t;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyENCODING_MYOSI_H */
+
diff --git a/include/myencoding/mystring.h b/include/myencoding/mystring.h
new file mode 100644
index 0000000..771b0ef
--- /dev/null
+++ b/include/myencoding/mystring.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 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 MyENCODING_MYSTRING_H
+#define MyENCODING_MYSTRING_H
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <myencoding/myosi.h>
+#include <myencoding/encoding.h>
+#include <mycore/mystring.h>
+#include <mycore/utils.h>
+
+void myencoding_string_append(mycore_string_t* str, const char* buff, size_t length, myencoding_t encoding);
+
+/* append with convert encoding */
+void myencoding_string_append_chunk(mycore_string_t* str, myencoding_result_t* res, const char* buff, size_t length, myencoding_t encoding);
+void myencoding_string_append_one(mycore_string_t* str, myencoding_result_t* res, const char data, myencoding_t encoding);
+
+/* append with convert encoding lowercase */
+void myencoding_string_append_lowercase_ascii(mycore_string_t* str, const char* buff, size_t length, myencoding_t encoding);
+void myencoding_string_append_chunk_lowercase_ascii(mycore_string_t* str, myencoding_result_t* res, const char* buff, size_t length, myencoding_t encoding);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyENCODING_MYSTRING_H */
diff --git a/include/myhtml/encoding_resource.h b/include/myencoding/resource.h
index 6ec72e2..9c8e845 100644
--- a/include/myhtml/encoding_resource.h
+++ b/include/myencoding/resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,17 +18,17 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include <myhtml/encoding.h>
+#include <myencoding/encoding.h>
-#ifndef MyHTML_ENCODING_RESOURCE_H
-#define MyHTML_ENCODING_RESOURCE_H
+#ifndef MyENCODING_RESOURCE_H
+#define MyENCODING_RESOURCE_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-static const unsigned long myhtml_encoding_map_big5[] = {
+static const unsigned long myencoding_map_big5[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -2010,7 +2010,7 @@ static const unsigned long myhtml_encoding_map_big5[] = {
168205, 31188,
};
-static const unsigned long myhtml_encoding_map_euc_kr[] = {
+static const unsigned long myencoding_map_euc_kr[] = {
44034, 44035, 44037, 44038, 44043, 44044, 44045, 44046, 44047, 44056,
44062, 44063, 44065, 44066, 44067, 44069, 44070, 44071, 44072, 44073,
44074, 44075, 44078, 44082, 44083, 44084, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -4408,7 +4408,7 @@ static const unsigned long myhtml_encoding_map_euc_kr[] = {
};
-static const unsigned long myhtml_encoding_map_gb18030[] = {
+static const unsigned long myencoding_map_gb18030[] = {
19970, 19972, 19973, 19974, 19983, 19986, 19991, 19999, 20000, 20001,
20003, 20006, 20009, 20014, 20015, 20017, 20019, 20021, 20023, 20028,
20032, 20033, 20034, 20036, 20038, 20042, 20049, 20053, 20055, 20058,
@@ -6806,7 +6806,7 @@ static const unsigned long myhtml_encoding_map_gb18030[] = {
};
-static const unsigned long myhtml_encoding_map_gb18030_ranges[][2] = {
+static const unsigned long myencoding_map_gb18030_ranges[][2] = {
{0, 128}, {36, 165}, {38, 169}, {45, 178}, {50, 184},
{81, 216}, {89, 226}, {95, 235}, {96, 238}, {100, 244},
{103, 248}, {104, 251}, {105, 253}, {109, 258}, {126, 276},
@@ -6851,7 +6851,7 @@ static const unsigned long myhtml_encoding_map_gb18030_ranges[][2] = {
{39394, 65510}, {189000, 65536},
};
-static const unsigned long myhtml_encoding_map_ibm866[] = {
+static const unsigned long myencoding_map_ibm866[] = {
1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049,
1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059,
1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069,
@@ -6867,7 +6867,7 @@ static const unsigned long myhtml_encoding_map_ibm866[] = {
176, 8729, 183, 8730, 8470, 164, 9632, 160,
};
-static const unsigned long myhtml_encoding_map_iso_8859_10[] = {
+static const unsigned long myencoding_map_iso_8859_10[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6883,7 +6883,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_10[] = {
248, 371, 250, 251, 252, 253, 254, 312,
};
-static const unsigned long myhtml_encoding_map_iso_8859_13[] = {
+static const unsigned long myencoding_map_iso_8859_13[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6899,7 +6899,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_13[] = {
371, 322, 347, 363, 252, 380, 382, 8217,
};
-static const unsigned long myhtml_encoding_map_iso_8859_14[] = {
+static const unsigned long myencoding_map_iso_8859_14[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6915,7 +6915,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_14[] = {
248, 249, 250, 251, 252, 253, 375, 255,
};
-static const unsigned long myhtml_encoding_map_iso_8859_15[] = {
+static const unsigned long myencoding_map_iso_8859_15[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6931,7 +6931,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_15[] = {
248, 249, 250, 251, 252, 253, 254, 255,
};
-static const unsigned long myhtml_encoding_map_iso_8859_16[] = {
+static const unsigned long myencoding_map_iso_8859_16[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6947,7 +6947,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_16[] = {
369, 249, 250, 251, 252, 281, 539, 255,
};
-static const unsigned long myhtml_encoding_map_iso_8859_2[] = {
+static const unsigned long myencoding_map_iso_8859_2[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6963,7 +6963,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_2[] = {
345, 367, 250, 369, 252, 253, 355, 729,
};
-static const unsigned long myhtml_encoding_map_iso_8859_3[] = {
+static const unsigned long myencoding_map_iso_8859_3[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6979,7 +6979,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_3[] = {
285, 249, 250, 251, 252, 365, 349, 729,
};
-static const unsigned long myhtml_encoding_map_iso_8859_4[] = {
+static const unsigned long myencoding_map_iso_8859_4[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6995,7 +6995,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_4[] = {
248, 371, 250, 251, 252, 361, 363, 729,
};
-static const unsigned long myhtml_encoding_map_iso_8859_5[] = {
+static const unsigned long myencoding_map_iso_8859_5[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -7011,7 +7011,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_5[] = {
1112, 1113, 1114, 1115, 1116, 167, 1118, 1119,
};
-static const unsigned long myhtml_encoding_map_iso_8859_6[] = {
+static const unsigned long myencoding_map_iso_8859_6[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -7027,7 +7027,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_6[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
};
-static const unsigned long myhtml_encoding_map_iso_8859_7[] = {
+static const unsigned long myencoding_map_iso_8859_7[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -7043,7 +7043,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_7[] = {
968, 969, 970, 971, 972, 973, 974, 0x0000,
};
-static const unsigned long myhtml_encoding_map_iso_8859_8[] = {
+static const unsigned long myencoding_map_iso_8859_8[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -7059,7 +7059,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_8[] = {
1512, 1513, 1514, 0x0000, 0x0000, 8206, 8207, 0x0000,
};
-static const unsigned long myhtml_encoding_map_jis0208[] = {
+static const unsigned long myencoding_map_jis0208[] = {
12288, 12289, 12290, 65292, 65294, 12539, 65306, 65307, 65311, 65281,
12443, 12444, 180, 65344, 168, 65342, 65507, 65343, 12541, 12542,
12445, 12446, 12291, 20189, 12293, 12294, 12295, 12540, 8213, 8208,
@@ -8191,7 +8191,7 @@ static const unsigned long myhtml_encoding_map_jis0208[] = {
};
-static const unsigned long myhtml_encoding_map_jis0212[] = {
+static const unsigned long myencoding_map_jis0212[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -9078,7 +9078,7 @@ static const unsigned long myhtml_encoding_map_jis0212[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
};
-static const unsigned long myhtml_encoding_map_koi8_r[] = {
+static const unsigned long myencoding_map_koi8_r[] = {
9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524,
9532, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 8992,
9632, 8729, 8730, 8776, 8804, 8805, 160, 8993, 176, 178,
@@ -9094,7 +9094,7 @@ static const unsigned long myhtml_encoding_map_koi8_r[] = {
1068, 1067, 1047, 1064, 1069, 1065, 1063, 1066,
};
-static const unsigned long myhtml_encoding_map_koi8_u[] = {
+static const unsigned long myencoding_map_koi8_u[] = {
9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524,
9532, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 8992,
9632, 8729, 8730, 8776, 8804, 8805, 160, 8993, 176, 178,
@@ -9110,7 +9110,7 @@ static const unsigned long myhtml_encoding_map_koi8_u[] = {
1068, 1067, 1047, 1064, 1069, 1065, 1063, 1066,
};
-static const unsigned long myhtml_encoding_map_macintosh[] = {
+static const unsigned long myencoding_map_macintosh[] = {
196, 197, 199, 201, 209, 214, 220, 225, 224, 226,
228, 227, 229, 231, 233, 232, 234, 235, 237, 236,
238, 239, 241, 243, 242, 244, 246, 245, 250, 249,
@@ -9126,7 +9126,7 @@ static const unsigned long myhtml_encoding_map_macintosh[] = {
175, 728, 729, 730, 184, 733, 731, 711,
};
-static const unsigned long myhtml_encoding_map_windows_1250[] = {
+static const unsigned long myencoding_map_windows_1250[] = {
8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240,
352, 8249, 346, 356, 381, 377, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 152, 8482, 353, 8250, 347, 357,
@@ -9142,7 +9142,7 @@ static const unsigned long myhtml_encoding_map_windows_1250[] = {
345, 367, 250, 369, 252, 253, 355, 729,
};
-static const unsigned long myhtml_encoding_map_windows_1251[] = {
+static const unsigned long myencoding_map_windows_1251[] = {
1026, 1027, 8218, 1107, 8222, 8230, 8224, 8225, 8364, 8240,
1033, 8249, 1034, 1036, 1035, 1039, 1106, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 152, 8482, 1113, 8250, 1114, 1116,
@@ -9158,7 +9158,7 @@ static const unsigned long myhtml_encoding_map_windows_1251[] = {
1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103,
};
-static const unsigned long myhtml_encoding_map_windows_1252[] = {
+static const unsigned long myencoding_map_windows_1252[] = {
8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240,
352, 8249, 338, 141, 381, 143, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157,
@@ -9174,7 +9174,7 @@ static const unsigned long myhtml_encoding_map_windows_1252[] = {
248, 249, 250, 251, 252, 253, 254, 255,
};
-static const unsigned long myhtml_encoding_map_windows_1253[] = {
+static const unsigned long myencoding_map_windows_1253[] = {
8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 136, 8240,
138, 8249, 140, 141, 142, 143, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 152, 8482, 154, 8250, 156, 157,
@@ -9190,7 +9190,7 @@ static const unsigned long myhtml_encoding_map_windows_1253[] = {
968, 969, 970, 971, 972, 973, 974, 0x0000,
};
-static const unsigned long myhtml_encoding_map_windows_1254[] = {
+static const unsigned long myencoding_map_windows_1254[] = {
8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240,
352, 8249, 338, 141, 142, 143, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157,
@@ -9206,7 +9206,7 @@ static const unsigned long myhtml_encoding_map_windows_1254[] = {
248, 249, 250, 251, 252, 305, 351, 255,
};
-static const unsigned long myhtml_encoding_map_windows_1255[] = {
+static const unsigned long myencoding_map_windows_1255[] = {
8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240,
138, 8249, 140, 141, 142, 143, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 732, 8482, 154, 8250, 156, 157,
@@ -9222,7 +9222,7 @@ static const unsigned long myhtml_encoding_map_windows_1255[] = {
1512, 1513, 1514, 0x0000, 0x0000, 8206, 8207, 0x0000,
};
-static const unsigned long myhtml_encoding_map_windows_1256[] = {
+static const unsigned long myencoding_map_windows_1256[] = {
8364, 1662, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240,
1657, 8249, 338, 1670, 1688, 1672, 1711, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 1705, 8482, 1681, 8250, 339, 8204,
@@ -9238,7 +9238,7 @@ static const unsigned long myhtml_encoding_map_windows_1256[] = {
1617, 249, 1618, 251, 252, 8206, 8207, 1746,
};
-static const unsigned long myhtml_encoding_map_windows_1257[] = {
+static const unsigned long myencoding_map_windows_1257[] = {
8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240,
138, 8249, 140, 168, 711, 184, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 152, 8482, 154, 8250, 156, 175,
@@ -9254,7 +9254,7 @@ static const unsigned long myhtml_encoding_map_windows_1257[] = {
371, 322, 347, 363, 252, 380, 382, 729,
};
-static const unsigned long myhtml_encoding_map_windows_1258[] = {
+static const unsigned long myencoding_map_windows_1258[] = {
8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240,
138, 8249, 338, 141, 142, 143, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 732, 8482, 154, 8250, 339, 157,
@@ -9270,7 +9270,7 @@ static const unsigned long myhtml_encoding_map_windows_1258[] = {
248, 249, 250, 251, 252, 432, 8363, 255,
};
-static const unsigned long myhtml_encoding_map_windows_874[] = {
+static const unsigned long myencoding_map_windows_874[] = {
8364, 129, 130, 131, 132, 8230, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 152, 153, 154, 155, 156, 157,
@@ -9286,7 +9286,7 @@ static const unsigned long myhtml_encoding_map_windows_874[] = {
3672, 3673, 3674, 3675, 0x0000, 0x0000, 0x0000, 0x0000,
};
-static const unsigned long myhtml_encoding_map_x_mac_cyrillic[] = {
+static const unsigned long myencoding_map_x_mac_cyrillic[] = {
1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049,
1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059,
1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069,
@@ -9302,28 +9302,75 @@ static const unsigned long myhtml_encoding_map_x_mac_cyrillic[] = {
1096, 1097, 1098, 1099, 1100, 1101, 1102, 8364,
};
-static const myhtml_encoding_custom_f myhtml_encoding_function_index[] = {
- myhtml_encoding_decode_utf_8, NULL, NULL, myhtml_encoding_decode_utf_8, myhtml_encoding_decode_utf_16le,
- myhtml_encoding_decode_utf_16be, myhtml_encoding_decode_x_user_defined,
- myhtml_encoding_decode_big5, myhtml_encoding_decode_euc_kr, myhtml_encoding_decode_gb18030,
- myhtml_encoding_decode_ibm866, myhtml_encoding_decode_iso_8859_10, myhtml_encoding_decode_iso_8859_13,
- myhtml_encoding_decode_iso_8859_14, myhtml_encoding_decode_iso_8859_15, myhtml_encoding_decode_iso_8859_16,
- myhtml_encoding_decode_iso_8859_2, myhtml_encoding_decode_iso_8859_3, myhtml_encoding_decode_iso_8859_4,
- myhtml_encoding_decode_iso_8859_5, myhtml_encoding_decode_iso_8859_6, myhtml_encoding_decode_iso_8859_7,
- myhtml_encoding_decode_iso_8859_8, myhtml_encoding_decode_koi8_r, myhtml_encoding_decode_koi8_u,
- myhtml_encoding_decode_macintosh, myhtml_encoding_decode_windows_1250, myhtml_encoding_decode_windows_1251,
- myhtml_encoding_decode_windows_1252, myhtml_encoding_decode_windows_1253, myhtml_encoding_decode_windows_1254,
- myhtml_encoding_decode_windows_1255, myhtml_encoding_decode_windows_1256, myhtml_encoding_decode_windows_1257,
- myhtml_encoding_decode_windows_1258, myhtml_encoding_decode_windows_874, myhtml_encoding_decode_x_mac_cyrillic,
- myhtml_encoding_decode_iso_2022_jp, myhtml_encoding_decode_gbk, myhtml_encoding_decode_shift_jis,
- myhtml_encoding_decode_euc_jp, myhtml_encoding_decode_iso_8859_8_i
+//static const myencoding_custom_f myencoding_function_index[] = {
+// myencoding_decode_utf_8, NULL, NULL, myencoding_decode_utf_8, myencoding_decode_utf_16le,
+// myencoding_decode_utf_16be, myencoding_decode_x_user_defined,
+// myencoding_decode_big5, myencoding_decode_euc_kr, myencoding_decode_gb18030,
+// myencoding_decode_ibm866, myencoding_decode_iso_8859_10, myencoding_decode_iso_8859_13,
+// myencoding_decode_iso_8859_14, myencoding_decode_iso_8859_15, myencoding_decode_iso_8859_16,
+// myencoding_decode_iso_8859_2, myencoding_decode_iso_8859_3, myencoding_decode_iso_8859_4,
+// myencoding_decode_iso_8859_5, myencoding_decode_iso_8859_6, myencoding_decode_iso_8859_7,
+// myencoding_decode_iso_8859_8, myencoding_decode_koi8_r, myencoding_decode_koi8_u,
+// myencoding_decode_macintosh, myencoding_decode_windows_1250, myencoding_decode_windows_1251,
+// myencoding_decode_windows_1252, myencoding_decode_windows_1253, myencoding_decode_windows_1254,
+// myencoding_decode_windows_1255, myencoding_decode_windows_1256, myencoding_decode_windows_1257,
+// myencoding_decode_windows_1258, myencoding_decode_windows_874, myencoding_decode_x_mac_cyrillic,
+// myencoding_decode_iso_2022_jp, myencoding_decode_gbk, myencoding_decode_shift_jis,
+// myencoding_decode_euc_jp, myencoding_decode_iso_8859_8_i
+//};
+
+static const myencoding_custom_f myencoding_function_index[] =
+{
+ myencoding_decode_utf_8, // MyENCODING_DEFAULT
+ NULL,
+ NULL,
+ myencoding_decode_utf_8, // MyENCODING_UTF_8
+ myencoding_decode_utf_16le, // MyENCODING_UTF_16LE
+ myencoding_decode_utf_16be, // MyENCODING_UTF_16BE
+ myencoding_decode_x_user_defined, // MyENCODING_X_USER_DEFINED
+ myencoding_decode_big5, // MyENCODING_BIG5
+ myencoding_decode_euc_jp, // MyENCODING_EUC_JP
+ myencoding_decode_euc_kr, // MyENCODING_EUC_KR
+ myencoding_decode_gb18030, // MyENCODING_GB18030
+ myencoding_decode_gbk, // MyENCODING_GBK
+ myencoding_decode_ibm866, // MyENCODING_IBM866
+ myencoding_decode_iso_2022_jp, // MyENCODING_ISO_2022_JP
+ myencoding_decode_iso_8859_10, // MyENCODING_ISO_8859_10
+ myencoding_decode_iso_8859_13, // MyENCODING_ISO_8859_13
+ myencoding_decode_iso_8859_14, // MyENCODING_ISO_8859_14
+ myencoding_decode_iso_8859_15, // MyENCODING_ISO_8859_15
+ myencoding_decode_iso_8859_16, // MyENCODING_ISO_8859_16
+ myencoding_decode_iso_8859_2, // MyENCODING_ISO_8859_2
+ myencoding_decode_iso_8859_3, // MyENCODING_ISO_8859_3
+ myencoding_decode_iso_8859_4, // MyENCODING_ISO_8859_4
+ myencoding_decode_iso_8859_5, // MyENCODING_ISO_8859_5
+ myencoding_decode_iso_8859_6, // MyENCODING_ISO_8859_6
+ myencoding_decode_iso_8859_7, // MyENCODING_ISO_8859_7
+ myencoding_decode_iso_8859_8, // MyENCODING_ISO_8859_8
+ myencoding_decode_iso_8859_8_i, // MyENCODING_ISO_8859_8_I
+ myencoding_decode_koi8_r, // MyENCODING_KOI8_R
+ myencoding_decode_koi8_u, // MyENCODING_KOI8_U
+ myencoding_decode_macintosh, // MyENCODING_MACINTOSH
+ myencoding_decode_shift_jis, // MyENCODING_SHIFT_JIS
+ myencoding_decode_windows_1250, // MyENCODING_WINDOWS_1250
+ myencoding_decode_windows_1251, // MyENCODING_WINDOWS_1251
+ myencoding_decode_windows_1252, // MyENCODING_WINDOWS_1252
+ myencoding_decode_windows_1253, // MyENCODING_WINDOWS_1253
+ myencoding_decode_windows_1254, // MyENCODING_WINDOWS_1254
+ myencoding_decode_windows_1255, // MyENCODING_WINDOWS_1255
+ myencoding_decode_windows_1256, // MyENCODING_WINDOWS_1256
+ myencoding_decode_windows_1257, // MyENCODING_WINDOWS_1257
+ myencoding_decode_windows_1258, // MyENCODING_WINDOWS_1258
+ myencoding_decode_windows_874, // MyENCODING_WINDOWS_874
+ myencoding_decode_x_mac_cyrillic, // MyENCODING_X_MAC_CYRILLIC
+ NULL,
};
#ifdef __cplusplus
} /* extern "C" */
#endif
-#endif /* MyHTML_ENCODING_RESOURCE_H */
+#endif /* MyENCODING_RESOURCE_H */
diff --git a/include/myfont/cmap.h b/include/myfont/cmap.h
index 8eae7b9..583f756 100644
--- a/include/myfont/cmap.h
+++ b/include/myfont/cmap.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -208,9 +208,9 @@ typedef myfont_table_cmap_t;
#include <myfont/myfont.h>
-myfont_status_t myfont_load_table_cmap(myfont_font_t *mf);
+mystatus_t myfont_load_table_cmap(myfont_font_t* mf, uint8_t* data, size_t data_size);
-uint16_t myfont_glyph_index_by_codepoint(myfont_font_t *mf, unsigned long char_code, myfont_status_t* status);
+uint16_t myfont_glyph_index_by_codepoint(myfont_font_t *mf, unsigned long char_code, mystatus_t* status);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myfont/glyf.h b/include/myfont/glyf.h
index 2d2e223..8c146db 100644
--- a/include/myfont/glyf.h
+++ b/include/myfont/glyf.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -99,13 +99,13 @@ typedef myfont_table_glyf_t;
struct myfont_font;
-myfont_status_t myfont_load_table_glyf(struct myfont_font *mf);
+mystatus_t myfont_load_table_glyf(myfont_font_t *mf, uint8_t* data, size_t data_size);
-myfont_status_t myfont_glyf_load(struct myfont_font *mf, myfont_table_glyph_t *glyph, uint16_t glyph_index);
-myfont_status_t myfont_glyf_load_data(struct myfont_font *mf, myfont_table_glyph_t *glyph, uint32_t offset);
-myfont_status_t myfont_glyf_load_simple(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, uint32_t offset);
-myfont_status_t myfont_glyf_load_simple_flags(struct myfont_font *mf, myfont_table_glyph_t *glyph, uint8_t *data, uint32_t offset);
-myfont_status_t myfont_glyf_load_simple_coordinates(struct myfont_font *mf, myfont_table_glyph_t *glyph, uint8_t *data, uint32_t offset);
+mystatus_t myfont_glyf_load(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t* data, size_t data_size, uint16_t glyph_index);
+mystatus_t myfont_glyf_load_data(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t* data, size_t data_size, uint32_t offset);
+mystatus_t myfont_glyf_load_simple(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, size_t data_size, uint32_t offset);
+mystatus_t myfont_glyf_load_simple_flags(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, size_t data_size, uint32_t offset);
+mystatus_t myfont_glyf_load_simple_coordinates(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, size_t data_size, uint32_t offset);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myfont/head.h b/include/myfont/head.h
index e17dc74..f24655a 100644
--- a/include/myfont/head.h
+++ b/include/myfont/head.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -53,9 +53,9 @@ typedef myfont_table_head_t;
struct myfont_font;
-myfont_status_t myfont_load_table_head(struct myfont_font *mf);
+mystatus_t myfont_load_table_head(myfont_font_t *mf, uint8_t* data, size_t data_size);
-float myfont_head_yMax_pixel(struct myfont_font *mf, float font_size);
+float myfont_head_yMax_pixel(myfont_font_t *mf, float font_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myfont/hhea.h b/include/myfont/hhea.h
index d0406f7..582df31 100644
--- a/include/myfont/hhea.h
+++ b/include/myfont/hhea.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -54,7 +54,7 @@ typedef myfont_table_hhea_t;
struct myfont_font;
-myfont_status_t myfont_load_table_hhea(struct myfont_font *mf);
+mystatus_t myfont_load_table_hhea(myfont_font_t *mf, uint8_t* data, size_t data_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myfont/hmtx.h b/include/myfont/hmtx.h
index 7a2609b..bda5ae3 100644
--- a/include/myfont/hmtx.h
+++ b/include/myfont/hmtx.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -45,7 +45,7 @@ typedef myfont_table_hmtx_t;
struct myfont_font;
-myfont_status_t myfont_load_table_hmtx(struct myfont_font *mf);
+mystatus_t myfont_load_table_hmtx(myfont_font_t* mf, uint8_t* data, size_t data_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myfont/loca.h b/include/myfont/loca.h
index 2419f52..8dd8db6 100644
--- a/include/myfont/loca.h
+++ b/include/myfont/loca.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -38,9 +38,9 @@ typedef myfont_table_loca_t;
struct myfont_font;
-myfont_status_t myfont_load_table_loca(struct myfont_font *mf);
+mystatus_t myfont_load_table_loca(myfont_font_t *mf, uint8_t* data, size_t data_size);
-uint32_t myfont_loca_get_offset(struct myfont_font *mf, uint16_t glyph_index);
+uint32_t myfont_loca_get_offset(myfont_font_t *mf, uint16_t glyph_index);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myfont/maxp.h b/include/myfont/maxp.h
index c078be8..d151c3c 100644
--- a/include/myfont/maxp.h
+++ b/include/myfont/maxp.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -51,7 +51,7 @@ typedef myfont_table_maxp_t;
struct myfont_font;
-myfont_status_t myfont_load_table_maxp(struct myfont_font *mf);
+mystatus_t myfont_load_table_maxp(myfont_font_t *mf, uint8_t* data, size_t data_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myfont/myfont.h b/include/myfont/myfont.h
index a51c4b8..5f1e0a2 100644
--- a/include/myfont/myfont.h
+++ b/include/myfont/myfont.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -22,6 +22,8 @@
#define MyFONT_MyFONT_H
#pragma once
+#include <string.h>
+
#include <myfont/myosi.h>
#include <myfont/cmap.h>
#include <myfont/head.h>
@@ -36,7 +38,13 @@
#include <myfont/pclt.h>
#include <myfont/loca.h>
-#include <myhtml/utils/mchar_async.h>
+#include <mycore/utils/mchar_async.h>
+
+#define MyFONT_VERSION_MAJOR 0
+#define MyFONT_VERSION_MINOR 0
+#define MyFONT_VERSION_PATCH 2
+
+#define MyFONT_VERSION_STRING MyCORE_STR(MyFONT_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyFONT_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyFONT_VERSION_PATCH)
#ifdef __cplusplus
extern "C" {
@@ -83,16 +91,12 @@ struct myfont_font {
myfont_table_pclt_t table_pclt;
myfont_table_loca_t table_loca;
- char* file_path;
- size_t file_size;
- uint8_t* file_data;
-
mchar_async_t* mchar;
size_t mchar_node_id;
};
myfont_font_t * myfont_create(void);
-myfont_status_t myfont_init(myfont_font_t *mf);
+mystatus_t myfont_init(myfont_font_t *mf);
void myfont_clean(myfont_font_t *mf);
myfont_font_t * myfont_destroy(myfont_font_t *mf, bool self_destroy);
@@ -100,10 +104,11 @@ void * myfont_malloc(myfont_font_t* mf, size_t size);
void * myfont_calloc(myfont_font_t* mf, size_t count, size_t size);
void myfont_free(myfont_font_t *mf, void* data);
-myfont_status_t myfont_load(myfont_font_t *mf, const char *filepath);
+mystatus_t myfont_load(myfont_font_t* mf, uint8_t* data, size_t data_size);
+mystatus_t myfont_load_from_file(myfont_font_t* mf, const char* filepath, uint8_t** return_data, size_t* data_size);
+void * myfont_destroy_font_data(myfont_font_t* mf, uint8_t* return_data);
-void myfont_font_print_exists_table(myfont_font_t *mf, FILE *file);
-myfont_status_t myfont_check_required_tables(myfont_font_t *mf);
+mystatus_t myfont_check_required_tables(myfont_font_t *mf);
float myfont_metrics_baseline(myfont_font_t *mf, float font_size);
float myfont_metrics_ascender(myfont_font_t *mf, float font_size);
@@ -113,11 +118,11 @@ float myfont_metrics_x_height(myfont_font_t *mf, float font_size);
float myfont_metrics_cap_height(myfont_font_t *mf, float font_size);
float myfont_metrics_font_height(myfont_font_t *mf, float font_size);
-float myfont_metrics_width(myfont_font_t *mf, unsigned long codepoint, float font_size, myfont_status_t* status);
-float myfont_metrics_height(myfont_font_t *mf, unsigned long codepoint, float font_size, myfont_status_t* status);
-float myfont_metrics_glyph_offset_y(myfont_font_t *mf, unsigned long codepoint, float font_size, myfont_status_t* status);
+float myfont_metrics_width(myfont_font_t *mf, unsigned long codepoint, float font_size, mystatus_t* status);
+float myfont_metrics_height(myfont_font_t *mf, unsigned long codepoint, float font_size, mystatus_t* status);
+float myfont_metrics_glyph_offset_y(myfont_font_t *mf, unsigned long codepoint, float font_size, mystatus_t* status);
-myfont_status_t myfont_load_table(myfont_font_t *mf, void *table, size_t size, enum myfont_table_key tkey);
+mystatus_t myfont_load_table(myfont_font_t *mf, void *table, size_t size, enum myfont_table_key tkey);
int16_t myfont_table_version_major(uint32_t version);
int16_t myfont_table_version_minor(uint32_t version);
diff --git a/include/myfont/myosi.h b/include/myfont/myosi.h
index 410f1f2..caecfc4 100644
--- a/include/myfont/myosi.h
+++ b/include/myfont/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -85,7 +85,6 @@ extern "C" {
// base
/*
Very important!!!
- see modest/myosi.h:modest_status_t
*/
enum myfont_status {
MyFONT_STATUS_OK = 0x000000,
diff --git a/include/myfont/name.h b/include/myfont/name.h
index e3a7010..153f596 100644
--- a/include/myfont/name.h
+++ b/include/myfont/name.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -60,8 +60,8 @@ typedef myfont_table_name_t;
struct myfont_font;
-myfont_status_t myfont_load_table_name(struct myfont_font *mf);
-
+mystatus_t myfont_load_table_name(myfont_font_t *mf, uint8_t* data, size_t data_size);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/include/myfont/os_2.h b/include/myfont/os_2.h
index f7462cc..52468a3 100644
--- a/include/myfont/os_2.h
+++ b/include/myfont/os_2.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -90,9 +90,9 @@ typedef myfont_table_os_2_t;
struct myfont_font;
-myfont_status_t myfont_load_table_os_2(struct myfont_font *mf);
+mystatus_t myfont_load_table_os_2(myfont_font_t* mf, uint8_t* data, size_t data_size);
-int8_t myfont_os_2_panose(struct myfont_font *mf, myfont_table_os_2_panose_t id);
+int8_t myfont_os_2_panose(myfont_font_t* mf, myfont_table_os_2_panose_t id);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myfont/pclt.h b/include/myfont/pclt.h
index 9ea8343..c37fd8c 100644
--- a/include/myfont/pclt.h
+++ b/include/myfont/pclt.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -52,7 +52,7 @@ typedef myfont_table_pclt_t;
struct myfont_font;
-myfont_status_t myfont_load_table_pclt(struct myfont_font *mf);
+mystatus_t myfont_load_table_pclt(myfont_font_t* mf, uint8_t* data, size_t data_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myfont/vhea.h b/include/myfont/vhea.h
index 0735be1..e2a1faf 100644
--- a/include/myfont/vhea.h
+++ b/include/myfont/vhea.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -54,7 +54,7 @@ typedef myfont_table_vhea_t;
struct myfont_font;
-myfont_status_t myfont_load_table_vhea(struct myfont_font *mf);
+mystatus_t myfont_load_table_vhea(myfont_font_t* mf, uint8_t* data, size_t data_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myfont/vmtx.h b/include/myfont/vmtx.h
index 2d8cbe5..bd4645d 100644
--- a/include/myfont/vmtx.h
+++ b/include/myfont/vmtx.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -45,7 +45,7 @@ typedef myfont_table_vmtx_t;
struct myfont_font;
-myfont_status_t myfont_load_table_vmtx(struct myfont_font *mf);
+mystatus_t myfont_load_table_vmtx(myfont_font_t* mf, uint8_t* data, size_t data_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myhtml/api.h b/include/myhtml/api.h
index e7eb4a6..9599750 100755
--- a/include/myhtml/api.h
+++ b/include/myhtml/api.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -34,14 +34,22 @@
*
*/
-#define MyHTML_VERSION_MAJOR 3
+#define MyHTML_VERSION_MAJOR 4
#define MyHTML_VERSION_MINOR 0
#define MyHTML_VERSION_PATCH 0
+#define MyHTML_VERSION_STRING MyCORE_STR(MyHTML_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyHTML_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyHTML_VERSION_PATCH)
+
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
+#include <mycore/myosi.h>
+#include <mycore/incoming.h>
+#include <mycore/mystring.h>
+#include <mycore/utils/mchar_async.h>
+#include <myencoding/myosi.h>
+
#if defined(_MSC_VER)
# define MyHTML_DEPRECATED(func) __declspec(deprecated) func
#elif defined(__GNUC__) || defined(__INTEL_COMPILER)
@@ -55,56 +63,6 @@ extern "C" {
#endif
/**
- * encodings type
- */
-enum myhtml_encoding_list {
- MyHTML_ENCODING_DEFAULT = 0x00,
-// MyHTML_ENCODING_AUTO = 0x01, // future
- MyHTML_ENCODING_NOT_DETERMINED = 0x02,
- MyHTML_ENCODING_UTF_8 = 0x00, // default encoding
- MyHTML_ENCODING_UTF_16LE = 0x04,
- MyHTML_ENCODING_UTF_16BE = 0x05,
- MyHTML_ENCODING_X_USER_DEFINED = 0x06,
- MyHTML_ENCODING_BIG5 = 0x07,
- MyHTML_ENCODING_EUC_JP = 0x08,
- MyHTML_ENCODING_EUC_KR = 0x09,
- MyHTML_ENCODING_GB18030 = 0x0a,
- MyHTML_ENCODING_GBK = 0x0b,
- MyHTML_ENCODING_IBM866 = 0x0c,
- MyHTML_ENCODING_ISO_2022_JP = 0x0d,
- MyHTML_ENCODING_ISO_8859_10 = 0x0e,
- MyHTML_ENCODING_ISO_8859_13 = 0x0f,
- MyHTML_ENCODING_ISO_8859_14 = 0x10,
- MyHTML_ENCODING_ISO_8859_15 = 0x11,
- MyHTML_ENCODING_ISO_8859_16 = 0x12,
- MyHTML_ENCODING_ISO_8859_2 = 0x13,
- MyHTML_ENCODING_ISO_8859_3 = 0x14,
- MyHTML_ENCODING_ISO_8859_4 = 0x15,
- MyHTML_ENCODING_ISO_8859_5 = 0x16,
- MyHTML_ENCODING_ISO_8859_6 = 0x17,
- MyHTML_ENCODING_ISO_8859_7 = 0x18,
- MyHTML_ENCODING_ISO_8859_8 = 0x19,
- MyHTML_ENCODING_ISO_8859_8_I = 0x1a,
- MyHTML_ENCODING_KOI8_R = 0x1b,
- MyHTML_ENCODING_KOI8_U = 0x1c,
- MyHTML_ENCODING_MACINTOSH = 0x1d,
- MyHTML_ENCODING_SHIFT_JIS = 0x1e,
- MyHTML_ENCODING_WINDOWS_1250 = 0x1f,
- MyHTML_ENCODING_WINDOWS_1251 = 0x20,
- MyHTML_ENCODING_WINDOWS_1252 = 0x21,
- MyHTML_ENCODING_WINDOWS_1253 = 0x22,
- MyHTML_ENCODING_WINDOWS_1254 = 0x23,
- MyHTML_ENCODING_WINDOWS_1255 = 0x24,
- MyHTML_ENCODING_WINDOWS_1256 = 0x25,
- MyHTML_ENCODING_WINDOWS_1257 = 0x26,
- MyHTML_ENCODING_WINDOWS_1258 = 0x27,
- MyHTML_ENCODING_WINDOWS_874 = 0x28,
- MyHTML_ENCODING_X_MAC_CYRILLIC = 0x29,
- MyHTML_ENCODING_LAST_ENTRY = 0x2a
-}
-typedef myhtml_encoding_t;
-
-/**
* @struct basic tag ids
*/
enum myhtml_tags {
@@ -384,54 +342,27 @@ enum myhtml_status {
MyHTML_STATUS_OK = 0x0000,
MyHTML_STATUS_ERROR = 0x0001,
MyHTML_STATUS_ERROR_MEMORY_ALLOCATION = 0x0002,
- MyHTML_STATUS_THREAD_ERROR_MEMORY_ALLOCATION = 0x0009,
- MyHTML_STATUS_THREAD_ERROR_LIST_INIT = 0x000a,
- MyHTML_STATUS_THREAD_ERROR_ATTR_MALLOC = 0x000b,
- MyHTML_STATUS_THREAD_ERROR_ATTR_INIT = 0x000c,
- MyHTML_STATUS_THREAD_ERROR_ATTR_SET = 0x000d,
- MyHTML_STATUS_THREAD_ERROR_ATTR_DESTROY = 0x000e,
- MyHTML_STATUS_THREAD_ERROR_NO_SLOTS = 0x000f,
- MyHTML_STATUS_THREAD_ERROR_BATCH_INIT = 0x0010,
- MyHTML_STATUS_THREAD_ERROR_WORKER_MALLOC = 0x0011,
- MyHTML_STATUS_THREAD_ERROR_WORKER_SEM_CREATE = 0x0012,
- MyHTML_STATUS_THREAD_ERROR_WORKER_THREAD_CREATE = 0x0013,
- MyHTML_STATUS_THREAD_ERROR_MASTER_THREAD_CREATE = 0x0014,
- MyHTML_STATUS_THREAD_ERROR_SEM_PREFIX_MALLOC = 0x0032,
- MyHTML_STATUS_THREAD_ERROR_SEM_CREATE = 0x0033,
- MyHTML_STATUS_THREAD_ERROR_QUEUE_MALLOC = 0x003c,
- MyHTML_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC = 0x003d,
- MyHTML_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC = 0x003e,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_MALLOC = 0x0046,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_INIT = 0x0047,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_LOCK = 0x0048,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_UNLOCK = 0x0049,
- MyHTML_STATUS_RULES_ERROR_MEMORY_ALLOCATION = 0x0064,
- MyHTML_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF = 0x00c8,
- MyHTML_STATUS_PERF_ERROR_FIND_CPU_CLOCK = 0x00c9,
- MyHTML_STATUS_TOKENIZER_ERROR_MEMORY_ALLOCATION = 0x012c,
- MyHTML_STATUS_TOKENIZER_ERROR_FRAGMENT_INIT = 0x012d,
- MyHTML_STATUS_TAGS_ERROR_MEMORY_ALLOCATION = 0x0190,
- MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE = 0x0191,
- MyHTML_STATUS_TAGS_ERROR_MCOBJECT_MALLOC = 0x0192,
- MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE_NODE = 0x0193,
- MyHTML_STATUS_TAGS_ERROR_CACHE_MEMORY_ALLOCATION = 0x0194,
- MyHTML_STATUS_TAGS_ERROR_INDEX_MEMORY_ALLOCATION = 0x0195,
- MyHTML_STATUS_TREE_ERROR_MEMORY_ALLOCATION = 0x01f4,
- MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE = 0x01f5,
- MyHTML_STATUS_TREE_ERROR_MCOBJECT_INIT = 0x01f6,
- MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE_NODE = 0x01f7,
- MyHTML_STATUS_TREE_ERROR_INCOMING_BUFFER_CREATE = 0x01f8,
- MyHTML_STATUS_ATTR_ERROR_ALLOCATION = 0x0258,
- MyHTML_STATUS_ATTR_ERROR_CREATE = 0x0259,
- MyHTML_STATUS_STREAM_BUFFER_ERROR_CREATE = 0x0300,
- MyHTML_STATUS_STREAM_BUFFER_ERROR_INIT = 0x0301,
- MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_CREATE = 0x0302,
- MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_INIT = 0x0303,
- MyHTML_STATUS_STREAM_BUFFER_ERROR_ADD_ENTRY = 0x0304,
- MyHTML_STATUS_MCOBJECT_ERROR_CACHE_CREATE = 0x0340,
- MyHTML_STATUS_MCOBJECT_ERROR_CHUNK_CREATE = 0x0341,
- MyHTML_STATUS_MCOBJECT_ERROR_CHUNK_INIT = 0x0342,
- MyHTML_STATUS_MCOBJECT_ERROR_CACHE_REALLOC = 0x0343
+ MyHTML_STATUS_RULES_ERROR_MEMORY_ALLOCATION = 0x9064,
+ MyHTML_STATUS_TOKENIZER_ERROR_MEMORY_ALLOCATION = 0x912c,
+ MyHTML_STATUS_TOKENIZER_ERROR_FRAGMENT_INIT = 0x912d,
+ MyHTML_STATUS_TAGS_ERROR_MEMORY_ALLOCATION = 0x9190,
+ MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE = 0x9191,
+ MyHTML_STATUS_TAGS_ERROR_MCOBJECT_MALLOC = 0x9192,
+ MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE_NODE = 0x9193,
+ MyHTML_STATUS_TAGS_ERROR_CACHE_MEMORY_ALLOCATION = 0x9194,
+ MyHTML_STATUS_TAGS_ERROR_INDEX_MEMORY_ALLOCATION = 0x9195,
+ MyHTML_STATUS_TREE_ERROR_MEMORY_ALLOCATION = 0x91f4,
+ MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE = 0x91f5,
+ MyHTML_STATUS_TREE_ERROR_MCOBJECT_INIT = 0x91f6,
+ MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE_NODE = 0x91f7,
+ MyHTML_STATUS_TREE_ERROR_INCOMING_BUFFER_CREATE = 0x91f8,
+ MyHTML_STATUS_ATTR_ERROR_ALLOCATION = 0x9258,
+ MyHTML_STATUS_ATTR_ERROR_CREATE = 0x9259,
+ MyHTML_STATUS_STREAM_BUFFER_ERROR_CREATE = 0x9300,
+ MyHTML_STATUS_STREAM_BUFFER_ERROR_INIT = 0x9301,
+ MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_CREATE = 0x9302,
+ MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_INIT = 0x9303,
+ MyHTML_STATUS_STREAM_BUFFER_ERROR_ADD_ENTRY = 0x9304
}
typedef myhtml_status_t;
@@ -492,6 +423,11 @@ typedef struct myhtml myhtml_t;
*/
typedef struct myhtml_tree myhtml_tree_t;
+/**
+ * @struct myhtml_token_t MyHTML_TOKEN
+ */
+typedef struct myhtml_token myhtml_token_t;
+
typedef struct myhtml_token_attr myhtml_tree_attr_t;
typedef struct myhtml_tree_node myhtml_tree_node_t;
@@ -503,39 +439,6 @@ typedef size_t myhtml_tag_id_t;
typedef struct myhtml_tag myhtml_tag_t;
/**
- * MCHAR_ASYNC structures
- *
- */
-typedef struct mchar_async mchar_async_t;
-
-/**
- * MyHTML_INCOMING structures
- *
- */
-typedef struct myhtml_incoming_buffer myhtml_incoming_buffer_t;
-
-/**
- * MyHTML_STRING structures
- *
- */
-struct myhtml_string {
- char* data;
- size_t size;
- size_t length;
-
- mchar_async_t *mchar;
- size_t node_idx;
-}
-typedef myhtml_string_t;
-
-struct myhtml_string_raw {
- char* data;
- size_t size;
- size_t length;
-}
-typedef myhtml_string_raw_t;
-
-/**
* @struct myhtml_collection_t
*/
struct myhtml_collection {
@@ -572,7 +475,6 @@ typedef myhtml_version_t;
// callback functions
typedef void* (*myhtml_callback_token_f)(myhtml_tree_t* tree, myhtml_token_node_t* token, void* ctx);
typedef void (*myhtml_callback_tree_node_f)(myhtml_tree_t* tree, myhtml_tree_node_t* node, void* ctx);
-typedef void (*myhtml_callback_serialize_f)(const char* buffer, size_t size, void* ctx);
/***********************************************************************************
*
@@ -602,7 +504,7 @@ myhtml_create(void);
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status value.
*/
-myhtml_status_t
+mystatus_t
myhtml_init(myhtml_t* myhtml, enum myhtml_options opt,
size_t thread_count, size_t queue_size);
@@ -627,7 +529,7 @@ myhtml_destroy(myhtml_t* myhtml);
* Parsing HTML
*
* @param[in] previously created structure myhtml_tree_t*
- * @param[in] Input character encoding; Default: MyHTML_ENCODING_UTF_8 or MyHTML_ENCODING_DEFAULT or 0
+ * @param[in] Input character encoding; Default: MyENCODING_UTF_8 or MyENCODING_DEFAULT or 0
* @param[in] HTML
* @param[in] HTML size
*
@@ -635,15 +537,15 @@ myhtml_destroy(myhtml_t* myhtml);
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
-myhtml_parse(myhtml_tree_t* tree, myhtml_encoding_t encoding,
+mystatus_t
+myhtml_parse(myhtml_tree_t* tree, myencoding_t encoding,
const char* html, size_t html_size);
/**
* Parsing fragment of HTML
*
* @param[in] previously created structure myhtml_tree_t*
- * @param[in] Input character encoding; Default: MyHTML_ENCODING_UTF_8 or MyHTML_ENCODING_DEFAULT or 0
+ * @param[in] Input character encoding; Default: MyENCODING_UTF_8 or MyENCODING_DEFAULT or 0
* @param[in] HTML
* @param[in] HTML size
* @param[in] fragment base (root) tag id. Default: MyHTML_TAG_DIV if set 0
@@ -653,8 +555,8 @@ myhtml_parse(myhtml_tree_t* tree, myhtml_encoding_t encoding,
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
-myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t encoding,
+mystatus_t
+myhtml_parse_fragment(myhtml_tree_t* tree, myencoding_t encoding,
const char* html, size_t html_size,
myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
@@ -663,7 +565,7 @@ myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t encoding,
* No matter what was said during initialization MyHTML
*
* @param[in] previously created structure myhtml_tree_t*
- * @param[in] Input character encoding; Default: MyHTML_ENCODING_UTF_8 or MyHTML_ENCODING_DEFAULT or 0
+ * @param[in] Input character encoding; Default: MyENCODING_UTF_8 or MyENCODING_DEFAULT or 0
* @param[in] HTML
* @param[in] HTML size
*
@@ -671,8 +573,8 @@ myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t encoding,
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
-myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encoding,
+mystatus_t
+myhtml_parse_single(myhtml_tree_t* tree, myencoding_t encoding,
const char* html, size_t html_size);
/**
@@ -680,7 +582,7 @@ myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encoding,
* No matter what was said during initialization MyHTML
*
* @param[in] previously created structure myhtml_tree_t*
- * @param[in] Input character encoding; Default: MyHTML_ENCODING_UTF_8 or MyHTML_ENCODING_DEFAULT or 0
+ * @param[in] Input character encoding; Default: MyENCODING_UTF_8 or MyENCODING_DEFAULT or 0
* @param[in] HTML
* @param[in] HTML size
* @param[in] fragment base (root) tag id. Default: MyHTML_TAG_DIV if set 0
@@ -690,8 +592,8 @@ myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encoding,
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
-myhtml_parse_fragment_single(myhtml_tree_t* tree, myhtml_encoding_t encoding,
+mystatus_t
+myhtml_parse_fragment_single(myhtml_tree_t* tree, myencoding_t encoding,
const char* html, size_t html_size,
myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
@@ -704,7 +606,7 @@ myhtml_parse_fragment_single(myhtml_tree_t* tree, myhtml_encoding_t encoding,
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
+mystatus_t
myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t html_size);
/**
@@ -718,7 +620,7 @@ myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t html_size);
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
+mystatus_t
myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* html,size_t html_size,
myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
@@ -732,7 +634,7 @@ myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* html,size_t html_si
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
+mystatus_t
myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, size_t html_size);
/**
@@ -747,7 +649,7 @@ myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, size_t html_siz
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
+mystatus_t
myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const char* html, size_t html_size,
myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
@@ -758,7 +660,7 @@ myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const char* html, size_t
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
+mystatus_t
myhtml_parse_chunk_end(myhtml_tree_t* tree);
/***********************************************************************************
@@ -783,7 +685,7 @@ myhtml_tree_create(void);
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
+mystatus_t
myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml);
/**
@@ -936,47 +838,13 @@ size_t
myhtml_tree_get_mchar_node_id(myhtml_tree_t* tree);
/**
- * Print tree of a node. Print including current node
- *
- * @param[in] myhtml_tree_t*
- * @param[in] myhtml_tree_node_t*
- * @param[in] file handle, for example use stdout
- * @param[in] tab (\t) increment for pretty print, set 0
- */
-void
-myhtml_tree_print_by_node(myhtml_tree_t* tree, myhtml_tree_node_t* node,
- FILE* out, size_t inc);
-
-/**
- * Print tree of a node. Print excluding current node
- *
- * @param[in] myhtml_tree_t*
- * @param[in] myhtml_tree_node_t*
- * @param[in] file handle, for example use stdout
- * @param[in] tab (\t) increment for pretty print, set 0
- */
-void
-myhtml_tree_print_node_children(myhtml_tree_t* tree, myhtml_tree_node_t* node,
- FILE* out, size_t inc);
-
-/**
- * Print a node
- *
- * @param[in] myhtml_tree_t*
- * @param[in] myhtml_tree_node_t*
- * @param[in] file handle, for example use stdout
- */
-void
-myhtml_tree_print_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out);
-
-/**
* Get first Incoming Buffer
*
* @param[in] myhtml_tree_t*
*
- * @return myhtml_incoming_buffer_t* if successful, otherwise a NULL value
+ * @return mycore_incoming_buffer_t* if successful, otherwise a NULL value
*/
-myhtml_incoming_buffer_t*
+mycore_incoming_buffer_t*
myhtml_tree_incoming_buffer_first(myhtml_tree_t *tree);
/***********************************************************************************
@@ -1007,7 +875,7 @@ myhtml_node_first(myhtml_tree_t* tree);
*/
myhtml_collection_t*
myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_collection_t *collection,
- myhtml_tag_id_t tag_id, myhtml_status_t *status);
+ myhtml_tag_id_t tag_id, mystatus_t *status);
/**
* Get nodes by tag name
@@ -1022,7 +890,7 @@ myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_collection_t *collection,
*/
myhtml_collection_t*
myhtml_get_nodes_by_name(myhtml_tree_t* tree, myhtml_collection_t *collection,
- const char* name, size_t length, myhtml_status_t *status);
+ const char* name, size_t length, mystatus_t *status);
/**
* Get nodes by attribute key
@@ -1039,7 +907,7 @@ myhtml_get_nodes_by_name(myhtml_tree_t* tree, myhtml_collection_t *collection,
myhtml_collection_t*
myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myhtml_collection_t* collection,
myhtml_tree_node_t* scope_node,
- const char* key, size_t key_len, myhtml_status_t* status);
+ const char* key, size_t key_len, mystatus_t* status);
/**
* Get nodes by attribute value; exactly equal; like a [foo="bar"]
@@ -1063,7 +931,7 @@ myhtml_get_nodes_by_attribute_value(myhtml_tree_t *tree,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/**
* Get nodes by attribute value; whitespace separated; like a [foo~="bar"]
@@ -1089,7 +957,7 @@ myhtml_get_nodes_by_attribute_value_whitespace_separated(myhtml_tree_t *tree,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/**
* Get nodes by attribute value; value begins exactly with the string; like a [foo^="bar"]
@@ -1115,7 +983,7 @@ myhtml_get_nodes_by_attribute_value_begin(myhtml_tree_t *tree,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/**
@@ -1142,7 +1010,7 @@ myhtml_get_nodes_by_attribute_value_end(myhtml_tree_t *tree,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/**
* Get nodes by attribute value; value contains the substring; like a [foo*="bar"]
@@ -1168,7 +1036,7 @@ myhtml_get_nodes_by_attribute_value_contain(myhtml_tree_t *tree,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/**
* Get nodes by attribute value; attribute value is a hyphen-separated list of values beginning;
@@ -1193,7 +1061,7 @@ myhtml_get_nodes_by_attribute_value_hyphen_separated(myhtml_tree_t *tree,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/**
* Get nodes by tag id in node scope
@@ -1209,7 +1077,7 @@ myhtml_get_nodes_by_attribute_value_hyphen_separated(myhtml_tree_t *tree,
myhtml_collection_t*
myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection,
myhtml_tree_node_t *node, myhtml_tag_id_t tag_id,
- myhtml_status_t *status);
+ mystatus_t *status);
/**
* Get nodes by tag name in node scope
@@ -1226,7 +1094,7 @@ myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, myhtml_collection_t *co
myhtml_collection_t*
myhtml_get_nodes_by_name_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection,
myhtml_tree_node_t *node, const char* html, size_t length,
- myhtml_status_t *status);
+ mystatus_t *status);
/**
* Get next sibling node
@@ -1378,11 +1246,11 @@ myhtml_node_insert_before(myhtml_tree_node_t *target, myhtml_tree_node_t *node);
* @param[in] text length
* @param[in] character encoding
*
- * @return myhtml_string_t* if successful, otherwise a NULL value
+ * @return mycore_string_t* if successful, otherwise a NULL value
*/
-myhtml_string_t*
+mycore_string_t*
myhtml_node_text_set(myhtml_tree_node_t *node, const char* text, size_t length,
- myhtml_encoding_t encoding);
+ myencoding_t encoding);
/**
* Add text for a node with convert character encoding.
@@ -1392,11 +1260,11 @@ myhtml_node_text_set(myhtml_tree_node_t *node, const char* text, size_t length,
* @param[in] text length
* @param[in] character encoding
*
- * @return myhtml_string_t* if successful, otherwise a NULL value
+ * @return mycore_string_t* if successful, otherwise a NULL value
*/
-myhtml_string_t*
+mycore_string_t*
myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, const char* text, size_t length,
- myhtml_encoding_t encoding);
+ myencoding_t encoding);
/**
* Get token node
@@ -1479,13 +1347,13 @@ const char*
myhtml_node_text(myhtml_tree_node_t *node, size_t *length);
/**
- * Get myhtml_string_t object by Tree node
+ * Get mycore_string_t object by Tree node
*
* @param[in] myhtml_tree_node_t*
*
- * @return myhtml_string_t* if exists, otherwise an NULL value
+ * @return mycore_string_t* if exists, otherwise an NULL value
*/
-myhtml_string_t*
+mycore_string_t*
myhtml_node_string(myhtml_tree_node_t *node);
/**
@@ -1613,9 +1481,9 @@ myhtml_attribute_value(myhtml_tree_attr_t *attr, size_t *length);
*
* @param[in] myhtml_tree_attr_t*
*
- * @return myhtml_string_t* if exists, otherwise an NULL value
+ * @return mycore_string_t* if exists, otherwise an NULL value
*/
-myhtml_string_t*
+mycore_string_t*
myhtml_attribute_key_string(myhtml_tree_attr_t* attr);
/**
@@ -1623,9 +1491,9 @@ myhtml_attribute_key_string(myhtml_tree_attr_t* attr);
*
* @param[in] myhtml_tree_attr_t*
*
- * @return myhtml_string_t* if exists, otherwise an NULL value
+ * @return mycore_string_t* if exists, otherwise an NULL value
*/
-myhtml_string_t*
+mycore_string_t*
myhtml_attribute_value_string(myhtml_tree_attr_t* attr);
/**
@@ -1649,7 +1517,7 @@ myhtml_attribute_by_key(myhtml_tree_node_t *node,
* @param[in] attr key name length
* @param[in] attr value name
* @param[in] attr value name length
- * @param[in] character encoding; Default: MyHTML_ENCODING_UTF_8 or MyHTML_ENCODING_DEFAULT or 0
+ * @param[in] character encoding; Default: MyENCODING_UTF_8 or MyENCODING_DEFAULT or 0
*
* @return created myhtml_tree_attr_t* if successful, otherwise a NULL value
*/
@@ -1657,7 +1525,7 @@ myhtml_tree_attr_t*
myhtml_attribute_add(myhtml_tree_node_t *node,
const char *key, size_t key_len,
const char *value, size_t value_len,
- myhtml_encoding_t encoding);
+ myencoding_t encoding);
/**
* Remove attribute reference. Not release the resources
@@ -1797,13 +1665,13 @@ const char*
myhtml_token_node_text(myhtml_token_node_t *token_node, size_t *length);
/**
- * Get myhtml_string_t object by token node
+ * Get mycore_string_t object by token node
*
* @param[in] myhtml_token_node_t*
*
- * @return myhtml_string_t* if exists, otherwise an NULL value
+ * @return mycore_string_t* if exists, otherwise an NULL value
*/
-myhtml_string_t*
+mycore_string_t*
myhtml_token_node_string(myhtml_token_node_t *token_node);
/**
@@ -1829,10 +1697,11 @@ myhtml_token_node_is_close_self(myhtml_token_node_t *token_node);
/**
* Wait for process token all parsing stage. Need if you use thread mode
*
+ * @param[in] myhtml_token_t*
* @param[in] myhtml_token_node_t*
*/
void
-myhtml_token_node_wait_for_done(myhtml_token_node_t* node);
+myhtml_token_node_wait_for_done(myhtml_token_t* token, myhtml_token_node_t* node);
/***********************************************************************************
*
@@ -1881,7 +1750,7 @@ myhtml_tag_id_by_name(myhtml_tree_t* tree,
* @return myhtml_collection_t* if successful, otherwise an NULL value
*/
myhtml_collection_t*
-myhtml_collection_create(size_t size, myhtml_status_t *status);
+myhtml_collection_create(size_t size, mystatus_t *status);
/**
* Clears collection
@@ -1911,7 +1780,7 @@ myhtml_collection_destroy(myhtml_collection_t *collection);
*
* @return NULL if successful, otherwise an myhtml_collection_t* structure
*/
-myhtml_status_t
+mystatus_t
myhtml_collection_check_size(myhtml_collection_t *collection, size_t need, size_t upto_length);
/***********************************************************************************
@@ -1928,16 +1797,16 @@ myhtml_collection_check_size(myhtml_collection_t *collection, size_t need, size_
*
*/
void
-myhtml_encoding_set(myhtml_tree_t* tree, myhtml_encoding_t encoding);
+myhtml_encoding_set(myhtml_tree_t* tree, myencoding_t encoding);
/**
* Get character encoding for current stream
*
* @param[in] myhtml_tree_t*
*
- * @return myhtml_encoding_t
+ * @return myencoding_t
*/
-myhtml_encoding_t
+myencoding_t
myhtml_encoding_get(myhtml_tree_t* tree);
/**
@@ -1950,7 +1819,7 @@ myhtml_encoding_get(myhtml_tree_t* tree);
* @return size character set
*/
size_t
-myhtml_encoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data);
+myencoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data);
/**
* Convert Unicode Codepoint to UTF-16LE
@@ -1964,7 +1833,7 @@ myhtml_encoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data);
* @return size character set
*/
size_t
-myhtml_encoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data);
+myencoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data);
/**
* Detect character encoding
@@ -1980,7 +1849,7 @@ myhtml_encoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data);
* @return true if encoding found, otherwise false
*/
bool
-myhtml_encoding_detect(const char *text, size_t length, myhtml_encoding_t *encoding);
+myencoding_detect(const char *text, size_t length, myencoding_t *encoding);
/**
* Detect Russian character encoding
@@ -1994,7 +1863,7 @@ myhtml_encoding_detect(const char *text, size_t length, myhtml_encoding_t *encod
* @return true if encoding found, otherwise false
*/
bool
-myhtml_encoding_detect_russian(const char *text, size_t length, myhtml_encoding_t *encoding);
+myencoding_detect_russian(const char *text, size_t length, myencoding_t *encoding);
/**
* Detect Unicode character encoding
@@ -2008,7 +1877,7 @@ myhtml_encoding_detect_russian(const char *text, size_t length, myhtml_encoding_
* @return true if encoding found, otherwise false
*/
bool
-myhtml_encoding_detect_unicode(const char *text, size_t length, myhtml_encoding_t *encoding);
+myencoding_detect_unicode(const char *text, size_t length, myencoding_t *encoding);
/**
* Detect Unicode character encoding by BOM
@@ -2022,7 +1891,7 @@ myhtml_encoding_detect_unicode(const char *text, size_t length, myhtml_encoding_
* @return true if encoding found, otherwise false
*/
bool
-myhtml_encoding_detect_bom(const char *text, size_t length, myhtml_encoding_t *encoding);
+myencoding_detect_bom(const char *text, size_t length, myencoding_t *encoding);
/**
* Detect Unicode character encoding by BOM. Cut BOM if will be found
@@ -2038,13 +1907,13 @@ myhtml_encoding_detect_bom(const char *text, size_t length, myhtml_encoding_t *e
* @return true if encoding found, otherwise false
*/
bool
-myhtml_encoding_detect_and_cut_bom(const char *text, size_t length, myhtml_encoding_t *encoding,
+myencoding_detect_and_cut_bom(const char *text, size_t length, myencoding_t *encoding,
const char **new_text, size_t *new_size);
/**
* Detect encoding by name
- * Names like: windows-1258 return MyHTML_ENCODING_WINDOWS_1258
- * cp1251 or windows-1251 return MyHTML_ENCODING_WINDOWS_1251
+ * Names like: windows-1258 return MyENCODING_WINDOWS_1258
+ * cp1251 or windows-1251 return MyENCODING_WINDOWS_1251
*
* See https://encoding.spec.whatwg.org/#names-and-labels
*
@@ -2055,18 +1924,18 @@ myhtml_encoding_detect_and_cut_bom(const char *text, size_t length, myhtml_encod
* @return true if encoding found, otherwise false
*/
bool
-myhtml_encoding_by_name(const char *name, size_t length, myhtml_encoding_t *encoding);
+myencoding_by_name(const char *name, size_t length, myencoding_t *encoding);
/**
- * Get Encoding name by myhtml_encoding_t (by id)
+ * Get Encoding name by myencoding_t (by id)
*
- * @param[in] myhtml_encoding_t, encoding id
+ * @param[in] myencoding_t, encoding id
* @param[out] return name length
*
* @return encoding name, otherwise NULL value
*/
const char*
-myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *length);
+myencoding_name_by_id(myencoding_t encoding, size_t *length);
/**
* Detect encoding in meta tag (<meta ...>) before start parsing
@@ -2076,10 +1945,27 @@ myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *length);
* @param[in] html data bytes
* @param[in] html data length
*
- * @return detected encoding if encoding found, otherwise MyHTML_ENCODING_NOT_DETERMINED
+ * @return detected encoding if encoding found, otherwise MyENCODING_NOT_DETERMINED
*/
-myhtml_encoding_t
-myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size);
+myencoding_t
+myencoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size);
+
+/**
+ * Extracting character encoding from string. Find "charset=" and see encoding.
+ * For example: "text/html; charset=windows-1251". Return MyENCODING_WINDOWS_1251
+ *
+ *
+ * See https://html.spec.whatwg.org/multipage/infrastructure.html#algorithm-for-extracting-a-character-encoding-from-a-meta-element
+ *
+ * @param[in] data
+ * @param[in] data length
+ * @param[out] return encoding
+ *
+ * @return true if encoding found
+ */
+bool
+myencoding_extracting_character_encoding_from_charset(const char *data, size_t data_size,
+ myencoding_t *encoding);
/***********************************************************************************
*
@@ -2088,7 +1974,7 @@ myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t da
***********************************************************************************/
/**
- * Init myhtml_string_t structure
+ * Init mycore_string_t structure
*
* @param[in] mchar_async_t*. It can be obtained from myhtml_tree_t object
* (see myhtml_tree_get_mchar function) or create manualy
@@ -2098,7 +1984,7 @@ myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t da
* if created mchar_async_t object manually you know it, if not then take from the Tree
* (see myhtml_tree_get_mchar_node_id)
*
- * @param[in] myhtml_string_t*. It can be obtained from myhtml_tree_node_t object
+ * @param[in] mycore_string_t*. It can be obtained from myhtml_tree_node_t object
* (see myhtml_node_string function) or create manualy
*
* @param[in] data size. Set the size you want for char*
@@ -2106,137 +1992,137 @@ myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t da
* @return char* of the size if successful, otherwise a NULL value
*/
char*
-myhtml_string_init(mchar_async_t *mchar, size_t node_id,
- myhtml_string_t* str, size_t size);
+mycore_string_init(mchar_async_t *mchar, size_t node_id,
+ mycore_string_t* str, size_t size);
/**
- * Increase the current size for myhtml_string_t object
+ * Increase the current size for mycore_string_t object
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
- * @param[in] data size. Set the new size you want for myhtml_string_t object
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
+ * @param[in] data size. Set the new size you want for mycore_string_t object
*
* @return char* of the size if successful, otherwise a NULL value
*/
char*
-myhtml_string_realloc(myhtml_string_t *str, size_t new_size);
+mycore_string_realloc(mycore_string_t *str, size_t new_size);
/**
- * Clean myhtml_string_t object. In reality, data length set to 0
- * Equivalently: myhtml_string_length_set(str, 0);
+ * Clean mycore_string_t object. In reality, data length set to 0
+ * Equivalently: mycore_string_length_set(str, 0);
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
*/
void
-myhtml_string_clean(myhtml_string_t* str);
+mycore_string_clean(mycore_string_t* str);
/**
- * Clean myhtml_string_t object. Equivalently: memset(str, 0, sizeof(myhtml_string_t))
+ * Clean mycore_string_t object. Equivalently: memset(str, 0, sizeof(mycore_string_t))
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
*/
void
-myhtml_string_clean_all(myhtml_string_t* str);
+mycore_string_clean_all(mycore_string_t* str);
/**
- * Release all resources for myhtml_string_t object
+ * Release all resources for mycore_string_t object
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
* @param[in] call free function for current object or not
*
- * @return NULL if destroy_obj set true, otherwise a current myhtml_string_t object
+ * @return NULL if destroy_obj set true, otherwise a current mycore_string_t object
*/
-myhtml_string_t*
-myhtml_string_destroy(myhtml_string_t* str, bool destroy_obj);
+mycore_string_t*
+mycore_string_destroy(mycore_string_t* str, bool destroy_obj);
/**
- * Get data (char*) from a myhtml_string_t object
+ * Get data (char*) from a mycore_string_t object
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
*
* @return char* if exists, otherwise a NULL value
*/
char*
-myhtml_string_data(myhtml_string_t *str);
+mycore_string_data(mycore_string_t *str);
/**
- * Get data length from a myhtml_string_t object
+ * Get data length from a mycore_string_t object
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
*
* @return data length
*/
size_t
-myhtml_string_length(myhtml_string_t *str);
+mycore_string_length(mycore_string_t *str);
/**
- * Get data size from a myhtml_string_t object
+ * Get data size from a mycore_string_t object
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
*
* @return data size
*/
size_t
-myhtml_string_size(myhtml_string_t *str);
+mycore_string_size(mycore_string_t *str);
/**
- * Set data (char *) for a myhtml_string_t object.
+ * Set data (char *) for a mycore_string_t object.
*
* Attention!!! Attention!!! Attention!!!
*
* You can assign only that it has been allocated from functions:
- * myhtml_string_data_alloc
- * myhtml_string_data_realloc
+ * mycore_string_data_alloc
+ * mycore_string_data_realloc
* or obtained manually created from mchar_async_t object
*
* Attention!!! Do not try set chat* from allocated by malloc or realloc!!!
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
* @param[in] you data to want assign
*
* @return assigned data if successful, otherwise a NULL value
*/
char*
-myhtml_string_data_set(myhtml_string_t *str, char *data);
+mycore_string_data_set(mycore_string_t *str, char *data);
/**
- * Set data size for a myhtml_string_t object.
+ * Set data size for a mycore_string_t object.
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
* @param[in] you size to want assign
*
* @return assigned size
*/
size_t
-myhtml_string_size_set(myhtml_string_t *str, size_t size);
+mycore_string_size_set(mycore_string_t *str, size_t size);
/**
- * Set data length for a myhtml_string_t object.
+ * Set data length for a mycore_string_t object.
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
* @param[in] you length to want assign
*
* @return assigned length
*/
size_t
-myhtml_string_length_set(myhtml_string_t *str, size_t length);
+mycore_string_length_set(mycore_string_t *str, size_t length);
/**
* Allocate data (char*) from a mchar_async_t object
*
- * @param[in] mchar_async_t*. See description for myhtml_string_init function
- * @param[in] node id. See description for myhtml_string_init function
+ * @param[in] mchar_async_t*. See description for mycore_string_init function
+ * @param[in] node id. See description for mycore_string_init function
* @param[in] you size to want assign
*
* @return data if successful, otherwise a NULL value
*/
char*
-myhtml_string_data_alloc(mchar_async_t *mchar, size_t node_id, size_t size);
+mycore_string_data_alloc(mchar_async_t *mchar, size_t node_id, size_t size);
/**
* Allocate data (char*) from a mchar_async_t object
*
- * @param[in] mchar_async_t*. See description for myhtml_string_init function
- * @param[in] node id. See description for myhtml_string_init function
+ * @param[in] mchar_async_t*. See description for mycore_string_init function
+ * @param[in] node id. See description for mycore_string_init function
* @param[in] old data
* @param[in] how much data is copied from the old data to new data
* @param[in] new size
@@ -2244,28 +2130,28 @@ myhtml_string_data_alloc(mchar_async_t *mchar, size_t node_id, size_t size);
* @return data if successful, otherwise a NULL value
*/
char*
-myhtml_string_data_realloc(mchar_async_t *mchar, size_t node_id,
+mycore_string_data_realloc(mchar_async_t *mchar, size_t node_id,
char *data, size_t len_to_copy, size_t size);
/**
* Release allocated data
*
- * @param[in] mchar_async_t*. See description for myhtml_string_init function
- * @param[in] node id. See description for myhtml_string_init function
+ * @param[in] mchar_async_t*. See description for mycore_string_init function
+ * @param[in] node id. See description for mycore_string_init function
* @param[in] data to release
*
* @return data if successful, otherwise a NULL value
*/
void
-myhtml_string_data_free(mchar_async_t *mchar, size_t node_id, char *data);
+mycore_string_data_free(mchar_async_t *mchar, size_t node_id, char *data);
/***********************************************************************************
*
* MyHTML_STRING_RAW
*
- * All work with myhtml_string_raw_t object occurs through
- * myhtml_malloc (standart malloc), myhtml_realloc (standart realloc),
- * myhtml_free (standart free).
+ * All work with mycore_string_raw_t object occurs through
+ * mycore_malloc (standart malloc), mycore_realloc (standart realloc),
+ * mycore_free (standart free).
*
* You are free to change them on without fear that something will happen
* You can call free for str_raw.data, or change str_raw.length = 0
@@ -2273,32 +2159,32 @@ myhtml_string_data_free(mchar_async_t *mchar, size_t node_id, char *data);
***********************************************************************************/
/**
- * Clean myhtml_string_raw_t object. In reality, data length set to 0
+ * Clean mycore_string_raw_t object. In reality, data length set to 0
*
- * @param[in] myhtml_string_raw_t*
+ * @param[in] mycore_string_raw_t*
*/
void
-myhtml_string_raw_clean(myhtml_string_raw_t* str_raw);
+mycore_string_raw_clean(mycore_string_raw_t* str_raw);
/**
- * Full clean myhtml_string_raw_t object.
- * Equivalently: memset(str_raw, 0, sizeof(myhtml_string_raw_t))
+ * Full clean mycore_string_raw_t object.
+ * Equivalently: memset(str_raw, 0, sizeof(mycore_string_raw_t))
*
- * @param[in] myhtml_string_raw_t*
+ * @param[in] mycore_string_raw_t*
*/
void
-myhtml_string_raw_clean_all(myhtml_string_raw_t* str_raw);
+mycore_string_raw_clean_all(mycore_string_raw_t* str_raw);
/**
- * Free resources for myhtml_string_raw_t object
+ * Free resources for mycore_string_raw_t object
*
- * @param[in] myhtml_string_raw_t*
+ * @param[in] mycore_string_raw_t*
* @param[in] call free function for current object or not
*
- * @return NULL if destroy_obj set true, otherwise a current myhtml_string_raw_t object
+ * @return NULL if destroy_obj set true, otherwise a current mycore_string_raw_t object
*/
-myhtml_string_raw_t*
-myhtml_string_raw_destroy(myhtml_string_raw_t* str_raw, bool destroy_obj);
+mycore_string_raw_t*
+mycore_string_raw_destroy(mycore_string_raw_t* str_raw, bool destroy_obj);
/***********************************************************************************
@@ -2316,99 +2202,99 @@ myhtml_string_raw_destroy(myhtml_string_raw_t* str_raw, bool destroy_obj);
/**
* Get Incoming Buffer by position
*
- * @param[in] current myhtml_incoming_buffer_t*
+ * @param[in] current mycore_incoming_buffer_t*
* @param[in] begin position
*
- * @return myhtml_incoming_buffer_t if successful, otherwise a NULL value
+ * @return mycore_incoming_buffer_t if successful, otherwise a NULL value
*/
-myhtml_incoming_buffer_t*
-myhtml_incoming_buffer_find_by_position(myhtml_incoming_buffer_t *inc_buf, size_t begin);
+mycore_incoming_buffer_t*
+mycore_incoming_buffer_find_by_position(mycore_incoming_buffer_t *inc_buf, size_t begin);
/**
* Get data of Incoming Buffer
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
*
* @return const char* if successful, otherwise a NULL value
*/
const char*
-myhtml_incoming_buffer_data(myhtml_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_data(mycore_incoming_buffer_t *inc_buf);
/**
* Get data length of Incoming Buffer
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
*
* @return size_t
*/
size_t
-myhtml_incoming_buffer_length(myhtml_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_length(mycore_incoming_buffer_t *inc_buf);
/**
* Get data size of Incoming Buffer
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
*
* @return size_t
*/
size_t
-myhtml_incoming_buffer_size(myhtml_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_size(mycore_incoming_buffer_t *inc_buf);
/**
* Get data offset of Incoming Buffer. Global position of begin Incoming Buffer.
* See description for MyHTML_INCOMING title
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
*
* @return size_t
*/
size_t
-myhtml_incoming_buffer_offset(myhtml_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_offset(mycore_incoming_buffer_t *inc_buf);
/**
* Get Relative Position for Incoming Buffer.
- * Incoming Buffer should be prepared by myhtml_incoming_buffer_find_by_position
+ * Incoming Buffer should be prepared by mycore_incoming_buffer_find_by_position
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
* @param[in] global begin
*
* @return size_t
*/
size_t
-myhtml_incoming_buffer_relative_begin(myhtml_incoming_buffer_t *inc_buf, size_t begin);
+mycore_incoming_buffer_relative_begin(mycore_incoming_buffer_t *inc_buf, size_t begin);
/**
* This function returns number of available data by Incoming Buffer
- * Incoming buffer may be incomplete. See myhtml_incoming_buffer_next
+ * Incoming buffer may be incomplete. See mycore_incoming_buffer_next
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
* @param[in] global begin
*
* @return size_t
*/
size_t
-myhtml_incoming_buffer_available_length(myhtml_incoming_buffer_t *inc_buf,
+mycore_incoming_buffer_available_length(mycore_incoming_buffer_t *inc_buf,
size_t relative_begin, size_t length);
/**
* Get next buffer
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
*
- * @return myhtml_incoming_buffer_t*
+ * @return mycore_incoming_buffer_t*
*/
-myhtml_incoming_buffer_t*
-myhtml_incoming_buffer_next(myhtml_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_t*
+mycore_incoming_buffer_next(mycore_incoming_buffer_t *inc_buf);
/**
* Get prev buffer
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
*
- * @return myhtml_incoming_buffer_t*
+ * @return mycore_incoming_buffer_t*
*/
-myhtml_incoming_buffer_t*
-myhtml_incoming_buffer_prev(myhtml_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_t*
+mycore_incoming_buffer_prev(mycore_incoming_buffer_t *inc_buf);
/***********************************************************************************
*
@@ -2564,7 +2450,7 @@ myhtml_callback_tree_node_remove_set(myhtml_tree_t* tree, myhtml_callback_tree_n
* @return 0 if match, otherwise index of break position
*/
size_t
-myhtml_strcasecmp(const char* str1, const char* str2);
+mycore_strcasecmp(const char* str1, const char* str2);
/**
* Compare two strings ignoring case of the first n characters
@@ -2575,7 +2461,7 @@ myhtml_strcasecmp(const char* str1, const char* str2);
* @return 0 if match, otherwise index of break position
*/
size_t
-myhtml_strncasecmp(const char* str1, const char* str2, size_t size);
+mycore_strncasecmp(const char* str1, const char* str2, size_t size);
/***********************************************************************************
*
@@ -2587,39 +2473,39 @@ myhtml_strncasecmp(const char* str1, const char* str2, size_t size);
* Tree fragment serialization
* The same as myhtml_serialization_tree_buffer function
*/
-bool
-myhtml_serialization(myhtml_tree_node_t* scope_node, myhtml_string_raw_t* str);
+mystatus_t
+myhtml_serialization(myhtml_tree_node_t* scope_node, mycore_string_raw_t* str);
/**
* Only one tree node serialization
* The same as myhtml_serialization_node_buffer function
*/
-bool
-myhtml_serialization_node(myhtml_tree_node_t* node, myhtml_string_raw_t* str);
+mystatus_t
+myhtml_serialization_node(myhtml_tree_node_t* node, mycore_string_raw_t* str);
/**
* Serialize tree to an output string
*
* @param[in] myhtml_tree_t*
* @param[in] scope node
- * @param[in] myhtml_string_raw_t*
+ * @param[in] mycore_string_raw_t*
*
* @return true if successful, otherwise false
*/
-bool
-myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, myhtml_string_raw_t* str);
+mystatus_t
+myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, mycore_string_raw_t* str);
/**
* Serialize node to an output string
*
* @param[in] myhtml_tree_t*
* @param[in] node
- * @param[in] myhtml_string_raw_t*
+ * @param[in] mycore_string_raw_t*
*
* @return true if successful, otherwise false
*/
-bool
-myhtml_serialization_node_buffer(myhtml_tree_node_t* node, myhtml_string_raw_t* str);
+mystatus_t
+myhtml_serialization_node_buffer(myhtml_tree_node_t* node, mycore_string_raw_t* str);
/**
* The serialize function for an entire tree
@@ -2631,9 +2517,9 @@ myhtml_serialization_node_buffer(myhtml_tree_node_t* node, myhtml_string_raw_t*
*
* @return true if successful, otherwise false
*/
-bool
+mystatus_t
myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node,
- myhtml_callback_serialize_f callback, void* ptr);
+ mycore_callback_serialize_f callback, void* ptr);
/**
* The serialize function for a single node
@@ -2645,9 +2531,9 @@ myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node,
*
* @return true if successful, otherwise false
*/
-bool
+mystatus_t
myhtml_serialization_node_callback(myhtml_tree_node_t* node,
- myhtml_callback_serialize_f callback, void* ptr);
+ mycore_callback_serialize_f callback, void* ptr);
/***********************************************************************************
*
diff --git a/include/myhtml/api_encoding.h b/include/myhtml/api_encoding.h
deleted file mode 100644
index a8dff01..0000000
--- a/include/myhtml/api_encoding.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- Copyright (C) 2015-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 MyHTML_API_ENCODING_H
-#define MyHTML_API_ENCODING_H
-#pragma once
-
-#include <myhtml/api.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum myhtml_encoding_status {
- MyHTML_ENCODING_STATUS_OK = 0x00,
- MyHTML_ENCODING_STATUS_ERROR = 0x01,
- MyHTML_ENCODING_STATUS_CONTINUE = 0x02,
- MyHTML_ENCODING_STATUS_DONE = 0x04
-}
-typedef myhtml_encoding_status_t;
-
-struct myhtml_encoding_result {
- unsigned long first;
- unsigned long second;
- unsigned long third;
- unsigned long result;
- unsigned long result_aux;
- unsigned long flag;
-}
-typedef myhtml_encoding_result_t;
-
-typedef myhtml_encoding_status_t
-(*myhtml_encoding_custom_f)(unsigned const char byte, myhtml_encoding_result_t *res);
-
-/***********************************************************************************
- *
- * MyHTML_ENCODING
- *
- ***********************************************************************************/
-
-/**
- * Clean myhtml_encoding_result_t. Use this function before and after text decode
- *
- * @param[in] myhtml_encoding_result_t*
- */
-void
-myhtml_encoding_result_clean(myhtml_encoding_result_t *res);
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* api_encoding_h */
diff --git a/include/myhtml/callback.h b/include/myhtml/callback.h
index c29dbe6..0379f0e 100644
--- a/include/myhtml/callback.h
+++ b/include/myhtml/callback.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/include/myhtml/charef.h b/include/myhtml/charef.h
index d98dfc6..2293946 100644
--- a/include/myhtml/charef.h
+++ b/include/myhtml/charef.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/include/myhtml/charef_resource.h b/include/myhtml/charef_resource.h
index 79c2086..59d93db 100644
--- a/include/myhtml/charef_resource.h
+++ b/include/myhtml/charef_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/include/myhtml/data_process.h b/include/myhtml/data_process.h
index 64e7bd6..2dfd09c 100644
--- a/include/myhtml/data_process.h
+++ b/include/myhtml/data_process.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -35,8 +35,8 @@ struct myhtml_data_process_entry {
myhtml_data_process_state_f state;
/* for encodings */
- myhtml_encoding_t encoding;
- myhtml_encoding_result_t res;
+ myencoding_t encoding;
+ myencoding_result_t res;
/* temp */
size_t tmp_str_pos_proc;
@@ -53,16 +53,16 @@ struct myhtml_data_process_entry {
void myhtml_data_process_entry_clean(myhtml_data_process_entry_t* proc_entry);
-void myhtml_data_process(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t size);
-void myhtml_data_process_end(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str);
+void myhtml_data_process(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t size);
+void myhtml_data_process_end(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str);
-size_t myhtml_data_process_state_data(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size);
-size_t myhtml_data_process_state_ampersand(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size);
-size_t myhtml_data_process_state_ampersand_data(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size);
-size_t myhtml_data_process_state_ampersand_hash(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size);
-size_t myhtml_data_process_state_ampersand_hash_data(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char *data, size_t offset, size_t size);
-size_t myhtml_data_process_state_ampersand_hash_x_data(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size);
-void myhtml_data_process_state_end(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str);
+size_t myhtml_data_process_state_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size);
+size_t myhtml_data_process_state_ampersand(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size);
+size_t myhtml_data_process_state_ampersand_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size);
+size_t myhtml_data_process_state_ampersand_hash(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size);
+size_t myhtml_data_process_state_ampersand_hash_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char *data, size_t offset, size_t size);
+size_t myhtml_data_process_state_ampersand_hash_x_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size);
+void myhtml_data_process_state_end(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myhtml/def.h b/include/myhtml/def.h
index 389b198..8ec75e6 100644
--- a/include/myhtml/def.h
+++ b/include/myhtml/def.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/include/myhtml/encoding.h b/include/myhtml/encoding.h
deleted file mode 100644
index 1ac3745..0000000
--- a/include/myhtml/encoding.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- Copyright (C) 2015-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 MyHTML_ENCODING_H
-#define MyHTML_ENCODING_H
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <myhtml/myosi.h>
-#include <myhtml/utils.h>
-#include <myhtml/mystring.h>
-
-enum myhtml_encoding_status {
- MyHTML_ENCODING_STATUS_OK = 0x00,
- MyHTML_ENCODING_STATUS_ERROR = 0x01,
- MyHTML_ENCODING_STATUS_CONTINUE = 0x02,
- MyHTML_ENCODING_STATUS_DONE = 0x04
-}
-typedef myhtml_encoding_status_t;
-
-struct myhtml_encoding_result {
- unsigned long first;
- unsigned long second;
- unsigned long third;
- unsigned long result;
- unsigned long result_aux;
- unsigned long flag;
-};
-
-struct myhtml_encoding_trigram {
- const unsigned char trigram[3];
- size_t value;
-};
-
-struct myhtml_encoding_trigram_result {
- size_t count;
- size_t value;
-};
-
-struct myhtml_encoding_unicode_result {
- size_t count_ascii;
- size_t count_good;
- size_t count_bad;
-};
-
-struct myhtml_encoding_detect_name_entry {
- const char* name;
- size_t name_length;
- const char* label;
- size_t label_length;
-
- myhtml_encoding_t encoding;
-
- size_t next;
- size_t curr;
-};
-
-struct myhtml_encoding_detect_attr {
- size_t key_begin;
- size_t key_length;
- size_t value_begin;
- size_t value_length;
-
- myhtml_encoding_detect_attr_t *next;
-};
-
-struct myhtml_encoding_entry_name_index {
- const char *name;
- size_t length;
-};
-
-typedef myhtml_encoding_status_t (*myhtml_encoding_custom_f)(unsigned const char data, myhtml_encoding_result_t *res);
-
-myhtml_encoding_custom_f myhtml_encoding_get_function_by_id(myhtml_encoding_t idx);
-
-enum myhtml_encoding_status myhtml_encoding_decode_utf_8(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_ibm866(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_2(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_3(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_4(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_5(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_6(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_7(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_8(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_8_i(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_10(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_13(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_14(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_15(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_16(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_koi8_r(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_koi8_u(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_macintosh(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_874(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1250(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1251(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1252(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1253(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1254(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1255(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1256(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1257(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1258(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_x_mac_cyrillic(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_gbk(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_gb18030(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_big5(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_euc_jp(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_2022_jp(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_shift_jis(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_euc_kr(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_shared_utf_16(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_utf_16be(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_utf_16le(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_x_user_defined(unsigned const char data, myhtml_encoding_result_t *res);
-
-size_t myhtml_encoding_codepoint_ascii_length(size_t codepoint);
-size_t myhtml_encoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data);
-size_t myhtml_encoding_codepoint_to_lowercase_ascii_utf_8(size_t codepoint, char *data);
-size_t myhtml_encoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data);
-size_t myhtml_encoding_ascii_utf_8_to_codepoint(const unsigned char* data, size_t* codepoint);
-
-void myhtml_encoding_result_clean(myhtml_encoding_result_t *res);
-
-bool myhtml_encoding_detect(const char *text, size_t length, myhtml_encoding_t *encoding);
-bool myhtml_encoding_detect_russian(const char *text, size_t length, myhtml_encoding_t *encoding);
-bool myhtml_encoding_detect_unicode(const char *text, size_t length, myhtml_encoding_t *encoding);
-bool myhtml_encoding_detect_bom(const char *text, size_t length, myhtml_encoding_t *encoding);
-bool myhtml_encoding_detect_and_cut_bom(const char *text, size_t length, myhtml_encoding_t *encoding, const char **new_text, size_t *new_size);
-
-size_t myhtml_encoding_convert_to_ascii_utf_8(myhtml_string_raw_t* raw_str, const char* buff, size_t length, myhtml_encoding_t encoding);
-
-const myhtml_encoding_detect_name_entry_t * myhtml_encoding_name_entry_by_name(const char* name, size_t length);
-bool myhtml_encoding_by_name(const char *name, size_t length, myhtml_encoding_t *encoding);
-const char * myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *length);
-
-myhtml_encoding_t myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* encoding_h */
diff --git a/include/myhtml/myhtml.h b/include/myhtml/myhtml.h
index d214e6a..d111add 100644
--- a/include/myhtml/myhtml.h
+++ b/include/myhtml/myhtml.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -28,19 +28,19 @@ extern "C" {
#include <myhtml/myosi.h>
-#include <myhtml/utils/mctree.h>
-#include <myhtml/utils/mcobject_async.h>
+#include <mycore/utils/mctree.h>
+#include <mycore/utils/mcobject_async.h>
+#include <mycore/mythread.h>
+#include <mycore/incoming.h>
+#include <myencoding/encoding.h>
#include <myhtml/tree.h>
#include <myhtml/tag.h>
#include <myhtml/def.h>
#include <myhtml/parser.h>
#include <myhtml/tokenizer.h>
-#include <myhtml/thread.h>
#include <myhtml/rules.h>
#include <myhtml/token.h>
#include <myhtml/charef.h>
-#include <myhtml/encoding.h>
-#include <myhtml/incoming.h>
#include <myhtml/callback.h>
#define mh_queue_current() tree->queue
@@ -65,8 +65,10 @@ extern "C" {
(onechar < 'A' || onechar > 'Z'))
struct myhtml {
- mythread_t *thread;
- //mchar_async_t *mchar; // for all
+ mythread_t* thread_stream;
+ mythread_t* thread_batch;
+ mythread_t* thread_list[3];
+ size_t thread_total;
myhtml_tokenizer_state_f* parse_state_func;
myhtml_insertion_f* insertion_func;
@@ -83,68 +85,68 @@ struct myhtml_collection {
myhtml_t * myhtml_create(void);
-myhtml_status_t myhtml_init(myhtml_t* myhtml, enum myhtml_options opt, size_t thread_count, size_t queue_size);
+mystatus_t myhtml_init(myhtml_t* myhtml, enum myhtml_options opt, size_t thread_count, size_t queue_size);
void myhtml_clean(myhtml_t* myhtml);
myhtml_t* myhtml_destroy(myhtml_t* myhtml);
-myhtml_status_t myhtml_parse(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size);
-myhtml_status_t myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
+mystatus_t myhtml_parse(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size);
+mystatus_t myhtml_parse_fragment(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
-myhtml_status_t myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size);
-myhtml_status_t myhtml_parse_fragment_single(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
+mystatus_t myhtml_parse_single(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size);
+mystatus_t myhtml_parse_fragment_single(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
-myhtml_status_t myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t html_size);
-myhtml_status_t myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
-myhtml_status_t myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, size_t html_size);
-myhtml_status_t myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
-myhtml_status_t myhtml_parse_chunk_end(myhtml_tree_t* tree);
+mystatus_t myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t html_size);
+mystatus_t myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
+mystatus_t myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, size_t html_size);
+mystatus_t myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
+mystatus_t myhtml_parse_chunk_end(myhtml_tree_t* tree);
// encoding
-void myhtml_encoding_set(myhtml_tree_t* tree, myhtml_encoding_t encoding);
-myhtml_encoding_t myhtml_encoding_get(myhtml_tree_t* tree);
+void myhtml_encoding_set(myhtml_tree_t* tree, myencoding_t encoding);
+myencoding_t myhtml_encoding_get(myhtml_tree_t* tree);
-myhtml_collection_t * myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tag_id_t tag_id, myhtml_status_t *status);
-myhtml_collection_t * myhtml_get_nodes_by_name(myhtml_tree_t* tree, myhtml_collection_t *collection, const char* html, size_t length, myhtml_status_t *status);
-myhtml_collection_t * myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* scope_node, const char* key, size_t key_len, myhtml_status_t* status);
+myhtml_collection_t * myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tag_id_t tag_id, mystatus_t *status);
+myhtml_collection_t * myhtml_get_nodes_by_name(myhtml_tree_t* tree, myhtml_collection_t *collection, const char* html, size_t length, mystatus_t *status);
+myhtml_collection_t * myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* scope_node, const char* key, size_t key_len, mystatus_t* status);
/* like a [some=value] or #id */
myhtml_collection_t * myhtml_get_nodes_by_attribute_value(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* node,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/* like a [some~=value] or .class */
myhtml_collection_t * myhtml_get_nodes_by_attribute_value_whitespace_separated(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* node,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/* like a [some^=value] */
myhtml_collection_t * myhtml_get_nodes_by_attribute_value_begin(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* node,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/* like a [some$=value] */
myhtml_collection_t * myhtml_get_nodes_by_attribute_value_end(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* node,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/* like a [some*=value] */
myhtml_collection_t * myhtml_get_nodes_by_attribute_value_contain(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* node,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/* like a [some|=value] */
myhtml_collection_t * myhtml_get_nodes_by_attribute_value_hyphen_separated(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* node,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
-myhtml_collection_t * myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, myhtml_tag_id_t tag_id, myhtml_status_t *status);
-myhtml_collection_t * myhtml_get_nodes_by_name_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, const char* html, size_t length, myhtml_status_t *status);
+myhtml_collection_t * myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, myhtml_tag_id_t tag_id, mystatus_t *status);
+myhtml_collection_t * myhtml_get_nodes_by_name_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, const char* html, size_t length, mystatus_t *status);
myhtml_tree_node_t * myhtml_node_first(myhtml_tree_t* tree);
myhtml_tree_node_t * myhtml_node_next(myhtml_tree_node_t *node);
@@ -174,7 +176,7 @@ bool myhtml_node_is_close_self(myhtml_tree_node_t *node);
myhtml_tree_attr_t * myhtml_node_attribute_first(myhtml_tree_node_t *node);
myhtml_tree_attr_t * myhtml_node_attribute_last(myhtml_tree_node_t *node);
const char * myhtml_node_text(myhtml_tree_node_t *node, size_t *length);
-myhtml_string_t * myhtml_node_string(myhtml_tree_node_t *node);
+mycore_string_t * myhtml_node_string(myhtml_tree_node_t *node);
myhtml_position_t myhtml_node_raw_pasition(myhtml_tree_node_t *node);
myhtml_position_t myhtml_node_element_pasition(myhtml_tree_node_t *node);
void myhtml_node_set_data(myhtml_tree_node_t *node, void* data);
@@ -188,10 +190,10 @@ void myhtml_attribute_namespace_set(myhtml_tree_attr_t *attr, myhtml_namespace_t
const char * myhtml_attribute_key(myhtml_tree_attr_t *attr, size_t *length);
const char * myhtml_attribute_value(myhtml_tree_attr_t *attr, size_t *length);
-myhtml_string_t * myhtml_attribute_key_string(myhtml_tree_attr_t* attr);
-myhtml_string_t * myhtml_attribute_value_string(myhtml_tree_attr_t* attr);
+mycore_string_t * myhtml_attribute_key_string(myhtml_tree_attr_t* attr);
+mycore_string_t * myhtml_attribute_value_string(myhtml_tree_attr_t* attr);
myhtml_tree_attr_t * myhtml_attribute_by_key(myhtml_tree_node_t *node, const char *key, size_t key_len);
-myhtml_tree_attr_t * myhtml_attribute_add(myhtml_tree_node_t *node, const char *key, size_t key_len, const char *value, size_t value_len, myhtml_encoding_t encoding);
+myhtml_tree_attr_t * myhtml_attribute_add(myhtml_tree_node_t *node, const char *key, size_t key_len, const char *value, size_t value_len, myencoding_t encoding);
myhtml_tree_attr_t * myhtml_attribute_remove(myhtml_tree_node_t *node, myhtml_tree_attr_t *attr);
myhtml_tree_attr_t * myhtml_attribute_remove_by_key(myhtml_tree_node_t *node, const char *key, size_t key_len);
void myhtml_attribute_delete(myhtml_tree_t *tree, myhtml_tree_node_t *node, myhtml_tree_attr_t *attr);
@@ -200,35 +202,20 @@ myhtml_position_t myhtml_attribute_key_raw_position(myhtml_tree_attr_t *attr);
myhtml_position_t myhtml_attribute_value_raw_position(myhtml_tree_attr_t *attr);
/* collection */
-myhtml_collection_t * myhtml_collection_create(size_t size, myhtml_status_t *status);
+myhtml_collection_t * myhtml_collection_create(size_t size, mystatus_t *status);
void myhtml_collection_clean(myhtml_collection_t *collection);
myhtml_collection_t * myhtml_collection_destroy(myhtml_collection_t *collection);
-myhtml_status_t myhtml_collection_check_size(myhtml_collection_t *collection, size_t need, size_t upto_length);
+mystatus_t myhtml_collection_check_size(myhtml_collection_t *collection, size_t need, size_t upto_length);
// strings
-myhtml_string_t * myhtml_node_text_set(myhtml_tree_node_t *node, const char* text, size_t length, myhtml_encoding_t encoding);
-myhtml_string_t * myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, const char* text, size_t length, myhtml_encoding_t encoding);
+mycore_string_t * myhtml_node_text_set(myhtml_tree_node_t *node, const char* text, size_t length, myencoding_t encoding);
+mycore_string_t * myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, const char* text, size_t length, myencoding_t encoding);
bool myhtml_utils_strcmp(const char* ab, const char* to_lowercase, size_t size);
bool myhtml_is_html_node(myhtml_tree_node_t *node, myhtml_tag_id_t tag_id);
// queue
-myhtml_status_t myhtml_queue_add(myhtml_tree_t *tree, size_t begin, myhtml_token_node_t* token);
-
-/**
- * Platform-specific hdef performance clock queries.
- * Implemented in perf.c
- */
-
-/** Get clock resolution */
-uint64_t myhtml_hperf_res(myhtml_status_t *status);
-
-/** Get current value in clock ticks */
-uint64_t myhtml_hperf_clock(myhtml_status_t *status);
-
-/** Print an hperf measure */
-myhtml_status_t myhtml_hperf_print(const char *name, uint64_t x, uint64_t y, FILE *fh);
-myhtml_status_t myhtml_hperf_print_by_val(const char *name, uint64_t x, FILE *fh);
+mystatus_t myhtml_queue_add(myhtml_tree_t *tree, size_t begin, myhtml_token_node_t* token);
/* version */
myhtml_version_t myhtml_version(void);
diff --git a/include/myhtml/mynamespace.h b/include/myhtml/mynamespace.h
index 8046291..6ebf0ab 100644
--- a/include/myhtml/mynamespace.h
+++ b/include/myhtml/mynamespace.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -31,7 +31,7 @@ extern "C" {
#include <string.h>
#include <myhtml/myosi.h>
-#include <myhtml/utils.h>
+#include <mycore/utils.h>
struct myhtml_namespace_detect_name_entry {
const char* name;
diff --git a/include/myhtml/mynamespace_resource.h b/include/myhtml/mynamespace_resource.h
index e584cb7..be20f0b 100644
--- a/include/myhtml/mynamespace_resource.h
+++ b/include/myhtml/mynamespace_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/include/myhtml/myosi.h b/include/myhtml/myosi.h
index 3901fae..cbacbe7 100644
--- a/include/myhtml/myosi.h
+++ b/include/myhtml/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -22,181 +22,23 @@
#define MyHTML_MYOSI_H
#pragma once
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-#include <stdint.h>
-#include <stdarg.h>
+#include <mycore/myosi.h>
-#define MyHTML_VERSION_MAJOR 3
+#define MyHTML_VERSION_MAJOR 4
#define MyHTML_VERSION_MINOR 0
#define MyHTML_VERSION_PATCH 0
-#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WINPTHREADS_VERSION)
-#define IS_OS_WINDOWS
-#include <windows.h>
-#endif
-
-#if defined(_MSC_VER)
-# define MyHTML_DEPRECATED(func) __declspec(deprecated) func
-#elif defined(__GNUC__) || defined(__INTEL_COMPILER)
-# define MyHTML_DEPRECATED(func) func __attribute__((deprecated))
-#else
-# define MyHTML_DEPRECATED(func) func
-#endif
+#define MyHTML_VERSION_STRING MyCORE_STR(MyHTML_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyHTML_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyHTML_VERSION_PATCH)
#ifdef __cplusplus
extern "C" {
#endif
-/* Mem */
-#ifdef MyHTML_EXTERN_MALLOC
- extern void * MyHTML_EXTERN_MALLOC(size_t size);
- #define myhtml_malloc MyHTML_EXTERN_MALLOC
-#else
- #define myhtml_malloc myhtml_mem_malloc
-#endif
-
-#ifdef MyHTML_EXTERN_REALLOC
- extern void * MyHTML_EXTERN_REALLOC(void* dst, size_t size);
- #define myhtml_realloc MyHTML_EXTERN_REALLOC
-#else
- #define myhtml_realloc myhtml_mem_realloc
-#endif
-
-#ifdef MyHTML_EXTERN_CALLOC
- extern void * MyHTML_EXTERN_CALLOC(size_t num, size_t size);
- #define myhtml_calloc MyHTML_EXTERN_CALLOC
-#else
- #define myhtml_calloc myhtml_mem_calloc
-#endif
-
-#ifdef MyHTML_EXTERN_FREE
- extern void MyHTML_EXTERN_FREE(void* dst);
- #define myhtml_free MyHTML_EXTERN_FREE
-#else
- #define myhtml_free myhtml_mem_free
-#endif
-
-/* Debug */
-#ifdef DEBUG_MODE
- #define MyHTML_DEBUG(format, ...) \
- myhtml_print(stderr, "DEBUG: "format"\n", ##__VA_ARGS__)
-#else
- #define MyHTML_DEBUG(format, ...)
-#endif
-
-#ifdef DEBUG_MODE
- #define MyHTML_DEBUG_ERROR(format, ...) \
- myhtml_print(stderr, "DEBUG ERROR: "format"\n", ##__VA_ARGS__)
-#else
- #define MyHTML_DEBUG_ERROR(format, ...)
-#endif
-
-#define myhtml_base_add(myhtml, point, lenn, sizen, strcn, size) \
- myhtml->Lenn++; \
- if(myhtml->lenn == myhtml->sizen) { \
- myhtml->sizen += size; \
- myhtml->point = (strcn*)myhtml_realloc(myhtml->point, \
- sizeof(strcn) * myhtml->sizen); \
- }
-
#define MyHTML_FAILED(_status_) ((_status_) != MyHTML_STATUS_OK)
-// encoding
-// https://encoding.spec.whatwg.org/#the-encoding
-// https://encoding.spec.whatwg.org/#legacy-single-byte-encodings
-// https://encoding.spec.whatwg.org/#legacy-multi-byte-chinese-(simplified)-encodings
-// https://encoding.spec.whatwg.org/#legacy-multi-byte-chinese-(traditional)-encodings
-// https://encoding.spec.whatwg.org/#legacy-multi-byte-japanese-encodings
-// https://encoding.spec.whatwg.org/#legacy-multi-byte-korean-encodings
-// https://encoding.spec.whatwg.org/#legacy-miscellaneous-encodings
-
-enum myhtml_encoding_list {
- MyHTML_ENCODING_DEFAULT = 0x00,
-// MyHTML_ENCODING_AUTO = 0x01, // future
- MyHTML_ENCODING_NOT_DETERMINED = 0x02,
- MyHTML_ENCODING_UTF_8 = 0x00, // default encoding
- MyHTML_ENCODING_UTF_16LE = 0x04,
- MyHTML_ENCODING_UTF_16BE = 0x05,
- MyHTML_ENCODING_X_USER_DEFINED = 0x06,
- MyHTML_ENCODING_BIG5 = 0x07,
- MyHTML_ENCODING_EUC_JP = 0x08,
- MyHTML_ENCODING_EUC_KR = 0x09,
- MyHTML_ENCODING_GB18030 = 0x0a,
- MyHTML_ENCODING_GBK = 0x0b,
- MyHTML_ENCODING_IBM866 = 0x0c,
- MyHTML_ENCODING_ISO_2022_JP = 0x0d,
- MyHTML_ENCODING_ISO_8859_10 = 0x0e,
- MyHTML_ENCODING_ISO_8859_13 = 0x0f,
- MyHTML_ENCODING_ISO_8859_14 = 0x10,
- MyHTML_ENCODING_ISO_8859_15 = 0x11,
- MyHTML_ENCODING_ISO_8859_16 = 0x12,
- MyHTML_ENCODING_ISO_8859_2 = 0x13,
- MyHTML_ENCODING_ISO_8859_3 = 0x14,
- MyHTML_ENCODING_ISO_8859_4 = 0x15,
- MyHTML_ENCODING_ISO_8859_5 = 0x16,
- MyHTML_ENCODING_ISO_8859_6 = 0x17,
- MyHTML_ENCODING_ISO_8859_7 = 0x18,
- MyHTML_ENCODING_ISO_8859_8 = 0x19,
- MyHTML_ENCODING_ISO_8859_8_I = 0x1a,
- MyHTML_ENCODING_KOI8_R = 0x1b,
- MyHTML_ENCODING_KOI8_U = 0x1c,
- MyHTML_ENCODING_MACINTOSH = 0x1d,
- MyHTML_ENCODING_SHIFT_JIS = 0x1e,
- MyHTML_ENCODING_WINDOWS_1250 = 0x1f,
- MyHTML_ENCODING_WINDOWS_1251 = 0x20,
- MyHTML_ENCODING_WINDOWS_1252 = 0x21,
- MyHTML_ENCODING_WINDOWS_1253 = 0x22,
- MyHTML_ENCODING_WINDOWS_1254 = 0x23,
- MyHTML_ENCODING_WINDOWS_1255 = 0x24,
- MyHTML_ENCODING_WINDOWS_1256 = 0x25,
- MyHTML_ENCODING_WINDOWS_1257 = 0x26,
- MyHTML_ENCODING_WINDOWS_1258 = 0x27,
- MyHTML_ENCODING_WINDOWS_874 = 0x28,
- MyHTML_ENCODING_X_MAC_CYRILLIC = 0x29,
- MyHTML_ENCODING_LAST_ENTRY = 0x2a
-}
-typedef myhtml_encoding_t;
-
-typedef struct myhtml_encoding_result myhtml_encoding_result_t;
-typedef struct myhtml_encoding_trigram myhtml_encoding_trigram_t;
-typedef struct myhtml_encoding_trigram_result myhtml_encoding_trigram_result_t;
-typedef struct myhtml_encoding_unicode_result myhtml_encoding_unicode_result_t;
-typedef struct myhtml_encoding_detect_name_entry myhtml_encoding_detect_name_entry_t;
-typedef struct myhtml_encoding_detect_attr myhtml_encoding_detect_attr_t;
-typedef struct myhtml_encoding_entry_name_index myhtml_encoding_entry_name_index_t;
-
// char references
typedef struct myhtml_data_process_entry myhtml_data_process_entry_t;
-// strings
-typedef struct myhtml_string_raw myhtml_string_raw_t;
-typedef struct myhtml_string myhtml_string_t;
-
-// thread
-enum mythread_thread_opt {
- MyTHREAD_OPT_UNDEF = 0x00,
- MyTHREAD_OPT_WAIT = 0x01,
- MyTHREAD_OPT_QUIT = 0x02,
- MyTHREAD_OPT_STOP = 0x04,
- MyTHREAD_OPT_DONE = 0x08
-}
-typedef mythread_thread_opt_t;
-
-typedef struct mythread_queue_list_entry mythread_queue_list_entry_t;
-typedef struct mythread_queue_thread_param mythread_queue_thread_param_t;
-typedef struct mythread_queue_list mythread_queue_list_t;
-typedef struct mythread_queue_node mythread_queue_node_t;
-typedef struct mythread_queue mythread_queue_t;
-
-typedef size_t mythread_id_t;
-typedef struct mythread_workers_list mythread_workers_list_t;
-typedef struct mythread_context mythread_context_t;
-typedef struct mythread_list mythread_list_t;
-typedef struct mythread mythread_t;
-
// tree
enum myhtml_tree_flags {
MyHTML_TREE_FLAGS_CLEAN = 0x000,
@@ -386,68 +228,33 @@ enum myhtml_insertion_mode {
// base
/*
Very important!!!
-
- for myhtml 0..00ffff; MyHTML_STATUS_OK == 0x000000
- for mycss and modules 010000..01ffff; MyCSS_STATUS_OK == 0x000000
- for modest 020000..02ffff; MODEST_STATUS_OK == 0x000000
- for myrender 030000..03ffff; MyRENDER_STATUS_OK == 0x000000
- for mydom 040000..04ffff; MyDOM_STATUS_OK == 0x000000
- for mynetwork 050000..05ffff; MyNETWORK_STATUS_OK == 0x000000
- for myecma 060000..06ffff; MyECMA_STATUS_OK == 0x000000
- not occupied 070000..
+ See mycore/myosi.h:mystatus_t
*/
enum myhtml_status {
MyHTML_STATUS_OK = 0x0000,
MyHTML_STATUS_ERROR = 0x0001,
MyHTML_STATUS_ERROR_MEMORY_ALLOCATION = 0x0002,
- MyHTML_STATUS_THREAD_ERROR_MEMORY_ALLOCATION = 0x0009,
- MyHTML_STATUS_THREAD_ERROR_LIST_INIT = 0x000a,
- MyHTML_STATUS_THREAD_ERROR_ATTR_MALLOC = 0x000b,
- MyHTML_STATUS_THREAD_ERROR_ATTR_INIT = 0x000c,
- MyHTML_STATUS_THREAD_ERROR_ATTR_SET = 0x000d,
- MyHTML_STATUS_THREAD_ERROR_ATTR_DESTROY = 0x000e,
- MyHTML_STATUS_THREAD_ERROR_NO_SLOTS = 0x000f,
- MyHTML_STATUS_THREAD_ERROR_BATCH_INIT = 0x0010,
- MyHTML_STATUS_THREAD_ERROR_WORKER_MALLOC = 0x0011,
- MyHTML_STATUS_THREAD_ERROR_WORKER_SEM_CREATE = 0x0012,
- MyHTML_STATUS_THREAD_ERROR_WORKER_THREAD_CREATE = 0x0013,
- MyHTML_STATUS_THREAD_ERROR_MASTER_THREAD_CREATE = 0x0014,
- MyHTML_STATUS_THREAD_ERROR_SEM_PREFIX_MALLOC = 0x0032,
- MyHTML_STATUS_THREAD_ERROR_SEM_CREATE = 0x0033,
- MyHTML_STATUS_THREAD_ERROR_QUEUE_MALLOC = 0x003c,
- MyHTML_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC = 0x003d,
- MyHTML_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC = 0x003e,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_MALLOC = 0x0046,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_INIT = 0x0047,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_LOCK = 0x0048,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_UNLOCK = 0x0049,
- MyHTML_STATUS_RULES_ERROR_MEMORY_ALLOCATION = 0x0064,
- MyHTML_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF = 0x00c8,
- MyHTML_STATUS_PERF_ERROR_FIND_CPU_CLOCK = 0x00c9,
- MyHTML_STATUS_TOKENIZER_ERROR_MEMORY_ALLOCATION = 0x012c,
- MyHTML_STATUS_TOKENIZER_ERROR_FRAGMENT_INIT = 0x012d,
- MyHTML_STATUS_TAGS_ERROR_MEMORY_ALLOCATION = 0x0190,
- MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE = 0x0191,
- MyHTML_STATUS_TAGS_ERROR_MCOBJECT_MALLOC = 0x0192,
- MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE_NODE = 0x0193,
- MyHTML_STATUS_TAGS_ERROR_CACHE_MEMORY_ALLOCATION = 0x0194,
- MyHTML_STATUS_TAGS_ERROR_INDEX_MEMORY_ALLOCATION = 0x0195,
- MyHTML_STATUS_TREE_ERROR_MEMORY_ALLOCATION = 0x01f4,
- MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE = 0x01f5,
- MyHTML_STATUS_TREE_ERROR_MCOBJECT_INIT = 0x01f6,
- MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE_NODE = 0x01f7,
- MyHTML_STATUS_TREE_ERROR_INCOMING_BUFFER_CREATE = 0x01f8,
- MyHTML_STATUS_ATTR_ERROR_ALLOCATION = 0x0258,
- MyHTML_STATUS_ATTR_ERROR_CREATE = 0x0259,
- MyHTML_STATUS_STREAM_BUFFER_ERROR_CREATE = 0x0300,
- MyHTML_STATUS_STREAM_BUFFER_ERROR_INIT = 0x0301,
- MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_CREATE = 0x0302,
- MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_INIT = 0x0303,
- MyHTML_STATUS_STREAM_BUFFER_ERROR_ADD_ENTRY = 0x0304,
- MyHTML_STATUS_MCOBJECT_ERROR_CACHE_CREATE = 0x0340,
- MyHTML_STATUS_MCOBJECT_ERROR_CHUNK_CREATE = 0x0341,
- MyHTML_STATUS_MCOBJECT_ERROR_CHUNK_INIT = 0x0342,
- MyHTML_STATUS_MCOBJECT_ERROR_CACHE_REALLOC = 0x0343
+ MyHTML_STATUS_RULES_ERROR_MEMORY_ALLOCATION = 0x9064,
+ MyHTML_STATUS_TOKENIZER_ERROR_MEMORY_ALLOCATION = 0x912c,
+ MyHTML_STATUS_TOKENIZER_ERROR_FRAGMENT_INIT = 0x912d,
+ MyHTML_STATUS_TAGS_ERROR_MEMORY_ALLOCATION = 0x9190,
+ MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE = 0x9191,
+ MyHTML_STATUS_TAGS_ERROR_MCOBJECT_MALLOC = 0x9192,
+ MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE_NODE = 0x9193,
+ MyHTML_STATUS_TAGS_ERROR_CACHE_MEMORY_ALLOCATION = 0x9194,
+ MyHTML_STATUS_TAGS_ERROR_INDEX_MEMORY_ALLOCATION = 0x9195,
+ MyHTML_STATUS_TREE_ERROR_MEMORY_ALLOCATION = 0x91f4,
+ MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE = 0x91f5,
+ MyHTML_STATUS_TREE_ERROR_MCOBJECT_INIT = 0x91f6,
+ MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE_NODE = 0x91f7,
+ MyHTML_STATUS_TREE_ERROR_INCOMING_BUFFER_CREATE = 0x91f8,
+ MyHTML_STATUS_ATTR_ERROR_ALLOCATION = 0x9258,
+ MyHTML_STATUS_ATTR_ERROR_CREATE = 0x9259,
+ MyHTML_STATUS_STREAM_BUFFER_ERROR_CREATE = 0x9300,
+ MyHTML_STATUS_STREAM_BUFFER_ERROR_INIT = 0x9301,
+ MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_CREATE = 0x9302,
+ MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_INIT = 0x9303,
+ MyHTML_STATUS_STREAM_BUFFER_ERROR_ADD_ENTRY = 0x9304
}
typedef myhtml_status_t;
@@ -486,7 +293,6 @@ struct myhtml_version {
}
typedef myhtml_version_t;
-typedef struct myhtml_incoming_buffer myhtml_incoming_buffer_t;
typedef myhtml_token_attr_t myhtml_tree_attr_t;
typedef struct myhtml_collection myhtml_collection_t;
typedef struct myhtml myhtml_t;
@@ -498,24 +304,14 @@ typedef size_t (*myhtml_tokenizer_state_f)(myhtml_tree_t* tree, myhtml_token_nod
typedef bool (*myhtml_insertion_f)(myhtml_tree_t* tree, myhtml_token_node_t* token);
// char references state
-typedef size_t (*myhtml_data_process_state_f)(myhtml_data_process_entry_t* charef, myhtml_string_t* str, const char* data, size_t offset, size_t size);
+typedef size_t (*myhtml_data_process_state_f)(myhtml_data_process_entry_t* charef, mycore_string_t* str, const char* data, size_t offset, size_t size);
// callback functions
typedef void* (*myhtml_callback_token_f)(myhtml_tree_t* tree, myhtml_token_node_t* token, void* ctx);
typedef void (*myhtml_callback_tree_node_f)(myhtml_tree_t* tree, myhtml_tree_node_t* node, void* ctx);
// find attribute value functions
-typedef bool (*myhtml_attribute_value_find_f)(myhtml_string_t* str_key, const char* value, size_t value_len);
-
-// callback to be implemented by the user
-typedef void (*myhtml_callback_serialize_f)(const char* buffer, size_t size, void* ctx);
-
-void * myhtml_mem_malloc(size_t size);
-void * myhtml_mem_realloc(void* dst, size_t size);
-void * myhtml_mem_calloc(size_t num, size_t size);
-void myhtml_mem_free(void* dst);
-
-void myhtml_print(FILE* out, const char* format, ...);
+typedef bool (*myhtml_attribute_value_find_f)(mycore_string_t* str_key, const char* value, size_t value_len);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myhtml/mystring.h b/include/myhtml/mystring.h
index ff4be9f..caa8eb9 100644
--- a/include/myhtml/mystring.h
+++ b/include/myhtml/mystring.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -25,129 +25,31 @@
#ifdef __cplusplus
extern "C" {
#endif
-
+
#include <myhtml/myosi.h>
-#include <myhtml/encoding.h>
-#include <myhtml/utils/mchar_async.h>
+
+#include <myencoding/encoding.h>
+#include <myencoding/mystring.h>
+
+#include <mycore/mystring.h>
+#include <mycore/utils/mchar_async.h>
#define myhtml_string_get(str, attr) str->attr
#define myhtml_string_set(str, attr) myhtml_string_get(str, attr)
#define myhtml_string_len(str) myhtml_string_get(str, length)
-#define MyHTML_STRING_PREPROCESSOR_CHECK_BUFFER_SIZE(str, unsigned_data) \
- if(str->length >= str->size) { \
- myhtml_string_realloc(str, (str->length + 5)); \
- \
- unsigned_data = (unsigned char*)str->data; \
- }
-
-#define MyHTML_STRING_REALLOC_IF_NEED(str, need_length, upto) \
- if((str->length + need_length) >= str->size) { \
- myhtml_string_realloc(str, (str->length + need_length + upto)); \
- } \
-
-#define MyHTML_STRING_APPEND_BYTE_WITHOUT_REALLOC(onechar, str) \
- str->data[str->length] = onechar; \
- str->length++
-
-#define MyHTML_STRING_APPEND_BYTE_WITHOUT_INCREMENT(onechar, str, upto) \
- if(str->length >= str->size) { \
- myhtml_string_realloc(str, (str->length + upto)); \
- } \
- str->data[str->length] = onechar
-
-#define MyHTML_STRING_APPEND_BYTE_WITHOUT_INCREMENT_REALLOC(onechar, str) \
- str->data[str->length] = onechar
-
-#define MyHTML_STRING_APPEND_BYTE(onechar, str, upto) \
- MyHTML_STRING_APPEND_BYTE_WITHOUT_INCREMENT(onechar, str, upto); \
- str->length++
-
-#define myhtml_mystring_whitespace(onechar, action, logic) \
- (onechar action ' ' logic \
- onechar action '\t' logic \
- onechar action '\n' logic \
- onechar action '\f' logic \
- onechar action '\r')
-
-struct myhtml_string {
- char* data;
- size_t size;
- size_t length;
-
- mchar_async_t *mchar;
- size_t node_idx;
-};
-
-struct myhtml_string_raw {
- char* data;
- size_t size;
- size_t length;
-};
-
-typedef size_t myhtml_string_index_t;
-
-char * myhtml_string_init(mchar_async_t *mchar, size_t node_idx, myhtml_string_t* str, size_t size);
-char * myhtml_string_realloc(myhtml_string_t *str, size_t new_size);
-
-void myhtml_string_clean(myhtml_string_t* str);
-void myhtml_string_clean_all(myhtml_string_t* str);
-myhtml_string_t * myhtml_string_destroy(myhtml_string_t* str, bool destroy_obj);
-
-void myhtml_string_raw_clean(myhtml_string_raw_t* str_raw);
-void myhtml_string_raw_clean_all(myhtml_string_raw_t* str_raw);
-myhtml_string_raw_t * myhtml_string_raw_destroy(myhtml_string_raw_t* str_raw, bool destroy_obj);
-
-/* basic api */
-char * myhtml_string_data_alloc(mchar_async_t *mchar, size_t node_id, size_t size);
-char * myhtml_string_data_realloc(mchar_async_t *mchar, size_t node_id, char *data, size_t len_to_copy, size_t size);
-void myhtml_string_data_free(mchar_async_t *mchar, size_t node_id, char *data);
-
-char * myhtml_string_data(myhtml_string_t *str);
-size_t myhtml_string_length(myhtml_string_t *str);
-size_t myhtml_string_size(myhtml_string_t *str);
-char * myhtml_string_data_set(myhtml_string_t *str, char *data);
-size_t myhtml_string_size_set(myhtml_string_t *str, size_t size);
-size_t myhtml_string_length_set(myhtml_string_t *str, size_t length);
-
-/* append */
-void myhtml_string_append(myhtml_string_t* str, const char* data, size_t length);
-void myhtml_string_append_one(myhtml_string_t* str, const char data);
-void myhtml_string_append_lowercase(myhtml_string_t* str, const char* data, size_t length);
-void myhtml_string_append_with_convert_encoding(myhtml_string_t* str, const char* buff, size_t length, myhtml_encoding_t encoding);
-
-/* append with convert encoding */
-void myhtml_string_append_chunk_with_convert_encoding(myhtml_string_t* str, myhtml_encoding_result_t* res, const char* buff, size_t length, myhtml_encoding_t encoding);
-void myhtml_string_append_one_with_convert_encoding(myhtml_string_t* str, myhtml_encoding_result_t* res, const char data, myhtml_encoding_t encoding);
-
-/* append with convert encoding lowercase */
-void myhtml_string_append_lowercase_ascii_with_convert_encoding(myhtml_string_t* str, const char* buff, size_t length, myhtml_encoding_t encoding);
-void myhtml_string_append_chunk_lowercase_ascii_with_convert_encoding(myhtml_string_t* str, myhtml_encoding_result_t* res, const char* buff, size_t length, myhtml_encoding_t encoding);
-
-/* Oh, long long long name */
-
/* append with convert encoding with preprocessing */
-size_t myhtml_string_append_with_convert_encoding_with_preprocessing(myhtml_string_t* str, const char* buff, size_t length, myhtml_encoding_t encoding, bool emit_null_chars);
-size_t myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(myhtml_string_t* str, myhtml_encoding_result_t* res, const char* buff, size_t length, myhtml_encoding_t encoding, bool emit_null_chars);
+size_t myhtml_string_append_with_convert_encoding_with_preprocessing(mycore_string_t* str, const char* buff, size_t length, myencoding_t encoding, bool emit_null_chars);
+size_t myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(mycore_string_t* str, myencoding_result_t* res, const char* buff, size_t length, myencoding_t encoding, bool emit_null_chars);
/* append with convert encoding lowercase with preprocessing */
-size_t myhtml_string_append_lowercase_with_convert_encoding_with_preprocessing(myhtml_string_t* str, const char* buff, size_t length, myhtml_encoding_t encoding, bool emit_null_chars);
-size_t myhtml_string_append_lowercase_chunk_with_convert_encoding_with_preprocessing(myhtml_string_t* str, myhtml_encoding_result_t* res, const char* buff, size_t length, myhtml_encoding_t encoding, bool emit_null_chars);
-
-void myhtml_string_append_with_replacement_null_characters_only(myhtml_string_t* str, const char* buff, size_t length);
+size_t myhtml_string_append_lowercase_with_convert_encoding_with_preprocessing(mycore_string_t* str, const char* buff, size_t length, myencoding_t encoding, bool emit_null_chars);
+size_t myhtml_string_append_lowercase_chunk_with_convert_encoding_with_preprocessing(mycore_string_t* str, myencoding_result_t* res, const char* buff, size_t length, myencoding_t encoding, bool emit_null_chars);
/* append with preprocessing */
-size_t myhtml_string_before_append_any_preprocessing(myhtml_string_t* str, const char* buff, size_t length, size_t last_position);
-size_t myhtml_string_append_with_preprocessing(myhtml_string_t* str, const char* buff, size_t length, bool emit_null_chars);
-size_t myhtml_string_append_lowercase_with_preprocessing(myhtml_string_t* str, const char* buff, size_t length, bool emit_null_chars);
-size_t myhtml_string_raw_set_replacement_character(myhtml_string_t* target, size_t position);
-
-/* other functions */
-void myhtml_string_copy(myhtml_string_t* dest, myhtml_string_t* target);
-size_t myhtml_string_raw_copy(char* str1, const char* str2, size_t size);
-void myhtml_string_stay_only_whitespace(myhtml_string_t* target);
-size_t myhtml_string_crop_whitespace_from_begin(myhtml_string_t* target);
-size_t myhtml_string_whitespace_from_begin(myhtml_string_t* target);
+size_t myhtml_string_before_append_any_preprocessing(mycore_string_t* str, const char* buff, size_t length, size_t last_position);
+size_t myhtml_string_append_with_preprocessing(mycore_string_t* str, const char* buff, size_t length, bool emit_null_chars);
+size_t myhtml_string_append_lowercase_with_preprocessing(mycore_string_t* str, const char* buff, size_t length, bool emit_null_chars);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myhtml/parser.h b/include/myhtml/parser.h
index 8e3c3de..9d91d10 100644
--- a/include/myhtml/parser.h
+++ b/include/myhtml/parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -37,9 +37,9 @@ void myhtml_parser_stream(mythread_id_t thread_id, void* ctx);
void myhtml_parser_worker(mythread_id_t thread_id, void* ctx);
void myhtml_parser_worker_stream(mythread_id_t thread_id, void* ctx);
-size_t myhtml_parser_token_data_to_string(myhtml_tree_t *tree, myhtml_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length);
-size_t myhtml_parser_token_data_to_string_lowercase(myhtml_tree_t *tree, myhtml_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length);
-size_t myhtml_parser_token_data_to_string_charef(myhtml_tree_t *tree, myhtml_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length);
+size_t myhtml_parser_token_data_to_string(myhtml_tree_t *tree, mycore_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length);
+size_t myhtml_parser_token_data_to_string_lowercase(myhtml_tree_t *tree, mycore_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length);
+size_t myhtml_parser_token_data_to_string_charef(myhtml_tree_t *tree, mycore_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myhtml/rules.h b/include/myhtml/rules.h
index 636cba4..6dbf79f 100644
--- a/include/myhtml/rules.h
+++ b/include/myhtml/rules.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -30,8 +30,7 @@ extern "C" {
#include <myhtml/myhtml.h>
#include <myhtml/tree.h>
-
-myhtml_status_t myhtml_rules_init(myhtml_t* myhtml);
+mystatus_t myhtml_rules_init(myhtml_t* myhtml);
void myhtml_rules_stop_parsing(myhtml_tree_t* tree);
bool myhtml_rules_tree_dispatcher(myhtml_tree_t* tree, myhtml_token_node_t* token);
@@ -39,7 +38,6 @@ bool myhtml_insertion_mode_in_body_other_end_tag(myhtml_tree_t* tree, myhtml_tok
bool myhtml_insertion_mode_in_body(myhtml_tree_t* tree, myhtml_token_node_t* token);
bool myhtml_insertion_mode_in_template(myhtml_tree_t* tree, myhtml_token_node_t* token);
-
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/include/myhtml/serialization.h b/include/myhtml/serialization.h
index 5c70946..353e5b6 100644
--- a/include/myhtml/serialization.h
+++ b/include/myhtml/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -31,15 +31,15 @@ extern "C" {
#endif
// the serialization functions
-bool myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, myhtml_string_raw_t* str);
-bool myhtml_serialization_node_buffer(myhtml_tree_node_t* node, myhtml_string_raw_t* str);
-bool myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node, myhtml_callback_serialize_f callback, void* ptr);
-bool myhtml_serialization_node_callback(myhtml_tree_node_t* node, myhtml_callback_serialize_f callback, void* ptr);
+mystatus_t myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, mycore_string_raw_t* str);
+mystatus_t myhtml_serialization_node_buffer(myhtml_tree_node_t* node, mycore_string_raw_t* str);
+mystatus_t myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node, mycore_callback_serialize_f callback, void* ptr);
+mystatus_t myhtml_serialization_node_callback(myhtml_tree_node_t* node, mycore_callback_serialize_f callback, void* ptr);
// in versuon 1.0.3 this is in public api.
// Need to set deprecated?
-bool myhtml_serialization(myhtml_tree_node_t* scope_node, myhtml_string_raw_t* str);
-bool myhtml_serialization_node(myhtml_tree_node_t* node, myhtml_string_raw_t* str);
+mystatus_t myhtml_serialization(myhtml_tree_node_t* scope_node, mycore_string_raw_t* str);
+mystatus_t myhtml_serialization_node(myhtml_tree_node_t* node, mycore_string_raw_t* str);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/myhtml/stream.h b/include/myhtml/stream.h
index 14dd31c..4ea1017 100644
--- a/include/myhtml/stream.h
+++ b/include/myhtml/stream.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -41,17 +41,17 @@ struct myhtml_stream_buffer {
size_t length;
size_t size;
- myhtml_encoding_result_t res;
+ myencoding_result_t res;
};
myhtml_stream_buffer_t * myhtml_stream_buffer_create(void);
-myhtml_status_t myhtml_stream_buffer_init(myhtml_stream_buffer_t* stream_buffer, size_t entries_size);
+mystatus_t myhtml_stream_buffer_init(myhtml_stream_buffer_t* stream_buffer, size_t entries_size);
void myhtml_stream_buffer_clean(myhtml_stream_buffer_t* stream_buffer);
myhtml_stream_buffer_t * myhtml_stream_buffer_destroy(myhtml_stream_buffer_t* stream_buffer, bool self_destroy);
myhtml_stream_buffer_entry_t * myhtml_stream_buffer_add_entry(myhtml_stream_buffer_t* stream_buffer, size_t entry_data_size);
myhtml_stream_buffer_entry_t * myhtml_stream_buffer_current_entry(myhtml_stream_buffer_t* stream_buffer);
-myhtml_status_t myhtml_stream_buffer_entry_init(myhtml_stream_buffer_entry_t* stream_buffer_entry, size_t size);
+mystatus_t myhtml_stream_buffer_entry_init(myhtml_stream_buffer_entry_t* stream_buffer_entry, size_t size);
void myhtml_stream_buffer_entry_clean(myhtml_stream_buffer_entry_t* stream_buffer_entry);
myhtml_stream_buffer_entry_t * myhtml_stream_buffer_entry_destroy(myhtml_stream_buffer_entry_t* stream_buffer_entry, bool self_destroy);
diff --git a/include/myhtml/tag.h b/include/myhtml/tag.h
index 384b841..4fc1da8 100644
--- a/include/myhtml/tag.h
+++ b/include/myhtml/tag.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -31,12 +31,12 @@ extern "C" {
#include <myhtml/tag_const.h>
#include <myhtml/tokenizer.h>
#include <myhtml/tree.h>
-#include <myhtml/utils.h>
-#include <myhtml/utils/mctree.h>
-#include <myhtml/utils/mchar_async.h>
-#include <myhtml/utils/mcobject.h>
-#include <myhtml/utils/mcobject_async.h>
-#include <myhtml/utils/mcsimple.h>
+#include <mycore/utils.h>
+#include <mycore/utils/mctree.h>
+#include <mycore/utils/mchar_async.h>
+#include <mycore/utils/mcobject.h>
+#include <mycore/utils/mcobject_async.h>
+#include <mycore/utils/mcsimple.h>
#define myhtml_tag_get(tags, idx, attr) tags->context[idx].attr
@@ -52,7 +52,7 @@ extern "C" {
tags->context_length++; \
if(tags->context_length == tags->context_size) { \
tags->context_size += 4096; \
- tags->context = (myhtml_tag_context_t*)myhtml_realloc(tags->context, \
+ tags->context = (myhtml_tag_context_t*)mycore_realloc(tags->context, \
sizeof(myhtml_tag_context_t) * tags->context_size); \
} \
myhtml_tag_context_clean(tags, tags->context_length)
@@ -89,7 +89,7 @@ struct myhtml_tag {
};
myhtml_tag_t * myhtml_tag_create(void);
-myhtml_status_t myhtml_tag_init(myhtml_tree_t *tree, myhtml_tag_t *tags);
+mystatus_t myhtml_tag_init(myhtml_tree_t *tree, myhtml_tag_t *tags);
void myhtml_tag_clean(myhtml_tag_t* tags);
myhtml_tag_t * myhtml_tag_destroy(myhtml_tag_t* tags);
@@ -105,8 +105,6 @@ const myhtml_tag_context_t * myhtml_tag_get_by_name(myhtml_tag_t* tags, const ch
const myhtml_tag_context_t * myhtml_tag_static_get_by_id(size_t idx);
const myhtml_tag_context_t * myhtml_tag_static_search(const char* name, size_t length);
-void myhtml_tag_print(myhtml_tag_t* tags, FILE* fh);
-
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/include/myhtml/tag_const.h b/include/myhtml/tag_const.h
index 0f5b389..1b29934 100644
--- a/include/myhtml/tag_const.h
+++ b/include/myhtml/tag_const.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/include/myhtml/thread.h b/include/myhtml/thread.h
deleted file mode 100644
index 47b6629..0000000
--- a/include/myhtml/thread.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- Copyright (C) 2015-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 MyHTML_THREAD_H
-#define MyHTML_THREAD_H
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <myhtml/myosi.h>
-
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
-
-#if !defined(IS_OS_WINDOWS)
-# include <pthread.h>
-# include <semaphore.h>
-#endif
-
-#include <time.h>
-#include <sys/stat.h>
-
-#include <fcntl.h>
-#include <errno.h>
-
-#include <myhtml/myhtml.h>
-#include <myhtml/tree.h>
-#include <myhtml/mystring.h>
-
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
-#define MyTHREAD_SEM_NAME "myhtml"
-
-/* functions */
-typedef void (*mythread_callback_before_join_f)(mythread_t* mythread);
-typedef void (*mythread_process_f)(void* arg);
-typedef void (*mythread_work_f)(mythread_id_t thread_id, void* arg);
-
-#ifdef MyHTML_BUILD_WITHOUT_THREADS
-
-struct mythread {
- int sys_last_error;
-};
-
-#else /* MyHTML_BUILD_WITHOUT_THREADS */
-
-void mythread_function_queue_stream(void *arg);
-void mythread_function_queue_batch(void *arg);
-void mythread_function(void *arg);
-
-// thread
-struct mythread_context {
- mythread_id_t id;
-
-#if defined(IS_OS_WINDOWS)
- HANDLE mutex;
-#else
- pthread_mutex_t *mutex;
-#endif
-
- size_t sem_name_size;
-
- mythread_work_f func;
-
- volatile size_t t_count;
- volatile mythread_thread_opt_t opt;
-
- mythread_t *mythread;
- unsigned int status;
-};
-
-struct mythread_list {
-#if defined(IS_OS_WINDOWS)
- HANDLE pth;
-#else
- pthread_t pth;
-#endif
- mythread_context_t data;
- mythread_process_f process_func;
-};
-
-struct mythread_workers_list {
- mythread_list_t *list;
- size_t count;
-};
-
-struct mythread {
- mythread_list_t *pth_list;
- size_t pth_list_length;
- size_t pth_list_size;
- size_t pth_list_root;
-
- void *context;
-
- char *sem_prefix;
- size_t sem_prefix_length;
-
-#if !defined(IS_OS_WINDOWS)
- pthread_attr_t *attr;
-#endif
-
- int sys_last_error;
-
- mythread_id_t batch_first_id;
- mythread_id_t batch_count;
-
- volatile mythread_thread_opt_t stream_opt;
- volatile mythread_thread_opt_t batch_opt;
-};
-
-mythread_id_t myhread_create_stream(mythread_t *mythread, mythread_process_f process_func, mythread_work_f func, mythread_thread_opt_t opt, myhtml_status_t *status);
-mythread_id_t myhread_create_batch(mythread_t *mythread, mythread_process_f process_func, mythread_work_f func, mythread_thread_opt_t opt, myhtml_status_t *status, size_t count);
-
-void myhtml_thread_nanosleep(const struct timespec *tomeout);
-
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
-mythread_t * mythread_create(void);
-myhtml_status_t mythread_init(mythread_t *mythread, const char *sem_prefix, size_t thread_count);
-void mythread_clean(mythread_t *mythread);
-mythread_t * mythread_destroy(mythread_t *mythread, mythread_callback_before_join_f before_join, bool self_destroy);
-
-void mythread_stream_quit_all(mythread_t *mythread);
-void mythread_batch_quit_all(mythread_t *mythread);
-
-void mythread_stream_stop_all(mythread_t *mythread);
-void mythread_batch_stop_all(mythread_t *mythread);
-
-void mythread_stop_all(mythread_t *mythread);
-void mythread_queue_wait_all_for_done(mythread_t *mythread);
-void mythread_resume_all(mythread_t *mythread);
-void mythread_suspend_all(mythread_t *mythread);
-unsigned int mythread_check_status(mythread_t *mythread);
-
-// queue
-struct mythread_queue_node {
- mythread_queue_node_t *prev;
- myhtml_token_node_t *token;
- myhtml_tree_t *tree;
-};
-
-struct mythread_queue_thread_param {
- volatile size_t use;
-};
-
-struct mythread_queue_list_entry {
- mythread_queue_list_entry_t *next;
- mythread_queue_list_entry_t *prev;
- mythread_queue_t *queue;
- mythread_queue_thread_param_t *thread_param;
-};
-
-struct mythread_queue_list {
- mythread_queue_list_entry_t *first;
- mythread_queue_list_entry_t *last;
-
- volatile size_t count;
-};
-
-struct mythread_queue {
- mythread_queue_node_t **nodes;
-
- size_t nodes_pos;
- size_t nodes_pos_size;
- size_t nodes_length;
-
- volatile size_t nodes_uses;
- volatile size_t nodes_size;
- volatile size_t nodes_root;
-};
-
-mythread_queue_t * mythread_queue_create(size_t size, myhtml_status_t *status);
-void mythread_queue_clean(mythread_queue_t* queue);
-mythread_queue_t * mythread_queue_destroy(mythread_queue_t* token);
-
-void mythread_queue_node_clean(mythread_queue_node_t* qnode);
-
-size_t mythread_queue_count_used_node(mythread_queue_t* queue);
-mythread_queue_node_t * mythread_queue_get_first_node(mythread_queue_t* queue);
-mythread_queue_node_t * mythread_queue_get_prev_node(mythread_queue_node_t* qnode);
-mythread_queue_node_t * mythread_queue_get_current_node(mythread_queue_t* queue);
-mythread_queue_node_t * mythread_queue_node_malloc(mythread_t *mythread, mythread_queue_t* queue, myhtml_status_t *status);
-mythread_queue_node_t * mythread_queue_node_malloc_limit(mythread_t *mythread, mythread_queue_t* queue, size_t limit, myhtml_status_t *status);
-
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
-
-mythread_queue_list_t * mythread_queue_list_create(myhtml_status_t *status);
-void mythread_queue_list_destroy(mythread_queue_list_t* queue_list);
-
-size_t mythread_queue_list_get_count(mythread_queue_list_t* queue_list);
-
-mythread_queue_list_entry_t * mythread_queue_list_entry_push(mythread_t *mythread, mythread_queue_t *queue, myhtml_status_t *status);
-mythread_queue_list_entry_t * mythread_queue_list_entry_delete(mythread_t *mythread, mythread_queue_list_entry_t *entry, bool destroy_queue);
-void mythread_queue_list_entry_clean(mythread_t *mythread, mythread_queue_list_entry_t *entry);
-void mythread_queue_list_entry_wait_for_done(mythread_t *mythread, mythread_queue_list_entry_t *entry);
-
-mythread_queue_node_t * mythread_queue_node_malloc_round(mythread_t *mythread, mythread_queue_list_entry_t *entry, myhtml_status_t *status);
-
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* defined(__myhtml__myhtml_thread__) */
-
diff --git a/include/myhtml/token.h b/include/myhtml/token.h
index 2a8206a..bf40736 100644
--- a/include/myhtml/token.h
+++ b/include/myhtml/token.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -29,13 +29,13 @@ extern "C" {
#include <string.h>
#include <myhtml/myosi.h>
-#include <myhtml/utils.h>
+#include <mycore/utils.h>
#include <myhtml/tag.h>
#include <myhtml/myhtml.h>
#include <myhtml/mystring.h>
-#include <myhtml/utils/mcobject_async.h>
-#include <myhtml/utils/mchar_async.h>
-#include <myhtml/utils/mcsync.h>
+#include <mycore/utils/mcobject_async.h>
+#include <mycore/utils/mchar_async.h>
+#include <mycore/utils/mcsync.h>
#define myhtml_token_node_set_done(token_node) token_node->type |= MyHTML_TOKEN_TYPE_DONE
@@ -61,8 +61,8 @@ struct myhtml_token_attr {
myhtml_token_attr_t* next;
myhtml_token_attr_t* prev;
- myhtml_string_t key;
- myhtml_string_t value;
+ mycore_string_t key;
+ mycore_string_t value;
size_t raw_key_begin;
size_t raw_key_length;
@@ -75,7 +75,7 @@ struct myhtml_token_attr {
struct myhtml_token_node {
myhtml_tag_id_t tag_id;
- myhtml_string_t str;
+ mycore_string_t str;
size_t raw_begin;
size_t raw_length;
@@ -115,7 +115,7 @@ myhtml_tree_attr_t * myhtml_token_node_attribute_first(myhtml_token_node_t *toke
myhtml_tree_attr_t * myhtml_token_node_attribute_last(myhtml_token_node_t *token_node);
const char * myhtml_token_node_text(myhtml_token_node_t *token_node, size_t *length);
-myhtml_string_t * myhtml_token_node_string(myhtml_token_node_t *token_node);
+mycore_string_t * myhtml_token_node_string(myhtml_token_node_t *token_node);
bool myhtml_token_node_is_close(myhtml_token_node_t *token_node);
bool myhtml_token_node_is_close_self(myhtml_token_node_t *token_node);
@@ -130,7 +130,7 @@ myhtml_token_attr_t * myhtml_token_attr_remove_by_name(myhtml_token_node_t* node
void myhtml_token_attr_delete_all(myhtml_token_t* token, myhtml_token_node_t* node);
void myhtml_token_delete(myhtml_token_t* token, myhtml_token_node_t* node);
-void myhtml_token_node_wait_for_done(myhtml_token_node_t* node);
+void myhtml_token_node_wait_for_done(myhtml_token_t* token, myhtml_token_node_t* node);
void myhtml_token_set_done(myhtml_token_node_t* node);
myhtml_token_attr_t * myhtml_token_attr_match(myhtml_token_t* token, myhtml_token_node_t* target, const char* key, size_t key_size, const char* value, size_t value_size);
@@ -143,7 +143,7 @@ void myhtml_token_adjust_svg_attributes(myhtml_token_node_t* target);
void myhtml_token_adjust_foreign_attributes(myhtml_token_node_t* target);
myhtml_token_attr_t * myhtml_token_node_attr_append(myhtml_token_t* token, myhtml_token_node_t* dest, const char* key, size_t key_len, const char* value, size_t value_len, size_t thread_idx);
-myhtml_token_attr_t * myhtml_token_node_attr_append_with_convert_encoding(myhtml_token_t* token, myhtml_token_node_t* dest, const char* key, size_t key_len, const char* value, size_t value_len, size_t thread_idx, myhtml_encoding_t encoding);
+myhtml_token_attr_t * myhtml_token_node_attr_append_with_convert_encoding(myhtml_token_t* token, myhtml_token_node_t* dest, const char* key, size_t key_len, const char* value, size_t value_len, size_t thread_idx, myencoding_t encoding);
void myhtml_token_node_text_append(myhtml_token_t* token, myhtml_token_node_t* dest, const char* text, size_t text_len);
void myhtml_token_node_attr_copy(myhtml_token_t* token, myhtml_token_node_t* target, myhtml_token_node_t* dest, size_t thread_idx);
void myhtml_token_node_attr_copy_with_check(myhtml_token_t* token, myhtml_token_node_t* target, myhtml_token_node_t* dest, size_t thread_idx);
@@ -154,10 +154,6 @@ bool myhtml_token_attr_compare(myhtml_token_node_t* target, myhtml_token_node_t*
myhtml_token_node_t * myhtml_token_merged_two_token_string(myhtml_tree_t* tree, myhtml_token_node_t* token_to, myhtml_token_node_t* token_from, bool cp_reverse);
void myhtml_token_set_replacement_character_for_null_token(myhtml_tree_t* tree, myhtml_token_node_t* node);
-void myhtml_token_print_param_by_idx(myhtml_tree_t* myhtml_tree, myhtml_token_node_t* node, FILE* out);
-void myhtml_token_print_by_idx(myhtml_tree_t* myhtml_tree, myhtml_token_node_t* node, FILE* out);
-void myhtml_token_print_attr(myhtml_tree_t* myhtml_tree, myhtml_token_node_t* node, FILE* out);
-
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/include/myhtml/tokenizer.h b/include/myhtml/tokenizer.h
index 4b09881..5e65fe8 100644
--- a/include/myhtml/tokenizer.h
+++ b/include/myhtml/tokenizer.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -27,23 +27,23 @@ extern "C" {
#endif
#include <myhtml/myosi.h>
-#include <myhtml/utils.h>
+#include <mycore/utils.h>
+#include <mycore/mythread.h>
#include <myhtml/myhtml.h>
#include <myhtml/tag.h>
-#include <myhtml/thread.h>
#include <myhtml/tokenizer_doctype.h>
#include <myhtml/tokenizer_script.h>
#include <myhtml/tokenizer_end.h>
-
+
#define myhtml_tokenizer_inc_html_offset(offset, size) \
offset++; \
if(offset >= size) \
return offset
-myhtml_status_t myhtml_tokenizer_begin(myhtml_tree_t* tree, const char* html, size_t html_length);
-myhtml_status_t myhtml_tokenizer_chunk(myhtml_tree_t* tree, const char* html, size_t html_length);
-myhtml_status_t myhtml_tokenizer_chunk_with_stream_buffer(myhtml_tree_t* tree, const char* html, size_t html_length);
-myhtml_status_t myhtml_tokenizer_end(myhtml_tree_t* tree);
+mystatus_t myhtml_tokenizer_begin(myhtml_tree_t* tree, const char* html, size_t html_length);
+mystatus_t myhtml_tokenizer_chunk(myhtml_tree_t* tree, const char* html, size_t html_length);
+mystatus_t myhtml_tokenizer_chunk_with_stream_buffer(myhtml_tree_t* tree, const char* html, size_t html_length);
+mystatus_t myhtml_tokenizer_end(myhtml_tree_t* tree);
void myhtml_tokenizer_set_state(myhtml_tree_t* tree, myhtml_token_node_t* token_node);
void myhtml_tokenizer_calc_current_namespace(myhtml_tree_t* tree, myhtml_token_node_t* token_node);
@@ -54,7 +54,7 @@ void myhtml_tokenizer_wait(myhtml_tree_t* tree);
void myhtml_tokenizer_post(myhtml_tree_t* tree);
void myhtml_tokenizer_pause(myhtml_tree_t* tree);
-myhtml_status_t myhtml_tokenizer_state_init(myhtml_t* myhtml);
+mystatus_t myhtml_tokenizer_state_init(myhtml_t* myhtml);
void myhtml_tokenizer_state_destroy(myhtml_t* myhtml);
myhtml_token_node_t * myhtml_tokenizer_queue_create_text_node_if_need(myhtml_tree_t* tree, myhtml_token_node_t* token_node, const char* html, size_t absolute_html_offset, enum myhtml_token_type type);
diff --git a/include/myhtml/tokenizer_doctype.h b/include/myhtml/tokenizer_doctype.h
index 6e36004..0c353c8 100644
--- a/include/myhtml/tokenizer_doctype.h
+++ b/include/myhtml/tokenizer_doctype.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -27,7 +27,7 @@ extern "C" {
#endif
#include <myhtml/myosi.h>
-#include <myhtml/utils.h>
+#include <mycore/utils.h>
#include <myhtml/myhtml.h>
size_t myhtml_tokenizer_state_doctype(myhtml_tree_t* tree, myhtml_token_node_t* token_node, const char* html, size_t html_offset, size_t html_size);
diff --git a/include/myhtml/tokenizer_end.h b/include/myhtml/tokenizer_end.h
index 4087ecc..adf16d7 100644
--- a/include/myhtml/tokenizer_end.h
+++ b/include/myhtml/tokenizer_end.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/include/myhtml/tokenizer_script.h b/include/myhtml/tokenizer_script.h
index b1d61b3..3ae7faa 100644
--- a/include/myhtml/tokenizer_script.h
+++ b/include/myhtml/tokenizer_script.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -27,7 +27,7 @@ extern "C" {
#endif
#include <myhtml/myosi.h>
-#include <myhtml/utils.h>
+#include <mycore/utils.h>
#include <myhtml/myhtml.h>
#include <myhtml/tokenizer.h>
diff --git a/include/myhtml/tree.h b/include/myhtml/tree.h
index d6b75ec..6b2ffa7 100644
--- a/include/myhtml/tree.h
+++ b/include/myhtml/tree.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -31,10 +31,11 @@ extern "C" {
#include <myhtml/mystring.h>
#include <myhtml/token.h>
#include <myhtml/stream.h>
-#include <myhtml/utils/mcsync.h>
-#include <myhtml/utils/mchar_async.h>
-#include <myhtml/utils/mcobject.h>
-#include <myhtml/utils/mcobject_async.h>
+#include <mycore/thread_queue.h>
+#include <mycore/utils/mcsync.h>
+#include <mycore/utils/mchar_async.h>
+#include <mycore/utils/mcobject.h>
+#include <mycore/utils/mcobject_async.h>
#define myhtml_tree_get(tree, attr) tree->attr
#define myhtml_tree_set(tree, attr) tree->attr
@@ -164,7 +165,7 @@ struct myhtml_tree_temp_stream {
size_t length;
size_t size;
- myhtml_encoding_result_t res;
+ myencoding_result_t res;
struct myhtml_tree_temp_tag_name* current;
};
@@ -185,6 +186,11 @@ struct myhtml_tree {
size_t mcasync_rules_token_id;
size_t mcasync_rules_attr_id;
size_t mcasync_tree_id;
+ /*
+ * mchar_node_id
+ * for rules, or if single mode,
+ * or for main thread only after parsing
+ */
size_t mchar_node_id;
myhtml_token_attr_t* attr_current;
myhtml_tag_id_t tmp_tag_id;
@@ -192,8 +198,8 @@ struct myhtml_tree {
mythread_queue_node_t* current_qnode;
mcobject_t* mcobject_incoming_buf;
- myhtml_incoming_buffer_t* incoming_buf;
- myhtml_incoming_buffer_t* incoming_buf_first;
+ mycore_incoming_buffer_t* incoming_buf;
+ mycore_incoming_buffer_t* incoming_buf_first;
// ref for nodes
myhtml_tree_node_t* document;
@@ -227,10 +233,10 @@ struct myhtml_tree {
volatile myhtml_tree_parse_flags_t parse_flags;
bool foster_parenting;
size_t global_offset;
- myhtml_status_t tokenizer_status;
+ mystatus_t tokenizer_status;
- myhtml_encoding_t encoding;
- myhtml_encoding_t encoding_usereq;
+ myencoding_t encoding;
+ myencoding_t encoding_usereq;
myhtml_tree_temp_tag_name_t temp_tag_name;
/* callback */
@@ -249,7 +255,7 @@ struct myhtml_tree {
// base
myhtml_tree_t * myhtml_tree_create(void);
-myhtml_status_t myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml);
+mystatus_t myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml);
void myhtml_tree_clean(myhtml_tree_t* tree);
void myhtml_tree_clean_all(myhtml_tree_t* tree);
myhtml_tree_t * myhtml_tree_destroy(myhtml_tree_t* tree);
@@ -355,10 +361,6 @@ void myhtml_tree_node_clean(myhtml_tree_node_t* tree_node);
void myhtml_tree_node_free(myhtml_tree_node_t* node);
myhtml_tree_node_t * myhtml_tree_node_clone(myhtml_tree_node_t* node);
-void myhtml_tree_print_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out);
-void myhtml_tree_print_node_children(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out, size_t inc);
-void myhtml_tree_print_by_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out, size_t inc);
-
void myhtml_tree_node_add_child(myhtml_tree_node_t* root, myhtml_tree_node_t* node);
void myhtml_tree_node_insert_before(myhtml_tree_node_t* root, myhtml_tree_node_t* node);
void myhtml_tree_node_insert_after(myhtml_tree_node_t* root, myhtml_tree_node_t* node);
@@ -390,21 +392,21 @@ bool myhtml_tree_is_mathml_integration_point(myhtml_tree_t* tree, myhtml_tree_no
bool myhtml_tree_is_html_integration_point(myhtml_tree_t* tree, myhtml_tree_node_t* node);
// temp tag name
-myhtml_status_t myhtml_tree_temp_tag_name_init(myhtml_tree_temp_tag_name_t* temp_tag_name);
+mystatus_t myhtml_tree_temp_tag_name_init(myhtml_tree_temp_tag_name_t* temp_tag_name);
void myhtml_tree_temp_tag_name_clean(myhtml_tree_temp_tag_name_t* temp_tag_name);
myhtml_tree_temp_tag_name_t * myhtml_tree_temp_tag_name_destroy(myhtml_tree_temp_tag_name_t* temp_tag_name, bool self_destroy);
-myhtml_status_t myhtml_tree_temp_tag_name_append(myhtml_tree_temp_tag_name_t* temp_tag_name, const char* name, size_t name_len);
-myhtml_status_t myhtml_tree_temp_tag_name_append_one(myhtml_tree_temp_tag_name_t* temp_tag_name, const char name);
+mystatus_t myhtml_tree_temp_tag_name_append(myhtml_tree_temp_tag_name_t* temp_tag_name, const char* name, size_t name_len);
+mystatus_t myhtml_tree_temp_tag_name_append_one(myhtml_tree_temp_tag_name_t* temp_tag_name, const char name);
/* special tonek list */
-myhtml_status_t myhtml_tree_special_list_init(myhtml_tree_special_token_list_t* special);
-myhtml_status_t myhtml_tree_special_list_append(myhtml_tree_special_token_list_t* special, myhtml_token_node_t *token, myhtml_namespace_t ns);
+mystatus_t myhtml_tree_special_list_init(myhtml_tree_special_token_list_t* special);
+mystatus_t myhtml_tree_special_list_append(myhtml_tree_special_token_list_t* special, myhtml_token_node_t *token, myhtml_namespace_t ns);
size_t myhtml_tree_special_list_length(myhtml_tree_special_token_list_t* special);
myhtml_tree_special_token_t * myhtml_tree_special_list_get_last(myhtml_tree_special_token_list_t* special);
size_t myhtml_tree_special_list_pop(myhtml_tree_special_token_list_t* special);
/* incoming buffer */
-myhtml_incoming_buffer_t * myhtml_tree_incoming_buffer_first(myhtml_tree_t *tree);
+mycore_incoming_buffer_t * myhtml_tree_incoming_buffer_first(myhtml_tree_t *tree);
const char * myhtml_tree_incomming_buffer_make_data(myhtml_tree_t *tree, size_t begin, size_t length);
#ifdef __cplusplus
diff --git a/include/myhtml/utils/avl_tree.h b/include/myhtml/utils/avl_tree.h
deleted file mode 100644
index 10851b1..0000000
--- a/include/myhtml/utils/avl_tree.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- 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 MyHTML_UTILS_AVL_TREE_H
-#define MyHTML_UTILS_AVL_TREE_H
-#pragma once
-
-#include <myhtml/myosi.h>
-#include <myhtml/utils/mcobject.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct myhtml_utils_avl_tree_node myhtml_utils_avl_tree_node_t;
-typedef void (*myhtml_utils_avl_tree_node_callback_f)(myhtml_utils_avl_tree_node_t* avl_tree_node, void* ctx);
-
-struct myhtml_utils_avl_tree_node {
- void *value;
- size_t type;
-
- myhtml_utils_avl_tree_node_t* left;
- myhtml_utils_avl_tree_node_t* right;
- myhtml_utils_avl_tree_node_t* parent;
-
- short height;
-};
-
-struct myhtml_utils_avl_tree {
- mcobject_t* mc_nodes;
-}
-typedef myhtml_utils_avl_tree_t;
-
-myhtml_utils_avl_tree_t * myhtml_utils_avl_tree_create(void);
-myhtml_status_t myhtml_utils_avl_tree_init(myhtml_utils_avl_tree_t* avl_tree);
-void myhtml_utils_avl_tree_clean(myhtml_utils_avl_tree_t* avl_tree);
-myhtml_utils_avl_tree_t * myhtml_utils_avl_tree_destroy(myhtml_utils_avl_tree_t* avl_tree, bool self_destroy);
-
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_create_root(myhtml_utils_avl_tree_t* avl_tree, size_t type, void* value);
-
-void myhtml_utils_avl_tree_add(myhtml_utils_avl_tree_t* avl_tree, myhtml_utils_avl_tree_node_t** root, size_t type, void* value);
-void * myhtml_utils_avl_tree_delete(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t** root, size_t type);
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_search_by_type(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t* node, size_t type);
-
-void myhtml_utils_avl_tree_list_all_nodes(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t* root, myhtml_utils_avl_tree_node_callback_f callback, void* ctx);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* MyHTML_UTILS_AVL_TREE_H */
diff --git a/include/myhtml/utils/mhash.h b/include/myhtml/utils/mhash.h
deleted file mode 100644
index bbf3738..0000000
--- a/include/myhtml/utils/mhash.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Copyright (C) 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 avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#ifndef html_mhash_h
-#define html_mhash_h
-
-#include <myhtml/myosi.h>
-#include <myhtml/utils/mchar_async.h>
-
-typedef struct myhtml_utils_mhash_entry myhtml_utils_mhash_entry_t;
-
-struct myhtml_utils_mhash_entry {
- char* key;
- size_t key_length;
-
- void *value;
-
- myhtml_utils_mhash_entry_t* next;
-};
-
-struct myhtml_utils_mhash {
- mchar_async_t* mchar_obj;
- size_t mchar_node;
-
- myhtml_utils_mhash_entry_t** table;
- size_t table_size;
- size_t table_length;
-
- size_t table_max_depth;
-}
-typedef myhtml_utils_mhash_t;
-
-myhtml_utils_mhash_t * myhtml_utils_mhash_create(void);
-myhtml_status_t myhtml_utils_mhash_init(myhtml_utils_mhash_t* mhash, size_t table_size, size_t depth);
-void myhtml_utils_mhash_clean(myhtml_utils_mhash_t* mhash);
-myhtml_utils_mhash_t * myhtml_utils_mhash_destroy(myhtml_utils_mhash_t* mhash, bool self_destroy);
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_create_entry(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
-
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_search(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add_with_choice(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size);
-
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_entry_by_id(myhtml_utils_mhash_t* mhash, size_t id);
-size_t myhtml_utils_mhash_get_table_size(myhtml_utils_mhash_t* mhash);
-
-myhtml_utils_mhash_entry_t ** myhtml_utils_mhash_rebuld(myhtml_utils_mhash_t* mhash);
-
-#endif
diff --git a/include/myunicode/myosi.h b/include/myunicode/myosi.h
new file mode 100644
index 0000000..e411130
--- /dev/null
+++ b/include/myunicode/myosi.h
@@ -0,0 +1,35 @@
+/*
+ Copyright (C) 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 MyUNICODE_MYOSI_H
+#define MyUNICODE_MYOSI_H
+#pragma once
+
+#include <myhtml/myosi.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyUNICODE_MYOSI_H */
diff --git a/include/myurl/host.h b/include/myurl/host.h
new file mode 100644
index 0000000..96d64b6
--- /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;
+ } value;
+
+ myurl_host_type_t type;
+}
+typedef myurl_host_t;
+
+myurl_host_t * myurl_host_create(myurl_t* url);
+mystatus_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);
+mystatus_t myurl_host_copy(myurl_t* url, myurl_host_t* host_from, myurl_host_t* host_to);
+
+mystatus_t myurl_host_parser(myurl_t* url, myurl_host_t* host, const char* data, size_t data_size, bool is_special);
+mystatus_t myurl_host_ipv4_parser(myurl_host_ipv_t* ipv, const char* data, size_t data_size, bool* failure);
+mystatus_t myurl_host_ipv6_parser(myurl_host_ipv_t* ipv, const char* data, size_t data_size);
+mystatus_t myurl_host_ipv6_ipv4_parser(myurl_host_ipv_t* ipv, const char* data, size_t data_size, unsigned int** piece_pointer);
+mystatus_t myurl_host_opaque_host_parser(myurl_t* url, myurl_host_opaque_t* opaque, const char* data, size_t data_size);
+mystatus_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..dcd3934
--- /dev/null
+++ b/include/myurl/myosi.h
@@ -0,0 +1,83 @@
+/*
+ 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>
+
+#define MyURL_VERSION_MAJOR 0
+#define MyURL_VERSION_MINOR 1
+#define MyURL_VERSION_PATCH 0
+
+#define MyURL_VERSION_STRING MyCORE_STR(MyURL_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyURL_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyURL_VERSION_PATCH)
+
+#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, mycore_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..2e0b52b
--- /dev/null
+++ b/include/myurl/parser.h
@@ -0,0 +1,103 @@
+/*
+ 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_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..e18abf3
--- /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);
+mystatus_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);
+mystatus_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..3c3a313
--- /dev/null
+++ b/include/myurl/punycode.h
@@ -0,0 +1,48 @@
+/*
+ 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 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 <myencoding/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..ea71527
--- /dev/null
+++ b/include/myurl/resources.h
@@ -0,0 +1,180 @@
+/*
+ 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_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..f315372
--- /dev/null
+++ b/include/myurl/scheme.h
@@ -0,0 +1,78 @@
+/*
+ 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_SCHEME_H
+#define MyURL_SCHEME_H
+#pragma once
+
+#include <myurl/myosi.h>
+#include <myurl/scheme_const.h>
+#include <mycore/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);
+
+mystatus_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..508c1a5
--- /dev/null
+++ b/include/myurl/scheme_const.h
@@ -0,0 +1,43 @@
+/*
+ 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_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..d408479
--- /dev/null
+++ b/include/myurl/scheme_resources.h
@@ -0,0 +1,64 @@
+/*
+ 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_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..fd70d7a
--- /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, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization_host(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization_auth_host_port(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization_path(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization_fragment(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization_with_fragment(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization_without_fragment(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization(myurl_entry_t* url_entry, bool exclude_fragment_flag, mycore_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..3a194ae
--- /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;
+ mystatus_t status;
+
+ myurl_t* url_ref;
+};
+
+struct myhtml_url {
+ /* parser */
+ myurl_state_f state;
+ myurl_state_f state_override;
+ myencoding_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);
+mystatus_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, mystatus_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 */
+mystatus_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 */
+mystatus_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 */
+mystatus_t myurl_entry_path_set(myurl_entry_t* url_entry, const char* path, size_t length);
+mystatus_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);
+mystatus_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..6e244c5
--- /dev/null
+++ b/include/myurl/utils.h
@@ -0,0 +1,73 @@
+/*
+ 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 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);
+mystatus_t myurl_utils_data_copy_set(myurl_t* url, const char* data, size_t size, char** to, size_t* to_length);
+mystatus_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/modest.pc.in b/modest.pc.in
new file mode 100644
index 0000000..85b0276
--- /dev/null
+++ b/modest.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=${prefix}/@includedir@
+libdir=${prefix}/@libdir@
+
+Name: @libname@
+Description: @description@
+Version: @version@
+Cflags: @cflags@
+Libs: -L${libdir} -l@libname@
diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt
deleted file mode 100644
index e9add12..0000000
--- a/projects/CMakeLists.txt
+++ /dev/null
@@ -1,205 +0,0 @@
-cmake_minimum_required( VERSION 2.8.8 )
-
-################
-## version and path
-#########################
-set(MODEST_PROJECT_NAME "modest")
-set(MODEST_PROJECT_DIR_ROOT "..")
-set(MODEST_PROJECT_DIR_LIB "${MODEST_PROJECT_DIR_ROOT}/lib")
-set(MODEST_PROJECT_API_HEADER "${MODEST_PROJECT_DIR_ROOT}/include/")
-set(MODEST_PROJECT_SOURCE "${MODEST_PROJECT_DIR_ROOT}/source")
-
-set(MODEST_VERSION_MAJOR 0)
-set(MODEST_VERSION_MINOR 0)
-set(MODEST_VERSION_PATCH 5)
-set(MODEST_VERSION_STRING "${MODEST_VERSION_MAJOR}.${MODEST_VERSION_MINOR}.${MODEST_VERSION_PATCH}")
-
-project(${MODEST_PROJECT_NAME})
-
-################
-## Detect OS
-#########################
-set(MODEST_PLATFORM "UNDEF")
-
-if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- if(EXISTS "/etc/debian_version")
- set(MODEST_PLATFORM "Debian")
- endif(EXISTS "/etc/debian_version")
-
- if(EXISTS "/etc/redhat-release")
- set(MODEST_PLATFORM "Redhat")
- endif(EXISTS "/etc/redhat-release")
-
- if(EXISTS "/etc/fedora-release")
- set(MODEST_PLATFORM "Redhat")
- endif(EXISTS "/etc/fedora-release")
-
- if(EXISTS "/etc/SuSE-release")
- set(MODEST_PLATFORM "SuSe")
- endif(EXISTS "/etc/SuSE-release")
-
- if(EXISTS "/etc/gentoo-release")
- set(MODEST_PLATFORM "Gentoo")
- endif(EXISTS "/etc/gentoo-release")
-endif()
-
-################
-## lib param
-#########################
-if(POLICY CMP0042)
- cmake_policy(SET CMP0042 OLD)
-endif()
-
-set(MODEST_PROJECT_LIB_NAME "${MODEST_PROJECT_NAME}")
-set(MODEST_PROJECT_LIB_NAME_STATIC "${MODEST_PROJECT_NAME}_static")
-
-if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
- set(CMAKE_INSTALL_LIBDIR "lib")
-endif()
-
-if(NOT DEFINED MODEST_OPTIMIZATION_LEVEL)
- set(MODEST_OPTIMIZATION_LEVEL "-O2")
-endif()
-
-if(NOT DEFINED MODEST_BUILD_WITHOUT_THREADS)
- set(MODEST_BUILD_WITHOUT_THREADS "NO")
-endif()
-
-################
-## extern mem functions
-#########################
-if(DEFINED MODEST_EXTERN_MALLOC)
- add_definitions(-DMODEST_EXTERN_MALLOC=${MODEST_EXTERN_MALLOC})
- add_definitions(-DMyHTML_EXTERN_MALLOC=${MODEST_EXTERN_MALLOC})
-endif()
-
-if(DEFINED MODEST_EXTERN_REALLOC)
- add_definitions(-DMODEST_EXTERN_REALLOC=${MODEST_EXTERN_REALLOC})
- add_definitions(-DMyHTML_EXTERN_REALLOC=${MODEST_EXTERN_REALLOC})
-endif()
-
-if(DEFINED MODEST_EXTERN_CALLOC)
- add_definitions(-DMODEST_EXTERN_CALLOC=${MODEST_EXTERN_CALLOC})
- add_definitions(-DMyHTML_EXTERN_CALLOC=${MODEST_EXTERN_CALLOC})
-endif()
-
-if(DEFINED MODEST_EXTERN_FREE)
- add_definitions(-DMODEST_EXTERN_FREE=${MODEST_EXTERN_FREE})
- add_definitions(-DMyHTML_EXTERN_FREE=${MODEST_EXTERN_FREE})
-endif()
-
-################
-## ARGS
-#########################
-set(INSTALL_DLL_EXE_DIR "bin")
-
-option(MODEST_BUILD_SHARED "Build shared library" ON)
-option(MODEST_BUILD_STATIC "Build static library" ON)
-option(MODEST_INSTALL_HEADER "Install header files" OFF)
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MODEST_OPTIMIZATION_LEVEL}")
-
-include_directories(${MODEST_PROJECT_SOURCE})
-FILE(GLOB_RECURSE ALL_SOURCE_LIST "${MODEST_PROJECT_SOURCE}/*.c")
-
-if (!UNIX AND WIN32)
- if(${CMAKE_CL_64})
- add_definitions(-D_WIN64)
- else()
- add_definitions(-D_WIN32)
- endif()
-endif()
-
-if(${CMAKE_C_COMPILER_ID} STREQUAL MSVC)
- add_definitions(/wd4100 /wd4255 /wd4820 /wd4668)
- add_definitions(-D_CRT_SECURE_NO_WARNINGS)
-
- message(STATUS "Windows set definitions")
-else()
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall --std=c99 -fPIC")
-
- if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- add_definitions(-D_POSIX_C_SOURCE=199309L)
- endif()
-
- if(MODEST_BUILD_WITHOUT_THREADS STREQUAL "NO")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
- endif()
-endif()
-
-if(MODEST_BUILD_WITHOUT_THREADS STREQUAL "YES")
- message(STATUS "Build without POSIX Threads")
- add_definitions(-DMODEST_BUILD_WITHOUT_THREADS)
- add_definitions(-DMyHTML_BUILD_WITHOUT_THREADS)
-else()
- message(STATUS "Build with POSIX Threads")
-endif()
-
-################
-## build
-#########################
-if(MODEST_BUILD_SHARED)
- add_library(${MODEST_PROJECT_NAME} SHARED ${ALL_SOURCE_LIST})
- set_target_properties(${MODEST_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${MODEST_PROJECT_NAME})
- set_target_properties(${MODEST_PROJECT_NAME} PROPERTIES VERSION ${MODEST_VERSION_STRING} SOVERSION ${MODEST_VERSION_MAJOR})
-endif()
-
-if(MODEST_BUILD_STATIC)
- add_library(${MODEST_PROJECT_LIB_NAME_STATIC} STATIC ${ALL_SOURCE_LIST})
- set_target_properties(${MODEST_PROJECT_LIB_NAME_STATIC} PROPERTIES OUTPUT_NAME ${MODEST_PROJECT_LIB_NAME_STATIC})
- set_target_properties(${MODEST_PROJECT_LIB_NAME_STATIC} PROPERTIES VERSION ${MODEST_VERSION_STRING} SOVERSION ${MODEST_VERSION_MAJOR})
-endif()
-
-################
-## install
-#########################
-if(MODEST_INSTALL_HEADER)
- install(DIRECTORY "${MODEST_PROJECT_API_HEADER}" DESTINATION "include" FILES_MATCHING PATTERN "*.h")
-endif()
-
-if(MODEST_BUILD_SHARED)
- install(TARGETS ${MODEST_PROJECT_LIB_NAME}
- RUNTIME DESTINATION "${INSTALL_DLL_EXE_DIR}"
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-endif()
-
-if(MODEST_BUILD_STATIC)
- install(TARGETS ${MODEST_PROJECT_LIB_NAME_STATIC}
- RUNTIME DESTINATION "${INSTALL_DLL_EXE_DIR}"
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-endif()
-
-################
-## Build an RPM.
-#########################
-set(CPACK_PACKAGE_VERSION ${MODEST_VERSION_STRING})
-
-if(MODEST_PLATFORM STREQUAL "Debian")
- set(CPACK_GENERATOR "DEB")
-elseif(MODEST_PLATFORM STREQUAL "Redhat")
- set(CPACK_GENERATOR "RPM")
-elseif(MODEST_PLATFORM STREQUAL "SuSe")
- set(CPACK_GENERATOR "RPM")
-else()
- set(CPACK_GENERATOR "TGZ")
-endif()
-
-set(CPACK_PACKAGE_NAME "modest")
-set(CPACK_PACKAGE_RELEASE 1)
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Modest is a fast HTML Render implemented as a pure C99 library with no outside dependencies.")
-set(CPACK_PACKAGE_CONTACT "Alexander Borisov")
-set(CPACK_PACKAGE_VENDOR "Alexander Borisov")
-
-if(32BIT)
- set(CPACK_RPM_PACKAGE_ARCHITECTURE i686)
-else()
- set(CPACK_RPM_PACKAGE_ARCHITECTURE x86_64)
-endif()
-
-if(MODEST_BUILD_WITHOUT_THREADS STREQUAL "YES")
- set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}-without-threads.${CPACK_RPM_PACKAGE_ARCHITECTURE}")
-else()
- set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}")
-endif()
-
-include(CPack)
diff --git a/source/modest/Makefile.mk b/source/modest/Makefile.mk
index 812bf35..0ab2e7f 100644
--- a/source/modest/Makefile.mk
+++ b/source/modest/Makefile.mk
@@ -1,14 +1,13 @@
-find_files_h = $(wildcard $(SRCDIR)/modest/$(dir)/*.h)
-find_files_c = $(wildcard $(SRCDIR)/modest/$(dir)/*.c)
+modest_dirs := . finder style node layer render utils
+modest_objs := $(call MODEST_UTILS_OBJS,modest,$(modest_dirs))
-SUBDIRS := . finder style node layer render utils
-HDRS += $(foreach dir,$(SUBDIRS),$(find_files_h))
-SRCS += $(foreach dir,$(SUBDIRS),$(find_files_c))
+modest_description := calculating, compare, renderer
+modest_dependencies := mycore mycss myencoding myfont myhtml myport myunicode myurl
-modest_clone: MODEST_DIR_$(SUBDIRS)
- mkdir -p $(INCLUDE_TMP)/modest
- cp $(SRCDIR)/modest/*.h $(INCLUDE_TMP)/modest
+modest_all: $(modest_objs)
-MODEST_DIR_$(SUBDIRS):
- mkdir -p $(INCLUDE_TMP)/modest/$(patsubst MODEST_DIR_%,%,$@)
- cp $(SRCDIR)/modest/$(patsubst MODEST_DIR_%,%,$@)/*.h $(INCLUDE_TMP)/modest/$(patsubst MODEST_DIR_%,%,$@)/
+modest_clean:
+ rm -f $(modest_objs)
+
+modest_clone:
+ $(call MODEST_UTILS_HDRS_CLONE,modest,$(modest_dirs))
diff --git a/source/modest/declaration.c b/source/modest/declaration.c
index 158dded..7e3d298 100644
--- a/source/modest/declaration.c
+++ b/source/modest/declaration.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/declaration.h b/source/modest/declaration.h
index ab43889..f1688d6 100644
--- a/source/modest/declaration.h
+++ b/source/modest/declaration.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/finder/finder.c b/source/modest/finder/finder.c
index 57b7e7b..bf52435 100644
--- a/source/modest/finder/finder.c
+++ b/source/modest/finder/finder.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -23,10 +23,10 @@
modest_finder_t * modest_finder_create(void)
{
- return (modest_finder_t*)myhtml_calloc(1, sizeof(modest_finder_t));
+ return (modest_finder_t*)mycore_calloc(1, sizeof(modest_finder_t));
}
-modest_status_t modest_finder_init(modest_finder_t* finder)
+mystatus_t modest_finder_init(modest_finder_t* finder)
{
return MODEST_STATUS_OK;
}
@@ -42,7 +42,7 @@ modest_finder_t * modest_finder_destroy(modest_finder_t* finder, bool self_destr
return NULL;
if(self_destroy) {
- myhtml_free(finder);
+ mycore_free(finder);
return NULL;
}
@@ -114,7 +114,7 @@ modest_finder_t * modest_finder_by_stylesheet(mycss_stylesheet_t *stylesheet, my
if(finder == NULL)
return NULL;
- modest_status_t status = modest_finder_init(finder);
+ mystatus_t status = modest_finder_init(finder);
if(status != MODEST_STATUS_OK) {
modest_finder_destroy(finder, true);
@@ -122,7 +122,7 @@ modest_finder_t * modest_finder_by_stylesheet(mycss_stylesheet_t *stylesheet, my
}
if(*collection == NULL) {
- myhtml_status_t status;
+ mystatus_t status;
*collection = myhtml_collection_create(4096, &status);
if(status) {
@@ -148,14 +148,14 @@ modest_finder_t * modest_finder_by_stylesheet(mycss_stylesheet_t *stylesheet, my
return finder;
}
-modest_status_t modest_finder_by_selectors_list(modest_finder_t* finder, myhtml_tree_node_t* scope_node,
+mystatus_t modest_finder_by_selectors_list(modest_finder_t* finder, myhtml_tree_node_t* scope_node,
mycss_selectors_list_t* selector_list, myhtml_collection_t** collection)
{
if(finder == NULL || selector_list == NULL || scope_node == NULL || collection == NULL)
return MODEST_STATUS_ERROR;
if(*collection == NULL) {
- myhtml_status_t status;
+ mystatus_t status;
*collection = myhtml_collection_create(4096, &status);
if(status)
diff --git a/source/modest/finder/finder.h b/source/modest/finder/finder.h
index dd29d87..d3cdeff 100644
--- a/source/modest/finder/finder.h
+++ b/source/modest/finder/finder.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -38,7 +38,7 @@ typedef myhtml_tree_node_t * (*modest_finder_selector_combinator_f)(modest_finde
/* init */
modest_finder_t * modest_finder_create(void);
-modest_status_t modest_finder_init(modest_finder_t* finder);
+mystatus_t modest_finder_init(modest_finder_t* finder);
void modest_finder_clean(modest_finder_t* finder);
modest_finder_t * modest_finder_destroy(modest_finder_t* finder, bool self_destroy);
@@ -59,7 +59,7 @@ void modest_finder_specificity_inc(mycss_selectors_entry_t* selector, mycss_sele
/* base api */
modest_finder_t * modest_finder_by_stylesheet(mycss_stylesheet_t *stylesheet, myhtml_collection_t** collection, myhtml_tree_node_t* base_node);
-modest_status_t modest_finder_by_selectors_list(modest_finder_t* finder, myhtml_tree_node_t* scope_node,
+mystatus_t modest_finder_by_selectors_list(modest_finder_t* finder, myhtml_tree_node_t* scope_node,
mycss_selectors_list_t* selector_list, myhtml_collection_t** collection);
/* process */
diff --git a/source/modest/finder/match.c b/source/modest/finder/match.c
index 97d5f9d..e75c524 100644
--- a/source/modest/finder/match.c
+++ b/source/modest/finder/match.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -28,7 +28,7 @@ bool modest_finder_match_attribute_only_key(myhtml_token_attr_t* attr, const cha
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
return true;
}
@@ -46,7 +46,7 @@ bool modest_finder_match_attribute_eq(myhtml_token_attr_t* attr, const char* key
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
{
if(attr->value.length == value_len) {
if(case_sensitive) {
@@ -55,7 +55,7 @@ bool modest_finder_match_attribute_eq(myhtml_token_attr_t* attr, const char* key
}
}
else {
- if(myhtml_strncasecmp(value, attr->value.data, value_len) == 0) {
+ if(mycore_strncasecmp(value, attr->value.data, value_len) == 0) {
return true;
}
}
@@ -79,46 +79,37 @@ bool modest_finder_match_attribute_ws(myhtml_token_attr_t* attr, const char* key
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
{
size_t i = 0;
+ size_t begin;
if(attr->value.length >= value_len) {
if(case_sensitive)
{
while(i < attr->value.length)
{
- size_t end = i + value_len;
+ begin = i;
+ while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;}
- if(end > attr->value.length)
- return false;
-
- if(
- (myhtml_strncmp(value, &attr->value.data[i], value_len) == 0) &&
- (myhtml_utils_whithspace(attr->value.data[end], ==, ||) || end == attr->value.length))
- {
+ if((i - begin) == value_len && (mycore_strncmp(value, &attr->value.data[begin], value_len) == 0)) {
return true;
}
-
- i++;
+ /* skip all ws */
+ while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;}
}
}
else {
while(i < attr->value.length)
{
- size_t end = i + value_len;
+ begin = i;
+ while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], !=, &&)) {i++;}
- if(end > attr->value.length)
- return false;
-
- if(
- (myhtml_strncasecmp(value, &attr->value.data[i], value_len) == 0) &&
- (myhtml_utils_whithspace(attr->value.data[end], ==, ||) || end == attr->value.length))
- {
+ if((i - begin) == value_len && (mycore_strncasecmp(value, &attr->value.data[begin], value_len) == 0)) {
return true;
}
-
- i++;
+ /* skip all ws */
+ while(i < attr->value.length && mycore_utils_whithspace(attr->value.data[i], ==, ||)) {i++;}
}
}
}
@@ -141,15 +132,15 @@ bool modest_finder_match_attribute_begin(myhtml_token_attr_t* attr, const char*
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
{
if(attr->value.length >= value_len) {
if(case_sensitive) {
- if(myhtml_strncmp(value, attr->value.data, value_len) == 0)
+ if(mycore_strncmp(value, attr->value.data, value_len) == 0)
return true;
}
else {
- if(myhtml_strncasecmp(value, attr->value.data, value_len) == 0)
+ if(mycore_strncasecmp(value, attr->value.data, value_len) == 0)
return true;
}
}
@@ -172,15 +163,15 @@ bool modest_finder_match_attribute_end(myhtml_token_attr_t* attr, const char* ke
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
{
if(attr->value.length >= value_len) {
if(case_sensitive) {
- if(myhtml_strncmp(value, &attr->value.data[ (attr->value.length - value_len) ], value_len) == 0)
+ if(mycore_strncmp(value, &attr->value.data[ (attr->value.length - value_len) ], value_len) == 0)
return true;
}
else {
- if(myhtml_strncasecmp(value, &attr->value.data[ (attr->value.length - value_len) ], value_len) == 0)
+ if(mycore_strncasecmp(value, &attr->value.data[ (attr->value.length - value_len) ], value_len) == 0)
return true;
}
}
@@ -203,7 +194,7 @@ bool modest_finder_match_attribute_sub(myhtml_token_attr_t* attr, const char* ke
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
{
if(attr->value.length >= value_len) {
size_t i = 0;
@@ -212,7 +203,7 @@ bool modest_finder_match_attribute_sub(myhtml_token_attr_t* attr, const char* ke
{
while ((i + value_len) <= attr->value.length)
{
- if(myhtml_strncmp(value, &attr->value.data[i], value_len) == 0)
+ if(mycore_strncmp(value, &attr->value.data[i], value_len) == 0)
return true;
i++;
@@ -221,7 +212,7 @@ bool modest_finder_match_attribute_sub(myhtml_token_attr_t* attr, const char* ke
else {
while ((i + value_len) <= attr->value.length)
{
- if(myhtml_strncasecmp(value, &attr->value.data[i], value_len) == 0)
+ if(mycore_strncasecmp(value, &attr->value.data[i], value_len) == 0)
return true;
i++;
@@ -247,27 +238,27 @@ bool modest_finder_match_attribute_hsp(myhtml_token_attr_t* attr, const char* ke
while (attr)
{
if(attr->key.length == key_len) {
- if(myhtml_strncasecmp(key, attr->key.data, key_len) == 0)
+ if(mycore_strncasecmp(key, attr->key.data, key_len) == 0)
{
if(attr->value.length == value_len) {
if(case_sensitive) {
- if(myhtml_strncmp(value, attr->value.data, value_len) == 0)
+ if(mycore_strncmp(value, attr->value.data, value_len) == 0)
return true;
}
else {
- if(myhtml_strncasecmp(value, attr->value.data, value_len) == 0)
+ if(mycore_strncasecmp(value, attr->value.data, value_len) == 0)
return true;
}
}
else if(attr->value.length > value_len) {
if(case_sensitive) {
- if(myhtml_strncmp(value, attr->value.data, value_len) == 0) {
+ if(mycore_strncmp(value, attr->value.data, value_len) == 0) {
if(attr->value.data[value_len] == '-')
return true;
}
}
else {
- if(myhtml_strncasecmp(value, attr->value.data, value_len) == 0) {
+ if(mycore_strncasecmp(value, attr->value.data, value_len) == 0) {
if(attr->value.data[value_len] == '-')
return true;
}
diff --git a/source/modest/finder/match.h b/source/modest/finder/match.h
index adcf493..df76258 100644
--- a/source/modest/finder/match.h
+++ b/source/modest/finder/match.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/finder/myosi.h b/source/modest/finder/myosi.h
index eaf769d..97232da 100644
--- a/source/modest/finder/myosi.h
+++ b/source/modest/finder/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/finder/pseudo_class.c b/source/modest/finder/pseudo_class.c
index 807996e..f26ac69 100644
--- a/source/modest/finder/pseudo_class.c
+++ b/source/modest/finder/pseudo_class.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -159,7 +159,7 @@ bool modest_finder_selector_sub_type_pseudo_class_function_nth_child_check_selec
bool modest_finder_selector_sub_type_pseudo_class_function_nth_child(modest_finder_t* finder, myhtml_tree_node_t* base_node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec)
{
if(selector->value == NULL)
- return NULL;
+ return false;
mycss_an_plus_b_entry_t *anb = mycss_selector_value_an_plus_b(selector->value);
@@ -226,7 +226,7 @@ bool modest_finder_selector_sub_type_pseudo_class_function_nth_column(modest_fin
bool modest_finder_selector_sub_type_pseudo_class_function_nth_last_child(modest_finder_t* finder, myhtml_tree_node_t* base_node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec)
{
if(selector->value == NULL)
- return NULL;
+ return false;
mycss_an_plus_b_entry_t *anb = mycss_selector_value_an_plus_b(selector->value);
@@ -290,7 +290,7 @@ bool modest_finder_selector_sub_type_pseudo_class_function_nth_last_column(modes
bool modest_finder_selector_sub_type_pseudo_class_function_nth_last_of_type(modest_finder_t* finder, myhtml_tree_node_t* base_node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec)
{
if(selector->value == NULL)
- return NULL;
+ return false;
mycss_an_plus_b_entry_t *anb = mycss_selector_value_an_plus_b(selector->value);
@@ -322,7 +322,7 @@ bool modest_finder_selector_sub_type_pseudo_class_function_nth_last_of_type(mode
bool modest_finder_selector_sub_type_pseudo_class_function_nth_of_type(modest_finder_t* finder, myhtml_tree_node_t* base_node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec)
{
if(selector->value == NULL)
- return NULL;
+ return false;
mycss_an_plus_b_entry_t *anb = mycss_selector_value_an_plus_b(selector->value);
@@ -420,15 +420,15 @@ bool modest_finder_selector_sub_type_pseudo_class_checked(modest_finder_t* finde
while (attr)
{
if(attr->key.length == 4) {
- if(myhtml_strncasecmp("type", attr->key.data, 4) == 0)
+ if(mycore_strncasecmp("type", attr->key.data, 4) == 0)
{
if(attr->value.length == 8) {
- if(myhtml_strncasecmp("checkbox", attr->value.data, 8) == 0) {
+ if(mycore_strncasecmp("checkbox", attr->value.data, 8) == 0) {
return modest_finder_match_attribute_only_key(base_node->token->attr_first, "checked", 7);
}
}
else if(attr->value.length == 5) {
- if(myhtml_strncasecmp("radio", attr->value.data, 5) == 0) {
+ if(mycore_strncasecmp("radio", attr->value.data, 5) == 0) {
return modest_finder_match_attribute_only_key(base_node->token->attr_first, "checked", 7);
}
}
diff --git a/source/modest/finder/pseudo_class.h b/source/modest/finder/pseudo_class.h
index 17c682a..c9c1c07 100644
--- a/source/modest/finder/pseudo_class.h
+++ b/source/modest/finder/pseudo_class.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/finder/resource.h b/source/modest/finder/resource.h
index 839914a..0d312ba 100644
--- a/source/modest/finder/resource.h
+++ b/source/modest/finder/resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/finder/thread.c b/source/modest/finder/thread.c
index 1d03b09..a6f5d86 100644
--- a/source/modest/finder/thread.c
+++ b/source/modest/finder/thread.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -21,7 +21,12 @@
#include "modest/finder/thread.h"
/* private functions */
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
static void modest_finder_thread_stream(mythread_id_t thread_id, void* arg);
+#else
+static void modest_finder_thread_stream_single(modest_finder_thread_t* finder_thread, mycss_selectors_list_t* selector_list);
+#endif
+
static modest_finder_thread_context_t * modest_finder_thread_create_context(modest_finder_thread_t* finder_thread, size_t count);
//static void modest_finder_thread_callback_found(modest_finder_t* finder, myhtml_tree_node_t* node, mycss_selectors_list_t* selector_list,
// mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec, void* ctx);
@@ -29,11 +34,15 @@ static modest_finder_thread_context_t * modest_finder_thread_create_context(mode
/* basic functions */
modest_finder_thread_t * modest_finder_thread_create(void)
{
- return (modest_finder_thread_t*)myhtml_calloc(1, sizeof(modest_finder_thread_t));
+ return (modest_finder_thread_t*)mycore_calloc(1, sizeof(modest_finder_thread_t));
}
-modest_status_t modest_finder_thread_init(modest_finder_t* finder, modest_finder_thread_t* finder_thread, size_t thread_count)
+mystatus_t modest_finder_thread_init(modest_finder_t* finder, modest_finder_thread_t* finder_thread, size_t thread_count)
{
+#ifdef MyCORE_BUILD_WITHOUT_THREADS
+ thread_count = 1;
+#endif
+
finder_thread->finder = finder;
/* objects for nodes */
@@ -59,23 +68,27 @@ modest_status_t modest_finder_thread_init(modest_finder_t* finder, modest_finder
return MODEST_STATUS_OK;
/* create and init threads */
+#ifdef MyCORE_BUILD_WITHOUT_THREADS
+ finder_thread->thread = NULL;
+#else
finder_thread->thread = mythread_create();
if(finder_thread->thread == NULL)
return MODEST_STATUS_OK;
- myhtml_status_t status = mythread_init(finder_thread->thread, "lastmac", thread_count);
+ mystatus_t status = mythread_init(finder_thread->thread, MyTHREAD_TYPE_STREAM, thread_count, 0);
if(status) {
- mythread_destroy(finder_thread->thread, NULL, true);
+ mythread_destroy(finder_thread->thread, NULL, NULL, true);
return MODEST_STATUS_OK;
}
finder_thread->thread->context = finder_thread;
/* create threads */
- for(size_t i = finder_thread->thread->pth_list_root; i < finder_thread->thread->pth_list_size; i++) {
- myhread_create_stream(finder_thread->thread, mythread_function, modest_finder_thread_stream, MyTHREAD_OPT_UNDEF, &status);
+ for(size_t i = 0; i < finder_thread->thread->entries_size; i++) {
+ myhread_entry_create(finder_thread->thread, mythread_function, modest_finder_thread_stream, MyTHREAD_OPT_STOP);
}
+#endif
return MODEST_STATUS_OK;
}
@@ -93,28 +106,24 @@ modest_finder_thread_t * modest_finder_thread_destroy(modest_finder_thread_t* fi
if(finder_thread == NULL)
return NULL;
- finder_thread->entry_obj = mcobject_async_destroy(finder_thread->entry_obj, true);
- finder_thread->declaration_obj = mcobject_async_destroy(finder_thread->declaration_obj, true);
-
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
if(finder_thread->thread) {
- finder_thread->thread->stream_opt = MyTHREAD_OPT_QUIT;
-
- for(size_t i = finder_thread->thread->pth_list_root; i < finder_thread->thread->pth_list_size; i++) {
- finder_thread->thread->pth_list[i].data.opt = MyTHREAD_OPT_QUIT;
- }
-
- finder_thread->thread = mythread_destroy(finder_thread->thread, NULL, true);
+ finder_thread->thread = mythread_destroy(finder_thread->thread, mythread_callback_quit, NULL, true);
}
+#endif
+
+ finder_thread->entry_obj = mcobject_async_destroy(finder_thread->entry_obj, true);
+ finder_thread->declaration_obj = mcobject_async_destroy(finder_thread->declaration_obj, true);
if(finder_thread->context_list) {
- myhtml_free(finder_thread->context_list);
+ mycore_free(finder_thread->context_list);
finder_thread->context_list = NULL;
finder_thread->context_list_size = 0;
}
if(self_destroy) {
- myhtml_free(finder_thread);
+ mycore_free(finder_thread);
return NULL;
}
@@ -133,8 +142,64 @@ void modest_finder_thread_collate_node(modest_t* modest, myhtml_tree_node_t* nod
}
}
-modest_status_t modest_finder_thread_process(modest_t* modest, modest_finder_thread_t* finder_thread,
- myhtml_tree_node_t* scope_node, mycss_selectors_list_t* selector_list)
+#ifdef MyCORE_BUILD_WITHOUT_THREADS
+mystatus_t modest_finder_thread_process(modest_t* modest, modest_finder_thread_t* finder_thread,
+ myhtml_tree_node_t* scope_node, mycss_selectors_list_t* selector_list)
+{
+ finder_thread->base_node = scope_node;
+ finder_thread->selector_list = selector_list;
+
+ if(finder_thread->finder == NULL)
+ return MODEST_STATUS_ERROR;
+
+ modest_finder_thread_stream_single(finder_thread, selector_list);
+
+ /* calc result */
+ modest_finder_thread_context_t* context = finder_thread->context_list;
+ myhtml_tree_node_t* node = scope_node;
+
+ /* compare results */
+ while(node) {
+ modest_finder_thread_entry_t* entry = context->entry;
+
+ while(entry) {
+ if(entry->node == node)
+ {
+ if(entry->next)
+ entry->next->prev = entry->prev;
+ else
+ context->entry_last = entry->prev;
+
+ if(entry->prev)
+ entry->prev->next = entry->next;
+ else
+ context->entry = entry->next;
+
+ modest_finder_thread_collate_node(modest, node, entry);
+ }
+
+ entry = entry->next;
+ }
+
+ if(node->child)
+ node = node->child;
+ else {
+ while(node != scope_node && node->next == NULL)
+ node = node->parent;
+
+ if(node == scope_node)
+ break;
+
+ node = node->next;
+ }
+ }
+
+ return MyCORE_STATUS_OK;
+}
+
+#else /* end def MyCORE_BUILD_WITHOUT_THREADS */
+mystatus_t modest_finder_thread_process(modest_t* modest, modest_finder_thread_t* finder_thread,
+ myhtml_tree_node_t* scope_node, mycss_selectors_list_t* selector_list)
{
finder_thread->base_node = scope_node;
finder_thread->selector_list = selector_list;
@@ -142,7 +207,7 @@ modest_status_t modest_finder_thread_process(modest_t* modest, modest_finder_thr
if(finder_thread->finder == NULL)
return MODEST_STATUS_ERROR;
- mythread_resume_all(finder_thread->thread);
+ mythread_resume(finder_thread->thread, MyTHREAD_OPT_UNDEF);
modest_finder_thread_wait_for_all_done(finder_thread);
/* calc result */
@@ -151,7 +216,7 @@ modest_status_t modest_finder_thread_process(modest_t* modest, modest_finder_thr
/* compare results */
while(node) {
- for(size_t i = finder_thread->thread->pth_list_root; i < finder_thread->thread->pth_list_size; i++)
+ for(size_t i = 0; i < finder_thread->thread->entries_length; i++)
{
modest_finder_thread_context_t* context = &context_list[i];
modest_finder_thread_entry_t* entry = context->entry;
@@ -194,29 +259,26 @@ modest_status_t modest_finder_thread_process(modest_t* modest, modest_finder_thr
void modest_finder_thread_wait_for_all_done(modest_finder_thread_t* finder_thread)
{
- const struct timespec tomeout = {0, 0};
-
- for (size_t idx = finder_thread->thread->pth_list_root; idx < finder_thread->thread->pth_list_size; idx++) {
- while((finder_thread->thread->pth_list[idx].data.opt & MyTHREAD_OPT_DONE) == 0) {
- myhtml_thread_nanosleep(&tomeout);
+ for (size_t idx = 0; idx < finder_thread->thread->entries_length; idx++) {
+ while((finder_thread->thread->entries[idx].context.opt & MyTHREAD_OPT_DONE) == 0) {
+ mythread_nanosleep_sleep(finder_thread->thread->timespec);
}
}
}
+#endif /* if undef MyCORE_BUILD_WITHOUT_THREADS */
modest_finder_thread_context_t * modest_finder_thread_create_context(modest_finder_thread_t* finder_thread, size_t count)
{
- /* +1 because threads ids begin 1 */
- count++;
finder_thread->context_list_size = count;
- modest_finder_thread_context_t *ctx = myhtml_calloc(count, sizeof(modest_finder_thread_context_t));
+ modest_finder_thread_context_t *ctx = mycore_calloc(count, sizeof(modest_finder_thread_context_t));
if(ctx == NULL)
return NULL;
mcobject_async_status_t mcstatus;
- for(size_t i = 1; i < count; i++) {
+ for(size_t i = 0; i < count; i++) {
ctx[i].entry_node_id = mcobject_async_node_add(finder_thread->entry_obj, &mcstatus);
if(mcstatus) {
@@ -225,12 +287,12 @@ modest_finder_thread_context_t * modest_finder_thread_create_context(modest_find
mcobject_async_node_delete(finder_thread->entry_obj, ctx[i].entry_node_id);
}
- myhtml_free(ctx);
+ mycore_free(ctx);
return NULL;
}
}
- for(size_t i = 1; i < count; i++) {
+ for(size_t i = 0; i < count; i++) {
ctx[i].declaration_node_id = mcobject_async_node_add(finder_thread->declaration_obj, &mcstatus);
if(mcstatus) {
@@ -245,7 +307,7 @@ modest_finder_thread_context_t * modest_finder_thread_create_context(modest_find
mcobject_async_node_delete(finder_thread->declaration_obj, ctx[i].declaration_node_id);
}
- myhtml_free(ctx);
+ mycore_free(ctx);
return NULL;
}
}
@@ -371,6 +433,25 @@ void modest_finder_thread_callback_found(modest_finder_t* finder, myhtml_tree_no
}
}
+void modest_finder_thread_stream_single(modest_finder_thread_t* finder_thread, mycss_selectors_list_t* selector_list)
+{
+ modest_finder_thread_found_context_t found_ctx = {finder_thread, finder_thread->context_list};
+
+ while(selector_list)
+ {
+ for(size_t i = 0; i < selector_list->entries_list_length; i++) {
+ mycss_selectors_entries_list_t *entries = &selector_list->entries_list[i];
+ mycss_selectors_specificity_t spec = entries->specificity;
+
+ modest_finder_node_combinator_begin(finder_thread->finder, finder_thread->base_node, selector_list,
+ entries->entry, &spec, modest_finder_thread_callback_found, &found_ctx);
+ }
+
+ selector_list = selector_list->next;
+ }
+}
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
void modest_finder_thread_stream(mythread_id_t thread_id, void* arg)
{
mythread_context_t* ctx = (mythread_context_t*)arg;
@@ -380,7 +461,7 @@ void modest_finder_thread_stream(mythread_id_t thread_id, void* arg)
modest_finder_thread_found_context_t found_ctx = {finder_thread, &finder_thread->context_list[ctx->id]};
size_t count = 0, counnt_done = ctx->id - 1;
- size_t offset = (ctx->mythread->pth_list_size - 1);
+ size_t offset = (ctx->mythread->entries_size - 1);
while(selector_list) {
for(size_t i = 0; i < selector_list->entries_list_length; i++) {
@@ -400,8 +481,6 @@ void modest_finder_thread_stream(mythread_id_t thread_id, void* arg)
selector_list = selector_list->next;
}
-
- ctx->opt = MyTHREAD_OPT_STOP|MyTHREAD_OPT_DONE;
}
-
+#endif
diff --git a/source/modest/finder/thread.h b/source/modest/finder/thread.h
index 7db18fb..7bb6959 100644
--- a/source/modest/finder/thread.h
+++ b/source/modest/finder/thread.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -29,8 +29,8 @@
#include "modest/finder/myosi.h"
#include "modest/finder/finder.h"
-#include "myhtml/thread.h"
-#include "myhtml/utils/mcobject_async.h"
+#include "mycore/mythread.h"
+#include "mycore/utils/mcobject_async.h"
#include "mycss/declaration/myosi.h"
@@ -85,13 +85,16 @@ struct modest_finder_thread_found_context {
modest_finder_thread_t * modest_finder_thread_create(void);
-modest_status_t modest_finder_thread_init(modest_finder_t* finder, modest_finder_thread_t* finder_thread, size_t thread_count);
+mystatus_t modest_finder_thread_init(modest_finder_t* finder, modest_finder_thread_t* finder_thread, size_t thread_count);
void modest_finder_thread_clean(modest_finder_thread_t* finder_thread, bool self_destroy);
modest_finder_thread_t * modest_finder_thread_destroy(modest_finder_thread_t* finder_thread, bool self_destroy);
-modest_status_t modest_finder_thread_process(modest_t* modest, modest_finder_thread_t* finder_thread, myhtml_tree_node_t* scope_node, mycss_selectors_list_t* selector_list);
+mystatus_t modest_finder_thread_process(modest_t* modest, modest_finder_thread_t* finder_thread, myhtml_tree_node_t* scope_node, mycss_selectors_list_t* selector_list);
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
void modest_finder_thread_wait_for_all_done(modest_finder_thread_t* finder_thread);
+#endif
+
bool modest_finder_thread_spec_is_up(modest_style_raw_specificity_t* spec_f, modest_style_raw_specificity_t* spec_t);
#ifdef __cplusplus
diff --git a/source/modest/finder/type.c b/source/modest/finder/type.c
index 0de5ad5..6db405e 100644
--- a/source/modest/finder/type.c
+++ b/source/modest/finder/type.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -35,7 +35,7 @@ bool modest_finder_selector_type_element(modest_finder_t* finder, myhtml_tree_no
}
/* tag match */
- myhtml_string_t *str = selector->key;
+ mycore_string_t *str = selector->key;
if(str->length == 1 && *str->data == '*')
return true;
diff --git a/source/modest/finder/type.h b/source/modest/finder/type.h
index 9156b47..a62a460 100644
--- a/source/modest/finder/type.h
+++ b/source/modest/finder/type.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -27,7 +27,7 @@
#include "modest/finder/pseudo_class.h"
#include "modest/finder/match.h"
#include "myhtml/tree.h"
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
#include "mycss/selectors/value.h"
#ifdef __cplusplus
diff --git a/source/modest/glue.c b/source/modest/glue.c
index 1c95643..2d54f37 100644
--- a/source/modest/glue.c
+++ b/source/modest/glue.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/glue.h b/source/modest/glue.h
index 138fa46..6dcb6d2 100644
--- a/source/modest/glue.h
+++ b/source/modest/glue.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/layer/layer.c b/source/modest/layer/layer.c
index 8d41f18..47aedce 100644
--- a/source/modest/layer/layer.c
+++ b/source/modest/layer/layer.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/layer/layer.h b/source/modest/layer/layer.h
index 6f501ff..3e19af6 100644
--- a/source/modest/layer/layer.h
+++ b/source/modest/layer/layer.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -23,7 +23,7 @@
#pragma once
#include "modest/myosi.h"
-#include "myhtml/utils/mcobject.h"
+#include "mycore/utils/mcobject.h"
#ifdef __cplusplus
extern "C" {
@@ -47,7 +47,7 @@ struct modest_layout {
};
modest_layout_t * modest_layers_create(void);
-modest_status_t modest_layers_init(modest_layout_t* layout);
+mystatus_t modest_layers_init(modest_layout_t* layout);
void modest_layers_clean_all(modest_layout_t* layout);
modest_layout_t * modest_layers_destroy(modest_layout_t* layout, bool self_destroy);
diff --git a/source/modest/modest.c b/source/modest/modest.c
index 680869f..7cf40db 100644
--- a/source/modest/modest.c
+++ b/source/modest/modest.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -25,11 +25,13 @@
modest_t * modest_create(void)
{
- return (modest_t*)myhtml_calloc(1, sizeof(modest_t));
+ return (modest_t*)mycore_calloc(1, sizeof(modest_t));
}
-modest_status_t modest_init(modest_t* modest)
+mystatus_t modest_init(modest_t* modest)
{
+ mystatus_t status;
+
/* Modest nodes */
modest->mnode_obj = mcobject_async_create();
if(modest->mnode_obj == NULL)
@@ -61,29 +63,33 @@ modest_status_t modest_init(modest_t* modest)
/* Modest style type */
- modest->mstyle_type_obj = mchar_async_create(12, (4096 * 5));
+ modest->mstyle_type_obj = mchar_async_create();
if(modest->mstyle_type_obj == NULL)
return MODEST_STATUS_ERROR_STYLE_TYPE_CREATE;
- modest->mstyle_type_node_id = mchar_async_node_add(modest->mstyle_type_obj);
+ if((status = mchar_async_init(modest->mstyle_type_obj, 12, (4096 * 5))))
+ return status;
+ modest->mstyle_type_node_id = mchar_async_node_add(modest->mstyle_type_obj, &status);
+ if(status)
+ return status;
/* for raw declaration style */
modest->mraw_style_declaration_obj = mcobject_create();
if(modest->mraw_style_declaration_obj == NULL)
return MODEST_STATUS_ERROR_STYLE_DECLARATION_CREATE;
- myhtml_status_t myhtml_status = mcobject_init(modest->mraw_style_declaration_obj, 256, sizeof(modest_style_raw_declaration_t));
+ mystatus_t myhtml_status = mcobject_init(modest->mraw_style_declaration_obj, 256, sizeof(modest_style_raw_declaration_t));
if(myhtml_status)
return MODEST_STATUS_ERROR_STYLE_DECLARATION_INIT;
/* styles tree */
- modest->style_avl_tree = myhtml_utils_avl_tree_create();
+ modest->style_avl_tree = mycore_utils_avl_tree_create();
if(modest->style_avl_tree == NULL)
return MODEST_STATUS_ERROR_AVL_TREE_CREATE;
- myhtml_status = myhtml_utils_avl_tree_init(modest->style_avl_tree);
+ myhtml_status = mycore_utils_avl_tree_init(modest->style_avl_tree);
if(myhtml_status)
return MODEST_STATUS_ERROR_AVL_TREE_INIT;
@@ -94,7 +100,7 @@ void modest_clean(modest_t* modest)
{
mcobject_async_clean(modest->mnode_obj);
mcobject_async_clean(modest->mstylesheet_obj);
- myhtml_utils_avl_tree_clean(modest->style_avl_tree);
+ mycore_utils_avl_tree_clean(modest->style_avl_tree);
}
modest_t * modest_destroy(modest_t* modest, bool self_destroy)
@@ -104,10 +110,10 @@ modest_t * modest_destroy(modest_t* modest, bool self_destroy)
modest->mnode_obj = mcobject_async_destroy(modest->mnode_obj, true);
modest->mstylesheet_obj = mcobject_async_destroy(modest->mstylesheet_obj, true);
- modest->style_avl_tree = myhtml_utils_avl_tree_destroy(modest->style_avl_tree, true);
+ modest->style_avl_tree = mycore_utils_avl_tree_destroy(modest->style_avl_tree, true);
if(self_destroy) {
- myhtml_free(modest);
+ mycore_free(modest);
return NULL;
}
diff --git a/source/modest/modest.h b/source/modest/modest.h
index fabe717..0848ad9 100644
--- a/source/modest/modest.h
+++ b/source/modest/modest.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -24,10 +24,10 @@
#include "modest/myosi.h"
#include "modest/layer/layer.h"
-#include "myhtml/utils/mcobject.h"
-#include "myhtml/utils/mcobject_async.h"
-#include "myhtml/utils/mchar_async.h"
-#include "myhtml/utils/avl_tree.h"
+#include "mycore/utils/mcobject.h"
+#include "mycore/utils/mcobject_async.h"
+#include "mycore/utils/mchar_async.h"
+#include "mycore/utils/avl_tree.h"
#ifdef __cplusplus
extern "C" {
@@ -47,7 +47,7 @@ struct modest {
modest_layout_t* layout;
- myhtml_utils_avl_tree_t* style_avl_tree;
+ mycore_utils_avl_tree_t* style_avl_tree;
/* refs */
myhtml_tree_t* myhtml_tree;
@@ -56,7 +56,7 @@ struct modest {
modest_t * modest_create(void);
-modest_status_t modest_init(modest_t* modest);
+mystatus_t modest_init(modest_t* modest);
void modest_clean(modest_t* modest);
modest_t * modest_destroy(modest_t* modest, bool self_destroy);
diff --git a/source/modest/myosi.h b/source/modest/myosi.h
index e1239e3..4434f89 100644
--- a/source/modest/myosi.h
+++ b/source/modest/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -22,9 +22,16 @@
#define MODEST_MYOSI_H
#pragma once
+#include "mycore/myosi.h"
#include "myhtml/myhtml.h"
#include "mycss/mycss.h"
+#define MODEST_VERSION_MAJOR 0
+#define MODEST_VERSION_MINOR 0
+#define MODEST_VERSION_PATCH 6
+
+#define MODEST_VERSION_STRING MyCORE_STR(MODEST_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MODEST_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MODEST_VERSION_PATCH)
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -36,12 +43,14 @@ extern "C" {
for myhtml 0..00ffff; MyHTML_STATUS_OK == 0x000000
for mycss and modules 010000..01ffff; MyCSS_STATUS_OK == 0x000000
for modest 020000..02ffff; MODEST_STATUS_OK == 0x000000
- for myrender 030000..03ffff; MyRENDER_STATUS_OK == 0x000000
+ for myrender 030000..037777; MyRENDER_STATUS_OK == 0x000000
+ for myurl 038888..0388ff; MyURL_STATUS_OK == 0x000000
+ for myunicode 038900..038bff; MyUNICODE_STATUS_OK == 0x000000
+ not occupied 038c00..03ffff;
for mydom 040000..04ffff; MyDOM_STATUS_OK == 0x000000
for mynetwork 050000..05ffff; MyNETWORK_STATUS_OK == 0x000000
for myecma 060000..06ffff; MyECMA_STATUS_OK == 0x000000
- for myfont 070000..07ffff; MyFONT_STATUS_OK == 0x000000
- not occupied 080000..
+ not occupied 070000..
*/
enum modest_status {
MODEST_STATUS_OK = 0x000000,
diff --git a/source/modest/node/node.c b/source/modest/node/node.c
index c9cb748..ce32709 100644
--- a/source/modest/node/node.c
+++ b/source/modest/node/node.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -33,13 +33,13 @@ modest_node_t * modest_node_create(modest_t* modest)
return mnode;
}
-modest_status_t modest_node_init(modest_t* modest, modest_node_t *mnode)
+mystatus_t modest_node_init(modest_t* modest, modest_node_t *mnode)
{
mnode->stylesheet = modest_style_sheet_create(modest);
if(mnode->stylesheet == NULL)
return MODEST_STATUS_ERROR_MEMORY_ALLOCATION;
- modest_status_t status = modest_style_sheet_init(modest, mnode->stylesheet);
+ mystatus_t status = modest_style_sheet_init(modest, mnode->stylesheet);
if(status)
return MODEST_STATUS_ERROR;
@@ -70,7 +70,7 @@ void modest_node_raw_declaration_set_by_type(modest_t* modest, modest_node_t *mn
mycss_declaration_entry_t * modest_node_declaration_by_type(modest_t* modest, modest_node_t *mnode, mycss_property_type_t type)
{
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(modest->style_avl_tree, mnode->avl_tree_node, type);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(modest->style_avl_tree, mnode->avl_tree_node, type);
if(find_node)
return ((modest_style_raw_declaration_t*)find_node->value)->declaration;
@@ -80,13 +80,13 @@ mycss_declaration_entry_t * modest_node_declaration_by_type(modest_t* modest, mo
modest_style_raw_declaration_t * modest_node_raw_declaration_by_type(modest_t* modest, modest_node_t *mnode, mycss_property_type_t type)
{
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(modest->style_avl_tree, mnode->avl_tree_node, type);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(modest->style_avl_tree, mnode->avl_tree_node, type);
return (find_node ? find_node->value : NULL);
}
void modest_node_raw_declaration_set_by_type(modest_t* modest, modest_node_t *mnode, mycss_property_type_t type, modest_style_raw_declaration_t *raw_declr)
{
- myhtml_utils_avl_tree_add(modest->style_avl_tree, &mnode->avl_tree_node, type, raw_declr);
+ mycore_utils_avl_tree_add(modest->style_avl_tree, &mnode->avl_tree_node, type, raw_declr);
}
#endif /* MODEST_NODE_FULL_RAW */
diff --git a/source/modest/node/node.h b/source/modest/node/node.h
index 3de5b9c..5403c35 100644
--- a/source/modest/node/node.h
+++ b/source/modest/node/node.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -26,7 +26,7 @@
#include "modest/modest.h"
#include "modest/style/raw.h"
#include "modest/render/tree_node.h"
-#include "myhtml/utils/avl_tree.h"
+#include "mycore/utils/avl_tree.h"
#ifdef __cplusplus
extern "C" {
@@ -35,7 +35,7 @@ extern "C" {
struct modest_node {
modest_style_sheet_t* stylesheet;
#ifndef MODEST_NODE_FULL_RAW
- myhtml_utils_avl_tree_node_t *avl_tree_node;
+ mycore_utils_avl_tree_node_t *avl_tree_node;
#else
modest_style_raw_declaration_t * raw_declaration[MyCSS_PROPERTY_TYPE_LAST_ENTRY];
#endif /* MODEST_NODE_FULL_RAW */
@@ -44,7 +44,7 @@ struct modest_node {
};
modest_node_t * modest_node_create(modest_t* modest);
-modest_status_t modest_node_init(modest_t* modest, modest_node_t *mnode);
+mystatus_t modest_node_init(modest_t* modest, modest_node_t *mnode);
mycss_declaration_entry_t * modest_node_declaration_by_type(modest_t* modest, modest_node_t *mnode, mycss_property_type_t type);
diff --git a/source/modest/node/property.c b/source/modest/node/property.c
index 5e77a57..f59a232 100644
--- a/source/modest/node/property.c
+++ b/source/modest/node/property.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/node/property.h b/source/modest/node/property.h
index 27190c0..fd7dc17 100644
--- a/source/modest/node/property.h
+++ b/source/modest/node/property.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/node/raw_property.c b/source/modest/node/raw_property.c
index 8b0bb33..f72dbfb 100644
--- a/source/modest/node/raw_property.c
+++ b/source/modest/node/raw_property.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/node/raw_property.h b/source/modest/node/raw_property.h
index 237cb63..bb19b81 100644
--- a/source/modest/node/raw_property.h
+++ b/source/modest/node/raw_property.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/node/serialization.c b/source/modest/node/serialization.c
index 0b6a23a..af72d8c 100644
--- a/source/modest/node/serialization.c
+++ b/source/modest/node/serialization.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "modest/node/serialization.h"
-void modest_node_raw_serialization_declaration(mycss_entry_t* mycss_entry, mycss_declaration_entry_t* decl, mycss_property_type_t property_type, mycss_callback_serialization_f callback, void* context, bool* is_use)
+void modest_node_raw_serialization_declaration(mycss_entry_t* mycss_entry, mycss_declaration_entry_t* decl, mycss_property_type_t property_type, mycore_callback_serialize_f callback, void* context, bool* is_use)
{
if(decl == NULL)
return;
@@ -36,7 +36,7 @@ void modest_node_raw_serialization_declaration(mycss_entry_t* mycss_entry, mycss
}
}
-//bool modest_node_raw_serialization(mycss_entry_t* mycss_entry, modest_node_t* mnode, mycss_callback_serialization_f callback, void* context)
+//bool modest_node_raw_serialization(mycss_entry_t* mycss_entry, modest_node_t* mnode, mycore_callback_serialize_f callback, void* context)
//{
// bool is_use = false;
//
@@ -48,7 +48,7 @@ void modest_node_raw_serialization_declaration(mycss_entry_t* mycss_entry, mycss
// return is_use;
//}
-void modest_node_raw_serialization_callback(myhtml_utils_avl_tree_node_t* node, void* context)
+void modest_node_raw_serialization_callback(mycore_utils_avl_tree_node_t* node, void* context)
{
modest_node_serialization_context_t *ctx = context;
@@ -56,11 +56,11 @@ void modest_node_raw_serialization_callback(myhtml_utils_avl_tree_node_t* node,
modest_node_raw_serialization_declaration(ctx->modest->mycss_entry, raw_declr->declaration, (mycss_property_type_t)node->type, ctx->callback, ctx->context, &ctx->is_use);
}
-bool modest_node_raw_serialization(modest_t* modest, modest_node_t* mnode, mycss_callback_serialization_f callback, void* context)
+bool modest_node_raw_serialization(modest_t* modest, modest_node_t* mnode, mycore_callback_serialize_f callback, void* context)
{
modest_node_serialization_context_t ctx = {modest, callback, context, 0};
- myhtml_utils_avl_tree_list_all_nodes(modest->style_avl_tree, mnode->avl_tree_node, modest_node_raw_serialization_callback, &ctx);
+ mycore_utils_avl_tree_list_all_nodes(modest->style_avl_tree, mnode->avl_tree_node, modest_node_raw_serialization_callback, &ctx);
return ctx.is_use;
}
diff --git a/source/modest/node/serialization.h b/source/modest/node/serialization.h
index 73f3828..df68ba6 100644
--- a/source/modest/node/serialization.h
+++ b/source/modest/node/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -34,13 +34,13 @@ extern "C" {
struct modest_node_serialization_context {
modest_t* modest;
- mycss_callback_serialization_f callback;
+ mycore_callback_serialize_f callback;
void* context;
bool is_use;
}
typedef modest_node_serialization_context_t;
-bool modest_node_raw_serialization(modest_t* modest, modest_node_t* mnode, mycss_callback_serialization_f callback, void* context);
+bool modest_node_raw_serialization(modest_t* modest, modest_node_t* mnode, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/modest/render/begin.c b/source/modest/render/begin.c
index 55784c7..6aff8bc 100644
--- a/source/modest/render/begin.c
+++ b/source/modest/render/begin.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/render/begin.h b/source/modest/render/begin.h
index 53a2b99..b772559 100644
--- a/source/modest/render/begin.h
+++ b/source/modest/render/begin.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/render/binding.c b/source/modest/render/binding.c
index d6486bc..6500c33 100644
--- a/source/modest/render/binding.c
+++ b/source/modest/render/binding.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/render/binding.h b/source/modest/render/binding.h
index 2f6ad5a..1b006da 100644
--- a/source/modest/render/binding.h
+++ b/source/modest/render/binding.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/render/tree.c b/source/modest/render/tree.c
index e7cc9d9..6c705dd 100644
--- a/source/modest/render/tree.c
+++ b/source/modest/render/tree.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -22,16 +22,16 @@
modest_render_tree_t * modest_render_tree_create(void)
{
- return myhtml_calloc(1, sizeof(modest_render_tree_t));
+ return mycore_calloc(1, sizeof(modest_render_tree_t));
}
-modest_status_t modest_render_tree_init(modest_render_tree_t* render_tree)
+mystatus_t modest_render_tree_init(modest_render_tree_t* render_tree)
{
render_tree->mc_nodes = mcobject_create();
if(render_tree->mc_nodes == NULL)
return MODEST_STATUS_ERROR_MEMORY_ALLOCATION;
- myhtml_status_t myhtml_status = mcobject_init(render_tree->mc_nodes, 1024, sizeof(modest_render_tree_node_t));
+ mystatus_t myhtml_status = mcobject_init(render_tree->mc_nodes, 1024, sizeof(modest_render_tree_node_t));
if(myhtml_status)
return MODEST_STATUS_ERROR;
@@ -51,7 +51,7 @@ modest_render_tree_t * modest_render_tree_destroy(modest_render_tree_t* render_t
render_tree->mc_nodes = mcobject_destroy(render_tree->mc_nodes, true);
if(self_destroy) {
- myhtml_free(render_tree);
+ mycore_free(render_tree);
return NULL;
}
@@ -59,7 +59,7 @@ modest_render_tree_t * modest_render_tree_destroy(modest_render_tree_t* render_t
}
void modest_render_tree_serialization(myhtml_tree_t* html_tree, modest_render_tree_t* tree,
- modest_render_tree_node_t* scope_node, mycss_callback_serialization_f callback, void* context)
+ modest_render_tree_node_t* scope_node, mycore_callback_serialize_f callback, void* context)
{
modest_render_tree_node_t* node = scope_node;
size_t depth = 0;
diff --git a/source/modest/render/tree.h b/source/modest/render/tree.h
index 1c3966e..ea9deeb 100644
--- a/source/modest/render/tree.h
+++ b/source/modest/render/tree.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -25,7 +25,7 @@
typedef struct modest_render_tree modest_render_tree_t;
#include "modest/modest.h"
-#include "myhtml/utils/mcobject.h"
+#include "mycore/utils/mcobject.h"
#include "modest/render/tree_node.h"
#ifdef __cplusplus
@@ -37,12 +37,12 @@ struct modest_render_tree {
};
modest_render_tree_t * modest_render_tree_create(void);
-modest_status_t modest_render_tree_init(modest_render_tree_t* render_tree);
+mystatus_t modest_render_tree_init(modest_render_tree_t* render_tree);
void modest_render_tree_clean_all(modest_render_tree_t* render_tree);
modest_render_tree_t * modest_render_tree_destroy(modest_render_tree_t* render_tree, bool self_destroy);
void modest_render_tree_serialization(myhtml_tree_t* html_tree, modest_render_tree_t* tree,
- modest_render_tree_node_t* scope_node, mycss_callback_serialization_f callback, void* context);
+ modest_render_tree_node_t* scope_node, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/modest/render/tree_node.c b/source/modest/render/tree_node.c
index 37eb736..fe2dc45 100644
--- a/source/modest/render/tree_node.c
+++ b/source/modest/render/tree_node.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -122,7 +122,7 @@ void modest_render_tree_node_append_before(modest_render_tree_node_t* target, mo
target->prev = node;
}
-void modest_render_tree_node_serialization(myhtml_tree_t* html_tree, modest_render_tree_node_t* node, mycss_callback_serialization_f callback, void* context)
+void modest_render_tree_node_serialization(myhtml_tree_t* html_tree, modest_render_tree_node_t* node, mycore_callback_serialize_f callback, void* context)
{
callback("<", 1, context);
diff --git a/source/modest/render/tree_node.h b/source/modest/render/tree_node.h
index 15593df..ce98ee7 100644
--- a/source/modest/render/tree_node.h
+++ b/source/modest/render/tree_node.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -28,7 +28,7 @@ typedef struct modest_render_tree_node modest_render_tree_node_t;
#include "modest/render/tree.h"
#include "myhtml/tree.h"
-#include "myhtml/utils/mcobject.h"
+#include "mycore/utils/mcobject.h"
#ifdef __cplusplus
extern "C" {
@@ -62,7 +62,7 @@ void modest_render_tree_node_remove(modest_render_tree_node_t* node);
void modest_render_tree_node_append_after(modest_render_tree_node_t* target, modest_render_tree_node_t* node);
void modest_render_tree_node_append_before(modest_render_tree_node_t* target, modest_render_tree_node_t* node);
-void modest_render_tree_node_serialization(myhtml_tree_t* html_tree, modest_render_tree_node_t* node, mycss_callback_serialization_f callback, void* context);
+void modest_render_tree_node_serialization(myhtml_tree_t* html_tree, modest_render_tree_node_t* node, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/modest/style/default.c b/source/modest/style/default.c
index 777db46..bd191de 100644
--- a/source/modest/style/default.c
+++ b/source/modest/style/default.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/style/default.h b/source/modest/style/default.h
index d4eadc3..2adc06a 100644
--- a/source/modest/style/default.h
+++ b/source/modest/style/default.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/style/default_entries.h b/source/modest/style/default_entries.h
index 0558e81..5545415 100644
--- a/source/modest/style/default_entries.h
+++ b/source/modest/style/default_entries.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/style/default_resources.h b/source/modest/style/default_resources.h
index 39d723d..a61abf4 100644
--- a/source/modest/style/default_resources.h
+++ b/source/modest/style/default_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/style/map.c b/source/modest/style/map.c
index 9ca57e0..5c2affc 100644
--- a/source/modest/style/map.c
+++ b/source/modest/style/map.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/style/map.h b/source/modest/style/map.h
index 28174bf..aad706c 100644
--- a/source/modest/style/map.h
+++ b/source/modest/style/map.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/style/map_resource.h b/source/modest/style/map_resource.h
index bb2eca2..9938dd8 100644
--- a/source/modest/style/map_resource.h
+++ b/source/modest/style/map_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/style/raw.c b/source/modest/style/raw.c
index 96cb01c..1b64e5d 100644
--- a/source/modest/style/raw.c
+++ b/source/modest/style/raw.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/modest/style/raw.h b/source/modest/style/raw.h
index 3567d47..c9155e5 100644
--- a/source/modest/style/raw.h
+++ b/source/modest/style/raw.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -24,7 +24,7 @@
#include "modest/myosi.h"
#include "modest/modest.h"
-#include "myhtml/utils/mcobject.h"
+#include "mycore/utils/mcobject.h"
#ifdef __cplusplus
extern "C" {
diff --git a/source/modest/style/sheet.c b/source/modest/style/sheet.c
index 84ae158..9609d26 100644
--- a/source/modest/style/sheet.c
+++ b/source/modest/style/sheet.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -32,7 +32,7 @@ modest_style_sheet_t * modest_style_sheet_create(modest_t* modest)
return m_stylesheet;
}
-modest_status_t modest_style_sheet_init(modest_t* modest, modest_style_sheet_t* m_stylesheet)
+mystatus_t modest_style_sheet_init(modest_t* modest, modest_style_sheet_t* m_stylesheet)
{
return MODEST_STATUS_OK;
}
diff --git a/source/modest/style/sheet.h b/source/modest/style/sheet.h
index 5f8bea6..5dd12df 100644
--- a/source/modest/style/sheet.h
+++ b/source/modest/style/sheet.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -53,7 +53,7 @@ struct modest_style_sheet {
};
modest_style_sheet_t * modest_style_sheet_create(modest_t* modest);
-modest_status_t modest_style_sheet_init(modest_t* modest, modest_style_sheet_t* m_stylesheet);
+mystatus_t modest_style_sheet_init(modest_t* modest, modest_style_sheet_t* m_stylesheet);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/modest/style/type.c b/source/modest/style/type.c
index fc81899..6750cb7 100644
--- a/source/modest/style/type.c
+++ b/source/modest/style/type.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -32,7 +32,7 @@ void * modest_style_type_create(modest_t* modest, size_t size)
return data;
}
-modest_status_t modest_style_type_init(modest_t* modest, void *data)
+mystatus_t modest_style_type_init(modest_t* modest, void *data)
{
return MODEST_STATUS_OK;
}
diff --git a/source/modest/style/type.h b/source/modest/style/type.h
index 366b0b4..a2b1e61 100644
--- a/source/modest/style/type.h
+++ b/source/modest/style/type.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -25,7 +25,7 @@
#include "modest/myosi.h"
#include "modest/modest.h"
#include "mycss/declaration/myosi.h"
-#include "myhtml/utils/mchar_async.h"
+#include "mycore/utils/mchar_async.h"
#ifdef __cplusplus
extern "C" {
@@ -44,7 +44,7 @@ struct modest_style_type_display {
void * modest_style_type_create(modest_t* modest, size_t size);
-modest_status_t modest_style_type_init(modest_t* modest, void *data);
+mystatus_t modest_style_type_init(modest_t* modest, void *data);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/mycore/Makefile.mk b/source/mycore/Makefile.mk
new file mode 100644
index 0000000..fbbd1c1
--- /dev/null
+++ b/source/mycore/Makefile.mk
@@ -0,0 +1,13 @@
+mycore_dirs := . utils
+mycore_objs := $(call MODEST_UTILS_OBJS,mycore,$(mycore_dirs))
+
+mycore_description := base module, it is used by all other modules
+mycore_dependencies :=
+
+mycore_all: $(mycore_objs)
+
+mycore_clean:
+ rm -f $(mycore_objs)
+
+mycore_clone:
+ $(call MODEST_UTILS_HDRS_CLONE,mycore,$(mycore_dirs))
diff --git a/source/myhtml/incoming.c b/source/mycore/incoming.c
index fc0bd99..4b83e11 100644
--- a/source/myhtml/incoming.c
+++ b/source/mycore/incoming.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -18,13 +18,13 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/incoming.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/incoming.h"
+#include "mycore/utils/resources.h"
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_add(myhtml_incoming_buffer_t *current, mcobject_t *mcobject,
+mycore_incoming_buffer_t * mycore_incoming_buffer_add(mycore_incoming_buffer_t *current, mcobject_t *mcobject,
const char *html, size_t html_size)
{
- myhtml_incoming_buffer_t *inc_buf = mcobject_malloc(mcobject, NULL);
+ mycore_incoming_buffer_t *inc_buf = mcobject_malloc(mcobject, NULL);
inc_buf->size = html_size;
inc_buf->length = 0;
@@ -44,15 +44,15 @@ myhtml_incoming_buffer_t * myhtml_incoming_buffer_add(myhtml_incoming_buffer_t *
return inc_buf;
}
-void myhtml_incoming_buffer_clean(myhtml_incoming_buffer_t *current)
+void mycore_incoming_buffer_clean(mycore_incoming_buffer_t *current)
{
- memset(current, 0, sizeof(myhtml_incoming_buffer_t));
+ memset(current, 0, sizeof(mycore_incoming_buffer_t));
}
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_split(myhtml_incoming_buffer_t *current, mcobject_t *mcobject, size_t global_pos)
+mycore_incoming_buffer_t * mycore_incoming_buffer_split(mycore_incoming_buffer_t *current, mcobject_t *mcobject, size_t global_pos)
{
size_t relative_pos = global_pos - current->offset;
- myhtml_incoming_buffer_t *inc_buf = mcobject_malloc(mcobject, NULL);
+ mycore_incoming_buffer_t *inc_buf = mcobject_malloc(mcobject, NULL);
inc_buf->size = current->size - relative_pos;
inc_buf->length = inc_buf->size;
@@ -68,7 +68,7 @@ myhtml_incoming_buffer_t * myhtml_incoming_buffer_split(myhtml_incoming_buffer_t
return inc_buf;
}
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_find_by_position(myhtml_incoming_buffer_t *inc_buf, size_t begin)
+mycore_incoming_buffer_t * mycore_incoming_buffer_find_by_position(mycore_incoming_buffer_t *inc_buf, size_t begin)
{
if(inc_buf->offset < begin) {
while(inc_buf && (inc_buf->offset + inc_buf->size) < begin)
@@ -82,32 +82,32 @@ myhtml_incoming_buffer_t * myhtml_incoming_buffer_find_by_position(myhtml_incomi
return inc_buf;
}
-const char * myhtml_incoming_buffer_data(myhtml_incoming_buffer_t *inc_buf)
+const char * mycore_incoming_buffer_data(mycore_incoming_buffer_t *inc_buf)
{
return inc_buf->data;
}
-size_t myhtml_incoming_buffer_length(myhtml_incoming_buffer_t *inc_buf)
+size_t mycore_incoming_buffer_length(mycore_incoming_buffer_t *inc_buf)
{
return inc_buf->length;
}
-size_t myhtml_incoming_buffer_size(myhtml_incoming_buffer_t *inc_buf)
+size_t mycore_incoming_buffer_size(mycore_incoming_buffer_t *inc_buf)
{
return inc_buf->size;
}
-size_t myhtml_incoming_buffer_offset(myhtml_incoming_buffer_t *inc_buf)
+size_t mycore_incoming_buffer_offset(mycore_incoming_buffer_t *inc_buf)
{
return inc_buf->offset;
}
-size_t myhtml_incoming_buffer_relative_begin(myhtml_incoming_buffer_t *inc_buf, size_t begin)
+size_t mycore_incoming_buffer_relative_begin(mycore_incoming_buffer_t *inc_buf, size_t begin)
{
return (begin - inc_buf->offset);
}
-size_t myhtml_incoming_buffer_available_length(myhtml_incoming_buffer_t *inc_buf, size_t relative_begin, size_t length)
+size_t mycore_incoming_buffer_available_length(mycore_incoming_buffer_t *inc_buf, size_t relative_begin, size_t length)
{
if((relative_begin + length) > inc_buf->size)
return (inc_buf->size - relative_begin);
@@ -115,12 +115,12 @@ size_t myhtml_incoming_buffer_available_length(myhtml_incoming_buffer_t *inc_buf
return length;
}
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_next(myhtml_incoming_buffer_t *inc_buf)
+mycore_incoming_buffer_t * mycore_incoming_buffer_next(mycore_incoming_buffer_t *inc_buf)
{
return inc_buf->next;
}
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_prev(myhtml_incoming_buffer_t *inc_buf)
+mycore_incoming_buffer_t * mycore_incoming_buffer_prev(mycore_incoming_buffer_t *inc_buf)
{
return inc_buf->prev;
}
@@ -128,10 +128,10 @@ myhtml_incoming_buffer_t * myhtml_incoming_buffer_prev(myhtml_incoming_buffer_t
// // //
// convert only one 002345 (\002345) to code point
//
-size_t myhtml_incoming_buffer_convert_one_escaped_to_code_point(myhtml_incoming_buffer_t **inc_buf, size_t *relative_pos)
+size_t mycore_incoming_buffer_convert_one_escaped_to_code_point(mycore_incoming_buffer_t **inc_buf, size_t *relative_pos)
{
const unsigned char *u_data;
- myhtml_incoming_buffer_t *current = *inc_buf;
+ mycore_incoming_buffer_t *current = *inc_buf;
if(*relative_pos >= current->size) {
*relative_pos = 0;
@@ -145,9 +145,9 @@ size_t myhtml_incoming_buffer_convert_one_escaped_to_code_point(myhtml_incoming_
while(current)
{
- if(myhtml_string_chars_num_map[ u_data[*relative_pos] ] != 0xff && consume < 6) {
+ if(mycore_string_chars_num_map[ u_data[*relative_pos] ] != 0xff && consume < 6) {
code_point <<= 4;
- code_point |= myhtml_string_chars_hex_map[ u_data[*relative_pos] ];
+ code_point |= mycore_string_chars_hex_map[ u_data[*relative_pos] ];
++consume;
}
@@ -173,9 +173,9 @@ size_t myhtml_incoming_buffer_convert_one_escaped_to_code_point(myhtml_incoming_
return code_point;
}
-size_t myhtml_incoming_buffer_escaped_case_cmp(myhtml_incoming_buffer_t **inc_buf, const char *to, size_t to_size, size_t *relative_pos)
+size_t mycore_incoming_buffer_escaped_case_cmp(mycore_incoming_buffer_t **inc_buf, const char *to, size_t to_size, size_t *relative_pos)
{
- myhtml_incoming_buffer_t *current = *inc_buf;
+ mycore_incoming_buffer_t *current = *inc_buf;
if(*relative_pos >= current->size) {
if(current->next == 0)
@@ -195,15 +195,15 @@ size_t myhtml_incoming_buffer_escaped_case_cmp(myhtml_incoming_buffer_t **inc_bu
if(u_data[*relative_pos] == 0x5C) {
*relative_pos += 1;
- size_t code_point = myhtml_incoming_buffer_convert_one_escaped_to_code_point(&current, relative_pos);
+ size_t code_point = mycore_incoming_buffer_convert_one_escaped_to_code_point(&current, relative_pos);
- if(code_point > 255 || myhtml_string_chars_lowercase_map[code_point] != myhtml_string_chars_lowercase_map[ u_to[i] ]) {
+ if(code_point > 255 || mycore_string_chars_lowercase_map[code_point] != mycore_string_chars_lowercase_map[ u_to[i] ]) {
break;
}
u_data = (const unsigned char*)current->data;
}
- else if(myhtml_string_chars_lowercase_map[ u_data[*relative_pos] ] != myhtml_string_chars_lowercase_map[ u_to[i] ]) {
+ else if(mycore_string_chars_lowercase_map[ u_data[*relative_pos] ] != mycore_string_chars_lowercase_map[ u_to[i] ]) {
break;
}
else {
@@ -226,7 +226,3 @@ size_t myhtml_incoming_buffer_escaped_case_cmp(myhtml_incoming_buffer_t **inc_bu
*inc_buf = current;
return (to_size - i);
}
-
-
-
-
diff --git a/include/myhtml/incoming.h b/source/mycore/incoming.h
index 6755d4e..6b7afd9 100644
--- a/include/myhtml/incoming.h
+++ b/source/mycore/incoming.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -18,51 +18,48 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_INCOMING_H
-#define MyHTML_INCOMING_H
+#ifndef MyCORE_INCOMING_H
+#define MyCORE_INCOMING_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-#include <myhtml/myosi.h>
-#include <myhtml/tree.h>
-#include <myhtml/utils/mcobject.h>
+#include "mycore/myosi.h"
+#include "mycore/utils/mcobject.h"
-struct myhtml_incoming_buffer {
+struct mycore_incoming_buffer {
const char* data;
size_t length; // use of data
size_t size; // size of data
size_t offset; // begin global offset
- struct myhtml_incoming_buffer* prev;
- struct myhtml_incoming_buffer* next;
+ struct mycore_incoming_buffer* prev;
+ struct mycore_incoming_buffer* next;
};
+mycore_incoming_buffer_t * mycore_incoming_buffer_add(mycore_incoming_buffer_t *current, mcobject_t *mcobject, const char *html, size_t html_size);
+void mycore_incoming_buffer_clean(mycore_incoming_buffer_t *current);
+mycore_incoming_buffer_t * mycore_incoming_buffer_split(mycore_incoming_buffer_t *current, mcobject_t *mcobject, size_t global_pos);
-// incoming buffer
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_add(myhtml_incoming_buffer_t *current, mcobject_t *mcobject, const char *html, size_t html_size);
-void myhtml_incoming_buffer_clean(myhtml_incoming_buffer_t *current);
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_split(myhtml_incoming_buffer_t *current, mcobject_t *mcobject, size_t global_pos);
+mycore_incoming_buffer_t * mycore_incoming_buffer_find_by_position(mycore_incoming_buffer_t *inc_buf, size_t begin);
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_find_by_position(myhtml_incoming_buffer_t *inc_buf, size_t begin);
+const char * mycore_incoming_buffer_data(mycore_incoming_buffer_t *inc_buf);
+size_t mycore_incoming_buffer_length(mycore_incoming_buffer_t *inc_buf);
+size_t mycore_incoming_buffer_size(mycore_incoming_buffer_t *inc_buf);
+size_t mycore_incoming_buffer_offset(mycore_incoming_buffer_t *inc_buf);
+size_t mycore_incoming_buffer_relative_begin(mycore_incoming_buffer_t *inc_buf, size_t begin);
+size_t mycore_incoming_buffer_available_length(mycore_incoming_buffer_t *inc_buf, size_t relative_begin, size_t length);
-const char * myhtml_incoming_buffer_data(myhtml_incoming_buffer_t *inc_buf);
-size_t myhtml_incoming_buffer_length(myhtml_incoming_buffer_t *inc_buf);
-size_t myhtml_incoming_buffer_size(myhtml_incoming_buffer_t *inc_buf);
-size_t myhtml_incoming_buffer_offset(myhtml_incoming_buffer_t *inc_buf);
-size_t myhtml_incoming_buffer_relative_begin(myhtml_incoming_buffer_t *inc_buf, size_t begin);
-size_t myhtml_incoming_buffer_available_length(myhtml_incoming_buffer_t *inc_buf, size_t relative_begin, size_t length);
+mycore_incoming_buffer_t * mycore_incoming_buffer_next(mycore_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_t * mycore_incoming_buffer_prev(mycore_incoming_buffer_t *inc_buf);
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_next(myhtml_incoming_buffer_t *inc_buf);
-myhtml_incoming_buffer_t * myhtml_incoming_buffer_prev(myhtml_incoming_buffer_t *inc_buf);
-
-size_t myhtml_incoming_buffer_convert_one_escaped_to_code_point(myhtml_incoming_buffer_t **inc_buf, size_t *relative_pos);
-size_t myhtml_incoming_buffer_escaped_case_cmp(myhtml_incoming_buffer_t **inc_buf, const char *to, size_t to_size, size_t *relative_pos);
+size_t mycore_incoming_buffer_convert_one_escaped_to_code_point(mycore_incoming_buffer_t **inc_buf, size_t *relative_pos);
+size_t mycore_incoming_buffer_escaped_case_cmp(mycore_incoming_buffer_t **inc_buf, const char *to, size_t to_size, size_t *relative_pos);
#ifdef __cplusplus
} /* extern "C" */
#endif
-#endif /* MyHTML_INCOMING_H */
+#endif /* MyCORE_INCOMING_H */
diff --git a/source/mycore/myosi.c b/source/mycore/myosi.c
new file mode 100644
index 0000000..f9758ed
--- /dev/null
+++ b/source/mycore/myosi.c
@@ -0,0 +1,22 @@
+/*
+ Copyright (C) 2015-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 "mycore/myosi.h"
+
diff --git a/source/mycore/myosi.h b/source/mycore/myosi.h
new file mode 100644
index 0000000..563c44e
--- /dev/null
+++ b/source/mycore/myosi.h
@@ -0,0 +1,169 @@
+/*
+ Copyright (C) 2015-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 MyCORE_MYOSI_H
+#define MyCORE_MYOSI_H
+#pragma once
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#define MyCORE_STR_HELPER(x) #x
+#define MyCORE_STR(x) MyCORE_STR_HELPER(x)
+
+#define MyCORE_VERSION_MAJOR 0
+#define MyCORE_VERSION_MINOR 1
+#define MyCORE_VERSION_PATCH 0
+
+#define MyCORE_VERSION_STRING MyCORE_STR(MyCORE_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyCORE_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyCORE_VERSION_PATCH)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Format */
+#ifdef MyCORE_OS_WINDOWS_NT
+#define MyCORE_FORMAT_Z "%Iu"
+#else
+#define MyCORE_FORMAT_Z "%zu"
+#endif
+
+#if defined(_MSC_VER)
+# define MyCORE_DEPRECATED(func) __declspec(deprecated) func
+#elif defined(__GNUC__) || defined(__INTEL_COMPILER)
+# define MyCORE_DEPRECATED(func) func __attribute__((deprecated))
+#else
+# define MyCORE_DEPRECATED(func) func
+#endif
+
+/* Debug */
+#define MyCORE_DEBUG(...) do {} while(0)
+#define MyCORE_DEBUG_ERROR(...) do {} while(0)
+
+#define MyCORE_FAILED(_status_) ((_status_) != MyCORE_STATUS_OK)
+
+// base
+/*
+ Very important!!!
+
+ for mycore 0..008fff; MyCORE_STATUS_OK == 0x000000
+ for myhtml 009000..0093ff; MyHTML_STATUS_OK == 0x000000
+ for myencoding 009400..00942f; MyENCODING_STATUS_OK == 0x000000
+ not occupied 009430..00ffff;
+ for mycss and modules 010000..01ffff; MyCSS_STATUS_OK == 0x000000
+ for modest 020000..02ffff; MODEST_STATUS_OK == 0x000000
+ for myrender 030000..037777; MyRENDER_STATUS_OK == 0x000000
+ for myurl 038888..0388ff; MyURL_STATUS_OK == 0x000000
+ for myunicode 038900..038bff; MyUNICODE_STATUS_OK == 0x000000
+ not occupied 038c00..03ffff;
+ for mydom 040000..04ffff; MyDOM_STATUS_OK == 0x000000
+ for mynetwork 050000..05ffff; MyNETWORK_STATUS_OK == 0x000000
+ for myecma 060000..06ffff; MyECMA_STATUS_OK == 0x000000
+ not occupied 070000..
+*/
+enum mycore_status {
+ MyCORE_STATUS_OK = 0x0000,
+ MyCORE_STATUS_ERROR = 0x0001,
+ MyCORE_STATUS_ERROR_MEMORY_ALLOCATION = 0x0002,
+ MyCORE_STATUS_THREAD_ERROR_MEMORY_ALLOCATION = 0x0009,
+ MyCORE_STATUS_THREAD_ERROR_LIST_INIT = 0x000a,
+ MyCORE_STATUS_THREAD_ERROR_ATTR_MALLOC = 0x000b,
+ MyCORE_STATUS_THREAD_ERROR_ATTR_INIT = 0x000c,
+ MyCORE_STATUS_THREAD_ERROR_ATTR_SET = 0x000d,
+ MyCORE_STATUS_THREAD_ERROR_ATTR_DESTROY = 0x000e,
+ MyCORE_STATUS_THREAD_ERROR_NO_SLOTS = 0x000f,
+ MyCORE_STATUS_THREAD_ERROR_BATCH_INIT = 0x0010,
+ MyCORE_STATUS_THREAD_ERROR_WORKER_MALLOC = 0x0011,
+ MyCORE_STATUS_THREAD_ERROR_WORKER_SEM_CREATE = 0x0012,
+ MyCORE_STATUS_THREAD_ERROR_WORKER_THREAD_CREATE = 0x0013,
+ MyCORE_STATUS_THREAD_ERROR_MASTER_THREAD_CREATE = 0x0014,
+ MyCORE_STATUS_THREAD_ERROR_SEM_PREFIX_MALLOC = 0x0032,
+ MyCORE_STATUS_THREAD_ERROR_SEM_CREATE = 0x0033,
+ MyCORE_STATUS_THREAD_ERROR_QUEUE_MALLOC = 0x003c,
+ MyCORE_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC = 0x003d,
+ MyCORE_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC = 0x003e,
+ MyCORE_STATUS_THREAD_ERROR_MUTEX_MALLOC = 0x0046,
+ MyCORE_STATUS_THREAD_ERROR_MUTEX_INIT = 0x0047,
+ MyCORE_STATUS_THREAD_ERROR_MUTEX_LOCK = 0x0048,
+ MyCORE_STATUS_THREAD_ERROR_MUTEX_UNLOCK = 0x0049,
+ MyCORE_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF = 0x0050,
+ MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK = 0x0051,
+ MyCORE_STATUS_MCOBJECT_ERROR_CACHE_CREATE = 0x0055,
+ MyCORE_STATUS_MCOBJECT_ERROR_CHUNK_CREATE = 0x0056,
+ MyCORE_STATUS_MCOBJECT_ERROR_CHUNK_INIT = 0x0057,
+ MyCORE_STATUS_MCOBJECT_ERROR_CACHE_REALLOC = 0x0058,
+ MyCORE_STATUS_ASYNC_ERROR_LOCK = 0x0060,
+ MyCORE_STATUS_ASYNC_ERROR_UNLOCK = 0x0061,
+ MyCORE_STATUS_ERROR_NO_FREE_SLOT = 0x0062,
+}
+typedef mycore_status_t;
+
+typedef unsigned int mystatus_t;
+
+/* thread */
+typedef struct mythread_queue_list_entry mythread_queue_list_entry_t;
+typedef struct mythread_queue_thread_param mythread_queue_thread_param_t;
+typedef struct mythread_queue_list mythread_queue_list_t;
+typedef struct mythread_queue_node mythread_queue_node_t;
+typedef struct mythread_queue mythread_queue_t;
+
+typedef size_t mythread_id_t;
+typedef struct mythread_context mythread_context_t;
+typedef struct mythread_entry mythread_entry_t;
+typedef struct mythread mythread_t;
+
+/* mystring */
+typedef struct mycore_string_raw mycore_string_raw_t;
+typedef struct mycore_string mycore_string_t;
+
+/* incoming buffer */
+typedef struct mycore_incoming_buffer mycore_incoming_buffer_t;
+
+/* callbacks */
+typedef mystatus_t (*mycore_callback_serialize_f)(const char* buffer, size_t size, void* ctx);
+
+void * mycore_malloc(size_t size);
+void * mycore_realloc(void* dst, size_t size);
+void * mycore_calloc(size_t num, size_t size);
+void * mycore_free(void* dst);
+
+/* io */
+FILE * mycore_fopen(const char *filename, const char *mode);
+int mycore_fclose(FILE *stream);
+
+size_t mycore_fread(void *buffer, size_t size, size_t count, FILE *stream);
+size_t mycore_fwrite(const void *buffer, size_t size, size_t count, FILE *stream);
+int mycore_fflush(FILE *stream);
+int mycore_fseek(FILE* stream, long offset, int origin);
+long mycore_ftell(FILE* stream);
+int mycore_ferror(FILE *stream);
+
+void mycore_setbuf(FILE *stream, char *buffer);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyCORE_MYOSI_H */
+
diff --git a/source/mycore/mystring.c b/source/mycore/mystring.c
new file mode 100644
index 0000000..67cd36a
--- /dev/null
+++ b/source/mycore/mystring.c
@@ -0,0 +1,319 @@
+/*
+ Copyright (C) 2015-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 "mycore/mystring.h"
+#include "mycore/utils/resources.h"
+
+/////////////////////////////////////////////////////////
+//// Init, Clean, Destroy
+////
+/////////////////////////////////////////////////////////
+char * mycore_string_init(mchar_async_t *mchar, size_t node_idx, mycore_string_t* str, size_t size)
+{
+ str->data = mchar_async_malloc(mchar, node_idx, size);
+ str->size = size;
+ str->node_idx = node_idx;
+ str->mchar = mchar;
+
+ mycore_string_clean(str);
+
+ return str->data;
+}
+
+void mycore_string_clean(mycore_string_t* str)
+{
+ str->length = 0;
+}
+
+void mycore_string_clean_all(mycore_string_t* str)
+{
+ memset(str, 0, sizeof(mycore_string_t));
+}
+
+mycore_string_t * mycore_string_destroy(mycore_string_t* str, bool destroy_obj)
+{
+ if(str == NULL)
+ return NULL;
+
+ if(str->data && str->mchar)
+ mchar_async_free(str->mchar, str->node_idx, str->data);
+
+ if(destroy_obj && str) {
+ mycore_free(str);
+ return NULL;
+ }
+
+ return str;
+}
+
+void mycore_string_raw_clean(mycore_string_raw_t* str_raw)
+{
+ str_raw->length = 0;
+}
+
+void mycore_string_raw_clean_all(mycore_string_raw_t* str_raw)
+{
+ memset(str_raw, 0, sizeof(mycore_string_raw_t));
+}
+
+mycore_string_raw_t * mycore_string_raw_destroy(mycore_string_raw_t* str_raw, bool destroy_obj)
+{
+ if(str_raw == NULL)
+ return NULL;
+
+ if(str_raw->data) {
+ mycore_free(str_raw->data);
+ str_raw->data = NULL;
+ }
+
+ if(destroy_obj && str_raw) {
+ mycore_free(str_raw);
+ return NULL;
+ }
+
+ return str_raw;
+}
+
+char * mycore_string_realloc(mycore_string_t *str, size_t new_size)
+{
+ if(str == NULL)
+ return NULL;
+
+ char *tmp = mchar_async_realloc(str->mchar, str->node_idx, str->data, str->length, new_size);
+
+ if(tmp) {
+ str->size = new_size;
+ str->data = tmp;
+ }
+ else
+ return NULL;
+
+ return tmp;
+}
+
+/////////////////////////////////////////////////////////
+//// Basic API
+////
+/////////////////////////////////////////////////////////
+char * mycore_string_data_alloc(mchar_async_t *mchar, size_t node_id, size_t size)
+{
+ return mchar_async_malloc(mchar, node_id, size);
+}
+
+char * mycore_string_data_realloc(mchar_async_t *mchar, size_t node_id, char *data, size_t len_to_copy, size_t size)
+{
+ return mchar_async_realloc(mchar, node_id, data, len_to_copy, size);
+}
+
+void mycore_string_data_free(mchar_async_t *mchar, size_t node_id, char *data)
+{
+ mchar_async_free(mchar, node_id, data);
+}
+
+char * mycore_string_data(mycore_string_t *str)
+{
+ if(str == NULL)
+ return NULL;
+
+ return str->data;
+}
+
+size_t mycore_string_length(mycore_string_t *str)
+{
+ if(str == NULL)
+ return 0;
+
+ return str->length;
+}
+
+size_t mycore_string_size(mycore_string_t *str)
+{
+ if(str == NULL)
+ return 0;
+
+ return str->size;
+}
+
+char * mycore_string_data_set(mycore_string_t *str, char *data)
+{
+ if(str == NULL)
+ return NULL;
+
+ str->data = data;
+ return str->data;
+}
+
+size_t mycore_string_size_set(mycore_string_t *str, size_t size)
+{
+ if(str == NULL)
+ return 0;
+
+ str->size = size;
+ return str->size;
+}
+
+size_t mycore_string_length_set(mycore_string_t *str, size_t length)
+{
+ if(str == NULL)
+ return 0;
+
+ str->length = length;
+ return str->length;
+}
+
+/////////////////////////////////////////////////////////
+//// Append API
+////
+/////////////////////////////////////////////////////////
+void mycore_string_append(mycore_string_t* str, const char* buff, size_t length)
+{
+ MyCORE_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
+
+ memcpy(&str->data[str->length], buff, (sizeof(char) * length));
+
+ str->length += length;
+ str->data[str->length] = '\0';
+}
+
+void mycore_string_append_one(mycore_string_t* str, const char data)
+{
+ MyCORE_STRING_REALLOC_IF_NEED(str, 2, 1);
+ MyCORE_STRING_APPEND_BYTE_WITHOUT_REALLOC(data, str);
+ MyCORE_STRING_APPEND_BYTE_WITHOUT_INCREMENT_REALLOC('\0', str);
+}
+
+void mycore_string_append_lowercase(mycore_string_t* str, const char* data, size_t length)
+{
+ MyCORE_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
+
+ unsigned char *ref = (unsigned char*)&str->data[str->length];
+ const unsigned char *buf = (const unsigned char*)data;
+
+ size_t i;
+ for(i = 0; i < length; i++) {
+ ref[i] = mycore_string_chars_lowercase_map[ buf[i] ];
+ }
+
+ ref[i] = '\0';
+ str->length += length;
+}
+
+void mycore_string_copy(mycore_string_t* dest, mycore_string_t* target)
+{
+ mycore_string_append(dest, target->data, target->length);
+}
+
+size_t mycore_string_raw_copy(char* str1, const char* str2, size_t size)
+{
+ str1[size] = '\0';
+
+ while(size) {
+ size--;
+ str1[size] = str2[size];
+ }
+
+ return size;
+}
+
+size_t mycore_string_raw_set_replacement_character(mycore_string_t* target, size_t position)
+{
+ // Unicode Character 'REPLACEMENT CHARACTER' (U+FFFD)
+ target->data[(position)] = (char)0xEF;
+ target->data[(position + 1)] = (char)0xBF;
+ target->data[(position + 2)] = (char)0xBD;
+
+ return 3;
+}
+
+void mycore_string_append_with_replacement_null_characters(mycore_string_t* str, const char* buff, size_t length)
+{
+ MyCORE_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
+
+ unsigned char *data = (unsigned char*)str->data;
+ const unsigned char *u_buff = (const unsigned char*)buff;
+
+ for (size_t i = 0; i < length; i++)
+ {
+ if(u_buff[i] == 0x00) {
+ mycore_string_realloc(str, (str->size + 5));
+ data = (unsigned char*)str->data;
+
+ // Unicode Character 'REPLACEMENT CHARACTER' (U+FFFD)
+ data[str->length] = 0xEF; str->length++;
+ data[str->length] = 0xBF; str->length++;
+ data[str->length] = 0xBD;
+ }
+ else
+ data[str->length] = u_buff[i];
+
+ str->length++;
+ }
+
+ str->data[str->length] = '\0';
+}
+
+void mycore_string_stay_only_whitespace(mycore_string_t* target)
+{
+ char *data = target->data;
+ size_t pos = 0;
+
+ for(size_t i = 0; i < target->length; i++)
+ {
+ if(mycore_utils_whithspace(data[i], ==, ||)) {
+ data[pos] = data[i];
+ pos++;
+ }
+ }
+
+ target->length = pos;
+}
+
+size_t mycore_string_crop_whitespace_from_begin(mycore_string_t* target)
+{
+ char *data = target->data;
+ size_t i;
+
+ for(i = 0; i < target->length; i++) {
+ if(mycore_utils_whithspace(data[i], !=, &&))
+ break;
+ }
+
+ if(i)
+ target->data = mchar_async_crop_first_chars_without_cache(target->data, i);
+
+ target->length -= i;
+
+ return i;
+}
+
+size_t mycore_string_whitespace_from_begin(mycore_string_t* target)
+{
+ char *data = target->data;
+ size_t i;
+
+ for(i = 0; i < target->length; i++) {
+ if(mycore_utils_whithspace(data[i], !=, &&))
+ break;
+ }
+
+ return i;
+}
+
+
diff --git a/source/mycore/mystring.h b/source/mycore/mystring.h
new file mode 100644
index 0000000..30de718
--- /dev/null
+++ b/source/mycore/mystring.h
@@ -0,0 +1,125 @@
+/*
+ Copyright (C) 2015-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 MyCORE_MYSTRING_H
+#define MyCORE_MYSTRING_H
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "mycore/myosi.h"
+#include "mycore/utils/mchar_async.h"
+#include "mycore/utils.h"
+
+#define mycore_string_get(str, attr) str->attr
+#define mycore_string_set(str, attr) mycore_string_get(str, attr)
+#define mycore_string_len(str) mycore_string_get(str, length)
+
+#define MyCORE_STRING_PREPROCESSOR_CHECK_BUFFER_SIZE(str, unsigned_data) \
+ if(str->length >= str->size) { \
+ mycore_string_realloc(str, (str->length + 5)); \
+ \
+ unsigned_data = (unsigned char*)str->data; \
+ }
+
+#define MyCORE_STRING_REALLOC_IF_NEED(str, need_length, upto) \
+ if((str->length + need_length) >= str->size) { \
+ mycore_string_realloc(str, (str->length + need_length + upto)); \
+ } \
+
+#define MyCORE_STRING_APPEND_BYTE_WITHOUT_REALLOC(onechar, str) \
+ str->data[str->length] = onechar; \
+ str->length++
+
+#define MyCORE_STRING_APPEND_BYTE_WITHOUT_INCREMENT(onechar, str, upto) \
+ if(str->length >= str->size) { \
+ mycore_string_realloc(str, (str->length + upto)); \
+ } \
+ str->data[str->length] = onechar
+
+#define MyCORE_STRING_APPEND_BYTE_WITHOUT_INCREMENT_REALLOC(onechar, str) \
+ str->data[str->length] = onechar
+
+#define MyCORE_STRING_APPEND_BYTE(onechar, str, upto) \
+ MyCORE_STRING_APPEND_BYTE_WITHOUT_INCREMENT(onechar, str, upto); \
+ str->length++
+
+struct mycore_string {
+ char* data;
+ size_t size;
+ size_t length;
+
+ mchar_async_t *mchar;
+ size_t node_idx;
+};
+
+struct mycore_string_raw {
+ char* data;
+ size_t size;
+ size_t length;
+};
+
+typedef size_t mycore_string_index_t;
+
+char * mycore_string_init(mchar_async_t *mchar, size_t node_idx, mycore_string_t* str, size_t size);
+char * mycore_string_realloc(mycore_string_t *str, size_t new_size);
+
+void mycore_string_clean(mycore_string_t* str);
+void mycore_string_clean_all(mycore_string_t* str);
+mycore_string_t * mycore_string_destroy(mycore_string_t* str, bool destroy_obj);
+
+void mycore_string_raw_clean(mycore_string_raw_t* str_raw);
+void mycore_string_raw_clean_all(mycore_string_raw_t* str_raw);
+mycore_string_raw_t * mycore_string_raw_destroy(mycore_string_raw_t* str_raw, bool destroy_obj);
+
+/* basic api */
+char * mycore_string_data_alloc(mchar_async_t *mchar, size_t node_id, size_t size);
+char * mycore_string_data_realloc(mchar_async_t *mchar, size_t node_id, char *data, size_t len_to_copy, size_t size);
+void mycore_string_data_free(mchar_async_t *mchar, size_t node_id, char *data);
+
+char * mycore_string_data(mycore_string_t *str);
+size_t mycore_string_length(mycore_string_t *str);
+size_t mycore_string_size(mycore_string_t *str);
+char * mycore_string_data_set(mycore_string_t *str, char *data);
+size_t mycore_string_size_set(mycore_string_t *str, size_t size);
+size_t mycore_string_length_set(mycore_string_t *str, size_t length);
+
+/* append */
+void mycore_string_append(mycore_string_t* str, const char* data, size_t length);
+void mycore_string_append_one(mycore_string_t* str, const char data);
+void mycore_string_append_lowercase(mycore_string_t* str, const char* data, size_t length);
+void mycore_string_append_with_replacement_null_characters(mycore_string_t* str, const char* buff, size_t length);
+
+size_t mycore_string_raw_set_replacement_character(mycore_string_t* target, size_t position);
+
+/* other functions */
+void mycore_string_copy(mycore_string_t* dest, mycore_string_t* target);
+size_t mycore_string_raw_copy(char* str1, const char* str2, size_t size);
+void mycore_string_stay_only_whitespace(mycore_string_t* target);
+size_t mycore_string_crop_whitespace_from_begin(mycore_string_t* target);
+size_t mycore_string_whitespace_from_begin(mycore_string_t* target);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* mycore_mystring_h */
diff --git a/source/mycore/mythread.c b/source/mycore/mythread.c
new file mode 100644
index 0000000..822fc08
--- /dev/null
+++ b/source/mycore/mythread.c
@@ -0,0 +1,331 @@
+/*
+ Copyright (C) 2015-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 "mycore/mythread.h"
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+
+mythread_t * mythread_create(void)
+{
+ return mycore_calloc(1, sizeof(mythread_t));
+}
+
+mystatus_t mythread_init(mythread_t *mythread, mythread_type_t type, size_t threads_count, size_t id_increase)
+{
+ if(threads_count == 0)
+ return MyCORE_STATUS_ERROR;
+
+ mythread->entries_size = threads_count;
+ mythread->entries_length = 0;
+ mythread->id_increase = id_increase;
+ mythread->type = type;
+
+ mythread->entries = (mythread_entry_t*)mycore_calloc(mythread->entries_size, sizeof(mythread_entry_t));
+ if(mythread->entries == NULL)
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ mythread->attr = mythread_thread_attr_init(mythread);
+ if(mythread->attr == NULL)
+ return MyCORE_STATUS_THREAD_ERROR_ATTR_INIT;
+
+ mythread->timespec = mythread_nanosleep_create(mythread);
+
+ return MyCORE_STATUS_OK;
+}
+
+void mythread_clean(mythread_t *mythread)
+{
+ mythread_thread_attr_clean(mythread, mythread->attr);
+ mythread_nanosleep_clean(mythread->timespec);
+
+ mythread->sys_last_error = 0;
+}
+
+mythread_t * mythread_destroy(mythread_t *mythread, mythread_callback_before_entry_join_f before_join, void* ctx, bool self_destroy)
+{
+ if(mythread == NULL)
+ return NULL;
+
+ if(mythread->entries) {
+ mythread_resume(mythread, MyTHREAD_OPT_QUIT);
+ mythread_quit(mythread, before_join, ctx);
+ mycore_free(mythread->entries);
+ }
+
+ mythread_thread_attr_destroy(mythread, mythread->attr);
+ mythread_nanosleep_destroy(mythread->timespec);
+
+ if(self_destroy) {
+ mycore_free(mythread);
+ return NULL;
+ }
+
+ return mythread;
+}
+
+mystatus_t myhread_entry_create(mythread_t *mythread, mythread_process_f process_func, mythread_work_f work_func, mythread_thread_opt_t opt)
+{
+ mythread->sys_last_error = 0;
+
+ if(mythread->entries_length >= mythread->entries_size)
+ return MyCORE_STATUS_THREAD_ERROR_NO_SLOTS;
+
+ mythread_entry_t *entry = &mythread->entries[mythread->entries_length];
+
+ entry->context.mythread = mythread;
+ entry->context.func = work_func;
+ entry->context.id = mythread->entries_length;
+ entry->context.t_count = mythread->entries_size;
+ entry->context.opt = opt;
+ entry->context.status = 0;
+
+ entry->context.timespec = mythread_nanosleep_create(mythread);
+
+ entry->context.mutex = mythread_mutex_create(mythread);
+ if(entry->context.mutex == NULL)
+ return MyCORE_STATUS_THREAD_ERROR_MUTEX_INIT;
+
+ if(mythread_mutex_wait(mythread, entry->context.mutex)) {
+ mythread_mutex_close(mythread, entry->context.mutex);
+ return MyCORE_STATUS_THREAD_ERROR_MUTEX_LOCK;
+ }
+
+ entry->thread = mythread_thread_create(mythread, process_func, &entry->context);
+ if(entry->thread == NULL) {
+ mythread_mutex_close(mythread, entry->context.mutex);
+ return MyCORE_STATUS_ERROR;
+ }
+
+ mythread->entries_length++;
+
+ return MyCORE_STATUS_OK;
+}
+
+mythread_id_t myhread_increase_id_by_entry_id(mythread_t* mythread, mythread_id_t thread_id)
+{
+ return mythread->id_increase + thread_id;
+}
+
+/*
+ * Global functions, for all threads
+ */
+mystatus_t mythread_join(mythread_t *mythread, mythread_callback_before_entry_join_f before_join, void* ctx)
+{
+ for (size_t i = 0; i < mythread->entries_length; i++) {
+ if(before_join)
+ before_join(mythread, &mythread->entries[i], ctx);
+
+ if(mythread_thread_join(mythread, mythread->entries[i].thread))
+ return MyCORE_STATUS_ERROR;
+ }
+
+ return MyCORE_STATUS_OK;
+}
+
+mystatus_t mythread_quit(mythread_t *mythread, mythread_callback_before_entry_join_f before_join, void* ctx)
+{
+ mythread_option_set(mythread, MyTHREAD_OPT_QUIT);
+
+ for (size_t i = 0; i < mythread->entries_length; i++)
+ {
+ if(before_join)
+ before_join(mythread, &mythread->entries[i], ctx);
+
+ if(mythread_thread_join(mythread, mythread->entries[i].thread) ||
+ mythread_thread_destroy(mythread, mythread->entries[i].thread))
+ {
+ return MyCORE_STATUS_ERROR;
+ }
+ }
+
+ return MyCORE_STATUS_OK;
+}
+
+mystatus_t mythread_stop(mythread_t *mythread)
+{
+ if(mythread->opt & MyTHREAD_OPT_STOP)
+ return MyCORE_STATUS_OK;
+
+ mythread_option_set(mythread, MyTHREAD_OPT_STOP);
+
+ for (size_t i = 0; i < mythread->entries_length; i++)
+ {
+ while((mythread->entries[i].context.opt & MyTHREAD_OPT_STOP) == 0) {
+ mythread_nanosleep_sleep(mythread->timespec);
+ }
+ }
+
+ return MyCORE_STATUS_OK;
+}
+
+mystatus_t mythread_suspend(mythread_t *mythread)
+{
+ if(mythread->opt & MyTHREAD_OPT_WAIT)
+ return MyCORE_STATUS_OK;
+
+ mythread_option_set(mythread, MyTHREAD_OPT_WAIT);
+
+ for (size_t i = 0; i < mythread->entries_length; i++)
+ {
+ while((mythread->entries[i].context.opt & MyTHREAD_OPT_STOP) == 0 &&
+ (mythread->entries[i].context.opt & MyTHREAD_OPT_WAIT) == 0)
+ {
+ mythread_nanosleep_sleep(mythread->timespec);
+ }
+ }
+
+ return MyCORE_STATUS_OK;
+}
+
+mystatus_t mythread_resume(mythread_t *mythread, mythread_thread_opt_t send_opt)
+{
+ if(mythread->opt & MyTHREAD_OPT_WAIT) {
+ mythread_option_set(mythread, send_opt);
+ return MyCORE_STATUS_OK;
+ }
+
+ mythread_option_set(mythread, send_opt);
+
+ for (size_t i = 0; i < mythread->entries_length; i++)
+ {
+ if(mythread->entries[i].context.opt & MyTHREAD_OPT_STOP) {
+ mythread->entries[i].context.opt = send_opt;
+
+ if(mythread_mutex_post(mythread, mythread->entries[i].context.mutex))
+ return MyCORE_STATUS_ERROR;
+ }
+ }
+
+ return MyCORE_STATUS_OK;
+}
+
+mystatus_t mythread_check_status(mythread_t *mythread)
+{
+ for (size_t i = 0; i < mythread->entries_length; i++)
+ {
+ if(mythread->entries[i].context.status)
+ return mythread->entries[i].context.status;
+ }
+
+ return MyCORE_STATUS_OK;
+}
+
+mythread_thread_opt_t mythread_option(mythread_t *mythread)
+{
+ return mythread->opt;
+}
+
+void mythread_option_set(mythread_t *mythread, mythread_thread_opt_t opt)
+{
+ mythread->opt = opt;
+}
+
+/*
+ * Entries functions, for all threads
+ */
+mystatus_t mythread_entry_join(mythread_entry_t* entry, mythread_callback_before_entry_join_f before_join, void* ctx)
+{
+ if(before_join)
+ before_join(entry->context.mythread, entry, ctx);
+
+ if(mythread_thread_join(entry->context.mythread, entry->thread))
+ return MyCORE_STATUS_ERROR;
+
+ return MyCORE_STATUS_OK;
+}
+
+mystatus_t mythread_entry_quit(mythread_entry_t* entry, mythread_callback_before_entry_join_f before_join, void* ctx)
+{
+ if(before_join)
+ before_join(entry->context.mythread, entry, ctx);
+
+ if(mythread_thread_join(entry->context.mythread, entry->thread) ||
+ mythread_thread_destroy(entry->context.mythread, entry->thread))
+ {
+ return MyCORE_STATUS_ERROR;
+ }
+
+ return MyCORE_STATUS_OK;
+}
+
+mystatus_t mythread_entry_stop(mythread_entry_t* entry)
+{
+ if(entry->context.opt & MyTHREAD_OPT_STOP)
+ return MyCORE_STATUS_OK;
+
+ entry->context.opt = MyTHREAD_OPT_STOP;
+
+ while((entry->context.opt & MyTHREAD_OPT_STOP) == 0) {
+ mythread_nanosleep_sleep(entry->context.mythread->timespec);
+ }
+
+ return MyCORE_STATUS_OK;
+}
+
+mystatus_t mythread_entry_suspend(mythread_entry_t* entry)
+{
+ if(entry->context.opt & MyTHREAD_OPT_WAIT)
+ return MyCORE_STATUS_OK;
+
+ entry->context.opt = MyTHREAD_OPT_WAIT;
+
+ while((entry->context.opt & MyTHREAD_OPT_STOP) == 0 && (entry->context.opt & MyTHREAD_OPT_WAIT) == 0) {
+ mythread_nanosleep_sleep(entry->context.mythread->timespec);
+ }
+
+ return MyCORE_STATUS_OK;
+}
+
+mystatus_t mythread_entry_resume(mythread_entry_t* entry, mythread_thread_opt_t send_opt)
+{
+ if(entry->context.opt & MyTHREAD_OPT_WAIT) {
+ entry->context.opt = send_opt;
+ }
+ else if(entry->context.opt & MyTHREAD_OPT_STOP) {
+ entry->context.opt = send_opt;
+
+ if(mythread_mutex_post(entry->context.mythread, entry->context.mutex))
+ return MyCORE_STATUS_ERROR;
+ }
+ else
+ entry->context.opt = send_opt;
+
+ return MyCORE_STATUS_OK;
+}
+
+mystatus_t mythread_entry_status(mythread_entry_t* entry)
+{
+ return entry->context.status;
+}
+
+mythread_t * mythread_entry_mythread(mythread_entry_t* entry)
+{
+ return entry->context.mythread;
+}
+
+/* Callbacks */
+void mythread_callback_quit(mythread_t* mythread, mythread_entry_t* entry, void* ctx)
+{
+ while((entry->context.opt & MyTHREAD_OPT_QUIT) == 0)
+ mythread_nanosleep_sleep(mythread->timespec);
+}
+
+#endif
+
diff --git a/source/mycore/mythread.h b/source/mycore/mythread.h
new file mode 100644
index 0000000..5142c25
--- /dev/null
+++ b/source/mycore/mythread.h
@@ -0,0 +1,159 @@
+/*
+ Copyright (C) 2015-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 MyCORE_THREAD_H
+#define MyCORE_THREAD_H
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "mycore/myosi.h"
+#include "mycore/mystring.h"
+
+#ifdef MyCORE_BUILD_WITHOUT_THREADS
+
+struct mythread {
+ int sys_last_error;
+};
+
+#else
+/* functions */
+typedef void (*mythread_callback_before_entry_join_f)(mythread_t* mythread, mythread_entry_t* entry, void* ctx);
+typedef void * (*mythread_process_f)(void* arg);
+typedef void (*mythread_work_f)(mythread_id_t thread_id, void* arg);
+
+void * mythread_function_queue_stream(void *arg);
+void * mythread_function_queue_batch(void *arg);
+void * mythread_function(void *arg);
+
+enum mythread_thread_opt {
+ MyTHREAD_OPT_UNDEF = 0x00,
+ MyTHREAD_OPT_WAIT = 0x01,
+ MyTHREAD_OPT_QUIT = 0x02,
+ MyTHREAD_OPT_STOP = 0x04,
+ MyTHREAD_OPT_DONE = 0x08
+}
+typedef mythread_thread_opt_t;
+
+enum mythread_type {
+ MyTHREAD_TYPE_STREAM = 0x00,
+ MyTHREAD_TYPE_BATCH = 0x01
+}
+typedef mythread_type_t;
+
+// thread
+struct mythread_context {
+ mythread_id_t id;
+ mythread_work_f func;
+
+ volatile size_t t_count;
+ volatile mythread_thread_opt_t opt;
+
+ mystatus_t status;
+
+ void* mutex;
+ void* timespec;
+ mythread_t* mythread;
+};
+
+struct mythread_entry {
+ void* thread;
+
+ mythread_context_t context;
+ mythread_process_f process_func;
+};
+
+struct mythread {
+ mythread_entry_t *entries;
+ size_t entries_length;
+ size_t entries_size;
+ size_t id_increase;
+
+ void* context;
+ void* attr;
+ void* timespec;
+
+ int sys_last_error;
+
+ mythread_type_t type;
+ volatile mythread_thread_opt_t opt;
+};
+
+mythread_t * mythread_create(void);
+mystatus_t mythread_init(mythread_t *mythread, mythread_type_t type, size_t threads_count, size_t id_increase);
+void mythread_clean(mythread_t *mythread);
+mythread_t * mythread_destroy(mythread_t *mythread, mythread_callback_before_entry_join_f before_join, void* ctx, bool self_destroy);
+
+mythread_id_t myhread_increase_id_by_entry_id(mythread_t* mythread, mythread_id_t thread_id);
+
+/* set for all threads */
+mystatus_t mythread_join(mythread_t *mythread, mythread_callback_before_entry_join_f before_join, void* ctx);
+mystatus_t mythread_quit(mythread_t *mythread, mythread_callback_before_entry_join_f before_join, void* ctx);
+mystatus_t mythread_stop(mythread_t *mythread);
+mystatus_t mythread_resume(mythread_t *mythread, mythread_thread_opt_t send_opt);
+mystatus_t mythread_suspend(mythread_t *mythread);
+mystatus_t mythread_check_status(mythread_t *mythread);
+
+mythread_thread_opt_t mythread_option(mythread_t *mythread);
+void mythread_option_set(mythread_t *mythread, mythread_thread_opt_t opt);
+
+/* Entries */
+mystatus_t myhread_entry_create(mythread_t *mythread, mythread_process_f process_func, mythread_work_f func, mythread_thread_opt_t opt);
+
+mystatus_t mythread_entry_join(mythread_entry_t* entry, mythread_callback_before_entry_join_f before_join, void* ctx);
+mystatus_t mythread_entry_quit(mythread_entry_t* entry, mythread_callback_before_entry_join_f before_join, void* ctx);
+mystatus_t mythread_entry_stop(mythread_entry_t* entry);
+mystatus_t mythread_entry_resume(mythread_entry_t* entry, mythread_thread_opt_t send_opt);
+mystatus_t mythread_entry_suspend(mythread_entry_t* entry);
+mystatus_t mythread_entry_status(mythread_entry_t* entry);
+mythread_t * mythread_entry_mythread(mythread_entry_t* entry);
+
+/* API for ports */
+void * mythread_thread_create(mythread_t *mythread, mythread_process_f process_func, void* ctx);
+mystatus_t mythread_thread_join(mythread_t *mythread, void* thread);
+mystatus_t mythread_thread_cancel(mythread_t *mythread, void* thread);
+mystatus_t mythread_thread_destroy(mythread_t *mythread, void* thread);
+
+void * mythread_thread_attr_init(mythread_t *mythread);
+void mythread_thread_attr_clean(mythread_t *mythread, void* attr);
+void mythread_thread_attr_destroy(mythread_t *mythread, void* attr);
+
+void * mythread_mutex_create(mythread_t *mythread);
+mystatus_t mythread_mutex_post(mythread_t *mythread, void* mutex);
+mystatus_t mythread_mutex_wait(mythread_t *mythread, void* mutex);
+void mythread_mutex_close(mythread_t *mythread, void* mutex);
+
+void * mythread_nanosleep_create(mythread_t* mythread);
+void mythread_nanosleep_clean(void* timespec);
+void mythread_nanosleep_destroy(void* timespec);
+mystatus_t mythread_nanosleep_sleep(void* timespec);
+
+/* callback */
+void mythread_callback_quit(mythread_t* mythread, mythread_entry_t* entry, void* ctx);
+
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyCORE_THREAD_H */
diff --git a/source/mycore/perf.h b/source/mycore/perf.h
new file mode 100644
index 0000000..0e878a1
--- /dev/null
+++ b/source/mycore/perf.h
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2015-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 MyCORE_PERF_H
+#define MyCORE_PERF_H
+#pragma once
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "mycore/myosi.h"
+
+#ifdef MyCORE_WITH_PERF
+void * mycore_perf_create(void);
+void mycore_perf_clean(void* perf);
+void mycore_perf_destroy(void* perf);
+
+mycore_status_t myhtml_perf_begin(void* perf);
+mycore_status_t myhtml_perf_end(void* perf);
+double myhtml_perf_in_sec(void* perf);
+
+unsigned long long mycore_perf_clock(void);
+unsigned long long mycore_perf_frequency(void);
+#endif /* MyCORE_WITH_PERF */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyCORE_PERF_H */
diff --git a/source/mycore/thread_queue.c b/source/mycore/thread_queue.c
new file mode 100644
index 0000000..4532c6b
--- /dev/null
+++ b/source/mycore/thread_queue.c
@@ -0,0 +1,654 @@
+/*
+ Copyright (C) 2015-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 "mycore/thread_queue.h"
+
+mythread_queue_t * mythread_queue_create(void)
+{
+ return mycore_calloc(1, sizeof(mythread_queue_t));
+}
+
+mystatus_t mythread_queue_init(mythread_queue_t* queue, size_t size)
+{
+ if(size < 32)
+ size = 32;
+
+ queue->nodes_pos_size = 512;
+ queue->nodes_size = size;
+ queue->nodes = (mythread_queue_node_t**)mycore_calloc(queue->nodes_pos_size, sizeof(mythread_queue_node_t*));
+
+ if(queue->nodes == NULL)
+ return MyCORE_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC;
+
+ queue->nodes[queue->nodes_pos] = (mythread_queue_node_t*)mycore_malloc(sizeof(mythread_queue_node_t) * queue->nodes_size);
+
+ if(queue->nodes[queue->nodes_pos] == NULL) {
+ queue->nodes = mycore_free(queue->nodes);
+ return MyCORE_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC;
+ }
+
+ return MyCORE_STATUS_OK;
+}
+
+void mythread_queue_clean(mythread_queue_t* queue)
+{
+ queue->nodes_length = 0;
+ queue->nodes_pos = 0;
+ queue->nodes_root = 0;
+ queue->nodes_uses = 0;
+}
+
+mythread_queue_t * mythread_queue_destroy(mythread_queue_t* queue)
+{
+ if(queue == NULL)
+ return NULL;
+
+ if(queue->nodes) {
+ /* '<=' it is normal */
+ for (size_t i = 0; i <= queue->nodes_pos; i++) {
+ mycore_free(queue->nodes[i]);
+ }
+
+ mycore_free(queue->nodes);
+ }
+
+ mycore_free(queue);
+
+ return NULL;
+}
+
+void mythread_queue_node_clean(mythread_queue_node_t* qnode)
+{
+ memset(qnode, 0, sizeof(mythread_queue_node_t));
+}
+
+mythread_queue_node_t * mythread_queue_get_prev_node(mythread_queue_node_t* qnode)
+{
+ return qnode->prev;
+}
+
+mythread_queue_node_t * mythread_queue_get_current_node(mythread_queue_t* queue)
+{
+ return &queue->nodes[queue->nodes_pos][queue->nodes_length];
+}
+
+mythread_queue_node_t * mythread_queue_get_first_node(mythread_queue_t* queue)
+{
+ return &queue->nodes[0][0];
+}
+
+size_t mythread_queue_count_used_node(mythread_queue_t* queue)
+{
+ return queue->nodes_uses;
+}
+
+mythread_queue_node_t * mythread_queue_node_malloc(mythread_t *mythread, mythread_queue_t* queue, mystatus_t *status)
+{
+ queue->nodes_length++;
+
+ if(queue->nodes_length >= queue->nodes_size)
+ {
+ queue->nodes_pos++;
+
+ if(queue->nodes_pos >= queue->nodes_pos_size)
+ {
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ if(mythread)
+ mythread_queue_list_wait_for_done(mythread, mythread->context);
+#endif
+ size_t new_size = queue->nodes_pos_size + 512;
+ mythread_queue_node_t** tmp = mycore_realloc(queue->nodes, sizeof(mythread_queue_node_t*) * new_size);
+
+ if(tmp) {
+ memset(&tmp[queue->nodes_pos], 0, sizeof(mythread_queue_node_t*) * (new_size - queue->nodes_pos));
+
+ queue->nodes = tmp;
+ queue->nodes_pos_size = new_size;
+ }
+ else {
+ if(status)
+ *status = MyCORE_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC;
+
+ return NULL;
+ }
+ }
+
+ if(queue->nodes[queue->nodes_pos] == NULL) {
+ queue->nodes[queue->nodes_pos] = (mythread_queue_node_t*)mycore_malloc(sizeof(mythread_queue_node_t) * queue->nodes_size);
+
+ if(queue->nodes[queue->nodes_pos] == NULL) {
+ if(status)
+ *status = MyCORE_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC;
+
+ return NULL;
+ }
+ }
+
+ queue->nodes_length = 0;
+ }
+
+ queue->nodes_uses++;
+
+ return &queue->nodes[queue->nodes_pos][queue->nodes_length];
+}
+
+mythread_queue_node_t * mythread_queue_node_malloc_limit(mythread_t *mythread, mythread_queue_t* queue, size_t limit, mystatus_t *status)
+{
+ queue->nodes_length++;
+
+ if(queue->nodes_uses >= limit) {
+ queue->nodes_uses++;
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ if(mythread)
+ mythread_queue_list_wait_for_done(mythread, mythread->context);
+#endif
+ queue->nodes_length = 0;
+ queue->nodes_pos = 0;
+ queue->nodes_root = 0;
+ queue->nodes_uses = 0;
+ }
+ else if(queue->nodes_length >= queue->nodes_size)
+ {
+ queue->nodes_pos++;
+
+ if(queue->nodes_pos >= queue->nodes_pos_size)
+ {
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ if(mythread)
+ mythread_queue_list_wait_for_done(mythread, mythread->context);
+#endif
+ size_t new_size = queue->nodes_pos_size + 512;
+ mythread_queue_node_t** tmp = mycore_realloc(queue->nodes, sizeof(mythread_queue_node_t*) * new_size);
+
+ if(tmp) {
+ memset(&tmp[queue->nodes_pos], 0, sizeof(mythread_queue_node_t*) * (new_size - queue->nodes_pos));
+
+ queue->nodes = tmp;
+ queue->nodes_pos_size = new_size;
+ }
+ else {
+ if(status)
+ *status = MyCORE_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC;
+
+ return NULL;
+ }
+ }
+
+ if(queue->nodes[queue->nodes_pos] == NULL) {
+ queue->nodes[queue->nodes_pos] = (mythread_queue_node_t*)mycore_malloc(sizeof(mythread_queue_node_t) * queue->nodes_size);
+
+ if(queue->nodes[queue->nodes_pos] == NULL) {
+ if(status)
+ *status = MyCORE_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC;
+
+ return NULL;
+ }
+ }
+
+ queue->nodes_length = 0;
+ }
+
+ queue->nodes_uses++;
+
+ return &queue->nodes[queue->nodes_pos][queue->nodes_length];
+}
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+mythread_queue_node_t * mythread_queue_node_malloc_round(mythread_t *mythread, mythread_queue_list_entry_t *entry, mystatus_t *status)
+{
+ mythread_queue_t* queue = entry->queue;
+
+ queue->nodes_length++;
+
+ if(queue->nodes_length >= queue->nodes_size) {
+ queue->nodes_uses++;
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ if(mythread)
+ mythread_queue_list_entry_wait_for_done(mythread, entry);
+#endif
+
+ mythread_queue_list_entry_clean(entry);
+ }
+ else
+ queue->nodes_uses++;
+
+ return &queue->nodes[queue->nodes_pos][queue->nodes_length];
+}
+#endif
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+/*
+ * Queue List
+ */
+mythread_queue_list_t * mythread_queue_list_create(mystatus_t *status)
+{
+ return (mythread_queue_list_t*)mycore_calloc(1, sizeof(mythread_queue_list_t));
+}
+
+void mythread_queue_list_destroy(mythread_queue_list_t* queue_list)
+{
+ if(queue_list == NULL)
+ return;
+
+ mycore_free(queue_list);
+}
+
+size_t mythread_queue_list_get_count(mythread_queue_list_t* queue_list)
+{
+ return queue_list->count;
+}
+
+void mythread_queue_list_wait_for_done(mythread_t* mythread, mythread_queue_list_t* queue_list)
+{
+ if(queue_list == NULL)
+ return;
+
+ mythread_queue_list_entry_t *entry = queue_list->first;
+
+ while(entry)
+ {
+ for (size_t i = 0; i < mythread->entries_length; i++) {
+ while(entry->thread_param[i].use < entry->queue->nodes_uses)
+ mythread_nanosleep_sleep(mythread->timespec);
+ }
+
+ entry = entry->next;
+ }
+}
+
+bool mythread_queue_list_see_for_done(mythread_t* mythread, mythread_queue_list_t* queue_list)
+{
+ if(queue_list == NULL)
+ return true;
+
+ mythread_queue_list_entry_t *entry = queue_list->first;
+
+ while(entry)
+ {
+ for (size_t i = 0; i < mythread->entries_length; i++) {
+ if(entry->thread_param[i].use < entry->queue->nodes_uses)
+ return false;
+ }
+
+ entry = entry->next;
+ }
+
+ return true;
+}
+
+bool mythread_queue_list_see_for_done_by_thread(mythread_t* mythread, mythread_queue_list_t* queue_list, mythread_id_t thread_id)
+{
+ if(queue_list == NULL)
+ return true;
+
+ mythread_queue_list_entry_t *entry = queue_list->first;
+
+ while(entry)
+ {
+ if(entry->thread_param[thread_id].use < entry->queue->nodes_uses)
+ return false;
+
+ entry = entry->next;
+ }
+
+ return true;
+}
+
+/*
+ * Queue List Entry
+ */
+mythread_queue_list_entry_t * mythread_queue_list_entry_push(mythread_t** mythread_list, size_t list_size, mythread_queue_list_t* queue_list,
+ mythread_queue_t* queue, size_t thread_param_size, mystatus_t* status)
+{
+ if(status)
+ *status = MyCORE_STATUS_OK;
+
+ /* create new entry */
+ mythread_queue_list_entry_t* entry = (mythread_queue_list_entry_t*)mycore_calloc(1, sizeof(mythread_queue_list_entry_t));
+ if(entry == NULL) {
+ if(status)
+ *status = MyCORE_STATUS_THREAD_ERROR_QUEUE_MALLOC;
+
+ return NULL;
+ }
+
+ /* create thread params */
+ entry->thread_param_size = thread_param_size;
+
+ if(thread_param_size) {
+ entry->thread_param = (mythread_queue_thread_param_t*)mycore_calloc(thread_param_size, sizeof(mythread_queue_thread_param_t));
+
+ if(entry->thread_param == NULL) {
+ mycore_free(entry);
+
+ if(status)
+ *status = MyCORE_STATUS_THREAD_ERROR_QUEUE_MALLOC;
+
+ return NULL;
+ }
+ }
+ else
+ entry->thread_param = NULL;
+
+ entry->queue = queue;
+
+ for(size_t i = 0; i < list_size; i++) {
+ if(mythread_list[i]->type == MyTHREAD_TYPE_BATCH) {
+ mythread_queue_list_entry_make_batch(mythread_list[i], entry, mythread_list[i]->id_increase, mythread_list[i]->entries_length);
+ }
+
+ if(mythread_list[i])
+ mythread_suspend(mythread_list[i]);
+ }
+
+ if(queue_list->first) {
+ queue_list->last->next = entry;
+ entry->prev = queue_list->last;
+
+ queue_list->last = entry;
+ }
+ else {
+ queue_list->first = entry;
+ queue_list->last = entry;
+ }
+
+ queue_list->count++;
+
+ for(size_t i = 0; i < list_size; i++)
+ if(mythread_list[i])
+ mythread_resume(mythread_list[i], MyTHREAD_OPT_UNDEF);
+
+ return entry;
+}
+
+mythread_queue_list_entry_t * mythread_queue_list_entry_delete(mythread_t** mythread_list, size_t list_size, mythread_queue_list_t *queue_list, mythread_queue_list_entry_t *entry, bool destroy_queue)
+{
+ for(size_t i = 0; i < list_size; i++)
+ if(mythread_list[i])
+ mythread_suspend(mythread_list[i]);
+
+ mythread_queue_list_entry_t *next = entry->next;
+ mythread_queue_list_entry_t *prev = entry->prev;
+
+ if(prev)
+ prev->next = next;
+
+ if(next)
+ next->prev = prev;
+
+ if(queue_list->first == entry)
+ queue_list->first = next;
+
+ if(queue_list->last == entry)
+ queue_list->last = prev;
+
+ queue_list->count--;
+
+ for(size_t i = 0; i < list_size; i++)
+ if(mythread_list[i])
+ mythread_resume(mythread_list[i], MyTHREAD_OPT_UNDEF);
+
+ if(destroy_queue && entry->queue)
+ mythread_queue_destroy(entry->queue);
+
+ if(entry->thread_param)
+ mycore_free(entry->thread_param);
+
+ mycore_free(entry);
+
+ return NULL;
+}
+
+void mythread_queue_list_entry_clean(mythread_queue_list_entry_t *entry)
+{
+ if(entry == NULL)
+ return;
+
+ mythread_queue_clean(entry->queue);
+
+ for (size_t i = 0; i < entry->thread_param_size; i++) {
+ memset(&entry->thread_param[i], 0, sizeof(mythread_queue_thread_param_t));
+ }
+}
+
+void mythread_queue_list_entry_wait_for_done(mythread_t* mythread, mythread_queue_list_entry_t *entry)
+{
+ if(entry == NULL)
+ return;
+
+ for(size_t i = 0; i < entry->thread_param_size; i++) {
+ while(entry->thread_param[i].use < entry->queue->nodes_uses)
+ mythread_nanosleep_sleep(mythread->timespec);
+ }
+}
+
+bool mythread_queue_list_entry_see_for_done(mythread_queue_list_entry_t *entry)
+{
+ if(entry == NULL)
+ return true;
+
+ for(size_t i = 0; i < entry->thread_param_size; i++) {
+ if(entry->thread_param[i].use < entry->queue->nodes_uses)
+ return false;
+ }
+
+ return true;
+}
+
+void mythread_queue_list_entry_make_batch(mythread_t* mythread, mythread_queue_list_entry_t* entry, size_t from, size_t count)
+{
+ size_t i = 0;
+ while(from <= count) {
+ entry->thread_param[from].use = i;
+ i++; from++;
+ }
+}
+
+/*
+ * Thread Process Functions
+ */
+bool mythread_function_see_opt(mythread_context_t *ctx, volatile mythread_thread_opt_t opt, mythread_id_t thread_id, size_t done_count, void* timeout)
+{
+ mythread_t *mythread = ctx->mythread;
+ mythread_queue_list_t *queue_list = (mythread_queue_list_t*)mythread->context;
+
+ if(done_count != queue_list->count)
+ return false;
+
+ if(opt & MyTHREAD_OPT_STOP)
+ {
+ if(mythread_queue_list_see_for_done_by_thread(mythread, queue_list, thread_id))
+ {
+ ctx->opt = MyTHREAD_OPT_STOP;
+ mythread_mutex_wait(mythread, ctx->mutex);
+ ctx->opt = MyTHREAD_OPT_UNDEF;
+
+ return false;
+ }
+ }
+ else if(opt & MyTHREAD_OPT_QUIT)
+ {
+ if(mythread_queue_list_see_for_done_by_thread(mythread, queue_list, thread_id))
+ {
+ mythread_mutex_close(mythread, ctx->mutex);
+ mythread_nanosleep_destroy(ctx->timespec);
+
+ ctx->opt = MyTHREAD_OPT_QUIT;
+ return true;
+ }
+ }
+
+ mythread_nanosleep_sleep(timeout);
+
+ return false;
+}
+
+void * mythread_function_queue_batch(void *arg)
+{
+ mythread_context_t *ctx = (mythread_context_t*)arg;
+ mythread_t *mythread = ctx->mythread;
+ mythread_queue_list_t *queue_list = (mythread_queue_list_t*)mythread->context;
+ mythread_id_t thread_id = myhread_increase_id_by_entry_id(mythread, ctx->id);
+
+ mythread_mutex_wait(mythread, ctx->mutex);
+
+ do {
+ if(mythread->opt & MyTHREAD_OPT_WAIT) {
+ ctx->opt = MyTHREAD_OPT_WAIT;
+
+ while (mythread->opt & MyTHREAD_OPT_WAIT)
+ mythread_nanosleep_sleep(ctx->timespec);
+
+ ctx->opt = MyTHREAD_OPT_UNDEF;
+ }
+
+ mythread_queue_list_entry_t *entry = queue_list->first;
+ size_t done_count = 0;
+
+ while(entry)
+ {
+ mythread_queue_thread_param_t *thread_param = &entry->thread_param[ thread_id ];
+
+ if(thread_param->use < entry->queue->nodes_uses)
+ {
+ size_t pos = thread_param->use / entry->queue->nodes_size;
+ size_t len = thread_param->use % entry->queue->nodes_size;
+
+ mythread_queue_node_t *qnode = &entry->queue->nodes[pos][len];
+
+ //if((qnode->tree->flags & MyCORE_TREE_FLAGS_SINGLE_MODE) == 0)
+ ctx->func(ctx->id, (void*)qnode);
+
+ thread_param->use += mythread->entries_length;
+ }
+ else
+ done_count++;
+
+ entry = entry->next;
+ }
+
+ if(done_count == queue_list->count &&
+ mythread_function_see_opt(ctx, mythread->opt, thread_id, done_count, ctx->timespec))
+ {
+ break;
+ }
+ }
+ while (1);
+
+ return NULL;
+}
+
+void * mythread_function_queue_stream(void *arg)
+{
+ mythread_context_t *ctx = (mythread_context_t*)arg;
+ mythread_t * mythread = ctx->mythread;
+ mythread_queue_list_t *queue_list = (mythread_queue_list_t*)mythread->context;
+ mythread_id_t thread_id = myhread_increase_id_by_entry_id(mythread, ctx->id);
+
+ mythread_mutex_wait(mythread, ctx->mutex);
+
+ do {
+ if(mythread->opt & MyTHREAD_OPT_WAIT) {
+ ctx->opt = MyTHREAD_OPT_WAIT;
+
+ while (mythread->opt & MyTHREAD_OPT_WAIT) {
+ mythread_nanosleep_sleep(ctx->timespec);
+ }
+
+ ctx->opt = MyTHREAD_OPT_UNDEF;
+ }
+
+ mythread_queue_list_entry_t *entry = queue_list->first;
+ size_t done_count = 0;
+
+ while(entry)
+ {
+ mythread_queue_thread_param_t *thread_param = &entry->thread_param[ thread_id ];
+
+ if(thread_param->use < entry->queue->nodes_uses)
+ {
+ size_t pos = thread_param->use / entry->queue->nodes_size;
+ size_t len = thread_param->use % entry->queue->nodes_size;
+
+ mythread_queue_node_t *qnode = &entry->queue->nodes[pos][len];
+
+ //if((qnode->tree->flags & MyCORE_TREE_FLAGS_SINGLE_MODE) == 0)
+ ctx->func(ctx->id, (void*)qnode);
+
+ thread_param->use++;
+ }
+ else
+ done_count++;
+
+ entry = entry->next;
+ }
+
+ if(done_count == queue_list->count &&
+ mythread_function_see_opt(ctx, mythread->opt, thread_id, done_count, ctx->timespec))
+ {
+ break;
+ }
+ }
+ while(1);
+
+ return NULL;
+}
+
+void * mythread_function(void *arg)
+{
+ mythread_context_t *ctx = (mythread_context_t*)arg;
+ mythread_t * mythread = ctx->mythread;
+
+ mythread_mutex_wait(mythread, ctx->mutex);
+
+ do {
+ ctx->func(ctx->id, ctx);
+
+ ctx->opt |= MyTHREAD_OPT_DONE;
+
+ if(ctx->opt & MyTHREAD_OPT_WAIT) {
+ while (ctx->opt & MyTHREAD_OPT_WAIT) {
+ mythread_nanosleep_sleep(ctx->timespec);
+ }
+ }
+ else {
+ ctx->opt |= MyTHREAD_OPT_STOP;
+ mythread_mutex_wait(mythread, ctx->mutex);
+ }
+
+ if(mythread->opt & MyTHREAD_OPT_QUIT || ctx->opt & MyTHREAD_OPT_QUIT)
+ {
+ mythread_mutex_close(mythread, ctx->mutex);
+ mythread_nanosleep_destroy(ctx->timespec);
+
+ ctx->opt = MyTHREAD_OPT_QUIT;
+ break;
+ }
+
+ ctx->opt = MyTHREAD_OPT_UNDEF;
+ }
+ while(1);
+
+ return NULL;
+}
+
+#endif
diff --git a/source/mycore/thread_queue.h b/source/mycore/thread_queue.h
new file mode 100644
index 0000000..789b708
--- /dev/null
+++ b/source/mycore/thread_queue.h
@@ -0,0 +1,110 @@
+/*
+ Copyright (C) 2015-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 MyCORE_THREAD_QUEUE_H
+#define MyCORE_THREAD_QUEUE_H
+#pragma once
+
+#include "mycore/myosi.h"
+#include "mycore/mythread.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// queue
+struct mythread_queue_node {
+ void* context;
+ void* args;
+
+ mythread_queue_node_t* prev;
+};
+
+struct mythread_queue_thread_param {
+ volatile size_t use;
+};
+
+struct mythread_queue_list_entry {
+ mythread_queue_t* queue;
+ mythread_queue_thread_param_t* thread_param;
+ size_t thread_param_size;
+
+ mythread_queue_list_entry_t* next;
+ mythread_queue_list_entry_t* prev;
+};
+
+struct mythread_queue_list {
+ mythread_queue_list_entry_t *first;
+ mythread_queue_list_entry_t *last;
+
+ volatile size_t count;
+};
+
+struct mythread_queue {
+ mythread_queue_node_t **nodes;
+
+ size_t nodes_pos;
+ size_t nodes_pos_size;
+ size_t nodes_length;
+
+ volatile size_t nodes_uses;
+ volatile size_t nodes_size;
+ volatile size_t nodes_root;
+};
+
+mythread_queue_t * mythread_queue_create(void);
+mystatus_t mythread_queue_init(mythread_queue_t* queue, size_t size);
+void mythread_queue_clean(mythread_queue_t* queue);
+mythread_queue_t * mythread_queue_destroy(mythread_queue_t* token);
+
+void mythread_queue_node_clean(mythread_queue_node_t* qnode);
+size_t mythread_queue_count_used_node(mythread_queue_t* queue);
+
+mythread_queue_node_t * mythread_queue_get_first_node(mythread_queue_t* queue);
+mythread_queue_node_t * mythread_queue_get_prev_node(mythread_queue_node_t* qnode);
+mythread_queue_node_t * mythread_queue_get_current_node(mythread_queue_t* queue);
+
+mythread_queue_node_t * mythread_queue_node_malloc(mythread_t *mythread, mythread_queue_t* queue, mystatus_t *status);
+mythread_queue_node_t * mythread_queue_node_malloc_limit(mythread_t *mythread, mythread_queue_t* queue, size_t limit, mystatus_t *status);
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+mythread_queue_node_t * mythread_queue_node_malloc_round(mythread_t *mythread, mythread_queue_list_entry_t *entry, mystatus_t *status);
+#endif
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+mythread_queue_list_t * mythread_queue_list_create(mystatus_t *status);
+void mythread_queue_list_destroy(mythread_queue_list_t* queue_list);
+size_t mythread_queue_list_get_count(mythread_queue_list_t* queue_list);
+
+void mythread_queue_list_wait_for_done(mythread_t* mythread, mythread_queue_list_t* queue_list);
+bool mythread_queue_list_see_for_done(mythread_t* mythread, mythread_queue_list_t* queue_list);
+bool mythread_queue_list_see_for_done_by_thread(mythread_t* mythread, mythread_queue_list_t* queue_list, mythread_id_t thread_id);
+
+mythread_queue_list_entry_t * mythread_queue_list_entry_push(mythread_t** mythread_list, size_t list_size, mythread_queue_list_t* queue_list, mythread_queue_t* queue, size_t thread_param_size, mystatus_t* status);
+mythread_queue_list_entry_t * mythread_queue_list_entry_delete(mythread_t** mythread_list, size_t list_size, mythread_queue_list_t *queue_list, mythread_queue_list_entry_t *entry, bool destroy_queue);
+void mythread_queue_list_entry_clean(mythread_queue_list_entry_t *entry);
+void mythread_queue_list_entry_wait_for_done(mythread_t *mythread, mythread_queue_list_entry_t *entry);
+void mythread_queue_list_entry_make_batch(mythread_t* mythread, mythread_queue_list_entry_t* entry, size_t from, size_t length);
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyCORE_THREAD_QUEUE_H */
diff --git a/source/myhtml/utils.c b/source/mycore/utils.c
index 52a99da..c91fc2c 100644
--- a/source/myhtml/utils.c
+++ b/source/mycore/utils.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,41 +18,23 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
+#include "mycore/utils/resources.h"
-static const unsigned char myhtml_utils_chars_map[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
- 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
- 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 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, 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, 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, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86,
- 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
- 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1,
- 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa,
- 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3,
- 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc,
- 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5,
- 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce,
- 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0,
- 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
- 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2,
- 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb,
- 0xfc, 0xfd, 0xfe, 0xff
-};
+size_t mycore_power(size_t t, size_t k)
+{
+ size_t res = 1;
+
+ while (k) {
+ if(k & 1) res *= t;
+ t *= t;
+ k >>= 1;
+ }
+
+ return res;
+}
-size_t myhtml_strncasecmp(const char* str1, const char* str2, size_t size)
+size_t mycore_strncasecmp(const char* str1, const char* str2, size_t size)
{
if(str1 == NULL || str2 == NULL) {
if(str1 == str2)
@@ -66,7 +48,7 @@ size_t myhtml_strncasecmp(const char* str1, const char* str2, size_t size)
size_t i = 0;
while (i < size) {
- if(myhtml_utils_chars_map[*ustr1] != myhtml_utils_chars_map[*ustr2])
+ if(mycore_string_chars_lowercase_map[*ustr1] != mycore_string_chars_lowercase_map[*ustr2])
return (size - i);
ustr1++;
@@ -78,7 +60,7 @@ size_t myhtml_strncasecmp(const char* str1, const char* str2, size_t size)
return 0;
}
-size_t myhtml_strcasecmp(const char* str1, const char* str2)
+size_t mycore_strcasecmp(const char* str1, const char* str2)
{
if(str1 == NULL || str2 == NULL) {
if(str1 == str2)
@@ -92,7 +74,7 @@ size_t myhtml_strcasecmp(const char* str1, const char* str2)
for (size_t i = 0;;)
{
- if(myhtml_utils_chars_map[*ustr1] != myhtml_utils_chars_map[*ustr2])
+ if(mycore_string_chars_lowercase_map[*ustr1] != mycore_string_chars_lowercase_map[*ustr2])
return (i + 1);
if(*ustr1 == '\0')
@@ -105,7 +87,7 @@ size_t myhtml_strcasecmp(const char* str1, const char* str2)
}
}
-size_t myhtml_strncmp(const char* str1, const char* str2, size_t size)
+size_t mycore_strncmp(const char* str1, const char* str2, size_t size)
{
if(str1 == NULL || str2 == NULL) {
if(str1 == str2)
@@ -131,7 +113,7 @@ size_t myhtml_strncmp(const char* str1, const char* str2, size_t size)
return 0;
}
-size_t myhtml_strcmp(const char* str1, const char* str2)
+size_t mycore_strcmp(const char* str1, const char* str2)
{
if(str1 == NULL || str2 == NULL) {
if(str1 == str2)
@@ -158,7 +140,7 @@ size_t myhtml_strcmp(const char* str1, const char* str2)
}
}
-size_t myhtml_strcmp_ws(const char* str1, const char* str2)
+size_t mycore_strcmp_ws(const char* str1, const char* str2)
{
if(str1 == NULL || str2 == NULL) {
if(str1 == str2)
@@ -175,7 +157,7 @@ size_t myhtml_strcmp_ws(const char* str1, const char* str2)
if(*ustr1 != *ustr2)
return (i + 1);
- if(myhtml_utils_whithspace(*ustr1, ==, ||) || *ustr1 == '\0')
+ if(mycore_utils_whithspace(*ustr1, ==, ||) || *ustr1 == '\0')
return 0;
ustr1++;
@@ -185,10 +167,10 @@ size_t myhtml_strcmp_ws(const char* str1, const char* str2)
}
}
-bool myhtml_ustrcasecmp_without_checks_by_secondary(const unsigned char* ustr1, const unsigned char* ustr2)
+bool mycore_ustrcasecmp_without_checks_by_secondary(const unsigned char* ustr1, const unsigned char* ustr2)
{
while (*ustr1 != '\0') {
- if(myhtml_utils_chars_map[*ustr1] != myhtml_utils_chars_map[*ustr2])
+ if(mycore_string_chars_lowercase_map[*ustr1] != mycore_string_chars_lowercase_map[*ustr2])
return false;
ustr1++;
diff --git a/source/myhtml/utils.h b/source/mycore/utils.h
index bca879c..f926cb7 100644
--- a/source/myhtml/utils.h
+++ b/source/mycore/utils.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,29 +18,30 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_H
-#define MyHTML_UTILS_H
+#ifndef MyCORE_UTILS_H
+#define MyCORE_UTILS_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-#include "myhtml/myosi.h"
+#include "mycore/myosi.h"
-#define myhtml_utils_whithspace(onechar, action, logic) \
+#define mycore_utils_whithspace(onechar, action, logic) \
(onechar action ' ' logic \
onechar action '\t' logic \
onechar action '\n' logic \
onechar action '\f' logic \
onechar action '\r')
-size_t myhtml_strncasecmp(const char* str1, const char* str2, size_t size);
-size_t myhtml_strcasecmp(const char* str1, const char* str2);
-size_t myhtml_strncmp(const char* str1, const char* str2, size_t size);
-size_t myhtml_strcmp(const char* str1, const char* str2);
-size_t myhtml_strcmp_ws(const char* str1, const char* str2);
-bool myhtml_ustrcasecmp_without_checks_by_secondary(const unsigned char* ustr1, const unsigned char* ustr2);
+size_t mycore_power(size_t t, size_t k);
+size_t mycore_strncasecmp(const char* str1, const char* str2, size_t size);
+size_t mycore_strcasecmp(const char* str1, const char* str2);
+size_t mycore_strncmp(const char* str1, const char* str2, size_t size);
+size_t mycore_strcmp(const char* str1, const char* str2);
+size_t mycore_strcmp_ws(const char* str1, const char* str2);
+bool mycore_ustrcasecmp_without_checks_by_secondary(const unsigned char* ustr1, const unsigned char* ustr2);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myhtml/utils/avl_tree.c b/source/mycore/utils/avl_tree.c
index b8da055..d9d4e39 100644
--- a/source/myhtml/utils/avl_tree.c
+++ b/source/mycore/utils/avl_tree.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -18,33 +18,33 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/utils/avl_tree.h"
+#include "mycore/utils/avl_tree.h"
-myhtml_utils_avl_tree_t * myhtml_utils_avl_tree_create(void)
+mycore_utils_avl_tree_t * mycore_utils_avl_tree_create(void)
{
- return (myhtml_utils_avl_tree_t*)myhtml_calloc(1, sizeof(myhtml_utils_avl_tree_t));
+ return (mycore_utils_avl_tree_t*)mycore_calloc(1, sizeof(mycore_utils_avl_tree_t));
}
-myhtml_status_t myhtml_utils_avl_tree_init(myhtml_utils_avl_tree_t* avl_tree)
+mystatus_t mycore_utils_avl_tree_init(mycore_utils_avl_tree_t* avl_tree)
{
/* for raw declaration style */
avl_tree->mc_nodes = mcobject_create();
if(avl_tree->mc_nodes == NULL)
- return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
- myhtml_status_t myhtml_status = mcobject_init(avl_tree->mc_nodes, 256, sizeof(myhtml_utils_avl_tree_node_t));
- if(myhtml_status)
- return MyHTML_STATUS_ERROR;
+ mystatus_t mycore_status = mcobject_init(avl_tree->mc_nodes, 256, sizeof(mycore_utils_avl_tree_node_t));
+ if(mycore_status)
+ return MyCORE_STATUS_ERROR;
- return MyHTML_STATUS_OK;
+ return MyCORE_STATUS_OK;
}
-void myhtml_utils_avl_tree_clean(myhtml_utils_avl_tree_t* avl_tree)
+void mycore_utils_avl_tree_clean(mycore_utils_avl_tree_t* avl_tree)
{
mcobject_clean(avl_tree->mc_nodes);
}
-myhtml_utils_avl_tree_t * myhtml_utils_avl_tree_destroy(myhtml_utils_avl_tree_t* avl_tree, bool self_destroy)
+mycore_utils_avl_tree_t * mycore_utils_avl_tree_destroy(mycore_utils_avl_tree_t* avl_tree, bool self_destroy)
{
if(avl_tree == NULL)
return NULL;
@@ -52,17 +52,17 @@ myhtml_utils_avl_tree_t * myhtml_utils_avl_tree_destroy(myhtml_utils_avl_tree_t*
mcobject_destroy(avl_tree->mc_nodes, true);
if(self_destroy) {
- myhtml_free(avl_tree);
+ mycore_free(avl_tree);
return NULL;
}
return avl_tree;
}
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_create_root(myhtml_utils_avl_tree_t* avl_tree, size_t type, void* value)
+mycore_utils_avl_tree_node_t * mycore_utils_avl_tree_node_create_root(mycore_utils_avl_tree_t* avl_tree, size_t type, void* value)
{
- myhtml_utils_avl_tree_node_t *node = mcobject_malloc(avl_tree->mc_nodes, NULL);
- memset(node, 0, sizeof(myhtml_utils_avl_tree_node_t));
+ mycore_utils_avl_tree_node_t *node = mcobject_malloc(avl_tree->mc_nodes, NULL);
+ memset(node, 0, sizeof(mycore_utils_avl_tree_node_t));
node->type = type;
node->value = value;
@@ -70,32 +70,32 @@ myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_create_root(myhtml_uti
return node;
}
-void myhtml_utils_avl_tree_node_clean(myhtml_utils_avl_tree_node_t* node)
+void mycore_utils_avl_tree_node_clean(mycore_utils_avl_tree_node_t* node)
{
- memset(node, 0, sizeof(myhtml_utils_avl_tree_node_t));
+ memset(node, 0, sizeof(mycore_utils_avl_tree_node_t));
}
-short myhtml_utils_avl_tree_node_height(myhtml_utils_avl_tree_node_t* node)
+short mycore_utils_avl_tree_node_height(mycore_utils_avl_tree_node_t* node)
{
return (node ? node->height : 0);
}
-short myhtml_utils_avl_tree_node_balance_factor(myhtml_utils_avl_tree_node_t* node)
+short mycore_utils_avl_tree_node_balance_factor(mycore_utils_avl_tree_node_t* node)
{
- return (myhtml_utils_avl_tree_node_height(node->right) - myhtml_utils_avl_tree_node_height(node->left));
+ return (mycore_utils_avl_tree_node_height(node->right) - mycore_utils_avl_tree_node_height(node->left));
}
-void myhtml_utils_avl_tree_node_set_height(myhtml_utils_avl_tree_node_t* node)
+void mycore_utils_avl_tree_node_set_height(mycore_utils_avl_tree_node_t* node)
{
- short left_height = myhtml_utils_avl_tree_node_height(node->left);
- short right_height = myhtml_utils_avl_tree_node_height(node->right);
+ short left_height = mycore_utils_avl_tree_node_height(node->left);
+ short right_height = mycore_utils_avl_tree_node_height(node->right);
node->height = (left_height > right_height ? left_height : right_height) + 1;
}
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_rotate_right(myhtml_utils_avl_tree_node_t* pos)
+mycore_utils_avl_tree_node_t * mycore_utils_avl_tree_node_rotate_right(mycore_utils_avl_tree_node_t* pos)
{
- myhtml_utils_avl_tree_node_t* node = pos->left;
+ mycore_utils_avl_tree_node_t* node = pos->left;
node->parent = pos->parent;
@@ -107,15 +107,15 @@ myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_rotate_right(myhtml_ut
node->right = pos;
- myhtml_utils_avl_tree_node_set_height(pos);
- myhtml_utils_avl_tree_node_set_height(node);
+ mycore_utils_avl_tree_node_set_height(pos);
+ mycore_utils_avl_tree_node_set_height(node);
return node;
}
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_rotate_left(myhtml_utils_avl_tree_node_t* pos)
+mycore_utils_avl_tree_node_t * mycore_utils_avl_tree_node_rotate_left(mycore_utils_avl_tree_node_t* pos)
{
- myhtml_utils_avl_tree_node_t* node = pos->right;
+ mycore_utils_avl_tree_node_t* node = pos->right;
node->parent = pos->parent;
@@ -127,17 +127,17 @@ myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_rotate_left(myhtml_uti
node->left = pos;
- myhtml_utils_avl_tree_node_set_height(pos);
- myhtml_utils_avl_tree_node_set_height(node);
+ mycore_utils_avl_tree_node_set_height(pos);
+ mycore_utils_avl_tree_node_set_height(node);
return node;
}
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_balance(myhtml_utils_avl_tree_node_t* node, myhtml_utils_avl_tree_node_t** root)
+mycore_utils_avl_tree_node_t * mycore_utils_avl_tree_node_balance(mycore_utils_avl_tree_node_t* node, mycore_utils_avl_tree_node_t** root)
{
/* set height */
- short left_height = myhtml_utils_avl_tree_node_height(node->left);
- short right_height = myhtml_utils_avl_tree_node_height(node->right);
+ short left_height = mycore_utils_avl_tree_node_height(node->left);
+ short right_height = mycore_utils_avl_tree_node_height(node->right);
node->height = (left_height > right_height ? left_height : right_height) + 1;
@@ -145,34 +145,34 @@ myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_balance(myhtml_utils_a
switch ((right_height - left_height))
{
case 2: {
- if(myhtml_utils_avl_tree_node_balance_factor(node->right) < 0)
- node->right = myhtml_utils_avl_tree_node_rotate_right(node->right);
+ if(mycore_utils_avl_tree_node_balance_factor(node->right) < 0)
+ node->right = mycore_utils_avl_tree_node_rotate_right(node->right);
- myhtml_utils_avl_tree_node_t* parent = node->parent;
+ mycore_utils_avl_tree_node_t* parent = node->parent;
if(parent) {
if(parent->right == node)
- return parent->right = myhtml_utils_avl_tree_node_rotate_left(node);
+ return parent->right = mycore_utils_avl_tree_node_rotate_left(node);
else
- return parent->left = myhtml_utils_avl_tree_node_rotate_left(node);
+ return parent->left = mycore_utils_avl_tree_node_rotate_left(node);
}
- return myhtml_utils_avl_tree_node_rotate_left(node);
+ return mycore_utils_avl_tree_node_rotate_left(node);
}
case -2: {
- if(myhtml_utils_avl_tree_node_balance_factor(node->left) > 0)
- node->left = myhtml_utils_avl_tree_node_rotate_left(node->left);
+ if(mycore_utils_avl_tree_node_balance_factor(node->left) > 0)
+ node->left = mycore_utils_avl_tree_node_rotate_left(node->left);
- myhtml_utils_avl_tree_node_t* parent = node->parent;
+ mycore_utils_avl_tree_node_t* parent = node->parent;
if(parent) {
if(parent->right == node)
- return parent->right = myhtml_utils_avl_tree_node_rotate_right(node);
+ return parent->right = mycore_utils_avl_tree_node_rotate_right(node);
else
- return parent->left = myhtml_utils_avl_tree_node_rotate_right(node);
+ return parent->left = mycore_utils_avl_tree_node_rotate_right(node);
}
- return myhtml_utils_avl_tree_node_rotate_right(node);
+ return mycore_utils_avl_tree_node_rotate_right(node);
}
default:
break;
@@ -184,16 +184,16 @@ myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_balance(myhtml_utils_a
return node->parent;
}
-void myhtml_utils_avl_tree_add(myhtml_utils_avl_tree_t* avl_tree, myhtml_utils_avl_tree_node_t** root, size_t type, void* value)
+void mycore_utils_avl_tree_add(mycore_utils_avl_tree_t* avl_tree, mycore_utils_avl_tree_node_t** root, size_t type, void* value)
{
if(*root == NULL) {
- *root = myhtml_utils_avl_tree_node_create_root(avl_tree, type, value);
+ *root = mycore_utils_avl_tree_node_create_root(avl_tree, type, value);
return;
}
- myhtml_utils_avl_tree_node_t* node = *root;
- myhtml_utils_avl_tree_node_t* new_node = mcobject_malloc(avl_tree->mc_nodes, NULL);
- myhtml_utils_avl_tree_node_clean(new_node);
+ mycore_utils_avl_tree_node_t* node = *root;
+ mycore_utils_avl_tree_node_t* new_node = mcobject_malloc(avl_tree->mc_nodes, NULL);
+ mycore_utils_avl_tree_node_clean(new_node);
while(1)
{
@@ -232,11 +232,11 @@ void myhtml_utils_avl_tree_add(myhtml_utils_avl_tree_t* avl_tree, myhtml_utils_a
}
while(node) {
- node = myhtml_utils_avl_tree_node_balance(node, root);
+ node = mycore_utils_avl_tree_node_balance(node, root);
}
}
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_find_min(myhtml_utils_avl_tree_node_t* node)
+mycore_utils_avl_tree_node_t * mycore_utils_avl_tree_find_min(mycore_utils_avl_tree_node_t* node)
{
if(node == NULL)
return NULL;
@@ -248,9 +248,9 @@ myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_find_min(myhtml_utils_avl_t
return node;
}
-void myhtml_utils_avl_tree_rotate_for_delete(myhtml_utils_avl_tree_node_t* delete_node, myhtml_utils_avl_tree_node_t* node, myhtml_utils_avl_tree_node_t** root)
+void mycore_utils_avl_tree_rotate_for_delete(mycore_utils_avl_tree_node_t* delete_node, mycore_utils_avl_tree_node_t* node, mycore_utils_avl_tree_node_t** root)
{
- myhtml_utils_avl_tree_node_t* balance_node;
+ mycore_utils_avl_tree_node_t* balance_node;
if(node) {
if(delete_node->left == node) {
@@ -297,18 +297,18 @@ void myhtml_utils_avl_tree_rotate_for_delete(myhtml_utils_avl_tree_node_t* delet
}
while(balance_node) {
- balance_node = myhtml_utils_avl_tree_node_balance(balance_node, root);
+ balance_node = mycore_utils_avl_tree_node_balance(balance_node, root);
}
}
-void * myhtml_utils_avl_tree_delete(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t** root, size_t type)
+void * mycore_utils_avl_tree_delete(mycore_utils_avl_tree_t *avl_tree, mycore_utils_avl_tree_node_t** root, size_t type)
{
- myhtml_utils_avl_tree_node_t* node = *root;
+ mycore_utils_avl_tree_node_t* node = *root;
while(node)
{
if(type == node->type) {
- myhtml_utils_avl_tree_rotate_for_delete(node, myhtml_utils_avl_tree_find_min(node->left), root);
+ mycore_utils_avl_tree_rotate_for_delete(node, mycore_utils_avl_tree_find_min(node->left), root);
void *value = node->value;
mcobject_free(avl_tree->mc_nodes, node);
@@ -324,7 +324,7 @@ void * myhtml_utils_avl_tree_delete(myhtml_utils_avl_tree_t *avl_tree, myhtml_ut
return NULL;
}
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_search_by_type(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t* node, size_t type)
+mycore_utils_avl_tree_node_t * mycore_utils_avl_tree_search_by_type(mycore_utils_avl_tree_t *avl_tree, mycore_utils_avl_tree_node_t* node, size_t type)
{
while(node)
{
@@ -339,15 +339,15 @@ myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_search_by_type(myhtml_utils
return NULL;
}
-void myhtml_utils_avl_tree_list_all_nodes(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t* root, myhtml_utils_avl_tree_node_callback_f callback, void* ctx)
+void mycore_utils_avl_tree_list_all_nodes(mycore_utils_avl_tree_t *avl_tree, mycore_utils_avl_tree_node_t* root, mycore_utils_avl_tree_node_callback_f callback, void* ctx)
{
if(root == NULL)
return;
callback(root, ctx);
- myhtml_utils_avl_tree_list_all_nodes(avl_tree, root->left, callback, ctx);
- myhtml_utils_avl_tree_list_all_nodes(avl_tree, root->right, callback, ctx);
+ mycore_utils_avl_tree_list_all_nodes(avl_tree, root->left, callback, ctx);
+ mycore_utils_avl_tree_list_all_nodes(avl_tree, root->right, callback, ctx);
}
diff --git a/source/mycore/utils/avl_tree.h b/source/mycore/utils/avl_tree.h
new file mode 100644
index 0000000..2ab7ecb
--- /dev/null
+++ b/source/mycore/utils/avl_tree.h
@@ -0,0 +1,68 @@
+/*
+ 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 avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyCORE_UTILS_AVL_TREE_H
+#define MyCORE_UTILS_AVL_TREE_H
+#pragma once
+
+#include "mycore/myosi.h"
+#include "mycore/utils/mcobject.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct mycore_utils_avl_tree_node mycore_utils_avl_tree_node_t;
+typedef void (*mycore_utils_avl_tree_node_callback_f)(mycore_utils_avl_tree_node_t* avl_tree_node, void* ctx);
+
+struct mycore_utils_avl_tree_node {
+ void *value;
+ size_t type;
+
+ mycore_utils_avl_tree_node_t* left;
+ mycore_utils_avl_tree_node_t* right;
+ mycore_utils_avl_tree_node_t* parent;
+
+ short height;
+};
+
+struct mycore_utils_avl_tree {
+ mcobject_t* mc_nodes;
+}
+typedef mycore_utils_avl_tree_t;
+
+mycore_utils_avl_tree_t * mycore_utils_avl_tree_create(void);
+mystatus_t mycore_utils_avl_tree_init(mycore_utils_avl_tree_t* avl_tree);
+void mycore_utils_avl_tree_clean(mycore_utils_avl_tree_t* avl_tree);
+mycore_utils_avl_tree_t * mycore_utils_avl_tree_destroy(mycore_utils_avl_tree_t* avl_tree, bool self_destroy);
+
+mycore_utils_avl_tree_node_t * mycore_utils_avl_tree_node_create_root(mycore_utils_avl_tree_t* avl_tree, size_t type, void* value);
+
+void mycore_utils_avl_tree_add(mycore_utils_avl_tree_t* avl_tree, mycore_utils_avl_tree_node_t** root, size_t type, void* value);
+void * mycore_utils_avl_tree_delete(mycore_utils_avl_tree_t *avl_tree, mycore_utils_avl_tree_node_t** root, size_t type);
+mycore_utils_avl_tree_node_t * mycore_utils_avl_tree_search_by_type(mycore_utils_avl_tree_t *avl_tree, mycore_utils_avl_tree_node_t* node, size_t type);
+
+void mycore_utils_avl_tree_list_all_nodes(mycore_utils_avl_tree_t *avl_tree, mycore_utils_avl_tree_node_t* root, mycore_utils_avl_tree_node_callback_f callback, void* ctx);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyCORE_UTILS_AVL_TREE_H */
diff --git a/source/myhtml/utils/mchar_async.c b/source/mycore/utils/mchar_async.c
index 37c8c57..23bd322 100644
--- a/source/myhtml/utils/mchar_async.c
+++ b/source/mycore/utils/mchar_async.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,18 +18,14 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/utils/mchar_async.h"
+#include "mycore/utils/mchar_async.h"
-mchar_async_t * mchar_async_create(size_t pos_size, size_t size)
+mchar_async_t * mchar_async_create(void)
{
- mchar_async_t *mcobj_async = (mchar_async_t*)myhtml_calloc(1, sizeof(mchar_async_t));
-
- mchar_async_init(mcobj_async, pos_size, size);
-
- return mcobj_async;
+ return (mchar_async_t*)mycore_calloc(1, sizeof(mchar_async_t));
}
-void mchar_async_init(mchar_async_t *mchar_async, size_t chunk_len, size_t char_size)
+mystatus_t mchar_async_init(mchar_async_t *mchar_async, size_t chunk_len, size_t char_size)
{
if(char_size < 4096)
char_size = 4096;
@@ -38,25 +34,58 @@ void mchar_async_init(mchar_async_t *mchar_async, size_t chunk_len, size_t char_
mchar_async->chunks_size = chunk_len;
mchar_async->chunks_pos_size = 1024;
- mchar_async->chunks = (mchar_async_chunk_t**)myhtml_calloc(mchar_async->chunks_pos_size, sizeof(mchar_async_chunk_t*));
- mchar_async->chunks[0] = (mchar_async_chunk_t*)myhtml_calloc(mchar_async->chunks_size, sizeof(mchar_async_chunk_t));
- mchar_async_cache_init(&mchar_async->chunk_cache);
+ /* Chunck, list of mchar_async_chunk_t* */
+ mchar_async->chunks = (mchar_async_chunk_t**)mycore_calloc(mchar_async->chunks_pos_size, sizeof(mchar_async_chunk_t*));
+
+ if(mchar_async->chunks == NULL)
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ /* Init first mchar_async_chunk_t* */
+ mchar_async->chunks[0] = (mchar_async_chunk_t*)mycore_calloc(mchar_async->chunks_size, sizeof(mchar_async_chunk_t));
+
+ if(mchar_async->chunks[0] == NULL) {
+ mchar_async->chunks = mycore_free(mchar_async->chunks);
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ /* Init cache */
+ mystatus_t status = mchar_async_cache_init(&mchar_async->chunk_cache);
+
+ if(status) {
+ mycore_free(mchar_async->chunks[0]);
+ mchar_async->chunks = mycore_free(mchar_async->chunks);
+
+ return status;
+ }
mchar_async->nodes_length = 0;
mchar_async->nodes_size = 64;
- mchar_async->nodes = (mchar_async_node_t*)myhtml_calloc(mchar_async->nodes_size, sizeof(mchar_async_node_t));
+ mchar_async->nodes = (mchar_async_node_t*)mycore_calloc(mchar_async->nodes_size, sizeof(mchar_async_node_t));
+
+ if(mchar_async->nodes == NULL)
+ return status;
mchar_async->nodes_cache_length = 0;
mchar_async->nodes_cache_size = mchar_async->nodes_size;
- mchar_async->nodes_cache = (size_t*)myhtml_malloc(mchar_async->nodes_cache_size * sizeof(size_t));
+ mchar_async->nodes_cache = (size_t*)mycore_malloc(mchar_async->nodes_cache_size * sizeof(size_t));
+
+ if(mchar_async->nodes_cache == NULL)
+ return status;
mchar_async_clean(mchar_async);
mchar_async->mcsync = mcsync_create();
+ if(mchar_async->mcsync == NULL)
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if((status = mcsync_init(mchar_async->mcsync)))
+ return status;
+
+ return MyCORE_STATUS_OK;
}
-void mchar_async_clean(mchar_async_t *mchar_async)
+mystatus_t mchar_async_clean(mchar_async_t *mchar_async)
{
mchar_async->chunks_length = 0;
mchar_async->chunks_pos_length = 1;
@@ -69,8 +98,14 @@ void mchar_async_clean(mchar_async_t *mchar_async)
mchar_async_cache_clean(&node->cache);
node->chunk = mchar_async_chunk_malloc(mchar_async, node, mchar_async->origin_size);
+
+ if(node->chunk == NULL)
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
node->chunk->prev = 0;
}
+
+ return MyCORE_STATUS_OK;
}
mchar_async_t * mchar_async_destroy(mchar_async_t *mchar_async, int destroy_self)
@@ -86,12 +121,12 @@ mchar_async_t * mchar_async_destroy(mchar_async_t *mchar_async, int destroy_self
mchar_async_cache_destroy(&node->cache, false);
}
- myhtml_free(mchar_async->nodes);
+ mycore_free(mchar_async->nodes);
mchar_async->nodes = NULL;
}
if(mchar_async->nodes_cache) {
- myhtml_free(mchar_async->nodes_cache);
+ mycore_free(mchar_async->nodes_cache);
}
if(mchar_async->chunks)
@@ -101,14 +136,14 @@ mchar_async_t * mchar_async_destroy(mchar_async_t *mchar_async, int destroy_self
{
for (size_t idx = 0; idx < mchar_async->chunks_size; idx++) {
if(mchar_async->chunks[pos_idx][idx].begin)
- myhtml_free(mchar_async->chunks[pos_idx][idx].begin);
+ mycore_free(mchar_async->chunks[pos_idx][idx].begin);
}
- myhtml_free(mchar_async->chunks[pos_idx]);
+ mycore_free(mchar_async->chunks[pos_idx]);
}
}
- myhtml_free(mchar_async->chunks);
+ mycore_free(mchar_async->chunks);
mchar_async->chunks = NULL;
}
@@ -119,7 +154,7 @@ mchar_async_t * mchar_async_destroy(mchar_async_t *mchar_async, int destroy_self
memset(mchar_async, 0, sizeof(mchar_async_t));
if(destroy_self)
- myhtml_free(mchar_async);
+ mycore_free(mchar_async);
else
return mchar_async;
@@ -133,10 +168,10 @@ void mchar_async_mem_malloc(mchar_async_t *mchar_async, mchar_async_node_t *node
if(chunk->begin) {
if(length > chunk->size) {
- myhtml_free(chunk->begin);
+ mycore_free(chunk->begin);
chunk->size = length + mchar_async->origin_size;
- chunk->begin = (char*)myhtml_malloc(chunk->size * sizeof(char));
+ chunk->begin = (char*)mycore_malloc(chunk->size * sizeof(char));
}
}
else {
@@ -145,7 +180,7 @@ void mchar_async_mem_malloc(mchar_async_t *mchar_async, mchar_async_node_t *node
if(length > chunk->size)
chunk->size = length;
- chunk->begin = (char*)myhtml_malloc(chunk->size * sizeof(char));
+ chunk->begin = (char*)mycore_malloc(chunk->size * sizeof(char));
}
chunk->length = 0;
@@ -159,6 +194,8 @@ mchar_async_chunk_t * mchar_async_chunk_malloc_without_lock(mchar_async_t *mchar
if(index)
return (mchar_async_chunk_t*)mchar_async->chunk_cache.nodes[index].value;
+ else
+ return NULL;
}
if(mchar_async->chunks_length >= mchar_async->chunks_size)
@@ -169,7 +206,7 @@ mchar_async_chunk_t * mchar_async_chunk_malloc_without_lock(mchar_async_t *mchar
if(mchar_async->chunks_pos_length >= mchar_async->chunks_pos_size)
{
mchar_async->chunks_pos_size <<= 1;
- mchar_async_chunk_t **tmp_pos = myhtml_realloc(mchar_async->chunks,
+ mchar_async_chunk_t **tmp_pos = mycore_realloc(mchar_async->chunks,
sizeof(mchar_async_chunk_t*) * mchar_async->chunks_pos_size);
if(tmp_pos) {
@@ -178,13 +215,17 @@ mchar_async_chunk_t * mchar_async_chunk_malloc_without_lock(mchar_async_t *mchar
mchar_async->chunks = tmp_pos;
}
+ else
+ return NULL;
}
if(mchar_async->chunks[current_idx] == NULL) {
- mchar_async_chunk_t *tmp = myhtml_calloc(mchar_async->chunks_size, sizeof(mchar_async_chunk_t));
+ mchar_async_chunk_t *tmp = mycore_calloc(mchar_async->chunks_size, sizeof(mchar_async_chunk_t));
if(tmp)
mchar_async->chunks[current_idx] = tmp;
+ else
+ return NULL;
}
mchar_async->chunks_length = 0;
@@ -195,6 +236,9 @@ mchar_async_chunk_t * mchar_async_chunk_malloc_without_lock(mchar_async_t *mchar
mchar_async_mem_malloc(mchar_async, node, chunk, length);
+ if(chunk->begin == NULL)
+ return NULL;
+
return chunk;
}
@@ -207,9 +251,14 @@ mchar_async_chunk_t * mchar_async_chunk_malloc(mchar_async_t *mchar_async, mchar
return chunk;
}
-size_t mchar_async_node_add(mchar_async_t *mchar_async)
+size_t mchar_async_node_add(mchar_async_t *mchar_async, mystatus_t* status)
{
- mcsync_lock(mchar_async->mcsync);
+ if(mcsync_lock(mchar_async->mcsync)) {
+ if(status)
+ *status = MyCORE_STATUS_ASYNC_ERROR_LOCK;
+
+ return 0;
+ }
size_t node_idx;
@@ -220,6 +269,9 @@ size_t mchar_async_node_add(mchar_async_t *mchar_async)
}
else {
if(mchar_async->nodes_length >= mchar_async->nodes_size) {
+ if(status)
+ *status = MyCORE_STATUS_ERROR_NO_FREE_SLOT;
+
mcsync_unlock(mchar_async->mcsync);
return 0;
}
@@ -230,15 +282,32 @@ size_t mchar_async_node_add(mchar_async_t *mchar_async)
mchar_async_node_t *node = &mchar_async->nodes[node_idx];
- mchar_async_cache_init(&node->cache);
+ if(mchar_async_cache_init(&node->cache)) {
+ if(status)
+ *status = MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ mcsync_unlock(mchar_async->mcsync);
+ return 0;
+ }
node->chunk = mchar_async_chunk_malloc_without_lock(mchar_async, node, mchar_async->origin_size);
+ if(node->chunk == NULL) {
+ if(status)
+ *status = MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ mcsync_unlock(mchar_async->mcsync);
+ return 0;
+ }
+
node->chunk->next = NULL;
node->chunk->prev = NULL;
mcsync_unlock(mchar_async->mcsync);
+ if(status)
+ *status = MyCORE_STATUS_OK;
+
return node_idx;
}
@@ -285,7 +354,7 @@ void mchar_async_node_delete(mchar_async_t *mchar_async, size_t node_idx)
if(mchar_async->nodes_cache_length >= mchar_async->nodes_cache_size) {
size_t new_size = mchar_async->nodes_cache_size << 1;
- size_t *tmp = (size_t*)myhtml_realloc(mchar_async->nodes_cache, sizeof(size_t) * mchar_async->nodes_cache_size);
+ size_t *tmp = (size_t*)mycore_realloc(mchar_async->nodes_cache, sizeof(size_t) * mchar_async->nodes_cache_size);
if(tmp) {
mchar_async->nodes_cache = tmp;
@@ -486,13 +555,16 @@ void mchar_async_free(mchar_async_t *mchar_async, size_t node_idx, char *entry)
mchar_async_cache_add(&mchar_async->nodes[node_idx].cache, entry, *(size_t*)(entry - sizeof(size_t)));
}
-void mchar_async_cache_init(mchar_async_cache_t *cache)
+mystatus_t mchar_async_cache_init(mchar_async_cache_t *cache)
{
cache->count = 0;
cache->nodes_root = 0;
cache->nodes_length = 1;
cache->nodes_size = 1024;
- cache->nodes = (mchar_async_cache_node_t*)myhtml_malloc(sizeof(mchar_async_cache_node_t) * cache->nodes_size);
+ cache->nodes = (mchar_async_cache_node_t*)mycore_malloc(sizeof(mchar_async_cache_node_t) * cache->nodes_size);
+
+ if(cache->nodes == NULL)
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
cache->nodes[0].left = 0;
cache->nodes[0].right = 0;
@@ -501,7 +573,14 @@ void mchar_async_cache_init(mchar_async_cache_t *cache)
cache->index_length = 0;
cache->index_size = cache->nodes_size;
- cache->index = (size_t*)myhtml_malloc(sizeof(size_t) * cache->index_size);
+ cache->index = (size_t*)mycore_malloc(sizeof(size_t) * cache->index_size);
+
+ if(cache->index == NULL) {
+ cache->nodes = mycore_free(cache->nodes);
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ return MyCORE_STATUS_OK;
}
void mchar_async_cache_clean(mchar_async_cache_t *cache)
@@ -525,13 +604,13 @@ mchar_async_cache_t * mchar_async_cache_destroy(mchar_async_cache_t *cache, bool
return NULL;
if(cache->nodes)
- myhtml_free(cache->nodes);
+ mycore_free(cache->nodes);
if(cache->index)
- myhtml_free(cache->index);
+ mycore_free(cache->index);
if(self_destroy) {
- myhtml_free(cache);
+ mycore_free(cache);
return NULL;
}
@@ -550,7 +629,7 @@ size_t mchar_async_cache_malloc(mchar_async_cache_t *cache)
if(cache->nodes_length >= cache->nodes_size) {
cache->nodes_size <<= 1;
- mchar_async_cache_node_t *tmp = (mchar_async_cache_node_t*)myhtml_realloc(cache->nodes, sizeof(mchar_async_cache_node_t) * cache->nodes_size);
+ mchar_async_cache_node_t *tmp = (mchar_async_cache_node_t*)mycore_realloc(cache->nodes, sizeof(mchar_async_cache_node_t) * cache->nodes_size);
if(tmp)
cache->nodes = tmp;
@@ -658,12 +737,14 @@ size_t mchar_async_cache_delete(mchar_async_cache_t *cache, size_t size)
if(cache->index_length >= cache->index_size)
{
size_t new_size = cache->index_size << 1;
- size_t *tmp = (size_t*)myhtml_realloc(cache->index, sizeof(size_t) * new_size);
+ size_t *tmp = (size_t*)mycore_realloc(cache->index, sizeof(size_t) * new_size);
if(tmp) {
cache->index = tmp;
cache->index_size = new_size;
}
+ else
+ return 0;
}
cache->count--;
diff --git a/source/myhtml/utils/mchar_async.h b/source/mycore/utils/mchar_async.h
index dcba9c5..f7fe54b 100644
--- a/source/myhtml/utils/mchar_async.h
+++ b/source/mycore/utils/mchar_async.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,16 +18,16 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_MCHAR_ASYNC_H
-#define MyHTML_UTILS_MCHAR_ASYNC_H
+#ifndef MyCORE_UTILS_MCHAR_ASYNC_H
+#define MyCORE_UTILS_MCHAR_ASYNC_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-#include "myhtml/myosi.h"
-#include "myhtml/utils/mcsync.h"
+#include "mycore/myosi.h"
+#include "mycore/utils/mcsync.h"
#define mchar_async_cache_has_nodes(cache) cache.count
@@ -96,16 +96,16 @@ struct mchar_async {
typedef mchar_async_t;
-mchar_async_t * mchar_async_create(size_t pos_size, size_t size);
-void mchar_async_init(mchar_async_t *mchar_async, size_t chunk_len, size_t char_size);
-void mchar_async_clean(mchar_async_t *mchar_async);
+mchar_async_t * mchar_async_create(void);
+mystatus_t mchar_async_init(mchar_async_t *mchar_async, size_t chunk_len, size_t char_size);
+mystatus_t mchar_async_clean(mchar_async_t *mchar_async);
mchar_async_t * mchar_async_destroy(mchar_async_t *mchar_async, int destroy_self);
char * mchar_async_malloc(mchar_async_t *mchar_async, size_t node_idx, size_t size);
char * mchar_async_realloc(mchar_async_t *mchar_async, size_t node_idx, char *data, size_t data_len, size_t new_size);
void mchar_async_free(mchar_async_t *mchar_async, size_t node_idx, char *entry);
-size_t mchar_async_node_add(mchar_async_t *mchar_async);
+size_t mchar_async_node_add(mchar_async_t *mchar_async, mystatus_t* status);
void mchar_async_node_clean(mchar_async_t *mchar_async, size_t node_idx);
void mchar_async_node_delete(mchar_async_t *mchar_async, size_t node_idx);
@@ -116,7 +116,7 @@ char * mchar_async_crop_first_chars_without_cache(char *data, size_t crop_len);
size_t mchar_async_get_size_by_data(const char *data);
// cache
-void mchar_async_cache_init(mchar_async_cache_t *cache);
+mystatus_t mchar_async_cache_init(mchar_async_cache_t *cache);
mchar_async_cache_t * mchar_async_cache_destroy(mchar_async_cache_t *cache, bool self_destroy);
void mchar_async_cache_clean(mchar_async_cache_t *cache);
diff --git a/source/myhtml/utils/mcobject.c b/source/mycore/utils/mcobject.c
index 3353909..57197f1 100644
--- a/source/myhtml/utils/mcobject.c
+++ b/source/mycore/utils/mcobject.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,14 +18,14 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/utils/mcobject.h"
+#include "mycore/utils/mcobject.h"
mcobject_t * mcobject_create(void)
{
- return myhtml_calloc(1, sizeof(mcobject_t));
+ return mycore_calloc(1, sizeof(mcobject_t));
}
-myhtml_status_t mcobject_init(mcobject_t *mcobject, size_t chunk_size, size_t struct_size)
+mystatus_t mcobject_init(mcobject_t *mcobject, size_t chunk_size, size_t struct_size)
{
mcobject->struct_size = struct_size;
mcobject->chunk_size = chunk_size;
@@ -34,12 +34,12 @@ myhtml_status_t mcobject_init(mcobject_t *mcobject, size_t chunk_size, size_t st
mcobject->cache_length = 0;
mcobject->cache_size = chunk_size;
- mcobject->cache = (void**)myhtml_malloc(sizeof(void*) * mcobject->cache_size);
+ mcobject->cache = (void**)mycore_malloc(sizeof(void*) * mcobject->cache_size);
if(mcobject->cache == NULL)
- return MyHTML_STATUS_MCOBJECT_ERROR_CACHE_CREATE;
+ return MyCORE_STATUS_MCOBJECT_ERROR_CACHE_CREATE;
- return MyHTML_STATUS_OK;
+ return MyCORE_STATUS_OK;
}
void mcobject_clean(mcobject_t *mcobject)
@@ -56,10 +56,10 @@ void mcobject_clean(mcobject_t *mcobject)
mcobject_chunk_t* tmp = chunk->prev;
if(chunk->begin) {
- myhtml_free(chunk->begin);
+ mycore_free(chunk->begin);
}
- myhtml_free(chunk);
+ mycore_free(chunk);
chunk = tmp;
}
@@ -76,22 +76,22 @@ mcobject_t * mcobject_destroy(mcobject_t *mcobject, bool destroy_self)
mcobject_clean(mcobject);
if(mcobject->cache) {
- myhtml_free(mcobject->cache);
+ mycore_free(mcobject->cache);
mcobject->cache = NULL;
}
if(destroy_self) {
- myhtml_free(mcobject);
+ mycore_free(mcobject);
return NULL;
}
return mcobject;
}
-void mcobject_chunk_malloc(mcobject_t* mcobject, myhtml_status_t* status)
+void mcobject_chunk_malloc(mcobject_t* mcobject, mystatus_t* status)
{
if(status)
- *status = MyHTML_STATUS_OK;
+ *status = MyCORE_STATUS_OK;
mcobject_chunk_t* chunk;
@@ -103,22 +103,22 @@ void mcobject_chunk_malloc(mcobject_t* mcobject, myhtml_status_t* status)
return;
}
else {
- chunk = myhtml_calloc(1, sizeof(mcobject_chunk_t));
+ chunk = mycore_calloc(1, sizeof(mcobject_chunk_t));
if(chunk == NULL) {
if(status)
- *status = MyHTML_STATUS_MCOBJECT_ERROR_CHUNK_CREATE;
+ *status = MyCORE_STATUS_MCOBJECT_ERROR_CHUNK_CREATE;
return;
}
- chunk->begin = myhtml_malloc(mcobject->struct_size * mcobject->chunk_size);
+ chunk->begin = mycore_malloc(mcobject->struct_size * mcobject->chunk_size);
if(chunk->begin == NULL) {
if(status)
- *status = MyHTML_STATUS_MCOBJECT_ERROR_CHUNK_INIT;
+ *status = MyCORE_STATUS_MCOBJECT_ERROR_CHUNK_INIT;
- myhtml_free(chunk);
+ mycore_free(chunk);
return;
}
@@ -136,11 +136,11 @@ void mcobject_chunk_malloc(mcobject_t* mcobject, myhtml_status_t* status)
mcobject->chunk = chunk;
}
-void * mcobject_malloc(mcobject_t *mcobject, myhtml_status_t* status)
+void * mcobject_malloc(mcobject_t *mcobject, mystatus_t* status)
{
if(mcobject->cache_length) {
if(status)
- *status = MyHTML_STATUS_OK;
+ *status = MyCORE_STATUS_OK;
mcobject->cache_length--;
return mcobject->cache[ mcobject->cache_length ];
@@ -150,7 +150,7 @@ void * mcobject_malloc(mcobject_t *mcobject, myhtml_status_t* status)
if(chunk == NULL || chunk->length >= chunk->size)
{
- myhtml_status_t ns_status;
+ mystatus_t ns_status;
mcobject_chunk_malloc(mcobject, &ns_status);
if(ns_status) {
@@ -164,31 +164,31 @@ void * mcobject_malloc(mcobject_t *mcobject, myhtml_status_t* status)
}
if(status)
- *status = MyHTML_STATUS_OK;
+ *status = MyCORE_STATUS_OK;
chunk->length++;
return &chunk->begin[((chunk->length - 1) * mcobject->struct_size)];
}
-myhtml_status_t mcobject_free(mcobject_t *mcobject, void *entry)
+mystatus_t mcobject_free(mcobject_t *mcobject, void *entry)
{
if(mcobject->cache_length >= mcobject->cache_size) {
size_t new_size = mcobject->cache_size << 1;
- void **tmp = (void**)myhtml_realloc(mcobject->cache, sizeof(void*) * new_size);
+ void **tmp = (void**)mycore_realloc(mcobject->cache, sizeof(void*) * new_size);
if(tmp) {
mcobject->cache = tmp;
mcobject->cache_size = new_size;
}
else
- return MyHTML_STATUS_MCOBJECT_ERROR_CACHE_REALLOC;
+ return MyCORE_STATUS_MCOBJECT_ERROR_CACHE_REALLOC;
}
mcobject->cache[ mcobject->cache_length ] = entry;
mcobject->cache_length++;
- return MyHTML_STATUS_OK;
+ return MyCORE_STATUS_OK;
}
diff --git a/include/myhtml/utils/mcobject.h b/source/mycore/utils/mcobject.h
index b641327..a38e937 100644
--- a/include/myhtml/utils/mcobject.h
+++ b/source/mycore/utils/mcobject.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,15 +18,15 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_MCOBJECT_H
-#define MyHTML_UTILS_MCOBJECT_H
+#ifndef MyCORE_UTILS_MCOBJECT_H
+#define MyCORE_UTILS_MCOBJECT_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-#include <myhtml/myosi.h>
+#include "mycore/myosi.h"
struct mcobject_chunk {
unsigned char *begin;
@@ -52,19 +52,19 @@ typedef mcobject_t;
mcobject_t * mcobject_create(void);
-myhtml_status_t mcobject_init(mcobject_t *mcobject, size_t chunk_size, size_t struct_size);
+mystatus_t mcobject_init(mcobject_t *mcobject, size_t chunk_size, size_t struct_size);
void mcobject_clean(mcobject_t *mcobject);
mcobject_t * mcobject_destroy(mcobject_t *mcobject, bool destroy_self);
-void mcobject_chunk_malloc(mcobject_t* mcobject, myhtml_status_t* status);
+void mcobject_chunk_malloc(mcobject_t* mcobject, mystatus_t* status);
-void * mcobject_malloc(mcobject_t *mcobject, myhtml_status_t* status);
-myhtml_status_t mcobject_free(mcobject_t *mcobject, void *entry);
+void * mcobject_malloc(mcobject_t *mcobject, mystatus_t* status);
+mystatus_t mcobject_free(mcobject_t *mcobject, void *entry);
#ifdef __cplusplus
} /* extern "C" */
#endif
-#endif /* MyHTML_UTILS_MCOBJECT_H */
+#endif /* MyCORE_UTILS_MCOBJECT_H */
diff --git a/source/myhtml/utils/mcobject_async.c b/source/mycore/utils/mcobject_async.c
index 21e36e8..191836a 100644
--- a/source/myhtml/utils/mcobject_async.c
+++ b/source/mycore/utils/mcobject_async.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,11 +18,11 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/utils/mcobject_async.h"
+#include "mycore/utils/mcobject_async.h"
mcobject_async_t * mcobject_async_create(void)
{
- return (mcobject_async_t*)myhtml_calloc(1, sizeof(mcobject_async_t));
+ return (mcobject_async_t*)mycore_calloc(1, sizeof(mcobject_async_t));
}
mcobject_async_status_t mcobject_async_chunk_up(mcobject_async_t *mcobj_async)
@@ -30,7 +30,7 @@ mcobject_async_status_t mcobject_async_chunk_up(mcobject_async_t *mcobj_async)
mcobj_async->chunks_length = 0;
if(mcobj_async->chunks[ mcobj_async->chunks_pos_length ] == NULL) {
- mcobj_async->chunks[ mcobj_async->chunks_pos_length ] = (mcobject_async_chunk_t*)myhtml_calloc(mcobj_async->chunks_size, sizeof(mcobject_async_chunk_t));
+ mcobj_async->chunks[ mcobj_async->chunks_pos_length ] = (mcobject_async_chunk_t*)mycore_calloc(mcobj_async->chunks_size, sizeof(mcobject_async_chunk_t));
if(mcobj_async->chunks[ mcobj_async->chunks_pos_length ] == NULL)
return MCOBJECT_ASYNC_STATUS_CHUNK_ERROR_MEMORY_ALLOCATION;
@@ -48,7 +48,7 @@ mcobject_async_status_t mcobject_async_init(mcobject_async_t *mcobj_async, size_
mcobj_async->chunks_pos_length = 0;
mcobj_async->chunks_pos_size = 128;
mcobj_async->chunks_size = chunk_len;
- mcobj_async->chunks = (mcobject_async_chunk_t**)myhtml_calloc(mcobj_async->chunks_pos_size, sizeof(mcobject_async_chunk_t*));
+ mcobj_async->chunks = (mcobject_async_chunk_t**)mycore_calloc(mcobj_async->chunks_pos_size, sizeof(mcobject_async_chunk_t*));
if(mcobj_async->chunks == NULL)
return MCOBJECT_ASYNC_STATUS_CHUNK_ERROR_MEMORY_ALLOCATION;
@@ -56,21 +56,21 @@ mcobject_async_status_t mcobject_async_init(mcobject_async_t *mcobj_async, size_
mcobject_async_chunk_up(mcobj_async);
mcobj_async->chunk_cache_size = mcobj_async->chunks_size;
- mcobj_async->chunk_cache = (mcobject_async_chunk_t**)myhtml_calloc(mcobj_async->chunk_cache_size, sizeof(mcobject_async_chunk_t*));
+ mcobj_async->chunk_cache = (mcobject_async_chunk_t**)mycore_calloc(mcobj_async->chunk_cache_size, sizeof(mcobject_async_chunk_t*));
if(mcobj_async->chunk_cache == NULL)
return MCOBJECT_ASYNC_STATUS_CHUNK_CACHE_ERROR_MEMORY_ALLOCATION;
mcobj_async->nodes_length = 0;
mcobj_async->nodes_size = 64;
- mcobj_async->nodes = (mcobject_async_node_t*)myhtml_calloc(mcobj_async->nodes_size, sizeof(mcobject_async_node_t));
+ mcobj_async->nodes = (mcobject_async_node_t*)mycore_calloc(mcobj_async->nodes_size, sizeof(mcobject_async_node_t));
if(mcobj_async->nodes == NULL)
return MCOBJECT_ASYNC_STATUS_NODES_ERROR_MEMORY_ALLOCATION;
mcobj_async->nodes_cache_length = 0;
mcobj_async->nodes_cache_size = mcobj_async->nodes_size;
- mcobj_async->nodes_cache = (size_t*)myhtml_malloc(mcobj_async->nodes_cache_size * sizeof(size_t));
+ mcobj_async->nodes_cache = (size_t*)mycore_malloc(mcobj_async->nodes_cache_size * sizeof(size_t));
if(mcobj_async->nodes_cache == NULL)
return MCOBJECT_ASYNC_STATUS_NODES_ERROR_MEMORY_ALLOCATION;
@@ -78,6 +78,11 @@ mcobject_async_status_t mcobject_async_init(mcobject_async_t *mcobj_async, size_
mcobject_async_clean(mcobj_async);
mcobj_async->mcsync = mcsync_create();
+ if(mcobj_async->mcsync == NULL)
+ return MCOBJECT_ASYNC_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if(mcsync_init(mcobj_async->mcsync))
+ return MCOBJECT_ASYNC_STATUS_ERROR_MEMORY_ALLOCATION;
return MCOBJECT_ASYNC_STATUS_OK;
}
@@ -116,14 +121,14 @@ mcobject_async_t * mcobject_async_destroy(mcobject_async_t *mcobj_async, int des
mcobject_async_node_t *node = &mcobj_async->nodes[node_idx];
if(node->cache)
- myhtml_free(node->cache);
+ mycore_free(node->cache);
}
- myhtml_free(mcobj_async->nodes);
+ mycore_free(mcobj_async->nodes);
}
if(mcobj_async->nodes_cache) {
- myhtml_free(mcobj_async->nodes_cache);
+ mycore_free(mcobj_async->nodes_cache);
}
if(mcobj_async->chunks) {
@@ -132,18 +137,18 @@ mcobject_async_t * mcobject_async_destroy(mcobject_async_t *mcobj_async, int des
{
for (size_t idx = 0; idx < mcobj_async->chunks_size; idx++) {
if(mcobj_async->chunks[pos_idx][idx].begin)
- myhtml_free(mcobj_async->chunks[pos_idx][idx].begin);
+ mycore_free(mcobj_async->chunks[pos_idx][idx].begin);
}
- myhtml_free(mcobj_async->chunks[pos_idx]);
+ mycore_free(mcobj_async->chunks[pos_idx]);
}
}
- myhtml_free(mcobj_async->chunks);
+ mycore_free(mcobj_async->chunks);
}
if(mcobj_async->chunk_cache) {
- myhtml_free(mcobj_async->chunk_cache);
+ mycore_free(mcobj_async->chunk_cache);
}
mcobj_async->mcsync = mcsync_destroy(mcobj_async->mcsync, 1);
@@ -151,7 +156,7 @@ mcobject_async_t * mcobject_async_destroy(mcobject_async_t *mcobj_async, int des
memset(mcobj_async, 0, sizeof(mcobject_async_t));
if(destroy_self)
- myhtml_free(mcobj_async);
+ mycore_free(mcobj_async);
else
return mcobj_async;
@@ -162,10 +167,10 @@ mcobject_async_status_t mcobject_async_mem_malloc(mcobject_async_t *mcobj_async,
{
if(chunk->begin) {
if(length > chunk->size) {
- myhtml_free(chunk->begin);
+ mycore_free(chunk->begin);
chunk->size = length + mcobj_async->origin_size;
- chunk->begin = (unsigned char*)myhtml_malloc(chunk->size * mcobj_async->struct_size_sn);
+ chunk->begin = (unsigned char*)mycore_malloc(chunk->size * mcobj_async->struct_size_sn);
}
}
else {
@@ -174,7 +179,7 @@ mcobject_async_status_t mcobject_async_mem_malloc(mcobject_async_t *mcobj_async,
if(length > chunk->size)
chunk->size += length;
- chunk->begin = (unsigned char*)myhtml_malloc(chunk->size * mcobj_async->struct_size_sn);
+ chunk->begin = (unsigned char*)mycore_malloc(chunk->size * mcobj_async->struct_size_sn);
}
chunk->length = 0;
@@ -206,7 +211,7 @@ mcobject_async_chunk_t * mcobject_async_chunk_malloc_without_lock(mcobject_async
if(mcobj_async->chunks_pos_length >= mcobj_async->chunks_pos_size)
{
size_t tmp_pos_size = mcobj_async->chunks_pos_size << 1;
- mcobject_async_chunk_t **tmp_pos = myhtml_realloc(mcobj_async->chunks,
+ mcobject_async_chunk_t **tmp_pos = mycore_realloc(mcobj_async->chunks,
sizeof(mcobject_async_chunk_t*) * tmp_pos_size);
if(tmp_pos)
@@ -251,7 +256,13 @@ mcobject_async_chunk_t * mcobject_async_chunk_malloc_without_lock(mcobject_async
mcobject_async_chunk_t * mcobject_async_chunk_malloc(mcobject_async_t *mcobj_async, size_t length, mcobject_async_status_t *status)
{
- mcsync_lock(mcobj_async->mcsync);
+ if(mcsync_lock(mcobj_async->mcsync)) {
+ if(status)
+ *status = MCOBJECT_ASYNC_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ return NULL;
+ }
+
mcobject_async_chunk_t* chunk = mcobject_async_chunk_malloc_without_lock(mcobj_async, length, status);
mcsync_unlock(mcobj_async->mcsync);
@@ -296,7 +307,7 @@ size_t mcobject_async_node_add(mcobject_async_t *mcobj_async, mcobject_async_sta
node->cache_length = 0;
node->cache_size = mcobj_async->origin_size;
- node->cache = (void**)myhtml_malloc(sizeof(void*) * node->cache_size);
+ node->cache = (void**)mycore_malloc(sizeof(void*) * node->cache_size);
if(node->cache == NULL) {
if(status)
@@ -356,7 +367,7 @@ void mcobject_async_node_delete(mcobject_async_t *mcobj_async, size_t node_idx)
if(mcobj_async->chunk_cache_length >= mcobj_async->chunk_cache_size) {
size_t new_size = mcobj_async->chunk_cache_size << 1;
- mcobject_async_chunk_t **tmp = (mcobject_async_chunk_t**)myhtml_realloc(mcobj_async->chunk_cache,
+ mcobject_async_chunk_t **tmp = (mcobject_async_chunk_t**)mycore_realloc(mcobj_async->chunk_cache,
sizeof(mcobject_async_chunk_t*) * new_size);
if(tmp) {
@@ -377,14 +388,14 @@ void mcobject_async_node_delete(mcobject_async_t *mcobj_async, size_t node_idx)
}
if(node->cache)
- myhtml_free(node->cache);
+ mycore_free(node->cache);
memset(node, 0, sizeof(mcobject_async_node_t));
if(mcobj_async->nodes_cache_length >= mcobj_async->nodes_cache_size) {
size_t new_size = mcobj_async->nodes_cache_size << 1;
- size_t *tmp = (size_t*)myhtml_realloc(mcobj_async->nodes_cache, sizeof(size_t) * mcobj_async->nodes_cache_size);
+ size_t *tmp = (size_t*)mycore_realloc(mcobj_async->nodes_cache, sizeof(size_t) * mcobj_async->nodes_cache_size);
if(tmp) {
mcobj_async->nodes_cache = tmp;
@@ -456,7 +467,7 @@ mcobject_async_status_t mcobject_async_free(mcobject_async_t *mcobj_async, void
if(node->cache_length >= node->cache_size) {
size_t new_size = node->cache_size << 1;
- void **tmp = (void**)myhtml_realloc(node->cache, sizeof(void*) * new_size);
+ void **tmp = (void**)mycore_realloc(node->cache, sizeof(void*) * new_size);
if(tmp) {
node->cache = tmp;
diff --git a/include/myhtml/utils/mcobject_async.h b/source/mycore/utils/mcobject_async.h
index 4d632c2..41252ff 100644
--- a/include/myhtml/utils/mcobject_async.h
+++ b/source/mycore/utils/mcobject_async.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,16 +18,16 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_MCOBJECT_ASYNC_H
-#define MyHTML_UTILS_MCOBJECT_ASYNC_H
+#ifndef MyCORE_UTILS_MCOBJECT_ASYNC_H
+#define MyCORE_UTILS_MCOBJECT_ASYNC_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-#include <myhtml/myosi.h>
-#include <myhtml/utils/mcsync.h>
+#include "mycore/myosi.h"
+#include "mycore/utils/mcsync.h"
enum mcobject_async_status {
MCOBJECT_ASYNC_STATUS_OK = 0,
diff --git a/source/myhtml/utils/mcsimple.c b/source/mycore/utils/mcsimple.c
index 8103b21..dbf9996 100644
--- a/source/myhtml/utils/mcsimple.c
+++ b/source/mycore/utils/mcsimple.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,11 +18,11 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/utils/mcsimple.h"
+#include "mycore/utils/mcsimple.h"
mcsimple_t * mcsimple_create(void)
{
- return myhtml_calloc(1, sizeof(mcsimple_t));
+ return mycore_calloc(1, sizeof(mcsimple_t));
}
void mcsimple_init(mcsimple_t *mcsimple, size_t pos_size, size_t list_size, size_t struct_size)
@@ -32,7 +32,7 @@ void mcsimple_init(mcsimple_t *mcsimple, size_t pos_size, size_t list_size, size
mcsimple->list_pos_length_used = 0;
mcsimple->list_pos_length = 0;
mcsimple->list_pos_size = pos_size;
- mcsimple->list = (uint8_t**)myhtml_calloc(pos_size, sizeof(uint8_t*));
+ mcsimple->list = (uint8_t**)mycore_calloc(pos_size, sizeof(uint8_t*));
if(mcsimple->list == NULL) {
return;
@@ -59,14 +59,14 @@ mcsimple_t * mcsimple_destroy(mcsimple_t *mcsimple, bool destroy_self)
if(mcsimple->list) {
for(size_t i = 0; i < mcsimple->list_pos_length_used; i++) {
if(mcsimple->list[i])
- free(mcsimple->list[i]);
+ mycore_free(mcsimple->list[i]);
}
- free(mcsimple->list);
+ mycore_free(mcsimple->list);
}
if(destroy_self) {
- free(mcsimple);
+ mycore_free(mcsimple);
return NULL;
}
@@ -78,7 +78,7 @@ uint8_t * mcsimple_init_list_entries(mcsimple_t *mcsimple, size_t pos)
if(mcsimple->list_pos_length >= mcsimple->list_pos_size)
{
size_t new_size = mcsimple->list_pos_size + 128;
- uint8_t **list = (uint8_t**)myhtml_realloc(mcsimple->list, mcsimple->list_pos_size * sizeof(uint8_t*));
+ uint8_t **list = (uint8_t**)mycore_realloc(mcsimple->list, mcsimple->list_pos_size * sizeof(uint8_t*));
if(list) {
mcsimple->list = list;
@@ -94,7 +94,7 @@ uint8_t * mcsimple_init_list_entries(mcsimple_t *mcsimple, size_t pos)
if(mcsimple->list[pos] == NULL) {
mcsimple->list_pos_length_used++;
- mcsimple->list[pos] = (uint8_t*)myhtml_malloc(mcsimple->list_size * sizeof(uint8_t));
+ mcsimple->list[pos] = (uint8_t*)mycore_malloc(mcsimple->list_size * sizeof(uint8_t));
}
return mcsimple->list[pos];
diff --git a/source/myhtml/utils/mcsimple.h b/source/mycore/utils/mcsimple.h
index be972d9..9eae399 100644
--- a/source/myhtml/utils/mcsimple.h
+++ b/source/mycore/utils/mcsimple.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,15 +18,15 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_MCSIMPLE_H
-#define MyHTML_UTILS_MCSIMPLE_H
+#ifndef MyCORE_UTILS_MCSIMPLE_H
+#define MyCORE_UTILS_MCSIMPLE_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-#include "myhtml/myosi.h"
+#include "mycore/myosi.h"
struct mcsimple {
size_t struct_size;
@@ -57,5 +57,5 @@ void * mcsimple_get_by_absolute_position(mcsimple_t *mcsimple, size_t pos);
} /* extern "C" */
#endif
-#endif /* MyHTML_UTILS_MCSIMPLE_H */
+#endif /* MyCORE_UTILS_MCSIMPLE_H */
diff --git a/source/mycore/utils/mcsync.c b/source/mycore/utils/mcsync.c
new file mode 100644
index 0000000..e5e0399
--- /dev/null
+++ b/source/mycore/utils/mcsync.c
@@ -0,0 +1,99 @@
+/*
+ Copyright (C) 2015-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 "mycore/utils/mcsync.h"
+
+mcsync_t * mcsync_create(void)
+{
+ return mycore_calloc(1, sizeof(mcsync_t));
+}
+
+
+
+mcsync_status_t mcsync_init(mcsync_t* mcsync)
+{
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ /* spinlock */
+ if((mcsync->spinlock = mcsync_spin_create()) == NULL)
+ return MCSYNC_STATUS_NOT_OK;
+
+ mcsync_status_t status = mcsync_spin_init(mcsync->spinlock);
+ if(status) {
+ mcsync_spin_destroy(mcsync->spinlock);
+ return status;
+ }
+
+ /* mutex */
+ if((mcsync->mutex = mcsync_mutex_create()) == NULL)
+ return MCSYNC_STATUS_NOT_OK;
+
+ if((status = mcsync_mutex_init(mcsync->mutex))) {
+ mcsync_spin_destroy(mcsync->spinlock);
+ mcsync_mutex_destroy(mcsync->mutex);
+
+ return status;
+ }
+#endif
+
+ return MCSYNC_STATUS_OK;
+}
+
+void mcsync_clean(mcsync_t* mcsync)
+{
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ mcsync_spin_clean(mcsync->spinlock);
+ mcsync_mutex_clean(mcsync->mutex);
+#endif
+}
+
+mcsync_t * mcsync_destroy(mcsync_t* mcsync, int destroy_self)
+{
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ if(mcsync == NULL)
+ return NULL;
+
+ mcsync_spin_destroy(mcsync->spinlock);
+ mcsync_mutex_destroy(mcsync->mutex);
+#endif
+ if(destroy_self) {
+ mycore_free(mcsync);
+ return NULL;
+ }
+
+ return mcsync;
+}
+
+mcsync_status_t mcsync_lock(mcsync_t* mcsync)
+{
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ return mcsync_spin_lock(mcsync->spinlock);
+#else
+ return MCSYNC_STATUS_OK;
+#endif
+}
+
+mcsync_status_t mcsync_unlock(mcsync_t* mcsync)
+{
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ return mcsync_spin_unlock(mcsync->spinlock);
+#else
+ return MCSYNC_STATUS_OK;
+#endif
+}
diff --git a/source/myhtml/utils/mcsync.h b/source/mycore/utils/mcsync.h
index 671aa1a..80fa896 100644
--- a/source/myhtml/utils/mcsync.h
+++ b/source/mycore/utils/mcsync.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,41 +18,26 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_MCSYNC_H
-#define MyHTML_UTILS_MCSYNC_H
+#ifndef MyCORE_UTILS_MCSYNC_H
+#define MyCORE_UTILS_MCSYNC_H
#pragma once
+#include "mycore/myosi.h"
+
#ifdef __cplusplus
extern "C" {
#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-
-#include "myhtml/myosi.h"
-
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS)
-#if defined(IS_OS_WINDOWS)
- typedef CRITICAL_SECTION pthread_mutex_t;
- typedef unsigned long pthread_mutexattr_t;
-#else
-# include <pthread.h>
-#endif
-#endif
enum mcsync_status {
- MCSYNC_STATUS_OK = 0,
- MCSYNC_STATUS_NOT_OK = 1,
- MCSYNC_STATUS_ERROR_MEM_ALLOCATE = 2
+ MCSYNC_STATUS_OK = 0x00,
+ MCSYNC_STATUS_NOT_OK = 0x01,
+ MCSYNC_STATUS_ERROR_MEM_ALLOCATE = 0x02
}
typedef mcsync_status_t;
struct mcsync {
- int spinlock;
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS)
- pthread_mutex_t *mutex;
-#endif
+ int* spinlock;
+ void* mutex;
}
typedef mcsync_t;
@@ -61,17 +46,26 @@ mcsync_status_t mcsync_init(mcsync_t* mcsync);
void mcsync_clean(mcsync_t* mcsync);
mcsync_t * mcsync_destroy(mcsync_t* mcsync, int destroy_self);
-mcsync_status_t mcsync_lock(mcsync_t* mclock);
-mcsync_status_t mcsync_unlock(mcsync_t* mclock);
+mcsync_status_t mcsync_lock(mcsync_t* mcsync);
+mcsync_status_t mcsync_unlock(mcsync_t* mcsync);
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+mcsync_status_t mcsync_spin_lock(void* spinlock);
+mcsync_status_t mcsync_spin_unlock(void* spinlock);
+
+mcsync_status_t mcsync_mutex_lock(void* mutex);
+mcsync_status_t mcsync_mutex_try_lock(void* mutex);
+mcsync_status_t mcsync_mutex_unlock(void* mutex);
-mcsync_status_t mcsync_mutex_lock(mcsync_t* mclock);
-mcsync_status_t mcsync_mutex_unlock(mcsync_t* mclock);
+void * mcsync_spin_create(void);
+mcsync_status_t mcsync_spin_init(void* spinlock);
+void mcsync_spin_clean(void* spinlock);
+void mcsync_spin_destroy(void* spinlock);
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && defined(IS_OS_WINDOWS)
- static int pthread_mutex_lock(pthread_mutex_t *mutex);
- static int pthread_mutex_unlock(pthread_mutex_t *mutex);
- static int pthread_mutex_init(pthread_mutex_t *m, pthread_mutexattr_t *a);
- static int pthread_mutex_destroy(pthread_mutex_t *m);
+void * mcsync_mutex_create(void);
+mcsync_status_t mcsync_mutex_init(void* mutex);
+void mcsync_mutex_clean(void* mutex);
+void mcsync_mutex_destroy(void* mutex);
#endif
#ifdef __cplusplus
diff --git a/source/myhtml/utils/mctree.c b/source/mycore/utils/mctree.c
index 526560c..6d5e281 100644
--- a/source/myhtml/utils/mctree.c
+++ b/source/mycore/utils/mctree.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,17 +18,24 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/utils/resources.h"
-#include "myhtml/utils/mctree.h"
-
+#include "mycore/utils/resources.h"
+#include "mycore/utils/mctree.h"
mctree_t * mctree_create(size_t start_size)
{
- mctree_t* mctree = (mctree_t*)myhtml_malloc(sizeof(mctree_t));
+ mctree_t* mctree = (mctree_t*)mycore_malloc(sizeof(mctree_t));
+
+ if(mctree == NULL)
+ return NULL;
mctree->nodes_size = start_size + 512;
mctree->nodes_length = start_size + 1;
- mctree->nodes = (mctree_node_t*)myhtml_calloc(mctree->nodes_size, sizeof(mctree_node_t));
+ mctree->nodes = (mctree_node_t*)mycore_calloc(mctree->nodes_size, sizeof(mctree_node_t));
+
+ if(mctree->nodes == NULL) {
+ mycore_free(mctree);
+ return NULL;
+ }
mctree->start_size = start_size;
@@ -47,9 +54,9 @@ mctree_t * mctree_destroy(mctree_t* mctree)
return NULL;
if(mctree->nodes)
- myhtml_free(mctree->nodes);
+ mycore_free(mctree->nodes);
- myhtml_free(mctree);
+ mycore_free(mctree);
return NULL;
}
@@ -61,7 +68,7 @@ mctree_index_t __mtree_search_lowercase_to_start(mctree_t* mctree, mctree_index_
while (idx)
{
if(key_size == nodes[idx].str_size) {
- if(myhtml_strncasecmp(key, nodes[idx].str, key_size) == 0) {
+ if(mycore_strncasecmp(key, nodes[idx].str, key_size) == 0) {
return idx;
}
diff --git a/include/myhtml/utils/mctree.h b/source/mycore/utils/mctree.h
index aaf79c0..2d848c3 100644
--- a/include/myhtml/utils/mctree.h
+++ b/source/mycore/utils/mctree.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,21 +18,21 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_MCTREE_H
-#define MyHTML_UTILS_MCTREE_H
+#ifndef MyCORE_UTILS_MCTREE_H
+#define MyCORE_UTILS_MCTREE_H
#pragma once
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <myhtml/myosi.h>
-#include <myhtml/utils.h>
+#include "mycore/myosi.h"
+#include "mycore/utils.h"
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define mctree_node_get_free_id(mctree) mctree->nodes_length
#define mctree_node_clean(mctree, idx) \
@@ -47,13 +47,13 @@ extern "C" {
mctree->nodes_length++; \
if(mctree->nodes_length >= mctree->nodes_size) { \
mctree->nodes_size = mctree->nodes_length + 4096; \
- mctree->nodes = (mctree_node_t*)myhtml_realloc(mctree->nodes, \
+ mctree->nodes = (mctree_node_t*)mycore_realloc(mctree->nodes, \
sizeof(mctree_node_t) * mctree->nodes_size); \
} \
mctree_node_clean(mctree, mctree->nodes_length)
#define mctree_make_first_idx(mctree, key, size) \
- ((myhtml_string_chars_lowercase_map[ (const unsigned char)(key[0]) ] + myhtml_string_chars_lowercase_map[ (const unsigned char)(key[size - 1]) ]) % mctree->start_size) + 1
+ ((mycore_string_chars_lowercase_map[ (const unsigned char)(key[0]) ] + mycore_string_chars_lowercase_map[ (const unsigned char)(key[size - 1]) ]) % mctree->start_size) + 1
typedef size_t mctree_index_t;
diff --git a/source/myhtml/utils/mhash.c b/source/mycore/utils/mhash.c
index 1929f26..6d0f627 100644
--- a/source/myhtml/utils/mhash.c
+++ b/source/mycore/utils/mhash.c
@@ -18,9 +18,9 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/utils/mhash.h"
+#include "mycore/utils/mhash.h"
-size_t myhtml_utils_mhash_hash(const char* key, size_t key_size, size_t table_size)
+size_t mycore_utils_mhash_hash(const char* key, size_t key_size, size_t table_size)
{
size_t hash, i;
@@ -38,25 +38,33 @@ size_t myhtml_utils_mhash_hash(const char* key, size_t key_size, size_t table_si
return hash % table_size;
}
-myhtml_utils_mhash_t * myhtml_utils_mhash_create(void)
+mycore_utils_mhash_t * mycore_utils_mhash_create(void)
{
- return myhtml_calloc(1, sizeof(myhtml_utils_mhash_t));
-};
+ return mycore_calloc(1, sizeof(mycore_utils_mhash_t));
+}
-myhtml_status_t myhtml_utils_mhash_init(myhtml_utils_mhash_t* mhash, size_t table_size, size_t max_depth)
+mystatus_t mycore_utils_mhash_init(mycore_utils_mhash_t* mhash, size_t table_size, size_t max_depth)
{
- mhash->mchar_obj = mchar_async_create(128, 4096);
+ mystatus_t status;
+
+ mhash->mchar_obj = mchar_async_create();
if(mhash->mchar_obj == NULL)
- return MyHTML_STATUS_ATTR_ERROR_ALLOCATION;
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
- mhash->mchar_node = mchar_async_node_add(mhash->mchar_obj);
+ if((status = mchar_async_init(mhash->mchar_obj, 128, 4096)))
+ return status;
+
+ /* nodest data for input char* */
+ mhash->mchar_node = mchar_async_node_add(mhash->mchar_obj, &status);
+ if(status)
+ return status;
if(table_size < 128)
table_size = 128;
- mhash->table = myhtml_calloc(table_size, sizeof(myhtml_utils_mhash_entry_t*));
+ mhash->table = mycore_calloc(table_size, sizeof(mycore_utils_mhash_entry_t*));
if(mhash->table == NULL)
- return MyHTML_STATUS_ATTR_ERROR_ALLOCATION;
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
if(max_depth < 1)
max_depth = 1;
@@ -64,37 +72,37 @@ myhtml_status_t myhtml_utils_mhash_init(myhtml_utils_mhash_t* mhash, size_t tabl
mhash->table_max_depth = max_depth;
mhash->table_size = table_size;
- return MyHTML_STATUS_OK;
-};
+ return MyCORE_STATUS_OK;
+}
-void myhtml_utils_mhash_clean(myhtml_utils_mhash_t* mhash)
+void mycore_utils_mhash_clean(mycore_utils_mhash_t* mhash)
{
mchar_async_clean(mhash->mchar_obj);
- memset(mhash->table, 0, (sizeof(myhtml_utils_mhash_entry_t*) * mhash->table_size));
+ memset(mhash->table, 0, (sizeof(mycore_utils_mhash_entry_t*) * mhash->table_size));
}
-myhtml_utils_mhash_t * myhtml_utils_mhash_destroy(myhtml_utils_mhash_t* mhash, bool self_destroy)
+mycore_utils_mhash_t * mycore_utils_mhash_destroy(mycore_utils_mhash_t* mhash, bool self_destroy)
{
if(mhash == NULL)
return NULL;
if(mhash->table) {
- myhtml_free(mhash->table);
+ mycore_free(mhash->table);
mhash->table = NULL;
}
if(self_destroy) {
- myhtml_free(mhash->table);
+ mycore_free(mhash->table);
return NULL;
}
return mhash;
}
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_create_entry(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value)
+mycore_utils_mhash_entry_t * mycore_utils_mhash_create_entry(mycore_utils_mhash_t* mhash, const char* key, size_t key_size, void* value)
{
- myhtml_utils_mhash_entry_t *entry = (myhtml_utils_mhash_entry_t*)
- mchar_async_malloc(mhash->mchar_obj, mhash->mchar_node, sizeof(myhtml_utils_mhash_entry_t));
+ mycore_utils_mhash_entry_t *entry = (mycore_utils_mhash_entry_t*)
+ mchar_async_malloc(mhash->mchar_obj, mhash->mchar_node, sizeof(mycore_utils_mhash_entry_t));
entry->key = mchar_async_malloc(mhash->mchar_obj, mhash->mchar_node, (sizeof(char) * key_size) + 1);
@@ -113,23 +121,23 @@ myhtml_utils_mhash_entry_t * myhtml_utils_mhash_create_entry(myhtml_utils_mhash_
return entry;
}
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add_with_choice(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size)
+mycore_utils_mhash_entry_t * mycore_utils_mhash_add_with_choice(mycore_utils_mhash_t* mhash, const char* key, size_t key_size)
{
if(key == NULL || key_size == 0)
return NULL;
- size_t hash_id = myhtml_utils_mhash_hash(key, key_size, mhash->table_size);
+ size_t hash_id = mycore_utils_mhash_hash(key, key_size, mhash->table_size);
- myhtml_utils_mhash_entry_t *entry;
+ mycore_utils_mhash_entry_t *entry;
if(mhash->table[hash_id] == NULL) {
/* rebuild table if need */
if(mhash->table_length >= (mhash->table_size - (mhash->table_size / 4))) {
- myhtml_utils_mhash_rebuld(mhash);
+ mycore_utils_mhash_rebuld(mhash);
}
- mhash->table[hash_id] = myhtml_utils_mhash_create_entry(mhash, key, key_size, NULL);
+ mhash->table[hash_id] = mycore_utils_mhash_create_entry(mhash, key, key_size, NULL);
return mhash->table[hash_id];
}
@@ -143,11 +151,11 @@ myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add_with_choice(myhtml_utils_mha
}
if(entry->next == NULL) {
- entry->next = myhtml_utils_mhash_create_entry(mhash, key, key_size, NULL);
+ entry->next = mycore_utils_mhash_create_entry(mhash, key, key_size, NULL);
if(depth > mhash->table_max_depth) {
- myhtml_utils_mhash_entry_t *entry_new = entry->next;
- myhtml_utils_mhash_rebuld(mhash);
+ mycore_utils_mhash_entry_t *entry_new = entry->next;
+ mycore_utils_mhash_rebuld(mhash);
return entry_new;
}
@@ -161,9 +169,9 @@ myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add_with_choice(myhtml_utils_mha
while(1);
}
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value)
+mycore_utils_mhash_entry_t * mycore_utils_mhash_add(mycore_utils_mhash_t* mhash, const char* key, size_t key_size, void* value)
{
- myhtml_utils_mhash_entry_t *entry = myhtml_utils_mhash_add_with_choice(mhash, key, key_size);
+ mycore_utils_mhash_entry_t *entry = mycore_utils_mhash_add_with_choice(mhash, key, key_size);
if(entry)
entry->value = value;
@@ -171,14 +179,14 @@ myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add(myhtml_utils_mhash_t* mhash,
return entry;
}
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_search(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value)
+mycore_utils_mhash_entry_t * mycore_utils_mhash_search(mycore_utils_mhash_t* mhash, const char* key, size_t key_size, void* value)
{
if(key == NULL || key_size == 0)
return NULL;
- size_t hash_id = myhtml_utils_mhash_hash(key, key_size, mhash->table_size);
+ size_t hash_id = mycore_utils_mhash_hash(key, key_size, mhash->table_size);
- myhtml_utils_mhash_entry_t *entry = mhash->table[hash_id];
+ mycore_utils_mhash_entry_t *entry = mhash->table[hash_id];
while(entry) {
if(entry->key_length == key_size) {
@@ -192,7 +200,7 @@ myhtml_utils_mhash_entry_t * myhtml_utils_mhash_search(myhtml_utils_mhash_t* mha
return NULL;
}
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_entry_by_id(myhtml_utils_mhash_t* mhash, size_t id)
+mycore_utils_mhash_entry_t * mycore_utils_mhash_entry_by_id(mycore_utils_mhash_t* mhash, size_t id)
{
if(mhash->table_size > id)
return mhash->table[id];
@@ -200,26 +208,26 @@ myhtml_utils_mhash_entry_t * myhtml_utils_mhash_entry_by_id(myhtml_utils_mhash_t
return NULL;
}
-size_t myhtml_utils_mhash_get_table_size(myhtml_utils_mhash_t* mhash)
+size_t mycore_utils_mhash_get_table_size(mycore_utils_mhash_t* mhash)
{
return mhash->table_size;
}
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_rebuild_add_entry(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, myhtml_utils_mhash_entry_t *ext_entry)
+mycore_utils_mhash_entry_t * mycore_utils_mhash_rebuild_add_entry(mycore_utils_mhash_t* mhash, const char* key, size_t key_size, mycore_utils_mhash_entry_t *ext_entry)
{
if(key == NULL || key_size == 0)
return NULL;
ext_entry->next = NULL;
- size_t hash_id = myhtml_utils_mhash_hash(key, key_size, mhash->table_size);
+ size_t hash_id = mycore_utils_mhash_hash(key, key_size, mhash->table_size);
if(mhash->table[hash_id] == NULL) {
mhash->table[hash_id] = ext_entry;
return ext_entry;
}
- myhtml_utils_mhash_entry_t *entry = mhash->table[hash_id];
+ mycore_utils_mhash_entry_t *entry = mhash->table[hash_id];
do {
if(entry->next == NULL) {
@@ -234,13 +242,13 @@ myhtml_utils_mhash_entry_t * myhtml_utils_mhash_rebuild_add_entry(myhtml_utils_m
return ext_entry;
}
-myhtml_utils_mhash_entry_t ** myhtml_utils_mhash_rebuld(myhtml_utils_mhash_t* mhash)
+mycore_utils_mhash_entry_t ** mycore_utils_mhash_rebuld(mycore_utils_mhash_t* mhash)
{
- myhtml_utils_mhash_entry_t **table = mhash->table;
+ mycore_utils_mhash_entry_t **table = mhash->table;
size_t size = mhash->table_size;
mhash->table_size = mhash->table_size << 1;
- mhash->table = myhtml_calloc(mhash->table_size, sizeof(myhtml_utils_mhash_entry_t*));
+ mhash->table = mycore_calloc(mhash->table_size, sizeof(mycore_utils_mhash_entry_t*));
if(mhash->table == NULL) {
mhash->table = table;
@@ -250,16 +258,16 @@ myhtml_utils_mhash_entry_t ** myhtml_utils_mhash_rebuld(myhtml_utils_mhash_t* mh
}
for(size_t i = 0; i < mhash->table_size; i++) {
- myhtml_utils_mhash_entry_t *entry = table[i];
+ mycore_utils_mhash_entry_t *entry = table[i];
while(entry) {
- myhtml_utils_mhash_rebuild_add_entry(mhash, entry->key, entry->key_length, entry);
+ mycore_utils_mhash_rebuild_add_entry(mhash, entry->key, entry->key_length, entry);
entry = entry->next;
}
}
- myhtml_free(table);
+ mycore_free(table);
return mhash->table;
}
diff --git a/source/mycore/utils/mhash.h b/source/mycore/utils/mhash.h
new file mode 100644
index 0000000..c90a30c
--- /dev/null
+++ b/source/mycore/utils/mhash.h
@@ -0,0 +1,75 @@
+/*
+ Copyright (C) 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 avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#ifndef MyCORE_UTILS_MHASH_H
+#define MyCORE_UTILS_MHASH_H
+
+#include <string.h>
+
+#include "mycore/myosi.h"
+#include "mycore/utils/mchar_async.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct mycore_utils_mhash_entry mycore_utils_mhash_entry_t;
+
+struct mycore_utils_mhash_entry {
+ char* key;
+ size_t key_length;
+
+ void *value;
+
+ mycore_utils_mhash_entry_t* next;
+};
+
+struct mycore_utils_mhash {
+ mchar_async_t* mchar_obj;
+ size_t mchar_node;
+
+ mycore_utils_mhash_entry_t** table;
+ size_t table_size;
+ size_t table_length;
+
+ size_t table_max_depth;
+}
+typedef mycore_utils_mhash_t;
+
+mycore_utils_mhash_t * mycore_utils_mhash_create(void);
+mystatus_t mycore_utils_mhash_init(mycore_utils_mhash_t* mhash, size_t table_size, size_t depth);
+void mycore_utils_mhash_clean(mycore_utils_mhash_t* mhash);
+mycore_utils_mhash_t * mycore_utils_mhash_destroy(mycore_utils_mhash_t* mhash, bool self_destroy);
+mycore_utils_mhash_entry_t * mycore_utils_mhash_create_entry(mycore_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
+
+mycore_utils_mhash_entry_t * mycore_utils_mhash_add(mycore_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
+mycore_utils_mhash_entry_t * mycore_utils_mhash_search(mycore_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
+mycore_utils_mhash_entry_t * mycore_utils_mhash_add_with_choice(mycore_utils_mhash_t* mhash, const char* key, size_t key_size);
+
+mycore_utils_mhash_entry_t * mycore_utils_mhash_entry_by_id(mycore_utils_mhash_t* mhash, size_t id);
+size_t mycore_utils_mhash_get_table_size(mycore_utils_mhash_t* mhash);
+
+mycore_utils_mhash_entry_t ** mycore_utils_mhash_rebuld(mycore_utils_mhash_t* mhash);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyCORE_UTILS_MHASH_H */
diff --git a/source/myhtml/utils/resources.h b/source/mycore/utils/resources.h
index beee061..da99a00 100644
--- a/source/myhtml/utils/resources.h
+++ b/source/mycore/utils/resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,17 +18,17 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_UTILS_RESOURCES_H
-#define MyHTML_UTILS_RESOURCES_H
+#ifndef MyCORE_UTILS_RESOURCES_H
+#define MyCORE_UTILS_RESOURCES_H
#pragma once
#include <stddef.h>
-#define MyHTML_TOKENIZER_CHAR_OTHER '\000'
-#define MyHTML_TOKENIZER_CHAR_A_Z_a_z '\001'
-#define MyHTML_TOKENIZER_CHAR_WHITESPACE '\002'
+#define MyCORE_STRING_MAP_CHAR_OTHER '\000'
+#define MyCORE_STRING_MAP_CHAR_A_Z_a_z '\001'
+#define MyCORE_STRING_MAP_CHAR_WHITESPACE '\002'
-static const unsigned char myhtml_string_chars_num_map[] = {
+static const unsigned char mycore_string_chars_num_map[] = {
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,
@@ -60,7 +60,7 @@ static const unsigned char myhtml_string_chars_num_map[] = {
0xff, 0xff, 0xff, 0xff
};
-static const unsigned char myhtml_string_chars_hex_map[] = {
+static const unsigned char mycore_string_chars_hex_map[] = {
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,
@@ -92,7 +92,7 @@ static const unsigned char myhtml_string_chars_hex_map[] = {
0xff, 0xff, 0xff, 0xff
};
-static const unsigned char myhtml_string_chars_lowercase_map[] = {
+static const unsigned char mycore_string_chars_lowercase_map[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
@@ -124,6 +124,38 @@ static const unsigned char myhtml_string_chars_lowercase_map[] = {
0xfc, 0xfd, 0xfe, 0xff
};
+static const unsigned char mycore_string_chars_uppercase_map[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
+ 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
+ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 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, 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, 0x7b, 0x7c, 0x7d,
+ 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86,
+ 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
+ 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1,
+ 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa,
+ 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3,
+ 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc,
+ 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5,
+ 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce,
+ 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0,
+ 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
+ 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2,
+ 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb,
+ 0xfc, 0xfd, 0xfe, 0xff
+};
+
static const size_t replacement_character[] = {
65533, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17,
@@ -145,7 +177,7 @@ static const size_t replacement_character[] = {
8482, 353, 8250, 339, 157, 382, 376
};
-static const size_t myhtml_string_alphanumeric_character[] = {
+static const size_t mycore_string_alphanumeric_character[] = {
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,
@@ -177,7 +209,39 @@ static const size_t myhtml_string_alphanumeric_character[] = {
0xff, 0xff, 0xff, 0xff
};
-static const unsigned char myhtml_tokenizer_chars_map[] = {
+static const size_t mycore_string_alpha_character[] = {
+ 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, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a,
+ 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d,
+ 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a,
+ 0x0b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x0d,
+ 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a,
+ 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d,
+ 0x0e, 0x0f, 0x0a, 0x0b, 0x0c, 0x0d, 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, 0xff, 0xff, 0xff
+};
+
+static const unsigned char mycore_tokenizer_chars_map[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -209,9 +273,45 @@ static const unsigned char myhtml_tokenizer_chars_map[] = {
0x00, 0x00, 0x00, 0x00
};
-static const unsigned char myhtml_string_hex_to_char_map[] = {
+static const unsigned char mycore_string_hex_to_char_map[] = {
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x00
};
-#endif /* MyHTML_UTILS_RESOURCES_H */
+static const char * mycore_string_char_to_two_hex_value[257] = {
+ "00", "01", "02", "03", "04", "05", "06", "07",
+ "08", "09", "0A", "0B", "0C", "0D", "0E", "0F",
+ "10", "11", "12", "13", "14", "15", "16", "17",
+ "18", "19", "1A", "1B", "1C", "1D", "1E", "1F",
+ "20", "21", "22", "23", "24", "25", "26", "27",
+ "28", "29", "2A", "2B", "2C", "2D", "2E", "2F",
+ "30", "31", "32", "33", "34", "35", "36", "37",
+ "38", "39", "3A", "3B", "3C", "3D", "3E", "3F",
+ "40", "41", "42", "43", "44", "45", "46", "47",
+ "48", "49", "4A", "4B", "4C", "4D", "4E", "4F",
+ "50", "51", "52", "53", "54", "55", "56", "57",
+ "58", "59", "5A", "5B", "5C", "5D", "5E", "5F",
+ "60", "61", "62", "63", "64", "65", "66", "67",
+ "68", "69", "6A", "6B", "6C", "6D", "6E", "6F",
+ "70", "71", "72", "73", "74", "75", "76", "77",
+ "78", "79", "7A", "7B", "7C", "7D", "7E", "7F",
+ "80", "81", "82", "83", "84", "85", "86", "87",
+ "88", "89", "8A", "8B", "8C", "8D", "8E", "8F",
+ "90", "91", "92", "93", "94", "95", "96", "97",
+ "98", "99", "9A", "9B", "9C", "9D", "9E", "9F",
+ "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
+ "A8", "A9", "AA", "AB", "AC", "AD", "AE", "AF",
+ "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7",
+ "B8", "B9", "BA", "BB", "BC", "BD", "BE", "BF",
+ "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7",
+ "C8", "C9", "CA", "CB", "CC", "CD", "CE", "CF",
+ "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
+ "D8", "D9", "DA", "DB", "DC", "DD", "DE", "DF",
+ "E0", "E1", "E2", "E3", "E4", "E5", "E6", "E7",
+ "E8", "E9", "EA", "EB", "EC", "ED", "EE", "EF",
+ "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7",
+ "F8", "F9", "FA", "FB", "FC", "FD", "FE", "FF",
+ NULL
+};
+
+#endif /* MyCORE_UTILS_RESOURCES_H */
diff --git a/source/mycss/Makefile.mk b/source/mycss/Makefile.mk
index 3303402..51005aa 100644
--- a/source/mycss/Makefile.mk
+++ b/source/mycss/Makefile.mk
@@ -1,12 +1,13 @@
-find_files_h = $(wildcard $(SRCDIR)/mycss/$(dir)/*.h)
-find_files_c = $(wildcard $(SRCDIR)/mycss/$(dir)/*.c)
+mycss_dirs := . selectors namespace media values property declaration
+mycss_objs := $(call MODEST_UTILS_OBJS,mycss,$(mycss_dirs))
-SUBDIRS := . selectors namespace media values property declaration
-HDRS += $(foreach dir,$(SUBDIRS),$(find_files_h))
-SRCS += $(foreach dir,$(SUBDIRS),$(find_files_c))
+mycss_description := CSS parser and modules by https://drafts.csswg.org/
+mycss_dependencies := mycore myencoding myport
-mycss_clone: MyCSS_DIR_$(SUBDIRS)
+mycss_all: $(mycss_objs)
-MyCSS_DIR_$(SUBDIRS):
- mkdir -p $(INCLUDE_TMP)/mycss/$(patsubst MyCSS_DIR_%,%,$@)
- cp $(SRCDIR)/mycss/$(patsubst MyCSS_DIR_%,%,$@)/*.h $(INCLUDE_TMP)/mycss/$(patsubst MyCSS_DIR_%,%,$@)/
+mycss_clean:
+ rm -f $(mycss_objs)
+
+mycss_clone:
+ $(call MODEST_UTILS_HDRS_CLONE,mycss,$(mycss_dirs))
diff --git a/source/mycss/an_plus_b.c b/source/mycss/an_plus_b.c
index c8b1b8f..038e0d6 100644
--- a/source/mycss/an_plus_b.c
+++ b/source/mycss/an_plus_b.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -19,19 +19,19 @@
*/
#include "mycss/an_plus_b.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
mycss_an_plus_b_t * mycss_an_plus_b_create(void)
{
- return (mycss_an_plus_b_t*)myhtml_calloc(1, sizeof(mycss_an_plus_b_t));
+ return (mycss_an_plus_b_t*)mycore_calloc(1, sizeof(mycss_an_plus_b_t));
}
-mycss_status_t mycss_an_plus_b_init(mycss_entry_t* entry, mycss_an_plus_b_t* anb)
+mystatus_t mycss_an_plus_b_init(mycss_entry_t* entry, mycss_an_plus_b_t* anb)
{
return MyCSS_STATUS_OK;
}
-mycss_status_t mycss_an_plus_b_clean_all(mycss_an_plus_b_t* anb)
+mystatus_t mycss_an_plus_b_clean_all(mycss_an_plus_b_t* anb)
{
return MyCSS_STATUS_OK;
}
@@ -42,7 +42,7 @@ mycss_an_plus_b_t * mycss_an_plus_b_destroy(mycss_an_plus_b_t* anb, bool self_de
return NULL;
if(self_destroy) {
- myhtml_free(anb);
+ mycore_free(anb);
return NULL;
}
@@ -91,7 +91,7 @@ void mycss_an_plus_b_parser_expectations_error(mycss_entry_t* entry)
//// An+B Serialization
////
/////////////////////////////////////////////////////////
-void mycss_an_plus_b_serialization(mycss_an_plus_b_entry_t* anb_entry, mycss_callback_serialization_f callback, void* context)
+void mycss_an_plus_b_serialization(mycss_an_plus_b_entry_t* anb_entry, mycore_callback_serialize_f callback, void* context)
{
char data[512];
@@ -137,10 +137,10 @@ bool mycss_an_plus_b_state_anb(mycss_entry_t* entry, mycss_token_t* token, bool
case MyCSS_TOKEN_TYPE_WHITESPACE:
break;
case MyCSS_TOKEN_TYPE_IDENT: {
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, false);
- if(myhtml_strncasecmp(str.data, "-n-", 3) == 0)
+ if(mycore_strncasecmp(str.data, "-n-", 3) == 0)
{
anb_entry->a = -1;
@@ -149,7 +149,7 @@ bool mycss_an_plus_b_state_anb(mycss_entry_t* entry, mycss_token_t* token, bool
entry->parser = mycss_an_plus_b_state_anb_plus_n_hyphen;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
return true;
}
/* -n-* */
@@ -159,18 +159,18 @@ bool mycss_an_plus_b_state_anb(mycss_entry_t* entry, mycss_token_t* token, bool
anb_entry->is_broken = true;
}
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_hyphen_n_hyphen_asterisk_end");
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_hyphen_n_hyphen_asterisk_end");
entry->parser = entry->parser_switch;
}
- else if(myhtml_strncasecmp(str.data, "-n", 2) == 0) {
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_hyphen_n_end")
+ else if(mycore_strncasecmp(str.data, "-n", 2) == 0) {
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_hyphen_n_end");
anb_entry->a = -1;
if(str.length == 2) {
entry->parser = mycss_an_plus_b_state_anb_plus_n;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
return true;
}
@@ -182,14 +182,14 @@ bool mycss_an_plus_b_state_anb(mycss_entry_t* entry, mycss_token_t* token, bool
entry->parser = entry->parser_switch;
}
- else if(myhtml_strncasecmp(str.data, "n-", 2) == 0)
+ else if(mycore_strncasecmp(str.data, "n-", 2) == 0)
{
anb_entry->a = 1;
if(str.length == 2) {
entry->parser = mycss_an_plus_b_state_anb_plus_n_hyphen;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
return true;
}
@@ -199,17 +199,17 @@ bool mycss_an_plus_b_state_anb(mycss_entry_t* entry, mycss_token_t* token, bool
anb_entry->is_broken = true;
}
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_n");
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_n");
entry->parser = entry->parser_switch;
}
- else if(myhtml_strncasecmp(str.data, "n", 1) == 0)
+ else if(mycore_strncasecmp(str.data, "n", 1) == 0)
{
anb_entry->a = 1;
if(str.length == 1) {
entry->parser = mycss_an_plus_b_state_anb_plus_n;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
return true;
}
@@ -219,32 +219,32 @@ bool mycss_an_plus_b_state_anb(mycss_entry_t* entry, mycss_token_t* token, bool
anb_entry->is_broken = true;
}
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_n");
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_n");
entry->parser = entry->parser_switch;
}
- else if(myhtml_strcasecmp(str.data, "even") == 0) {
+ else if(mycore_strcasecmp(str.data, "even") == 0) {
anb_entry->a = 2;
anb_entry->b = 0;
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_e_v_e_n")
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_e_v_e_n");
entry->parser = entry->parser_switch;
}
- else if(myhtml_strcasecmp(str.data, "odd") == 0) {
+ else if(mycore_strcasecmp(str.data, "odd") == 0) {
anb_entry->a = 2;
anb_entry->b = 1;
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_o_d_d")
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_o_d_d");
entry->parser = entry->parser_switch;
}
else {
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
mycss_an_plus_b_parser_expectations_error(entry);
entry->parser = entry->parser_switch;
return false;
}
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
break;
}
case MyCSS_TOKEN_TYPE_DELIM: {
@@ -261,31 +261,31 @@ bool mycss_an_plus_b_state_anb(mycss_entry_t* entry, mycss_token_t* token, bool
break;
}
case MyCSS_TOKEN_TYPE_NUMBER: {
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, false);
mycss_convert_data_to_integer(str.data, str.length, &anb_entry->b);
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_number")
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_number");
entry->parser = entry->parser_switch;
break;
}
case MyCSS_TOKEN_TYPE_DIMENSION: {
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, false);
size_t consumed_len = mycss_convert_data_to_integer(str.data, str.length, &anb_entry->a);
- if(myhtml_strncasecmp(&str.data[consumed_len], "n-", 2) == 0)
+ if(mycore_strncasecmp(&str.data[consumed_len], "n-", 2) == 0)
{
size_t rem = str.length - consumed_len;
if(rem == 2) {
entry->parser = mycss_an_plus_b_state_anb_plus_n_hyphen;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
return true;
}
@@ -295,17 +295,17 @@ bool mycss_an_plus_b_state_anb(mycss_entry_t* entry, mycss_token_t* token, bool
anb_entry->is_broken = true;
}
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_n_hyphen_asterisk_end")
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_n_hyphen_asterisk_end");
entry->parser = entry->parser_switch;
}
- else if(myhtml_strncasecmp(&str.data[consumed_len], "n", 1) == 0)
+ else if(mycore_strncasecmp(&str.data[consumed_len], "n", 1) == 0)
{
size_t rem = (str.length - consumed_len) - 1;
if(rem == 0) {
entry->parser = mycss_an_plus_b_state_anb_plus_n;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
return true;
}
@@ -314,18 +314,18 @@ bool mycss_an_plus_b_state_anb(mycss_entry_t* entry, mycss_token_t* token, bool
anb_entry->is_broken = true;
}
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_n_end")
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_n_end");
entry->parser = entry->parser_switch;
}
else {
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
mycss_an_plus_b_parser_expectations_error(entry);
entry->parser = entry->parser_switch;
return false;
}
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
break;
}
default: {
@@ -344,15 +344,15 @@ bool mycss_an_plus_b_state_anb_plus(mycss_entry_t* entry, mycss_token_t* token,
switch (token->type) {
case MyCSS_TOKEN_TYPE_IDENT: {
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, false);
- if(myhtml_strncasecmp(str.data, "n-", 2) == 0)
+ if(mycore_strncasecmp(str.data, "n-", 2) == 0)
{
if(str.length == 2) {
entry->parser = mycss_an_plus_b_state_anb_plus_n_hyphen;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
return true;
}
@@ -362,22 +362,22 @@ bool mycss_an_plus_b_state_anb_plus(mycss_entry_t* entry, mycss_token_t* token,
anb_entry->is_broken = true;
}
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_plus_n_hyphen_asterisk_end")
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_plus_n_hyphen_asterisk_end");
entry->parser = entry->parser_switch;
}
- else if(myhtml_strncasecmp(str.data, "n", 1) == 0) {
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_plus_n")
+ else if(mycore_strncasecmp(str.data, "n", 1) == 0) {
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_plus_n");
entry->parser = mycss_an_plus_b_state_anb_plus_n;
}
else {
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
mycss_an_plus_b_parser_expectations_error(entry);
entry->parser = entry->parser_switch;
return false;
}
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
break;
}
default: {
@@ -399,9 +399,9 @@ bool mycss_an_plus_b_state_anb_plus_n_hyphen(mycss_entry_t* entry, mycss_token_t
if(token->type == MyCSS_TOKEN_TYPE_NUMBER) {
/* begin from 0-9 */
- if(myhtml_string_chars_num_map[ (const unsigned char)(*token->data) ] != 0xff)
+ if(mycore_string_chars_num_map[ (const unsigned char)(*token->data) ] != 0xff)
{
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, false);
long res;
@@ -409,10 +409,10 @@ bool mycss_an_plus_b_state_anb_plus_n_hyphen(mycss_entry_t* entry, mycss_token_t
anb_entry->b = -res;
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_plus_n_hyphen_zero_hyphen_nine_end")
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_plus_n_hyphen_zero_hyphen_nine_end");
entry->parser = entry->parser_switch;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
}
else {
mycss_an_plus_b_parser_expectations_error(entry);
@@ -454,15 +454,15 @@ bool mycss_an_plus_b_state_anb_plus_n(mycss_entry_t* entry, mycss_token_t* token
case MyCSS_TOKEN_TYPE_NUMBER: {
if(*token->data == '+' || *token->data == '-')
{
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, false);
mycss_convert_data_to_integer(str.data, str.length, &anb_entry->b);
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_plus_n_begin_plus_vertical_bar_hyphen")
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_plus_n_begin_plus_vertical_bar_hyphen");
entry->parser = entry->parser_switch;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
}
else {
mycss_an_plus_b_parser_expectations_error(entry);
@@ -489,17 +489,17 @@ bool mycss_an_plus_b_state_anb_plus_n_plus(mycss_entry_t* entry, mycss_token_t*
if(token->type == MyCSS_TOKEN_TYPE_NUMBER) {
/* begin from 0-9 */
- if(myhtml_string_chars_num_map[ (const unsigned char)(*token->data) ] != 0xff)
+ if(mycore_string_chars_num_map[ (const unsigned char)(*token->data) ] != 0xff)
{
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, false);
mycss_convert_data_to_integer(str.data, str.length, &anb_entry->b);
- MyCSS_DEBUG_MESSAGE("mycss_an_plus_b_state_anb_plus_n_plus_zero_hyphen_nine_end")
+ MyCORE_DEBUG("mycss_an_plus_b_state_anb_plus_n_plus_zero_hyphen_nine_end");
entry->parser = entry->parser_switch;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
}
else {
mycss_an_plus_b_parser_expectations_error(entry);
diff --git a/source/mycss/an_plus_b.h b/source/mycss/an_plus_b.h
index fd52aa8..7faa35c 100644
--- a/source/mycss/an_plus_b.h
+++ b/source/mycss/an_plus_b.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -45,15 +45,15 @@ struct mycss_an_plus_b_entry {
};
mycss_an_plus_b_t * mycss_an_plus_b_create(void);
-mycss_status_t mycss_an_plus_b_init(mycss_entry_t* entry, mycss_an_plus_b_t* anb);
-mycss_status_t mycss_an_plus_b_clean_all(mycss_an_plus_b_t* anb);
+mystatus_t mycss_an_plus_b_init(mycss_entry_t* entry, mycss_an_plus_b_t* anb);
+mystatus_t mycss_an_plus_b_clean_all(mycss_an_plus_b_t* anb);
mycss_an_plus_b_t * mycss_an_plus_b_destroy(mycss_an_plus_b_t* anb, bool self_destroy);
mycss_an_plus_b_entry_t * mycss_an_plus_b_entry_create(mycss_entry_t* entry);
void mycss_an_plus_b_entry_clean_all(mycss_an_plus_b_entry_t* anb_entry);
mycss_an_plus_b_entry_t * mycss_an_plus_b_entry_destroy(mycss_entry_t* entry, mycss_an_plus_b_entry_t* anb_entry, bool self_destroy);
-void mycss_an_plus_b_serialization(mycss_an_plus_b_entry_t* anb_entry, mycss_callback_serialization_f callback, void* context);
+void mycss_an_plus_b_serialization(mycss_an_plus_b_entry_t* anb_entry, mycore_callback_serialize_f callback, void* context);
void mycss_an_plus_b_parser_expectations_error(mycss_entry_t* entry);
diff --git a/source/mycss/api.h b/source/mycss/api.h
index 9111bf5..9daef46 100644
--- a/source/mycss/api.h
+++ b/source/mycss/api.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -36,10 +36,14 @@
*/
#define MyCSS_VERSION_MAJOR 0
-#define MyCSS_VERSION_MINOR 0
-#define MyCSS_VERSION_PATCH 9
+#define MyCSS_VERSION_MINOR 1
+#define MyCSS_VERSION_PATCH 0
-#include "myhtml/api.h"
+#include <mycore/myosi.h>
+#include <mycore/incoming.h>
+#include <mycore/mystring.h>
+#include <mycore/utils/mchar_async.h>
+#include <myencoding/myosi.h>
#ifdef __cplusplus
extern "C" {
@@ -52,7 +56,6 @@ extern "C" {
// base
/*
Very important!!!
- see modest/myosi.h:modest_status_tv
*/
enum mycss_status {
MyCSS_STATUS_OK = 0x000000,
@@ -185,7 +188,7 @@ mycss_create(void);
*
* @return MyCSS_STATUS_OK if successful, otherwise an error status value.
*/
-mycss_status_t
+mystatus_t
mycss_init(mycss_t* mycss);
/**
@@ -203,7 +206,7 @@ mycss_destroy(mycss_t* mycss, bool self_destroy);
* Parsing CSS
*
* @param[in] previously created structure mycss_entry_t*
- * @param[in] Now is not working! Coming Soon. Input character encoding; Default: MyHTML_ENCODING_UTF_8 or MyHTML_ENCODING_DEFAULT or 0
+ * @param[in] Now is not working! Coming Soon. Input character encoding; Default: MyENCODING_UTF_8 or MyENCODING_DEFAULT or 0
* @param[in] CSS data
* @param[in] CSS data size
*
@@ -211,8 +214,8 @@ mycss_destroy(mycss_t* mycss, bool self_destroy);
*
* @return MyCSS_STATUS_OK if successful, otherwise an error status
*/
-mycss_status_t
-mycss_parse(mycss_entry_t* entry, myhtml_encoding_t encoding, const char* css, size_t css_size);
+mystatus_t
+mycss_parse(mycss_entry_t* entry, myencoding_t encoding, const char* css, size_t css_size);
/**
* Parsing CSS chunk. For End Parsing call mycss_parse_chunk_end function
@@ -225,7 +228,7 @@ mycss_parse(mycss_entry_t* entry, myhtml_encoding_t encoding, const char* css, s
*
* @return MyCSS_STATUS_OK if successful, otherwise an error status
*/
-mycss_status_t
+mystatus_t
mycss_parse_chunk(mycss_entry_t* entry, const char* css, size_t css_size);
/**
@@ -235,7 +238,7 @@ mycss_parse_chunk(mycss_entry_t* entry, const char* css, size_t css_size);
*
* @return MyCSS_STATUS_OK if successful, otherwise an error status
*/
-mycss_status_t
+mystatus_t
mycss_parse_chunk_end(mycss_entry_t* entry);
/***********************************************************************************
@@ -260,7 +263,7 @@ mycss_entry_create(void);
*
* @return MyCSS_STATUS_OK if successful, otherwise an error status value.
*/
-mycss_status_t
+mystatus_t
mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry);
/**
@@ -270,7 +273,7 @@ mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry);
*
* @return MyCSS_STATUS_OK if successful, otherwise an error status value.
*/
-mycss_status_t
+mystatus_t
mycss_entry_clean_all(mycss_entry_t* entry);
/**
@@ -321,9 +324,9 @@ mycss_entry_token_count(mycss_entry_t* entry);
*
* @param[in] mycss_entry_t*
*
- * @return myhtml_incoming_buffer_t* if successful, otherwise an NULL value.
+ * @return mycore_incoming_buffer_t* if successful, otherwise an NULL value.
*/
-myhtml_incoming_buffer_t*
+mycore_incoming_buffer_t*
mycss_entry_incoming_buffer_current(mycss_entry_t* entry);
/**
@@ -332,9 +335,9 @@ mycss_entry_incoming_buffer_current(mycss_entry_t* entry);
*
* @param[in] mycss_entry_t*
*
- * @return myhtml_incoming_buffer_t* if successful, otherwise an NULL value.
+ * @return mycore_incoming_buffer_t* if successful, otherwise an NULL value.
*/
-myhtml_incoming_buffer_t*
+mycore_incoming_buffer_t*
mycss_entry_incoming_buffer_first(mycss_entry_t* entry);
/***********************************************************************************
@@ -400,14 +403,14 @@ mycss_token_name_by_type(mycss_token_type_t type);
*
* @param[in] mycss_entry_t*
* @param[in] mycss_token_t*, token from which data will be obtained
- * @param[in] myhtml_string_t*, a pointer to the row in which the data will be written
- * @param[in] initialization myhtml_string_t* object
+ * @param[in] mycore_string_t*, a pointer to the row in which the data will be written
+ * @param[in] initialization mycore_string_t* object
*
* @return length of processed data
*/
size_t
mycss_token_data_to_string(mycss_entry_t* entry, mycss_token_t* token,
- myhtml_string_t* str, bool init_string);
+ mycore_string_t* str, bool init_string);
/***********************************************************************************
*
@@ -424,20 +427,20 @@ mycss_token_data_to_string(mycss_entry_t* entry, mycss_token_t* token,
* @param[in] mycss_entry_t*
* @param[in] Input character encoding.
* See https://github.com/lexborisov/myhtml/blob/master/source/myhtml/api.h
- * myhtml_encoding_t
+ * myencoding_t
*
*/
void
-mycss_encoding_set(mycss_entry_t* entry, myhtml_encoding_t encoding);
+mycss_encoding_set(mycss_entry_t* entry, myencoding_t encoding);
/**
* Get character encoding for current stream
*
* @param[in] mycss_entry_t*
*
- * @return myhtml_encoding_t
+ * @return myencoding_t
*/
-myhtml_encoding_t
+myencoding_t
mycss_encoding_get(mycss_entry_t* entry);
/**
@@ -446,16 +449,16 @@ mycss_encoding_get(mycss_entry_t* entry);
* See for information:
* https://www.w3.org/TR/css-syntax-3/#get-an-encoding
* https://www.w3.org/TR/css-syntax-3/#charset-rule
- * myhtml_encoding_by_name in https://github.com/lexborisov/myhtml/blob/master/source/myhtml/api.h
+ * myencoding_by_name in https://github.com/lexborisov/myhtml/blob/master/source/myhtml/api.h
*
- * If @charset rule is missing or encoding not found return MyHTML_ENCODING_UTF_8 by default
+ * If @charset rule is missing or encoding not found return MyENCODING_UTF_8 by default
*
* @param[in] css data stream
* @param[in] css data stream size
*
- * @return myhtml_encoding_t
+ * @return myencoding_t
*/
-myhtml_encoding_t
+myencoding_t
mycss_encoding_check_charset_rule(const char* css, size_t size);
/***********************************************************************************
diff --git a/source/mycss/check.c b/source/mycss/check.c
index fb2d051..ff1da93 100644
--- a/source/mycss/check.c
+++ b/source/mycss/check.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -33,7 +33,7 @@
/////////////////////////////////////////////////////////
bool mycss_check_two_code_points_valid_escape_chunk(mycss_entry_t* entry, size_t css_offset)
{
- myhtml_incoming_buffer_t* buffer = entry->current_buffer;
+ mycore_incoming_buffer_t* buffer = entry->current_buffer;
MyCSS_CHECK_CHUNK_POSITION_AND_SET_IF_NEED
@@ -51,7 +51,7 @@ bool mycss_check_two_code_points_valid_escape_chunk(mycss_entry_t* entry, size_t
bool mycss_check_three_code_points_would_start_identifier_chunk(mycss_entry_t* entry, size_t css_offset)
{
- myhtml_incoming_buffer_t* buffer = entry->current_buffer;
+ mycore_incoming_buffer_t* buffer = entry->current_buffer;
MyCSS_CHECK_CHUNK_POSITION_AND_SET_IF_NEED
const unsigned char *u_css = (const unsigned char*)buffer->data;
@@ -82,7 +82,7 @@ bool mycss_check_three_code_points_would_start_identifier_chunk(mycss_entry_t* e
bool mycss_check_three_code_points_would_start_number_chunk(mycss_entry_t* entry, size_t css_offset)
{
- myhtml_incoming_buffer_t* buffer = entry->current_buffer;
+ mycore_incoming_buffer_t* buffer = entry->current_buffer;
MyCSS_CHECK_CHUNK_POSITION_AND_SET_IF_NEED
diff --git a/source/mycss/check.h b/source/mycss/check.h
index 1d0ab5c..057e229 100644
--- a/source/mycss/check.h
+++ b/source/mycss/check.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/convert.c b/source/mycss/convert.c
index c4e2959..a973d51 100644
--- a/source/mycss/convert.c
+++ b/source/mycss/convert.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -19,9 +19,9 @@
*/
#include "convert.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
-const char * mycss_convert_split_dimension_string(myhtml_string_t* str, double* value, bool* is_float)
+const char * mycss_convert_split_dimension_string(mycore_string_t* str, double* value, bool* is_float)
{
size_t length = mycss_convert_data_to_double(str->data, str->length, value, is_float);
return &str->data[length];
@@ -177,9 +177,9 @@ size_t mycss_convert_data_to_integer(const char* data, size_t size, long* return
const unsigned char* u_data = (const unsigned char*)data;
- while(offset < size && myhtml_string_chars_num_map[u_data[offset]] != 0xff)
+ while(offset < size && mycore_string_chars_num_map[u_data[offset]] != 0xff)
{
- res_num = myhtml_string_chars_num_map[ u_data[offset] ] + res_num * 10;
+ res_num = mycore_string_chars_num_map[ u_data[offset] ] + res_num * 10;
++offset;
}
@@ -200,9 +200,9 @@ size_t mycss_convert_hex_to_codepoint(const char *data, size_t size, size_t *cod
while(length < size)
{
- if(myhtml_string_chars_hex_map[u_data[length]] != 0xff) {
+ if(mycore_string_chars_hex_map[u_data[length]] != 0xff) {
*codepoint <<= 4;
- *codepoint |= myhtml_string_chars_hex_map[ u_data[length] ];
+ *codepoint |= mycore_string_chars_hex_map[ u_data[length] ];
--max_consumed;
@@ -233,10 +233,10 @@ size_t mycss_convert_unicode_range_to_codepoint(const char *data, size_t size, s
do {
*start <<= 4;
- *start |= myhtml_string_chars_hex_map[ 0x30 ]; // 0x30 == '0'
+ *start |= mycore_string_chars_hex_map[ 0x30 ]; // 0x30 == '0'
*end <<= 4;
- *end |= myhtml_string_chars_hex_map[ 0x46 ]; // 0x46 == 'F'
+ *end |= mycore_string_chars_hex_map[ 0x46 ]; // 0x46 == 'F'
++length;
}
diff --git a/source/mycss/convert.h b/source/mycss/convert.h
index 5f89572..b311eae 100644
--- a/source/mycss/convert.h
+++ b/source/mycss/convert.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -30,7 +30,7 @@ extern "C" {
#include "mycss/entry.h"
#include "myhtml/mystring.h"
-const char * mycss_convert_split_dimension_string(myhtml_string_t* str, double* value, bool* is_float);
+const char * mycss_convert_split_dimension_string(mycore_string_t* str, double* value, bool* is_float);
size_t mycss_convert_data_to_integer(const char* data, size_t size, long* return_num);
size_t mycss_convert_data_to_double(const char *data, size_t size, double *return_num, bool* is_float);
diff --git a/source/mycss/declaration/default.c b/source/mycss/declaration/default.c
index 9ef4ea1..1963ffc 100644
--- a/source/mycss/declaration/default.c
+++ b/source/mycss/declaration/default.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/declaration/default.h b/source/mycss/declaration/default.h
index 49cc968..8e3a32e 100644
--- a/source/mycss/declaration/default.h
+++ b/source/mycss/declaration/default.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/declaration/default_entries.h b/source/mycss/declaration/default_entries.h
index f1d0df5..5016ec3 100644
--- a/source/mycss/declaration/default_entries.h
+++ b/source/mycss/declaration/default_entries.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/declaration/default_resources.h b/source/mycss/declaration/default_resources.h
index 682e305..245b841 100644
--- a/source/mycss/declaration/default_resources.h
+++ b/source/mycss/declaration/default_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/declaration/entry.c b/source/mycss/declaration/entry.c
index 2d3c519..f743ead 100644
--- a/source/mycss/declaration/entry.c
+++ b/source/mycss/declaration/entry.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -21,7 +21,7 @@
#include "mycss/declaration/entry.h"
#include "mycss/declaration/entry_destroy_resources.h"
-mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, myhtml_status_t* status)
+mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, mystatus_t* status)
{
mycss_declaration_entry_t *dec_entry = mcobject_malloc(declaration->mcobject_entries, status);
memset(dec_entry, 0, sizeof(mycss_declaration_entry_t));
diff --git a/source/mycss/declaration/entry.h b/source/mycss/declaration/entry.h
index 4206fa1..9455adc 100644
--- a/source/mycss/declaration/entry.h
+++ b/source/mycss/declaration/entry.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -31,7 +31,7 @@
extern "C" {
#endif
-mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, myhtml_status_t* status);
+mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, mystatus_t* status);
void mycss_declaration_entry_clean(mycss_declaration_entry_t* entry);
void mycss_declaration_entry_clean_all(mycss_declaration_entry_t* entry);
mycss_declaration_entry_t * mycss_declaration_entry_destroy(mycss_declaration_t* declaration, mycss_declaration_entry_t* decl_entry, bool self_destroy);
diff --git a/source/mycss/declaration/entry_destroy.c b/source/mycss/declaration/entry_destroy.c
index dae22a9..8bbf090 100644
--- a/source/mycss/declaration/entry_destroy.c
+++ b/source/mycss/declaration/entry_destroy.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/declaration/entry_destroy.h b/source/mycss/declaration/entry_destroy.h
index f946a75..38dac05 100644
--- a/source/mycss/declaration/entry_destroy.h
+++ b/source/mycss/declaration/entry_destroy.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/declaration/entry_destroy_resources.h b/source/mycss/declaration/entry_destroy_resources.h
index 6d21555..206fafe 100644
--- a/source/mycss/declaration/entry_destroy_resources.h
+++ b/source/mycss/declaration/entry_destroy_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/declaration/init.c b/source/mycss/declaration/init.c
index 056e14c..e2a9d0d 100644
--- a/source/mycss/declaration/init.c
+++ b/source/mycss/declaration/init.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -23,10 +23,10 @@
mycss_declaration_t * mycss_declaration_create(void)
{
- return (mycss_declaration_t*)myhtml_calloc(1, sizeof(mycss_declaration_t));
+ return (mycss_declaration_t*)mycore_calloc(1, sizeof(mycss_declaration_t));
}
-mycss_status_t mycss_declaration_init(mycss_entry_t* entry, mycss_declaration_t* declaration)
+mystatus_t mycss_declaration_init(mycss_entry_t* entry, mycss_declaration_t* declaration)
{
declaration->ref_entry = entry;
declaration->entry = NULL;
@@ -37,7 +37,7 @@ mycss_status_t mycss_declaration_init(mycss_entry_t* entry, mycss_declaration_t*
if(declaration->mcobject_entries == NULL)
return MyCSS_STATUS_ERROR_DECLARATION_ENTRY_CREATE;
- myhtml_status_t myhtml_status = mcobject_init(declaration->mcobject_entries, 256, sizeof(mycss_declaration_entry_t));
+ mystatus_t myhtml_status = mcobject_init(declaration->mcobject_entries, 256, sizeof(mycss_declaration_entry_t));
if(myhtml_status)
return MyCSS_STATUS_ERROR_DECLARATION_ENTRY_INIT;
@@ -78,7 +78,7 @@ mycss_declaration_t * mycss_declaration_destroy(mycss_declaration_t* declaration
declaration->stack = mycss_stack_destroy(declaration->stack, true);
if(self_destroy) {
- myhtml_free(declaration);
+ mycore_free(declaration);
return NULL;
}
@@ -106,7 +106,7 @@ mycss_token_type_t mycss_declaration_ending_token_type(mycss_declaration_t* decl
return declaration->ending_token;
}
-mycss_declaration_entry_t * mycss_declaration_parse(mycss_declaration_t* declaration, myhtml_encoding_t encoding, const char* data, size_t data_size, mycss_status_t* out_status)
+mycss_declaration_entry_t * mycss_declaration_parse(mycss_declaration_t* declaration, myencoding_t encoding, const char* data, size_t data_size, mystatus_t* out_status)
{
if(data == NULL || data_size == 0) {
if(out_status)
@@ -137,7 +137,7 @@ mycss_declaration_entry_t * mycss_declaration_parse(mycss_declaration_t* declara
/* parsing */
mycss_encoding_set(entry, encoding);
- mycss_status_t status = mycss_tokenizer_chunk(entry, data, data_size);
+ mystatus_t status = mycss_tokenizer_chunk(entry, data, data_size);
if(status != MyCSS_STATUS_OK) {
if(out_status)
*out_status = status;
diff --git a/source/mycss/declaration/init.h b/source/mycss/declaration/init.h
index a439e99..c03e50b 100644
--- a/source/mycss/declaration/init.h
+++ b/source/mycss/declaration/init.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -30,18 +30,18 @@ extern "C" {
#endif
mycss_declaration_t * mycss_declaration_create(void);
-mycss_status_t mycss_declaration_init(mycss_entry_t* entry, mycss_declaration_t* declaration);
+mystatus_t mycss_declaration_init(mycss_entry_t* entry, mycss_declaration_t* declaration);
void mycss_declaration_clean_all(mycss_declaration_t* declaration);
void mycss_declaration_clean(mycss_declaration_t* declaration);
mycss_declaration_t * mycss_declaration_destroy(mycss_declaration_t* declaration, bool self_destroy);
void mycss_declaration_entry_clean(mycss_declaration_entry_t* entry);
-mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, myhtml_status_t* status);
+mycss_declaration_entry_t * mycss_declaration_entry_create(mycss_declaration_t* declaration, mystatus_t* status);
void mycss_declaration_entry_clean_all(mycss_declaration_entry_t* entry);
void mycss_declaration_entry_append_to_current(mycss_declaration_t* declaration, mycss_declaration_entry_t* dec_entry);
-mycss_declaration_entry_t * mycss_declaration_parse(mycss_declaration_t* declaration, myhtml_encoding_t encoding, const char* data, size_t data_size, mycss_status_t* out_status);
+mycss_declaration_entry_t * mycss_declaration_parse(mycss_declaration_t* declaration, myencoding_t encoding, const char* data, size_t data_size, mystatus_t* out_status);
mycss_token_type_t mycss_declaration_ending_token_type(mycss_declaration_t* declaration);
void mycss_declaration_ending_token_type_set(mycss_declaration_t* declaration, mycss_token_type_t ending_token_type);
diff --git a/source/mycss/declaration/myosi.h b/source/mycss/declaration/myosi.h
index 2169cdf..ddf6727 100644
--- a/source/mycss/declaration/myosi.h
+++ b/source/mycss/declaration/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -26,7 +26,7 @@
#include "mycss/stack.h"
#include "mycss/values/units.h"
#include "mycss/property/myosi.h"
-#include "myhtml/utils/mcobject.h"
+#include "mycore/utils/mcobject.h"
#ifdef __cplusplus
extern "C" {
diff --git a/source/mycss/declaration/parser.c b/source/mycss/declaration/parser.c
index 74278ab..386ec5b 100644
--- a/source/mycss/declaration/parser.c
+++ b/source/mycss/declaration/parser.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -38,7 +38,7 @@ void mycss_declaration_parser_ident(mycss_entry_t* entry, mycss_token_t* token)
else
mycss_declaration_entry_clean(dec_entry);
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, false);
const mycss_property_index_static_entry_t *prop_entry = mycss_property_index_entry_by_name(str.data, str.length);
@@ -53,7 +53,7 @@ void mycss_declaration_parser_ident(mycss_entry_t* entry, mycss_token_t* token)
entry->parser = mycss_declaration_state_parse_error;
}
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
}
void mycss_declaration_parser_end(mycss_entry_t* entry, mycss_token_t* token)
diff --git a/source/mycss/declaration/parser.h b/source/mycss/declaration/parser.h
index ee94963..fa8e3ea 100644
--- a/source/mycss/declaration/parser.h
+++ b/source/mycss/declaration/parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/declaration/serialization.c b/source/mycss/declaration/serialization.c
index 9c2851a..5f29ec7 100644
--- a/source/mycss/declaration/serialization.c
+++ b/source/mycss/declaration/serialization.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -21,7 +21,7 @@
#include "mycss/declaration/serialization.h"
#include "mycss/declaration/serialization_resources.h"
-static void mycss_declaration_serialization_important_if_need(mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context)
+static void mycss_declaration_serialization_important_if_need(mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context)
{
if(dec_entry->is_important) {
callback(" !important", 11, context);
@@ -29,7 +29,7 @@ static void mycss_declaration_serialization_important_if_need(mycss_declaration_
}
bool mycss_declaration_serialization_entry(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -42,7 +42,7 @@ bool mycss_declaration_serialization_entry(mycss_entry_t* entry, mycss_declarati
}
bool mycss_declaration_serialization_entry_only_value(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -52,7 +52,7 @@ bool mycss_declaration_serialization_entry_only_value(mycss_entry_t* entry, mycs
bool mycss_declaration_serialization_entry_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
mycss_property_type_t property_type,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL || property_type >= MyCSS_PROPERTY_TYPE_LAST_ENTRY)
return false;
@@ -66,7 +66,7 @@ bool mycss_declaration_serialization_entry_by_type(mycss_entry_t* entry, mycss_d
bool mycss_declaration_serialization_entry_only_value_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
mycss_property_type_t property_type,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL || property_type >= MyCSS_PROPERTY_TYPE_LAST_ENTRY)
return false;
@@ -76,7 +76,7 @@ bool mycss_declaration_serialization_entry_only_value_by_type(mycss_entry_t* ent
void mycss_declaration_serialization_entries(mycss_entry_t* entry, mycss_declaration_entry_t* first_dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(first_dec_entry == NULL)
return;
@@ -94,7 +94,7 @@ void mycss_declaration_serialization_entries(mycss_entry_t* entry, mycss_declara
}
bool mycss_declaration_serialization_undef(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -106,7 +106,7 @@ bool mycss_declaration_serialization_undef(mycss_entry_t* entry, mycss_declarati
}
bool mycss_declaration_serialization_shorthand_four(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL || dec_entry->value == NULL)
return false;
@@ -146,7 +146,7 @@ bool mycss_declaration_serialization_shorthand_four(mycss_entry_t* entry, mycss_
}
bool mycss_declaration_serialization_shorthand_two(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL || dec_entry->value == NULL)
return false;
@@ -172,7 +172,7 @@ bool mycss_declaration_serialization_shorthand_two(mycss_entry_t* entry, mycss_d
}
bool mycss_declaration_serialization_shorthand_two_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL || dec_entry->value == NULL)
return false;
@@ -195,7 +195,7 @@ bool mycss_declaration_serialization_shorthand_two_type(mycss_entry_t* entry, my
}
bool mycss_declaration_serialization_type_list(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -218,7 +218,7 @@ bool mycss_declaration_serialization_type_list(mycss_entry_t* entry, mycss_decla
}
bool mycss_declaration_serialization_text_decoration(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -255,7 +255,7 @@ bool mycss_declaration_serialization_text_decoration(mycss_entry_t* entry, mycss
}
bool mycss_declaration_serialization_font_family(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -271,11 +271,11 @@ bool mycss_declaration_serialization_font_family(mycss_entry_t* entry, mycss_dec
callback(", ", 2, context);
if(font_family->entries[i].type == MyCSS_VALUES_FONT_FAMILY_TYPE_GENERIC) {
- mycss_property_serialization_value(font_family->entries[i].prop_type, NULL, callback, context);
+ mycss_property_serialization_value(font_family->entries[i].value.prop_type, NULL, callback, context);
}
else if(font_family->entries[i].type == MyCSS_VALUES_FONT_FAMILY_TYPE_NAME) {
callback("\"", 1, context);
- myhtml_string_t *str = &font_family->entries[i].str;
+ mycore_string_t *str = &font_family->entries[i].value.str;
callback(str->data, str->length, context);
callback("\"", 1, context);
}
@@ -286,7 +286,7 @@ bool mycss_declaration_serialization_font_family(mycss_entry_t* entry, mycss_dec
}
bool mycss_declaration_serialization_font(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -345,7 +345,7 @@ bool mycss_declaration_serialization_font(mycss_entry_t* entry, mycss_declaratio
}
bool mycss_declaration_serialization_border_radius(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -427,7 +427,7 @@ bool mycss_declaration_serialization_border_radius(mycss_entry_t* entry, mycss_d
}
bool mycss_declaration_serialization_text_decoration_line(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -442,7 +442,7 @@ bool mycss_declaration_serialization_text_decoration_line(mycss_entry_t* entry,
}
bool mycss_declaration_serialization_text_decoration_skip(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -457,7 +457,7 @@ bool mycss_declaration_serialization_text_decoration_skip(mycss_entry_t* entry,
}
bool mycss_declaration_serialization_background(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -521,7 +521,7 @@ bool mycss_declaration_serialization_background(mycss_entry_t* entry, mycss_decl
}
bool mycss_declaration_serialization_background_image(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -544,7 +544,7 @@ bool mycss_declaration_serialization_background_image(mycss_entry_t* entry, mycs
}
bool mycss_declaration_serialization_background_repeat(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -574,7 +574,7 @@ bool mycss_declaration_serialization_background_repeat(mycss_entry_t* entry, myc
}
bool mycss_declaration_serialization_background_position(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -587,23 +587,23 @@ bool mycss_declaration_serialization_background_position(mycss_entry_t* entry, m
if(position->one.type) {
o_e = true;
- mycss_property_serialization_value(position->one.type, position->one.length, callback, context);
+ mycss_property_serialization_value(position->one.type, position->one.value.length, callback, context);
}
if(position->two.type) {
if(o_e) callback(" ", 1, context); else o_e = true;
- mycss_property_serialization_value(position->two.type, position->two.length, callback, context);
+ mycss_property_serialization_value(position->two.type, position->two.value.length, callback, context);
}
if(position->three.type) {
if(o_e) callback(" ", 1, context); else o_e = true;
- mycss_property_serialization_value(position->three.type, position->three.length, callback, context);
+ mycss_property_serialization_value(position->three.type, position->three.value.length, callback, context);
}
if(position->four.type) {
if(o_e) callback(" ", 1, context);
- mycss_property_serialization_value(position->four.type, position->four.length, callback, context);
+ mycss_property_serialization_value(position->four.type, position->four.value.length, callback, context);
}
mycss_declaration_serialization_important_if_need(dec_entry, callback, context);
@@ -612,7 +612,7 @@ bool mycss_declaration_serialization_background_position(mycss_entry_t* entry, m
}
bool mycss_declaration_serialization_background_size(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
@@ -635,7 +635,7 @@ bool mycss_declaration_serialization_background_size(mycss_entry_t* entry, mycss
}
bool mycss_declaration_serialization_border_x(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
if(dec_entry == NULL)
return false;
diff --git a/source/mycss/declaration/serialization.h b/source/mycss/declaration/serialization.h
index b6fe723..d561d48 100644
--- a/source/mycss/declaration/serialization.h
+++ b/source/mycss/declaration/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -32,31 +32,31 @@ extern "C" {
#endif
typedef bool (*mycss_declaration_serialization_f)(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
- mycss_callback_serialization_f callback, void* context);
+ mycore_callback_serialize_f callback, void* context);
-bool mycss_declaration_serialization_entry(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-void mycss_declaration_serialization_entries(mycss_entry_t* entry, mycss_declaration_entry_t* first_dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_entry_only_value(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_entry_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_property_type_t property_type, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_entry_only_value_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_property_type_t property_type, mycss_callback_serialization_f callback, void* context);
+bool mycss_declaration_serialization_entry(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+void mycss_declaration_serialization_entries(mycss_entry_t* entry, mycss_declaration_entry_t* first_dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_entry_only_value(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_entry_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_property_type_t property_type, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_entry_only_value_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_property_type_t property_type, mycore_callback_serialize_f callback, void* context);
-bool mycss_declaration_serialization_undef(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_shorthand_four(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_shorthand_two(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_shorthand_two_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_type_list(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_border_radius(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_text_decoration(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_text_decoration_line(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_text_decoration_skip(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_font_family(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_font(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_background(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_background_image(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_background_repeat(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_background_position(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_background_size(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
-bool mycss_declaration_serialization_border_x(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
+bool mycss_declaration_serialization_undef(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_shorthand_four(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_shorthand_two(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_shorthand_two_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_type_list(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_border_radius(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_text_decoration(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_text_decoration_line(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_text_decoration_skip(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_font_family(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_font(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_background(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_background_image(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_background_repeat(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_background_position(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_background_size(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
+bool mycss_declaration_serialization_border_x(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/mycss/declaration/serialization_resources.h b/source/mycss/declaration/serialization_resources.h
index a9fa1a1..09ff31b 100644
--- a/source/mycss/declaration/serialization_resources.h
+++ b/source/mycss/declaration/serialization_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/declaration/state.c b/source/mycss/declaration/state.c
index 04f0512..aa81086 100644
--- a/source/mycss/declaration/state.c
+++ b/source/mycss/declaration/state.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -99,11 +99,11 @@ bool mycss_declaration_state_colon_before_important(mycss_entry_t* entry, mycss_
bool mycss_declaration_state_colon_important(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
{
if(token->type == MyCSS_TOKEN_TYPE_IDENT) {
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, true);
- if(myhtml_strcmp(str.data, "important") == 0) {
- myhtml_string_destroy(&str, false);
+ if(mycore_strcmp(str.data, "important") == 0) {
+ mycore_string_destroy(&str, false);
entry->parser = mycss_declaration_state_colon_delim_after_important;
(entry->declaration->entry_last)->is_important = true;
@@ -111,7 +111,7 @@ bool mycss_declaration_state_colon_important(mycss_entry_t* entry, mycss_token_t
return true;
}
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
/* parse error */
entry->parser = mycss_declaration_state_parse_error;
diff --git a/source/mycss/declaration/state.h b/source/mycss/declaration/state.h
index 0884a21..85a5664 100644
--- a/source/mycss/declaration/state.h
+++ b/source/mycss/declaration/state.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/entry.c b/source/mycss/entry.c
index ba4c46e..85b5d27 100644
--- a/source/mycss/entry.c
+++ b/source/mycss/entry.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -23,11 +23,13 @@
mycss_entry_t * mycss_entry_create(void)
{
- return (mycss_entry_t*)myhtml_calloc(1, sizeof(mycss_entry_t));
+ return (mycss_entry_t*)mycore_calloc(1, sizeof(mycss_entry_t));
}
-mycss_status_t mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry)
+mystatus_t mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry)
{
+ mystatus_t status;
+
entry->mycss = mycss;
entry->parser = NULL;
entry->parser_switch = NULL;
@@ -35,9 +37,21 @@ mycss_status_t mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry)
entry->parser_ending_token = MyCSS_TOKEN_TYPE_UNDEF;
// Other init
- entry->mchar = mchar_async_create(128, (4096 * 5));
- entry->mchar_node_id = mchar_async_node_add(entry->mchar);
- entry->mchar_value_node_id = mchar_async_node_add(entry->mchar);
+ entry->mchar = mchar_async_create();
+ if(entry->mchar == NULL)
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if((status = mchar_async_init(entry->mchar, 128, (4096 * 5))))
+ return status;
+
+ /* init data nodes for save input char* */
+ entry->mchar_node_id = mchar_async_node_add(entry->mchar, &status);
+ if(status)
+ return status;
+
+ entry->mchar_value_node_id = mchar_async_node_add(entry->mchar, &status);
+ if(status)
+ return status;
entry->parser_list = mycss_entry_parser_list_create_and_init(128);
@@ -49,7 +63,7 @@ mycss_status_t mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry)
if(entry->mcobject_string_entries == NULL)
return MyCSS_STATUS_ERROR_STRING_CREATE;
- myhtml_status_t myhtml_status = mcobject_init(entry->mcobject_string_entries, 256, sizeof(myhtml_string_t));
+ mystatus_t myhtml_status = mcobject_init(entry->mcobject_string_entries, 256, sizeof(mycore_string_t));
if(myhtml_status)
return MyCSS_STATUS_ERROR_STRING_INIT;
@@ -58,7 +72,7 @@ mycss_status_t mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry)
if(entry->selectors == NULL)
return MyCSS_STATUS_ERROR_SELECTORS_CREATE;
- mycss_status_t status = mycss_selectors_init(entry, entry->selectors);
+ status = mycss_selectors_init(entry, entry->selectors);
if(status != MyCSS_STATUS_OK)
return status;
@@ -103,7 +117,7 @@ mycss_status_t mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry)
if(entry->mcobject_incoming_buffer == NULL)
return MyCSS_STATUS_ERROR_ENTRY_INCOMING_BUFFER_CREATE;
- myhtml_status = mcobject_init(entry->mcobject_incoming_buffer, 256, sizeof(myhtml_incoming_buffer_t));
+ myhtml_status = mcobject_init(entry->mcobject_incoming_buffer, 256, sizeof(mycore_incoming_buffer_t));
if(myhtml_status)
return MyCSS_STATUS_ERROR_ENTRY_INCOMING_BUFFER_INIT;
@@ -113,7 +127,7 @@ mycss_status_t mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry)
return MyCSS_STATUS_OK;
}
-mycss_status_t mycss_entry_clean(mycss_entry_t* entry)
+mystatus_t mycss_entry_clean(mycss_entry_t* entry)
{
mcobject_clean(entry->mcobject_incoming_buffer);
mycss_entry_parser_list_clean(entry->parser_list);
@@ -138,7 +152,7 @@ mycss_status_t mycss_entry_clean(mycss_entry_t* entry)
return MyCSS_STATUS_OK;
}
-mycss_status_t mycss_entry_clean_all(mycss_entry_t* entry)
+mystatus_t mycss_entry_clean_all(mycss_entry_t* entry)
{
mcobject_clean(entry->mcobject_incoming_buffer);
mchar_async_node_clean(entry->mchar, entry->mchar_node_id);
@@ -189,12 +203,12 @@ mycss_entry_t * mycss_entry_destroy(mycss_entry_t* entry, bool self_destroy)
entry->mcobject_incoming_buffer = mcobject_destroy(entry->mcobject_incoming_buffer, true);
if(entry->token) {
- myhtml_free(entry->token);
+ mycore_free(entry->token);
entry->token = NULL;
}
if(self_destroy) {
- myhtml_free(entry);
+ mycore_free(entry);
return NULL;
}
@@ -212,14 +226,14 @@ mycss_selectors_t * mycss_entry_selectors(mycss_entry_t* entry)
return entry->selectors;
}
-myhtml_string_t * mycss_entry_string_create_and_init(mycss_entry_t* entry, size_t string_size)
+mycore_string_t * mycss_entry_string_create_and_init(mycss_entry_t* entry, size_t string_size)
{
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
if(str == NULL)
return NULL;
- myhtml_string_init(entry->mchar, entry->mchar_node_id, str, (string_size + 1));
+ mycore_string_init(entry->mchar, entry->mchar_node_id, str, (string_size + 1));
return str;
}
@@ -237,12 +251,12 @@ size_t mycss_entry_token_count(mycss_entry_t* entry)
return entry->token_counter;
}
-myhtml_incoming_buffer_t * mycss_entry_incoming_buffer_current(mycss_entry_t* entry)
+mycore_incoming_buffer_t * mycss_entry_incoming_buffer_current(mycss_entry_t* entry)
{
return entry->current_buffer;
}
-myhtml_incoming_buffer_t * mycss_entry_incoming_buffer_first(mycss_entry_t* entry)
+mycore_incoming_buffer_t * mycss_entry_incoming_buffer_first(mycss_entry_t* entry)
{
return entry->first_buffer;
}
@@ -275,17 +289,17 @@ void mycss_entry_parser_original_set(mycss_entry_t* entry, mycss_parser_token_f
/* parser list */
mycss_entry_parser_list_t * mycss_entry_parser_list_create_and_init(size_t size)
{
- mycss_entry_parser_list_t* parser_list = myhtml_malloc(sizeof(mycss_entry_parser_list_t));
+ mycss_entry_parser_list_t* parser_list = mycore_malloc(sizeof(mycss_entry_parser_list_t));
if(parser_list == NULL)
return NULL;
parser_list->length = 0;
parser_list->size = size;
- parser_list->list = myhtml_malloc(parser_list->size * sizeof(mycss_entry_parser_list_entry_t));
+ parser_list->list = mycore_malloc(parser_list->size * sizeof(mycss_entry_parser_list_entry_t));
if(parser_list->list == NULL) {
- myhtml_free(parser_list);
+ mycore_free(parser_list);
return NULL;
}
@@ -303,19 +317,19 @@ mycss_entry_parser_list_t * mycss_entry_parser_list_destroy(mycss_entry_parser_l
return NULL;
if(parser_list->list) {
- myhtml_free(parser_list->list);
+ mycore_free(parser_list->list);
parser_list->list = NULL;
}
if(self_destroy) {
- myhtml_free(parser_list);
+ mycore_free(parser_list);
return NULL;
}
return parser_list;
}
-mycss_status_t mycss_entry_parser_list_push(mycss_entry_t* entry, mycss_parser_token_f parser_func,
+mystatus_t mycss_entry_parser_list_push(mycss_entry_t* entry, mycss_parser_token_f parser_func,
mycss_parser_token_f parser_switch, mycss_token_type_t ending_token,
bool is_local)
{
@@ -324,7 +338,7 @@ mycss_status_t mycss_entry_parser_list_push(mycss_entry_t* entry, mycss_parser_t
if(parser_list->length >= parser_list->size) {
size_t new_size = parser_list->length + 1024;
- mycss_entry_parser_list_entry_t *new_list = myhtml_realloc(parser_list->list, new_size * sizeof(mycss_entry_parser_list_entry_t));
+ mycss_entry_parser_list_entry_t *new_list = mycore_realloc(parser_list->list, new_size * sizeof(mycss_entry_parser_list_entry_t));
if(new_list) {
parser_list->size = new_size;
diff --git a/source/mycss/entry.h b/source/mycss/entry.h
index ebb104a..c0dab41 100644
--- a/source/mycss/entry.h
+++ b/source/mycss/entry.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -40,8 +40,8 @@ extern "C" {
#include "mycss/declaration/entry.h"
#include "mycss/media/myosi.h"
#include "mycss/media/init.h"
-#include "myhtml/utils/mcobject.h"
-#include "myhtml/utils/mchar_async.h"
+#include "mycore/utils/mcobject.h"
+#include "mycore/utils/mchar_async.h"
struct mycss_entry_parser_list_entry {
mycss_parser_token_f parser;
@@ -83,12 +83,12 @@ struct mycss_entry {
/* incoming buffer */
mcobject_t* mcobject_incoming_buffer;
- myhtml_incoming_buffer_t* first_buffer;
- myhtml_incoming_buffer_t* current_buffer;
+ mycore_incoming_buffer_t* first_buffer;
+ mycore_incoming_buffer_t* current_buffer;
/* options */
mycss_entry_type_t type;
- myhtml_encoding_t encoding;
+ myencoding_t encoding;
/* tokenizer */
mycss_tokenizer_state_t state;
@@ -112,9 +112,9 @@ struct mycss_entry {
};
mycss_entry_t * mycss_entry_create(void);
-mycss_status_t mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry);
-mycss_status_t mycss_entry_clean(mycss_entry_t* entry);
-mycss_status_t mycss_entry_clean_all(mycss_entry_t* entry);
+mystatus_t mycss_entry_init(mycss_t* mycss, mycss_entry_t* entry);
+mystatus_t mycss_entry_clean(mycss_entry_t* entry);
+mystatus_t mycss_entry_clean_all(mycss_entry_t* entry);
mycss_entry_t * mycss_entry_destroy(mycss_entry_t* entry, bool self_destroy);
void mycss_entry_end(mycss_entry_t* entry);
@@ -125,10 +125,10 @@ mycss_selectors_t * mycss_entry_selectors(mycss_entry_t* entry);
mycss_token_ready_callback_f mycss_entry_token_ready_callback(mycss_entry_t* entry, mycss_token_ready_callback_f callback_f);
size_t mycss_entry_token_count(mycss_entry_t* entry);
-myhtml_incoming_buffer_t * mycss_entry_incoming_buffer_current(mycss_entry_t* entry);
-myhtml_incoming_buffer_t * mycss_entry_incoming_buffer_first(mycss_entry_t* entry);
+mycore_incoming_buffer_t * mycss_entry_incoming_buffer_current(mycss_entry_t* entry);
+mycore_incoming_buffer_t * mycss_entry_incoming_buffer_first(mycss_entry_t* entry);
-myhtml_string_t * mycss_entry_string_create_and_init(mycss_entry_t* entry, size_t string_size);
+mycore_string_t * mycss_entry_string_create_and_init(mycss_entry_t* entry, size_t string_size);
mycss_stylesheet_t * mycss_entry_stylesheet(mycss_entry_t* entry);
mycss_selectors_list_t * mycss_entry_current_selectors_list(mycss_entry_t* entry);
@@ -142,7 +142,7 @@ mycss_entry_parser_list_t * mycss_entry_parser_list_create_and_init(size_t size)
void mycss_entry_parser_list_clean(mycss_entry_parser_list_t* parser_list);
mycss_entry_parser_list_t * mycss_entry_parser_list_destroy(mycss_entry_parser_list_t* parser_list, bool self_destroy);
-mycss_status_t mycss_entry_parser_list_push(mycss_entry_t* entry, mycss_parser_token_f parser_func,
+mystatus_t mycss_entry_parser_list_push(mycss_entry_t* entry, mycss_parser_token_f parser_func,
mycss_parser_token_f parser_switch, mycss_token_type_t ending_token,
bool is_local);
diff --git a/source/mycss/media/init.c b/source/mycss/media/init.c
index eb82b9a..70b1afd 100644
--- a/source/mycss/media/init.c
+++ b/source/mycss/media/init.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -22,15 +22,15 @@
mycss_media_t * mycss_media_create(void)
{
- return (mycss_media_t*)myhtml_calloc(1, sizeof(mycss_media_t));
+ return (mycss_media_t*)mycore_calloc(1, sizeof(mycss_media_t));
}
-mycss_status_t mycss_media_init(mycss_entry_t* entry, mycss_media_t* media)
+mystatus_t mycss_media_init(mycss_entry_t* entry, mycss_media_t* media)
{
return MyCSS_STATUS_OK;
}
-mycss_status_t mycss_media_clean_all(mycss_media_t* media)
+mystatus_t mycss_media_clean_all(mycss_media_t* media)
{
return MyCSS_STATUS_OK;
}
@@ -41,7 +41,7 @@ mycss_media_t * mycss_media_destroy(mycss_media_t* media, bool self_destroy)
return NULL;
if(self_destroy) {
- myhtml_free(media);
+ mycore_free(media);
return NULL;
}
diff --git a/source/mycss/media/init.h b/source/mycss/media/init.h
index 01f1d48..7023dba 100644
--- a/source/mycss/media/init.h
+++ b/source/mycss/media/init.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -29,8 +29,8 @@ extern "C" {
#endif
mycss_media_t * mycss_media_create(void);
-mycss_status_t mycss_media_init(mycss_entry_t* entry, mycss_media_t* media);
-mycss_status_t mycss_media_clean_all(mycss_media_t* media);
+mystatus_t mycss_media_init(mycss_entry_t* entry, mycss_media_t* media);
+mystatus_t mycss_media_clean_all(mycss_media_t* media);
mycss_media_t * mycss_media_destroy(mycss_media_t* media, bool self_destroy);
#ifdef __cplusplus
diff --git a/source/mycss/media/myosi.h b/source/mycss/media/myosi.h
index 10a55af..3b2489a 100644
--- a/source/mycss/media/myosi.h
+++ b/source/mycss/media/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -32,6 +32,7 @@ typedef struct mycss_media mycss_media_t;
struct mycss_media {
+ mystatus_t error;
};
diff --git a/source/mycss/media/state.h b/source/mycss/media/state.h
index aeda0e4..60629c9 100644
--- a/source/mycss/media/state.h
+++ b/source/mycss/media/state.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/mycss.c b/source/mycss/mycss.c
index ab307ff..f0d3e89 100644
--- a/source/mycss/mycss.c
+++ b/source/mycss/mycss.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -23,12 +23,12 @@
mycss_t * mycss_create(void)
{
- return (mycss_t*)myhtml_calloc(1, sizeof(mycss_t));
+ return (mycss_t*)mycore_calloc(1, sizeof(mycss_t));
}
-mycss_status_t mycss_init(mycss_t* mycss)
+mystatus_t mycss_init(mycss_t* mycss)
{
- mycss_status_t status = mycss_tokenizer_state_init(mycss);
+ mystatus_t status = mycss_tokenizer_state_init(mycss);
if(status != MyCSS_STATUS_OK)
return status;
@@ -44,14 +44,14 @@ mycss_t * mycss_destroy(mycss_t* mycss, bool self_destroy)
mycss_tokenizer_state_destroy(mycss);
if(self_destroy) {
- myhtml_free(mycss);
+ mycore_free(mycss);
return NULL;
}
return mycss;
}
-mycss_status_t mycss_parse(mycss_entry_t* entry, myhtml_encoding_t encoding, const char* css, size_t css_size)
+mystatus_t mycss_parse(mycss_entry_t* entry, myencoding_t encoding, const char* css, size_t css_size)
{
mycss_entry_clean(entry);
@@ -65,7 +65,7 @@ mycss_status_t mycss_parse(mycss_entry_t* entry, myhtml_encoding_t encoding, con
/* and parse css */
mycss_encoding_set(entry, encoding);
- mycss_status_t status = mycss_tokenizer_chunk(entry, css, css_size);
+ mystatus_t status = mycss_tokenizer_chunk(entry, css, css_size);
if(status != MyCSS_STATUS_OK)
return status;
@@ -74,7 +74,7 @@ mycss_status_t mycss_parse(mycss_entry_t* entry, myhtml_encoding_t encoding, con
return status;
}
-mycss_status_t mycss_parse_chunk(mycss_entry_t* entry, const char* css, size_t css_size)
+mystatus_t mycss_parse_chunk(mycss_entry_t* entry, const char* css, size_t css_size)
{
if(entry->type & MyCSS_ENTRY_TYPE_END) {
mycss_entry_clean_all(entry);
@@ -89,9 +89,9 @@ mycss_status_t mycss_parse_chunk(mycss_entry_t* entry, const char* css, size_t c
return mycss_tokenizer_chunk(entry, css, css_size);
}
-mycss_status_t mycss_parse_chunk_end(mycss_entry_t* entry)
+mystatus_t mycss_parse_chunk_end(mycss_entry_t* entry)
{
- mycss_status_t status = mycss_tokenizer_end(entry);
+ mystatus_t status = mycss_tokenizer_end(entry);
mycss_entry_end(entry);
return status;
@@ -129,10 +129,10 @@ const char * mycss_token_name_by_type(mycss_token_type_t type)
return mycss_token_type_description[type];
}
-size_t mycss_token_data_to_string(mycss_entry_t* entry, mycss_token_t* token, myhtml_string_t* str, bool init_string, bool case_insensitive)
+size_t mycss_token_data_to_string(mycss_entry_t* entry, mycss_token_t* token, mycore_string_t* str, bool init_string, bool case_insensitive)
{
if(init_string)
- myhtml_string_init(entry->mchar, entry->mchar_node_id, str, (token->length + 4));
+ mycore_string_init(entry->mchar, entry->mchar_node_id, str, (token->length + 4));
mycss_string_res_t out_res;
mycss_string_res_clean(&out_res);
@@ -140,7 +140,7 @@ size_t mycss_token_data_to_string(mycss_entry_t* entry, mycss_token_t* token, my
out_res.encoding = entry->encoding;
out_res.case_insensitive = case_insensitive;
- myhtml_incoming_buffer_t *buffer = myhtml_incoming_buffer_find_by_position(entry->current_buffer, token->begin);
+ mycore_incoming_buffer_t *buffer = mycore_incoming_buffer_find_by_position(entry->current_buffer, token->begin);
size_t relative_begin = token->begin - buffer->offset;
// if token data length in one buffer then print them all at once
@@ -175,30 +175,30 @@ size_t mycss_token_data_to_string(mycss_entry_t* entry, mycss_token_t* token, my
return token->length;
}
-myhtml_incoming_buffer_t * mycss_token_buffer_first(mycss_entry_t* entry, mycss_token_t* token)
+mycore_incoming_buffer_t * mycss_token_buffer_first(mycss_entry_t* entry, mycss_token_t* token)
{
- return myhtml_incoming_buffer_find_by_position(entry->current_buffer, token->begin);
+ return mycore_incoming_buffer_find_by_position(entry->current_buffer, token->begin);
}
// encoding
-void mycss_encoding_set(mycss_entry_t* entry, myhtml_encoding_t encoding)
+void mycss_encoding_set(mycss_entry_t* entry, myencoding_t encoding)
{
entry->encoding = encoding;
}
-myhtml_encoding_t mycss_encoding_get(mycss_entry_t* entry)
+myencoding_t mycss_encoding_get(mycss_entry_t* entry)
{
return entry->encoding;
}
-myhtml_encoding_t mycss_encoding_check_charset_rule(const char* css, size_t size)
+myencoding_t mycss_encoding_check_charset_rule(const char* css, size_t size)
{
if(size < 15)
- return MyHTML_ENCODING_UTF_8;
+ return MyENCODING_UTF_8;
if(strncmp("@charset \"", css, 10))
- return MyHTML_ENCODING_UTF_8;
+ return MyENCODING_UTF_8;
size_t begin = 10;
size_t length = begin;
@@ -209,12 +209,12 @@ myhtml_encoding_t mycss_encoding_check_charset_rule(const char* css, size_t size
++length;
if(length >= size || css[length] != ';')
- return MyHTML_ENCODING_UTF_8;
+ return MyENCODING_UTF_8;
size_t name_len = (length - begin) - 1;
- myhtml_encoding_t encoding;
- if(myhtml_encoding_by_name(&css[begin], name_len, &encoding))
+ myencoding_t encoding;
+ if(myencoding_by_name(&css[begin], name_len, &encoding))
return encoding;
break;
@@ -223,7 +223,7 @@ myhtml_encoding_t mycss_encoding_check_charset_rule(const char* css, size_t size
++length;
}
- return MyHTML_ENCODING_UTF_8;
+ return MyENCODING_UTF_8;
}
diff --git a/source/mycss/mycss.h b/source/mycss/mycss.h
index 167af74..e4a1d8a 100644
--- a/source/mycss/mycss.h
+++ b/source/mycss/mycss.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -26,51 +26,37 @@
extern "C" {
#endif
-#ifdef MyCSS_DEBUG
- #define MyCSS_DEBUG_MESSAGE(format, ...) \
- myhtml_print(stderr, "DEBUG: "format"\n", ##__VA_ARGS__)
-#else
- #define MyCSS_DEBUG_MESSAGE(format, ...)
-#endif
-
-#ifdef DEBUG_MODE
-#define MyHTML_DEBUG_ERROR(format, ...) \
-myhtml_print(stderr, "DEBUG ERROR: "format"\n", ##__VA_ARGS__)
-#else
-#define MyHTML_DEBUG_ERROR(format, ...)
-#endif
-
#include "mycss/myosi.h"
#include "mycss/entry.h"
#include "mycss/tokenizer.h"
#include "myhtml/myhtml.h"
-#include "myhtml/utils/mcobject_async.h"
+#include "mycore/utils/mcobject_async.h"
struct mycss {
mycss_tokenizer_state_f* parse_state_func;
};
mycss_t * mycss_create(void);
-mycss_status_t mycss_init(mycss_t* mycss);
+mystatus_t mycss_init(mycss_t* mycss);
mycss_t * mycss_destroy(mycss_t* mycss, bool self_destroy);
-mycss_status_t mycss_parse(mycss_entry_t* entry, myhtml_encoding_t encoding, const char* css, size_t css_size);
-mycss_status_t mycss_parse_chunk(mycss_entry_t* entry, const char* css, size_t css_size);
-mycss_status_t mycss_parse_chunk_end(mycss_entry_t* entry);
+mystatus_t mycss_parse(mycss_entry_t* entry, myencoding_t encoding, const char* css, size_t css_size);
+mystatus_t mycss_parse_chunk(mycss_entry_t* entry, const char* css, size_t css_size);
+mystatus_t mycss_parse_chunk_end(mycss_entry_t* entry);
size_t mycss_token_begin(mycss_token_t* token);
size_t mycss_token_length(mycss_token_t* token);
size_t mycss_token_position(mycss_token_t* token, size_t *return_length);
mycss_token_type_t mycss_token_type(mycss_token_t* token);
const char * mycss_token_name_by_type(mycss_token_type_t type);
-size_t mycss_token_data_to_string(mycss_entry_t* entry, mycss_token_t* token, myhtml_string_t* str, bool init_string, bool case_insensitive);
+size_t mycss_token_data_to_string(mycss_entry_t* entry, mycss_token_t* token, mycore_string_t* str, bool init_string, bool case_insensitive);
-myhtml_incoming_buffer_t * mycss_token_buffer_first(mycss_entry_t* entry, mycss_token_t* token);
+mycore_incoming_buffer_t * mycss_token_buffer_first(mycss_entry_t* entry, mycss_token_t* token);
// encoding
-void mycss_encoding_set(mycss_entry_t* entry, myhtml_encoding_t encoding);
-myhtml_encoding_t mycss_encoding_get(mycss_entry_t* entry);
-myhtml_encoding_t mycss_encoding_check_charset_rule(const char* css, size_t size);
+void mycss_encoding_set(mycss_entry_t* entry, myencoding_t encoding);
+myencoding_t mycss_encoding_get(mycss_entry_t* entry);
+myencoding_t mycss_encoding_check_charset_rule(const char* css, size_t size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/mycss/myosi.h b/source/mycss/myosi.h
index e6588e5..f6eaffb 100644
--- a/source/mycss/myosi.h
+++ b/source/mycss/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -22,6 +22,12 @@
#define MyHTML_MyCSS_MYOSI_H
#pragma once
+#define MyCSS_VERSION_MAJOR 0
+#define MyCSS_VERSION_MINOR 1
+#define MyCSS_VERSION_PATCH 0
+
+#define MyCSS_VERSION_STRING MyCORE_STR(MyCSS_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyCSS_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyCSS_VERSION_PATCH)
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -31,7 +37,7 @@ extern "C" {
// base
/*
Very important!!!
- see modest/myosi.h:modest_status_t
+ see modest/myosi.h:mystatus_t
*/
enum mycss_status {
MyCSS_STATUS_OK = 0x000000,
@@ -260,10 +266,9 @@ typedef struct mycss_string_res mycss_string_res_t;
typedef size_t (*mycss_tokenizer_state_f)(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size);
typedef mycss_token_t * (*mycss_token_ready_callback_f)(mycss_entry_t* entry, mycss_token_t* token);
-typedef size_t (*mycss_string_process_state_f)(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
+typedef size_t (*mycss_string_process_state_f)(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
typedef bool (*mycss_parser_token_f)(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
typedef bool (*mycss_an_plus_b_state_f)(mycss_entry_t* entry, mycss_an_plus_b_t* anb, mycss_an_plus_b_entry_t* anb_entry, mycss_token_t* token);
-typedef void (*mycss_callback_serialization_f)(const char* buffer, size_t size, void* ctx);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/mycss/mystring.c b/source/mycss/mystring.c
index 3dac2e0..f9e549b 100644
--- a/source/mycss/mystring.c
+++ b/source/mycss/mystring.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,8 +20,8 @@
#include "mycss/mystring.h"
#include "mycss/tokenizer_resource.h"
-#include "myhtml/utils/resources.h"
-#include "myhtml/encoding.h"
+#include "mycore/utils/resources.h"
+#include "myencoding/encoding.h"
static const mycss_string_process_state_f mycss_string_state_list_map[] = {
mycss_string_process_state_data, mycss_string_process_state_escaped
@@ -31,47 +31,47 @@ static const mycss_string_process_state_f mycss_string_state_list_map_utf_8[] =
mycss_string_process_state_data_utf_8, mycss_string_process_state_escaped_utf_8
};
-void mycss_string_append_codepoint_to_string(myhtml_string_t* str, size_t code_point)
+void mycss_string_append_codepoint_to_string(mycore_string_t* str, size_t code_point)
{
if((str->length + 4) >= str->size) {
- myhtml_string_realloc(str, (str->size + 8));
+ mycore_string_realloc(str, (str->size + 8));
}
// If this number is zero
if(code_point == 0) {
- str->length += myhtml_string_raw_set_replacement_character(str, str->length);
+ str->length += mycore_string_raw_set_replacement_character(str, str->length);
}
else if(code_point >= 0xD800 && code_point <= 0xDFFF) {
- str->length += myhtml_string_raw_set_replacement_character(str, str->length);
+ str->length += mycore_string_raw_set_replacement_character(str, str->length);
}
// maximum allowed code point
else if(code_point > 0x10FFFF) {
- str->length += myhtml_string_raw_set_replacement_character(str, str->length);
+ str->length += mycore_string_raw_set_replacement_character(str, str->length);
}
else
- str->length += myhtml_encoding_codepoint_to_ascii_utf_8(code_point, &str->data[str->length]);
+ str->length += myencoding_codepoint_to_ascii_utf_8(code_point, &str->data[str->length]);
}
-size_t mycss_string_process_state_escaped(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res)
+size_t mycss_string_process_state_escaped(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res)
{
const unsigned char *u_data = (const unsigned char*)data;
- myhtml_encoding_custom_f func = myhtml_encoding_get_function_by_id(out_res->encoding);
- myhtml_encoding_result_t *encoding_res = &out_res->encoding_res;
+ myencoding_custom_f func = myencoding_get_function_by_id(out_res->encoding);
+ myencoding_result_t *encoding_res = &out_res->encoding_res;
char convert_data[4] = {0};
while(length < size)
{
- enum myhtml_encoding_status encoding_status = func(u_data[length], encoding_res);
+ myencoding_status_t encoding_status = func(u_data[length], encoding_res);
- if(encoding_status == MyHTML_ENCODING_STATUS_OK)
+ if(encoding_status == MyENCODING_STATUS_OK)
{
- myhtml_encoding_codepoint_to_ascii_utf_8(encoding_res->result, convert_data);
+ myencoding_codepoint_to_ascii_utf_8(encoding_res->result, convert_data);
- if(myhtml_string_chars_hex_map[(unsigned char)convert_data[0]] != 0xff) {
+ if(mycore_string_chars_hex_map[(unsigned char)convert_data[0]] != 0xff) {
out_res->escaped.code_point <<= 4;
- out_res->escaped.code_point |= myhtml_string_chars_hex_map[ (unsigned char)convert_data[0] ];
+ out_res->escaped.code_point |= mycore_string_chars_hex_map[ (unsigned char)convert_data[0] ];
++out_res->escaped.consumed;
@@ -96,15 +96,15 @@ size_t mycss_string_process_state_escaped(myhtml_string_t* str, const char* data
return length;
}
-size_t mycss_string_process_state_escaped_utf_8(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res)
+size_t mycss_string_process_state_escaped_utf_8(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res)
{
const unsigned char *u_data = (const unsigned char*)data;
while(length < size)
{
- if(myhtml_string_chars_hex_map[u_data[length]] != 0xff) {
+ if(mycore_string_chars_hex_map[u_data[length]] != 0xff) {
out_res->escaped.code_point <<= 4;
- out_res->escaped.code_point |= myhtml_string_chars_hex_map[ u_data[length] ];
+ out_res->escaped.code_point |= mycore_string_chars_hex_map[ u_data[length] ];
++out_res->escaped.consumed;
@@ -137,30 +137,30 @@ void mycss_string_escaped_res_clean(mycss_string_escaped_res_t* res)
void mycss_string_res_clean(mycss_string_res_t* res)
{
memset(res, 0, sizeof(mycss_string_res_t));
- memset(&res->encoding_res, 0, sizeof(myhtml_encoding_result_t));
+ memset(&res->encoding_res, 0, sizeof(myencoding_result_t));
}
-size_t mycss_string_process_state_data(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res)
+size_t mycss_string_process_state_data(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res)
{
char *str_data = str->data;
unsigned const char* u_str_data = (unsigned const char*)data;
- myhtml_encoding_custom_f func = myhtml_encoding_get_function_by_id(out_res->encoding);
- myhtml_encoding_result_t *encoding_res = &out_res->encoding_res;
+ myencoding_custom_f func = myencoding_get_function_by_id(out_res->encoding);
+ myencoding_result_t *encoding_res = &out_res->encoding_res;
while(length < size)
{
- enum myhtml_encoding_status encoding_status = func(u_str_data[length], encoding_res);
+ myencoding_status_t encoding_status = func(u_str_data[length], encoding_res);
- if(encoding_status == MyHTML_ENCODING_STATUS_OK)
+ if(encoding_status == MyENCODING_STATUS_OK)
{
if((str->length + 4) >= str->size) {
- myhtml_string_realloc(str, (str->size + 16));
+ mycore_string_realloc(str, (str->size + 16));
str_data = str->data;
}
- size_t len = myhtml_encoding_codepoint_to_ascii_utf_8(encoding_res->result, &str_data[str->length]);
+ size_t len = myencoding_codepoint_to_ascii_utf_8(encoding_res->result, &str_data[str->length]);
if(len == 1) {
if(str_data[str->length] == '\\') {
@@ -180,7 +180,7 @@ size_t mycss_string_process_state_data(myhtml_string_t* str, const char* data, s
str_data[str->length] = '\n';
}
else if(str_data[str->length] == '\0') {
- myhtml_string_raw_set_replacement_character(str, str->length);
+ mycore_string_raw_set_replacement_character(str, str->length);
str->length += 2;
}
}
@@ -194,7 +194,7 @@ size_t mycss_string_process_state_data(myhtml_string_t* str, const char* data, s
return length;
}
-size_t mycss_string_process_state_data_utf_8(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res)
+size_t mycss_string_process_state_data_utf_8(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res)
{
char *str_data = str->data;
@@ -208,7 +208,7 @@ size_t mycss_string_process_state_data_utf_8(myhtml_string_t* str, const char* d
}
if(str->length >= str->size) {
- myhtml_string_realloc(str, (str->size + 16));
+ mycore_string_realloc(str, (str->size + 16));
str_data = str->data;
}
@@ -224,7 +224,7 @@ size_t mycss_string_process_state_data_utf_8(myhtml_string_t* str, const char* d
str_data[str->length] = '\n';
}
else if(data[length] == '\0') {
- myhtml_string_raw_set_replacement_character(str, str->length);
+ mycore_string_raw_set_replacement_character(str, str->length);
str->length += 2;
}
else
@@ -237,9 +237,9 @@ size_t mycss_string_process_state_data_utf_8(myhtml_string_t* str, const char* d
return length;
}
-size_t mycss_string_data_process(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res)
+size_t mycss_string_data_process(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res)
{
- if(out_res->encoding == MyHTML_ENCODING_UTF_8) {
+ if(out_res->encoding == MyENCODING_UTF_8) {
while(length < size) {
length = mycss_string_state_list_map_utf_8[ out_res->state ](str, data, length, size, out_res);
}
@@ -253,7 +253,7 @@ size_t mycss_string_data_process(myhtml_string_t* str, const char* data, size_t
return length;
}
-void mycss_string_data_process_end(myhtml_string_t* str, mycss_string_res_t *out_res)
+void mycss_string_data_process_end(mycore_string_t* str, mycss_string_res_t *out_res)
{
if(out_res->state == MyCSS_STRING_PROCESS_STATE_ESCAPED) {
mycss_string_append_codepoint_to_string(str, out_res->escaped.code_point);
@@ -264,7 +264,7 @@ void mycss_string_data_process_end(myhtml_string_t* str, mycss_string_res_t *out
}
if(str->length >= str->size)
- myhtml_string_realloc(str, (str->size + 2));
+ mycore_string_realloc(str, (str->size + 2));
str->data[str->length] = '\0';
@@ -272,7 +272,7 @@ void mycss_string_data_process_end(myhtml_string_t* str, mycss_string_res_t *out
unsigned char *u_data = (unsigned char*)str->data;
for(size_t i = 0; i < str->length; i++)
- u_data[i] = myhtml_string_chars_lowercase_map[u_data[i]];
+ u_data[i] = mycore_string_chars_lowercase_map[u_data[i]];
}
}
diff --git a/source/mycss/mystring.h b/source/mycss/mystring.h
index 883b080..63a5d85 100644
--- a/source/mycss/mystring.h
+++ b/source/mycss/mystring.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -27,9 +27,10 @@ extern "C" {
#endif
#include "mycss/myosi.h"
-#include "myhtml/incoming.h"
-#include "myhtml/mystring.h"
-
+#include "mycore/incoming.h"
+#include "mycore/mystring.h"
+#include "myencoding/encoding.h"
+
enum mycss_string_process_state {
MyCSS_STRING_PROCESS_STATE_DATA = 0x00,
MyCSS_STRING_PROCESS_STATE_ESCAPED = 0x01,
@@ -46,18 +47,18 @@ struct mycss_string_res {
mycss_string_escaped_res_t escaped;
mycss_string_process_state_t state;
- myhtml_encoding_t encoding;
- myhtml_encoding_result_t encoding_res;
+ myencoding_t encoding;
+ myencoding_result_t encoding_res;
bool case_insensitive;
};
-size_t mycss_string_data_process(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
-void mycss_string_data_process_end(myhtml_string_t* str, mycss_string_res_t *out_res);
+size_t mycss_string_data_process(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
+void mycss_string_data_process_end(mycore_string_t* str, mycss_string_res_t *out_res);
-size_t mycss_string_process_state_data(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
-size_t mycss_string_process_state_data_utf_8(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
-size_t mycss_string_process_state_escaped(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
-size_t mycss_string_process_state_escaped_utf_8(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
+size_t mycss_string_process_state_data(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
+size_t mycss_string_process_state_data_utf_8(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
+size_t mycss_string_process_state_escaped(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
+size_t mycss_string_process_state_escaped_utf_8(mycore_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
void mycss_string_res_clean(mycss_string_res_t* res);
void mycss_string_escaped_res_clean(mycss_string_escaped_res_t* res);
diff --git a/source/mycss/namespace/init.c b/source/mycss/namespace/init.c
index 017449f..419a3d1 100644
--- a/source/mycss/namespace/init.c
+++ b/source/mycss/namespace/init.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -22,17 +22,17 @@
mycss_namespace_t * mycss_namespace_create(void)
{
- return (mycss_namespace_t*)myhtml_calloc(1, sizeof(mycss_namespace_t));
+ return (mycss_namespace_t*)mycore_calloc(1, sizeof(mycss_namespace_t));
}
-mycss_status_t mycss_namespace_init(mycss_entry_t* entry, mycss_namespace_t* ns)
+mystatus_t mycss_namespace_init(mycss_entry_t* entry, mycss_namespace_t* ns)
{
/* Objects Namespace */
ns->mcobject_entries = mcobject_create();
if(ns->mcobject_entries == NULL)
return MyCSS_STATUS_ERROR_NAMESPACE_ENTRIES_CREATE;
- myhtml_status_t myhtml_status = mcobject_init(ns->mcobject_entries, 256, sizeof(mycss_namespace_entry_t));
+ mystatus_t myhtml_status = mcobject_init(ns->mcobject_entries, 256, sizeof(mycss_namespace_entry_t));
if(myhtml_status)
return MyCSS_STATUS_ERROR_NAMESPACE_ENTRIES_INIT;
@@ -44,7 +44,7 @@ void mycss_namespace_clean(mycss_namespace_t* ns)
ns->entry = NULL;
}
-mycss_status_t mycss_namespace_clean_all(mycss_namespace_t* ns)
+mystatus_t mycss_namespace_clean_all(mycss_namespace_t* ns)
{
mcobject_clean(ns->mcobject_entries);
ns->entry = NULL;
@@ -60,7 +60,7 @@ mycss_namespace_t * mycss_namespace_destroy(mycss_namespace_t* ns, bool self_des
ns->mcobject_entries = mcobject_destroy(ns->mcobject_entries, true);
if(self_destroy) {
- myhtml_free(ns);
+ mycore_free(ns);
return NULL;
}
@@ -80,17 +80,17 @@ void mycss_namespace_entry_clean(mycss_namespace_entry_t* ns_entry)
mycss_namespace_entry_t * mycss_namespace_entry_destroy(mycss_namespace_entry_t* ns_entry, mycss_entry_t* entry, bool self_destroy)
{
if(ns_entry->name) {
- myhtml_string_destroy(ns_entry->name, false);
+ mycore_string_destroy(ns_entry->name, false);
mcobject_free(entry->mcobject_string_entries, ns_entry->name);
}
if(ns_entry->url) {
- myhtml_string_destroy(ns_entry->url, false);
+ mycore_string_destroy(ns_entry->url, false);
mcobject_free(entry->mcobject_string_entries, ns_entry->url);
}
if(self_destroy) {
- myhtml_free(ns_entry);
+ mycore_free(ns_entry);
return NULL;
}
@@ -110,7 +110,7 @@ void mycss_namespace_entry_append_to_current(mycss_namespace_t* ns, mycss_namesp
ns->entry_last = ns_entry;
}
-mycss_status_t mycss_namespace_stylesheet_init(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry)
+mystatus_t mycss_namespace_stylesheet_init(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry)
{
ns_stylesheet->name_tree = mctree_create(14);
if(ns_stylesheet->name_tree == NULL)
@@ -135,7 +135,7 @@ mycss_status_t mycss_namespace_stylesheet_init(mycss_namespace_stylesheet_t* ns_
if(ns_stylesheet->entry_any.name == NULL)
return MyCSS_STATUS_ERROR_STRING_CREATE;
- myhtml_string_append(ns_stylesheet->entry_any.name, "*", 1);
+ mycore_string_append(ns_stylesheet->entry_any.name, "*", 1);
ns_stylesheet->entry_any.ns_id = MyHTML_NAMESPACE_ANY;
mycss_namespace_stylesheet_init_default(ns_stylesheet, entry, NULL, 0, MyHTML_NAMESPACE_ANY);
@@ -143,7 +143,7 @@ mycss_status_t mycss_namespace_stylesheet_init(mycss_namespace_stylesheet_t* ns_
return MyCSS_STATUS_OK;
}
-mycss_status_t mycss_namespace_stylesheet_clean(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry)
+mystatus_t mycss_namespace_stylesheet_clean(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry)
{
mctree_clean(ns_stylesheet->name_tree);
ns_stylesheet->ns_id_counter = 0;
@@ -167,32 +167,32 @@ mycss_namespace_stylesheet_t * mycss_namespace_stylesheet_destroy(mycss_namespac
}
ns_stylesheet->name_tree = mctree_destroy(ns_stylesheet->name_tree);
- ns_stylesheet->entry_undef.name = myhtml_string_destroy(ns_stylesheet->entry_undef.name, false);
- ns_stylesheet->entry_any.name = myhtml_string_destroy(ns_stylesheet->entry_any.name, false);
+ ns_stylesheet->entry_undef.name = mycore_string_destroy(ns_stylesheet->entry_undef.name, false);
+ ns_stylesheet->entry_any.name = mycore_string_destroy(ns_stylesheet->entry_any.name, false);
if(self_destroy) {
- myhtml_free(ns_stylesheet);
+ mycore_free(ns_stylesheet);
return NULL;
}
return ns_stylesheet;
}
-mycss_status_t mycss_namespace_stylesheet_init_default(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry, const char* url, size_t url_length, myhtml_namespace_t def_ns)
+mystatus_t mycss_namespace_stylesheet_init_default(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry, const char* url, size_t url_length, myhtml_namespace_t def_ns)
{
- myhtml_string_t *str = ns_stylesheet->entry_default->url;
+ mycore_string_t *str = ns_stylesheet->entry_default->url;
if(str == NULL) {
str = mcobject_malloc(entry->mcobject_string_entries, NULL);
- myhtml_string_init(entry->mchar, entry->mchar_node_id, str, (url_length + 1));
+ mycore_string_init(entry->mchar, entry->mchar_node_id, str, (url_length + 1));
ns_stylesheet->entry_default->url = str;
}
else
- myhtml_string_clean(str);
+ mycore_string_clean(str);
if(url && url_length) {
- myhtml_string_append(str, url, url_length);
+ mycore_string_append(str, url, url_length);
ns_stylesheet->entry_default->ns_id = myhtml_namespace_id_by_url(url, url_length);
}
else
@@ -226,10 +226,10 @@ void mycss_namespace_stylesheet_append_default(mycss_namespace_stylesheet_t* ns_
void mycss_namespace_stylesheet_destroy_default(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry)
{
- myhtml_string_t *str = ns_stylesheet->entry_default->url;
+ mycore_string_t *str = ns_stylesheet->entry_default->url;
if(str) {
- myhtml_string_destroy(str, false);
+ mycore_string_destroy(str, false);
mcobject_free(entry->mcobject_string_entries, str);
ns_stylesheet->entry_default->url = NULL;
diff --git a/source/mycss/namespace/init.h b/source/mycss/namespace/init.h
index 528e8a3..ccc27e2 100644
--- a/source/mycss/namespace/init.h
+++ b/source/mycss/namespace/init.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -31,16 +31,16 @@ extern "C" {
#include "myhtml/mynamespace.h"
mycss_namespace_t * mycss_namespace_create(void);
-mycss_status_t mycss_namespace_init(mycss_entry_t* entry, mycss_namespace_t* ns);
+mystatus_t mycss_namespace_init(mycss_entry_t* entry, mycss_namespace_t* ns);
void mycss_namespace_clean(mycss_namespace_t* ns);
-mycss_status_t mycss_namespace_clean_all(mycss_namespace_t* ns);
+mystatus_t mycss_namespace_clean_all(mycss_namespace_t* ns);
mycss_namespace_t * mycss_namespace_destroy(mycss_namespace_t* ns, bool self_destroy);
-mycss_status_t mycss_namespace_stylesheet_init(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry);
-mycss_status_t mycss_namespace_stylesheet_clean(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry);
+mystatus_t mycss_namespace_stylesheet_init(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry);
+mystatus_t mycss_namespace_stylesheet_clean(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry);
mycss_namespace_stylesheet_t * mycss_namespace_stylesheet_destroy(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry, bool self_destroy);
-mycss_status_t mycss_namespace_stylesheet_init_default(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry, const char* url, size_t url_length, myhtml_namespace_t def_ns);
+mystatus_t mycss_namespace_stylesheet_init_default(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry, const char* url, size_t url_length, myhtml_namespace_t def_ns);
void mycss_namespace_stylesheet_append_default(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_namespace_entry_t* ns_entry);
void mycss_namespace_stylesheet_destroy_default(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_entry_t* entry);
diff --git a/source/mycss/namespace/myosi.h b/source/mycss/namespace/myosi.h
index 884605f..7d96e16 100644
--- a/source/mycss/namespace/myosi.h
+++ b/source/mycss/namespace/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -28,16 +28,16 @@ extern "C" {
#include "mycss/myosi.h"
#include "myhtml/mystring.h"
-#include "myhtml/utils/mctree.h"
-#include "myhtml/utils/mcobject.h"
+#include "mycore/utils/mctree.h"
+#include "mycore/utils/mcobject.h"
typedef struct mycss_namespace mycss_namespace_t;
typedef struct mycss_namespace_entry mycss_namespace_entry_t;
typedef struct mycss_namespace_stylesheet mycss_namespace_stylesheet_t;
struct mycss_namespace_entry {
- myhtml_string_t* name;
- myhtml_string_t* url;
+ mycore_string_t* name;
+ mycore_string_t* url;
myhtml_namespace_t ns_id;
size_t mctree_id;
diff --git a/source/mycss/namespace/parser.c b/source/mycss/namespace/parser.c
index c442316..5dd9499 100644
--- a/source/mycss/namespace/parser.c
+++ b/source/mycss/namespace/parser.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -31,7 +31,7 @@ void mycss_namespace_parser_begin(mycss_entry_t* entry)
void mycss_namespace_parser_name(mycss_entry_t* entry, mycss_token_t* token)
{
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
mycss_token_data_to_string(entry, token, str, true, false);
entry->ns->entry_last->name = str;
@@ -39,7 +39,7 @@ void mycss_namespace_parser_name(mycss_entry_t* entry, mycss_token_t* token)
void mycss_namespace_parser_url(mycss_entry_t* entry, mycss_token_t* token)
{
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
mycss_token_data_to_string(entry, token, str, true, false);
entry->ns->entry_last->url = str;
@@ -49,11 +49,11 @@ void mycss_namespace_parser_end(mycss_entry_t* entry, mycss_token_t* token)
{
mycss_namespace_entry_t *ns_entry = entry->ns->entry_last;
- myhtml_string_t *str_url = entry->ns->entry_last->url;
+ mycore_string_t *str_url = entry->ns->entry_last->url;
ns_entry->ns_id = myhtml_namespace_id_by_url(str_url->data, str_url->length);
if(ns_entry->name) {
- myhtml_string_t *str = ns_entry->name;
+ mycore_string_t *str = ns_entry->name;
ns_entry->mctree_id = mctree_insert(entry->ns->ns_stylesheet->name_tree, str->data, str->length, (void*)ns_entry, NULL);
diff --git a/source/mycss/namespace/parser.h b/source/mycss/namespace/parser.h
index 630e39a..40b06dd 100644
--- a/source/mycss/namespace/parser.h
+++ b/source/mycss/namespace/parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -29,7 +29,7 @@ extern "C" {
#include "mycss/entry.h"
#include "mycss/namespace/myosi.h"
#include "myhtml/mynamespace.h"
-#include "myhtml/utils/mctree.h"
+#include "mycore/utils/mctree.h"
void mycss_namespace_parser_begin(mycss_entry_t* entry);
diff --git a/source/mycss/namespace/serialization.c b/source/mycss/namespace/serialization.c
index 1dc60d1..2743b06 100644
--- a/source/mycss/namespace/serialization.c
+++ b/source/mycss/namespace/serialization.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "mycss/namespace/serialization.h"
-void mycss_namespace_serialization_stylesheet(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_callback_serialization_f callback, void* context)
+void mycss_namespace_serialization_stylesheet(mycss_namespace_stylesheet_t* ns_stylesheet, mycore_callback_serialize_f callback, void* context)
{
mycss_namespace_entry_t* ns_entry = ns_stylesheet->entry_first;
@@ -43,13 +43,13 @@ void mycss_namespace_serialization_stylesheet(mycss_namespace_stylesheet_t* ns_s
}
}
-void mycss_namespace_serialization_entry(mycss_namespace_t* ns, mycss_namespace_entry_t* ns_entry, mycss_callback_serialization_f callback, void* context, bool with_vbar)
+void mycss_namespace_serialization_entry(mycss_namespace_t* ns, mycss_namespace_entry_t* ns_entry, mycore_callback_serialize_f callback, void* context, bool with_vbar)
{
if(ns_entry->name && ns_entry->name->length) {
callback(ns_entry->name->data, ns_entry->name->length, context);
}
else if(ns_entry->ns_id == MyHTML_NAMESPACE_ANY)
- return; //fprintf(fh, "*");
+ return;
else if(ns_entry->ns_id == MyHTML_NAMESPACE_UNDEF) {
/* some print */
}
diff --git a/source/mycss/namespace/serialization.h b/source/mycss/namespace/serialization.h
index 1e87f3e..d11fa65 100644
--- a/source/mycss/namespace/serialization.h
+++ b/source/mycss/namespace/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -29,8 +29,8 @@
extern "C" {
#endif
-void mycss_namespace_serialization_stylesheet(mycss_namespace_stylesheet_t* ns_stylesheet, mycss_callback_serialization_f callback, void* context);
-void mycss_namespace_serialization_entry(mycss_namespace_t* ns, mycss_namespace_entry_t* ns_entry, mycss_callback_serialization_f callback, void* context, bool with_vbar);
+void mycss_namespace_serialization_stylesheet(mycss_namespace_stylesheet_t* ns_stylesheet, mycore_callback_serialize_f callback, void* context);
+void mycss_namespace_serialization_entry(mycss_namespace_t* ns, mycss_namespace_entry_t* ns_entry, mycore_callback_serialize_f callback, void* context, bool with_vbar);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/mycss/namespace/state.c b/source/mycss/namespace/state.c
index 9cf7208..11faeca 100644
--- a/source/mycss/namespace/state.c
+++ b/source/mycss/namespace/state.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -23,10 +23,10 @@
bool mycss_namespace_state_namespace(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
{
if(token->type == MyCSS_TOKEN_TYPE_AT_KEYWORD) {
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, true);
- if(myhtml_strcmp(str.data, "namespace") == 0) {
+ if(mycore_strcmp(str.data, "namespace") == 0) {
entry->parser = mycss_namespace_state_namespace_namespace;
}
else {
@@ -34,7 +34,7 @@ bool mycss_namespace_state_namespace(mycss_entry_t* entry, mycss_token_t* token,
entry->parser = mycss_parser_token;
}
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
}
else {
mycss_namespace_parser_expectations_error(entry, token);
@@ -110,7 +110,7 @@ bool mycss_namespace_state_namespace_namespace_ident_string(mycss_entry_t* entry
if(token->type == MyCSS_TOKEN_TYPE_SEMICOLON) {
mycss_namespace_parser_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_namespace_state_namespace_namespace_ident_string_semicolon")
+ MyCORE_DEBUG("mycss_namespace_state_namespace_namespace_ident_string_semicolon");
entry->parser = mycss_parser_token;
}
else {
@@ -129,7 +129,7 @@ bool mycss_namespace_state_namespace_namespace_ident_url(mycss_entry_t* entry, m
if(token->type == MyCSS_TOKEN_TYPE_SEMICOLON) {
mycss_namespace_parser_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_namespace_state_namespace_namespace_ident_url_semicolon")
+ MyCORE_DEBUG("mycss_namespace_state_namespace_namespace_ident_url_semicolon");
entry->parser = mycss_parser_token;
}
else {
@@ -148,7 +148,7 @@ bool mycss_namespace_state_namespace_namespace_string(mycss_entry_t* entry, mycs
if(token->type == MyCSS_TOKEN_TYPE_SEMICOLON) {
mycss_namespace_parser_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_namespace_state_namespace_namespace_string_semicolon")
+ MyCORE_DEBUG("mycss_namespace_state_namespace_namespace_string_semicolon");
entry->parser = mycss_parser_token;
}
else {
@@ -167,7 +167,7 @@ bool mycss_namespace_state_namespace_namespace_url(mycss_entry_t* entry, mycss_t
if(token->type == MyCSS_TOKEN_TYPE_SEMICOLON) {
mycss_namespace_parser_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_namespace_state_namespace_namespace_url_semicolon")
+ MyCORE_DEBUG("mycss_namespace_state_namespace_namespace_url_semicolon");
entry->parser = mycss_parser_token;
}
else {
diff --git a/source/mycss/namespace/state.h b/source/mycss/namespace/state.h
index ec7f031..715644c 100644
--- a/source/mycss/namespace/state.h
+++ b/source/mycss/namespace/state.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -29,7 +29,7 @@ extern "C" {
#include "mycss/entry.h"
#include "mycss/namespace/myosi.h"
#include "mycss/namespace/parser.h"
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
bool mycss_namespace_state_namespace(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_namespace_state_namespace_namespace(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
diff --git a/source/mycss/parser.c b/source/mycss/parser.c
index 2844e6a..76860f1 100644
--- a/source/mycss/parser.c
+++ b/source/mycss/parser.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -43,10 +43,10 @@ bool mycss_parser_token(mycss_entry_t* entry, mycss_token_t* token, bool last_re
break;
case MyCSS_TOKEN_TYPE_AT_KEYWORD: {
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, true);
- if(myhtml_strcmp(str.data, "namespace") == 0) {
+ if(mycore_strcmp(str.data, "namespace") == 0) {
mycss_namespace_t *ns = entry->ns;
ns->ns_stylesheet = &entry->stylesheet->ns_stylesheet;
@@ -58,7 +58,7 @@ bool mycss_parser_token(mycss_entry_t* entry, mycss_token_t* token, bool last_re
entry->parser = mycss_parser_token_drop_at_rule;
}
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
mycss_entry_parser_list_push(entry, mycss_parser_token, entry->parser_switch, MyCSS_TOKEN_TYPE_UNDEF, false);
break;
diff --git a/source/mycss/parser.h b/source/mycss/parser.h
index bec7eb5..28e6fbc 100644
--- a/source/mycss/parser.h
+++ b/source/mycss/parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -35,7 +35,7 @@ extern "C" {
#include "mycss/selectors/state.h"
#include "mycss/selectors/parser.h"
#include "mycss/declaration/state.h"
-#include "myhtml/incoming.h"
+#include "mycore/incoming.h"
mycss_token_t * mycss_parser_token_ready_callback_function(mycss_entry_t* entry, mycss_token_t* token);
diff --git a/source/mycss/property/const.h b/source/mycss/property/const.h
index cd430ea..8881359 100644
--- a/source/mycss/property/const.h
+++ b/source/mycss/property/const.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/source/mycss/property/init.c b/source/mycss/property/init.c
index 3b8169b..551018e 100644
--- a/source/mycss/property/init.c
+++ b/source/mycss/property/init.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,22 +20,22 @@
#include "mycss/property/init.h"
#include "mycss/property/resources.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
const mycss_property_index_static_entry_t * mycss_property_index_entry_by_name(const char* name, size_t length)
{
if(length == 0)
return NULL;
- size_t idx = ((myhtml_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
- myhtml_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
+ size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
+ mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
length)
% MyCSS_PROPERTY_STATIC_INDEX_FOR_SEARCH_SIZE) + 1;
while (mycss_property_index_static_for_search[idx].name)
{
if(mycss_property_index_static_for_search[idx].name_length == length) {
- if(myhtml_strncasecmp(mycss_property_index_static_for_search[idx].name, name, length) == 0)
+ if(mycore_strncasecmp(mycss_property_index_static_for_search[idx].name, name, length) == 0)
return &mycss_property_index_static_for_search[idx];
if(mycss_property_index_static_for_search[idx].next)
@@ -69,15 +69,15 @@ const mycss_property_value_index_static_entry_t * mycss_property_value_index_ent
if(length == 0)
return NULL;
- size_t idx = ((myhtml_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
- myhtml_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
+ size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
+ mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
length)
% MyCSS_PROPERTY_VALUE_STATIC_INDEX_FOR_SEARCH_SIZE) + 1;
while (mycss_property_value_index_static_for_search[idx].name)
{
if(mycss_property_value_index_static_for_search[idx].name_length == length) {
- if(myhtml_strncasecmp(mycss_property_value_index_static_for_search[idx].name, name, length) == 0)
+ if(mycore_strncasecmp(mycss_property_value_index_static_for_search[idx].name, name, length) == 0)
return &mycss_property_value_index_static_for_search[idx];
if(mycss_property_value_index_static_for_search[idx].next)
diff --git a/source/mycss/property/init.h b/source/mycss/property/init.h
index f63d37d..7470203 100644
--- a/source/mycss/property/init.h
+++ b/source/mycss/property/init.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -25,7 +25,7 @@
#include "mycss/property/myosi.h"
#include "mycss/property/parser.h"
#include "mycss/values/serialization.h"
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
#ifdef __cplusplus
extern "C" {
diff --git a/source/mycss/property/myosi.h b/source/mycss/property/myosi.h
index f1e50e3..6a626e2 100644
--- a/source/mycss/property/myosi.h
+++ b/source/mycss/property/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/property/parser.c b/source/mycss/property/parser.c
index 4bb81b2..5899cbd 100644
--- a/source/mycss/property/parser.c
+++ b/source/mycss/property/parser.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "mycss/property/parser.h"
-bool mycss_property_parser_destroy_string(myhtml_string_t* str, bool return_value)
+bool mycss_property_parser_destroy_string(mycore_string_t* str, bool return_value)
{
mycss_property_shared_destroy_string(str);
return return_value;
@@ -47,7 +47,7 @@ bool mycss_property_parser_width(mycss_entry_t* entry, mycss_token_t* token, boo
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
if(mycss_property_shared_width(entry, token, &declr_entry->value, &declr_entry->value_type, &str)) {
@@ -62,7 +62,7 @@ bool mycss_property_parser_height(mycss_entry_t* entry, mycss_token_t* token, bo
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
if(mycss_property_shared_height(entry, token, &declr_entry->value, &declr_entry->value_type, &str))
@@ -76,7 +76,7 @@ bool mycss_property_parser_max_width(mycss_entry_t* entry, mycss_token_t* token,
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_length_percentage(entry, token, &dec_entry->value, &dec_entry->value_type, &str))
@@ -116,7 +116,7 @@ bool mycss_property_parser_min_width(mycss_entry_t* entry, mycss_token_t* token,
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_length_percentage(entry, token, &dec_entry->value, &dec_entry->value_type, &str) ||
@@ -134,7 +134,7 @@ bool mycss_property_parser_min_height(mycss_entry_t* entry, mycss_token_t* token
}
/* padding */
-mycss_declaration_entry_t * mycss_property_parser_padding_shared(mycss_entry_t* entry, mycss_token_t* token, myhtml_string_t* str)
+mycss_declaration_entry_t * mycss_property_parser_padding_shared(mycss_entry_t* entry, mycss_token_t* token, mycore_string_t* str)
{
void *value = NULL;
unsigned int value_type = 0;
@@ -173,7 +173,7 @@ bool mycss_property_parser_padding(mycss_entry_t* entry, mycss_token_t* token, b
return true;
}
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
if(value->one == NULL)
{
@@ -212,7 +212,7 @@ bool mycss_property_parser_padding_X(mycss_entry_t* entry, mycss_token_t* token,
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_length_percentage(entry, token, &dec_entry->value, &dec_entry->value_type, &str) ||
@@ -266,7 +266,7 @@ bool mycss_property_parser_padding_inline_end(mycss_entry_t* entry, mycss_token_
}
/* margin */
-mycss_declaration_entry_t * mycss_property_parser_margin_shared(mycss_entry_t* entry, mycss_token_t* token, myhtml_string_t* str)
+mycss_declaration_entry_t * mycss_property_parser_margin_shared(mycss_entry_t* entry, mycss_token_t* token, mycore_string_t* str)
{
void *value = NULL;
unsigned int value_type = 0;
@@ -306,7 +306,7 @@ bool mycss_property_parser_margin(mycss_entry_t* entry, mycss_token_t* token, bo
return true;
}
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
if(value->one == NULL)
{
@@ -345,7 +345,7 @@ bool mycss_property_parser_margin_X(mycss_entry_t* entry, mycss_token_t* token,
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_length(entry, token, &dec_entry->value, &dec_entry->value_type, &str) ||
@@ -405,7 +405,7 @@ bool mycss_property_parser_display(mycss_entry_t* entry, mycss_token_t* token, b
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
if(token->type == MyCSS_TOKEN_TYPE_IDENT)
{
@@ -459,7 +459,7 @@ bool mycss_property_parser_display(mycss_entry_t* entry, mycss_token_t* token, b
}
/* border */
-mycss_declaration_entry_t * mycss_property_parser_border_width_shared(mycss_entry_t* entry, mycss_token_t* token, myhtml_string_t* str)
+mycss_declaration_entry_t * mycss_property_parser_border_width_shared(mycss_entry_t* entry, mycss_token_t* token, mycore_string_t* str)
{
void *value = NULL;
unsigned int value_type = 0;
@@ -478,7 +478,7 @@ mycss_declaration_entry_t * mycss_property_parser_border_width_shared(mycss_entr
}
static mycss_declaration_entry_t * mycss_property_parser_border_color_shared(mycss_entry_t* entry, mycss_token_t* token,
- myhtml_string_t* str, mycss_parser_token_f return_parser,
+ mycore_string_t* str, mycss_parser_token_f return_parser,
unsigned int type)
{
void *value = NULL;
@@ -504,7 +504,7 @@ static mycss_declaration_entry_t * mycss_property_parser_border_color_shared(myc
return NULL;
}
-mycss_declaration_entry_t * mycss_property_parser_border_style_shared(mycss_entry_t* entry, mycss_token_t* token, myhtml_string_t* str)
+mycss_declaration_entry_t * mycss_property_parser_border_style_shared(mycss_entry_t* entry, mycss_token_t* token, mycore_string_t* str)
{
unsigned int value_type = 0;
@@ -542,7 +542,7 @@ bool mycss_property_parser_border_top(mycss_entry_t* entry, mycss_token_t* token
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
unsigned int value_type = 0;
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
@@ -658,7 +658,7 @@ bool mycss_property_parser_border_width(mycss_entry_t* entry, mycss_token_t* tok
return true;
}
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
if(value->one == NULL)
{
@@ -697,7 +697,7 @@ bool mycss_property_parser_border_top_width(mycss_entry_t* entry, mycss_token_t*
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
if(mycss_property_shared_line_width(entry, token, &declr_entry->value, &declr_entry->value_type, &str)) {
@@ -764,7 +764,7 @@ bool mycss_property_parser_border_style(mycss_entry_t* entry, mycss_token_t* tok
return true;
}
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
if(value->one == NULL)
{
@@ -803,7 +803,7 @@ bool mycss_property_parser_border_top_style(mycss_entry_t* entry, mycss_token_t*
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
if(mycss_property_shared_line_style(entry, token, &declr_entry->value_type, &str)) {
@@ -850,7 +850,7 @@ bool mycss_property_parser_border_inline_end_style(mycss_entry_t* entry, mycss_t
}
/* border radius */
-static mycss_declaration_entry_t * mycss_property_parser_border_radius_shared(mycss_entry_t* entry, mycss_token_t* token, myhtml_string_t* str, bool is_first)
+static mycss_declaration_entry_t * mycss_property_parser_border_radius_shared(mycss_entry_t* entry, mycss_token_t* token, mycore_string_t* str, bool is_first)
{
void *value = NULL;
unsigned int value_type = 0;
@@ -878,7 +878,7 @@ static mycss_declaration_entry_t * mycss_property_parser_border_radius_shared(my
}
static bool mycss_property_parser_border_radius_two_shared(mycss_entry_t* entry, mycss_token_t* token,
- mycss_values_shorthand_two_type_t *short_two_type, myhtml_string_t* str)
+ mycss_values_shorthand_two_type_t *short_two_type, mycore_string_t* str)
{
if(mycss_property_shared_length_percentage(entry, token, &short_two_type->two, &short_two_type->type_two, str)) {
return true;
@@ -899,7 +899,7 @@ bool mycss_property_parser_border_radius_two(mycss_entry_t* entry, mycss_token_t
return true;
}
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
if(((mycss_values_shorthand_two_type_t*)(value->one->value))->two == NULL)
{
@@ -983,7 +983,7 @@ bool mycss_property_parser_border_radius(mycss_entry_t* entry, mycss_token_t* to
return true;
}
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
if(value->one == NULL)
{
@@ -1053,7 +1053,7 @@ bool mycss_property_parser_border_top_right_radius(mycss_entry_t* entry, mycss_t
return true;
}
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
if(short_two_type->one == NULL)
{
@@ -1096,7 +1096,7 @@ bool mycss_property_parser_border_color(mycss_entry_t* entry, mycss_token_t* tok
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
mycss_values_shorthand_four_t *value = dec_entry->value;
@@ -1208,7 +1208,7 @@ bool mycss_property_parser_box_sizing(mycss_entry_t* entry, mycss_token_t* token
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return mycss_property_shared_switch_to_parse_error(entry);
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_token_data_to_string(entry, token, &str, true, false);
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
@@ -1236,7 +1236,7 @@ bool mycss_property_parser_vertical_align(mycss_entry_t* entry, mycss_token_t* t
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_length_percentage(entry, token, &dec_entry->value, &dec_entry->value_type, &str))
@@ -1278,7 +1278,7 @@ bool mycss_property_parser_line_height(mycss_entry_t* entry, mycss_token_t* toke
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_line_height(entry, token, &dec_entry->value, &dec_entry->value_type, &str))
@@ -1293,7 +1293,7 @@ bool mycss_property_parser_color(mycss_entry_t* entry, mycss_token_t* token, boo
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
bool parser_changed = false;
@@ -1330,7 +1330,7 @@ bool mycss_property_parser_position(mycss_entry_t* entry, mycss_token_t* token,
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -1364,7 +1364,7 @@ bool mycss_property_parser_z_index(mycss_entry_t* entry, mycss_token_t* token, b
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_number(entry, token, &dec_entry->value, &dec_entry->value_type, &str))
@@ -1400,7 +1400,7 @@ bool mycss_property_parser_cursor(mycss_entry_t* entry, mycss_token_t* token, bo
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -1465,7 +1465,7 @@ bool mycss_property_parser_float(mycss_entry_t* entry, mycss_token_t* token, boo
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -1500,7 +1500,7 @@ bool mycss_property_parser_float_displace(mycss_entry_t* entry, mycss_token_t* t
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -1533,7 +1533,7 @@ bool mycss_property_parser_top(mycss_entry_t* entry, mycss_token_t* token, bool
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_length_percentage(entry, token, &dec_entry->value, &dec_entry->value_type, &str))
@@ -1584,7 +1584,7 @@ bool mycss_property_parser_clear(mycss_entry_t* entry, mycss_token_t* token, boo
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -1616,7 +1616,7 @@ bool mycss_property_parser_clear_after(mycss_entry_t* entry, mycss_token_t* toke
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -1656,7 +1656,7 @@ bool mycss_property_parser_overflow(mycss_entry_t* entry, mycss_token_t* token,
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -1690,7 +1690,7 @@ bool mycss_property_parser_overflow_wrap(mycss_entry_t* entry, mycss_token_t* to
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -1732,7 +1732,7 @@ bool mycss_property_parser_visibility(mycss_entry_t* entry, mycss_token_t* token
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -1764,7 +1764,7 @@ bool mycss_property_parser_font_weight(mycss_entry_t* entry, mycss_token_t* toke
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_font_weight(entry, token, &dec_entry->value_type, &str))
@@ -1778,7 +1778,7 @@ bool mycss_property_parser_font_size(mycss_entry_t* entry, mycss_token_t* token,
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_font_size(entry, token, &dec_entry->value, &dec_entry->value_type, &str))
@@ -1792,7 +1792,7 @@ bool mycss_property_parser_font_size_adjust(mycss_entry_t* entry, mycss_token_t*
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_number(entry, token, &dec_entry->value, &dec_entry->value_type, &str))
@@ -1827,7 +1827,7 @@ bool mycss_property_parser_font_stretch(mycss_entry_t* entry, mycss_token_t* tok
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_font_stretch(entry, token, &dec_entry->value_type, &str))
@@ -1841,7 +1841,7 @@ bool mycss_property_parser_font_style(mycss_entry_t* entry, mycss_token_t* token
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_font_style(entry, token, &dec_entry->value_type, &str))
@@ -1874,7 +1874,7 @@ bool mycss_property_parser_font_family(mycss_entry_t* entry, mycss_token_t* toke
if(mycss_property_shared_check_declaration_end(entry, token))
return true;
- myhtml_string_t str = {0}; bool dont_destroy_str;
+ mycore_string_t str = {0}; bool dont_destroy_str;
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_font_family(entry, token, &dec_entry->value, &dec_entry->value_type, &dont_destroy_str, &str)) {
@@ -1921,7 +1921,7 @@ bool mycss_property_parser_font_step_wait_family(mycss_entry_t* entry, mycss_tok
if(dec_entry->value == NULL)
return mycss_property_shared_switch_to_parse_error(entry);
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_values_font_t *font = (mycss_values_font_t*)dec_entry->value;
void *value = NULL;
@@ -1967,7 +1967,7 @@ bool mycss_property_parser_font_step_wait_line_height(mycss_entry_t* entry, mycs
void *value = NULL;
unsigned int value_type = 0;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_values_font_t *font = (mycss_values_font_t*)dec_entry->value;
if(mycss_property_shared_line_height(entry, token, &value, &value_type, &str)) {
@@ -2010,7 +2010,7 @@ bool mycss_property_parser_font_step_after_size(mycss_entry_t* entry, mycss_toke
unsigned int value_type = 0;
bool dont_destroy_str;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_values_font_t *font = (mycss_values_font_t*)dec_entry->value;
if(mycss_property_shared_font_family(entry, token, &value, &value_type, &dont_destroy_str, &str)) {
@@ -2038,7 +2038,7 @@ bool mycss_property_parser_font_step_one(mycss_entry_t* entry, mycss_token_t* to
if(mycss_property_shared_check_declaration_end(entry, token))
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(dec_entry->value == NULL)
@@ -2120,7 +2120,7 @@ bool mycss_property_parser_font(mycss_entry_t* entry, mycss_token_t* token, bool
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
dec_entry->value = mycss_values_create(entry, sizeof(mycss_values_font_t));
@@ -2206,7 +2206,7 @@ bool mycss_property_parser_text_align(mycss_entry_t* entry, mycss_token_t* token
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2242,7 +2242,7 @@ bool mycss_property_parser_text_align_all(mycss_entry_t* entry, mycss_token_t* t
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2277,7 +2277,7 @@ bool mycss_property_parser_text_align_last(mycss_entry_t* entry, mycss_token_t*
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2313,7 +2313,7 @@ bool mycss_property_parser_white_space(mycss_entry_t* entry, mycss_token_t* toke
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2346,7 +2346,7 @@ bool mycss_property_parser_text_transform(mycss_entry_t* entry, mycss_token_t* t
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2379,7 +2379,7 @@ bool mycss_property_parser_word_break(mycss_entry_t* entry, mycss_token_t* token
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2410,7 +2410,7 @@ bool mycss_property_parser_line_break(mycss_entry_t* entry, mycss_token_t* token
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2442,7 +2442,7 @@ bool mycss_property_parser_tab_size(mycss_entry_t* entry, mycss_token_t* token,
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_number(entry, token, &dec_entry->value, &dec_entry->value_type, &str) ||
@@ -2460,7 +2460,7 @@ bool mycss_property_parser_hyphens(mycss_entry_t* entry, mycss_token_t* token, b
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2496,7 +2496,7 @@ bool mycss_property_parser_text_justify(mycss_entry_t* entry, mycss_token_t* tok
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2528,7 +2528,7 @@ bool mycss_property_parser_word_spacing(mycss_entry_t* entry, mycss_token_t* tok
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_length_percentage(entry, token, &dec_entry->value, &dec_entry->value_type, &str) ||
@@ -2546,7 +2546,7 @@ bool mycss_property_parser_letter_spacing(mycss_entry_t* entry, mycss_token_t* t
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_length(entry, token, &dec_entry->value, &dec_entry->value_type, &str) ||
@@ -2564,7 +2564,7 @@ bool mycss_property_parser_direction(mycss_entry_t* entry, mycss_token_t* token,
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2594,7 +2594,7 @@ bool mycss_property_parser_unicode_bidi(mycss_entry_t* entry, mycss_token_t* tok
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2628,7 +2628,7 @@ bool mycss_property_parser_writing_mode(mycss_entry_t* entry, mycss_token_t* tok
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2661,7 +2661,7 @@ bool mycss_property_parser_text_orientation(mycss_entry_t* entry, mycss_token_t*
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
@@ -2692,7 +2692,7 @@ bool mycss_property_parser_glyph_orientation_vertical(mycss_entry_t* entry, mycs
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
diff --git a/source/mycss/property/parser.h b/source/mycss/property/parser.h
index 0140e9f..43917c0 100644
--- a/source/mycss/property/parser.h
+++ b/source/mycss/property/parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -34,7 +34,7 @@ extern "C" {
/* custom added */
bool mycss_property_parser_background_position_check(mycss_values_background_position_t *position);
-bool mycss_property_parser_destroy_string(myhtml_string_t* str, bool return_value);
+bool mycss_property_parser_destroy_string(mycore_string_t* str, bool return_value);
bool mycss_property_parser_switcher_to_find_important(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_property_parser_text_decoration_line_not_none(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_property_parser_text_decoration_line_after(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
diff --git a/source/mycss/property/parser_background.c b/source/mycss/property/parser_background.c
index c86612e..0900ca7 100644
--- a/source/mycss/property/parser_background.c
+++ b/source/mycss/property/parser_background.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -292,9 +292,9 @@ static bool mycss_property_parser_background_check_position(mycss_entry_t* entry
pos_entry->type = value_type;
if(value_type == MyCSS_PROPERTY_VALUE__LENGTH)
- pos_entry->length = value;
+ pos_entry->value.length = value;
else if(value_type == MyCSS_PROPERTY_VALUE__PERCENTAGE)
- pos_entry->percentage = value;
+ pos_entry->value.percentage = value;
return true;
}
@@ -304,7 +304,7 @@ static bool mycss_property_parser_background_step_size_height(mycss_entry_t* ent
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
mycss_values_background_t *background = mycss_values_background_list_current_entry(dec_entry->value);
@@ -319,7 +319,7 @@ static bool mycss_property_parser_background_step_size_height(mycss_entry_t* ent
if(value) {
bg_entry->height = mycss_values_create(entry, sizeof(mycss_values_type_length_percentage_entry_t));
- bg_entry->height->percentage = value;
+ bg_entry->height->value.percentage = value;
bg_entry->height->type = value_type;
}
else if(value_type == MyCSS_PROPERTY_BACKGROUND_SIZE_AUTO)
@@ -343,7 +343,7 @@ bool mycss_property_parser_background_step_size(mycss_entry_t* entry, mycss_toke
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
mycss_values_background_t *background = mycss_values_background_list_current_entry(dec_entry->value);
@@ -362,7 +362,7 @@ bool mycss_property_parser_background_step_size(mycss_entry_t* entry, mycss_toke
if(value) {
bg_entry->width = mycss_values_create(entry, sizeof(mycss_values_type_length_percentage_entry_t));
- bg_entry->width->percentage = value;
+ bg_entry->width->value.percentage = value;
bg_entry->width->type = value_type;
entry->parser = mycss_property_parser_background_step_size_height;
@@ -396,7 +396,7 @@ static bool mycss_property_parser_background_step_position(mycss_entry_t* entry,
return true;
}
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
void* value = NULL;
@@ -421,7 +421,7 @@ static bool mycss_property_parser_background_step_repeat_wait_two(mycss_entry_t*
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
mycss_values_background_t *background = mycss_values_background_list_current_entry(dec_entry->value);
@@ -457,7 +457,7 @@ bool mycss_property_parser_background(mycss_entry_t* entry, mycss_token_t* token
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_values_image_t stat_image;
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
@@ -695,7 +695,7 @@ bool mycss_property_parser_background_attachment(mycss_entry_t* entry, mycss_tok
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
unsigned int value_type = 0;
@@ -745,7 +745,7 @@ bool mycss_property_parser_background_clip(mycss_entry_t* entry, mycss_token_t*
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
unsigned int value_type = 0;
@@ -795,7 +795,7 @@ bool mycss_property_parser_background_image(mycss_entry_t* entry, mycss_token_t*
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_values_image_t stat_image;
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
@@ -873,7 +873,7 @@ bool mycss_property_parser_background_origin(mycss_entry_t* entry, mycss_token_t
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
unsigned int value_type = 0;
@@ -906,7 +906,7 @@ bool mycss_property_parser_background_position(mycss_entry_t* entry, mycss_token
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
void* value = NULL;
@@ -934,9 +934,9 @@ bool mycss_property_parser_background_position(mycss_entry_t* entry, mycss_token
pos_entry->type = value_type;
if(value_type == MyCSS_PROPERTY_VALUE__LENGTH)
- pos_entry->length = value;
+ pos_entry->value.length = value;
else if(value_type == MyCSS_PROPERTY_VALUE__PERCENTAGE)
- pos_entry->percentage = value;
+ pos_entry->value.percentage = value;
return mycss_property_parser_destroy_string(&str, true);
}
@@ -990,7 +990,7 @@ static bool mycss_property_parser_background_repeat_wait_two(mycss_entry_t* entr
return true;
}
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
unsigned int value_type = 0;
@@ -1023,7 +1023,7 @@ bool mycss_property_parser_background_repeat(mycss_entry_t* entry, mycss_token_t
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
unsigned int value_type = 0;
@@ -1077,7 +1077,7 @@ static bool mycss_property_parser_background_size_height(mycss_entry_t* entry, m
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
void *value = NULL;
@@ -1090,7 +1090,7 @@ static bool mycss_property_parser_background_size_height(mycss_entry_t* entry, m
if(value) {
bg_entry->height = mycss_values_create(entry, sizeof(mycss_values_type_length_percentage_entry_t));
- bg_entry->height->percentage = value;
+ bg_entry->height->value.percentage = value;
bg_entry->height->type = value_type;
entry->parser = mycss_property_parser_background_size_end;
@@ -1116,7 +1116,7 @@ bool mycss_property_parser_background_size(mycss_entry_t* entry, mycss_token_t*
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
void *value = NULL;
@@ -1131,7 +1131,7 @@ bool mycss_property_parser_background_size(mycss_entry_t* entry, mycss_token_t*
if(value) {
bg_entry->width = mycss_values_create(entry, sizeof(mycss_values_type_length_percentage_entry_t));
- bg_entry->width->percentage = value;
+ bg_entry->width->value.percentage = value;
bg_entry->width->type = value_type;
entry->parser = mycss_property_parser_background_size_height;
diff --git a/source/mycss/property/parser_image.c b/source/mycss/property/parser_image.c
index 159a046..751a719 100644
--- a/source/mycss/property/parser_image.c
+++ b/source/mycss/property/parser_image.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -56,11 +56,11 @@ bool mycss_property_parser_image_function_image(mycss_entry_t* entry, mycss_toke
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
mycss_values_image_t *image = (mycss_values_image_t*)declr_entry->value;
- mycss_values_image_image_t *image_image = image->ii;
+ mycss_values_image_image_t *image_image = image->value.ii;
void *value = NULL;
unsigned int value_type = 0;
@@ -82,7 +82,7 @@ bool mycss_property_parser_image_function_image(mycss_entry_t* entry, mycss_toke
if(token->type == MyCSS_TOKEN_TYPE_STRING)
{
- myhtml_string_t *ns_str = mycss_values_create(entry, sizeof(myhtml_string_t));
+ mycore_string_t *ns_str = mycss_values_create(entry, sizeof(mycore_string_t));
mycss_token_data_to_string(entry, token, ns_str, true, false);
image_image->str = ns_str;
@@ -134,11 +134,11 @@ bool mycss_property_parser_image_function_image_color(mycss_entry_t* entry, mycs
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
mycss_values_image_t *image = (mycss_values_image_t*)declr_entry->value;
- mycss_values_image_image_t *image_image = image->ii;
+ mycss_values_image_image_t *image_image = image->value.ii;
void *value = NULL;
unsigned int value_type = 0;
@@ -186,11 +186,11 @@ bool mycss_property_parser_image_function_image_set(mycss_entry_t* entry, mycss_
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
mycss_values_image_t *image = (mycss_values_image_t*)declr_entry->value;
- mycss_values_image_image_set_t *ii_set = image->ii_set;
+ mycss_values_image_image_set_t *ii_set = image->value.ii_set;
void *value = NULL;
unsigned int value_type = 0;
@@ -214,7 +214,7 @@ bool mycss_property_parser_image_function_image_set(mycss_entry_t* entry, mycss_
if(token->type == MyCSS_TOKEN_TYPE_STRING)
{
- myhtml_string_t *ns_str = mycss_values_create(entry, sizeof(myhtml_string_t));
+ mycore_string_t *ns_str = mycss_values_create(entry, sizeof(mycore_string_t));
mycss_token_data_to_string(entry, token, ns_str, true, false);
mycss_values_image_image_set_option_t *ii_entry = mycss_property_parser_image_function_get_next_option(entry, ii_set);
@@ -233,11 +233,11 @@ bool mycss_property_parser_image_function_image_set_resolution(mycss_entry_t* en
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
mycss_values_image_t *image = (mycss_values_image_t*)declr_entry->value;
- mycss_values_image_image_set_t *ii_set = image->ii_set;
+ mycss_values_image_image_set_t *ii_set = image->value.ii_set;
void *value = NULL;
unsigned int value_type = 0;
@@ -282,7 +282,7 @@ bool mycss_property_parser_image_function_string(mycss_entry_t* entry, mycss_tok
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
mycss_values_image_t *image = (mycss_values_image_t*)declr_entry->value;
- mycss_values_element_t *element = image->element;
+ mycss_values_element_t *element = image->value.element;
void *value = &element->custom_ident;
@@ -336,9 +336,9 @@ bool mycss_property_parser_image_function_string_wait_ident(mycss_entry_t* entry
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
mycss_values_image_t *image = (mycss_values_image_t*)declr_entry->value;
- mycss_values_element_t *element = image->element;
+ mycss_values_element_t *element = image->value.element;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_token_data_to_string(entry, token, &str, true, false);
element->type = mycss_property_value_type_by_name(str.data, str.length);
@@ -370,9 +370,9 @@ bool mycss_property_parser_image_function_cross_fade(mycss_entry_t* entry, mycss
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
mycss_values_image_t *image = (mycss_values_image_t*)declr_entry->value;
- mycss_values_cross_fade_t *cross_fade = image->cross_fade;
+ mycss_values_cross_fade_t *cross_fade = image->value.cross_fade;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
void *value = NULL;
unsigned int value_type = 0;
@@ -411,9 +411,9 @@ bool mycss_property_parser_image_function_cross_fade_mixing_after_percentage(myc
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
mycss_values_image_t *image = (mycss_values_image_t*)declr_entry->value;
- mycss_values_cross_fade_t *cross_fade = image->cross_fade;
+ mycss_values_cross_fade_t *cross_fade = image->value.cross_fade;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
void *value = NULL;
unsigned int value_type = 0;
@@ -465,9 +465,9 @@ bool mycss_property_parser_image_function_cross_fade_final(mycss_entry_t* entry,
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
mycss_values_image_t *image = (mycss_values_image_t*)declr_entry->value;
- mycss_values_cross_fade_t *cross_fade = image->cross_fade;
+ mycss_values_cross_fade_t *cross_fade = image->value.cross_fade;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
void *value = NULL;
unsigned int value_type = 0;
diff --git a/source/mycss/property/parser_text_decoration.c b/source/mycss/property/parser_text_decoration.c
index 3e021f7..824796b 100644
--- a/source/mycss/property/parser_text_decoration.c
+++ b/source/mycss/property/parser_text_decoration.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -54,7 +54,7 @@ bool mycss_property_parser_text_decoration(mycss_entry_t* entry, mycss_token_t*
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
mycss_values_text_decoration_t *text_decoration;
@@ -208,7 +208,7 @@ bool mycss_property_parser_text_decoration_color(mycss_entry_t* entry, mycss_tok
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
bool parser_changed = false;
@@ -247,7 +247,7 @@ bool mycss_property_parser_text_decoration_skip(mycss_entry_t* entry, mycss_toke
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return mycss_property_shared_switch_to_parse_error(entry);
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
unsigned int value = 0;
@@ -278,7 +278,7 @@ bool mycss_property_parser_text_decoration_skip_not_none(mycss_entry_t* entry, m
return false;
}
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_text_decoration_skip(entry, token, (unsigned int*)dec_entry->value, &dec_entry->value_type, &str, false))
@@ -309,7 +309,7 @@ bool mycss_property_parser_text_decoration_style(mycss_entry_t* entry, mycss_tok
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return mycss_property_shared_switch_to_parse_error(entry);
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_text_decoration_style(entry, token, &dec_entry->value_type, &str))
@@ -326,7 +326,7 @@ bool mycss_property_parser_text_decoration_line(mycss_entry_t* entry, mycss_toke
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return mycss_property_shared_switch_to_parse_error(entry);
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
unsigned int value = 0;
@@ -358,7 +358,7 @@ bool mycss_property_parser_text_decoration_line_not_none(mycss_entry_t* entry, m
return false;
}
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_declaration_entry_t* dec_entry = entry->declaration->entry_last;
if(mycss_property_shared_text_decoration_line(entry, token, (unsigned int*)dec_entry->value, &dec_entry->value_type, &str, false))
diff --git a/source/mycss/property/parser_url.c b/source/mycss/property/parser_url.c
index aebfa6f..3fe2c70 100644
--- a/source/mycss/property/parser_url.c
+++ b/source/mycss/property/parser_url.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -55,7 +55,7 @@ bool mycss_property_parser_url_string(mycss_entry_t* entry, mycss_token_t* token
return false;
}
- myhtml_string_t *str = mycss_values_create(entry, sizeof(myhtml_string_t));
+ mycore_string_t *str = mycss_values_create(entry, sizeof(mycore_string_t));
mycss_token_data_to_string(entry, token, str, true, false);
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;
diff --git a/source/mycss/property/resources.h b/source/mycss/property/resources.h
index dd9d86a..b42e068 100644
--- a/source/mycss/property/resources.h
+++ b/source/mycss/property/resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/property/resources_name.h b/source/mycss/property/resources_name.h
index ad25497..45a04de 100644
--- a/source/mycss/property/resources_name.h
+++ b/source/mycss/property/resources_name.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/property/serialization.c b/source/mycss/property/serialization.c
index 8e7f8de..a48c581 100644
--- a/source/mycss/property/serialization.c
+++ b/source/mycss/property/serialization.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -21,7 +21,7 @@
#include "mycss/property/serialization.h"
#include "mycss/property/resources_name.h"
-void mycss_property_serialization_type_name(mycss_property_type_t prop_type, mycss_callback_serialization_f callback, void* context)
+void mycss_property_serialization_type_name(mycss_property_type_t prop_type, mycore_callback_serialize_f callback, void* context)
{
if(prop_type >= MyCSS_PROPERTY_TYPE_LAST_ENTRY)
return;
@@ -30,7 +30,7 @@ void mycss_property_serialization_type_name(mycss_property_type_t prop_type, myc
callback(name, strlen(name), context);
}
-void mycss_property_serialization_value(unsigned int value_type, void* value, mycss_callback_serialization_f callback, void* context)
+void mycss_property_serialization_value(unsigned int value_type, void* value, mycore_callback_serialize_f callback, void* context)
{
if(value == NULL) {
if(value_type < MyCSS_PROPERTY_VALUE_LAST_ENTRY) {
diff --git a/source/mycss/property/serialization.h b/source/mycss/property/serialization.h
index 2f1abb7..26f79f4 100644
--- a/source/mycss/property/serialization.h
+++ b/source/mycss/property/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -30,8 +30,8 @@
extern "C" {
#endif
-void mycss_property_serialization_type_name(mycss_property_type_t prop_type, mycss_callback_serialization_f callback, void* context);
-void mycss_property_serialization_value(unsigned int value_type, void* value, mycss_callback_serialization_f callback, void* context);
+void mycss_property_serialization_type_name(mycss_property_type_t prop_type, mycore_callback_serialize_f callback, void* context);
+void mycss_property_serialization_value(unsigned int value_type, void* value, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/mycss/property/shared.c b/source/mycss/property/shared.c
index 25b77b4..a780368 100644
--- a/source/mycss/property/shared.c
+++ b/source/mycss/property/shared.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -52,7 +52,7 @@ bool mycss_property_shared_check_declaration_end(mycss_entry_t* entry, mycss_tok
return false;
}
-bool mycss_property_shared_number(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_number(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_NUMBER)
return false;
@@ -66,9 +66,9 @@ bool mycss_property_shared_number(mycss_entry_t* entry, mycss_token_t* token, vo
mycss_convert_data_to_double(str->data, str->length, &return_num, &length->is_float);
if(length->is_float)
- length->f = (float)return_num;
+ length->value.f = (float)return_num;
else
- length->i = (int)return_num;
+ length->value.i = (int)return_num;
*value = length;
*value_type = MyCSS_PROPERTY_VALUE__NUMBER;
@@ -76,7 +76,7 @@ bool mycss_property_shared_number(mycss_entry_t* entry, mycss_token_t* token, vo
return true;
}
-bool mycss_property_shared_length(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_length(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_DIMENSION && token->type != MyCSS_TOKEN_TYPE_NUMBER)
return false;
@@ -96,9 +96,9 @@ bool mycss_property_shared_length(mycss_entry_t* entry, mycss_token_t* token, vo
mycss_values_length_t *length = mycss_values_create(entry, sizeof(mycss_values_length_t));
if(is_float)
- length->f = (float)return_num;
+ length->value.f = (float)return_num;
else
- length->i = (int)return_num;
+ length->value.i = (int)return_num;
length->is_float = is_float;
length->type = type;
@@ -109,7 +109,7 @@ bool mycss_property_shared_length(mycss_entry_t* entry, mycss_token_t* token, vo
return true;
}
-bool mycss_property_shared_resolution(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_resolution(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_DIMENSION)
return false;
@@ -135,9 +135,9 @@ bool mycss_property_shared_resolution(mycss_entry_t* entry, mycss_token_t* token
mycss_values_resolution_t *resolution = mycss_values_create(entry, sizeof(mycss_values_resolution_t));
if(is_float)
- resolution->f = (float)return_num;
+ resolution->value.f = (float)return_num;
else
- resolution->i = (int)return_num;
+ resolution->value.i = (int)return_num;
resolution->is_float = is_float;
resolution->type = type;
@@ -173,7 +173,7 @@ bool mycss_property_shared_custom_ident(mycss_entry_t* entry, mycss_token_t* tok
return true;
}
-bool mycss_property_shared_percentage(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_percentage(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_PERCENTAGE)
return false;
@@ -187,9 +187,9 @@ bool mycss_property_shared_percentage(mycss_entry_t* entry, mycss_token_t* token
mycss_convert_data_to_double(str->data, str->length, &return_num, &length->is_float);
if(length->is_float)
- length->f = (float)return_num;
+ length->value.f = (float)return_num;
else
- length->i = (int)return_num;
+ length->value.i = (int)return_num;
*value = length;
*value_type = MyCSS_PROPERTY_VALUE__PERCENTAGE;
@@ -197,13 +197,13 @@ bool mycss_property_shared_percentage(mycss_entry_t* entry, mycss_token_t* token
return true;
}
-bool mycss_property_shared_length_percentage(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_length_percentage(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
return mycss_property_shared_length(entry, token, value, value_type, str) ||
mycss_property_shared_percentage(entry, token, value, value_type, str);
}
-bool mycss_property_shared_color(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str, bool* parser_changed)
+bool mycss_property_shared_color(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str, bool* parser_changed)
{
switch (token->type) {
case MyCSS_TOKEN_TYPE_FUNCTION:
@@ -238,8 +238,8 @@ bool mycss_property_shared_color(mycss_entry_t* entry, mycss_token_t* token, voi
if(color_entry) {
mycss_values_color_t *color = mycss_values_create(entry, sizeof(mycss_values_color_t));
- color->name_id = color_entry->type;
- color->type = MyCSS_VALUES_COLOR_TYPE_NAMED;
+ color->value.name_id = color_entry->type;
+ color->type = MyCSS_VALUES_COLOR_TYPE_NAMED;
*value = color;
*value_type = MyCSS_PROPERTY_VALUE__COLOR;
@@ -261,7 +261,7 @@ bool mycss_property_shared_color(mycss_entry_t* entry, mycss_token_t* token, voi
}
bool mycss_property_shared_text_decoration_skip(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value,
- unsigned int* value_type, myhtml_string_t* str, bool with_global)
+ unsigned int* value_type, mycore_string_t* str, bool with_global)
{
if(str->data == NULL)
mycss_token_data_to_string(entry, token, str, true, false);
@@ -334,7 +334,7 @@ bool mycss_property_shared_text_decoration_skip(mycss_entry_t* entry, mycss_toke
}
bool mycss_property_shared_text_decoration_line(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value,
- unsigned int* value_type, myhtml_string_t* str, bool with_global)
+ unsigned int* value_type, mycore_string_t* str, bool with_global)
{
if(str->data == NULL)
mycss_token_data_to_string(entry, token, str, true, false);
@@ -385,7 +385,7 @@ bool mycss_property_shared_text_decoration_line(mycss_entry_t* entry, mycss_toke
return false;
}
-bool mycss_property_shared_text_decoration_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_text_decoration_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str)
{
if(str->data == NULL)
mycss_token_data_to_string(entry, token, str, true, false);
@@ -413,7 +413,7 @@ bool mycss_property_shared_text_decoration_style(mycss_entry_t* entry, mycss_tok
return false;
}
-bool mycss_property_shared_default(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_default(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return false;
@@ -437,7 +437,7 @@ bool mycss_property_shared_default(mycss_entry_t* entry, mycss_token_t* token, u
return true;
}
-unsigned int mycss_property_shared_get_value_type(mycss_entry_t* entry, mycss_token_t* token, myhtml_string_t* str)
+unsigned int mycss_property_shared_get_value_type(mycss_entry_t* entry, mycss_token_t* token, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return MyCSS_PROPERTY_TYPE_UNDEF;
@@ -448,7 +448,7 @@ unsigned int mycss_property_shared_get_value_type(mycss_entry_t* entry, mycss_to
return mycss_property_value_type_by_name(str->data, str->length);
}
-bool mycss_property_shared_by_value_type(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, unsigned int check_type, myhtml_string_t* str)
+bool mycss_property_shared_by_value_type(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, unsigned int check_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return false;
@@ -464,7 +464,7 @@ bool mycss_property_shared_by_value_type(mycss_entry_t* entry, mycss_token_t* to
return false;
}
-bool mycss_property_shared_width(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_width(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(mycss_property_shared_length_percentage(entry, token, value, value_type, str))
return true;
@@ -493,7 +493,7 @@ bool mycss_property_shared_width(mycss_entry_t* entry, mycss_token_t* token, voi
return true;
}
-bool mycss_property_shared_height(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_height(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(mycss_property_shared_length_percentage(entry, token, value, value_type, str))
return true;
@@ -522,7 +522,7 @@ bool mycss_property_shared_height(mycss_entry_t* entry, mycss_token_t* token, vo
return true;
}
-bool mycss_property_shared_line_width(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_line_width(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(mycss_property_shared_length(entry, token, value, value_type, str))
return true;
@@ -553,7 +553,7 @@ bool mycss_property_shared_line_width(mycss_entry_t* entry, mycss_token_t* token
return true;
}
-bool mycss_property_shared_line_height(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_line_height(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(mycss_property_shared_length_percentage(entry, token, value, value_type, str) ||
mycss_property_shared_number(entry, token, value, value_type, str))
@@ -584,7 +584,7 @@ bool mycss_property_shared_line_height(mycss_entry_t* entry, mycss_token_t* toke
return false;
}
-bool mycss_property_shared_line_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_line_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return false;
@@ -619,12 +619,12 @@ bool mycss_property_shared_line_style(mycss_entry_t* entry, mycss_token_t* token
return true;
}
-void mycss_property_shared_destroy_string(myhtml_string_t* str)
+void mycss_property_shared_destroy_string(mycore_string_t* str)
{
- myhtml_string_destroy(str, false);
+ mycore_string_destroy(str, false);
}
-bool mycss_property_shared_font_ends(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_font_ends(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return false;
@@ -675,7 +675,7 @@ static mycss_values_font_family_entry_t * mycss_property_shared_font_family_chec
return ff_entry;
}
-bool mycss_property_shared_font_family(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, bool* dont_destroy_str, myhtml_string_t* str)
+bool mycss_property_shared_font_family(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, bool* dont_destroy_str, mycore_string_t* str)
{
*dont_destroy_str = false;
@@ -696,7 +696,7 @@ bool mycss_property_shared_font_family(mycss_entry_t* entry, mycss_token_t* toke
mycss_values_font_family_entry_t *ff_entry = mycss_property_shared_font_family_check(entry, value);
ff_entry->type = MyCSS_VALUES_FONT_FAMILY_TYPE_GENERIC;
- ff_entry->prop_type = family_type;
+ ff_entry->value.prop_type = family_type;
return true;
}
@@ -724,7 +724,7 @@ bool mycss_property_shared_font_family(mycss_entry_t* entry, mycss_token_t* toke
mycss_values_font_family_entry_t *ff_entry = mycss_property_shared_font_family_check(entry, value);
ff_entry->type = MyCSS_VALUES_FONT_FAMILY_TYPE_NAME;
- ff_entry->str = *str;
+ ff_entry->value.str = *str;
*dont_destroy_str = true;
return true;
@@ -732,7 +732,7 @@ bool mycss_property_shared_font_family(mycss_entry_t* entry, mycss_token_t* toke
}
}
-bool mycss_property_shared_font_weight(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_font_weight(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_IDENT && token->type != MyCSS_TOKEN_TYPE_NUMBER)
return false;
@@ -769,7 +769,7 @@ bool mycss_property_shared_font_weight(mycss_entry_t* entry, mycss_token_t* toke
return false;
}
-bool mycss_property_shared_font_size(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_font_size(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(mycss_property_shared_length_percentage(entry, token, value, value_type, str))
return true;
@@ -805,7 +805,7 @@ bool mycss_property_shared_font_size(mycss_entry_t* entry, mycss_token_t* token,
return false;
}
-bool mycss_property_shared_font_stretch(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_font_stretch(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return false;
@@ -838,7 +838,7 @@ bool mycss_property_shared_font_stretch(mycss_entry_t* entry, mycss_token_t* tok
return false;
}
-bool mycss_property_shared_font_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_font_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return false;
@@ -865,11 +865,11 @@ bool mycss_property_shared_font_style(mycss_entry_t* entry, mycss_token_t* token
return false;
}
-bool mycss_property_shared_url(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_url(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(token->type == MyCSS_TOKEN_TYPE_URL)
{
- myhtml_string_t *new_str = mycss_values_create(entry, sizeof(myhtml_string_t));
+ mycore_string_t *new_str = mycss_values_create(entry, sizeof(mycore_string_t));
mycss_token_data_to_string(entry, token, new_str, true, false);
*value = new_str;
@@ -887,7 +887,7 @@ bool mycss_property_shared_url(mycss_entry_t* entry, mycss_token_t* token, void*
if(str->data == NULL)
mycss_token_data_to_string(entry, token, str, true, false);
- if(myhtml_strcasecmp(str->data, "url"))
+ if(mycore_strcasecmp(str->data, "url"))
return false;
entry->parser = mycss_property_parser_url_string;
@@ -896,7 +896,7 @@ bool mycss_property_shared_url(mycss_entry_t* entry, mycss_token_t* token, void*
return true;
}
-bool mycss_property_shared_image(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str, bool* parser_changed)
+bool mycss_property_shared_image(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str, bool* parser_changed)
{
if(token->type == MyCSS_TOKEN_TYPE_URL)
{
@@ -945,7 +945,7 @@ bool mycss_property_shared_image(mycss_entry_t* entry, mycss_token_t* token, voi
return true;
}
-bool mycss_property_shared_background_repeat_one(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_background_repeat_one(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return false;
@@ -968,7 +968,7 @@ bool mycss_property_shared_background_repeat_one(mycss_entry_t* entry, mycss_tok
return false;
}
-bool mycss_property_shared_background_repeat_two(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_background_repeat_two(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return false;
@@ -993,7 +993,7 @@ bool mycss_property_shared_background_repeat_two(mycss_entry_t* entry, mycss_tok
return false;
}
-bool mycss_property_shared_background_attachment(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_background_attachment(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return false;
@@ -1017,7 +1017,7 @@ bool mycss_property_shared_background_attachment(mycss_entry_t* entry, mycss_tok
return false;
}
-bool mycss_property_shared_background_position(mycss_entry_t* entry, mycss_token_t* token, void* value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_background_position(mycss_entry_t* entry, mycss_token_t* token, void* value, unsigned int* value_type, mycore_string_t* str)
{
if(mycss_property_shared_length_percentage(entry, token, value, value_type, str))
return true;
@@ -1046,7 +1046,7 @@ bool mycss_property_shared_background_position(mycss_entry_t* entry, mycss_token
return false;
}
-bool mycss_property_shared_background_clip(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_background_clip(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_IDENT)
return false;
@@ -1070,7 +1070,7 @@ bool mycss_property_shared_background_clip(mycss_entry_t* entry, mycss_token_t*
return false;
}
-bool mycss_property_shared_background_size(mycss_entry_t* entry, mycss_token_t* token, void* value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_background_size(mycss_entry_t* entry, mycss_token_t* token, void* value, unsigned int* value_type, mycore_string_t* str)
{
if(mycss_property_shared_length_percentage(entry, token, value, value_type, str))
return true;
@@ -1104,7 +1104,7 @@ bool mycss_property_shared_background_size(mycss_entry_t* entry, mycss_token_t*
-bool mycss_property_shared_function_image(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_function_image(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_FUNCTION)
return false;
@@ -1115,7 +1115,7 @@ bool mycss_property_shared_function_image(mycss_entry_t* entry, mycss_token_t* t
if(str->data == NULL)
mycss_token_data_to_string(entry, token, str, true, false);
- if(myhtml_strcasecmp(str->data, "image"))
+ if(mycore_strcasecmp(str->data, "image"))
return false;
entry->parser = NULL;
@@ -1124,7 +1124,7 @@ bool mycss_property_shared_function_image(mycss_entry_t* entry, mycss_token_t* t
return true;
}
-bool mycss_property_shared_function_image_set(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_function_image_set(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_FUNCTION)
return false;
@@ -1135,7 +1135,7 @@ bool mycss_property_shared_function_image_set(mycss_entry_t* entry, mycss_token_
if(str->data == NULL)
mycss_token_data_to_string(entry, token, str, true, false);
- if(myhtml_strcasecmp(str->data, "image-set"))
+ if(mycore_strcasecmp(str->data, "image-set"))
return false;
entry->parser = NULL;
@@ -1144,7 +1144,7 @@ bool mycss_property_shared_function_image_set(mycss_entry_t* entry, mycss_token_
return true;
}
-bool mycss_property_shared_element(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_property_shared_element(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_FUNCTION)
return false;
@@ -1155,7 +1155,7 @@ bool mycss_property_shared_element(mycss_entry_t* entry, mycss_token_t* token, v
if(str->data == NULL)
mycss_token_data_to_string(entry, token, str, true, false);
- if(myhtml_strcasecmp(str->data, "cross-fade"))
+ if(mycore_strcasecmp(str->data, "cross-fade"))
return false;
entry->parser = NULL;
diff --git a/source/mycss/property/shared.h b/source/mycss/property/shared.h
index f36def3..3f04201 100644
--- a/source/mycss/property/shared.h
+++ b/source/mycss/property/shared.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -27,7 +27,7 @@
#include "mycss/values/values.h"
#include "mycss/values/color.h"
#include "mycss/values/image.h"
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
#ifdef __cplusplus
extern "C" {
@@ -37,42 +37,42 @@ bool mycss_property_shared_switch_to_find_important(mycss_entry_t* entry);
bool mycss_property_shared_switch_to_parse_error(mycss_entry_t* entry);
bool mycss_property_shared_check_declaration_end(mycss_entry_t* entry, mycss_token_t* token);
-bool mycss_property_shared_number(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_length(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_percentage(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_length_percentage(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_resolution(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
+bool mycss_property_shared_number(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_length(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_percentage(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_length_percentage(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_resolution(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
bool mycss_property_shared_custom_ident(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type);
-bool mycss_property_shared_color(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str, bool* parser_changed);
-bool mycss_property_shared_default(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-unsigned int mycss_property_shared_get_value_type(mycss_entry_t* entry, mycss_token_t* token, myhtml_string_t* str);
-bool mycss_property_shared_by_value_type(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, unsigned int check_type, myhtml_string_t* str);
-bool mycss_property_shared_width(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_height(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_line_width(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_line_height(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_line_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_text_decoration_skip(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value, unsigned int* value_type, myhtml_string_t* str, bool with_global);
-bool mycss_property_shared_text_decoration_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_text_decoration_line(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value, unsigned int* value_type, myhtml_string_t* str, bool with_global);
+bool mycss_property_shared_color(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str, bool* parser_changed);
+bool mycss_property_shared_default(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+unsigned int mycss_property_shared_get_value_type(mycss_entry_t* entry, mycss_token_t* token, mycore_string_t* str);
+bool mycss_property_shared_by_value_type(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, unsigned int check_type, mycore_string_t* str);
+bool mycss_property_shared_width(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_height(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_line_width(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_line_height(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_line_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_text_decoration_skip(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value, unsigned int* value_type, mycore_string_t* str, bool with_global);
+bool mycss_property_shared_text_decoration_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_text_decoration_line(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value, unsigned int* value_type, mycore_string_t* str, bool with_global);
-bool mycss_property_shared_font_ends(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_font_weight(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_font_size(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_font_stretch(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_font_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_font_family(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, bool *dont_destroy_str, myhtml_string_t* str);
+bool mycss_property_shared_font_ends(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_font_weight(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_font_size(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_font_stretch(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_font_style(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_font_family(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, bool *dont_destroy_str, mycore_string_t* str);
-bool mycss_property_shared_image(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str, bool* parser_changed);
+bool mycss_property_shared_image(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str, bool* parser_changed);
-bool mycss_property_shared_background_repeat_one(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_background_repeat_two(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_background_attachment(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_background_position(mycss_entry_t* entry, mycss_token_t* token, void* value, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_background_clip(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, myhtml_string_t* str);
-bool mycss_property_shared_background_size(mycss_entry_t* entry, mycss_token_t* token, void* value, unsigned int* value_type, myhtml_string_t* str);
+bool mycss_property_shared_background_repeat_one(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_background_repeat_two(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_background_attachment(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_background_position(mycss_entry_t* entry, mycss_token_t* token, void* value, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_background_clip(mycss_entry_t* entry, mycss_token_t* token, unsigned int* value_type, mycore_string_t* str);
+bool mycss_property_shared_background_size(mycss_entry_t* entry, mycss_token_t* token, void* value, unsigned int* value_type, mycore_string_t* str);
-void mycss_property_shared_destroy_string(myhtml_string_t* str);
+void mycss_property_shared_destroy_string(mycore_string_t* str);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/mycss/selectors/function.c b/source/mycss/selectors/function.c
index 19187d9..d291f9d 100644
--- a/source/mycss/selectors/function.c
+++ b/source/mycss/selectors/function.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "mycss/selectors/function.h"
#include "mycss/selectors/function_resource.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
/////////////////////////////////////////////////////////
//// Functions for a find Begin Function
@@ -28,15 +28,15 @@
/////////////////////////////////////////////////////////
const mycss_selectots_function_begin_entry_t * mycss_function_begin_entry_by_name(const char* name, size_t length)
{
- size_t idx = ((myhtml_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
- myhtml_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
+ size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
+ mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
length)
% MyCSS_SELECTORS_FUNCTION_NAME_STATIC_SIZE) + 1;
while (mycss_selectors_function_begin_map_index[idx].name)
{
if(mycss_selectors_function_begin_map_index[idx].length == length) {
- if(myhtml_strncasecmp(mycss_selectors_function_begin_map_index[idx].name, name, length) == 0)
+ if(mycore_strncasecmp(mycss_selectors_function_begin_map_index[idx].name, name, length) == 0)
return &mycss_selectors_function_begin_map_index[idx];
if(mycss_selectors_function_begin_map_index[idx].next)
diff --git a/source/mycss/selectors/function.h b/source/mycss/selectors/function.h
index beea322..7bf4f09 100644
--- a/source/mycss/selectors/function.h
+++ b/source/mycss/selectors/function.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/selectors/function_parser.c b/source/mycss/selectors/function_parser.c
index 3850954..7aa9e34 100644
--- a/source/mycss/selectors/function_parser.c
+++ b/source/mycss/selectors/function_parser.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -257,24 +257,24 @@ bool mycss_selectors_function_parser_nth_with_selectors_need_of(mycss_entry_t* e
mycss_selectors_t *selectors = entry->selectors;
mycss_selectors_entry_t *selector = selectors->entry_last;
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, false);
mycss_an_plus_b_entry_t *anb = mycss_selector_value_an_plus_b(selector->value);
- if(myhtml_strcasecmp(str.data, "of") != 0) {
+ if(mycore_strcasecmp(str.data, "of") != 0) {
if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0)
selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
anb->of = NULL;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
entry->parser = mycss_selectors_function_parser_state_drop_component_value;
return true;
}
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
/* create and switch entry, and create selector */
mycss_selectors_list_t *current_list = selectors->list_last;
@@ -407,16 +407,16 @@ bool mycss_selectors_function_parser_drop(mycss_entry_t* entry, mycss_token_t* t
mycss_selectors_function_drop_type_t drop_val = mycss_selector_value_drop(selector->value);
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, false);
- if(myhtml_strcasecmp(str.data ,"active") == 0) {
+ if(mycore_strcasecmp(str.data ,"active") == 0) {
drop_val |= MyCSS_SELECTORS_FUNCTION_DROP_TYPE_ACTIVE;
}
- else if(myhtml_strcasecmp(str.data ,"valid") == 0) {
+ else if(mycore_strcasecmp(str.data ,"valid") == 0) {
drop_val |= MyCSS_SELECTORS_FUNCTION_DROP_TYPE_VALID;
}
- else if(myhtml_strcasecmp(str.data ,"invalid") == 0) {
+ else if(mycore_strcasecmp(str.data ,"invalid") == 0) {
drop_val |= MyCSS_SELECTORS_FUNCTION_DROP_TYPE_INVALID;
}
else {
@@ -426,7 +426,7 @@ bool mycss_selectors_function_parser_drop(mycss_entry_t* entry, mycss_token_t* t
selector->value = (void*)drop_val;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
entry->parser = mycss_selectors_function_parser_drop_after;
}
diff --git a/source/mycss/selectors/function_parser.h b/source/mycss/selectors/function_parser.h
index a0e67c2..8005872 100644
--- a/source/mycss/selectors/function_parser.h
+++ b/source/mycss/selectors/function_parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/selectors/function_resource.h b/source/mycss/selectors/function_resource.h
index a3a369e..67c48ac 100644
--- a/source/mycss/selectors/function_resource.h
+++ b/source/mycss/selectors/function_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/selectors/init.c b/source/mycss/selectors/init.c
index 8abffc3..4cec9cd 100644
--- a/source/mycss/selectors/init.c
+++ b/source/mycss/selectors/init.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -23,10 +23,10 @@
mycss_selectors_t * mycss_selectors_create(void)
{
- return (mycss_selectors_t*)myhtml_calloc(1, sizeof(mycss_selectors_t));
+ return (mycss_selectors_t*)mycore_calloc(1, sizeof(mycss_selectors_t));
}
-mycss_status_t mycss_selectors_init(mycss_entry_t* entry, mycss_selectors_t* selectors)
+mystatus_t mycss_selectors_init(mycss_entry_t* entry, mycss_selectors_t* selectors)
{
selectors->ref_entry = entry;
selectors->entry = NULL;
@@ -40,7 +40,7 @@ mycss_status_t mycss_selectors_init(mycss_entry_t* entry, mycss_selectors_t* sel
if(selectors->mcobject_entries == NULL)
return MyCSS_STATUS_ERROR_SELECTORS_ENTRIES_CREATE;
- myhtml_status_t myhtml_status = mcobject_init(selectors->mcobject_entries, 256, sizeof(mycss_selectors_entry_t));
+ mystatus_t myhtml_status = mcobject_init(selectors->mcobject_entries, 256, sizeof(mycss_selectors_entry_t));
if(myhtml_status)
return MyCSS_STATUS_ERROR_SELECTORS_ENTRIES_INIT;
@@ -65,7 +65,7 @@ void mycss_selectors_clean(mycss_selectors_t* selectors)
selectors->combinator = NULL;
}
-mycss_status_t mycss_selectors_clean_all(mycss_selectors_t* selectors)
+mystatus_t mycss_selectors_clean_all(mycss_selectors_t* selectors)
{
selectors->entry = NULL;
selectors->entry_last = NULL;
@@ -88,7 +88,7 @@ mycss_selectors_t * mycss_selectors_destroy(mycss_selectors_t* selectors, bool s
selectors->mcobject_list_entries = mcobject_destroy(selectors->mcobject_list_entries, true);
if(self_destroy) {
- myhtml_free(selectors);
+ mycore_free(selectors);
return NULL;
}
@@ -111,7 +111,7 @@ mycss_token_t * mycss_selectors_parse_token_callback(mycss_entry_t* entry, mycss
return entry->token;
}
-mycss_selectors_list_t * mycss_selectors_parse_by_function(mycss_selectors_t* selectors, mycss_parser_token_f func, myhtml_encoding_t encoding, const char* data, size_t data_size, mycss_status_t* out_status)
+mycss_selectors_list_t * mycss_selectors_parse_by_function(mycss_selectors_t* selectors, mycss_parser_token_f func, myencoding_t encoding, const char* data, size_t data_size, mystatus_t* out_status)
{
mycss_entry_t *entry = selectors->ref_entry;
@@ -131,7 +131,7 @@ mycss_selectors_list_t * mycss_selectors_parse_by_function(mycss_selectors_t* se
/* parsing */
mycss_encoding_set(entry, encoding);
- mycss_status_t status = mycss_tokenizer_chunk(entry, data, data_size);
+ mystatus_t status = mycss_tokenizer_chunk(entry, data, data_size);
if(status != MyCSS_STATUS_OK) {
if(out_status)
*out_status = status;
@@ -150,7 +150,7 @@ mycss_selectors_list_t * mycss_selectors_parse_by_function(mycss_selectors_t* se
return NULL;
}
-mycss_selectors_list_t * mycss_selectors_parse(mycss_selectors_t* selectors, myhtml_encoding_t encoding, const char* data, size_t data_size, mycss_status_t* out_status)
+mycss_selectors_list_t * mycss_selectors_parse(mycss_selectors_t* selectors, myencoding_t encoding, const char* data, size_t data_size, mystatus_t* out_status)
{
return mycss_selectors_parse_by_function(selectors, mycss_selectors_state_complex_selector_list, encoding, data, data_size, out_status);
}
@@ -177,7 +177,7 @@ mycss_selectors_entry_t * mycss_selectors_entry_destroy(mycss_selectors_t* selec
return NULL;
if(selector->key) {
- myhtml_string_destroy(selector->key, false);
+ mycore_string_destroy(selector->key, false);
mcobject_free(selectors->ref_entry->mcobject_string_entries, selector->key);
}
diff --git a/source/mycss/selectors/init.h b/source/mycss/selectors/init.h
index 6fb47d9..629bafa 100644
--- a/source/mycss/selectors/init.h
+++ b/source/mycss/selectors/init.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -31,9 +31,9 @@ extern "C" {
#include "mycss/selectors/list.h"
mycss_selectors_t * mycss_selectors_create(void);
-mycss_status_t mycss_selectors_init(mycss_entry_t* entry, mycss_selectors_t* selectors);
+mystatus_t mycss_selectors_init(mycss_entry_t* entry, mycss_selectors_t* selectors);
void mycss_selectors_clean(mycss_selectors_t* selectors);
-mycss_status_t mycss_selectors_clean_all(mycss_selectors_t* selectors);
+mystatus_t mycss_selectors_clean_all(mycss_selectors_t* selectors);
mycss_selectors_t * mycss_selectors_destroy(mycss_selectors_t* selectors, bool self_destroy);
void mycss_selectors_entry_clean(mycss_selectors_entry_t* sel_entry);
@@ -41,8 +41,8 @@ mycss_selectors_entry_t * mycss_selectors_entry_destroy(mycss_selectors_t* selec
void * mycss_selectors_entry_value_destroy(mycss_entry_t* entry, mycss_selectors_entry_t* selector_entry, bool destroy_self);
-mycss_selectors_list_t * mycss_selectors_parse(mycss_selectors_t* selectors, myhtml_encoding_t encoding, const char* data, size_t data_size, mycss_status_t* out_status);
-mycss_selectors_list_t * mycss_selectors_parse_by_function(mycss_selectors_t* selectors, mycss_parser_token_f func, myhtml_encoding_t encoding, const char* data, size_t data_size, mycss_status_t* out_status);
+mycss_selectors_list_t * mycss_selectors_parse(mycss_selectors_t* selectors, myencoding_t encoding, const char* data, size_t data_size, mystatus_t* out_status);
+mycss_selectors_list_t * mycss_selectors_parse_by_function(mycss_selectors_t* selectors, mycss_parser_token_f func, myencoding_t encoding, const char* data, size_t data_size, mystatus_t* out_status);
mycss_selectors_entry_t * mycss_selectors_entry_find_first(mycss_selectors_entry_t* selector);
diff --git a/source/mycss/selectors/list.c b/source/mycss/selectors/list.c
index 4676dfe..454c7d3 100644
--- a/source/mycss/selectors/list.c
+++ b/source/mycss/selectors/list.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/selectors/list.h b/source/mycss/selectors/list.h
index 73bcc2c..e19fb33 100644
--- a/source/mycss/selectors/list.h
+++ b/source/mycss/selectors/list.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/selectors/myosi.h b/source/mycss/selectors/myosi.h
index e3d7e36..3df9c38 100644
--- a/source/mycss/selectors/myosi.h
+++ b/source/mycss/selectors/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -36,7 +36,7 @@ typedef struct mycss_selectors_specificity mycss_selectors_specificity_t;
#include "mycss/mystring.h"
#include "mycss/namespace/myosi.h"
#include "mycss/declaration/myosi.h"
-#include "myhtml/utils/mcobject.h"
+#include "mycore/utils/mcobject.h"
typedef bool (*mycss_selectors_state_f)(mycss_entry_t* entry, mycss_selectors_t* selectors, mycss_selectors_entry_t* selector, mycss_token_t* token);
typedef void (*mycss_callback_selector_done_f)(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector);
@@ -218,7 +218,7 @@ struct mycss_selectors_entry {
mycss_namespace_entry_t* ns_entry;
- myhtml_string_t* key;
+ mycore_string_t* key;
void* value;
mycss_selectors_combinator_t combinator;
diff --git a/source/mycss/selectors/myosi_resource.h b/source/mycss/selectors/myosi_resource.h
index 70a0b6a..21baa67 100644
--- a/source/mycss/selectors/myosi_resource.h
+++ b/source/mycss/selectors/myosi_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/selectors/parser.c b/source/mycss/selectors/parser.c
index 316b667..688f458 100644
--- a/source/mycss/selectors/parser.c
+++ b/source/mycss/selectors/parser.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -39,7 +39,7 @@ void mycss_selectors_parser_selector_ident_type(mycss_entry_t* entry, mycss_toke
{
mycss_selectors_entry_t *selector = entry->selectors->entry_last;
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
mycss_token_data_to_string(entry, token, str, true, false);
/* set default namespace */
@@ -58,7 +58,7 @@ void mycss_selectors_parser_selector_ident_attr(mycss_entry_t* entry, mycss_toke
{
mycss_selectors_entry_t *selector = entry->selectors->entry_last;
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
mycss_token_data_to_string(entry, token, str, true, false);
/* set default namespace */
@@ -77,7 +77,7 @@ void mycss_selectors_parser_selector_id(mycss_entry_t* entry, mycss_token_t* tok
{
mycss_selectors_entry_t *selector = entry->selectors->entry_last;
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
mycss_token_data_to_string(entry, token, str, true, false);
/* set default namespace */
@@ -97,7 +97,7 @@ void mycss_selectors_parser_selector_class(mycss_entry_t* entry, mycss_token_t*
{
mycss_selectors_entry_t *selector = entry->selectors->entry_last;
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
mycss_token_data_to_string(entry, token, str, true, false);
/* set default namespace */
@@ -120,10 +120,10 @@ void mycss_selectors_parser_selector_class(mycss_entry_t* entry, mycss_token_t*
void mycss_selectors_parser_selector_namespace(mycss_entry_t* entry, mycss_token_t* token)
{
mycss_selectors_entry_t *selector = entry->selectors->entry_last;
- myhtml_string_t *str = selector->key;
+ mycore_string_t *str = selector->key;
if(str == NULL || str->length == 0) {
- myhtml_string_destroy(str, 0);
+ mycore_string_destroy(str, 0);
selector->key = NULL;
@@ -134,7 +134,7 @@ void mycss_selectors_parser_selector_namespace(mycss_entry_t* entry, mycss_token
}
if(str->length == 1 && *str->data == '*') {
- myhtml_string_destroy(str, 0);
+ mycore_string_destroy(str, 0);
selector->key = NULL;
@@ -150,7 +150,7 @@ void mycss_selectors_parser_selector_namespace(mycss_entry_t* entry, mycss_token
if(selector->ns_entry == NULL)
mycss_selectors_parser_expectations_error(entry, token);
- myhtml_string_destroy(str, 0);
+ mycore_string_destroy(str, 0);
selector->key = NULL;
}
@@ -178,7 +178,7 @@ void mycss_selectors_parser_selector_after_namespace(mycss_entry_t* entry, mycss
{
mycss_selectors_entry_t *selector = entry->selectors->entry_last;
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
mycss_token_data_to_string(entry, token, str, true, true);
selector->key = str;
@@ -209,7 +209,7 @@ void mycss_selectors_parser_selector_value(mycss_entry_t* entry, mycss_token_t*
mycss_selectors_entry_t *selector = entry->selectors->entry_last;
mycss_selectors_object_attribute_t *attr = selector->value;
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
mycss_token_data_to_string(entry, token, str, true, false);
attr->value = str;
@@ -229,7 +229,7 @@ void mycss_selectors_parser_selector_pseudo_class(mycss_entry_t* entry, mycss_to
{
mycss_selectors_entry_t *selector = entry->selectors->entry_last;
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
mycss_token_data_to_string(entry, token, str, true, true);
selector->sub_type = mycss_pseudo_class_by_name(str->data, str->length);
@@ -259,7 +259,7 @@ void mycss_selectors_parser_selector_pseudo_class_function(mycss_entry_t* entry,
{
mycss_selectors_entry_t *selector = entry->selectors->entry_last;
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
mycss_token_data_to_string(entry, token, str, true, true);
selector->key = str;
@@ -303,7 +303,7 @@ void mycss_selectors_parser_selector_pseudo_element(mycss_entry_t* entry, mycss_
{
mycss_selectors_entry_t *selector = entry->selectors->entry_last;
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
mycss_token_data_to_string(entry, token, str, true, true);
selector->key = str;
@@ -325,7 +325,7 @@ void mycss_selectors_parser_selector_pseudo_element_function(mycss_entry_t* entr
{
mycss_selectors_entry_t *selector = entry->selectors->entry_last;
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
mycss_token_data_to_string(entry, token, str, true, true);
selector->key = str;
@@ -373,7 +373,7 @@ void mycss_selectors_parser_bad_token(mycss_entry_t* entry, mycss_token_t* token
if((selector->flags & MyCSS_SELECTORS_FLAGS_SELECTOR_BAD) == 0) {
selector->flags |= MyCSS_SELECTORS_FLAGS_SELECTOR_BAD;
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
selector->key = str;
mycss_token_data_to_string(entry, token, selector->key, true, false);
diff --git a/source/mycss/selectors/parser.h b/source/mycss/selectors/parser.h
index 78b7898..afe734a 100644
--- a/source/mycss/selectors/parser.h
+++ b/source/mycss/selectors/parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/selectors/pseudo.c b/source/mycss/selectors/pseudo.c
index 4488a4d..39b2790 100644
--- a/source/mycss/selectors/pseudo.c
+++ b/source/mycss/selectors/pseudo.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "mycss/selectors/pseudo.h"
#include "mycss/selectors/pseudo_resource.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
/////////////////////////////////////////////////////////
//// Functions for a find Begin Function
@@ -28,15 +28,15 @@
/////////////////////////////////////////////////////////
const mycss_selectots_pseudo_begin_entry_t * mycss_pseudo_begin_entry_by_name(const char* name, size_t length, size_t static_size, const mycss_selectots_pseudo_begin_entry_t* pseudo)
{
- size_t idx = ((myhtml_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
- myhtml_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
+ size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
+ mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
length)
% static_size) + 1;
while (pseudo[idx].name)
{
if(pseudo[idx].length == length) {
- if(myhtml_strncasecmp(pseudo[idx].name, name, length) == 0)
+ if(mycore_strncasecmp(pseudo[idx].name, name, length) == 0)
return &pseudo[idx];
if(pseudo[idx].next)
diff --git a/source/mycss/selectors/pseudo.h b/source/mycss/selectors/pseudo.h
index 84f3e83..8c53ab1 100644
--- a/source/mycss/selectors/pseudo.h
+++ b/source/mycss/selectors/pseudo.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/selectors/pseudo_resource.h b/source/mycss/selectors/pseudo_resource.h
index 4bb9994..9a8ce37 100644
--- a/source/mycss/selectors/pseudo_resource.h
+++ b/source/mycss/selectors/pseudo_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/selectors/serialization.c b/source/mycss/selectors/serialization.c
index 00933ad..f451dcd 100644
--- a/source/mycss/selectors/serialization.c
+++ b/source/mycss/selectors/serialization.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -22,13 +22,13 @@
#include "mycss/selectors/myosi_resource.h"
void mycss_selectors_serialization_chain(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
while(selector) {
if(selector->combinator == MyCSS_SELECTORS_COMBINATOR_DESCENDANT)
callback(" ", 1, context);
else if(selector->combinator == MyCSS_SELECTORS_COMBINATOR_UNDEF) {
- /* fprintf(fh, "") */
+ /* "" */
}
else {
callback(" ", 1, context);
@@ -46,7 +46,7 @@ void mycss_selectors_serialization_chain(mycss_selectors_t* selectors, mycss_sel
}
bool mycss_selectors_serialization_list(mycss_selectors_t* selectors, mycss_selectors_list_t* selectors_list,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
while(selectors_list) {
for(size_t i = 0; i < selectors_list->entries_list_length; i++)
@@ -78,7 +78,7 @@ bool mycss_selectors_serialization_list(mycss_selectors_t* selectors, mycss_sele
}
bool mycss_selectors_serialization_selector(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector,
- mycss_callback_serialization_f callback, void* context)
+ mycore_callback_serialize_f callback, void* context)
{
switch(selector->type) {
case MyCSS_SELECTORS_TYPE_ELEMENT: {
@@ -114,7 +114,7 @@ bool mycss_selectors_serialization_selector(mycss_selectors_t* selectors, mycss_
/* value */
if(mycss_selector_value_attribute(selector->value)->value) {
- myhtml_string_t *str_value = mycss_selector_value_attribute(selector->value)->value;
+ mycore_string_t *str_value = mycss_selector_value_attribute(selector->value)->value;
callback(str_value->data, str_value->length, context);
}
@@ -203,7 +203,7 @@ bool mycss_selectors_serialization_selector(mycss_selectors_t* selectors, mycss_
case MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_DIR:
{
if(selector->value) {
- myhtml_string_t *str_fname = mycss_selector_value_string(selector->value);
+ mycore_string_t *str_fname = mycss_selector_value_string(selector->value);
callback(str_fname->data, str_fname->length, context);
}
diff --git a/source/mycss/selectors/serialization.h b/source/mycss/selectors/serialization.h
index 7d9d0cc..338278e 100644
--- a/source/mycss/selectors/serialization.h
+++ b/source/mycss/selectors/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -30,9 +30,9 @@ extern "C" {
#include "mycss/namespace/serialization.h"
#include "mycss/declaration/serialization.h"
-void mycss_selectors_serialization_chain(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector, mycss_callback_serialization_f callback, void* context);
-bool mycss_selectors_serialization_list(mycss_selectors_t* selectors, mycss_selectors_list_t* selectors_list, mycss_callback_serialization_f callback, void* context);
-bool mycss_selectors_serialization_selector(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector, mycss_callback_serialization_f callback, void* context);
+void mycss_selectors_serialization_chain(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector, mycore_callback_serialize_f callback, void* context);
+bool mycss_selectors_serialization_list(mycss_selectors_t* selectors, mycss_selectors_list_t* selectors_list, mycore_callback_serialize_f callback, void* context);
+bool mycss_selectors_serialization_selector(mycss_selectors_t* selectors, mycss_selectors_entry_t* selector, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/mycss/selectors/state.c b/source/mycss/selectors/state.c
index fe91022..191ee75 100644
--- a/source/mycss/selectors/state.c
+++ b/source/mycss/selectors/state.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -132,24 +132,24 @@ bool mycss_selectors_state_combinator(mycss_entry_t* entry, mycss_token_t* token
switch (token->type) {
case MyCSS_TOKEN_TYPE_COLUMN: {
*entry->selectors->combinator = MyCSS_SELECTORS_COMBINATOR_COLUMN;
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_combinator_column")
+ MyCORE_DEBUG("mycss_selectors_state_combinator_column");
entry->parser = entry->parser_switch;
break;
}
case MyCSS_TOKEN_TYPE_DELIM: {
if(*token->data == '+') {
*entry->selectors->combinator = MyCSS_SELECTORS_COMBINATOR_NEXT_SIBLING;
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_combinator_plus")
+ MyCORE_DEBUG("mycss_selectors_state_combinator_plus");
entry->parser = entry->parser_switch;
}
else if(*token->data == '>') {
*entry->selectors->combinator = MyCSS_SELECTORS_COMBINATOR_CHILD;
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_combinator_greater_than")
+ MyCORE_DEBUG("mycss_selectors_state_combinator_greater_than");
entry->parser = mycss_selectors_state_combinator_greater_than;
}
else if(*token->data == '~') {
*entry->selectors->combinator = MyCSS_SELECTORS_COMBINATOR_FOLLOWING_SIBLING;
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_combinator_tilde")
+ MyCORE_DEBUG("mycss_selectors_state_combinator_tilde");
entry->parser = entry->parser_switch;
}
else {
@@ -175,7 +175,7 @@ bool mycss_selectors_state_combinator_greater_than(mycss_entry_t* entry, mycss_t
if(token->type == MyCSS_TOKEN_TYPE_DELIM) {
if(*token->data == '>') {
*entry->selectors->combinator = MyCSS_SELECTORS_COMBINATOR_DESCENDANT;
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_combinator_greater_than_greater_than")
+ MyCORE_DEBUG("mycss_selectors_state_combinator_greater_than_greater_than");
entry->parser = entry->parser_switch;
}
else {
@@ -573,7 +573,7 @@ bool mycss_selectors_state_simple_selector(mycss_entry_t* entry, mycss_token_t*
switch (token->type) {
case MyCSS_TOKEN_TYPE_IDENT: {
mycss_selectors_parser_selector_ident_type(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_ident")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_ident");
entry->parser = mycss_selectors_state_simple_selector_ident;
break;
@@ -582,7 +582,7 @@ bool mycss_selectors_state_simple_selector(mycss_entry_t* entry, mycss_token_t*
// HAND_EDIT_BEGIN
if(*token->data == '*') {
mycss_selectors_parser_selector_ident_type(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_asterisk")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_asterisk");
entry->parser = mycss_selectors_state_simple_selector_ident;
}
@@ -613,7 +613,7 @@ bool mycss_selectors_state_simple_selector(mycss_entry_t* entry, mycss_token_t*
}
case MyCSS_TOKEN_TYPE_HASH: {
mycss_selectors_parser_selector_id(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_hash")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_hash");
entry->parser = entry->parser_switch;
break;
}
@@ -772,7 +772,7 @@ bool mycss_selectors_state_simple_selector_left_bracket_ident(mycss_entry_t* ent
}
case MyCSS_TOKEN_TYPE_RIGHT_SQUARE_BRACKET: {
mycss_selectors_parser_selector_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_left_bracket_ident_right_bracket")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_left_bracket_ident_right_bracket");
entry->parser = entry->parser_switch;
break;
}
@@ -815,7 +815,7 @@ bool mycss_selectors_state_simple_selector_colon(mycss_entry_t* entry, mycss_tok
switch (token->type) {
case MyCSS_TOKEN_TYPE_IDENT: {
mycss_selectors_parser_selector_pseudo_class(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_colon_ident")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_colon_ident");
entry->parser = entry->parser_switch;
break;
}
@@ -841,7 +841,7 @@ bool mycss_selectors_state_simple_selector_colon_colon(mycss_entry_t* entry, myc
{
if(token->type == MyCSS_TOKEN_TYPE_IDENT) {
mycss_selectors_parser_selector_pseudo_element(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_colon_colon_ident")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_colon_colon_ident");
entry->parser = entry->parser_switch;
}
else if(token->type == MyCSS_TOKEN_TYPE_FUNCTION) {
@@ -860,7 +860,7 @@ bool mycss_selectors_state_simple_selector_colon_colon_function(mycss_entry_t* e
{
if(token->type == MyCSS_TOKEN_TYPE_RIGHT_PARENTHESIS) {
mycss_selectors_parser_selector_pseudo_element_function_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_colon_colon_function_right_parenthesis")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_colon_colon_function_right_parenthesis");
entry->parser = entry->parser_switch;
}
else {
@@ -876,7 +876,7 @@ bool mycss_selectors_state_simple_selector_colon_function(mycss_entry_t* entry,
{
if(token->type == MyCSS_TOKEN_TYPE_RIGHT_PARENTHESIS) {
mycss_selectors_parser_selector_pseudo_class_function_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_colon_function_right_parenthesis")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_colon_function_right_parenthesis");
entry->parser = entry->parser_switch;
}
else {
@@ -893,7 +893,7 @@ bool mycss_selectors_state_simple_selector_full_stop(mycss_entry_t* entry, mycss
{
if(token->type == MyCSS_TOKEN_TYPE_IDENT) {
mycss_selectors_parser_selector_class(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_full_stop_ident")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_full_stop_ident");
entry->parser = entry->parser_switch;
}
else {
@@ -910,14 +910,14 @@ bool mycss_selectors_state_simple_selector_vertical_bar(mycss_entry_t* entry, my
if(token->type == MyCSS_TOKEN_TYPE_IDENT) {
mycss_selectors_parser_selector_after_namespace(entry, token);
mycss_selectors_parser_selector_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_vertical_bar_ident")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_vertical_bar_ident");
entry->parser = entry->parser_switch;
}
else if(token->type == MyCSS_TOKEN_TYPE_DELIM) {
if(*token->data == '*') {
mycss_selectors_parser_selector_after_namespace(entry, token);
mycss_selectors_parser_selector_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_vertical_bar_asterisk")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_vertical_bar_asterisk");
entry->parser = entry->parser_switch;
}
else {
@@ -964,14 +964,14 @@ bool mycss_selectors_state_simple_selector_ident_vertical_bar(mycss_entry_t* ent
if(token->type == MyCSS_TOKEN_TYPE_IDENT) {
mycss_selectors_parser_selector_after_namespace(entry, token);
mycss_selectors_parser_selector_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_ident_vertical_bar_ident")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_ident_vertical_bar_ident");
entry->parser = entry->parser_switch;
}
else if(token->type == MyCSS_TOKEN_TYPE_DELIM) {
if(*token->data == '*') {
mycss_selectors_parser_selector_after_namespace(entry, token);
mycss_selectors_parser_selector_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_simple_selector_ident_vertical_bar_asterisk")
+ MyCORE_DEBUG("mycss_selectors_state_simple_selector_ident_vertical_bar_asterisk");
entry->parser = entry->parser_switch;
}
else {
@@ -1064,7 +1064,7 @@ bool mycss_selectors_state_left_bracket_after_wq_name_attr(mycss_entry_t* entry,
}
case MyCSS_TOKEN_TYPE_RIGHT_SQUARE_BRACKET: {
mycss_selectors_parser_selector_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_shared_after_wq_name_attr_right_bracket")
+ MyCORE_DEBUG("mycss_selectors_state_shared_after_wq_name_attr_right_bracket");
entry->parser = entry->parser_switch;
break;
}
@@ -1089,7 +1089,7 @@ bool mycss_selectors_state_shared_after_attr_modifier(mycss_entry_t* entry, mycs
if(token->type == MyCSS_TOKEN_TYPE_RIGHT_SQUARE_BRACKET) {
mycss_selectors_parser_selector_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_shared_after_attr_modifier_right_bracket")
+ MyCORE_DEBUG("mycss_selectors_state_shared_after_attr_modifier_right_bracket");
entry->parser = entry->parser_switch;
}
else {
@@ -1119,7 +1119,7 @@ bool mycss_selectors_state_shared_after_attribute_value(mycss_entry_t* entry, my
}
else if(token->type == MyCSS_TOKEN_TYPE_RIGHT_SQUARE_BRACKET) {
mycss_selectors_parser_selector_end(entry, token);
- MyCSS_DEBUG_MESSAGE("mycss_selectors_state_shared_after_attribute_value_right_bracket")
+ MyCORE_DEBUG("mycss_selectors_state_shared_after_attribute_value_right_bracket");
entry->parser = entry->parser_switch;
}
else {
diff --git a/source/mycss/selectors/state.h b/source/mycss/selectors/state.h
index 2cea842..0555a95 100644
--- a/source/mycss/selectors/state.h
+++ b/source/mycss/selectors/state.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -29,7 +29,7 @@ extern "C" {
#include "mycss/entry.h"
#include "mycss/selectors/myosi.h"
#include "mycss/selectors/parser.h"
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
void mycss_selectors_state_end(mycss_entry_t* entry);
bool mycss_selectors_state_function_skip_all(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
diff --git a/source/mycss/selectors/value.c b/source/mycss/selectors/value.c
index f72c101..d0f0588 100644
--- a/source/mycss/selectors/value.c
+++ b/source/mycss/selectors/value.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -47,7 +47,7 @@ mycss_selectors_object_attribute_t * mycss_selectors_value_attribute_create(mycs
/////////////////////////////////////////////////////////
void * mycss_selectors_value_undef_destroy(mycss_entry_t* entry, mycss_selectors_type_t type, int sub_type, void* value, bool self_destroy)
{
- myhtml_string_destroy(mycss_selector_value_string(value), false);
+ mycore_string_destroy(mycss_selector_value_string(value), false);
mcobject_free(entry->mcobject_string_entries, value);
return NULL;
@@ -55,7 +55,7 @@ void * mycss_selectors_value_undef_destroy(mycss_entry_t* entry, mycss_selectors
void * mycss_selectors_value_id_destroy(mycss_entry_t* entry, mycss_selectors_type_t type, int sub_type, void* value, bool self_destroy)
{
- myhtml_string_destroy(mycss_selector_value_string(value), false);
+ mycore_string_destroy(mycss_selector_value_string(value), false);
if(self_destroy) {
mcobject_free(entry->mcobject_string_entries, value);
@@ -67,7 +67,7 @@ void * mycss_selectors_value_id_destroy(mycss_entry_t* entry, mycss_selectors_ty
void * mycss_selectors_value_class_destroy(mycss_entry_t* entry, mycss_selectors_type_t type, int sub_type, void* value, bool self_destroy)
{
- myhtml_string_destroy(mycss_selector_value_string(value), false);
+ mycore_string_destroy(mycss_selector_value_string(value), false);
if(self_destroy) {
mcobject_free(entry->mcobject_string_entries, value);
@@ -79,7 +79,7 @@ void * mycss_selectors_value_class_destroy(mycss_entry_t* entry, mycss_selectors
void * mycss_selectors_value_element_destroy(mycss_entry_t* entry, mycss_selectors_type_t type, int sub_type, void* value, bool self_destroy)
{
- myhtml_string_destroy(mycss_selector_value_string(value), false);
+ mycore_string_destroy(mycss_selector_value_string(value), false);
if(self_destroy) {
mcobject_free(entry->mcobject_string_entries, value);
@@ -92,7 +92,7 @@ void * mycss_selectors_value_element_destroy(mycss_entry_t* entry, mycss_selecto
void * mycss_selectors_value_attribute_destroy(mycss_entry_t* entry, mycss_selectors_type_t type, int sub_type, void* value, bool self_destroy)
{
if(mycss_selector_value_attribute(value)->value) {
- myhtml_string_destroy(mycss_selector_value_attribute(value)->value, false);
+ mycore_string_destroy(mycss_selector_value_attribute(value)->value, false);
mcobject_free(entry->mcobject_string_entries, mycss_selector_value_attribute(value)->value);
}
@@ -128,10 +128,10 @@ void * mycss_selectors_value_pseudo_class_function_current_create(mycss_entry_t*
void * mycss_selectors_value_pseudo_class_function_dir_create(mycss_entry_t* entry, bool set_clean)
{
- myhtml_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
+ mycore_string_t *str = mcobject_malloc(entry->mcobject_string_entries, NULL);
if(set_clean)
- myhtml_string_clean_all(str);
+ mycore_string_clean_all(str);
return str;
}
@@ -154,7 +154,7 @@ void * mycss_selectors_value_pseudo_class_function_lang_create(mycss_entry_t* en
if(set_clean) {
lang->next = NULL;
- myhtml_string_clean_all(&lang->str);
+ mycore_string_clean_all(&lang->str);
}
return lang;
@@ -227,7 +227,7 @@ void * mycss_selectors_value_pseudo_class_function_current_destroy(mycss_entry_t
void * mycss_selectors_value_pseudo_class_function_dir_destroy(mycss_entry_t* entry, void* value, bool self_destroy)
{
- return myhtml_string_destroy(value, self_destroy);
+ return mycore_string_destroy(value, self_destroy);
}
void * mycss_selectors_value_pseudo_class_function_drop_destroy(mycss_entry_t* entry, void* value, bool self_destroy)
@@ -253,7 +253,7 @@ void * mycss_selectors_value_pseudo_class_function_lang_destroy(mycss_entry_t* e
mycss_selectors_value_lang_t *lang_entry = mycss_selector_value_lang(value);
while(lang_entry) {
- myhtml_string_destroy(&lang_entry->str, false);
+ mycore_string_destroy(&lang_entry->str, false);
lang_entry = lang_entry->next;
}
diff --git a/source/mycss/selectors/value.h b/source/mycss/selectors/value.h
index cd71770..8fd23f7 100644
--- a/source/mycss/selectors/value.h
+++ b/source/mycss/selectors/value.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -23,7 +23,7 @@
#pragma once
#define mycss_selector_value_attribute(obj) ((mycss_selectors_object_attribute_t*)(obj))
-#define mycss_selector_value_string(obj) ((myhtml_string_t*)(obj))
+#define mycss_selector_value_string(obj) ((mycore_string_t*)(obj))
#define mycss_selector_value_an_plus_b(obj) ((mycss_an_plus_b_entry_t*)(obj))
#define mycss_selector_value_drop(obj) ((mycss_selectors_function_drop_type_t)(obj))
#define mycss_selector_value_lang(obj) ((mycss_selectors_value_lang_t*)(obj))
@@ -36,13 +36,13 @@ extern "C" {
#include "mycss/entry.h"
#include "mycss/selectors/myosi.h"
-#include "myhtml/utils/mchar_async.h"
+#include "mycore/utils/mchar_async.h"
typedef void * (*mycss_selectors_value_destroy_f)(mycss_entry_t* entry, mycss_selectors_type_t type, int sub_type, void* value, bool self_destroy);
typedef void * (*mycss_selectors_value_function_destroy_f)(mycss_entry_t* entry, void* value, bool self_destroy);
struct mycss_selectors_value_attribute {
- myhtml_string_t* value;
+ mycore_string_t* value;
mycss_selectors_match_t match;
mycss_selectors_mod_t mod;
@@ -50,7 +50,7 @@ struct mycss_selectors_value_attribute {
typedef mycss_selectors_object_attribute_t;
struct mycss_selectors_value_lang {
- myhtml_string_t str;
+ mycore_string_t str;
struct mycss_selectors_value_lang* next;
}
typedef mycss_selectors_value_lang_t;
diff --git a/source/mycss/selectors/value_resource.h b/source/mycss/selectors/value_resource.h
index 328fd62..c2e0eb2 100644
--- a/source/mycss/selectors/value_resource.h
+++ b/source/mycss/selectors/value_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/stack.c b/source/mycss/stack.c
index 9e0928b..d2bea18 100644
--- a/source/mycss/stack.c
+++ b/source/mycss/stack.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -22,14 +22,14 @@
mycss_stack_t * mycss_stack_create(void)
{
- return myhtml_calloc(1, sizeof(mycss_stack_t));
+ return mycore_calloc(1, sizeof(mycss_stack_t));
}
-mycss_status_t mycss_stack_init(mycss_stack_t *stack, size_t size)
+mystatus_t mycss_stack_init(mycss_stack_t *stack, size_t size)
{
stack->entries_size = size;
stack->entries_length = 0;
- stack->entries = (mycss_stack_entry_t*)myhtml_calloc(stack->entries_size, sizeof(mycss_stack_entry_t));
+ stack->entries = (mycss_stack_entry_t*)mycore_calloc(stack->entries_size, sizeof(mycss_stack_entry_t));
if(stack->entries == NULL)
return MyCSS_STATUS_ERROR_MEMORY_ALLOCATION;
@@ -48,24 +48,24 @@ mycss_stack_t * mycss_stack_destroy(mycss_stack_t *stack, bool self_destroy)
return NULL;
if(stack->entries) {
- myhtml_free(stack->entries);
+ mycore_free(stack->entries);
stack->entries = NULL;
}
if(self_destroy) {
- myhtml_free(stack);
+ mycore_free(stack);
return NULL;
}
return stack;
}
-mycss_status_t mycss_stack_push(mycss_stack_t *stack, void* value, mycss_parser_token_f parser)
+mystatus_t mycss_stack_push(mycss_stack_t *stack, void* value, mycss_parser_token_f parser)
{
if(stack->entries_length >= stack->entries_size) {
size_t new_size = stack->entries_length << 1;
- mycss_stack_entry_t *entries = (mycss_stack_entry_t*)myhtml_realloc(stack->entries,
+ mycss_stack_entry_t *entries = (mycss_stack_entry_t*)mycore_realloc(stack->entries,
sizeof(mycss_stack_entry_t) * new_size);
if(entries) {
diff --git a/source/mycss/stack.h b/source/mycss/stack.h
index cf5140a..e03334e 100644
--- a/source/mycss/stack.h
+++ b/source/mycss/stack.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -42,11 +42,11 @@ struct mycss_stack {
typedef mycss_stack_t;
mycss_stack_t * mycss_stack_create(void);
-mycss_status_t mycss_stack_init(mycss_stack_t *stack, size_t size);
+mystatus_t mycss_stack_init(mycss_stack_t *stack, size_t size);
void mycss_stack_clean(mycss_stack_t *stack);
mycss_stack_t * mycss_stack_destroy(mycss_stack_t *stack, bool self_destroy);
-mycss_status_t mycss_stack_push(mycss_stack_t *stack, void* value, mycss_parser_token_f parser);
+mystatus_t mycss_stack_push(mycss_stack_t *stack, void* value, mycss_parser_token_f parser);
mycss_stack_entry_t * mycss_stack_pop(mycss_stack_t *stack);
mycss_stack_entry_t * mycss_stack_current(mycss_stack_t *stack);
diff --git a/source/mycss/stylesheet.c b/source/mycss/stylesheet.c
index dc998c0..8990026 100644
--- a/source/mycss/stylesheet.c
+++ b/source/mycss/stylesheet.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -22,23 +22,23 @@
mycss_stylesheet_t * mycss_stylesheet_create(void)
{
- return (mycss_stylesheet_t*)myhtml_calloc(1, sizeof(mycss_stylesheet_t));
+ return (mycss_stylesheet_t*)mycore_calloc(1, sizeof(mycss_stylesheet_t));
}
-mycss_status_t mycss_stylesheet_init(mycss_stylesheet_t* stylesheet, mycss_entry_t* entry)
+mystatus_t mycss_stylesheet_init(mycss_stylesheet_t* stylesheet, mycss_entry_t* entry)
{
stylesheet->entry = entry;
- mycss_status_t status = mycss_namespace_stylesheet_init(&stylesheet->ns_stylesheet, entry);
+ mystatus_t status = mycss_namespace_stylesheet_init(&stylesheet->ns_stylesheet, entry);
if(status != MyCSS_STATUS_OK)
return status;
return MyCSS_STATUS_OK;
}
-mycss_status_t mycss_stylesheet_clean_all(mycss_stylesheet_t* stylesheet)
+mystatus_t mycss_stylesheet_clean_all(mycss_stylesheet_t* stylesheet)
{
- mycss_status_t status = mycss_namespace_stylesheet_clean(&stylesheet->ns_stylesheet, stylesheet->entry);
+ mystatus_t status = mycss_namespace_stylesheet_clean(&stylesheet->ns_stylesheet, stylesheet->entry);
if(status != MyCSS_STATUS_OK)
return status;
@@ -52,7 +52,7 @@ mycss_stylesheet_t * mycss_stylesheet_destroy(mycss_stylesheet_t* stylesheet, bo
mycss_namespace_stylesheet_destroy(&stylesheet->ns_stylesheet, stylesheet->entry, false);
if(self_destroy) {
- myhtml_free(stylesheet);
+ mycore_free(stylesheet);
return NULL;
}
@@ -60,7 +60,7 @@ mycss_stylesheet_t * mycss_stylesheet_destroy(mycss_stylesheet_t* stylesheet, bo
}
/* print */
-void mycss_stylesheet_serialization(mycss_stylesheet_t* stylesheet, mycss_callback_serialization_f callback, void* context)
+void mycss_stylesheet_serialization(mycss_stylesheet_t* stylesheet, mycore_callback_serialize_f callback, void* context)
{
mycss_selectors_serialization_list(stylesheet->entry->selectors, stylesheet->sel_list_first, callback, context);
}
diff --git a/source/mycss/stylesheet.h b/source/mycss/stylesheet.h
index dd7d8a9..c4dafa1 100644
--- a/source/mycss/stylesheet.h
+++ b/source/mycss/stylesheet.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -45,11 +45,11 @@ struct mycss_stylesheet {
};
mycss_stylesheet_t * mycss_stylesheet_create(void);
-mycss_status_t mycss_stylesheet_init(mycss_stylesheet_t* stylesheet, mycss_entry_t* entry);
-mycss_status_t mycss_stylesheet_clean_all(mycss_stylesheet_t* stylesheet);
+mystatus_t mycss_stylesheet_init(mycss_stylesheet_t* stylesheet, mycss_entry_t* entry);
+mystatus_t mycss_stylesheet_clean_all(mycss_stylesheet_t* stylesheet);
mycss_stylesheet_t * mycss_stylesheet_destroy(mycss_stylesheet_t* stylesheet, bool self_destroy);
-void mycss_stylesheet_serialization(mycss_stylesheet_t* stylesheet, mycss_callback_serialization_f callback, void* context);
+void mycss_stylesheet_serialization(mycss_stylesheet_t* stylesheet, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/mycss/tokenizer.c b/source/mycss/tokenizer.c
index 522c60d..5f2c03b 100644
--- a/source/mycss/tokenizer.c
+++ b/source/mycss/tokenizer.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,11 +20,11 @@
#include "mycss/tokenizer.h"
#include "mycss/tokenizer_resource.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
-mycss_status_t mycss_tokenizer_chunk(mycss_entry_t* entry, const char* css, size_t css_length)
+mystatus_t mycss_tokenizer_chunk(mycss_entry_t* entry, const char* css, size_t css_length)
{
- entry->current_buffer = myhtml_incoming_buffer_add(entry->current_buffer, entry->mcobject_incoming_buffer,
+ entry->current_buffer = mycore_incoming_buffer_add(entry->current_buffer, entry->mcobject_incoming_buffer,
css, css_length);
if(entry->current_buffer == NULL)
@@ -35,7 +35,7 @@ mycss_status_t mycss_tokenizer_chunk(mycss_entry_t* entry, const char* css, size
entry->first_buffer = entry->current_buffer;
if(entry->token == NULL) {
- entry->token = (mycss_token_t*)myhtml_calloc(1, sizeof(mycss_token_t));
+ entry->token = (mycss_token_t*)mycore_calloc(1, sizeof(mycss_token_t));
if(entry->token == NULL)
return MyCSS_STATUS_ERROR_TOKENIZER_TOKEN_ALLOCATION;
@@ -44,7 +44,7 @@ mycss_status_t mycss_tokenizer_chunk(mycss_entry_t* entry, const char* css, size
return mycss_tokenizer_process(entry, css, css_length);
}
-mycss_status_t mycss_tokenizer_process(mycss_entry_t* entry, const char* css, size_t css_length)
+mystatus_t mycss_tokenizer_process(mycss_entry_t* entry, const char* css, size_t css_length)
{
/*
Why use utf-8 when the declaration says utf-16?
@@ -57,16 +57,16 @@ mycss_status_t mycss_tokenizer_process(mycss_entry_t* entry, const char* css, si
As well, this mimics the behavior of HTML’s <meta charset> attribute.
*/
- if(entry->encoding == MyHTML_ENCODING_UTF_16LE || entry->encoding == MyHTML_ENCODING_UTF_16BE)
- entry->encoding = MyHTML_ENCODING_UTF_8;
+ if(entry->encoding == MyENCODING_UTF_16LE || entry->encoding == MyENCODING_UTF_16BE)
+ entry->encoding = MyENCODING_UTF_8;
mycss_t* mycss = entry->mycss;
mycss_tokenizer_state_f* state_f = mycss->parse_state_func;
- myhtml_incoming_buffer_t *current = entry->current_buffer;
+ mycore_incoming_buffer_t *current = entry->current_buffer;
do {
- myhtml_incoming_buffer_t *mt = entry->current_buffer;
+ mycore_incoming_buffer_t *mt = entry->current_buffer;
mt->length = 0;
while (mt->length < mt->size) {
@@ -82,14 +82,14 @@ mycss_status_t mycss_tokenizer_process(mycss_entry_t* entry, const char* css, si
return MyCSS_STATUS_OK;
}
-mycss_status_t mycss_tokenizer_end(mycss_entry_t* entry)
+mystatus_t mycss_tokenizer_end(mycss_entry_t* entry)
{
mycss_t* mycss = entry->mycss;
mycss_tokenizer_state_f* state_f = mycss->parse_state_func;
if(entry->state != MyCSS_TOKENIZER_STATE_DATA)
{
- myhtml_incoming_buffer_t *mt = entry->current_buffer;
+ mycore_incoming_buffer_t *mt = entry->current_buffer;
size_t end_state = (MyCSS_TOKENIZER_STATE_LAST_ENTRY + entry->state);
mt->length = state_f[end_state](entry, entry->token, mt->data, mt->length, mt->size);
@@ -116,7 +116,7 @@ size_t mycss_tokenizer_state_set_current_buffer_for_continue(mycss_entry_t* entr
if(css_offset >= css_minus_offset)
return css_offset;
- myhtml_incoming_buffer_t *buffer = entry->current_buffer;
+ mycore_incoming_buffer_t *buffer = entry->current_buffer;
size_t need = (css_minus_offset - css_offset);
size_t position = buffer->offset - need;
@@ -134,11 +134,11 @@ size_t mycss_tokenizer_state_set_current_buffer_for_continue(mycss_entry_t* entr
size_t mycss_tokenizer_token_strcasecmp(mycss_entry_t* entry, mycss_token_t* token, const char* to, size_t to_length)
{
- myhtml_incoming_buffer_t *buffer = myhtml_incoming_buffer_find_by_position(entry->current_buffer, token->begin);
+ mycore_incoming_buffer_t *buffer = mycore_incoming_buffer_find_by_position(entry->current_buffer, token->begin);
size_t token_offset = token->begin - buffer->offset;
- return myhtml_incoming_buffer_escaped_case_cmp(&buffer, to, to_length, &token_offset);
+ return mycore_incoming_buffer_escaped_case_cmp(&buffer, to, to_length, &token_offset);
}
//////////////////////
@@ -668,7 +668,7 @@ size_t mycss_tokenizer_state_solidus_comment_end(mycss_entry_t* entry, mycss_tok
if(css[css_offset] == '/') {
if(css_offset == 0)
{
- myhtml_incoming_buffer_t *buffer = entry->current_buffer->prev;
+ mycore_incoming_buffer_t *buffer = entry->current_buffer->prev;
while(buffer && buffer->size == 0)
buffer = buffer->prev;
@@ -1052,7 +1052,7 @@ size_t mycss_tokenizer_state_letter_u(mycss_entry_t* entry, mycss_token_t* token
return css_offset;
}
- if(myhtml_string_chars_hex_map[ (const unsigned char)(css[css_offset]) ] != 0xff ||
+ if(mycore_string_chars_hex_map[ (const unsigned char)(css[css_offset]) ] != 0xff ||
css[css_offset] == '?')
{
token->begin += 2;
@@ -1075,7 +1075,7 @@ size_t mycss_tokenizer_state_letter_u(mycss_entry_t* entry, mycss_token_t* token
size_t mycss_tokenizer_state_letter_u_next(mycss_entry_t* entry, mycss_token_t* token, const char* css, size_t css_offset, size_t css_size)
{
- if(myhtml_string_chars_hex_map[ (const unsigned char)(css[css_offset]) ] != 0xff ||
+ if(mycore_string_chars_hex_map[ (const unsigned char)(css[css_offset]) ] != 0xff ||
css[css_offset] == '?')
{
token->begin += 2;
@@ -1186,9 +1186,9 @@ size_t mycss_tokenizer_state_delim_single_code_point(mycss_entry_t* entry, mycss
//// init tokenizer
////
/////////////////////////////////////////////////////////
-mycss_status_t mycss_tokenizer_state_init(mycss_t* mycss)
+mystatus_t mycss_tokenizer_state_init(mycss_t* mycss)
{
- mycss->parse_state_func = (mycss_tokenizer_state_f*)myhtml_calloc((MyCSS_TOKENIZER_STATE_LAST_ENTRY * 2), sizeof(mycss_tokenizer_state_f));
+ mycss->parse_state_func = (mycss_tokenizer_state_f*)mycore_calloc((MyCSS_TOKENIZER_STATE_LAST_ENTRY * 2), sizeof(mycss_tokenizer_state_f));
if(mycss->parse_state_func == NULL)
return MyCSS_STATUS_ERROR_TOKENIZER_STATE_ALLOCATION;
@@ -1361,7 +1361,7 @@ mycss_status_t mycss_tokenizer_state_init(mycss_t* mycss)
void mycss_tokenizer_state_destroy(mycss_t* mycss)
{
if(mycss->parse_state_func) {
- free(mycss->parse_state_func);
+ mycore_free(mycss->parse_state_func);
mycss->parse_state_func = NULL;
}
}
diff --git a/source/mycss/tokenizer.h b/source/mycss/tokenizer.h
index a712ad3..8caf24b 100644
--- a/source/mycss/tokenizer.h
+++ b/source/mycss/tokenizer.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -33,7 +33,7 @@ extern "C" {
#include "mycss/tokenizer_global.h"
#include "mycss/tokenizer_end.h"
-#include "myhtml/incoming.h"
+#include "mycore/incoming.h"
#define MyCSS_TOKEN_READY_CALLBACK_FUNCTION(ENTRY, TOKEN) \
++ENTRY->token_counter; \
@@ -53,12 +53,12 @@ struct mycss_token {
const char* data;
};
-mycss_status_t mycss_tokenizer_state_init(mycss_t* mycss);
+mystatus_t mycss_tokenizer_state_init(mycss_t* mycss);
void mycss_tokenizer_state_destroy(mycss_t* mycss);
-mycss_status_t mycss_tokenizer_chunk(mycss_entry_t* entry, const char* css, size_t css_length);
-mycss_status_t mycss_tokenizer_process(mycss_entry_t* entry, const char* css, size_t css_length);
-mycss_status_t mycss_tokenizer_end(mycss_entry_t* entry);
+mystatus_t mycss_tokenizer_chunk(mycss_entry_t* entry, const char* css, size_t css_length);
+mystatus_t mycss_tokenizer_process(mycss_entry_t* entry, const char* css, size_t css_length);
+mystatus_t mycss_tokenizer_end(mycss_entry_t* entry);
size_t mycss_tokenizer_run_state_single(mycss_entry_t* entry, mycss_tokenizer_state_t state, const char* css, size_t css_offset, size_t css_size);
size_t mycss_tokenizer_state_set_current_buffer_for_continue(mycss_entry_t* entry, size_t css_offset, size_t css_minus_offset);
diff --git a/source/mycss/tokenizer_end.c b/source/mycss/tokenizer_end.c
index ba5c1f2..d722f48 100644
--- a/source/mycss/tokenizer_end.c
+++ b/source/mycss/tokenizer_end.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/tokenizer_end.h b/source/mycss/tokenizer_end.h
index 590f1e0..27e4370 100644
--- a/source/mycss/tokenizer_end.h
+++ b/source/mycss/tokenizer_end.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/tokenizer_global.c b/source/mycss/tokenizer_global.c
index 6edb86b..9b1fdea 100644
--- a/source/mycss/tokenizer_global.c
+++ b/source/mycss/tokenizer_global.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "mycss/tokenizer_global.h"
#include "mycss/tokenizer_resource.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
/////////////////////////////////////////////////////////
//// Global back
@@ -676,7 +676,7 @@ size_t mycss_tokenizer_global_state_unicode_range(mycss_entry_t* entry, mycss_to
while(css_offset < css_size)
{
- if(myhtml_string_chars_hex_map[ u_css[css_offset] ] != 0xff)
+ if(mycore_string_chars_hex_map[ u_css[css_offset] ] != 0xff)
{
entry->help_counter++;
@@ -758,7 +758,7 @@ size_t mycss_tokenizer_global_state_unicode_range_minus(mycss_entry_t* entry, my
while(css_offset < css_size)
{
- if(myhtml_string_chars_hex_map[ u_css[css_offset] ] != 0xff)
+ if(mycore_string_chars_hex_map[ u_css[css_offset] ] != 0xff)
{
entry->help_counter++;
diff --git a/source/mycss/tokenizer_global.h b/source/mycss/tokenizer_global.h
index 37327d6..5ba51c5 100644
--- a/source/mycss/tokenizer_global.h
+++ b/source/mycss/tokenizer_global.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/tokenizer_resource.h b/source/mycss/tokenizer_resource.h
index 623a904..4d39109 100644
--- a/source/mycss/tokenizer_resource.h
+++ b/source/mycss/tokenizer_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/values/color.c b/source/mycss/values/color.c
index cb22714..4a161f0 100644
--- a/source/mycss/values/color.c
+++ b/source/mycss/values/color.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,19 +20,19 @@
#include "mycss/values/color.h"
#include "mycss/values/color_resources.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
const mycss_values_color_index_static_entry_t * mycss_values_color_index_entry_by_name(const char* name, size_t length)
{
- size_t idx = ((myhtml_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
- myhtml_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
+ size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
+ mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
length)
% MyCSS_COLOR_NAME_STATIC_INDEX_FOR_SEARCH_SIZE) + 1;
while (mycss_values_color_name_index_static_for_search[idx].name)
{
if(mycss_values_color_name_index_static_for_search[idx].name_length == length) {
- if(myhtml_strncasecmp(mycss_values_color_name_index_static_for_search[idx].name, name, length) == 0)
+ if(mycore_strncasecmp(mycss_values_color_name_index_static_for_search[idx].name, name, length) == 0)
return &mycss_values_color_name_index_static_for_search[idx];
if(mycss_values_color_name_index_static_for_search[idx].next)
@@ -80,15 +80,15 @@ const char * mycss_values_color_name_by_id(mycss_values_color_id_t color_id, siz
const mycss_values_color_function_index_static_entry_t * mycss_values_color_function_index_entry_by_name(const char* name, size_t length)
{
- size_t idx = ((myhtml_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
- myhtml_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
+ size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
+ mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
length)
% MyCSS_COLOR_FUNCTION_STATIC_INDEX_FOR_SEARCH_SIZE) + 1;
while (mycss_values_color_function_index_static_for_search[idx].name)
{
if(mycss_values_color_function_index_static_for_search[idx].name_length == length) {
- if(myhtml_strncasecmp(mycss_values_color_function_index_static_for_search[idx].name, name, length) == 0)
+ if(mycore_strncasecmp(mycss_values_color_function_index_static_for_search[idx].name, name, length) == 0)
return &mycss_values_color_function_index_static_for_search[idx];
if(mycss_values_color_function_index_static_for_search[idx].next)
diff --git a/source/mycss/values/color.h b/source/mycss/values/color.h
index 1220c77..2819a39 100644
--- a/source/mycss/values/color.h
+++ b/source/mycss/values/color.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/values/color_const.h b/source/mycss/values/color_const.h
index fb28243..0c614b8 100644
--- a/source/mycss/values/color_const.h
+++ b/source/mycss/values/color_const.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/source/mycss/values/color_parser.c b/source/mycss/values/color_parser.c
index 661da53..b84f4b3 100644
--- a/source/mycss/values/color_parser.c
+++ b/source/mycss/values/color_parser.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -19,7 +19,7 @@
*/
#include "mycss/values/color_parser.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
bool mycss_values_color_parser_undef(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
{
@@ -51,39 +51,39 @@ static bool mycss_values_color_parser_find_end(mycss_entry_t* entry, mycss_token
static void mycss_values_color_parser_set_percentage_value(mycss_entry_t* entry, mycss_token_t* token, mycss_values_percentage_t *color_rgb)
{
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_token_data_to_string(entry, token, &str, true, false);
double return_num;
mycss_convert_data_to_double(str.data, str.length, &return_num, &color_rgb->is_float);
if(color_rgb->is_float)
- color_rgb->f = (float)return_num;
+ color_rgb->value.f = (float)return_num;
else
- color_rgb->i = (int)return_num;
+ color_rgb->value.i = (int)return_num;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
}
static void mycss_values_color_parser_set_number_value(mycss_entry_t* entry, mycss_token_t* token, mycss_values_number_t *color_rgb)
{
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_token_data_to_string(entry, token, &str, true, false);
double return_num;
mycss_convert_data_to_double(str.data, str.length, &return_num, &color_rgb->is_float);
if(color_rgb->is_float)
- color_rgb->f = (float)return_num;
+ color_rgb->value.f = (float)return_num;
else
- color_rgb->i = (int)return_num;
+ color_rgb->value.i = (int)return_num;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
}
static bool mycss_values_color_parser_set_angle_value(mycss_entry_t* entry, mycss_token_t* token, mycss_values_angle_t *angle)
{
- myhtml_string_t str = {0};
+ mycore_string_t str = {0};
mycss_token_data_to_string(entry, token, &str, true, false);
bool is_float;
@@ -92,7 +92,7 @@ static bool mycss_values_color_parser_set_angle_value(mycss_entry_t* entry, mycs
size_t consume_length = mycss_convert_data_to_double(str.data, str.length, &return_num, &is_float);
mycss_units_type_t type = mycss_units_type_by_name(&str.data[consume_length], (str.length - consume_length));
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
switch (type) {
case MyCSS_UNIT_TYPE_DEG:
@@ -106,9 +106,9 @@ static bool mycss_values_color_parser_set_angle_value(mycss_entry_t* entry, mycs
}
if(is_float)
- angle->f = (float)return_num;
+ angle->value.f = (float)return_num;
else
- angle->i = (int)return_num;
+ angle->value.i = (int)return_num;
angle->is_float = is_float;
angle->type = type;
@@ -120,14 +120,14 @@ static bool mycss_values_color_parser_rgb_full(mycss_entry_t* entry, mycss_token
{
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE)
{
- mycss_values_color_parser_set_percentage_value(entry, token, &color->rgba_percentage.r);
+ mycss_values_color_parser_set_percentage_value(entry, token, &color->value.rgba_percentage.r);
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE;
entry->parser = mycss_values_color_parser_rgb_before_g_percentage;
}
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER)
{
- mycss_values_color_parser_set_number_value(entry, token, &color->rgba_number.r);
+ mycss_values_color_parser_set_number_value(entry, token, &color->value.rgba_number.r);
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
entry->parser = mycss_values_color_parser_rgb_before_g_number;
@@ -217,7 +217,7 @@ bool mycss_values_color_parser_rgb_g_percentage(mycss_entry_t* entry, mycss_toke
}
mycss_values_color_t *color = declr_entry->value;
- mycss_values_color_parser_set_percentage_value(entry, token, &color->rgba_percentage.g);
+ mycss_values_color_parser_set_percentage_value(entry, token, &color->value.rgba_percentage.g);
entry->parser = mycss_values_color_parser_rgb_before_b_percentage;
@@ -259,7 +259,7 @@ bool mycss_values_color_parser_rgb_b_percentage(mycss_entry_t* entry, mycss_toke
}
mycss_values_color_t *color = declr_entry->value;
- mycss_values_color_parser_set_percentage_value(entry, token, &color->rgba_percentage.b);
+ mycss_values_color_parser_set_percentage_value(entry, token, &color->value.rgba_percentage.b);
entry->parser = mycss_values_color_parser_rgb_before_alpha_percentage;
return true;
@@ -307,12 +307,12 @@ bool mycss_values_color_parser_rgb_alpha_percentage(mycss_entry_t* entry, mycss_
mycss_values_color_t *color = declr_entry->value;
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE) {
- mycss_values_color_parser_set_percentage_value(entry, token, &color->rgba_percentage.alpha.percentage);
- color->rgba_percentage.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE;
+ mycss_values_color_parser_set_percentage_value(entry, token, &color->value.rgba_percentage.alpha.value.percentage);
+ color->value.rgba_percentage.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE;
}
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) {
- mycss_values_color_parser_set_number_value(entry, token, &color->rgba_percentage.alpha.number);
- color->rgba_percentage.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
+ mycss_values_color_parser_set_number_value(entry, token, &color->value.rgba_percentage.alpha.value.number);
+ color->value.rgba_percentage.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
}
else {
mycss_values_color_parser_switch_parser(entry);
@@ -364,7 +364,7 @@ bool mycss_values_color_parser_rgb_g_number(mycss_entry_t* entry, mycss_token_t*
}
mycss_values_color_t *color = declr_entry->value;
- mycss_values_color_parser_set_number_value(entry, token, &color->rgba_number.g);
+ mycss_values_color_parser_set_number_value(entry, token, &color->value.rgba_number.g);
entry->parser = mycss_values_color_parser_rgb_before_b_number;
return true;
@@ -408,7 +408,7 @@ bool mycss_values_color_parser_rgb_b_number(mycss_entry_t* entry, mycss_token_t*
}
mycss_values_color_t *color = declr_entry->value;
- mycss_values_color_parser_set_number_value(entry, token, &color->rgba_number.b);
+ mycss_values_color_parser_set_number_value(entry, token, &color->value.rgba_number.b);
entry->parser = mycss_values_color_parser_rgb_before_alpha_number;
return true;
@@ -456,12 +456,12 @@ bool mycss_values_color_parser_rgb_alpha_number(mycss_entry_t* entry, mycss_toke
mycss_values_color_t *color = declr_entry->value;
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE) {
- mycss_values_color_parser_set_percentage_value(entry, token, &color->rgba_number.alpha.percentage);
- color->rgba_number.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE;
+ mycss_values_color_parser_set_percentage_value(entry, token, &color->value.rgba_number.alpha.value.percentage);
+ color->value.rgba_number.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE;
}
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) {
- mycss_values_color_parser_set_number_value(entry, token, &color->rgba_number.alpha.number);
- color->rgba_number.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
+ mycss_values_color_parser_set_number_value(entry, token, &color->value.rgba_number.alpha.value.number);
+ color->value.rgba_number.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
}
else {
mycss_values_color_parser_switch_parser(entry);
@@ -478,7 +478,7 @@ bool mycss_values_color_parser_rgb_alpha_number(mycss_entry_t* entry, mycss_toke
static bool mycss_values_color_parser_hsla_full(mycss_entry_t* entry, mycss_token_t* token, mycss_values_color_t *color)
{
if(token->type == MyCSS_TOKEN_TYPE_DIMENSION) {
- if(mycss_values_color_parser_set_angle_value(entry, token, &color->hsla.hue.angle) == false) {
+ if(mycss_values_color_parser_set_angle_value(entry, token, &color->value.hsla.hue.value.angle) == false) {
mycss_values_color_parser_switch_parser(entry);
return false;
}
@@ -487,7 +487,7 @@ static bool mycss_values_color_parser_hsla_full(mycss_entry_t* entry, mycss_toke
}
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER)
{
- mycss_values_color_parser_set_number_value(entry, token, &color->hsla.hue.number);
+ mycss_values_color_parser_set_number_value(entry, token, &color->value.hsla.hue.value.number);
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
}
else {
@@ -573,7 +573,7 @@ bool mycss_values_color_parser_hsl_saturation(mycss_entry_t* entry, mycss_token_
}
mycss_values_color_t *color = declr_entry->value;
- mycss_values_color_parser_set_percentage_value(entry, token, &color->hsla.saturation);
+ mycss_values_color_parser_set_percentage_value(entry, token, &color->value.hsla.saturation);
entry->parser = mycss_values_color_parser_hsl_before_lightness;
return true;
@@ -617,7 +617,7 @@ bool mycss_values_color_parser_hsl_lightness(mycss_entry_t* entry, mycss_token_t
}
mycss_values_color_t *color = declr_entry->value;
- mycss_values_color_parser_set_percentage_value(entry, token, &color->hsla.lightness);
+ mycss_values_color_parser_set_percentage_value(entry, token, &color->value.hsla.lightness);
entry->parser = mycss_values_color_parser_hsl_before_alpha;
return true;
@@ -665,12 +665,12 @@ bool mycss_values_color_parser_hsl_alpha(mycss_entry_t* entry, mycss_token_t* to
mycss_values_color_t *color = declr_entry->value;
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE) {
- mycss_values_color_parser_set_percentage_value(entry, token, &color->hsla.alpha.percentage);
- color->hsla.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE;
+ mycss_values_color_parser_set_percentage_value(entry, token, &color->value.hsla.alpha.value.percentage);
+ color->value.hsla.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE;
}
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) {
- mycss_values_color_parser_set_number_value(entry, token, &color->hsla.alpha.number);
- color->hsla.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
+ mycss_values_color_parser_set_number_value(entry, token, &color->value.hsla.alpha.value.number);
+ color->value.hsla.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
}
else {
mycss_values_color_parser_switch_parser(entry);
@@ -686,10 +686,10 @@ bool mycss_values_color_parser_hsl_alpha(mycss_entry_t* entry, mycss_token_t* to
*/
static unsigned int mycss_values_color_parser_hex_get_by_two(unsigned char* u_data)
{
- return (myhtml_string_chars_hex_map[ u_data[0] ] << 4) | myhtml_string_chars_hex_map[ u_data[1] ];
+ return (mycore_string_chars_hex_map[ u_data[0] ] << 4) | mycore_string_chars_hex_map[ u_data[1] ];
}
-bool mycss_values_color_parser_hex(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str)
+bool mycss_values_color_parser_hex(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str)
{
if(token->type != MyCSS_TOKEN_TYPE_HASH)
return true;
@@ -702,50 +702,50 @@ bool mycss_values_color_parser_hex(mycss_entry_t* entry, mycss_token_t* token, v
switch (str->length) {
case 6:
- color->hex.r.i = (int)mycss_values_color_parser_hex_get_by_two(u_data);
- color->hex.g.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[2]);
- color->hex.b.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[4]);
- color->hex.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_UNDEF;
+ color->value.hex.r.value.i = (int)mycss_values_color_parser_hex_get_by_two(u_data);
+ color->value.hex.g.value.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[2]);
+ color->value.hex.b.value.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[4]);
+ color->value.hex.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_UNDEF;
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_HEX_6;
break;
case 8:
- color->hex.r.i = (int)mycss_values_color_parser_hex_get_by_two(u_data);
- color->hex.g.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[2]);
- color->hex.b.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[4]);
+ color->value.hex.r.value.i = (int)mycss_values_color_parser_hex_get_by_two(u_data);
+ color->value.hex.g.value.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[2]);
+ color->value.hex.b.value.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[4]);
- color->hex.alpha.number.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[6]);
- color->hex.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
+ color->value.hex.alpha.value.number.value.i = (int)mycss_values_color_parser_hex_get_by_two(&u_data[6]);
+ color->value.hex.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_HEX_8;
break;
case 3:
- color->hex.r.i = (int)(myhtml_string_chars_hex_map[ u_data[0] ]);
- color->hex.r.i = (color->hex.r.i << 4) | color->hex.r.i;
+ color->value.hex.r.value.i = (int)(mycore_string_chars_hex_map[ u_data[0] ]);
+ color->value.hex.r.value.i = (color->value.hex.r.value.i << 4) | color->value.hex.r.value.i;
- color->hex.g.i = (int)(myhtml_string_chars_hex_map[ u_data[1] ]);
- color->hex.g.i = (color->hex.g.i << 4) | color->hex.g.i;
+ color->value.hex.g.value.i = (int)(mycore_string_chars_hex_map[ u_data[1] ]);
+ color->value.hex.g.value.i = (color->value.hex.g.value.i << 4) | color->value.hex.g.value.i;
- color->hex.b.i = (int)(myhtml_string_chars_hex_map[ u_data[2] ]);
- color->hex.b.i = (color->hex.b.i << 4) | color->hex.b.i;
+ color->value.hex.b.value.i = (int)(mycore_string_chars_hex_map[ u_data[2] ]);
+ color->value.hex.b.value.i = (color->value.hex.b.value.i << 4) | color->value.hex.b.value.i;
- color->hex.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_UNDEF;
+ color->value.hex.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_UNDEF;
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_HEX_3;
break;
case 4:
- color->hex.r.i = (int)(myhtml_string_chars_hex_map[ u_data[0] ]);
- color->hex.r.i = (color->hex.r.i << 4) | color->hex.r.i;
+ color->value.hex.r.value.i = (int)(mycore_string_chars_hex_map[ u_data[0] ]);
+ color->value.hex.r.value.i = (color->value.hex.r.value.i << 4) | color->value.hex.r.value.i;
- color->hex.g.i = (int)(myhtml_string_chars_hex_map[ u_data[1] ]);
- color->hex.g.i = (color->hex.g.i << 4) | color->hex.g.i;
+ color->value.hex.g.value.i = (int)(mycore_string_chars_hex_map[ u_data[1] ]);
+ color->value.hex.g.value.i = (color->value.hex.g.value.i << 4) | color->value.hex.g.value.i;
- color->hex.b.i = (int)(myhtml_string_chars_hex_map[ u_data[2] ]);
- color->hex.b.i = (color->hex.b.i << 4) | color->hex.b.i;
+ color->value.hex.b.value.i = (int)(mycore_string_chars_hex_map[ u_data[2] ]);
+ color->value.hex.b.value.i = (color->value.hex.b.value.i << 4) | color->value.hex.b.value.i;
- color->hex.alpha.number.i = (int)(myhtml_string_chars_hex_map[ u_data[3] ]);
- color->hex.alpha.number.i = (color->hex.alpha.number.i << 4) | color->hex.alpha.number.i;
- color->hex.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
+ color->value.hex.alpha.value.number.value.i = (int)(mycore_string_chars_hex_map[ u_data[3] ]);
+ color->value.hex.alpha.value.number.value.i = (color->value.hex.alpha.value.number.value.i << 4) | color->value.hex.alpha.value.number.value.i;
+ color->value.hex.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_HEX_4;
break;
@@ -771,7 +771,7 @@ bool mycss_values_color_parser_hex(mycss_entry_t* entry, mycss_token_t* token, v
static bool mycss_values_color_parser_hwb_hue(mycss_entry_t* entry, mycss_token_t* token, mycss_values_color_t *color)
{
if(token->type == MyCSS_TOKEN_TYPE_DIMENSION) {
- if(mycss_values_color_parser_set_angle_value(entry, token, &color->hwb.hue.angle) == false) {
+ if(mycss_values_color_parser_set_angle_value(entry, token, &color->value.hwb.hue.value.angle) == false) {
mycss_values_color_parser_switch_parser(entry);
return false;
}
@@ -780,7 +780,7 @@ static bool mycss_values_color_parser_hwb_hue(mycss_entry_t* entry, mycss_token_
}
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER)
{
- mycss_values_color_parser_set_number_value(entry, token, &color->hwb.hue.number);
+ mycss_values_color_parser_set_number_value(entry, token, &color->value.hwb.hue.value.number);
color->type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
}
else {
@@ -845,7 +845,7 @@ bool mycss_values_color_parser_hwb_whiteness(mycss_entry_t* entry, mycss_token_t
}
mycss_values_color_t *color = declr_entry->value;
- mycss_values_color_parser_set_percentage_value(entry, token, &color->hwb.saturation);
+ mycss_values_color_parser_set_percentage_value(entry, token, &color->value.hwb.saturation);
entry->parser = mycss_values_color_parser_hwb_before_blackness;
return true;
@@ -889,7 +889,7 @@ bool mycss_values_color_parser_hwb_blackness(mycss_entry_t* entry, mycss_token_t
}
mycss_values_color_t *color = declr_entry->value;
- mycss_values_color_parser_set_percentage_value(entry, token, &color->hwb.lightness);
+ mycss_values_color_parser_set_percentage_value(entry, token, &color->value.hwb.lightness);
entry->parser = mycss_values_color_parser_hwb_before_alpha;
return true;
@@ -937,12 +937,12 @@ bool mycss_values_color_parser_hwb_alpha(mycss_entry_t* entry, mycss_token_t* to
mycss_values_color_t *color = declr_entry->value;
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE) {
- mycss_values_color_parser_set_percentage_value(entry, token, &color->hwb.alpha.percentage);
- color->hwb.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE;
+ mycss_values_color_parser_set_percentage_value(entry, token, &color->value.hwb.alpha.value.percentage);
+ color->value.hwb.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE;
}
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) {
- mycss_values_color_parser_set_number_value(entry, token, &color->hwb.alpha.number);
- color->hwb.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
+ mycss_values_color_parser_set_number_value(entry, token, &color->value.hwb.alpha.value.number);
+ color->value.hwb.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
}
else {
mycss_values_color_parser_switch_parser(entry);
@@ -972,7 +972,7 @@ bool mycss_values_color_parser_gray(mycss_entry_t* entry, mycss_token_t* token,
if(token->type == MyCSS_TOKEN_TYPE_NUMBER)
{
- mycss_values_color_parser_set_number_value(entry, token, &color->gray.number);
+ mycss_values_color_parser_set_number_value(entry, token, &color->value.gray.number);
color->type = MyCSS_VALUES_COLOR_TYPE_GRAY;
entry->parser = mycss_values_color_parser_gray_before_alpha;
@@ -1027,12 +1027,12 @@ bool mycss_values_color_parser_gray_alpha(mycss_entry_t* entry, mycss_token_t* t
mycss_values_color_t *color = declr_entry->value;
if(token->type == MyCSS_TOKEN_TYPE_PERCENTAGE) {
- mycss_values_color_parser_set_percentage_value(entry, token, &color->gray.alpha.percentage);
- color->gray.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE;
+ mycss_values_color_parser_set_percentage_value(entry, token, &color->value.gray.alpha.value.percentage);
+ color->value.gray.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE;
}
else if(token->type == MyCSS_TOKEN_TYPE_NUMBER) {
- mycss_values_color_parser_set_number_value(entry, token, &color->gray.alpha.number);
- color->gray.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
+ mycss_values_color_parser_set_number_value(entry, token, &color->value.gray.alpha.value.number);
+ color->value.gray.alpha.type_value = MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER;
}
else {
mycss_values_color_parser_switch_parser(entry);
diff --git a/source/mycss/values/color_parser.h b/source/mycss/values/color_parser.h
index 20f5525..8f175a0 100644
--- a/source/mycss/values/color_parser.h
+++ b/source/mycss/values/color_parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -55,7 +55,7 @@ bool mycss_values_color_parser_hsl_lightness(mycss_entry_t* entry, mycss_token_t
bool mycss_values_color_parser_hsl_before_alpha(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_values_color_parser_hsl_alpha(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
-bool mycss_values_color_parser_hex(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, myhtml_string_t* str);
+bool mycss_values_color_parser_hex(mycss_entry_t* entry, mycss_token_t* token, void** value, unsigned int* value_type, mycore_string_t* str);
bool mycss_values_color_parser_hwb(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
bool mycss_values_color_parser_hwb_before_whiteness(mycss_entry_t* entry, mycss_token_t* token, bool last_response);
diff --git a/source/mycss/values/color_resources.h b/source/mycss/values/color_resources.h
index b06cba3..108a410 100644
--- a/source/mycss/values/color_resources.h
+++ b/source/mycss/values/color_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/values/consume.c b/source/mycss/values/consume.c
index aed5979..69215ae 100644
--- a/source/mycss/values/consume.c
+++ b/source/mycss/values/consume.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -26,7 +26,7 @@ bool mycss_values_consume_length(mycss_entry_t* entry, mycss_token_t* token)
{
mycss_values_length_t *value = mycss_values_create(entry, sizeof(mycss_values_length_t));
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, false);
double return_num;
@@ -34,7 +34,7 @@ bool mycss_values_consume_length(mycss_entry_t* entry, mycss_token_t* token)
if(token->type == MyCSS_TOKEN_TYPE_DIMENSION) {
value->type = mycss_units_type_by_name(&str.data[consume_length], (str.length - consume_length));
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
if(value->type == MyCSS_UNIT_TYPE_UNDEF) {
mycss_values_destroy(entry, value);
@@ -43,13 +43,13 @@ bool mycss_values_consume_length(mycss_entry_t* entry, mycss_token_t* token)
}
else {
value->type = MyCSS_UNIT_TYPE_UNDEF;
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
}
if(value->is_float)
- value->f = (float)return_num;
+ value->value.f = (float)return_num;
else
- value->i = (int)return_num;
+ value->value.i = (int)return_num;
*entry->values = value;
}
@@ -65,18 +65,18 @@ bool mycss_values_consume_percentage(mycss_entry_t* entry, mycss_token_t* token)
{
mycss_values_percentage_t *value = mycss_values_create(entry, sizeof(mycss_values_length_t));
- myhtml_string_t str;
+ mycore_string_t str;
mycss_token_data_to_string(entry, token, &str, true, false);
double return_num;
mycss_convert_data_to_double(str.data, str.length, &return_num, &value->is_float);
- myhtml_string_destroy(&str, false);
+ mycore_string_destroy(&str, false);
if(value->is_float)
- value->f = (float)return_num;
+ value->value.f = (float)return_num;
else
- value->i = (int)return_num;
+ value->value.i = (int)return_num;
*entry->values = value;
diff --git a/source/mycss/values/consume.h b/source/mycss/values/consume.h
index 1a8441e..da4508a 100644
--- a/source/mycss/values/consume.h
+++ b/source/mycss/values/consume.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/values/destroy.c b/source/mycss/values/destroy.c
index 7a8fde2..ebf0268 100644
--- a/source/mycss/values/destroy.c
+++ b/source/mycss/values/destroy.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -333,12 +333,12 @@ mycss_values_text_decoration_t * mycss_values_destroy_text_decoration(mycss_entr
/*
* String
*/
-myhtml_string_t * mycss_values_destroy_string(mycss_entry_t* entry, myhtml_string_t* value, bool self_destroy)
+mycore_string_t * mycss_values_destroy_string(mycss_entry_t* entry, mycore_string_t* value, bool self_destroy)
{
if(value == NULL)
return NULL;
- myhtml_string_destroy(value, false);
+ mycore_string_destroy(value, false);
if(self_destroy) {
mycss_values_destroy(entry, (void*)value);
@@ -377,23 +377,23 @@ mycss_values_image_t * mycss_values_destroy_image(mycss_entry_t* entry, mycss_va
switch (image->type) {
case MyCSS_PROPERTY_VALUE__URL:
- image->url = mycss_values_destroy_url(entry, image->url, true);
+ image->value.url = mycss_values_destroy_url(entry, image->value.url, true);
break;
case MyCSS_PROPERTY_VALUE__IMAGE_FUNCTION:
- image->ii = mycss_values_destroy_image_image(entry, image->ii, true);
+ image->value.ii = mycss_values_destroy_image_image(entry, image->value.ii, true);
break;
case MyCSS_PROPERTY_VALUE__IMAGE_SET_FUNCTION:
- image->ii_set = mycss_values_destroy_image_image_set(entry, image->ii_set, true);
+ image->value.ii_set = mycss_values_destroy_image_image_set(entry, image->value.ii_set, true);
break;
case MyCSS_PROPERTY_VALUE__ELEMENT_FUNCTION:
- image->element = mycss_values_destroy_element(entry, image->element, true);
+ image->value.element = mycss_values_destroy_element(entry, image->value.element, true);
break;
case MyCSS_PROPERTY_VALUE__CROSS_FADE_FUNCTION:
- image->cross_fade = mycss_values_destroy_cross_fade(entry, image->cross_fade, true);
+ image->value.cross_fade = mycss_values_destroy_cross_fade(entry, image->value.cross_fade, true);
break;
default:
@@ -543,20 +543,20 @@ mycss_values_background_position_t * mycss_values_destroy_background_position(my
if(value == NULL)
return NULL;
- if(value->one.length) {
- mycss_values_destroy(entry, (void*)value->one.length);
+ if(value->one.value.length) {
+ mycss_values_destroy(entry, (void*)value->one.value.length);
}
- if(value->two.length) {
- mycss_values_destroy(entry, (void*)value->two.length);
+ if(value->two.value.length) {
+ mycss_values_destroy(entry, (void*)value->two.value.length);
}
- if(value->three.length) {
- mycss_values_destroy(entry, (void*)value->three.length);
+ if(value->three.value.length) {
+ mycss_values_destroy(entry, (void*)value->three.value.length);
}
- if(value->four.length) {
- mycss_values_destroy(entry, (void*)value->four.length);
+ if(value->four.value.length) {
+ mycss_values_destroy(entry, (void*)value->four.value.length);
}
if(self_destroy) {
@@ -574,15 +574,15 @@ mycss_values_background_size_list_t * mycss_values_destroy_background_size(mycss
for(size_t i = 0; i < value->entries_length; i++) {
if(value->entries[i].width) {
- if(value->entries[i].width->percentage)
- mycss_values_destroy(entry, (void*)value->entries[i].width->percentage);
+ if(value->entries[i].width->value.percentage)
+ mycss_values_destroy(entry, (void*)value->entries[i].width->value.percentage);
mycss_values_destroy(entry, (void*)value->entries[i].width);
}
if(value->entries[i].height) {
- if(value->entries[i].height->percentage)
- mycss_values_destroy(entry, (void*)value->entries[i].height->percentage);
+ if(value->entries[i].height->value.percentage)
+ mycss_values_destroy(entry, (void*)value->entries[i].height->value.percentage);
mycss_values_destroy(entry, (void*)value->entries[i].height);
}
diff --git a/source/mycss/values/destroy.h b/source/mycss/values/destroy.h
index 7f5e2b1..67d6a32 100644
--- a/source/mycss/values/destroy.h
+++ b/source/mycss/values/destroy.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/values/image.c b/source/mycss/values/image.c
index 74f860d..066e14c 100644
--- a/source/mycss/values/image.c
+++ b/source/mycss/values/image.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,19 +20,19 @@
#include "mycss/values/image.h"
#include "mycss/values/image_resources.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
const mycss_values_image_function_index_static_entry_t * mycss_values_image_index_entry_by_name(const char* name, size_t length)
{
- size_t idx = ((myhtml_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
- myhtml_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
+ size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
+ mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
length)
% MyCSS_IMAGE_FUNCTION_STATIC_INDEX_FOR_SEARCH_SIZE) + 1;
while (mycss_values_image_function_index_static_for_search[idx].name)
{
if(mycss_values_image_function_index_static_for_search[idx].name_length == length) {
- if(myhtml_strncasecmp(mycss_values_image_function_index_static_for_search[idx].name, name, length) == 0)
+ if(mycore_strncasecmp(mycss_values_image_function_index_static_for_search[idx].name, name, length) == 0)
return &mycss_values_image_function_index_static_for_search[idx];
if(mycss_values_image_function_index_static_for_search[idx].next)
@@ -63,32 +63,32 @@ mycss_property_value_t mycss_values_image_id_by_name(const char *name, size_t le
void * mycss_values_image_creator_url(mycss_entry_t* entry, mycss_values_image_t* image)
{
- image->url = mycss_values_create(entry, sizeof(mycss_values_url_t));
- return image->url;
+ image->value.url = mycss_values_create(entry, sizeof(mycss_values_url_t));
+ return image->value.url;
}
void * mycss_values_image_creator_function_image(mycss_entry_t* entry, mycss_values_image_t* image)
{
- image->ii = mycss_values_create(entry, sizeof(mycss_values_image_image_t));
- return image->ii;
+ image->value.ii = mycss_values_create(entry, sizeof(mycss_values_image_image_t));
+ return image->value.ii;
}
void * mycss_values_image_creator_image_set(mycss_entry_t* entry, mycss_values_image_t* image)
{
- image->ii_set = mycss_values_create(entry, sizeof(mycss_values_image_image_set_t));
- return image->ii_set;
+ image->value.ii_set = mycss_values_create(entry, sizeof(mycss_values_image_image_set_t));
+ return image->value.ii_set;
}
void * mycss_values_image_creator_element(mycss_entry_t* entry, mycss_values_image_t* image)
{
- image->element = mycss_values_create(entry, sizeof(mycss_values_element_t));
- return image->element;
+ image->value.element = mycss_values_create(entry, sizeof(mycss_values_element_t));
+ return image->value.element;
}
void * mycss_values_image_creator_cross_fade(mycss_entry_t* entry, mycss_values_image_t* image)
{
- image->cross_fade = mycss_values_create(entry, sizeof(mycss_values_cross_fade_t));
- return image->cross_fade;
+ image->value.cross_fade = mycss_values_create(entry, sizeof(mycss_values_cross_fade_t));
+ return image->value.cross_fade;
}
diff --git a/source/mycss/values/image.h b/source/mycss/values/image.h
index 888f926..a35fe32 100644
--- a/source/mycss/values/image.h
+++ b/source/mycss/values/image.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/values/image_resources.h b/source/mycss/values/image_resources.h
index a612ec7..02863c9 100644
--- a/source/mycss/values/image_resources.h
+++ b/source/mycss/values/image_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/values/resources.h b/source/mycss/values/resources.h
index 1c7efd4..faf67a5 100644
--- a/source/mycss/values/resources.h
+++ b/source/mycss/values/resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/values/serialization.c b/source/mycss/values/serialization.c
index f46b2e4..be4e202 100644
--- a/source/mycss/values/serialization.c
+++ b/source/mycss/values/serialization.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -21,20 +21,20 @@
#include "mycss/values/serialization.h"
#include "mycss/values/units_resources.h"
#include "mycss/property/resources_name.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
-static void mycss_values_serialization_to_callback(const char* data, size_t len, mycss_callback_serialization_f callback, void* context)
+static void mycss_values_serialization_to_callback(const char* data, size_t len, mycore_callback_serialize_f callback, void* context)
{
if(len > 0)
callback(data, len, context);
}
-void mycss_values_serialization_string(myhtml_string_t* str, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_string(mycore_string_t* str, mycore_callback_serialize_f callback, void* context)
{
callback(str->data, str->length, context);
}
-void mycss_values_serialization_number(mycss_values_number_t* value, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_number(mycss_values_number_t* value, mycore_callback_serialize_f callback, void* context)
{
if(value == NULL)
return;
@@ -42,16 +42,16 @@ void mycss_values_serialization_number(mycss_values_number_t* value, mycss_callb
char buff[512];
if(value->is_float) {
- int len = snprintf(buff, 512, "%0.4f", value->f);
+ int len = snprintf(buff, 512, "%0.4f", value->value.f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
- int len = snprintf(buff, 512, "%d", value->i);
+ int len = snprintf(buff, 512, "%d", value->value.i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
}
-void mycss_values_serialization_length(mycss_values_length_t* value, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_length(mycss_values_length_t* value, mycore_callback_serialize_f callback, void* context)
{
if(value == NULL)
return;
@@ -59,11 +59,11 @@ void mycss_values_serialization_length(mycss_values_length_t* value, mycss_callb
char buff[512];
if(value->is_float) {
- int len = snprintf(buff, 512, "%0.4f", value->f);
+ int len = snprintf(buff, 512, "%0.4f", value->value.f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
- int len = snprintf(buff, 512, "%d", value->i);
+ int len = snprintf(buff, 512, "%d", value->value.i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
@@ -73,7 +73,7 @@ void mycss_values_serialization_length(mycss_values_length_t* value, mycss_callb
}
}
-void mycss_values_serialization_angle(mycss_values_angle_t* value, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_angle(mycss_values_angle_t* value, mycore_callback_serialize_f callback, void* context)
{
if(value == NULL)
return;
@@ -81,11 +81,11 @@ void mycss_values_serialization_angle(mycss_values_angle_t* value, mycss_callbac
char buff[512];
if(value->is_float) {
- int len = snprintf(buff, 512, "%0.4f", value->f);
+ int len = snprintf(buff, 512, "%0.4f", value->value.f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
- int len = snprintf(buff, 512, "%d", value->i);
+ int len = snprintf(buff, 512, "%d", value->value.i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
@@ -95,7 +95,7 @@ void mycss_values_serialization_angle(mycss_values_angle_t* value, mycss_callbac
}
}
-void mycss_values_serialization_resolution(mycss_values_resolution_t* value, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_resolution(mycss_values_resolution_t* value, mycore_callback_serialize_f callback, void* context)
{
if(value == NULL)
return;
@@ -103,11 +103,11 @@ void mycss_values_serialization_resolution(mycss_values_resolution_t* value, myc
char buff[512];
if(value->is_float) {
- int len = snprintf(buff, 512, "%0.4f", value->f);
+ int len = snprintf(buff, 512, "%0.4f", value->value.f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
- int len = snprintf(buff, 512, "%d", value->i);
+ int len = snprintf(buff, 512, "%d", value->value.i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
@@ -117,7 +117,7 @@ void mycss_values_serialization_resolution(mycss_values_resolution_t* value, myc
}
}
-void mycss_values_serialization_percentage(mycss_values_percentage_t* value, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_percentage(mycss_values_percentage_t* value, mycore_callback_serialize_f callback, void* context)
{
if(value == NULL)
return;
@@ -125,24 +125,24 @@ void mycss_values_serialization_percentage(mycss_values_percentage_t* value, myc
char buff[512];
if(value->is_float) {
- int len = snprintf(buff, 512, "%0.4f%%", value->f);
+ int len = snprintf(buff, 512, "%0.4f%%", value->value.f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
- int len = snprintf(buff, 512, "%d%%", value->i);
+ int len = snprintf(buff, 512, "%d%%", value->value.i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
}
-void mycss_values_serialization_type_length_percentage(mycss_values_type_length_percentage_entry_t* value, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_type_length_percentage(mycss_values_type_length_percentage_entry_t* value, mycore_callback_serialize_f callback, void* context)
{
switch (value->type) {
case MyCSS_PROPERTY_VALUE__LENGTH:
- mycss_values_serialization_length(value->length, callback, context);
+ mycss_values_serialization_length(value->value.length, callback, context);
break;
case MyCSS_PROPERTY_VALUE__PERCENTAGE:
- mycss_values_serialization_percentage(value->percentage, callback, context);
+ mycss_values_serialization_percentage(value->value.percentage, callback, context);
break;
default: {
@@ -156,16 +156,16 @@ void mycss_values_serialization_type_length_percentage(mycss_values_type_length_
static void mycss_values_serialization_color_hex_one_value(int value, unsigned char* data)
{
- data[0] = myhtml_string_hex_to_char_map[ (unsigned int)(value >> 4) ];
+ data[0] = mycore_string_hex_to_char_map[ (unsigned int)(value >> 4) ];
}
static void mycss_values_serialization_color_hex_two_value(int value, unsigned char* data)
{
- data[0] = myhtml_string_hex_to_char_map[ (unsigned int)(value >> 4) ];
- data[1] = myhtml_string_hex_to_char_map[ (unsigned int)((value) ^ ((value >> 4) << 4)) ];
+ data[0] = mycore_string_hex_to_char_map[ (unsigned int)(value >> 4) ];
+ data[1] = mycore_string_hex_to_char_map[ (unsigned int)((value) ^ ((value >> 4) << 4)) ];
}
-void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_color(mycss_values_color_t* value, mycore_callback_serialize_f callback, void* context)
{
if(value == NULL)
return;
@@ -173,7 +173,7 @@ void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callbac
switch (value->type) {
case MyCSS_VALUES_COLOR_TYPE_NAMED: {
size_t length;
- const char *name = mycss_values_color_name_by_id(value->name_id, &length);
+ const char *name = mycss_values_color_name_by_id(value->value.name_id, &length);
mycss_values_serialization_to_callback(name, length, callback, context);
break;
@@ -189,25 +189,25 @@ void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callbac
if(value->type_value == MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE)
{
- mycss_values_serialization_percentage(&value->rgba_percentage.r, callback, context);
+ mycss_values_serialization_percentage(&value->value.rgba_percentage.r, callback, context);
callback(", ", 2, context);
- mycss_values_serialization_percentage(&value->rgba_percentage.g, callback, context);
+ mycss_values_serialization_percentage(&value->value.rgba_percentage.g, callback, context);
callback(", ", 2, context);
- mycss_values_serialization_percentage(&value->rgba_percentage.b, callback, context);
- mycss_values_serialization_color_alpha(&value->rgba_percentage.alpha, callback, context);
+ mycss_values_serialization_percentage(&value->value.rgba_percentage.b, callback, context);
+ mycss_values_serialization_color_alpha(&value->value.rgba_percentage.alpha, callback, context);
}
else if(value->type_value == MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER)
{
- mycss_values_serialization_number(&value->rgba_number.r, callback, context);
+ mycss_values_serialization_number(&value->value.rgba_number.r, callback, context);
callback(", ", 2, context);
- mycss_values_serialization_number(&value->rgba_number.g, callback, context);
+ mycss_values_serialization_number(&value->value.rgba_number.g, callback, context);
callback(", ", 2, context);
- mycss_values_serialization_number(&value->rgba_number.b, callback, context);
- mycss_values_serialization_color_alpha(&value->rgba_number.alpha, callback, context);
+ mycss_values_serialization_number(&value->value.rgba_number.b, callback, context);
+ mycss_values_serialization_color_alpha(&value->value.rgba_number.alpha, callback, context);
}
callback(")", 1, context);
@@ -223,19 +223,19 @@ void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callbac
else
callback("hsla(", 5, context);
- if(value->hsla.hue.type_value == MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER) {
- mycss_values_serialization_number(&value->hsla.hue.number, callback, context);
+ if(value->value.hsla.hue.type_value == MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER) {
+ mycss_values_serialization_number(&value->value.hsla.hue.value.number, callback, context);
}
else {
- mycss_values_serialization_angle(&value->hsla.hue.angle, callback, context);
+ mycss_values_serialization_angle(&value->value.hsla.hue.value.angle, callback, context);
}
callback(", ", 2, context);
- mycss_values_serialization_percentage(&value->hsla.saturation, callback, context);
+ mycss_values_serialization_percentage(&value->value.hsla.saturation, callback, context);
callback(", ", 2, context);
- mycss_values_serialization_percentage(&value->hsla.lightness, callback, context);
- mycss_values_serialization_color_alpha(&value->hsla.alpha, callback, context);
+ mycss_values_serialization_percentage(&value->value.hsla.lightness, callback, context);
+ mycss_values_serialization_color_alpha(&value->value.hsla.alpha, callback, context);
callback(")", 1, context);
@@ -246,19 +246,19 @@ void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callbac
{
callback("hwb(", 4, context);
- if(value->hwb.hue.type_value == MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER) {
- mycss_values_serialization_number(&value->hwb.hue.number, callback, context);
+ if(value->value.hwb.hue.type_value == MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER) {
+ mycss_values_serialization_number(&value->value.hwb.hue.value.number, callback, context);
}
else {
- mycss_values_serialization_angle(&value->hwb.hue.angle, callback, context);
+ mycss_values_serialization_angle(&value->value.hwb.hue.value.angle, callback, context);
}
callback(", ", 2, context);
- mycss_values_serialization_percentage(&value->hwb.saturation, callback, context);
+ mycss_values_serialization_percentage(&value->value.hwb.saturation, callback, context);
callback(", ", 2, context);
- mycss_values_serialization_percentage(&value->hwb.lightness, callback, context);
- mycss_values_serialization_color_alpha(&value->hwb.alpha, callback, context);
+ mycss_values_serialization_percentage(&value->value.hwb.lightness, callback, context);
+ mycss_values_serialization_color_alpha(&value->value.hwb.alpha, callback, context);
callback(")", 1, context);
@@ -269,8 +269,8 @@ void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callbac
{
callback("gray(", 5, context);
- mycss_values_serialization_number(&value->gray.number, callback, context);
- mycss_values_serialization_color_alpha(&value->gray.alpha, callback, context);
+ mycss_values_serialization_number(&value->value.gray.number, callback, context);
+ mycss_values_serialization_color_alpha(&value->value.gray.alpha, callback, context);
callback(")", 1, context);
@@ -284,10 +284,10 @@ void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callbac
if(value->type_value == MyCSS_VALUES_COLOR_TYPE_VALUE_HEX_8) {
unsigned char data[9];
- mycss_values_serialization_color_hex_two_value(value->hex.r.i, data);
- mycss_values_serialization_color_hex_two_value(value->hex.g.i, &data[2]);
- mycss_values_serialization_color_hex_two_value(value->hex.b.i, &data[4]);
- mycss_values_serialization_color_hex_two_value(value->hex.alpha.number.i, &data[6]);
+ mycss_values_serialization_color_hex_two_value(value->value.hex.r.value.i, data);
+ mycss_values_serialization_color_hex_two_value(value->value.hex.g.value.i, &data[2]);
+ mycss_values_serialization_color_hex_two_value(value->value.hex.b.value.i, &data[4]);
+ mycss_values_serialization_color_hex_two_value(value->value.hex.alpha.value.number.value.i, &data[6]);
data[8] = '\0';
callback((const char*)data, 8, context);
@@ -295,9 +295,9 @@ void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callbac
else if(value->type_value == MyCSS_VALUES_COLOR_TYPE_VALUE_HEX_6) {
unsigned char data[7];
- mycss_values_serialization_color_hex_two_value(value->hex.r.i, data);
- mycss_values_serialization_color_hex_two_value(value->hex.g.i, &data[2]);
- mycss_values_serialization_color_hex_two_value(value->hex.b.i, &data[4]);
+ mycss_values_serialization_color_hex_two_value(value->value.hex.r.value.i, data);
+ mycss_values_serialization_color_hex_two_value(value->value.hex.g.value.i, &data[2]);
+ mycss_values_serialization_color_hex_two_value(value->value.hex.b.value.i, &data[4]);
data[6] = '\0';
callback((const char*)data, 6, context);
@@ -305,10 +305,10 @@ void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callbac
else if(value->type_value == MyCSS_VALUES_COLOR_TYPE_VALUE_HEX_4) {
unsigned char data[5];
- mycss_values_serialization_color_hex_one_value(value->hex.r.i, data);
- mycss_values_serialization_color_hex_one_value(value->hex.g.i, &data[1]);
- mycss_values_serialization_color_hex_one_value(value->hex.b.i, &data[2]);
- mycss_values_serialization_color_hex_one_value(value->hex.alpha.number.i, &data[3]);
+ mycss_values_serialization_color_hex_one_value(value->value.hex.r.value.i, data);
+ mycss_values_serialization_color_hex_one_value(value->value.hex.g.value.i, &data[1]);
+ mycss_values_serialization_color_hex_one_value(value->value.hex.b.value.i, &data[2]);
+ mycss_values_serialization_color_hex_one_value(value->value.hex.alpha.value.number.value.i, &data[3]);
data[4] = '\0';
callback((const char*)data, 4, context);
@@ -316,9 +316,9 @@ void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callbac
else if(value->type_value == MyCSS_VALUES_COLOR_TYPE_VALUE_HEX_3) {
unsigned char data[4];
- mycss_values_serialization_color_hex_one_value(value->hex.r.i, data);
- mycss_values_serialization_color_hex_one_value(value->hex.g.i, &data[1]);
- mycss_values_serialization_color_hex_one_value(value->hex.b.i, &data[2]);
+ mycss_values_serialization_color_hex_one_value(value->value.hex.r.value.i, data);
+ mycss_values_serialization_color_hex_one_value(value->value.hex.g.value.i, &data[1]);
+ mycss_values_serialization_color_hex_one_value(value->value.hex.b.value.i, &data[2]);
data[3] = '\0';
callback((const char*)data, 3, context);
@@ -332,22 +332,22 @@ void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callbac
}
}
-void mycss_values_serialization_color_alpha(mycss_values_color_alpha_value_t* value, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_color_alpha(mycss_values_color_alpha_value_t* value, mycore_callback_serialize_f callback, void* context)
{
if(value == NULL)
return;
if(value->type_value == MyCSS_VALUES_COLOR_TYPE_VALUE_PERCENTAGE) {
callback(", ", 2, context);
- mycss_values_serialization_percentage(&value->percentage, callback, context);
+ mycss_values_serialization_percentage(&value->value.percentage, callback, context);
}
else if(value->type_value == MyCSS_VALUES_COLOR_TYPE_VALUE_NUMBER) {
callback(", ", 2, context);
- mycss_values_serialization_number(&value->number, callback, context);
+ mycss_values_serialization_number(&value->value.number, callback, context);
}
}
-void mycss_values_serialization_text_decoration_line(mycss_values_text_decoration_line_t value, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_text_decoration_line(mycss_values_text_decoration_line_t value, mycore_callback_serialize_f callback, void* context)
{
const char *text_value = NULL;
@@ -381,7 +381,7 @@ void mycss_values_serialization_text_decoration_line(mycss_values_text_decoratio
}
}
-void mycss_values_serialization_text_decoration_skip(mycss_values_text_decoration_skip_t value, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_text_decoration_skip(mycss_values_text_decoration_skip_t value, mycore_callback_serialize_f callback, void* context)
{
const char *text_value = NULL;
@@ -423,18 +423,18 @@ void mycss_values_serialization_text_decoration_skip(mycss_values_text_decoratio
}
}
-void mycss_values_serialization_url(mycss_values_url_t* url, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_url(mycss_values_url_t* url, mycore_callback_serialize_f callback, void* context)
{
callback("url(", 4, context);
callback(url->str.data, url->str.length, context);
callback(")", 1, context);
}
-void mycss_values_serialization_image(mycss_values_image_t* image, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_image(mycss_values_image_t* image, mycore_callback_serialize_f callback, void* context)
{
switch (image->type) {
case MyCSS_PROPERTY_VALUE__URL:
- mycss_values_serialization_url(image->url, callback, context);
+ mycss_values_serialization_url(image->value.url, callback, context);
break;
case MyCSS_PROPERTY_VALUE__IMAGE_FUNCTION: {
@@ -442,23 +442,23 @@ void mycss_values_serialization_image(mycss_values_image_t* image, mycss_callbac
bool o_e = false;
- if(image->ii->image) {
+ if(image->value.ii->image) {
o_e = true;
- mycss_values_serialization_image(image->ii->image, callback, context);
+ mycss_values_serialization_image(image->value.ii->image, callback, context);
}
- else if(image->ii->str) {
+ else if(image->value.ii->str) {
o_e = true;
callback("\"", 1, context);
- mycss_values_serialization_string(image->ii->str, callback, context);
+ mycss_values_serialization_string(image->value.ii->str, callback, context);
callback("\"", 1, context);
}
- if(image->ii->color) {
+ if(image->value.ii->color) {
if(o_e)
callback(", ", 2, context);
- mycss_values_serialization_color(image->ii->color, callback, context);
+ mycss_values_serialization_color(image->value.ii->color, callback, context);
}
callback(")", 1, context);
@@ -470,9 +470,9 @@ void mycss_values_serialization_image(mycss_values_image_t* image, mycss_callbac
bool o_e = false;
- for(size_t i = 0; i < image->ii_set->options_length; i++)
+ for(size_t i = 0; i < image->value.ii_set->options_length; i++)
{
- mycss_values_image_image_set_option_t* option = &image->ii_set->options[i];
+ mycss_values_image_image_set_option_t* option = &image->value.ii_set->options[i];
if(option->image) {
o_e = true;
@@ -501,12 +501,12 @@ void mycss_values_serialization_image(mycss_values_image_t* image, mycss_callbac
case MyCSS_PROPERTY_VALUE__ELEMENT_FUNCTION: {
callback("string(", 7, context);
- mycss_values_serialization_string(&image->element->custom_ident.str, callback, context);
+ mycss_values_serialization_string(&image->value.element->custom_ident.str, callback, context);
- if(image->element->type) {
+ if(image->value.element->type) {
callback(", ", 2, context);
- const char* text_value = mycss_property_index_type_value[image->element->type];
+ const char* text_value = mycss_property_index_type_value[image->value.element->type];
callback(text_value, strlen(text_value), context);
}
@@ -517,26 +517,26 @@ void mycss_values_serialization_image(mycss_values_image_t* image, mycss_callbac
case MyCSS_PROPERTY_VALUE__CROSS_FADE_FUNCTION: {
callback("cross-fade(", 11, context);
- if(image->cross_fade->mixing_image.percentage) {
- mycss_values_serialization_percentage(image->cross_fade->mixing_image.percentage, callback, context);
+ if(image->value.cross_fade->mixing_image.percentage) {
+ mycss_values_serialization_percentage(image->value.cross_fade->mixing_image.percentage, callback, context);
}
- if(image->cross_fade->mixing_image.image) {
- if(image->cross_fade->mixing_image.percentage)
+ if(image->value.cross_fade->mixing_image.image) {
+ if(image->value.cross_fade->mixing_image.percentage)
callback(" ", 1, context);
- mycss_values_serialization_image(image->cross_fade->mixing_image.image, callback, context);
+ mycss_values_serialization_image(image->value.cross_fade->mixing_image.image, callback, context);
}
- mycss_values_serialization_string(&image->element->custom_ident.str, callback, context);
+ mycss_values_serialization_string(&image->value.element->custom_ident.str, callback, context);
- if(image->cross_fade->final_image.image) {
+ if(image->value.cross_fade->final_image.image) {
callback(", ", 2, context);
- mycss_values_serialization_image(image->cross_fade->final_image.image, callback, context);
+ mycss_values_serialization_image(image->value.cross_fade->final_image.image, callback, context);
}
- else if(image->cross_fade->final_image.color) {
+ else if(image->value.cross_fade->final_image.color) {
callback(", ", 2, context);
- mycss_values_serialization_color(image->cross_fade->final_image.color, callback, context);
+ mycss_values_serialization_color(image->value.cross_fade->final_image.color, callback, context);
}
callback(")", 1, context);
@@ -552,7 +552,7 @@ void mycss_values_serialization_image(mycss_values_image_t* image, mycss_callbac
}
}
-void mycss_values_serialization_background_size_entry(mycss_values_background_size_entry_t* bg_size_entry, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_background_size_entry(mycss_values_background_size_entry_t* bg_size_entry, mycore_callback_serialize_f callback, void* context)
{
if(bg_size_entry->scale) {
const char* text_value = mycss_property_index_type_value[bg_size_entry->scale];
@@ -571,7 +571,7 @@ void mycss_values_serialization_background_size_entry(mycss_values_background_si
}
}
-void mycss_values_serialization_border(mycss_values_border_t* border, mycss_callback_serialization_f callback, void* context)
+void mycss_values_serialization_border(mycss_values_border_t* border, mycore_callback_serialize_f callback, void* context)
{
bool o_e = false;
diff --git a/source/mycss/values/serialization.h b/source/mycss/values/serialization.h
index 45b4887..3c9c71b 100644
--- a/source/mycss/values/serialization.h
+++ b/source/mycss/values/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -30,21 +30,21 @@ extern "C" {
#include "mycss/values/color.h"
#include "mycss/property/const.h"
-void mycss_values_serialization_string(myhtml_string_t* str, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_number(mycss_values_number_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_length(mycss_values_length_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_angle(mycss_values_angle_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_resolution(mycss_values_resolution_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_percentage(mycss_values_percentage_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_type_length_percentage(mycss_values_type_length_percentage_entry_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_color(mycss_values_color_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_color_alpha(mycss_values_color_alpha_value_t* value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_text_decoration_line(mycss_values_text_decoration_line_t value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_text_decoration_skip(mycss_values_text_decoration_skip_t value, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_url(mycss_values_url_t* url, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_image(mycss_values_image_t* image, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_background_size_entry(mycss_values_background_size_entry_t* bg_size_entry, mycss_callback_serialization_f callback, void* context);
-void mycss_values_serialization_border(mycss_values_border_t* border, mycss_callback_serialization_f callback, void* context);
+void mycss_values_serialization_string(mycore_string_t* str, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_number(mycss_values_number_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_length(mycss_values_length_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_angle(mycss_values_angle_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_resolution(mycss_values_resolution_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_percentage(mycss_values_percentage_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_type_length_percentage(mycss_values_type_length_percentage_entry_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_color(mycss_values_color_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_color_alpha(mycss_values_color_alpha_value_t* value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_text_decoration_line(mycss_values_text_decoration_line_t value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_text_decoration_skip(mycss_values_text_decoration_skip_t value, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_url(mycss_values_url_t* url, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_image(mycss_values_image_t* image, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_background_size_entry(mycss_values_background_size_entry_t* bg_size_entry, mycore_callback_serialize_f callback, void* context);
+void mycss_values_serialization_border(mycss_values_border_t* border, mycore_callback_serialize_f callback, void* context);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/mycss/values/units.c b/source/mycss/values/units.c
index 7f0533d..a84639e 100644
--- a/source/mycss/values/units.c
+++ b/source/mycss/values/units.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,22 +20,22 @@
#include "mycss/values/units.h"
#include "mycss/values/units_resources.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
const mycss_units_index_static_entry_t * mycss_units_index_entry_by_name(const char* name, size_t length)
{
if(length == 0)
return NULL;
- size_t idx = ((myhtml_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
- myhtml_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
+ size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
+ mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
length)
% MyCSS_UNITS_STATIC_INDEX_FOR_SEARCH_SIZE) + 1;
while (mycss_units_index_static_for_search[idx].name)
{
if(mycss_units_index_static_for_search[idx].name_length == length) {
- if(myhtml_strncasecmp(mycss_units_index_static_for_search[idx].name, name, length) == 0)
+ if(mycore_strncasecmp(mycss_units_index_static_for_search[idx].name, name, length) == 0)
return &mycss_units_index_static_for_search[idx];
if(mycss_units_index_static_for_search[idx].next)
diff --git a/source/mycss/values/units.h b/source/mycss/values/units.h
index 165f718..223c48f 100644
--- a/source/mycss/values/units.h
+++ b/source/mycss/values/units.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -23,7 +23,7 @@
#pragma once
#include "mycss/myosi.h"
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
#define mycss_units_is_angel_type(type) (type >= 1 && type <= 4)
#define mycss_units_is_frequency_type(type) (type >= 5 && type <= 6)
diff --git a/source/mycss/values/units_resources.h b/source/mycss/values/units_resources.h
index 7d7c8e1..e602fac 100644
--- a/source/mycss/values/units_resources.h
+++ b/source/mycss/values/units_resources.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/values/values.c b/source/mycss/values/values.c
index 0ff0c1c..8f18f6e 100644
--- a/source/mycss/values/values.c
+++ b/source/mycss/values/values.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/mycss/values/values.h b/source/mycss/values/values.h
index 0d94df7..b1cc84f 100644
--- a/source/mycss/values/values.h
+++ b/source/mycss/values/values.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -26,7 +26,7 @@
#include "mycss/values/units.h"
#include "mycss/values/color_const.h"
#include "mycss/property/const.h"
-#include "myhtml/utils/mchar_async.h"
+#include "mycore/utils/mchar_async.h"
#include "myhtml/mystring.h"
#include "mycss/declaration/myosi.h"
@@ -115,12 +115,13 @@ struct mycss_values_type_list {
size_t entries_length;
};
-struct mycss_values_type_length_percentage_entry {
- union {
- mycss_values_percentage_t* percentage;
- mycss_values_length_t* length;
- };
+union mycss_values_type_length_percentage_union {
+ mycss_values_percentage_t* percentage;
+ mycss_values_length_t* length;
+};
+struct mycss_values_type_length_percentage_entry {
+ union mycss_values_type_length_percentage_union value;
unsigned int type;
};
@@ -128,7 +129,7 @@ struct mycss_values_number {
union {
int i;
float f;
- };
+ } value;
bool is_float;
};
@@ -137,9 +138,10 @@ struct mycss_values_length {
union {
int i;
float f;
- };
+ } value;
bool is_float;
+
mycss_units_type_t type;
};
@@ -147,7 +149,7 @@ struct mycss_values_percentage {
union {
int i;
float f;
- };
+ } value;
bool is_float;
};
@@ -156,7 +158,7 @@ struct mycss_values_angle {
union {
int i;
float f;
- };
+ } value;
bool is_float;
mycss_units_type_t type;
@@ -166,14 +168,14 @@ struct mycss_values_resolution {
union {
int i;
float f;
- };
+ } value;
bool is_float;
mycss_units_type_t type;
};
struct mycss_values_custom_ident {
- myhtml_string_t str;
+ mycore_string_t str;
};
/*
@@ -211,7 +213,7 @@ struct mycss_values_color_alpha_value {
union {
mycss_values_number_t number;
mycss_values_percentage_t percentage;
- };
+ } value;
mycss_values_color_type_value_t type_value;
};
@@ -220,7 +222,7 @@ struct mycss_values_color_hue_value {
union {
mycss_values_number_t number;
mycss_values_angle_t angle;
- };
+ } value;
mycss_values_color_type_value_t type_value;
};
@@ -267,7 +269,7 @@ struct mycss_values_color {
mycss_values_color_hwb_t hwb;
mycss_values_color_gray_t gray;
mycss_values_color_id_t name_id;
- };
+ } value;
mycss_values_color_type_t type;
mycss_values_color_type_value_t type_value;
@@ -287,7 +289,7 @@ struct mycss_values_color_stop_list {
URL
*/
struct mycss_values_url {
- myhtml_string_t str;
+ mycore_string_t str;
};
/*
@@ -308,7 +310,7 @@ struct mycss_values_image {
mycss_values_image_image_set_t* ii_set;
mycss_values_element_t* element;
mycss_values_cross_fade_t* cross_fade;
- };
+ } value;
mycss_property_value_t type;
};
@@ -320,14 +322,14 @@ struct mycss_values_image_list {
/* image() */
struct mycss_values_image_image {
- myhtml_string_t* str;
+ mycore_string_t* str;
mycss_values_image_t* image;
mycss_values_color_t* color;
};
/* image-set() */
struct mycss_values_image_image_set_option {
- myhtml_string_t* str;
+ mycore_string_t* str;
mycss_values_image_t* image;
mycss_values_resolution_t* resolution;
};
@@ -378,7 +380,7 @@ struct mycss_values_gradient_linear {
union {
mycss_values_angle_t angle;
mycss_values_gradient_side_or_corner_t side_or_corner;
- };
+ } value;
mycss_values_color_stop_list_t color_stop_list;
};
@@ -398,9 +400,9 @@ typedef mycss_values_font_family_type_t;
struct mycss_values_font_family_entry {
union {
- myhtml_string_t str;
+ mycore_string_t str;
mycss_property_font_family_t prop_type;
- };
+ } value;
mycss_values_font_family_type_t type;
};
diff --git a/source/myencoding/Makefile.mk b/source/myencoding/Makefile.mk
new file mode 100644
index 0000000..d6194bc
--- /dev/null
+++ b/source/myencoding/Makefile.mk
@@ -0,0 +1,13 @@
+myencoding_dirs := .
+myencoding_objs := $(call MODEST_UTILS_OBJS,myencoding,$(myencoding_dirs))
+
+myencoding_description := work with character encodings, detecting encoding, convert encodings by https://encoding.spec.whatwg.org/
+myencoding_dependencies := mycore myport
+
+myencoding_all: $(myencoding_objs)
+
+myencoding_clean:
+ rm -f $(myencoding_objs)
+
+myencoding_clone:
+ $(call MODEST_UTILS_HDRS_CLONE,myencoding,$(myencoding_dirs))
diff --git a/source/myhtml/encoding_detect.c b/source/myencoding/detect.c
index 4dc0842..4cbba83 100644
--- a/source/myhtml/encoding_detect.c
+++ b/source/myencoding/detect.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,15 +18,15 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/encoding.h"
-#include "myhtml/encoding_detect_resource.h"
-#include "myhtml/utils/resources.h"
+#include "myencoding/encoding.h"
+#include "myencoding/detect_resource.h"
+#include "mycore/utils/resources.h"
-myhtml_encoding_trigram_result_t myhtml_encoding_detect_by_trigram(unsigned const char *u_text, size_t length,
- const myhtml_encoding_trigram_t *list, size_t list_length,
+myencoding_trigram_result_t myencoding_detect_by_trigram(unsigned const char *u_text, size_t length,
+ const myencoding_trigram_t *list, size_t list_length,
size_t max_sum_for_break)
{
- myhtml_encoding_trigram_result_t res = {0, 0};
+ myencoding_trigram_result_t res = {0, 0};
for (size_t i = 0; i < (length - 3); i++) {
if(u_text[i] > 127)
@@ -49,7 +49,7 @@ myhtml_encoding_trigram_result_t myhtml_encoding_detect_by_trigram(unsigned cons
return res;
}
-bool myhtml_encoding_detect_russian_has_end(myhtml_encoding_trigram_result_t *res, size_t min_count, size_t min_value)
+bool myencoding_detect_russian_has_end(myencoding_trigram_result_t *res, size_t min_count, size_t min_value)
{
if(res->value >= min_value || res->count >= min_count)
return true;
@@ -57,7 +57,7 @@ bool myhtml_encoding_detect_russian_has_end(myhtml_encoding_trigram_result_t *re
return false;
}
-bool myhtml_encoding_detect_unicode_has_end(myhtml_encoding_unicode_result_t *res, size_t max_bad_percent)
+bool myencoding_detect_unicode_has_end(myencoding_unicode_result_t *res, size_t max_bad_percent)
{
if(res->count_good == 0) {
if(res->count_bad)
@@ -75,10 +75,10 @@ bool myhtml_encoding_detect_unicode_has_end(myhtml_encoding_unicode_result_t *re
return false;
}
-myhtml_encoding_unicode_result_t myhtml_encoding_detect_utf_8(unsigned const char *u_text, size_t length)
+myencoding_unicode_result_t myencoding_detect_utf_8(unsigned const char *u_text, size_t length)
{
size_t i = 0;
- myhtml_encoding_unicode_result_t res = {0, 0, 0};
+ myencoding_unicode_result_t res = {0, 0, 0};
while(i < length)
{
@@ -133,10 +133,10 @@ myhtml_encoding_unicode_result_t myhtml_encoding_detect_utf_8(unsigned const cha
return res;
}
-myhtml_encoding_unicode_result_t myhtml_encoding_detect_utf_16(unsigned const char *u_text, size_t length)
+myencoding_unicode_result_t myencoding_detect_utf_16(unsigned const char *u_text, size_t length)
{
size_t i = 0;
- myhtml_encoding_unicode_result_t res = {0, 0, 0};
+ myencoding_unicode_result_t res = {0, 0, 0};
while(i < length)
{
@@ -161,7 +161,7 @@ myhtml_encoding_unicode_result_t myhtml_encoding_detect_utf_16(unsigned const ch
return res;
}
-bool myhtml_encoding_detect_bom(const char *text, size_t length, myhtml_encoding_t *encoding)
+bool myencoding_detect_bom(const char *text, size_t length, myencoding_t *encoding)
{
unsigned const char *u_text = (unsigned const char*)text;
@@ -170,19 +170,19 @@ bool myhtml_encoding_detect_bom(const char *text, size_t length, myhtml_encoding
u_text[1] == 0xBB &&
u_text[2] == 0xBF)
{
- *encoding = MyHTML_ENCODING_UTF_8;
+ *encoding = MyENCODING_UTF_8;
return true;
}
}
if(length > 1) {
if(u_text[0] == 0xFE && u_text[1] == 0xFF) {
- *encoding = MyHTML_ENCODING_UTF_16BE;
+ *encoding = MyENCODING_UTF_16BE;
return true;
}
if(u_text[0] == 0xFF && u_text[1] == 0xFE) {
- *encoding = MyHTML_ENCODING_UTF_16LE;
+ *encoding = MyENCODING_UTF_16LE;
return true;
}
}
@@ -194,7 +194,7 @@ bool myhtml_encoding_detect_bom(const char *text, size_t length, myhtml_encoding
// u_text[2] == 0xFE &&
// u_text[3] == 0xFF)
// {
-// *encoding = MyHTML_ENCODING_UTF_32BE;
+// *encoding = MyENCODING_UTF_32BE;
// return true;
// }
//
@@ -203,7 +203,7 @@ bool myhtml_encoding_detect_bom(const char *text, size_t length, myhtml_encoding
// u_text[2] == 0x00 &&
// u_text[3] == 0x00)
// {
-// *encoding = MyHTML_ENCODING_UTF_32LE;
+// *encoding = MyENCODING_UTF_32LE;
// return true;
// }
// }
@@ -211,11 +211,11 @@ bool myhtml_encoding_detect_bom(const char *text, size_t length, myhtml_encoding
return false;
}
-bool myhtml_encoding_detect_and_cut_bom(const char *text, size_t length, myhtml_encoding_t *encoding, const char **new_text, size_t *new_size)
+bool myencoding_detect_and_cut_bom(const char *text, size_t length, myencoding_t *encoding, const char **new_text, size_t *new_size)
{
- if(myhtml_encoding_detect_bom(text, length, encoding))
+ if(myencoding_detect_bom(text, length, encoding))
{
- if(*encoding == MyHTML_ENCODING_UTF_8) {
+ if(*encoding == MyENCODING_UTF_8) {
*new_text = &text[3];
*new_size = length - 3;
}
@@ -230,32 +230,32 @@ bool myhtml_encoding_detect_and_cut_bom(const char *text, size_t length, myhtml_
return false;
}
-bool myhtml_encoding_detect_unicode(const char *text, size_t length, myhtml_encoding_t *encoding)
+bool myencoding_detect_unicode(const char *text, size_t length, myencoding_t *encoding)
{
unsigned const char *u_text = (unsigned const char*)text;
- *encoding = MyHTML_ENCODING_DEFAULT;
+ *encoding = MyENCODING_DEFAULT;
- myhtml_encoding_unicode_result_t res = myhtml_encoding_detect_utf_16(u_text, length);
+ myencoding_unicode_result_t res = myencoding_detect_utf_16(u_text, length);
if(res.count_bad == 0 && res.count_good >= 3) {
- *encoding = MyHTML_ENCODING_UTF_16LE;
+ *encoding = MyENCODING_UTF_16LE;
return true;
}
else if(res.count_bad >= 3 && res.count_good == 0) {
- *encoding = MyHTML_ENCODING_UTF_16BE;
+ *encoding = MyENCODING_UTF_16BE;
return true;
}
- res = myhtml_encoding_detect_utf_8(u_text, length);
- if(myhtml_encoding_detect_unicode_has_end(&res, 10)) {
- *encoding = MyHTML_ENCODING_UTF_8;
+ res = myencoding_detect_utf_8(u_text, length);
+ if(myencoding_detect_unicode_has_end(&res, 10)) {
+ *encoding = MyENCODING_UTF_8;
return true;
}
return false;
}
-bool myhtml_encoding_detect_russian(const char *text, size_t length, myhtml_encoding_t *encoding)
+bool myencoding_detect_russian(const char *text, size_t length, myencoding_t *encoding)
{
unsigned const char *u_text = (unsigned const char*)text;
@@ -263,111 +263,111 @@ bool myhtml_encoding_detect_russian(const char *text, size_t length, myhtml_enco
size_t min_value = 100000;
size_t max_value = 0;
- *encoding = MyHTML_ENCODING_DEFAULT;
+ *encoding = MyENCODING_DEFAULT;
- myhtml_encoding_trigram_result_t
- res = myhtml_encoding_detect_by_trigram(u_text, length, myhtml_encoding_detect_trigrams_index_windows_1251, 1000, min_value);
- if(myhtml_encoding_detect_russian_has_end(&res, min_count, min_value)) {
- *encoding = MyHTML_ENCODING_WINDOWS_1251;
+ myencoding_trigram_result_t
+ res = myencoding_detect_by_trigram(u_text, length, myencoding_detect_trigrams_index_windows_1251, 1000, min_value);
+ if(myencoding_detect_russian_has_end(&res, min_count, min_value)) {
+ *encoding = MyENCODING_WINDOWS_1251;
return true;
}
max_value = res.value;
if(max_value) {
- *encoding = MyHTML_ENCODING_WINDOWS_1251;
+ *encoding = MyENCODING_WINDOWS_1251;
}
- res = myhtml_encoding_detect_by_trigram(u_text, length, myhtml_encoding_detect_trigrams_index_koi8_r, 1000, min_value);
- if(myhtml_encoding_detect_russian_has_end(&res, min_count, min_value)) {
- *encoding = MyHTML_ENCODING_KOI8_R;
+ res = myencoding_detect_by_trigram(u_text, length, myencoding_detect_trigrams_index_koi8_r, 1000, min_value);
+ if(myencoding_detect_russian_has_end(&res, min_count, min_value)) {
+ *encoding = MyENCODING_KOI8_R;
return true;
}
if(max_value < res.value) {
- *encoding = MyHTML_ENCODING_KOI8_R;
+ *encoding = MyENCODING_KOI8_R;
max_value = res.value;
}
- res = myhtml_encoding_detect_by_trigram(u_text, length, myhtml_encoding_detect_trigrams_index_iso_8859_5, 1000, min_value);
- if(myhtml_encoding_detect_russian_has_end(&res, min_count, min_value)) {
- *encoding = MyHTML_ENCODING_ISO_8859_5;
+ res = myencoding_detect_by_trigram(u_text, length, myencoding_detect_trigrams_index_iso_8859_5, 1000, min_value);
+ if(myencoding_detect_russian_has_end(&res, min_count, min_value)) {
+ *encoding = MyENCODING_ISO_8859_5;
return true;
}
if(max_value < res.value) {
- *encoding = MyHTML_ENCODING_ISO_8859_5;
+ *encoding = MyENCODING_ISO_8859_5;
max_value = res.value;
}
- res = myhtml_encoding_detect_by_trigram(u_text, length, myhtml_encoding_detect_trigrams_index_x_mac_cyrillic, 1000, min_value);
- if(myhtml_encoding_detect_russian_has_end(&res, min_count, min_value)) {
- *encoding = MyHTML_ENCODING_X_MAC_CYRILLIC;
+ res = myencoding_detect_by_trigram(u_text, length, myencoding_detect_trigrams_index_x_mac_cyrillic, 1000, min_value);
+ if(myencoding_detect_russian_has_end(&res, min_count, min_value)) {
+ *encoding = MyENCODING_X_MAC_CYRILLIC;
return true;
}
if(max_value < res.value) {
- *encoding = MyHTML_ENCODING_X_MAC_CYRILLIC;
+ *encoding = MyENCODING_X_MAC_CYRILLIC;
max_value = res.value;
}
- res = myhtml_encoding_detect_by_trigram(u_text, length, myhtml_encoding_detect_trigrams_index_ibm866, 1000, min_value);
- if(myhtml_encoding_detect_russian_has_end(&res, min_count, min_value)) {
- *encoding = MyHTML_ENCODING_IBM866;
+ res = myencoding_detect_by_trigram(u_text, length, myencoding_detect_trigrams_index_ibm866, 1000, min_value);
+ if(myencoding_detect_russian_has_end(&res, min_count, min_value)) {
+ *encoding = MyENCODING_IBM866;
return true;
}
if(max_value < res.value) {
- *encoding = MyHTML_ENCODING_IBM866;
+ *encoding = MyENCODING_IBM866;
}
return false;
}
-bool myhtml_encoding_detect(const char *text, size_t length, myhtml_encoding_t *encoding)
+bool myencoding_detect(const char *text, size_t length, myencoding_t *encoding)
{
- *encoding = MyHTML_ENCODING_DEFAULT;
+ *encoding = MyENCODING_DEFAULT;
- if(myhtml_encoding_detect_unicode(text, length, encoding))
+ if(myencoding_detect_unicode(text, length, encoding))
return true;
- if(myhtml_encoding_detect_russian(text, length, encoding))
+ if(myencoding_detect_russian(text, length, encoding))
return true;
return false;
}
-const myhtml_encoding_detect_name_entry_t * myhtml_encoding_name_entry_by_name(const char* name, size_t length)
+const myencoding_detect_name_entry_t * myencoding_name_entry_by_name(const char* name, size_t length)
{
- size_t idx = ((myhtml_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
- myhtml_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
+ size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
+ mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
length)
- % MyHTML_ENCODING_DETECT_NAME_STATIC_SIZE) + 1;
+ % MyENCODING_DETECT_NAME_STATIC_SIZE) + 1;
- while (myhtml_encoding_detect_name_entry_static_list_index[idx].label)
+ while (myencoding_detect_name_entry_static_list_index[idx].label)
{
- if(myhtml_encoding_detect_name_entry_static_list_index[idx].label_length == length) {
- if(myhtml_strncasecmp(myhtml_encoding_detect_name_entry_static_list_index[idx].label, name, length) == 0)
- return &myhtml_encoding_detect_name_entry_static_list_index[idx];
+ if(myencoding_detect_name_entry_static_list_index[idx].label_length == length) {
+ if(mycore_strncasecmp(myencoding_detect_name_entry_static_list_index[idx].label, name, length) == 0)
+ return &myencoding_detect_name_entry_static_list_index[idx];
- if(myhtml_encoding_detect_name_entry_static_list_index[idx].next)
- idx = myhtml_encoding_detect_name_entry_static_list_index[idx].next;
+ if(myencoding_detect_name_entry_static_list_index[idx].next)
+ idx = myencoding_detect_name_entry_static_list_index[idx].next;
else
return NULL;
}
- else if(myhtml_encoding_detect_name_entry_static_list_index[idx].label_length > length) {
+ else if(myencoding_detect_name_entry_static_list_index[idx].label_length > length) {
return NULL;
}
else {
- idx = myhtml_encoding_detect_name_entry_static_list_index[idx].next;
+ idx = myencoding_detect_name_entry_static_list_index[idx].next;
}
}
return NULL;
}
-bool myhtml_encoding_by_name(const char *name, size_t length, myhtml_encoding_t *encoding)
+bool myencoding_by_name(const char *name, size_t length, myencoding_t *encoding)
{
- const myhtml_encoding_detect_name_entry_t *entry = myhtml_encoding_name_entry_by_name(name, length);
+ const myencoding_detect_name_entry_t *entry = myencoding_name_entry_by_name(name, length);
if(entry) {
if(encoding)
@@ -379,9 +379,9 @@ bool myhtml_encoding_by_name(const char *name, size_t length, myhtml_encoding_t
return false;
}
-const char * myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *length)
+const char * myencoding_name_by_id(myencoding_t encoding, size_t *length)
{
- if(encoding >= MyHTML_ENCODING_LAST_ENTRY) {
+ if(encoding >= MyENCODING_LAST_ENTRY) {
if(length) {
*length = 0;
}
@@ -389,7 +389,7 @@ const char * myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *leng
return NULL;
}
- const myhtml_encoding_entry_name_index_t *entry = &myhtml_encoding_entry_name_index_static_list_index[encoding];
+ const myencoding_entry_name_index_t *entry = &myencoding_entry_name_index_static_list_index[encoding];
if(length) {
*length = entry->length;
@@ -406,10 +406,9 @@ const char * myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *leng
the user agent either runs out of bytes (meaning the position pointer created in the first step below goes beyond the end of the byte stream obtained so far)
or reaches its end condition, then abort the prescan a byte stream to determine its encoding algorithm unsuccessfully.
*/
-
-bool myhtml_encoding_algorithm_extracting_character_encoding_from_meta_element(const char *data, size_t data_size, myhtml_encoding_t *encoding)
+bool myencoding_extracting_character_encoding_from_charset(const char *data, size_t data_size, myencoding_t *encoding)
{
- *encoding = MyHTML_ENCODING_NOT_DETERMINED;
+ *encoding = MyENCODING_NOT_DETERMINED;
/* 1 */
size_t length = 0;
@@ -420,7 +419,7 @@ bool myhtml_encoding_algorithm_extracting_character_encoding_from_meta_element(c
/* 2 */
while((length + charset_length) < data_size) {
- if(myhtml_ustrcasecmp_without_checks_by_secondary((const unsigned char*)"charset", &udata[length]))
+ if(mycore_ustrcasecmp_without_checks_by_secondary((const unsigned char*)"charset", &udata[length]))
{
length += charset_length;
@@ -473,7 +472,7 @@ bool myhtml_encoding_algorithm_extracting_character_encoding_from_meta_element(c
while(length < data_size) {
if(udata[length] == 0x22)
- return myhtml_encoding_by_name(&data[begin], (length - begin), encoding);
+ return myencoding_by_name(&data[begin], (length - begin), encoding);
length++;
}
@@ -489,7 +488,7 @@ bool myhtml_encoding_algorithm_extracting_character_encoding_from_meta_element(c
while(length < data_size) {
if(udata[length] == 0x27)
- return myhtml_encoding_by_name(&data[begin], (length - begin), encoding);
+ return myencoding_by_name(&data[begin], (length - begin), encoding);
length++;
}
@@ -507,13 +506,13 @@ bool myhtml_encoding_algorithm_extracting_character_encoding_from_meta_element(c
while(length < data_size) {
/* SEMICOLON character (;) */
if(udata[length] == 0x3B) {
- return myhtml_encoding_by_name(&data[begin], (length - begin), encoding);
+ return myencoding_by_name(&data[begin], (length - begin), encoding);
}
length++;
}
- return myhtml_encoding_by_name(&data[begin], (length - begin), encoding);
+ return myencoding_by_name(&data[begin], (length - begin), encoding);
}
length++;
@@ -522,7 +521,7 @@ bool myhtml_encoding_algorithm_extracting_character_encoding_from_meta_element(c
return false;
}
-bool myhtml_encoding_prescan_stream_to_determine_encoding_get_attr_spaces(const unsigned char *udata, size_t *data_length, size_t data_size, myhtml_encoding_detect_attr_t *attr)
+bool myencoding_prescan_stream_to_determine_encoding_get_attr_spaces(const unsigned char *udata, size_t *data_length, size_t data_size, myencoding_detect_attr_t *attr)
{
size_t length = *data_length;
@@ -556,7 +555,7 @@ bool myhtml_encoding_prescan_stream_to_determine_encoding_get_attr_spaces(const
return true;
}
-size_t myhtml_encoding_prescan_stream_to_determine_encoding_get_attr_value(const unsigned char *udata, size_t length, size_t data_size, myhtml_encoding_detect_attr_t *attr, bool *it_last)
+size_t myencoding_prescan_stream_to_determine_encoding_get_attr_value(const unsigned char *udata, size_t length, size_t data_size, myencoding_detect_attr_t *attr, bool *it_last)
{
/* 9 */
while(length < data_size) {
@@ -633,9 +632,9 @@ size_t myhtml_encoding_prescan_stream_to_determine_encoding_get_attr_value(const
return length;
}
-size_t myhtml_encoding_prescan_stream_to_determine_encoding_get_attr(const unsigned char *udata, size_t length, size_t data_size, myhtml_encoding_detect_attr_t *attr, bool *it_last)
+size_t myencoding_prescan_stream_to_determine_encoding_get_attr(const unsigned char *udata, size_t length, size_t data_size, myencoding_detect_attr_t *attr, bool *it_last)
{
- memset(attr, 0, sizeof(myhtml_encoding_detect_attr_t));
+ memset(attr, 0, sizeof(myencoding_detect_attr_t));
/*
If the byte at position is one of 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR),
@@ -673,7 +672,7 @@ size_t myhtml_encoding_prescan_stream_to_determine_encoding_get_attr(const unsig
attr->key_length = length - attr->key_begin;
length++;
- return myhtml_encoding_prescan_stream_to_determine_encoding_get_attr_value(udata, length, data_size, attr, it_last);
+ return myencoding_prescan_stream_to_determine_encoding_get_attr_value(udata, length, data_size, attr, it_last);
}
/* fall through */
@@ -685,12 +684,12 @@ size_t myhtml_encoding_prescan_stream_to_determine_encoding_get_attr(const unsig
case 0x20: /* (ASCII space) */
length++;
- if(myhtml_encoding_prescan_stream_to_determine_encoding_get_attr_spaces(udata, &length, data_size, attr) == false) {
+ if(myencoding_prescan_stream_to_determine_encoding_get_attr_spaces(udata, &length, data_size, attr) == false) {
*it_last = true;
return length;
}
- return myhtml_encoding_prescan_stream_to_determine_encoding_get_attr_value(udata, length, data_size, attr, it_last);
+ return myencoding_prescan_stream_to_determine_encoding_get_attr_value(udata, length, data_size, attr, it_last);
case 0x2F: /* (ASCII /) */
case 0x3E: /* (ASCII >) */
@@ -706,17 +705,17 @@ size_t myhtml_encoding_prescan_stream_to_determine_encoding_get_attr(const unsig
length++;
}
- if(myhtml_encoding_prescan_stream_to_determine_encoding_get_attr_spaces(udata, &length, data_size, attr) == false) {
+ if(myencoding_prescan_stream_to_determine_encoding_get_attr_spaces(udata, &length, data_size, attr) == false) {
*it_last = true;
return length;
}
- return myhtml_encoding_prescan_stream_to_determine_encoding_get_attr_value(udata, length, data_size, attr, it_last);
+ return myencoding_prescan_stream_to_determine_encoding_get_attr_value(udata, length, data_size, attr, it_last);
}
-bool myhtml_encoding_prescan_stream_to_determine_encoding_check_meta(const unsigned char *udata, size_t *length, size_t data_size, myhtml_encoding_t *encoding)
+bool myencoding_prescan_stream_to_determine_encoding_check_meta(const unsigned char *udata, size_t *length, size_t data_size, myencoding_t *encoding)
{
- myhtml_encoding_detect_attr_t attr;
+ myencoding_detect_attr_t attr;
bool got_pragma = false;
bool it_last = false;
@@ -732,40 +731,40 @@ bool myhtml_encoding_prescan_stream_to_determine_encoding_check_meta(const unsig
size_t is_exists = 0;
while(*length < data_size) {
- *length = myhtml_encoding_prescan_stream_to_determine_encoding_get_attr(udata, *length, data_size, &attr, &it_last);
+ *length = myencoding_prescan_stream_to_determine_encoding_get_attr(udata, *length, data_size, &attr, &it_last);
/* 9 */
if(attr.key_length == strlen("http-equiv") &&
- myhtml_ustrcasecmp_without_checks_by_secondary((const unsigned char*)"http-equiv", &udata[ attr.key_begin ]))
+ mycore_ustrcasecmp_without_checks_by_secondary((const unsigned char*)"http-equiv", &udata[ attr.key_begin ]))
{
if((is_exists & 1) == 0) {
is_exists |= 1;
if(attr.value_length == strlen("content-type") &&
- myhtml_ustrcasecmp_without_checks_by_secondary((const unsigned char*)"content-type", &udata[ attr.value_begin ]))
+ mycore_ustrcasecmp_without_checks_by_secondary((const unsigned char*)"content-type", &udata[ attr.value_begin ]))
{
got_pragma = true;
}
}
}
else if(attr.key_length == strlen("content") &&
- myhtml_ustrcasecmp_without_checks_by_secondary((const unsigned char*)"content", &udata[ attr.key_begin ]))
+ mycore_ustrcasecmp_without_checks_by_secondary((const unsigned char*)"content", &udata[ attr.key_begin ]))
{
if((is_exists & 2) == 0) {
is_exists |= 2;
- if(myhtml_encoding_algorithm_extracting_character_encoding_from_meta_element((const char*)(&udata[ attr.value_begin ]), attr.value_length, encoding)) {
+ if(myencoding_extracting_character_encoding_from_charset((const char*)(&udata[ attr.value_begin ]), attr.value_length, encoding)) {
need_pragma = 2;
}
}
}
else if(attr.key_length == strlen("charset") &&
- myhtml_ustrcasecmp_without_checks_by_secondary((const unsigned char*)"charset", &udata[ attr.key_begin ]))
+ mycore_ustrcasecmp_without_checks_by_secondary((const unsigned char*)"charset", &udata[ attr.key_begin ]))
{
if((is_exists & 4) == 0) {
is_exists |= 4;
- myhtml_encoding_by_name((const char*)(&udata[ attr.value_begin ]), attr.value_length, encoding);
+ myencoding_by_name((const char*)(&udata[ attr.value_begin ]), attr.value_length, encoding);
need_pragma = 1;
}
}
@@ -776,25 +775,25 @@ bool myhtml_encoding_prescan_stream_to_determine_encoding_check_meta(const unsig
/* 11, 12, 13 */
if(need_pragma == 0 || (need_pragma == 2 && got_pragma == false)) {
- *encoding = MyHTML_ENCODING_NOT_DETERMINED;
+ *encoding = MyENCODING_NOT_DETERMINED;
return false;
}
/* 14 */
- if(*encoding == MyHTML_ENCODING_UTF_16BE || *encoding == MyHTML_ENCODING_UTF_16LE) {
- *encoding = MyHTML_ENCODING_UTF_8;
+ if(*encoding == MyENCODING_UTF_16BE || *encoding == MyENCODING_UTF_16LE) {
+ *encoding = MyENCODING_UTF_8;
}
/* 15 */
- if(*encoding == MyHTML_ENCODING_X_USER_DEFINED) {
- *encoding = MyHTML_ENCODING_WINDOWS_1252;
+ if(*encoding == MyENCODING_X_USER_DEFINED) {
+ *encoding = MyENCODING_WINDOWS_1252;
}
/* 16 */
return true;
}
-size_t myhtml_encoding_prescan_stream_to_determine_encoding_skip_name(const unsigned char *udata, size_t length, size_t data_size)
+size_t myencoding_prescan_stream_to_determine_encoding_skip_name(const unsigned char *udata, size_t length, size_t data_size)
{
while(length < data_size) {
if(udata[length] != 0x09 && udata[length] != 0x0A && udata[length] != 0x0C &&
@@ -813,11 +812,11 @@ size_t myhtml_encoding_prescan_stream_to_determine_encoding_skip_name(const unsi
return (length + 1);
}
- myhtml_encoding_detect_attr_t attr;
+ myencoding_detect_attr_t attr;
bool it_last = false;
while(length < data_size) {
- length = myhtml_encoding_prescan_stream_to_determine_encoding_get_attr(udata, length, data_size, &attr, &it_last);
+ length = myencoding_prescan_stream_to_determine_encoding_get_attr(udata, length, data_size, &attr, &it_last);
if(it_last) {
return length;
@@ -827,7 +826,7 @@ size_t myhtml_encoding_prescan_stream_to_determine_encoding_skip_name(const unsi
return length;
}
-size_t myhtml_encoding_prescan_stream_to_determine_encoding_skip_other(const unsigned char *udata, size_t length, size_t data_size)
+size_t myencoding_prescan_stream_to_determine_encoding_skip_other(const unsigned char *udata, size_t length, size_t data_size)
{
if(udata[length] == 0x2F) { /* / */
length++;
@@ -835,8 +834,8 @@ size_t myhtml_encoding_prescan_stream_to_determine_encoding_skip_other(const uns
if(length >= data_size)
return length;
- if(myhtml_tokenizer_chars_map[ udata[length] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z) {
- return myhtml_encoding_prescan_stream_to_determine_encoding_skip_name(udata, length, data_size);
+ if(mycore_tokenizer_chars_map[ udata[length] ] == MyCORE_STRING_MAP_CHAR_A_Z_a_z) {
+ return myencoding_prescan_stream_to_determine_encoding_skip_name(udata, length, data_size);
}
while(length < data_size) {
@@ -890,13 +889,13 @@ size_t myhtml_encoding_prescan_stream_to_determine_encoding_skip_other(const uns
}
- return myhtml_encoding_prescan_stream_to_determine_encoding_skip_name(udata, length, data_size);
+ return myencoding_prescan_stream_to_determine_encoding_skip_name(udata, length, data_size);
}
-myhtml_encoding_t myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size)
+myencoding_t myencoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size)
{
const unsigned char* udata = (const unsigned char*)data;
- myhtml_encoding_t encoding = MyHTML_ENCODING_NOT_DETERMINED;
+ myencoding_t encoding = MyENCODING_NOT_DETERMINED;
size_t i = 0;
while(i < data_size) {
@@ -917,7 +916,7 @@ myhtml_encoding_t myhtml_encoding_prescan_stream_to_determine_encoding(const cha
*/
case 0x4D:
case 0x6D:
- if(myhtml_ustrcasecmp_without_checks_by_secondary((const unsigned char*)"meta", &udata[i])) {
+ if(mycore_ustrcasecmp_without_checks_by_secondary((const unsigned char*)"meta", &udata[i])) {
i += 4;
if(udata[i] == 0x09 || udata[i] == 0x0A || udata[i] == 0x0C ||
@@ -925,7 +924,7 @@ myhtml_encoding_t myhtml_encoding_prescan_stream_to_determine_encoding(const cha
{
i++;
- if(myhtml_encoding_prescan_stream_to_determine_encoding_check_meta(udata, &i, data_size, &encoding))
+ if(myencoding_prescan_stream_to_determine_encoding_check_meta(udata, &i, data_size, &encoding))
return encoding;
}
}
@@ -933,7 +932,7 @@ myhtml_encoding_t myhtml_encoding_prescan_stream_to_determine_encoding(const cha
break;
default:
- i = myhtml_encoding_prescan_stream_to_determine_encoding_skip_other(udata, i, data_size);
+ i = myencoding_prescan_stream_to_determine_encoding_skip_other(udata, i, data_size);
break;
}
}
diff --git a/source/myhtml/encoding_detect_resource.h b/source/myencoding/detect_resource.h
index 361f6ae..2e33713 100644
--- a/source/myhtml/encoding_detect_resource.h
+++ b/source/myencoding/detect_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,19 +18,19 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#ifndef MyHTML_ENCODING_DETECT_RESOURCE_H
-#define MyHTML_ENCODING_DETECT_RESOURCE_H
+#ifndef MyENCODING_DETECT_RESOURCE_H
+#define MyENCODING_DETECT_RESOURCE_H
#pragma once
#ifdef __cplusplus
-//extern "C" {
+extern "C" {
#endif
-#define MyHTML_ENCODING_DETECT_NAME_STATIC_SIZE 419
+#define MyENCODING_DETECT_NAME_STATIC_SIZE 419
-#include "myhtml/encoding.h"
+#include "myencoding/encoding.h"
-static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_entry_static_list_index[] =
+static const myencoding_detect_name_entry_t myencoding_detect_name_entry_static_list_index[] =
{
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -39,21 +39,21 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1257", 12, "x-cp1257", 8, MyHTML_ENCODING_WINDOWS_1257, 0, 7},
+ {"windows-1257", 12, "x-cp1257", 8, MyENCODING_WINDOWS_1257, 0, 7},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-874", 11, "tis-620", 7, MyHTML_ENCODING_WINDOWS_874, 0, 10},
- {"iso-8859-3", 10, "iso8859-3", 9, MyHTML_ENCODING_ISO_8859_3, 420, 11},
+ {"windows-874", 11, "tis-620", 7, MyENCODING_WINDOWS_874, 0, 10},
+ {"iso-8859-3", 10, "iso8859-3", 9, MyENCODING_ISO_8859_3, 420, 11},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"shift_jis", 9, "ms932", 5, MyHTML_ENCODING_SHIFT_JIS, 0, 16},
- {"gbk", 3, "gb_2312", 7, MyHTML_ENCODING_GBK, 421, 17},
+ {"shift_jis", 9, "ms932", 5, MyENCODING_SHIFT_JIS, 0, 16},
+ {"gbk", 3, "gb_2312", 7, MyENCODING_GBK, 421, 17},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-7", 10, "iso8859-7", 9, MyHTML_ENCODING_ISO_8859_7, 422, 20},
- {"windows-1250", 12, "cp1250", 6, MyHTML_ENCODING_WINDOWS_1250, 423, 21},
+ {"iso-8859-7", 10, "iso8859-7", 9, MyENCODING_ISO_8859_7, 422, 20},
+ {"windows-1250", 12, "cp1250", 6, MyENCODING_WINDOWS_1250, 423, 21},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -62,9 +62,9 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"shift_jis", 9, "shift-jis", 9, MyHTML_ENCODING_SHIFT_JIS, 424, 30},
- {"ibm866", 6, "csibm866", 8, MyHTML_ENCODING_IBM866, 425, 31},
- {"euc-kr", 6, "windows-949", 11, MyHTML_ENCODING_EUC_KR, 0, 32},
+ {"shift_jis", 9, "shift-jis", 9, MyENCODING_SHIFT_JIS, 424, 30},
+ {"ibm866", 6, "csibm866", 8, MyENCODING_IBM866, 425, 31},
+ {"euc-kr", 6, "windows-949", 11, MyENCODING_EUC_KR, 0, 32},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -72,33 +72,33 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-2022-jp", 11, "csiso2022jp", 11, MyHTML_ENCODING_ISO_2022_JP, 0, 40},
+ {"iso-2022-jp", 11, "csiso2022jp", 11, MyENCODING_ISO_2022_JP, 0, 40},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-15", 11, "iso-8859-15", 11, MyHTML_ENCODING_ISO_8859_15, 426, 42},
+ {"iso-8859-15", 11, "iso-8859-15", 11, MyENCODING_ISO_8859_15, 426, 42},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-kr", 6, "ksc_5601", 8, MyHTML_ENCODING_EUC_KR, 0, 45},
+ {"euc-kr", 6, "ksc_5601", 8, MyENCODING_EUC_KR, 0, 45},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"gbk", 3, "csiso58gb231280", 15, MyHTML_ENCODING_GBK, 0, 51},
+ {"gbk", 3, "csiso58gb231280", 15, MyENCODING_GBK, 0, 51},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-5", 10, "cyrillic", 8, MyHTML_ENCODING_ISO_8859_5, 0, 56},
+ {"iso-8859-5", 10, "cyrillic", 8, MyENCODING_ISO_8859_5, 0, 56},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1255", 12, "cp1255", 6, MyHTML_ENCODING_WINDOWS_1255, 427, 58},
+ {"windows-1255", 12, "cp1255", 6, MyENCODING_WINDOWS_1255, 427, 58},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1254", 12, "x-cp1254", 8, MyHTML_ENCODING_WINDOWS_1254, 0, 60},
+ {"windows-1254", 12, "x-cp1254", 8, MyENCODING_WINDOWS_1254, 0, 60},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-15", 11, "csisolatin9", 11, MyHTML_ENCODING_ISO_8859_15, 0, 62},
- {"koi8-u", 6, "koi8-ru", 7, MyHTML_ENCODING_KOI8_U, 0, 63},
- {"iso-8859-4", 10, "csisolatin4", 11, MyHTML_ENCODING_ISO_8859_4, 0, 64},
+ {"iso-8859-15", 11, "csisolatin9", 11, MyENCODING_ISO_8859_15, 0, 62},
+ {"koi8-u", 6, "koi8-ru", 7, MyENCODING_KOI8_U, 0, 63},
+ {"iso-8859-4", 10, "csisolatin4", 11, MyENCODING_ISO_8859_4, 0, 64},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"shift_jis", 9, "windows-31j", 11, MyHTML_ENCODING_SHIFT_JIS, 0, 66},
+ {"shift_jis", 9, "windows-31j", 11, MyENCODING_SHIFT_JIS, 0, 66},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -111,14 +111,14 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"utf-8", 5, "utf-8", 5, MyHTML_ENCODING_UTF_8, 0, 79},
+ {"utf-8", 5, "utf-8", 5, MyENCODING_UTF_8, 0, 79},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"ibm866", 6, "ibm866", 6, MyHTML_ENCODING_IBM866, 0, 82},
+ {"ibm866", 6, "ibm866", 6, MyENCODING_IBM866, 0, 82},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"koi8-r", 6, "koi8", 4, MyHTML_ENCODING_KOI8_R, 0, 86},
+ {"koi8-r", 6, "koi8", 4, MyENCODING_KOI8_R, 0, 86},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -126,62 +126,62 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"gbk", 3, "x-gbk", 5, MyHTML_ENCODING_GBK, 428, 94},
- {"iso-8859-7", 10, "csisolatingreek", 15, MyHTML_ENCODING_ISO_8859_7, 0, 95},
+ {"gbk", 3, "x-gbk", 5, MyENCODING_GBK, 428, 94},
+ {"iso-8859-7", 10, "csisolatingreek", 15, MyENCODING_ISO_8859_7, 0, 95},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "iso88591", 8, MyHTML_ENCODING_WINDOWS_1252, 0, 99},
+ {"windows-1252", 12, "iso88591", 8, MyENCODING_WINDOWS_1252, 0, 99},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "iso88592", 8, MyHTML_ENCODING_ISO_8859_2, 0, 101},
+ {"iso-8859-2", 10, "iso88592", 8, MyENCODING_ISO_8859_2, 0, 101},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-3", 10, "iso88593", 8, MyHTML_ENCODING_ISO_8859_3, 0, 103},
+ {"iso-8859-3", 10, "iso88593", 8, MyENCODING_ISO_8859_3, 0, 103},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-4", 10, "iso88594", 8, MyHTML_ENCODING_ISO_8859_4, 0, 105},
+ {"iso-8859-4", 10, "iso88594", 8, MyENCODING_ISO_8859_4, 0, 105},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"shift_jis", 9, "sjis", 4, MyHTML_ENCODING_SHIFT_JIS, 430, 107},
+ {"shift_jis", 9, "sjis", 4, MyENCODING_SHIFT_JIS, 430, 107},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-6", 10, "iso88596", 8, MyHTML_ENCODING_ISO_8859_6, 431, 109},
- {"windows-1252", 12, "l1", 2, MyHTML_ENCODING_WINDOWS_1252, 432, 110},
- {"macintosh", 9, "mac", 3, MyHTML_ENCODING_MACINTOSH, 433, 111},
+ {"iso-8859-6", 10, "iso88596", 8, MyENCODING_ISO_8859_6, 431, 109},
+ {"windows-1252", 12, "l1", 2, MyENCODING_WINDOWS_1252, 432, 110},
+ {"macintosh", 9, "mac", 3, MyENCODING_MACINTOSH, 433, 111},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-8", 10, "iso88598", 8, MyHTML_ENCODING_ISO_8859_8, 435, 113},
- {"koi8-u", 6, "koi8-u", 6, MyHTML_ENCODING_KOI8_U, 0, 114},
- {"windows-1254", 12, "iso88599", 8, MyHTML_ENCODING_WINDOWS_1254, 0, 115},
+ {"iso-8859-8", 10, "iso88598", 8, MyENCODING_ISO_8859_8, 435, 113},
+ {"koi8-u", 6, "koi8-u", 6, MyENCODING_KOI8_U, 0, 114},
+ {"windows-1254", 12, "iso88599", 8, MyENCODING_WINDOWS_1254, 0, 115},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-6", 10, "ecma-114", 8, MyHTML_ENCODING_ISO_8859_6, 0, 117},
- {"iso-8859-4", 10, "iso8859-4", 9, MyHTML_ENCODING_ISO_8859_4, 436, 118},
+ {"iso-8859-6", 10, "ecma-114", 8, MyENCODING_ISO_8859_6, 0, 117},
+ {"iso-8859-4", 10, "iso8859-4", 9, MyENCODING_ISO_8859_4, 436, 118},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-4", 10, "iso-ir-110", 10, MyHTML_ENCODING_ISO_8859_4, 437, 121},
+ {"iso-8859-4", 10, "iso-ir-110", 10, MyENCODING_ISO_8859_4, 437, 121},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-3", 10, "l3", 2, MyHTML_ENCODING_ISO_8859_3, 0, 123},
+ {"iso-8859-3", 10, "l3", 2, MyENCODING_ISO_8859_3, 0, 123},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "iso-8859-2", 10, MyHTML_ENCODING_ISO_8859_2, 439, 126},
- {"windows-1253", 12, "cp1253", 6, MyHTML_ENCODING_WINDOWS_1253, 440, 127},
+ {"iso-8859-2", 10, "iso-8859-2", 10, MyENCODING_ISO_8859_2, 439, 126},
+ {"windows-1253", 12, "cp1253", 6, MyENCODING_WINDOWS_1253, 440, 127},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1258", 12, "x-cp1258", 8, MyHTML_ENCODING_WINDOWS_1258, 0, 129},
+ {"windows-1258", 12, "x-cp1258", 8, MyENCODING_WINDOWS_1258, 0, 129},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-4", 10, "iso-8859-4", 10, MyHTML_ENCODING_ISO_8859_4, 443, 131},
+ {"iso-8859-4", 10, "iso-8859-4", 10, MyENCODING_ISO_8859_4, 443, 131},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-10", 11, "iso-8859-10", 11, MyHTML_ENCODING_ISO_8859_10, 0, 133},
+ {"iso-8859-10", 11, "iso-8859-10", 11, MyENCODING_ISO_8859_10, 0, 133},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1254", 12, "l5", 2, MyHTML_ENCODING_WINDOWS_1254, 446, 136},
+ {"windows-1254", 12, "l5", 2, MyENCODING_WINDOWS_1254, 446, 136},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "latin2", 6, MyHTML_ENCODING_ISO_8859_2, 0, 138},
+ {"iso-8859-2", 10, "latin2", 6, MyENCODING_ISO_8859_2, 0, 138},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-8", 10, "iso-8859-8", 10, MyHTML_ENCODING_ISO_8859_8, 449, 141},
+ {"iso-8859-8", 10, "iso-8859-8", 10, MyENCODING_ISO_8859_8, 449, 141},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "cp819", 5, MyHTML_ENCODING_WINDOWS_1252, 0, 143},
- {"iso-8859-14", 11, "iso-8859-14", 11, MyHTML_ENCODING_ISO_8859_14, 0, 144},
+ {"windows-1252", 12, "cp819", 5, MyENCODING_WINDOWS_1252, 0, 143},
+ {"iso-8859-14", 11, "iso-8859-14", 11, MyENCODING_ISO_8859_14, 0, 144},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-10", 11, "csisolatin6", 11, MyHTML_ENCODING_ISO_8859_10, 0, 147},
+ {"iso-8859-10", 11, "csisolatin6", 11, MyENCODING_ISO_8859_10, 0, 147},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "csisolatin1", 11, MyHTML_ENCODING_WINDOWS_1252, 0, 149},
+ {"windows-1252", 12, "csisolatin1", 11, MyENCODING_WINDOWS_1252, 0, 149},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -194,44 +194,44 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-15", 11, "l9", 2, MyHTML_ENCODING_ISO_8859_15, 0, 162},
+ {"iso-8859-15", 11, "l9", 2, MyENCODING_ISO_8859_15, 0, 162},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1258", 12, "cp1258", 6, MyHTML_ENCODING_WINDOWS_1258, 0, 164},
+ {"windows-1258", 12, "cp1258", 6, MyENCODING_WINDOWS_1258, 0, 164},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "windows-1252", 12, MyHTML_ENCODING_WINDOWS_1252, 0, 171},
+ {"windows-1252", 12, "windows-1252", 12, MyENCODING_WINDOWS_1252, 0, 171},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-7", 10, "sun_eu_greek", 12, MyHTML_ENCODING_ISO_8859_7, 0, 173},
+ {"iso-8859-7", 10, "sun_eu_greek", 12, MyENCODING_ISO_8859_7, 0, 173},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-jp", 6, "cseucpkdfmtjapanese", 19, MyHTML_ENCODING_EUC_JP, 0, 175},
+ {"euc-jp", 6, "cseucpkdfmtjapanese", 19, MyENCODING_EUC_JP, 0, 175},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-4", 10, "latin4", 6, MyHTML_ENCODING_ISO_8859_4, 0, 177},
+ {"iso-8859-4", 10, "latin4", 6, MyENCODING_ISO_8859_4, 0, 177},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1255", 12, "x-cp1255", 8, MyHTML_ENCODING_WINDOWS_1255, 452, 182},
+ {"windows-1255", 12, "x-cp1255", 8, MyENCODING_WINDOWS_1255, 452, 182},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"koi8-r", 6, "koi", 3, MyHTML_ENCODING_KOI8_R, 0, 186},
+ {"koi8-r", 6, "koi", 3, MyENCODING_KOI8_R, 0, 186},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1257", 12, "windows-1257", 12, MyHTML_ENCODING_WINDOWS_1257, 0, 188},
+ {"windows-1257", 12, "windows-1257", 12, MyENCODING_WINDOWS_1257, 0, 188},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-874", 11, "windows-874", 11, MyHTML_ENCODING_WINDOWS_874, 0, 191},
+ {"windows-874", 11, "windows-874", 11, MyENCODING_WINDOWS_874, 0, 191},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1251", 12, "cp1251", 6, MyHTML_ENCODING_WINDOWS_1251, 0, 196},
+ {"windows-1251", 12, "cp1251", 6, MyENCODING_WINDOWS_1251, 0, 196},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"utf-16le", 8, "utf-16", 6, MyHTML_ENCODING_UTF_16LE, 0, 199},
+ {"utf-16le", 8, "utf-16", 6, MyENCODING_UTF_16LE, 0, 199},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -239,35 +239,35 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-8", 10, "visual", 6, MyHTML_ENCODING_ISO_8859_8, 0, 207},
- {"macintosh", 9, "macintosh", 9, MyHTML_ENCODING_MACINTOSH, 0, 208},
+ {"iso-8859-8", 10, "visual", 6, MyENCODING_ISO_8859_8, 0, 207},
+ {"macintosh", 9, "macintosh", 9, MyENCODING_MACINTOSH, 0, 208},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "ansi_x3.4-1968", 14, MyHTML_ENCODING_WINDOWS_1252, 0, 210},
- {"iso-8859-3", 10, "iso_8859-3:1988", 15, MyHTML_ENCODING_ISO_8859_3, 453, 211},
- {"iso-8859-6", 10, "csiso88596e", 11, MyHTML_ENCODING_ISO_8859_6, 456, 212},
+ {"windows-1252", 12, "ansi_x3.4-1968", 14, MyENCODING_WINDOWS_1252, 0, 210},
+ {"iso-8859-3", 10, "iso_8859-3:1988", 15, MyENCODING_ISO_8859_3, 453, 211},
+ {"iso-8859-6", 10, "csiso88596e", 11, MyENCODING_ISO_8859_6, 456, 212},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"gbk", 3, "csgb2312", 8, MyHTML_ENCODING_GBK, 0, 215},
- {"iso-8859-6", 10, "arabic", 6, MyHTML_ENCODING_ISO_8859_6, 457, 216},
- {"iso-8859-7", 10, "greek", 5, MyHTML_ENCODING_ISO_8859_7, 0, 217},
+ {"gbk", 3, "csgb2312", 8, MyENCODING_GBK, 0, 215},
+ {"iso-8859-6", 10, "arabic", 6, MyENCODING_ISO_8859_6, 457, 216},
+ {"iso-8859-7", 10, "greek", 5, MyENCODING_ISO_8859_7, 0, 217},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"shift_jis", 9, "ms_kanji", 8, MyHTML_ENCODING_SHIFT_JIS, 0, 219},
+ {"shift_jis", 9, "ms_kanji", 8, MyENCODING_SHIFT_JIS, 0, 219},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-5", 10, "iso8859-5", 9, MyHTML_ENCODING_ISO_8859_5, 460, 225},
+ {"iso-8859-5", 10, "iso8859-5", 9, MyENCODING_ISO_8859_5, 460, 225},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "ascii", 5, MyHTML_ENCODING_WINDOWS_1252, 461, 227},
+ {"windows-1252", 12, "ascii", 5, MyENCODING_WINDOWS_1252, 461, 227},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-kr", 6, "korean", 6, MyHTML_ENCODING_EUC_KR, 0, 229},
+ {"euc-kr", 6, "korean", 6, MyENCODING_EUC_KR, 0, 229},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"utf-8", 5, "utf8", 4, MyHTML_ENCODING_UTF_8, 462, 231},
- {"iso-8859-3", 10, "csisolatin3", 11, MyHTML_ENCODING_ISO_8859_3, 0, 232},
- {"windows-1256", 12, "cp1256", 6, MyHTML_ENCODING_WINDOWS_1256, 464, 233},
- {"windows-1254", 12, "iso8859-9", 9, MyHTML_ENCODING_WINDOWS_1254, 0, 234},
- {"windows-1252", 12, "us-ascii", 8, MyHTML_ENCODING_WINDOWS_1252, 465, 235},
+ {"utf-8", 5, "utf8", 4, MyENCODING_UTF_8, 462, 231},
+ {"iso-8859-3", 10, "csisolatin3", 11, MyENCODING_ISO_8859_3, 0, 232},
+ {"windows-1256", 12, "cp1256", 6, MyENCODING_WINDOWS_1256, 464, 233},
+ {"windows-1254", 12, "iso8859-9", 9, MyENCODING_WINDOWS_1254, 0, 234},
+ {"windows-1252", 12, "us-ascii", 8, MyENCODING_WINDOWS_1252, 465, 235},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -278,44 +278,44 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"big5", 4, "big5", 4, MyHTML_ENCODING_BIG5, 466, 246},
+ {"big5", 4, "big5", 4, MyENCODING_BIG5, 466, 246},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1250", 12, "windows-1250", 12, MyHTML_ENCODING_WINDOWS_1250, 0, 248},
- {"euc-kr", 6, "ksc5601", 7, MyHTML_ENCODING_EUC_KR, 0, 249},
+ {"windows-1250", 12, "windows-1250", 12, MyENCODING_WINDOWS_1250, 0, 248},
+ {"euc-kr", 6, "ksc5601", 7, MyENCODING_EUC_KR, 0, 249},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-7", 10, "greek8", 6, MyHTML_ENCODING_ISO_8859_7, 467, 251},
+ {"iso-8859-7", 10, "greek8", 6, MyENCODING_ISO_8859_7, 467, 251},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-jp", 6, "x-euc-jp", 8, MyHTML_ENCODING_EUC_JP, 0, 257},
- {"shift_jis", 9, "x-sjis", 6, MyHTML_ENCODING_SHIFT_JIS, 0, 258},
+ {"euc-jp", 6, "x-euc-jp", 8, MyENCODING_EUC_JP, 0, 257},
+ {"shift_jis", 9, "x-sjis", 6, MyENCODING_SHIFT_JIS, 0, 258},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"utf-16be", 8, "utf-16be", 8, MyHTML_ENCODING_UTF_16BE, 468, 262},
+ {"utf-16be", 8, "utf-16be", 8, MyENCODING_UTF_16BE, 468, 262},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1255", 12, "windows-1255", 12, MyHTML_ENCODING_WINDOWS_1255, 0, 265},
+ {"windows-1255", 12, "windows-1255", 12, MyENCODING_WINDOWS_1255, 0, 265},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-kr", 6, "ks_c_5601-1987", 14, MyHTML_ENCODING_EUC_KR, 0, 267},
+ {"euc-kr", 6, "ks_c_5601-1987", 14, MyENCODING_EUC_KR, 0, 267},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"ibm866", 6, "866", 3, MyHTML_ENCODING_IBM866, 0, 274},
+ {"ibm866", 6, "866", 3, MyENCODING_IBM866, 0, 274},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"big5", 4, "cn-big5", 7, MyHTML_ENCODING_BIG5, 0, 277},
+ {"big5", 4, "cn-big5", 7, MyENCODING_BIG5, 0, 277},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"koi8-r", 6, "koi8-r", 6, MyHTML_ENCODING_KOI8_R, 469, 283},
+ {"koi8-r", 6, "koi8-r", 6, MyENCODING_KOI8_R, 469, 283},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -328,93 +328,93 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "ibm819", 6, MyHTML_ENCODING_WINDOWS_1252, 0, 296},
+ {"windows-1252", 12, "ibm819", 6, MyENCODING_WINDOWS_1252, 0, 296},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-6", 10, "asmo-708", 8, MyHTML_ENCODING_ISO_8859_6, 0, 300},
+ {"iso-8859-6", 10, "asmo-708", 8, MyENCODING_ISO_8859_6, 0, 300},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1254", 12, "cp1254", 6, MyHTML_ENCODING_WINDOWS_1254, 470, 302},
+ {"windows-1254", 12, "cp1254", 6, MyENCODING_WINDOWS_1254, 470, 302},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1256", 12, "x-cp1256", 8, MyHTML_ENCODING_WINDOWS_1256, 471, 304},
+ {"windows-1256", 12, "x-cp1256", 8, MyENCODING_WINDOWS_1256, 471, 304},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-2022-jp", 11, "iso-2022-jp", 11, MyHTML_ENCODING_ISO_2022_JP, 0, 309},
+ {"iso-2022-jp", 11, "iso-2022-jp", 11, MyENCODING_ISO_2022_JP, 0, 309},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "iso_8859-2:1987", 15, MyHTML_ENCODING_ISO_8859_2, 473, 312},
+ {"iso-8859-2", 10, "iso_8859-2:1987", 15, MyENCODING_ISO_8859_2, 473, 312},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"gbk", 3, "gb2312", 6, MyHTML_ENCODING_GBK, 0, 314},
- {"windows-1254", 12, "csisolatin5", 11, MyHTML_ENCODING_WINDOWS_1254, 0, 315},
- {"iso-8859-6", 10, "iso-8859-6-i", 12, MyHTML_ENCODING_ISO_8859_6, 476, 316},
+ {"gbk", 3, "gb2312", 6, MyENCODING_GBK, 0, 314},
+ {"windows-1254", 12, "csisolatin5", 11, MyENCODING_WINDOWS_1254, 0, 315},
+ {"iso-8859-6", 10, "iso-8859-6-i", 12, MyENCODING_ISO_8859_6, 476, 316},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "iso8859-2", 9, MyHTML_ENCODING_ISO_8859_2, 0, 323},
+ {"iso-8859-2", 10, "iso8859-2", 9, MyENCODING_ISO_8859_2, 0, 323},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "l2", 2, MyHTML_ENCODING_ISO_8859_2, 0, 326},
+ {"iso-8859-2", 10, "l2", 2, MyENCODING_ISO_8859_2, 0, 326},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "latin1", 6, MyHTML_ENCODING_WINDOWS_1252, 0, 328},
+ {"windows-1252", 12, "latin1", 6, MyENCODING_WINDOWS_1252, 0, 328},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-kr", 6, "ks_c_5601-1989", 14, MyHTML_ENCODING_EUC_KR, 0, 330},
+ {"euc-kr", 6, "ks_c_5601-1989", 14, MyENCODING_EUC_KR, 0, 330},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-6", 10, "iso8859-6", 9, MyHTML_ENCODING_ISO_8859_6, 0, 332},
- {"iso-8859-2", 10, "iso-ir-101", 10, MyHTML_ENCODING_ISO_8859_2, 477, 333},
- {"ibm866", 6, "cp866", 5, MyHTML_ENCODING_IBM866, 0, 334},
+ {"iso-8859-6", 10, "iso8859-6", 9, MyENCODING_ISO_8859_6, 0, 332},
+ {"iso-8859-2", 10, "iso-ir-101", 10, MyENCODING_ISO_8859_2, 477, 333},
+ {"ibm866", 6, "cp866", 5, MyENCODING_IBM866, 0, 334},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-3", 10, "iso-8859-3", 10, MyHTML_ENCODING_ISO_8859_3, 480, 338},
- {"iso-8859-4", 10, "l4", 2, MyHTML_ENCODING_ISO_8859_4, 0, 339},
+ {"iso-8859-3", 10, "iso-8859-3", 10, MyENCODING_ISO_8859_3, 480, 338},
+ {"iso-8859-4", 10, "l4", 2, MyENCODING_ISO_8859_4, 0, 339},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1253", 12, "windows-1253", 12, MyHTML_ENCODING_WINDOWS_1253, 0, 342},
- {"iso-8859-5", 10, "iso-8859-5", 10, MyHTML_ENCODING_ISO_8859_5, 482, 343},
+ {"windows-1253", 12, "windows-1253", 12, MyENCODING_WINDOWS_1253, 0, 342},
+ {"iso-8859-5", 10, "iso-8859-5", 10, MyENCODING_ISO_8859_5, 482, 343},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-6", 10, "iso-ir-127", 10, MyHTML_ENCODING_ISO_8859_6, 484, 348},
+ {"iso-8859-6", 10, "iso-ir-127", 10, MyENCODING_ISO_8859_6, 484, 348},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"utf-8", 5, "unicode-1-1-utf-8", 17, MyHTML_ENCODING_UTF_8, 0, 350},
+ {"utf-8", 5, "unicode-1-1-utf-8", 17, MyENCODING_UTF_8, 0, 350},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-10", 11, "l6", 2, MyHTML_ENCODING_ISO_8859_10, 0, 352},
- {"iso-8859-3", 10, "iso-ir-109", 10, MyHTML_ENCODING_ISO_8859_3, 487, 353},
+ {"iso-8859-10", 11, "l6", 2, MyENCODING_ISO_8859_10, 0, 352},
+ {"iso-8859-3", 10, "iso-ir-109", 10, MyENCODING_ISO_8859_3, 487, 353},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1253", 12, "x-cp1253", 8, MyHTML_ENCODING_WINDOWS_1253, 0, 357},
+ {"windows-1253", 12, "x-cp1253", 8, MyENCODING_WINDOWS_1253, 0, 357},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-16", 11, "iso-8859-16", 11, MyHTML_ENCODING_ISO_8859_16, 490, 359},
+ {"iso-8859-16", 11, "iso-8859-16", 11, MyENCODING_ISO_8859_16, 490, 359},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-8-i", 12, "logical", 7, MyHTML_ENCODING_ISO_8859_8_I, 0, 363},
+ {"iso-8859-8-i", 12, "logical", 7, MyENCODING_ISO_8859_8_I, 0, 363},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-8", 10, "csisolatinhebrew", 16, MyHTML_ENCODING_ISO_8859_8, 0, 366},
- {"iso-8859-3", 10, "latin3", 6, MyHTML_ENCODING_ISO_8859_3, 491, 367},
+ {"iso-8859-8", 10, "csisolatinhebrew", 16, MyENCODING_ISO_8859_8, 0, 366},
+ {"iso-8859-3", 10, "latin3", 6, MyENCODING_ISO_8859_3, 491, 367},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-kr", 6, "euc-kr", 6, MyHTML_ENCODING_EUC_KR, 0, 369},
+ {"euc-kr", 6, "euc-kr", 6, MyENCODING_EUC_KR, 0, 369},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1252", 12, "cp1252", 6, MyHTML_ENCODING_WINDOWS_1252, 0, 371},
+ {"windows-1252", 12, "cp1252", 6, MyENCODING_WINDOWS_1252, 0, 371},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-6", 10, "csiso88596i", 11, MyHTML_ENCODING_ISO_8859_6, 492, 378},
+ {"iso-8859-6", 10, "csiso88596i", 11, MyENCODING_ISO_8859_6, 492, 378},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"gbk", 3, "gbk", 3, MyHTML_ENCODING_GBK, 0, 382},
+ {"gbk", 3, "gbk", 3, MyENCODING_GBK, 0, 382},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
@@ -426,109 +426,109 @@ static const myhtml_encoding_detect_name_entry_t myhtml_encoding_detect_name_ent
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-kr", 6, "csksc56011987", 13, MyHTML_ENCODING_EUC_KR, 0, 394},
+ {"euc-kr", 6, "csksc56011987", 13, MyENCODING_EUC_KR, 0, 394},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"x-mac-cyrillic", 14, "x-mac-cyrillic", 14, MyHTML_ENCODING_X_MAC_CYRILLIC, 0, 397},
+ {"x-mac-cyrillic", 14, "x-mac-cyrillic", 14, MyENCODING_X_MAC_CYRILLIC, 0, 397},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-2", 10, "csisolatin2", 11, MyHTML_ENCODING_ISO_8859_2, 0, 400},
- {"x-user-defined", 14, "x-user-defined", 14, MyHTML_ENCODING_X_USER_DEFINED, 0, 401},
+ {"iso-8859-2", 10, "csisolatin2", 11, MyENCODING_ISO_8859_2, 0, 400},
+ {"x-user-defined", 14, "x-user-defined", 14, MyENCODING_X_USER_DEFINED, 0, 401},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1254", 12, "latin5", 6, MyHTML_ENCODING_WINDOWS_1254, 0, 406},
+ {"windows-1254", 12, "latin5", 6, MyENCODING_WINDOWS_1254, 0, 406},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"windows-1257", 12, "cp1257", 6, MyHTML_ENCODING_WINDOWS_1257, 0, 408},
- {"big5", 4, "big5-hkscs", 10, MyHTML_ENCODING_BIG5, 0, 409},
- {"windows-1250", 12, "x-cp1250", 8, MyHTML_ENCODING_WINDOWS_1250, 0, 410},
+ {"windows-1257", 12, "cp1257", 6, MyENCODING_WINDOWS_1257, 0, 408},
+ {"big5", 4, "big5-hkscs", 10, MyENCODING_BIG5, 0, 409},
+ {"windows-1250", 12, "x-cp1250", 8, MyENCODING_WINDOWS_1250, 0, 410},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"euc-jp", 6, "euc-jp", 6, MyHTML_ENCODING_EUC_JP, 0, 414},
+ {"euc-jp", 6, "euc-jp", 6, MyENCODING_EUC_JP, 0, 414},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"iso-8859-7", 10, "ecma-118", 8, MyHTML_ENCODING_ISO_8859_7, 493, 416},
+ {"iso-8859-7", 10, "ecma-118", 8, MyENCODING_ISO_8859_7, 493, 416},
{NULL, 0, NULL, 0, 0, 0, 0},
- {"gbk", 3, "gb_2312-80", 10, MyHTML_ENCODING_GBK, 0, 418},
- {"windows-1251", 12, "windows-1251", 12, MyHTML_ENCODING_WINDOWS_1251, 0, 419},
- {"iso-8859-13", 11, "iso885913", 9, MyHTML_ENCODING_ISO_8859_13, 0, 420},
- {"windows-1256", 12, "windows-1256", 12, MyHTML_ENCODING_WINDOWS_1256, 0, 421},
- {"iso-8859-5", 10, "csisolatincyrillic", 18, MyHTML_ENCODING_ISO_8859_5, 0, 422},
- {"gbk", 3, "chinese", 7, MyHTML_ENCODING_GBK, 0, 423},
- {"shift_jis", 9, "shift_jis", 9, MyHTML_ENCODING_SHIFT_JIS, 0, 424},
- {"windows-874", 11, "iso-8859-11", 11, MyHTML_ENCODING_WINDOWS_874, 0, 425},
- {"iso-8859-15", 11, "iso_8859-15", 11, MyHTML_ENCODING_ISO_8859_15, 0, 426},
- {"big5", 4, "csbig5", 6, MyHTML_ENCODING_BIG5, 0, 427},
- {"iso-8859-8", 10, "hebrew", 6, MyHTML_ENCODING_ISO_8859_8, 429, 428},
- {"windows-1254", 12, "windows-1254", 12, MyHTML_ENCODING_WINDOWS_1254, 0, 429},
- {"iso-8859-5", 10, "iso88595", 8, MyHTML_ENCODING_ISO_8859_5, 0, 430},
- {"iso-8859-10", 11, "iso885910", 9, MyHTML_ENCODING_ISO_8859_10, 0, 431},
- {"windows-1254", 12, "iso_8859-9:1989", 15, MyHTML_ENCODING_WINDOWS_1254, 0, 432},
- {"iso-8859-7", 10, "iso88597", 8, MyHTML_ENCODING_ISO_8859_7, 434, 433},
- {"iso-8859-6", 10, "csisolatinarabic", 16, MyHTML_ENCODING_ISO_8859_6, 0, 434},
- {"windows-1251", 12, "x-cp1251", 8, MyHTML_ENCODING_WINDOWS_1251, 0, 435},
- {"iso-8859-14", 11, "iso885914", 9, MyHTML_ENCODING_ISO_8859_14, 0, 436},
- {"iso-8859-10", 11, "iso8859-10", 10, MyHTML_ENCODING_ISO_8859_10, 438, 437},
- {"windows-1252", 12, "iso-ir-100", 10, MyHTML_ENCODING_WINDOWS_1252, 0, 438},
- {"iso-8859-2", 10, "iso_8859-2", 10, MyHTML_ENCODING_ISO_8859_2, 0, 439},
- {"iso-8859-8", 10, "iso8859-8", 9, MyHTML_ENCODING_ISO_8859_8, 441, 440},
- {"gbk", 3, "iso-ir-58", 9, MyHTML_ENCODING_GBK, 442, 441},
- {"macintosh", 9, "csmacintosh", 11, MyHTML_ENCODING_MACINTOSH, 0, 442},
- {"iso-8859-4", 10, "iso_8859-4", 10, MyHTML_ENCODING_ISO_8859_4, 444, 443},
- {"iso-8859-5", 10, "iso-ir-144", 10, MyHTML_ENCODING_ISO_8859_5, 445, 444},
- {"iso-8859-14", 11, "iso8859-14", 10, MyHTML_ENCODING_ISO_8859_14, 0, 445},
- {"iso-8859-6", 10, "iso-8859-6", 10, MyHTML_ENCODING_ISO_8859_6, 447, 446},
- {"iso-8859-6", 10, "iso_8859-6", 10, MyHTML_ENCODING_ISO_8859_6, 448, 447},
- {"iso-8859-7", 10, "iso-ir-126", 10, MyHTML_ENCODING_ISO_8859_7, 0, 448},
- {"iso-8859-8", 10, "iso-ir-138", 10, MyHTML_ENCODING_ISO_8859_8, 450, 449},
- {"iso-8859-8", 10, "iso_8859-8", 10, MyHTML_ENCODING_ISO_8859_8, 451, 450},
- {"windows-1254", 12, "iso-ir-148", 10, MyHTML_ENCODING_WINDOWS_1254, 0, 451},
- {"big5", 4, "x-x-big5", 8, MyHTML_ENCODING_BIG5, 0, 452},
- {"iso-8859-4", 10, "iso_8859-4:1988", 15, MyHTML_ENCODING_ISO_8859_4, 454, 453},
- {"iso-8859-5", 10, "iso_8859-5:1988", 15, MyHTML_ENCODING_ISO_8859_5, 455, 454},
- {"iso-8859-8", 10, "iso_8859-8:1988", 15, MyHTML_ENCODING_ISO_8859_8, 0, 455},
- {"iso-8859-8", 10, "csiso88598e", 11, MyHTML_ENCODING_ISO_8859_8, 0, 456},
- {"iso-8859-10", 11, "latin6", 6, MyHTML_ENCODING_ISO_8859_10, 458, 457},
- {"windows-874", 11, "iso885911", 9, MyHTML_ENCODING_WINDOWS_874, 459, 458},
- {"windows-1252", 12, "iso8859-1", 9, MyHTML_ENCODING_WINDOWS_1252, 0, 459},
- {"iso-8859-15", 11, "iso885915", 9, MyHTML_ENCODING_ISO_8859_15, 0, 460},
- {"macintosh", 9, "x-mac-roman", 11, MyHTML_ENCODING_MACINTOSH, 0, 461},
- {"koi8-r", 6, "cskoi8r", 7, MyHTML_ENCODING_KOI8_R, 463, 462},
- {"euc-kr", 6, "cseuckr", 7, MyHTML_ENCODING_EUC_KR, 0, 463},
- {"x-mac-cyrillic", 14, "x-mac-ukrainian", 15, MyHTML_ENCODING_X_MAC_CYRILLIC, 0, 464},
- {"windows-1252", 12, "x-cp1252", 8, MyHTML_ENCODING_WINDOWS_1252, 0, 465},
- {"iso-8859-13", 11, "iso-8859-13", 11, MyHTML_ENCODING_ISO_8859_13, 0, 466},
- {"gb18030", 7, "gb18030", 7, MyHTML_ENCODING_GB18030, 0, 467},
- {"utf-16le", 8, "utf-16le", 8, MyHTML_ENCODING_UTF_16LE, 0, 468},
- {"koi8-r", 6, "koi8_r", 6, MyHTML_ENCODING_KOI8_R, 0, 469},
- {"shift_jis", 9, "csshiftjis", 10, MyHTML_ENCODING_SHIFT_JIS, 0, 470},
- {"iso-8859-6", 10, "iso-8859-6-e", 12, MyHTML_ENCODING_ISO_8859_6, 472, 471},
- {"iso-8859-8", 10, "iso-8859-8-e", 12, MyHTML_ENCODING_ISO_8859_8, 0, 472},
- {"iso-8859-6", 10, "iso_8859-6:1987", 15, MyHTML_ENCODING_ISO_8859_6, 474, 473},
- {"iso-8859-7", 10, "iso_8859-7:1987", 15, MyHTML_ENCODING_ISO_8859_7, 475, 474},
- {"windows-1252", 12, "iso_8859-1:1987", 15, MyHTML_ENCODING_WINDOWS_1252, 0, 475},
- {"iso-8859-8-i", 12, "iso-8859-8-i", 12, MyHTML_ENCODING_ISO_8859_8_I, 0, 476},
- {"windows-874", 11, "iso8859-11", 10, MyHTML_ENCODING_WINDOWS_874, 478, 477},
- {"windows-1252", 12, "iso-8859-1", 10, MyHTML_ENCODING_WINDOWS_1252, 479, 478},
- {"windows-1252", 12, "iso_8859-1", 10, MyHTML_ENCODING_WINDOWS_1252, 0, 479},
- {"iso-8859-3", 10, "iso_8859-3", 10, MyHTML_ENCODING_ISO_8859_3, 481, 480},
- {"iso-8859-13", 11, "iso8859-13", 10, MyHTML_ENCODING_ISO_8859_13, 0, 481},
- {"iso-8859-5", 10, "iso_8859-5", 10, MyHTML_ENCODING_ISO_8859_5, 483, 482},
- {"iso-8859-15", 11, "iso8859-15", 10, MyHTML_ENCODING_ISO_8859_15, 0, 483},
- {"iso-8859-7", 10, "iso-8859-7", 10, MyHTML_ENCODING_ISO_8859_7, 485, 484},
- {"iso-8859-7", 10, "iso_8859-7", 10, MyHTML_ENCODING_ISO_8859_7, 486, 485},
- {"iso-8859-10", 11, "iso-ir-157", 10, MyHTML_ENCODING_ISO_8859_10, 0, 486},
- {"windows-1254", 12, "iso-8859-9", 10, MyHTML_ENCODING_WINDOWS_1254, 488, 487},
- {"windows-1254", 12, "iso_8859-9", 10, MyHTML_ENCODING_WINDOWS_1254, 489, 488},
- {"euc-kr", 6, "iso-ir-149", 10, MyHTML_ENCODING_EUC_KR, 0, 489},
- {"windows-1258", 12, "windows-1258", 12, MyHTML_ENCODING_WINDOWS_1258, 0, 490},
- {"windows-874", 11, "dos-874", 7, MyHTML_ENCODING_WINDOWS_874, 0, 491},
- {"iso-8859-8-i", 12, "csiso88598i", 11, MyHTML_ENCODING_ISO_8859_8_I, 0, 492},
- {"iso-8859-7", 10, "elot_928", 8, MyHTML_ENCODING_ISO_8859_7, 0, 493},
+ {"gbk", 3, "gb_2312-80", 10, MyENCODING_GBK, 0, 418},
+ {"windows-1251", 12, "windows-1251", 12, MyENCODING_WINDOWS_1251, 0, 419},
+ {"iso-8859-13", 11, "iso885913", 9, MyENCODING_ISO_8859_13, 0, 420},
+ {"windows-1256", 12, "windows-1256", 12, MyENCODING_WINDOWS_1256, 0, 421},
+ {"iso-8859-5", 10, "csisolatincyrillic", 18, MyENCODING_ISO_8859_5, 0, 422},
+ {"gbk", 3, "chinese", 7, MyENCODING_GBK, 0, 423},
+ {"shift_jis", 9, "shift_jis", 9, MyENCODING_SHIFT_JIS, 0, 424},
+ {"windows-874", 11, "iso-8859-11", 11, MyENCODING_WINDOWS_874, 0, 425},
+ {"iso-8859-15", 11, "iso_8859-15", 11, MyENCODING_ISO_8859_15, 0, 426},
+ {"big5", 4, "csbig5", 6, MyENCODING_BIG5, 0, 427},
+ {"iso-8859-8", 10, "hebrew", 6, MyENCODING_ISO_8859_8, 429, 428},
+ {"windows-1254", 12, "windows-1254", 12, MyENCODING_WINDOWS_1254, 0, 429},
+ {"iso-8859-5", 10, "iso88595", 8, MyENCODING_ISO_8859_5, 0, 430},
+ {"iso-8859-10", 11, "iso885910", 9, MyENCODING_ISO_8859_10, 0, 431},
+ {"windows-1254", 12, "iso_8859-9:1989", 15, MyENCODING_WINDOWS_1254, 0, 432},
+ {"iso-8859-7", 10, "iso88597", 8, MyENCODING_ISO_8859_7, 434, 433},
+ {"iso-8859-6", 10, "csisolatinarabic", 16, MyENCODING_ISO_8859_6, 0, 434},
+ {"windows-1251", 12, "x-cp1251", 8, MyENCODING_WINDOWS_1251, 0, 435},
+ {"iso-8859-14", 11, "iso885914", 9, MyENCODING_ISO_8859_14, 0, 436},
+ {"iso-8859-10", 11, "iso8859-10", 10, MyENCODING_ISO_8859_10, 438, 437},
+ {"windows-1252", 12, "iso-ir-100", 10, MyENCODING_WINDOWS_1252, 0, 438},
+ {"iso-8859-2", 10, "iso_8859-2", 10, MyENCODING_ISO_8859_2, 0, 439},
+ {"iso-8859-8", 10, "iso8859-8", 9, MyENCODING_ISO_8859_8, 441, 440},
+ {"gbk", 3, "iso-ir-58", 9, MyENCODING_GBK, 442, 441},
+ {"macintosh", 9, "csmacintosh", 11, MyENCODING_MACINTOSH, 0, 442},
+ {"iso-8859-4", 10, "iso_8859-4", 10, MyENCODING_ISO_8859_4, 444, 443},
+ {"iso-8859-5", 10, "iso-ir-144", 10, MyENCODING_ISO_8859_5, 445, 444},
+ {"iso-8859-14", 11, "iso8859-14", 10, MyENCODING_ISO_8859_14, 0, 445},
+ {"iso-8859-6", 10, "iso-8859-6", 10, MyENCODING_ISO_8859_6, 447, 446},
+ {"iso-8859-6", 10, "iso_8859-6", 10, MyENCODING_ISO_8859_6, 448, 447},
+ {"iso-8859-7", 10, "iso-ir-126", 10, MyENCODING_ISO_8859_7, 0, 448},
+ {"iso-8859-8", 10, "iso-ir-138", 10, MyENCODING_ISO_8859_8, 450, 449},
+ {"iso-8859-8", 10, "iso_8859-8", 10, MyENCODING_ISO_8859_8, 451, 450},
+ {"windows-1254", 12, "iso-ir-148", 10, MyENCODING_WINDOWS_1254, 0, 451},
+ {"big5", 4, "x-x-big5", 8, MyENCODING_BIG5, 0, 452},
+ {"iso-8859-4", 10, "iso_8859-4:1988", 15, MyENCODING_ISO_8859_4, 454, 453},
+ {"iso-8859-5", 10, "iso_8859-5:1988", 15, MyENCODING_ISO_8859_5, 455, 454},
+ {"iso-8859-8", 10, "iso_8859-8:1988", 15, MyENCODING_ISO_8859_8, 0, 455},
+ {"iso-8859-8", 10, "csiso88598e", 11, MyENCODING_ISO_8859_8, 0, 456},
+ {"iso-8859-10", 11, "latin6", 6, MyENCODING_ISO_8859_10, 458, 457},
+ {"windows-874", 11, "iso885911", 9, MyENCODING_WINDOWS_874, 459, 458},
+ {"windows-1252", 12, "iso8859-1", 9, MyENCODING_WINDOWS_1252, 0, 459},
+ {"iso-8859-15", 11, "iso885915", 9, MyENCODING_ISO_8859_15, 0, 460},
+ {"macintosh", 9, "x-mac-roman", 11, MyENCODING_MACINTOSH, 0, 461},
+ {"koi8-r", 6, "cskoi8r", 7, MyENCODING_KOI8_R, 463, 462},
+ {"euc-kr", 6, "cseuckr", 7, MyENCODING_EUC_KR, 0, 463},
+ {"x-mac-cyrillic", 14, "x-mac-ukrainian", 15, MyENCODING_X_MAC_CYRILLIC, 0, 464},
+ {"windows-1252", 12, "x-cp1252", 8, MyENCODING_WINDOWS_1252, 0, 465},
+ {"iso-8859-13", 11, "iso-8859-13", 11, MyENCODING_ISO_8859_13, 0, 466},
+ {"gb18030", 7, "gb18030", 7, MyENCODING_GB18030, 0, 467},
+ {"utf-16le", 8, "utf-16le", 8, MyENCODING_UTF_16LE, 0, 468},
+ {"koi8-r", 6, "koi8_r", 6, MyENCODING_KOI8_R, 0, 469},
+ {"shift_jis", 9, "csshiftjis", 10, MyENCODING_SHIFT_JIS, 0, 470},
+ {"iso-8859-6", 10, "iso-8859-6-e", 12, MyENCODING_ISO_8859_6, 472, 471},
+ {"iso-8859-8", 10, "iso-8859-8-e", 12, MyENCODING_ISO_8859_8, 0, 472},
+ {"iso-8859-6", 10, "iso_8859-6:1987", 15, MyENCODING_ISO_8859_6, 474, 473},
+ {"iso-8859-7", 10, "iso_8859-7:1987", 15, MyENCODING_ISO_8859_7, 475, 474},
+ {"windows-1252", 12, "iso_8859-1:1987", 15, MyENCODING_WINDOWS_1252, 0, 475},
+ {"iso-8859-8-i", 12, "iso-8859-8-i", 12, MyENCODING_ISO_8859_8_I, 0, 476},
+ {"windows-874", 11, "iso8859-11", 10, MyENCODING_WINDOWS_874, 478, 477},
+ {"windows-1252", 12, "iso-8859-1", 10, MyENCODING_WINDOWS_1252, 479, 478},
+ {"windows-1252", 12, "iso_8859-1", 10, MyENCODING_WINDOWS_1252, 0, 479},
+ {"iso-8859-3", 10, "iso_8859-3", 10, MyENCODING_ISO_8859_3, 481, 480},
+ {"iso-8859-13", 11, "iso8859-13", 10, MyENCODING_ISO_8859_13, 0, 481},
+ {"iso-8859-5", 10, "iso_8859-5", 10, MyENCODING_ISO_8859_5, 483, 482},
+ {"iso-8859-15", 11, "iso8859-15", 10, MyENCODING_ISO_8859_15, 0, 483},
+ {"iso-8859-7", 10, "iso-8859-7", 10, MyENCODING_ISO_8859_7, 485, 484},
+ {"iso-8859-7", 10, "iso_8859-7", 10, MyENCODING_ISO_8859_7, 486, 485},
+ {"iso-8859-10", 11, "iso-ir-157", 10, MyENCODING_ISO_8859_10, 0, 486},
+ {"windows-1254", 12, "iso-8859-9", 10, MyENCODING_WINDOWS_1254, 488, 487},
+ {"windows-1254", 12, "iso_8859-9", 10, MyENCODING_WINDOWS_1254, 489, 488},
+ {"euc-kr", 6, "iso-ir-149", 10, MyENCODING_EUC_KR, 0, 489},
+ {"windows-1258", 12, "windows-1258", 12, MyENCODING_WINDOWS_1258, 0, 490},
+ {"windows-874", 11, "dos-874", 7, MyENCODING_WINDOWS_874, 0, 491},
+ {"iso-8859-8-i", 12, "csiso88598i", 11, MyENCODING_ISO_8859_8_I, 0, 492},
+ {"iso-8859-7", 10, "elot_928", 8, MyENCODING_ISO_8859_7, 0, 493},
};
-static const myhtml_encoding_entry_name_index_t myhtml_encoding_entry_name_index_static_list_index[(MyHTML_ENCODING_LAST_ENTRY + 1)] =
+static const myencoding_entry_name_index_t myencoding_entry_name_index_static_list_index[(MyENCODING_LAST_ENTRY + 1)] =
{
{"UTF-8", 5},
{"AUTO", 4},
@@ -574,7 +574,7 @@ static const myhtml_encoding_entry_name_index_t myhtml_encoding_entry_name_index
{"", 0},
};
-static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_ibm866[] = {
+static const myencoding_trigram_t myencoding_detect_trigrams_index_ibm866[] = {
{{0xA5, 0xAD, 0xA8}, 991}, /* ени */
{{0xAE, 0xA3, 0xAE}, 806}, /* ого */
{{0xE1, 0xE2, 0xA2}, 659}, /* ств */
@@ -1583,7 +1583,7 @@ static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_ibm
{{0xAC, 0xAB, 0xA5}, 10}, /* мле */
};
-static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_iso_8859_5[] = {
+static const myencoding_trigram_t myencoding_detect_trigrams_index_iso_8859_5[] = {
{{0xD5, 0xDD, 0xD8}, 991}, /* ени */
{{0xDE, 0xD3, 0xDE}, 806}, /* ого */
{{0xE1, 0xE2, 0xD2}, 659}, /* ств */
@@ -2592,7 +2592,7 @@ static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_iso
{{0xDC, 0xDB, 0xD5}, 10}, /* мле */
};
-static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_koi8_r[] = {
+static const myencoding_trigram_t myencoding_detect_trigrams_index_koi8_r[] = {
{{0xC5, 0xCE, 0xC9}, 991}, /* ени */
{{0xCF, 0xC7, 0xCF}, 806}, /* ого */
{{0xD3, 0xD4, 0xD7}, 659}, /* ств */
@@ -3601,7 +3601,7 @@ static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_koi
{{0xCD, 0xCC, 0xC5}, 10}, /* мле */
};
-static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_windows_1251[] = {
+static const myencoding_trigram_t myencoding_detect_trigrams_index_windows_1251[] = {
{{0xE5, 0xED, 0xE8}, 991}, /* ени */
{{0xEE, 0xE3, 0xEE}, 806}, /* ого */
{{0xF1, 0xF2, 0xE2}, 659}, /* ств */
@@ -4610,7 +4610,7 @@ static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_win
{{0xEC, 0xEB, 0xE5}, 10}, /* мле */
};
-static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_x_mac_cyrillic[] = {
+static const myencoding_trigram_t myencoding_detect_trigrams_index_x_mac_cyrillic[] = {
{{0xE5, 0xED, 0xE8}, 991}, /* ени */
{{0xEE, 0xE3, 0xEE}, 806}, /* ого */
{{0xF1, 0xF2, 0xE2}, 659}, /* ств */
@@ -5623,4 +5623,4 @@ static const myhtml_encoding_trigram_t myhtml_encoding_detect_trigrams_index_x_m
} /* extern "C" */
#endif
-#endif /* MyHTML_ENCODING_DETECT_RESOURCE_H */
+#endif /* MyENCODING_DETECT_RESOURCE_H */
diff --git a/source/myhtml/encoding.c b/source/myencoding/encoding.c
index d7a7807..515e059 100644
--- a/source/myhtml/encoding.c
+++ b/source/myencoding/encoding.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,18 +18,16 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/encoding.h"
-#include "myhtml/encoding_resource.h"
-#include "myhtml/utils/resources.h"
+#include "myencoding/encoding.h"
+#include "myencoding/resource.h"
+#include "mycore/utils/resources.h"
-
-
-myhtml_encoding_custom_f myhtml_encoding_get_function_by_id(myhtml_encoding_t idx)
+myencoding_custom_f myencoding_get_function_by_id(myencoding_t idx)
{
- return myhtml_encoding_function_index[idx];
+ return myencoding_function_index[idx];
}
-enum myhtml_encoding_status myhtml_encoding_decode_utf_8(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_utf_8(unsigned const char data, myencoding_result_t *res)
{
// res->first -- lower boundary
// res->second -- upper boundary
@@ -41,7 +39,7 @@ enum myhtml_encoding_status myhtml_encoding_decode_utf_8(unsigned const char dat
{
if(data <= 0x7F) {
res->result = data;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
else if(data >= 0xC2 && data <= 0xDF) {
res->flag = 1;
@@ -70,10 +68,10 @@ enum myhtml_encoding_status myhtml_encoding_decode_utf_8(unsigned const char dat
res->result = data - 0xF0;
}
else
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
res->result = res->result << (6 * res->flag);
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
if(data < res->first && data > res->second)
@@ -84,7 +82,7 @@ enum myhtml_encoding_status myhtml_encoding_decode_utf_8(unsigned const char dat
res->first = 0x80;
res->second = 0xBF;
- return MyHTML_ENCODING_STATUS_DONE|MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_DONE|MyENCODING_STATUS_ERROR;
}
res->first = 0x80;
@@ -94,300 +92,300 @@ enum myhtml_encoding_status myhtml_encoding_decode_utf_8(unsigned const char dat
res->result += (unsigned long)(data - 0x80) << (6 * (res->flag - res->third));
if(res->third != res->flag)
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
res->flag = 0x00;
res->third = 0x00;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_ibm866(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_ibm866(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_ibm866[(data - 0x80)]);
+ (res->result = myencoding_map_ibm866[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_2(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_2(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_2[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_2[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_3(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_3(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_3[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_3[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_4(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_4(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_4[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_4[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_5(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_5(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_5[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_5[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_6(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_6(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_6[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_6[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_7(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_7(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_7[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_7[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_8(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_8(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_8[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_8[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_8_i(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_8_i(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_8[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_8[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_10(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_10(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_10[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_10[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_13(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_13(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_13[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_13[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_14(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_14(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_14[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_14[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_15(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_15(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_15[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_15[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_16(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_8859_16(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_iso_8859_16[(data - 0x80)]);
+ (res->result = myencoding_map_iso_8859_16[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_koi8_r(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_koi8_r(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_koi8_r[(data - 0x80)]);
+ (res->result = myencoding_map_koi8_r[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_koi8_u(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_koi8_u(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_koi8_u[(data - 0x80)]);
+ (res->result = myencoding_map_koi8_u[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_macintosh(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_macintosh(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_macintosh[(data - 0x80)]);
+ (res->result = myencoding_map_macintosh[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_windows_874(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_windows_874(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_windows_874[(data - 0x80)]);
+ (res->result = myencoding_map_windows_874[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1250(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_windows_1250(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_windows_1250[(data - 0x80)]);
+ (res->result = myencoding_map_windows_1250[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1251(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_windows_1251(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_windows_1251[(data - 0x80)]);
+ (res->result = myencoding_map_windows_1251[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1252(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_windows_1252(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_windows_1252[(data - 0x80)]);
+ (res->result = myencoding_map_windows_1252[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1253(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_windows_1253(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_windows_1253[(data - 0x80)]);
+ (res->result = myencoding_map_windows_1253[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1254(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_windows_1254(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_windows_1254[(data - 0x80)]);
+ (res->result = myencoding_map_windows_1254[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1255(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_windows_1255(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_windows_1255[(data - 0x80)]);
+ (res->result = myencoding_map_windows_1255[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1256(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_windows_1256(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_windows_1256[(data - 0x80)]);
+ (res->result = myencoding_map_windows_1256[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1257(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_windows_1257(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_windows_1257[(data - 0x80)]);
+ (res->result = myencoding_map_windows_1257[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1258(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_windows_1258(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_windows_1258[(data - 0x80)]);
+ (res->result = myencoding_map_windows_1258[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_x_mac_cyrillic(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_x_mac_cyrillic(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
(res->result = data);
else
- (res->result = myhtml_encoding_map_x_mac_cyrillic[(data - 0x80)]);
+ (res->result = myencoding_map_x_mac_cyrillic[(data - 0x80)]);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_gbk(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_gbk(unsigned const char data, myencoding_result_t *res)
{
- return myhtml_encoding_decode_gb18030(data, res);
+ return myencoding_decode_gb18030(data, res);
}
-unsigned long myhtml_encoding_index_gb18030_ranges_code_point(unsigned long pointer)
+unsigned long myencoding_index_gb18030_ranges_code_point(unsigned long pointer)
{
// step 1
if((pointer > 39419 && pointer < 189000) || pointer > 1237575)
@@ -398,16 +396,16 @@ unsigned long myhtml_encoding_index_gb18030_ranges_code_point(unsigned long poin
return 0xe7c7;
// step 3
- unsigned long offset = sizeof(myhtml_encoding_map_gb18030_ranges) / (sizeof(unsigned long) * 2);
+ unsigned long offset = sizeof(myencoding_map_gb18030_ranges) / (sizeof(unsigned long) * 2);
unsigned long code_point_offset = 0;
while (offset) {
offset--;
- if(myhtml_encoding_map_gb18030_ranges[offset][0] == pointer ||
- myhtml_encoding_map_gb18030_ranges[offset][0] < pointer)
+ if(myencoding_map_gb18030_ranges[offset][0] == pointer ||
+ myencoding_map_gb18030_ranges[offset][0] < pointer)
{
- code_point_offset = myhtml_encoding_map_gb18030_ranges[offset][1];
+ code_point_offset = myencoding_map_gb18030_ranges[offset][1];
break;
}
}
@@ -416,11 +414,11 @@ unsigned long myhtml_encoding_index_gb18030_ranges_code_point(unsigned long poin
return (code_point_offset + pointer - offset);
}
-enum myhtml_encoding_status myhtml_encoding_decode_gb18030(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_gb18030(unsigned const char data, myencoding_result_t *res)
{
if(res->third) {
if(data >= 0x30 && data <= 0x39) {
- res->result = myhtml_encoding_index_gb18030_ranges_code_point((((res->first - 0x81) * 10 + res->second - 0x30) *
+ res->result = myencoding_index_gb18030_ranges_code_point((((res->first - 0x81) * 10 + res->second - 0x30) *
126 + res->third - 0x81) * 10 + data - 0x30);
}
@@ -429,25 +427,25 @@ enum myhtml_encoding_status myhtml_encoding_decode_gb18030(unsigned const char d
res->third = 0;
if(res->result)
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
else if(res->second) {
if(data >= 0x81 && data <= 0xFE) {
res->third = data;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
res->first = 0;
res->second = 0;
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
else if(res->first) {
if(data >= 0x30 && data <= 0x39) {
res->second = data;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
unsigned long lead = res->first, pointer = 0x00;
@@ -466,32 +464,32 @@ enum myhtml_encoding_status myhtml_encoding_decode_gb18030(unsigned const char d
pointer = (lead - 0x81) * 190 + (data - offset);
}
else {
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
- res->result = myhtml_encoding_map_gb18030[pointer];
- return MyHTML_ENCODING_STATUS_OK;
+ res->result = myencoding_map_gb18030[pointer];
+ return MyENCODING_STATUS_OK;
}
if(data <= 0x7F) {
res->result = data;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
if(data == 0x80) {
res->result = 0x20ac;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
if(data >= 0x81 && data <= 0xFE) {
res->first = data;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
-enum myhtml_encoding_status myhtml_encoding_decode_big5(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_big5(unsigned const char data, myencoding_result_t *res)
{
if(res->first)
{
@@ -517,61 +515,61 @@ enum myhtml_encoding_status myhtml_encoding_decode_big5(unsigned const char data
// U+00CA U+0304
res->result = 0x00ca;
res->result_aux = 0x0304;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
case 1135:
// U+00CA U+030C
res->result = 0x00ca;
res->result_aux = 0x030c;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
case 1164:
// U+00EA U+0304
res->result = 0x00ea;
res->result_aux = 0x0304;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
case 1166:
// U+00EA U+030C
res->result = 0x00ea;
res->result_aux = 0x030c;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
default:
break;
}
if(pointer == 0)
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
- res->result = myhtml_encoding_map_big5[pointer];
+ res->result = myencoding_map_big5[pointer];
res->result_aux = 0;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
if(data <= 0x7F) {
res->result = data;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
if(data >= 0x81 && data <= 0xFE) {
res->first = data;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
-enum myhtml_encoding_status myhtml_encoding_decode_euc_jp(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_euc_jp(unsigned const char data, myencoding_result_t *res)
{
if(res->first == 0x8E && (data >= 0xA1 && data <= 0xDF)) {
res->first = 0x00;
res->result = 0xFF61 + data - 0xA1;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
else if(res->first == 0x8F && (data >= 0xA1 && data <= 0xFE)) {
res->flag = 1;
res->first = data;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
else if(res->first)
{
@@ -583,37 +581,37 @@ enum myhtml_encoding_status myhtml_encoding_decode_euc_jp(unsigned const char da
{
unsigned long idx = (lead - 0xA1) * 94 + data - 0xA1;
if(res->flag) {
- res->result = myhtml_encoding_map_jis0212[idx];
+ res->result = myencoding_map_jis0212[idx];
}
else {
- res->result = myhtml_encoding_map_jis0208[idx];
+ res->result = myencoding_map_jis0208[idx];
}
res->flag = 0;
if(res->result == 0)
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
}
if(data <= 0x7F) {
res->result = data;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
if((data >= 0x8E && data <= 0x8F) ||
(data >= 0xA1 && data <= 0xFE))
{
res->first = data;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
-enum myhtml_encoding_status myhtml_encoding_decode_iso_2022_jp(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_iso_2022_jp(unsigned const char data, myencoding_result_t *res)
{
// res->first -- lead
// res->second -- state
@@ -625,35 +623,35 @@ enum myhtml_encoding_status myhtml_encoding_decode_iso_2022_jp(unsigned const ch
{
if(data == 0x1B) {
res->second = 6;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
else if((data <= 0x7F) &&
data != 0x0E && data != 0x0F && data != 0x1B)
{
res->flag = 0;
res->result = data;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
res->flag = 0;
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
case 1: // Roman
{
if(data == 0x1B) {
res->second = 6;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
else if(data == 0x5C) {
res->flag = 0;
res->result = 0x00A5;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
else if(data == 0x7E) {
res->flag = 0;
res->result = 0x203E;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
else if((data <= 0x7F) &&
data != 0x0E && data != 0x0F &&
@@ -662,68 +660,68 @@ enum myhtml_encoding_status myhtml_encoding_decode_iso_2022_jp(unsigned const ch
{
res->flag = 0;
res->result = data;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
res->flag = 0;
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
case 3: // Katakana
{
if(data == 0x1B) {
res->second = 6;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
else if(data >= 0x21 && data <= 0x5F) {
res->flag = 0;
res->result = 0xFF61 + data - 0x21;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
res->flag = 0;
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
case 4: // Lead byte
{
if(data == 0x1B) {
res->second = 6;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
else if(data >= 0x21 && data <= 0x7E) {
res->flag = 0;
res->first = data;
res->second = 5;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
res->flag = 0;
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
case 5: // Trail byte
{
if(data == 0x1B) {
res->second = 6;
- return MyHTML_ENCODING_STATUS_CONTINUE|MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_CONTINUE|MyENCODING_STATUS_ERROR;
}
else if(data >= 0x21 && data <= 0x7E) {
res->second = 4;
unsigned long pointer = (res->first - 0x21) * 94 + data - 0x21;
- res->result = myhtml_encoding_map_jis0208[pointer];
+ res->result = myencoding_map_jis0208[pointer];
if(res->result == 0)
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
res->second = 4;
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
case 6: // Escape start
@@ -732,13 +730,13 @@ enum myhtml_encoding_status myhtml_encoding_decode_iso_2022_jp(unsigned const ch
res->first = data;
res->second = 7;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
res->flag = 0;
res->second = res->third;
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
case 7: // Escape
@@ -769,15 +767,15 @@ enum myhtml_encoding_status myhtml_encoding_decode_iso_2022_jp(unsigned const ch
res->flag = 1;
if(output_flag)
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
res->flag = 0;
res->second = res->third;
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
default:
@@ -787,7 +785,7 @@ enum myhtml_encoding_status myhtml_encoding_decode_iso_2022_jp(unsigned const ch
return 0;
}
-enum myhtml_encoding_status myhtml_encoding_decode_shift_jis(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_shift_jis(unsigned const char data, myencoding_result_t *res)
{
// res->first -- lead
@@ -814,7 +812,7 @@ enum myhtml_encoding_status myhtml_encoding_decode_shift_jis(unsigned const char
}
if(pointer)
- res->result = myhtml_encoding_map_jis0208[pointer];
+ res->result = myencoding_map_jis0208[pointer];
else
res->result = 0x00;
@@ -823,31 +821,31 @@ enum myhtml_encoding_status myhtml_encoding_decode_shift_jis(unsigned const char
}
if(res->result)
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
if((data <= 0x7F) || data == 0x80) {
res->result = data;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
if(data >= 0xA1 && data <= 0xDF) {
res->result = 0xFF61 + data - 0xA1;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
if((data >= 0x81 && data <= 0x9F) ||
(data >= 0xE0 && data <= 0xFC)) {
res->first = data;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
-enum myhtml_encoding_status myhtml_encoding_decode_euc_kr(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_euc_kr(unsigned const char data, myencoding_result_t *res)
{
// res->first -- lead
@@ -861,28 +859,28 @@ enum myhtml_encoding_status myhtml_encoding_decode_euc_kr(unsigned const char da
}
if(pointer)
- res->result = myhtml_encoding_map_euc_kr[pointer];
+ res->result = myencoding_map_euc_kr[pointer];
if(res->result)
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
if(data <= 0x7F) {
res->result = data;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
if(data >= 0x81 && data <= 0xFE) {
res->first = data;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
-enum myhtml_encoding_status myhtml_encoding_decode_shared_utf_16(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_shared_utf_16(unsigned const char data, myencoding_result_t *res)
{
// res->first -- lead
// res->second -- lead surrogate
@@ -890,7 +888,7 @@ enum myhtml_encoding_status myhtml_encoding_decode_shared_utf_16(unsigned const
if(res->first == 0x00) {
res->first = data;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
unsigned long code_unit;
@@ -907,7 +905,7 @@ enum myhtml_encoding_status myhtml_encoding_decode_shared_utf_16(unsigned const
if(code_unit >= 0xDC00 && code_unit <= 0xDFFF) {
res->result = 0x10000 + ((lead_surrogate - 0xD800) << 10) + (code_unit - 0xDC00);
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
unsigned char byte1 = (unsigned char)(code_unit >> 8);
@@ -922,55 +920,55 @@ enum myhtml_encoding_status myhtml_encoding_decode_shared_utf_16(unsigned const
res->result_aux = byte1;
}
- return MyHTML_ENCODING_STATUS_DONE|MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_DONE|MyENCODING_STATUS_ERROR;
}
if(code_unit >= 0xD800 && code_unit <= 0xDBFF) {
res->second = code_unit;
- return MyHTML_ENCODING_STATUS_CONTINUE;
+ return MyENCODING_STATUS_CONTINUE;
}
if(code_unit >= 0xDC00 && code_unit <= 0xDFFF) {
- return MyHTML_ENCODING_STATUS_ERROR;
+ return MyENCODING_STATUS_ERROR;
}
res->result = code_unit;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-enum myhtml_encoding_status myhtml_encoding_decode_utf_16be(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_utf_16be(unsigned const char data, myencoding_result_t *res)
{
if(res->flag == 0)
res->flag = 1;
- return myhtml_encoding_decode_shared_utf_16(data, res);
+ return myencoding_decode_shared_utf_16(data, res);
}
-enum myhtml_encoding_status myhtml_encoding_decode_utf_16le(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_utf_16le(unsigned const char data, myencoding_result_t *res)
{
if(res->flag)
res->flag = 0;
- return myhtml_encoding_decode_shared_utf_16(data, res);
+ return myencoding_decode_shared_utf_16(data, res);
}
-enum myhtml_encoding_status myhtml_encoding_decode_x_user_defined(unsigned const char data, myhtml_encoding_result_t *res)
+myencoding_status_t myencoding_decode_x_user_defined(unsigned const char data, myencoding_result_t *res)
{
if(data <= 0x7F)
res->result = data;
else
res->result = 0xF780 + data - 0x80;
- return MyHTML_ENCODING_STATUS_OK;
+ return MyENCODING_STATUS_OK;
}
-void myhtml_encoding_result_clean(myhtml_encoding_result_t *res)
+void myencoding_result_clean(myencoding_result_t *res)
{
- memset(res, 0, sizeof(myhtml_encoding_result_t));
+ memset(res, 0, sizeof(myencoding_result_t));
}
-size_t myhtml_encoding_codepoint_ascii_length(size_t codepoint)
+size_t myencoding_codepoint_ascii_length(size_t codepoint)
{
if (codepoint <= 0x0000007F) {
return 1;
@@ -995,7 +993,31 @@ size_t myhtml_encoding_codepoint_ascii_length(size_t codepoint)
return 0;
}
-size_t myhtml_encoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data)
+size_t myencoding_ascii_utf_8_length(const unsigned char data)
+{
+ if (data < 0x80){
+ return 1;
+ }
+ else if ((data & 0xe0) == 0xc0) {
+ return 2;
+ }
+ else if ((data & 0xf0) == 0xe0) {
+ return 3;
+ }
+ else if ((data & 0xf8) == 0xf0) {
+ return 4;
+ }
+ else if ((data & 0xfc) == 0xf8) {
+ return 5;
+ }
+ else if ((data & 0xff) == 0xfc) {
+ return 6;
+ }
+
+ return 0;
+}
+
+size_t myencoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data)
{
/* 0x80 -- 10xxxxxx */
/* 0xC0 -- 110xxxxx */
@@ -1059,7 +1081,7 @@ size_t myhtml_encoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data)
return 0;
}
-size_t myhtml_encoding_codepoint_to_lowercase_ascii_utf_8(size_t codepoint, char *data)
+size_t myencoding_codepoint_to_lowercase_ascii_utf_8(size_t codepoint, char *data)
{
/* 0x80 -- 10xxxxxx */
/* 0xC0 -- 110xxxxx */
@@ -1070,7 +1092,7 @@ size_t myhtml_encoding_codepoint_to_lowercase_ascii_utf_8(size_t codepoint, char
if (codepoint <= 0x0000007F) {
/* 0xxxxxxx */
- data[0] = (char)myhtml_string_chars_lowercase_map[ codepoint ];
+ data[0] = (char)mycore_string_chars_lowercase_map[ codepoint ];
return 1;
}
else if (codepoint <= 0x000007FF) {
@@ -1123,7 +1145,7 @@ size_t myhtml_encoding_codepoint_to_lowercase_ascii_utf_8(size_t codepoint, char
return 0;
}
-size_t myhtml_encoding_ascii_utf_8_to_codepoint(const unsigned char* data, size_t* codepoint)
+size_t myencoding_ascii_utf_8_to_codepoint(const unsigned char* data, size_t* codepoint)
{
if (*data < 0x80){
/* 0xxxxxxx */
@@ -1158,7 +1180,7 @@ size_t myhtml_encoding_ascii_utf_8_to_codepoint(const unsigned char* data, size_
return 0;
}
-size_t myhtml_encoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data)
+size_t myencoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data)
{
if((codepoint >> 16)) {
codepoint -= 0x10000;
@@ -1180,29 +1202,29 @@ size_t myhtml_encoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data)
return 2;
}
-size_t myhtml_encoding_convert_to_ascii_utf_8(myhtml_string_raw_t* raw_str, const char* buff, size_t length, myhtml_encoding_t encoding)
+size_t myencoding_convert_to_ascii_utf_8(mycore_string_raw_t* raw_str, const char* buff, size_t length, myencoding_t encoding)
{
if(raw_str->data == NULL) {
raw_str->size = length + 1;
raw_str->length = 0;
- raw_str->data = myhtml_malloc(sizeof(char) * raw_str->size);
+ raw_str->data = mycore_malloc(sizeof(char) * raw_str->size);
if(raw_str->data == NULL)
return 0;
}
- myhtml_encoding_result_t res = {0};
+ myencoding_result_t res = {0};
unsigned const char* u_buff = (unsigned const char*)buff;
- const myhtml_encoding_custom_f func = myhtml_encoding_get_function_by_id(encoding);
+ const myencoding_custom_f func = myencoding_get_function_by_id(encoding);
size_t i;
for (i = 0; i < length; i++)
{
- if(func(u_buff[i], &res) == MyHTML_ENCODING_STATUS_OK) {
+ if(func(u_buff[i], &res) == MyENCODING_STATUS_OK) {
if((raw_str->length + 6) >= raw_str->size) {
size_t new_size = raw_str->length + 6 + (length / 2);
- char *new_data = myhtml_realloc(raw_str->data, sizeof(char) * new_size);
+ char *new_data = mycore_realloc(raw_str->data, sizeof(char) * new_size);
if(new_data == NULL) {
return 0;
@@ -1212,7 +1234,7 @@ size_t myhtml_encoding_convert_to_ascii_utf_8(myhtml_string_raw_t* raw_str, cons
raw_str->size = new_size;
}
- raw_str->length += myhtml_encoding_codepoint_to_ascii_utf_8(res.result, &raw_str->data[raw_str->length]);
+ raw_str->length += myencoding_codepoint_to_ascii_utf_8(res.result, &raw_str->data[raw_str->length]);
}
}
diff --git a/source/myencoding/encoding.h b/source/myencoding/encoding.h
new file mode 100644
index 0000000..fa43018
--- /dev/null
+++ b/source/myencoding/encoding.h
@@ -0,0 +1,160 @@
+/*
+ Copyright (C) 2015-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 MyENCODING_ENCODING_H
+#define MyENCODING_ENCODING_H
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+
+#include "myencoding/myosi.h"
+#include "mycore/utils.h"
+#include "mycore/mystring.h"
+
+struct myencoding_result {
+ unsigned long first;
+ unsigned long second;
+ unsigned long third;
+ unsigned long result;
+ unsigned long result_aux;
+ unsigned long flag;
+};
+
+struct myencoding_trigram {
+ const unsigned char trigram[3];
+ size_t value;
+};
+
+struct myencoding_trigram_result {
+ size_t count;
+ size_t value;
+};
+
+struct myencoding_unicode_result {
+ size_t count_ascii;
+ size_t count_good;
+ size_t count_bad;
+};
+
+struct myencoding_detect_name_entry {
+ const char* name;
+ size_t name_length;
+ const char* label;
+ size_t label_length;
+
+ myencoding_t encoding;
+
+ size_t next;
+ size_t curr;
+};
+
+struct myencoding_detect_attr {
+ size_t key_begin;
+ size_t key_length;
+ size_t value_begin;
+ size_t value_length;
+
+ myencoding_detect_attr_t *next;
+};
+
+struct myencoding_entry_name_index {
+ const char *name;
+ size_t length;
+};
+
+typedef myencoding_status_t (*myencoding_custom_f)(unsigned const char data, myencoding_result_t *res);
+
+myencoding_custom_f myencoding_get_function_by_id(myencoding_t idx);
+
+myencoding_status_t myencoding_decode_utf_8(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_ibm866(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_2(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_3(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_4(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_5(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_6(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_7(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_8(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_8_i(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_10(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_13(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_14(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_15(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_8859_16(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_koi8_r(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_koi8_u(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_macintosh(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_874(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1250(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1251(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1252(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1253(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1254(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1255(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1256(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1257(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_windows_1258(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_x_mac_cyrillic(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_gbk(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_gb18030(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_big5(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_euc_jp(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_iso_2022_jp(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_shift_jis(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_euc_kr(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_shared_utf_16(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_utf_16be(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_utf_16le(unsigned const char data, myencoding_result_t *res);
+myencoding_status_t myencoding_decode_x_user_defined(unsigned const char data, myencoding_result_t *res);
+
+size_t myencoding_codepoint_ascii_length(size_t codepoint);
+size_t myencoding_ascii_utf_8_length(const unsigned char data);
+
+size_t myencoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data);
+size_t myencoding_codepoint_to_lowercase_ascii_utf_8(size_t codepoint, char *data);
+size_t myencoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data);
+size_t myencoding_ascii_utf_8_to_codepoint(const unsigned char* data, size_t* codepoint);
+
+void myencoding_result_clean(myencoding_result_t *res);
+
+bool myencoding_detect(const char *text, size_t length, myencoding_t *encoding);
+bool myencoding_detect_russian(const char *text, size_t length, myencoding_t *encoding);
+bool myencoding_detect_unicode(const char *text, size_t length, myencoding_t *encoding);
+bool myencoding_detect_bom(const char *text, size_t length, myencoding_t *encoding);
+bool myencoding_detect_and_cut_bom(const char *text, size_t length, myencoding_t *encoding, const char **new_text, size_t *new_size);
+
+size_t myencoding_convert_to_ascii_utf_8(mycore_string_raw_t* raw_str, const char* buff, size_t length, myencoding_t encoding);
+
+const myencoding_detect_name_entry_t * myencoding_name_entry_by_name(const char* name, size_t length);
+bool myencoding_by_name(const char *name, size_t length, myencoding_t *encoding);
+const char * myencoding_name_by_id(myencoding_t encoding, size_t *length);
+
+bool myencoding_extracting_character_encoding_from_charset(const char *data, size_t data_size, myencoding_t *encoding);
+myencoding_t myencoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyENCODING_ENCODING_H */
diff --git a/source/myencoding/myosi.h b/source/myencoding/myosi.h
new file mode 100644
index 0000000..6939c44
--- /dev/null
+++ b/source/myencoding/myosi.h
@@ -0,0 +1,114 @@
+/*
+ Copyright (C) 2015-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 MyENCODING_MYOSI_H
+#define MyENCODING_MYOSI_H
+#pragma once
+
+#include "mycore/myosi.h"
+
+#define MyENCODING_VERSION_MAJOR 0
+#define MyENCODING_VERSION_MINOR 1
+#define MyENCODING_VERSION_PATCH 0
+
+#define MyENCODING_VERSION_STRING MyCORE_STR(MyENCODING_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyENCODING_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyENCODING_VERSION_PATCH)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// encoding
+// https://encoding.spec.whatwg.org/#the-encoding
+// https://encoding.spec.whatwg.org/#legacy-single-byte-encodings
+// https://encoding.spec.whatwg.org/#legacy-multi-byte-chinese-(simplified)-encodings
+// https://encoding.spec.whatwg.org/#legacy-multi-byte-chinese-(traditional)-encodings
+// https://encoding.spec.whatwg.org/#legacy-multi-byte-japanese-encodings
+// https://encoding.spec.whatwg.org/#legacy-multi-byte-korean-encodings
+// https://encoding.spec.whatwg.org/#legacy-miscellaneous-encodings
+
+enum myencoding_list {
+ MyENCODING_DEFAULT = 0x00,
+ //MyENCODING_AUTO = 0x01, // future
+ MyENCODING_NOT_DETERMINED = 0x02,
+ MyENCODING_UTF_8 = 0x00, // default encoding
+ MyENCODING_UTF_16LE = 0x04,
+ MyENCODING_UTF_16BE = 0x05,
+ MyENCODING_X_USER_DEFINED = 0x06,
+ MyENCODING_BIG5 = 0x07,
+ MyENCODING_EUC_JP = 0x08,
+ MyENCODING_EUC_KR = 0x09,
+ MyENCODING_GB18030 = 0x0a,
+ MyENCODING_GBK = 0x0b,
+ MyENCODING_IBM866 = 0x0c,
+ MyENCODING_ISO_2022_JP = 0x0d,
+ MyENCODING_ISO_8859_10 = 0x0e,
+ MyENCODING_ISO_8859_13 = 0x0f,
+ MyENCODING_ISO_8859_14 = 0x10,
+ MyENCODING_ISO_8859_15 = 0x11,
+ MyENCODING_ISO_8859_16 = 0x12,
+ MyENCODING_ISO_8859_2 = 0x13,
+ MyENCODING_ISO_8859_3 = 0x14,
+ MyENCODING_ISO_8859_4 = 0x15,
+ MyENCODING_ISO_8859_5 = 0x16,
+ MyENCODING_ISO_8859_6 = 0x17,
+ MyENCODING_ISO_8859_7 = 0x18,
+ MyENCODING_ISO_8859_8 = 0x19,
+ MyENCODING_ISO_8859_8_I = 0x1a,
+ MyENCODING_KOI8_R = 0x1b,
+ MyENCODING_KOI8_U = 0x1c,
+ MyENCODING_MACINTOSH = 0x1d,
+ MyENCODING_SHIFT_JIS = 0x1e,
+ MyENCODING_WINDOWS_1250 = 0x1f,
+ MyENCODING_WINDOWS_1251 = 0x20,
+ MyENCODING_WINDOWS_1252 = 0x21,
+ MyENCODING_WINDOWS_1253 = 0x22,
+ MyENCODING_WINDOWS_1254 = 0x23,
+ MyENCODING_WINDOWS_1255 = 0x24,
+ MyENCODING_WINDOWS_1256 = 0x25,
+ MyENCODING_WINDOWS_1257 = 0x26,
+ MyENCODING_WINDOWS_1258 = 0x27,
+ MyENCODING_WINDOWS_874 = 0x28,
+ MyENCODING_X_MAC_CYRILLIC = 0x29,
+ MyENCODING_LAST_ENTRY = 0x2a
+}
+typedef myencoding_t;
+
+enum myencoding_status {
+ MyENCODING_STATUS_OK = 0x0000,
+ MyENCODING_STATUS_ERROR = 0x0001,
+ MyENCODING_STATUS_CONTINUE = 0x0002,
+ MyENCODING_STATUS_DONE = 0x0004
+}
+typedef myencoding_status_t;
+
+typedef struct myencoding_result myencoding_result_t;
+typedef struct myencoding_trigram myencoding_trigram_t;
+typedef struct myencoding_trigram_result myencoding_trigram_result_t;
+typedef struct myencoding_unicode_result myencoding_unicode_result_t;
+typedef struct myencoding_detect_name_entry myencoding_detect_name_entry_t;
+typedef struct myencoding_detect_attr myencoding_detect_attr_t;
+typedef struct myencoding_entry_name_index myencoding_entry_name_index_t;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyENCODING_MYOSI_H */
+
diff --git a/source/myencoding/mystring.c b/source/myencoding/mystring.c
new file mode 100644
index 0000000..6c102a9
--- /dev/null
+++ b/source/myencoding/mystring.c
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 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 "myencoding/mystring.h"
+#include "mycore/utils/resources.h"
+
+void myencoding_string_append(mycore_string_t* str, const char* buff, size_t length, myencoding_t encoding)
+{
+ myencoding_result_t res;
+ myencoding_result_clean(&res);
+
+ myencoding_string_append_chunk(str, &res, buff, length, encoding);
+}
+
+void myencoding_string_append_chunk(mycore_string_t* str, myencoding_result_t* res, const char* buff, size_t length, myencoding_t encoding)
+{
+ unsigned const char* u_buff = (unsigned const char*)buff;
+ const myencoding_custom_f func = myencoding_get_function_by_id(encoding);
+
+ for (size_t i = 0; i < length; i++)
+ {
+ if(func(u_buff[i], res) == MyENCODING_STATUS_OK) {
+ MyCORE_STRING_REALLOC_IF_NEED(str, 5, 0);
+ str->length += myencoding_codepoint_to_ascii_utf_8(res->result, &str->data[str->length]);
+ }
+ }
+
+ MyCORE_STRING_APPEND_BYTE_WITHOUT_INCREMENT('\0', str, 1);
+}
+
+void myencoding_string_append_one(mycore_string_t* str, myencoding_result_t* res, const char data, myencoding_t encoding)
+{
+ const myencoding_custom_f func = myencoding_get_function_by_id(encoding);
+
+ if(func((unsigned const char)data, res) == MyENCODING_STATUS_OK) {
+ MyCORE_STRING_REALLOC_IF_NEED(str, 5, 0);
+ str->length += myencoding_codepoint_to_ascii_utf_8(res->result, &str->data[str->length]);
+
+ MyCORE_STRING_APPEND_BYTE_WITHOUT_INCREMENT_REALLOC('\0', str);
+ }
+}
+
+void myencoding_string_append_lowercase_ascii(mycore_string_t* str, const char* buff, size_t length, myencoding_t encoding)
+{
+ myencoding_result_t res;
+ myencoding_result_clean(&res);
+
+ myencoding_string_append_chunk_lowercase_ascii(str, &res, buff, length, encoding);
+}
+
+void myencoding_string_append_chunk_lowercase_ascii(mycore_string_t* str, myencoding_result_t* res, const char* buff, size_t length, myencoding_t encoding)
+{
+ unsigned const char* u_buff = (unsigned const char*)buff;
+ const myencoding_custom_f func = myencoding_get_function_by_id(encoding);
+
+ for (size_t i = 0; i < length; i++)
+ {
+ if(func(u_buff[i], res) == MyENCODING_STATUS_OK) {
+ MyCORE_STRING_REALLOC_IF_NEED(str, 5, 1);
+
+ size_t insert_len = myencoding_codepoint_to_ascii_utf_8(res->result, &str->data[str->length]);
+
+ if(insert_len == 1) {
+ str->data[str->length] = (const char)mycore_string_chars_lowercase_map[ u_buff[i] ];
+ }
+
+ str->length += insert_len;
+ }
+ }
+
+ MyCORE_STRING_APPEND_BYTE_WITHOUT_INCREMENT('\0', str, 1);
+}
diff --git a/source/myencoding/mystring.h b/source/myencoding/mystring.h
new file mode 100644
index 0000000..49ce8b6
--- /dev/null
+++ b/source/myencoding/mystring.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 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 MyENCODING_MYSTRING_H
+#define MyENCODING_MYSTRING_H
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "myencoding/myosi.h"
+#include "myencoding/encoding.h"
+#include "mycore/mystring.h"
+#include "mycore/utils.h"
+
+void myencoding_string_append(mycore_string_t* str, const char* buff, size_t length, myencoding_t encoding);
+
+/* append with convert encoding */
+void myencoding_string_append_chunk(mycore_string_t* str, myencoding_result_t* res, const char* buff, size_t length, myencoding_t encoding);
+void myencoding_string_append_one(mycore_string_t* str, myencoding_result_t* res, const char data, myencoding_t encoding);
+
+/* append with convert encoding lowercase */
+void myencoding_string_append_lowercase_ascii(mycore_string_t* str, const char* buff, size_t length, myencoding_t encoding);
+void myencoding_string_append_chunk_lowercase_ascii(mycore_string_t* str, myencoding_result_t* res, const char* buff, size_t length, myencoding_t encoding);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyENCODING_MYSTRING_H */
diff --git a/source/myhtml/encoding_resource.h b/source/myencoding/resource.h
index af6a763..12f4a73 100644
--- a/source/myhtml/encoding_resource.h
+++ b/source/myencoding/resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,17 +18,17 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/encoding.h"
+#include "myencoding/encoding.h"
-#ifndef MyHTML_ENCODING_RESOURCE_H
-#define MyHTML_ENCODING_RESOURCE_H
+#ifndef MyENCODING_RESOURCE_H
+#define MyENCODING_RESOURCE_H
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
-static const unsigned long myhtml_encoding_map_big5[] = {
+static const unsigned long myencoding_map_big5[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -2010,7 +2010,7 @@ static const unsigned long myhtml_encoding_map_big5[] = {
168205, 31188,
};
-static const unsigned long myhtml_encoding_map_euc_kr[] = {
+static const unsigned long myencoding_map_euc_kr[] = {
44034, 44035, 44037, 44038, 44043, 44044, 44045, 44046, 44047, 44056,
44062, 44063, 44065, 44066, 44067, 44069, 44070, 44071, 44072, 44073,
44074, 44075, 44078, 44082, 44083, 44084, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -4408,7 +4408,7 @@ static const unsigned long myhtml_encoding_map_euc_kr[] = {
};
-static const unsigned long myhtml_encoding_map_gb18030[] = {
+static const unsigned long myencoding_map_gb18030[] = {
19970, 19972, 19973, 19974, 19983, 19986, 19991, 19999, 20000, 20001,
20003, 20006, 20009, 20014, 20015, 20017, 20019, 20021, 20023, 20028,
20032, 20033, 20034, 20036, 20038, 20042, 20049, 20053, 20055, 20058,
@@ -6806,7 +6806,7 @@ static const unsigned long myhtml_encoding_map_gb18030[] = {
};
-static const unsigned long myhtml_encoding_map_gb18030_ranges[][2] = {
+static const unsigned long myencoding_map_gb18030_ranges[][2] = {
{0, 128}, {36, 165}, {38, 169}, {45, 178}, {50, 184},
{81, 216}, {89, 226}, {95, 235}, {96, 238}, {100, 244},
{103, 248}, {104, 251}, {105, 253}, {109, 258}, {126, 276},
@@ -6851,7 +6851,7 @@ static const unsigned long myhtml_encoding_map_gb18030_ranges[][2] = {
{39394, 65510}, {189000, 65536},
};
-static const unsigned long myhtml_encoding_map_ibm866[] = {
+static const unsigned long myencoding_map_ibm866[] = {
1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049,
1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059,
1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069,
@@ -6867,7 +6867,7 @@ static const unsigned long myhtml_encoding_map_ibm866[] = {
176, 8729, 183, 8730, 8470, 164, 9632, 160,
};
-static const unsigned long myhtml_encoding_map_iso_8859_10[] = {
+static const unsigned long myencoding_map_iso_8859_10[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6883,7 +6883,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_10[] = {
248, 371, 250, 251, 252, 253, 254, 312,
};
-static const unsigned long myhtml_encoding_map_iso_8859_13[] = {
+static const unsigned long myencoding_map_iso_8859_13[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6899,7 +6899,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_13[] = {
371, 322, 347, 363, 252, 380, 382, 8217,
};
-static const unsigned long myhtml_encoding_map_iso_8859_14[] = {
+static const unsigned long myencoding_map_iso_8859_14[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6915,7 +6915,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_14[] = {
248, 249, 250, 251, 252, 253, 375, 255,
};
-static const unsigned long myhtml_encoding_map_iso_8859_15[] = {
+static const unsigned long myencoding_map_iso_8859_15[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6931,7 +6931,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_15[] = {
248, 249, 250, 251, 252, 253, 254, 255,
};
-static const unsigned long myhtml_encoding_map_iso_8859_16[] = {
+static const unsigned long myencoding_map_iso_8859_16[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6947,7 +6947,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_16[] = {
369, 249, 250, 251, 252, 281, 539, 255,
};
-static const unsigned long myhtml_encoding_map_iso_8859_2[] = {
+static const unsigned long myencoding_map_iso_8859_2[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6963,7 +6963,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_2[] = {
345, 367, 250, 369, 252, 253, 355, 729,
};
-static const unsigned long myhtml_encoding_map_iso_8859_3[] = {
+static const unsigned long myencoding_map_iso_8859_3[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6979,7 +6979,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_3[] = {
285, 249, 250, 251, 252, 365, 349, 729,
};
-static const unsigned long myhtml_encoding_map_iso_8859_4[] = {
+static const unsigned long myencoding_map_iso_8859_4[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -6995,7 +6995,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_4[] = {
248, 371, 250, 251, 252, 361, 363, 729,
};
-static const unsigned long myhtml_encoding_map_iso_8859_5[] = {
+static const unsigned long myencoding_map_iso_8859_5[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -7011,7 +7011,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_5[] = {
1112, 1113, 1114, 1115, 1116, 167, 1118, 1119,
};
-static const unsigned long myhtml_encoding_map_iso_8859_6[] = {
+static const unsigned long myencoding_map_iso_8859_6[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -7027,7 +7027,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_6[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
};
-static const unsigned long myhtml_encoding_map_iso_8859_7[] = {
+static const unsigned long myencoding_map_iso_8859_7[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -7043,7 +7043,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_7[] = {
968, 969, 970, 971, 972, 973, 974, 0x0000,
};
-static const unsigned long myhtml_encoding_map_iso_8859_8[] = {
+static const unsigned long myencoding_map_iso_8859_8[] = {
128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
@@ -7059,7 +7059,7 @@ static const unsigned long myhtml_encoding_map_iso_8859_8[] = {
1512, 1513, 1514, 0x0000, 0x0000, 8206, 8207, 0x0000,
};
-static const unsigned long myhtml_encoding_map_jis0208[] = {
+static const unsigned long myencoding_map_jis0208[] = {
12288, 12289, 12290, 65292, 65294, 12539, 65306, 65307, 65311, 65281,
12443, 12444, 180, 65344, 168, 65342, 65507, 65343, 12541, 12542,
12445, 12446, 12291, 20189, 12293, 12294, 12295, 12540, 8213, 8208,
@@ -8191,7 +8191,7 @@ static const unsigned long myhtml_encoding_map_jis0208[] = {
};
-static const unsigned long myhtml_encoding_map_jis0212[] = {
+static const unsigned long myencoding_map_jis0212[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -9078,7 +9078,7 @@ static const unsigned long myhtml_encoding_map_jis0212[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
};
-static const unsigned long myhtml_encoding_map_koi8_r[] = {
+static const unsigned long myencoding_map_koi8_r[] = {
9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524,
9532, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 8992,
9632, 8729, 8730, 8776, 8804, 8805, 160, 8993, 176, 178,
@@ -9094,7 +9094,7 @@ static const unsigned long myhtml_encoding_map_koi8_r[] = {
1068, 1067, 1047, 1064, 1069, 1065, 1063, 1066,
};
-static const unsigned long myhtml_encoding_map_koi8_u[] = {
+static const unsigned long myencoding_map_koi8_u[] = {
9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524,
9532, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 8992,
9632, 8729, 8730, 8776, 8804, 8805, 160, 8993, 176, 178,
@@ -9110,7 +9110,7 @@ static const unsigned long myhtml_encoding_map_koi8_u[] = {
1068, 1067, 1047, 1064, 1069, 1065, 1063, 1066,
};
-static const unsigned long myhtml_encoding_map_macintosh[] = {
+static const unsigned long myencoding_map_macintosh[] = {
196, 197, 199, 201, 209, 214, 220, 225, 224, 226,
228, 227, 229, 231, 233, 232, 234, 235, 237, 236,
238, 239, 241, 243, 242, 244, 246, 245, 250, 249,
@@ -9126,7 +9126,7 @@ static const unsigned long myhtml_encoding_map_macintosh[] = {
175, 728, 729, 730, 184, 733, 731, 711,
};
-static const unsigned long myhtml_encoding_map_windows_1250[] = {
+static const unsigned long myencoding_map_windows_1250[] = {
8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240,
352, 8249, 346, 356, 381, 377, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 152, 8482, 353, 8250, 347, 357,
@@ -9142,7 +9142,7 @@ static const unsigned long myhtml_encoding_map_windows_1250[] = {
345, 367, 250, 369, 252, 253, 355, 729,
};
-static const unsigned long myhtml_encoding_map_windows_1251[] = {
+static const unsigned long myencoding_map_windows_1251[] = {
1026, 1027, 8218, 1107, 8222, 8230, 8224, 8225, 8364, 8240,
1033, 8249, 1034, 1036, 1035, 1039, 1106, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 152, 8482, 1113, 8250, 1114, 1116,
@@ -9158,7 +9158,7 @@ static const unsigned long myhtml_encoding_map_windows_1251[] = {
1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103,
};
-static const unsigned long myhtml_encoding_map_windows_1252[] = {
+static const unsigned long myencoding_map_windows_1252[] = {
8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240,
352, 8249, 338, 141, 381, 143, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157,
@@ -9174,7 +9174,7 @@ static const unsigned long myhtml_encoding_map_windows_1252[] = {
248, 249, 250, 251, 252, 253, 254, 255,
};
-static const unsigned long myhtml_encoding_map_windows_1253[] = {
+static const unsigned long myencoding_map_windows_1253[] = {
8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 136, 8240,
138, 8249, 140, 141, 142, 143, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 152, 8482, 154, 8250, 156, 157,
@@ -9190,7 +9190,7 @@ static const unsigned long myhtml_encoding_map_windows_1253[] = {
968, 969, 970, 971, 972, 973, 974, 0x0000,
};
-static const unsigned long myhtml_encoding_map_windows_1254[] = {
+static const unsigned long myencoding_map_windows_1254[] = {
8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240,
352, 8249, 338, 141, 142, 143, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157,
@@ -9206,7 +9206,7 @@ static const unsigned long myhtml_encoding_map_windows_1254[] = {
248, 249, 250, 251, 252, 305, 351, 255,
};
-static const unsigned long myhtml_encoding_map_windows_1255[] = {
+static const unsigned long myencoding_map_windows_1255[] = {
8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240,
138, 8249, 140, 141, 142, 143, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 732, 8482, 154, 8250, 156, 157,
@@ -9222,7 +9222,7 @@ static const unsigned long myhtml_encoding_map_windows_1255[] = {
1512, 1513, 1514, 0x0000, 0x0000, 8206, 8207, 0x0000,
};
-static const unsigned long myhtml_encoding_map_windows_1256[] = {
+static const unsigned long myencoding_map_windows_1256[] = {
8364, 1662, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240,
1657, 8249, 338, 1670, 1688, 1672, 1711, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 1705, 8482, 1681, 8250, 339, 8204,
@@ -9238,7 +9238,7 @@ static const unsigned long myhtml_encoding_map_windows_1256[] = {
1617, 249, 1618, 251, 252, 8206, 8207, 1746,
};
-static const unsigned long myhtml_encoding_map_windows_1257[] = {
+static const unsigned long myencoding_map_windows_1257[] = {
8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240,
138, 8249, 140, 168, 711, 184, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 152, 8482, 154, 8250, 156, 175,
@@ -9254,7 +9254,7 @@ static const unsigned long myhtml_encoding_map_windows_1257[] = {
371, 322, 347, 363, 252, 380, 382, 729,
};
-static const unsigned long myhtml_encoding_map_windows_1258[] = {
+static const unsigned long myencoding_map_windows_1258[] = {
8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240,
138, 8249, 338, 141, 142, 143, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 732, 8482, 154, 8250, 339, 157,
@@ -9270,7 +9270,7 @@ static const unsigned long myhtml_encoding_map_windows_1258[] = {
248, 249, 250, 251, 252, 432, 8363, 255,
};
-static const unsigned long myhtml_encoding_map_windows_874[] = {
+static const unsigned long myencoding_map_windows_874[] = {
8364, 129, 130, 131, 132, 8230, 134, 135, 136, 137,
138, 139, 140, 141, 142, 143, 144, 8216, 8217, 8220,
8221, 8226, 8211, 8212, 152, 153, 154, 155, 156, 157,
@@ -9286,7 +9286,7 @@ static const unsigned long myhtml_encoding_map_windows_874[] = {
3672, 3673, 3674, 3675, 0x0000, 0x0000, 0x0000, 0x0000,
};
-static const unsigned long myhtml_encoding_map_x_mac_cyrillic[] = {
+static const unsigned long myencoding_map_x_mac_cyrillic[] = {
1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049,
1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059,
1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069,
@@ -9302,28 +9302,75 @@ static const unsigned long myhtml_encoding_map_x_mac_cyrillic[] = {
1096, 1097, 1098, 1099, 1100, 1101, 1102, 8364,
};
-static const myhtml_encoding_custom_f myhtml_encoding_function_index[] = {
- myhtml_encoding_decode_utf_8, NULL, NULL, myhtml_encoding_decode_utf_8, myhtml_encoding_decode_utf_16le,
- myhtml_encoding_decode_utf_16be, myhtml_encoding_decode_x_user_defined,
- myhtml_encoding_decode_big5, myhtml_encoding_decode_euc_kr, myhtml_encoding_decode_gb18030,
- myhtml_encoding_decode_ibm866, myhtml_encoding_decode_iso_8859_10, myhtml_encoding_decode_iso_8859_13,
- myhtml_encoding_decode_iso_8859_14, myhtml_encoding_decode_iso_8859_15, myhtml_encoding_decode_iso_8859_16,
- myhtml_encoding_decode_iso_8859_2, myhtml_encoding_decode_iso_8859_3, myhtml_encoding_decode_iso_8859_4,
- myhtml_encoding_decode_iso_8859_5, myhtml_encoding_decode_iso_8859_6, myhtml_encoding_decode_iso_8859_7,
- myhtml_encoding_decode_iso_8859_8, myhtml_encoding_decode_koi8_r, myhtml_encoding_decode_koi8_u,
- myhtml_encoding_decode_macintosh, myhtml_encoding_decode_windows_1250, myhtml_encoding_decode_windows_1251,
- myhtml_encoding_decode_windows_1252, myhtml_encoding_decode_windows_1253, myhtml_encoding_decode_windows_1254,
- myhtml_encoding_decode_windows_1255, myhtml_encoding_decode_windows_1256, myhtml_encoding_decode_windows_1257,
- myhtml_encoding_decode_windows_1258, myhtml_encoding_decode_windows_874, myhtml_encoding_decode_x_mac_cyrillic,
- myhtml_encoding_decode_iso_2022_jp, myhtml_encoding_decode_gbk, myhtml_encoding_decode_shift_jis,
- myhtml_encoding_decode_euc_jp, myhtml_encoding_decode_iso_8859_8_i
+//static const myencoding_custom_f myencoding_function_index[] = {
+// myencoding_decode_utf_8, NULL, NULL, myencoding_decode_utf_8, myencoding_decode_utf_16le,
+// myencoding_decode_utf_16be, myencoding_decode_x_user_defined,
+// myencoding_decode_big5, myencoding_decode_euc_kr, myencoding_decode_gb18030,
+// myencoding_decode_ibm866, myencoding_decode_iso_8859_10, myencoding_decode_iso_8859_13,
+// myencoding_decode_iso_8859_14, myencoding_decode_iso_8859_15, myencoding_decode_iso_8859_16,
+// myencoding_decode_iso_8859_2, myencoding_decode_iso_8859_3, myencoding_decode_iso_8859_4,
+// myencoding_decode_iso_8859_5, myencoding_decode_iso_8859_6, myencoding_decode_iso_8859_7,
+// myencoding_decode_iso_8859_8, myencoding_decode_koi8_r, myencoding_decode_koi8_u,
+// myencoding_decode_macintosh, myencoding_decode_windows_1250, myencoding_decode_windows_1251,
+// myencoding_decode_windows_1252, myencoding_decode_windows_1253, myencoding_decode_windows_1254,
+// myencoding_decode_windows_1255, myencoding_decode_windows_1256, myencoding_decode_windows_1257,
+// myencoding_decode_windows_1258, myencoding_decode_windows_874, myencoding_decode_x_mac_cyrillic,
+// myencoding_decode_iso_2022_jp, myencoding_decode_gbk, myencoding_decode_shift_jis,
+// myencoding_decode_euc_jp, myencoding_decode_iso_8859_8_i
+//};
+
+static const myencoding_custom_f myencoding_function_index[] =
+{
+ myencoding_decode_utf_8, // MyENCODING_DEFAULT
+ NULL,
+ NULL,
+ myencoding_decode_utf_8, // MyENCODING_UTF_8
+ myencoding_decode_utf_16le, // MyENCODING_UTF_16LE
+ myencoding_decode_utf_16be, // MyENCODING_UTF_16BE
+ myencoding_decode_x_user_defined, // MyENCODING_X_USER_DEFINED
+ myencoding_decode_big5, // MyENCODING_BIG5
+ myencoding_decode_euc_jp, // MyENCODING_EUC_JP
+ myencoding_decode_euc_kr, // MyENCODING_EUC_KR
+ myencoding_decode_gb18030, // MyENCODING_GB18030
+ myencoding_decode_gbk, // MyENCODING_GBK
+ myencoding_decode_ibm866, // MyENCODING_IBM866
+ myencoding_decode_iso_2022_jp, // MyENCODING_ISO_2022_JP
+ myencoding_decode_iso_8859_10, // MyENCODING_ISO_8859_10
+ myencoding_decode_iso_8859_13, // MyENCODING_ISO_8859_13
+ myencoding_decode_iso_8859_14, // MyENCODING_ISO_8859_14
+ myencoding_decode_iso_8859_15, // MyENCODING_ISO_8859_15
+ myencoding_decode_iso_8859_16, // MyENCODING_ISO_8859_16
+ myencoding_decode_iso_8859_2, // MyENCODING_ISO_8859_2
+ myencoding_decode_iso_8859_3, // MyENCODING_ISO_8859_3
+ myencoding_decode_iso_8859_4, // MyENCODING_ISO_8859_4
+ myencoding_decode_iso_8859_5, // MyENCODING_ISO_8859_5
+ myencoding_decode_iso_8859_6, // MyENCODING_ISO_8859_6
+ myencoding_decode_iso_8859_7, // MyENCODING_ISO_8859_7
+ myencoding_decode_iso_8859_8, // MyENCODING_ISO_8859_8
+ myencoding_decode_iso_8859_8_i, // MyENCODING_ISO_8859_8_I
+ myencoding_decode_koi8_r, // MyENCODING_KOI8_R
+ myencoding_decode_koi8_u, // MyENCODING_KOI8_U
+ myencoding_decode_macintosh, // MyENCODING_MACINTOSH
+ myencoding_decode_shift_jis, // MyENCODING_SHIFT_JIS
+ myencoding_decode_windows_1250, // MyENCODING_WINDOWS_1250
+ myencoding_decode_windows_1251, // MyENCODING_WINDOWS_1251
+ myencoding_decode_windows_1252, // MyENCODING_WINDOWS_1252
+ myencoding_decode_windows_1253, // MyENCODING_WINDOWS_1253
+ myencoding_decode_windows_1254, // MyENCODING_WINDOWS_1254
+ myencoding_decode_windows_1255, // MyENCODING_WINDOWS_1255
+ myencoding_decode_windows_1256, // MyENCODING_WINDOWS_1256
+ myencoding_decode_windows_1257, // MyENCODING_WINDOWS_1257
+ myencoding_decode_windows_1258, // MyENCODING_WINDOWS_1258
+ myencoding_decode_windows_874, // MyENCODING_WINDOWS_874
+ myencoding_decode_x_mac_cyrillic, // MyENCODING_X_MAC_CYRILLIC
+ NULL,
};
#ifdef __cplusplus
} /* extern "C" */
#endif
-#endif /* MyHTML_ENCODING_RESOURCE_H */
+#endif /* MyENCODING_RESOURCE_H */
diff --git a/source/myfont/Makefile.mk b/source/myfont/Makefile.mk
index 273d845..91ea339 100644
--- a/source/myfont/Makefile.mk
+++ b/source/myfont/Makefile.mk
@@ -1,14 +1,13 @@
-find_files_h = $(wildcard $(SRCDIR)/myfont/$(dir)/*.h)
-find_files_c = $(wildcard $(SRCDIR)/myfont/$(dir)/*.c)
+myfont_dirs := .
+myfont_objs := $(call MODEST_UTILS_OBJS,myfont,$(myfont_dirs))
-SUBDIRS := .
-HDRS += $(foreach dir,$(SUBDIRS),$(find_files_h))
-SRCS += $(foreach dir,$(SUBDIRS),$(find_files_c))
+myfont_description := work with font, metrics, calculating size and more by https://www.microsoft.com/en-us/Typography/SpecificationsOverview.aspx
+myfont_dependencies := mycore myport
-myfont_clone: MyFONT_DIR_$(SUBDIRS)
- mkdir -p $(INCLUDE_TMP)/myfont
- cp $(SRCDIR)/myfont/*.h $(INCLUDE_TMP)/myfont
+myfont_all: $(myfont_objs)
-MyFONT_DIR_$(SUBDIRS):
- mkdir -p $(INCLUDE_TMP)/myfont/$(patsubst MyFONT_DIR_%,%,$@)
- cp $(SRCDIR)/myfont/$(patsubst MyFONT_DIR_%,%,$@)/*.h $(INCLUDE_TMP)/myfont/$(patsubst MyFONT_DIR_%,%,$@)/
+myfont_clean:
+ rm -f $(myfont_objs)
+
+myfont_clone:
+ $(call MODEST_UTILS_HDRS_CLONE,myfont,$(myfont_dirs))
diff --git a/source/myfont/cmap.c b/source/myfont/cmap.c
index 0bce7c2..59c504b 100644
--- a/source/myfont/cmap.c
+++ b/source/myfont/cmap.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,9 +20,9 @@
#include "myfont/cmap.h"
-myfont_status_t myfont_table_cmap_format_0(myfont_font_t *mf, myfont_tcmap_entry_t *entry, size_t offset)
+mystatus_t myfont_table_cmap_format_0(myfont_font_t *mf, myfont_tcmap_entry_t *entry, uint8_t* font_data, size_t data_size, size_t offset)
{
- if(mf->file_size < (offset + 260)) {
+ if(data_size < (offset + 260)) {
entry->header = NULL;
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
}
@@ -34,7 +34,7 @@ myfont_status_t myfont_table_cmap_format_0(myfont_font_t *mf, myfont_tcmap_entry
return MyFONT_STATUS_ERROR_MEMORY_ALLOCATION;
}
- uint8_t *data = &mf->file_data[offset];
+ uint8_t *data = &font_data[offset];
f0->length = myfont_read_u16(&data);
f0->language = myfont_read_u16(&data);
@@ -46,9 +46,9 @@ myfont_status_t myfont_table_cmap_format_0(myfont_font_t *mf, myfont_tcmap_entry
return MyFONT_STATUS_OK;
}
-myfont_status_t myfont_table_cmap_format_4(myfont_font_t *mf, myfont_tcmap_entry_t *entry, size_t offset)
+mystatus_t myfont_table_cmap_format_4(myfont_font_t *mf, myfont_tcmap_entry_t *entry, uint8_t* font_data, size_t data_size, size_t offset)
{
- uint8_t *data = &mf->file_data[offset];
+ uint8_t *data = &font_data[offset];
myfont_tcmap_format_4_t *f4 = (myfont_tcmap_format_4_t*)myfont_calloc(mf, 1, sizeof(myfont_tcmap_format_4_t));
@@ -57,7 +57,7 @@ myfont_status_t myfont_table_cmap_format_4(myfont_font_t *mf, myfont_tcmap_entry
offset += MyFONT_TCMAP_FORMAT_4_FIRST_LENGTH;
- if(mf->file_size < offset) {
+ if(data_size < offset) {
myfont_free(mf, f4);
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
}
@@ -73,7 +73,7 @@ myfont_status_t myfont_table_cmap_format_4(myfont_font_t *mf, myfont_tcmap_entry
f4->numGlyphId = ((f4->length - (16L + 8L * f4->segCount)) & 0xffff) / 2;
offset += sizeof(uint16_t) * (f4->segCount * 5);
- if(mf->file_size < offset)
+ if(data_size < offset)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
/* init mem */
@@ -137,7 +137,7 @@ myfont_status_t myfont_table_cmap_format_4(myfont_font_t *mf, myfont_tcmap_entry
return MyFONT_STATUS_OK;
}
-uint16_t myfont_glyph_index_by_code_format_0(myfont_tcmap_format_0_t *f0, unsigned long codepoint, myfont_status_t* status)
+uint16_t myfont_glyph_index_by_code_format_0(myfont_tcmap_format_0_t *f0, unsigned long codepoint, mystatus_t* status)
{
if(status)
*status = MyFONT_STATUS_OK;
@@ -151,7 +151,7 @@ uint16_t myfont_glyph_index_by_code_format_0(myfont_tcmap_format_0_t *f0, unsign
return 0;
}
-uint16_t myfont_glyph_index_by_code_format_4(myfont_tcmap_format_4_t *f4, unsigned long codepoint, myfont_status_t* status)
+uint16_t myfont_glyph_index_by_code_format_4(myfont_tcmap_format_4_t *f4, unsigned long codepoint, mystatus_t* status)
{
uint16_t i;
@@ -187,10 +187,10 @@ uint16_t myfont_glyph_index_by_code_format_4(myfont_tcmap_format_4_t *f4, unsign
return 0;
}
-uint16_t myfont_glyph_index_by_codepoint(myfont_font_t *mf, unsigned long codepoint, myfont_status_t* status)
+uint16_t myfont_glyph_index_by_codepoint(myfont_font_t *mf, unsigned long codepoint, mystatus_t* status)
{
uint16_t i, index = 0, tcout = mf->table_cmap.header.numTables;
- myfont_status_t mf_status;
+ mystatus_t mf_status;
for(i = 0; i < tcout; i++)
{
@@ -224,7 +224,7 @@ uint16_t myfont_glyph_index_by_codepoint(myfont_font_t *mf, unsigned long codepo
return 0;
}
-myfont_status_t myfont_load_table_cmap(myfont_font_t *mf)
+mystatus_t myfont_load_table_cmap(myfont_font_t *mf, uint8_t* font_data, size_t data_size)
{
myfont_table_cmap_t *tcmap = &mf->table_cmap;
const uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_cmap];
@@ -232,11 +232,11 @@ myfont_status_t myfont_load_table_cmap(myfont_font_t *mf)
if(table_offset == 0)
return MyFONT_STATUS_OK;
- if((table_offset + 4) > mf->file_size)
+ if((table_offset + 4) > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
/* get current data */
- uint8_t *data = &mf->file_data[table_offset];
+ uint8_t *data = &font_data[table_offset];
/* get header */
tcmap->header.version = myfont_read_u16(&data);
@@ -248,7 +248,7 @@ myfont_status_t myfont_load_table_cmap(myfont_font_t *mf)
size_t size_records = sizeof(myfont_tcmap_record_t) * tcmap->header.numTables;
size_t size_entries = sizeof(myfont_tcmap_entry_t) * tcmap->header.numTables;
- if(mf->file_size < (size_records + size_entries))
+ if(data_size < (size_records + size_entries))
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
if((tcmap->records = (myfont_tcmap_record_t *)myfont_malloc(mf, size_records)) == NULL)
@@ -271,19 +271,19 @@ myfont_status_t myfont_load_table_cmap(myfont_font_t *mf)
{
uint32_t offset = tcmap->records[i].offset + table_offset;
- if(mf->file_size <= offset)
+ if(data_size <= offset)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
- data = &mf->file_data[offset];
+ data = &font_data[offset];
tcmap->entries[i].format = myfont_read_u16(&data);
switch (tcmap->entries[i].format) {
case 0:
- myfont_table_cmap_format_0(mf, &tcmap->entries[i], (offset + 2));
+ myfont_table_cmap_format_0(mf, &tcmap->entries[i], font_data, data_size, (offset + 2));
break;
case 4:
- myfont_table_cmap_format_4(mf, &tcmap->entries[i], (offset + 2));
+ myfont_table_cmap_format_4(mf, &tcmap->entries[i], font_data, data_size, (offset + 2));
break;
default:
diff --git a/source/myfont/cmap.h b/source/myfont/cmap.h
index aeb671f..737a352 100644
--- a/source/myfont/cmap.h
+++ b/source/myfont/cmap.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -208,9 +208,9 @@ typedef myfont_table_cmap_t;
#include "myfont/myfont.h"
-myfont_status_t myfont_load_table_cmap(myfont_font_t *mf);
+mystatus_t myfont_load_table_cmap(myfont_font_t* mf, uint8_t* data, size_t data_size);
-uint16_t myfont_glyph_index_by_codepoint(myfont_font_t *mf, unsigned long char_code, myfont_status_t* status);
+uint16_t myfont_glyph_index_by_codepoint(myfont_font_t *mf, unsigned long char_code, mystatus_t* status);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myfont/glyf.c b/source/myfont/glyf.c
index 2b5851e..b284cd4 100644
--- a/source/myfont/glyf.c
+++ b/source/myfont/glyf.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "myfont/glyf.h"
-myfont_status_t myfont_load_table_glyf(struct myfont_font *mf)
+mystatus_t myfont_load_table_glyf(myfont_font_t* mf, uint8_t* font_data, size_t data_size)
{
memset(&mf->table_glyf, 0, sizeof(myfont_table_glyf_t));
@@ -38,7 +38,7 @@ myfont_status_t myfont_load_table_glyf(struct myfont_font *mf)
for(uint16_t i = 0; i < mf->table_maxp.numGlyphs; i++)
{
uint32_t offset = mf->cache.tables_offset[MyFONT_TKEY_glyf] + mf->table_loca.offsets[i];
- myfont_status_t status = myfont_glyf_load_data(mf, &glyphs[i], offset);
+ mystatus_t status = myfont_glyf_load_data(mf, &glyphs[i], font_data, data_size, offset);
if(status)
return status;
@@ -49,7 +49,7 @@ myfont_status_t myfont_load_table_glyf(struct myfont_font *mf)
return MyFONT_STATUS_OK;
}
-myfont_status_t myfont_glyf_load(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint16_t glyph_index)
+mystatus_t myfont_glyf_load(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t* font_data, size_t data_size, uint16_t glyph_index)
{
memset(glyph, 0, sizeof(myfont_table_glyph_t));
@@ -59,21 +59,21 @@ myfont_status_t myfont_glyf_load(myfont_font_t *mf, myfont_table_glyph_t *glyph,
uint16_t offset = myfont_loca_get_offset(mf, glyph_index);
offset += mf->cache.tables_offset[MyFONT_TKEY_glyf];
- return myfont_glyf_load_data(mf, glyph, offset);
+ return myfont_glyf_load_data(mf, glyph, font_data, data_size, offset);
}
-myfont_status_t myfont_glyf_load_data(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint32_t offset)
+mystatus_t myfont_glyf_load_data(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t* font_data, size_t data_size, uint32_t offset)
{
memset(&glyph->head, 0, sizeof(myfont_table_glyf_head_t));
+ /* get current data */
+ uint8_t *data = &font_data[offset];
+
// load head
offset += 10;
- if(offset > mf->file_size)
+ if(offset > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
- /* get current data */
- uint8_t *data = &mf->file_data[offset];
-
glyph->head.numberOfContours = myfont_read_16(&data);
glyph->head.xMin = myfont_read_16(&data);
glyph->head.yMin = myfont_read_16(&data);
@@ -81,12 +81,12 @@ myfont_status_t myfont_glyf_load_data(myfont_font_t *mf, myfont_table_glyph_t *g
glyph->head.yMax = myfont_read_16(&data);
if(glyph->head.numberOfContours > 0)
- return myfont_glyf_load_simple(mf, glyph, data, offset);
+ return myfont_glyf_load_simple(mf, glyph, data, data_size, offset);
return MyFONT_STATUS_OK;
}
-myfont_status_t myfont_glyf_load_simple(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, uint32_t offset)
+mystatus_t myfont_glyf_load_simple(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, size_t data_size, uint32_t offset)
{
uint16_t *endPtsOfContours = (uint16_t *)myfont_calloc(mf, glyph->head.numberOfContours, sizeof(uint16_t));
@@ -95,7 +95,7 @@ myfont_status_t myfont_glyf_load_simple(myfont_font_t *mf, myfont_table_glyph_t
offset = offset + (glyph->head.numberOfContours * 2) + 2;
- if(offset > mf->file_size)
+ if(offset > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
for(uint16_t i = 0; i < glyph->head.numberOfContours; i++) {
@@ -108,7 +108,7 @@ myfont_status_t myfont_glyf_load_simple(myfont_font_t *mf, myfont_table_glyph_t
/* instruction */
offset += glyph->simple.instructionLength;
- if(offset > mf->file_size)
+ if(offset > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
if(glyph->simple.instructionLength) {
@@ -121,10 +121,10 @@ myfont_status_t myfont_glyf_load_simple(myfont_font_t *mf, myfont_table_glyph_t
data += glyph->simple.instructionLength;
}
- return myfont_glyf_load_simple_flags(mf, glyph, data, offset);
+ return myfont_glyf_load_simple_flags(mf, glyph, data, data_size, offset);
}
-myfont_status_t myfont_glyf_load_simple_flags(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, uint32_t offset)
+mystatus_t myfont_glyf_load_simple_flags(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, size_t data_size, uint32_t offset)
{
uint8_t *flags = (uint8_t *)myfont_calloc(mf, glyph->pointCount, sizeof(uint8_t));
@@ -134,7 +134,7 @@ myfont_status_t myfont_glyf_load_simple_flags(myfont_font_t *mf, myfont_table_gl
uint16_t i = 0;
while(i < glyph->pointCount)
{
- if(offset >= mf->file_size) {
+ if(offset >= data_size) {
myfont_free(mf, flags);
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
}
@@ -143,7 +143,7 @@ myfont_status_t myfont_glyf_load_simple_flags(myfont_font_t *mf, myfont_table_gl
if(flags[i] & MyFONT_GLYF_SML_FLAGS_repeat)
{
- if(offset >= mf->file_size) {
+ if(offset >= data_size) {
myfont_free(mf, flags);
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
}
@@ -168,10 +168,10 @@ myfont_status_t myfont_glyf_load_simple_flags(myfont_font_t *mf, myfont_table_gl
glyph->simple.flags = flags;
- return myfont_glyf_load_simple_coordinates(mf, glyph, data, offset);
+ return myfont_glyf_load_simple_coordinates(mf, glyph, data, data_size, offset);
}
-myfont_status_t myfont_glyf_load_simple_coordinates(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, uint32_t offset)
+mystatus_t myfont_glyf_load_simple_coordinates(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, size_t data_size, uint32_t offset)
{
/* alloc resources */
int16_t *xCoordinates = (int16_t *)myfont_calloc(mf, glyph->pointCount, sizeof(int16_t));
@@ -192,7 +192,7 @@ myfont_status_t myfont_glyf_load_simple_coordinates(myfont_font_t *mf, myfont_ta
{
if(flags[i] & MyFONT_GLYF_SML_FLAGS_x_ShortVector)
{
- if(offset >= mf->file_size) {
+ if(offset >= data_size) {
myfont_free(mf, xCoordinates);
myfont_free(mf, yCoordinates);
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
@@ -209,7 +209,7 @@ myfont_status_t myfont_glyf_load_simple_coordinates(myfont_font_t *mf, myfont_ta
{
offset++;
- if(offset >= mf->file_size) {
+ if(offset >= data_size) {
myfont_free(mf, xCoordinates);
myfont_free(mf, yCoordinates);
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
@@ -232,7 +232,7 @@ myfont_status_t myfont_glyf_load_simple_coordinates(myfont_font_t *mf, myfont_ta
{
if(flags[i] & MyFONT_GLYF_SML_FLAGS_y_ShortVector)
{
- if(offset >= mf->file_size) {
+ if(offset >= data_size) {
myfont_free(mf, xCoordinates);
myfont_free(mf, yCoordinates);
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
@@ -248,7 +248,7 @@ myfont_status_t myfont_glyf_load_simple_coordinates(myfont_font_t *mf, myfont_ta
else {
offset++;
- if(offset >= mf->file_size) {
+ if(offset >= data_size) {
myfont_free(mf, xCoordinates);
myfont_free(mf, yCoordinates);
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
diff --git a/source/myfont/glyf.h b/source/myfont/glyf.h
index 4d853aa..b0ac56b 100644
--- a/source/myfont/glyf.h
+++ b/source/myfont/glyf.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -99,13 +99,13 @@ typedef myfont_table_glyf_t;
struct myfont_font;
-myfont_status_t myfont_load_table_glyf(struct myfont_font *mf);
+mystatus_t myfont_load_table_glyf(myfont_font_t *mf, uint8_t* data, size_t data_size);
-myfont_status_t myfont_glyf_load(struct myfont_font *mf, myfont_table_glyph_t *glyph, uint16_t glyph_index);
-myfont_status_t myfont_glyf_load_data(struct myfont_font *mf, myfont_table_glyph_t *glyph, uint32_t offset);
-myfont_status_t myfont_glyf_load_simple(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, uint32_t offset);
-myfont_status_t myfont_glyf_load_simple_flags(struct myfont_font *mf, myfont_table_glyph_t *glyph, uint8_t *data, uint32_t offset);
-myfont_status_t myfont_glyf_load_simple_coordinates(struct myfont_font *mf, myfont_table_glyph_t *glyph, uint8_t *data, uint32_t offset);
+mystatus_t myfont_glyf_load(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t* data, size_t data_size, uint16_t glyph_index);
+mystatus_t myfont_glyf_load_data(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t* data, size_t data_size, uint32_t offset);
+mystatus_t myfont_glyf_load_simple(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, size_t data_size, uint32_t offset);
+mystatus_t myfont_glyf_load_simple_flags(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, size_t data_size, uint32_t offset);
+mystatus_t myfont_glyf_load_simple_coordinates(myfont_font_t *mf, myfont_table_glyph_t *glyph, uint8_t *data, size_t data_size, uint32_t offset);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myfont/head.c b/source/myfont/head.c
index fed5822..8fe5648 100644
--- a/source/myfont/head.c
+++ b/source/myfont/head.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "myfont/head.h"
-myfont_status_t myfont_load_table_head(struct myfont_font *mf)
+mystatus_t myfont_load_table_head(myfont_font_t* mf, uint8_t* font_data, size_t data_size)
{
memset(&mf->table_head, 0, sizeof(myfont_table_head_t));
@@ -30,11 +30,11 @@ myfont_status_t myfont_load_table_head(struct myfont_font *mf)
myfont_table_head_t *thead = &mf->table_head;
const uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_head];
- if(mf->file_size < (table_offset + 16 + 4 + 16 + 8 + 4 + 6))
+ if(data_size < (table_offset + 16 + 4 + 16 + 8 + 4 + 6))
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
/* get current data */
- uint8_t *data = &mf->file_data[table_offset];
+ uint8_t *data = &font_data[table_offset];
/* u32 */
thead->version = myfont_read_u32(&data);
diff --git a/source/myfont/head.h b/source/myfont/head.h
index 770c886..89f71c9 100644
--- a/source/myfont/head.h
+++ b/source/myfont/head.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -53,9 +53,9 @@ typedef myfont_table_head_t;
struct myfont_font;
-myfont_status_t myfont_load_table_head(struct myfont_font *mf);
+mystatus_t myfont_load_table_head(myfont_font_t *mf, uint8_t* data, size_t data_size);
-float myfont_head_yMax_pixel(struct myfont_font *mf, float font_size);
+float myfont_head_yMax_pixel(myfont_font_t *mf, float font_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myfont/hhea.c b/source/myfont/hhea.c
index 92cd247..16b97d5 100644
--- a/source/myfont/hhea.c
+++ b/source/myfont/hhea.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "myfont/hhea.h"
-myfont_status_t myfont_load_table_hhea(myfont_font_t *mf)
+mystatus_t myfont_load_table_hhea(myfont_font_t* mf, uint8_t* font_data, size_t data_size)
{
memset(&mf->table_hhea, 0, sizeof(myfont_table_hhea_t));
@@ -30,11 +30,11 @@ myfont_status_t myfont_load_table_hhea(myfont_font_t *mf)
myfont_table_hhea_t *thhea = &mf->table_hhea;
const uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_hhea];
- if(mf->file_size < (table_offset + 8 + 6 + 2 + 22 + 2))
+ if(data_size < (table_offset + 8 + 6 + 2 + 22 + 2))
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
/* get current data */
- uint8_t *data = &mf->file_data[table_offset];
+ uint8_t *data = &font_data[table_offset];
thhea->version = myfont_read_u32(&data);
diff --git a/source/myfont/hhea.h b/source/myfont/hhea.h
index 794c5c9..4f5eb07 100644
--- a/source/myfont/hhea.h
+++ b/source/myfont/hhea.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -54,7 +54,7 @@ typedef myfont_table_hhea_t;
struct myfont_font;
-myfont_status_t myfont_load_table_hhea(struct myfont_font *mf);
+mystatus_t myfont_load_table_hhea(myfont_font_t *mf, uint8_t* data, size_t data_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myfont/hmtx.c b/source/myfont/hmtx.c
index e08c95f..96e10b7 100644
--- a/source/myfont/hmtx.c
+++ b/source/myfont/hmtx.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "myfont/hmtx.h"
-myfont_status_t myfont_load_table_hmtx(struct myfont_font *mf)
+mystatus_t myfont_load_table_hmtx(myfont_font_t* mf, uint8_t* font_data, size_t data_size)
{
memset(&mf->table_hmtx, 0, sizeof(myfont_table_hmtx_t));
@@ -31,13 +31,13 @@ myfont_status_t myfont_load_table_hmtx(struct myfont_font *mf)
const uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_hmtx];
/* get current data */
- uint8_t *data = &mf->file_data[table_offset];
+ uint8_t *data = &font_data[table_offset];
uint16_t num_metrics = mf->table_hhea.numberOfHMetrics;
if(num_metrics == 0)
return MyFONT_STATUS_OK;
- if(mf->file_size < (table_offset + (num_metrics * 2)))
+ if(data_size < (table_offset + (num_metrics * 2)))
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
myfont_long_hor_metric_t *lhor_metric = (myfont_long_hor_metric_t *)myfont_calloc(mf, num_metrics, sizeof(myfont_long_hor_metric_t));
diff --git a/source/myfont/hmtx.h b/source/myfont/hmtx.h
index c8368b6..ccc6d29 100644
--- a/source/myfont/hmtx.h
+++ b/source/myfont/hmtx.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -45,7 +45,7 @@ typedef myfont_table_hmtx_t;
struct myfont_font;
-myfont_status_t myfont_load_table_hmtx(struct myfont_font *mf);
+mystatus_t myfont_load_table_hmtx(myfont_font_t* mf, uint8_t* data, size_t data_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myfont/loca.c b/source/myfont/loca.c
index 27c5c43..33dcd4b 100644
--- a/source/myfont/loca.c
+++ b/source/myfont/loca.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "myfont/loca.h"
-myfont_status_t myfont_load_table_loca(struct myfont_font *mf)
+mystatus_t myfont_load_table_loca(myfont_font_t* mf, uint8_t* font_data, size_t data_size)
{
memset(&mf->table_loca, 0, sizeof(myfont_table_loca_t));
@@ -31,7 +31,7 @@ myfont_status_t myfont_load_table_loca(struct myfont_font *mf)
uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_loca];
/* get current data */
- uint8_t *data = &mf->file_data[table_offset];
+ uint8_t *data = &font_data[table_offset];
uint16_t numGlyph = mf->table_maxp.numGlyphs;
if(numGlyph == 0)
@@ -46,23 +46,23 @@ myfont_status_t myfont_load_table_loca(struct myfont_font *mf)
if(mf->table_head.indexToLocFormat)
{
- if(mf->file_size < (table_offset + (numGlyph * 4))) {
+ if(data_size < (table_offset + (numGlyph * 4))) {
myfont_free(mf, tloca->offsets);
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
}
- for(uint16_t i = 0; i < numGlyph; i++) {
+ for(size_t i = 0; i < numGlyph; i++) {
tloca->offsets[i] = myfont_read_u32(&data);
}
}
else
{
- if(mf->file_size < (table_offset + (numGlyph * 2))) {
+ if(data_size < (table_offset + (numGlyph * 2))) {
myfont_free(mf, tloca->offsets);
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
}
- for(uint16_t i = 0; i < numGlyph; i++) {
+ for(size_t i = 0; i < numGlyph; i++) {
tloca->offsets[i] = myfont_read_u16(&data) * 2;
}
}
diff --git a/source/myfont/loca.h b/source/myfont/loca.h
index bb6c13d..1d22f4f 100644
--- a/source/myfont/loca.h
+++ b/source/myfont/loca.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -38,9 +38,9 @@ typedef myfont_table_loca_t;
struct myfont_font;
-myfont_status_t myfont_load_table_loca(struct myfont_font *mf);
+mystatus_t myfont_load_table_loca(myfont_font_t *mf, uint8_t* data, size_t data_size);
-uint32_t myfont_loca_get_offset(struct myfont_font *mf, uint16_t glyph_index);
+uint32_t myfont_loca_get_offset(myfont_font_t *mf, uint16_t glyph_index);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myfont/maxp.c b/source/myfont/maxp.c
index bd652dc..a894522 100644
--- a/source/myfont/maxp.c
+++ b/source/myfont/maxp.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "myfont/maxp.h"
-myfont_status_t myfont_load_table_maxp(myfont_font_t *mf)
+mystatus_t myfont_load_table_maxp(myfont_font_t* mf, uint8_t* font_data, size_t data_size)
{
memset(&mf->table_maxp, 0, sizeof(myfont_table_maxp_t));
@@ -30,17 +30,17 @@ myfont_status_t myfont_load_table_maxp(myfont_font_t *mf)
myfont_table_maxp_t *tmaxp = &mf->table_maxp;
const uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_maxp];
- if((table_offset + 4) > mf->file_size)
+ if((table_offset + 4) > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
/* get current data */
- uint8_t *data = &mf->file_data[table_offset];
+ uint8_t *data = &font_data[table_offset];
tmaxp->version = myfont_read_u32_as_net(&data);
if(myfont_table_version_major(tmaxp->version) == 1)
{
- if((table_offset + 4 + 28) > mf->file_size)
+ if((table_offset + 4 + 28) > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
tmaxp->numGlyphs = myfont_read_u16(&data);
@@ -59,7 +59,7 @@ myfont_status_t myfont_load_table_maxp(myfont_font_t *mf)
tmaxp->maxComponentDepth = myfont_read_u16(&data);
}
else {
- if((table_offset + 4 + 2) > mf->file_size)
+ if((table_offset + 4 + 2) > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
tmaxp->numGlyphs = myfont_read_u16(&data);
diff --git a/source/myfont/maxp.h b/source/myfont/maxp.h
index 85fa03b..b24df05 100644
--- a/source/myfont/maxp.h
+++ b/source/myfont/maxp.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -51,7 +51,7 @@ typedef myfont_table_maxp_t;
struct myfont_font;
-myfont_status_t myfont_load_table_maxp(struct myfont_font *mf);
+mystatus_t myfont_load_table_maxp(myfont_font_t *mf, uint8_t* data, size_t data_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myfont/myfont.c b/source/myfont/myfont.c
index 9f3ac0d..4129add 100644
--- a/source/myfont/myfont.c
+++ b/source/myfont/myfont.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -32,19 +32,28 @@ const char myfont_table_name[][5] = {
myfont_font_t * myfont_create(void)
{
- return (myfont_font_t *)myhtml_calloc(1, sizeof(myfont_font_t));
+ return (myfont_font_t *)mycore_calloc(1, sizeof(myfont_font_t));
}
-myfont_status_t myfont_init(myfont_font_t *mf)
+mystatus_t myfont_init(myfont_font_t *mf)
{
- mf->mchar = mchar_async_create(64, (4096 * 2));
- mf->mchar_node_id = mchar_async_node_add(mf->mchar);
+ mystatus_t status;
+
+ mf->mchar = mchar_async_create();
+ if(mf->mchar == NULL)
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if((status = mchar_async_init(mf->mchar, 64, (4096 * 2))))
+ return status;
+
+ mf->mchar_node_id = mchar_async_node_add(mf->mchar, &status);
+
+ if(status)
+ return status;
memset(mf->cache.tables_offset, 0, sizeof(uint32_t) * MyFONT_TKEY_LAST_KEY);
memset(&mf->header, 0, sizeof(myfont_header_t));
- mf->file_path = NULL;
-
return MyFONT_STATUS_OK;
}
@@ -54,17 +63,6 @@ void myfont_clean(myfont_font_t *mf)
memset(mf->cache.tables_offset, 0, sizeof(uint32_t) * MyFONT_TKEY_LAST_KEY);
memset(&mf->header, 0, sizeof(myfont_header_t));
-
- if(mf->file_data) {
- myhtml_free(mf->file_data);
- mf->file_data = NULL;
- }
-
- if(mf->file_path) {
- myhtml_free(mf->file_path);
- mf->file_path = NULL;
- }
-
memset(mf, 0, sizeof(myfont_font_t));
}
@@ -75,18 +73,8 @@ myfont_font_t * myfont_destroy(myfont_font_t *mf, bool self_destroy)
mf->mchar = mchar_async_destroy(mf->mchar, 1);
- if(mf->file_data) {
- myhtml_free(mf->file_data);
- mf->file_data = NULL;
- }
-
- if(mf->file_path) {
- myhtml_free(mf->file_path);
- mf->file_path = NULL;
- }
-
if(self_destroy) {
- myhtml_free(mf);
+ mycore_free(mf);
return NULL;
}
@@ -111,53 +99,80 @@ void myfont_free(myfont_font_t *mf, void* data)
mchar_async_free(mf->mchar, mf->mchar_node_id, data);
}
-myfont_status_t myfont_load(myfont_font_t *mf, const char *filepath)
+mystatus_t myfont_load_from_file(myfont_font_t *mf, const char *filepath, uint8_t** return_data, size_t* data_size)
{
- FILE *fh = fopen(filepath, "rb");
+ if(return_data)
+ *return_data = NULL;
+
+ if(data_size)
+ *data_size = 0;
+
+ size_t file_data_size;
+
+ FILE *fh = mycore_fopen(filepath, "rb");
if(fh == NULL)
return MyFONT_STATUS_ERROR_FILE_OPEN;
- if(fseek(fh, 0L, SEEK_END)) {
- fclose(fh);
+ if(mycore_fseek(fh, 0L, SEEK_END)) {
+ mycore_fclose(fh);
return MyFONT_STATUS_ERROR_FILE_SEEK;
}
- long file_size = ftell(fh);
+ long file_size = mycore_ftell(fh);
if(file_size == -1) {
- fclose(fh);
+ mycore_fclose(fh);
return MyFONT_STATUS_ERROR_FILE_TELL;
}
- if(fseek(fh, 0L, SEEK_SET)) {
- fclose(fh);
+ if(mycore_fseek(fh, 0L, SEEK_SET)) {
+ mycore_fclose(fh);
return MyFONT_STATUS_ERROR_FILE_SEEK;
}
if(file_size > 0)
- mf->file_size = (size_t)file_size;
+ file_data_size = (size_t)file_size;
else {
- fclose(fh);
+ mycore_fclose(fh);
return MyFONT_STATUS_ERROR_FILE_TOO_SMALL;
}
- mf->file_data = (uint8_t*)myhtml_malloc(file_size);
+ uint8_t* data = (uint8_t*)mycore_malloc(file_size);
- if(mf->file_data == NULL) {
- fclose(fh);
+ if(data == NULL) {
+ mycore_fclose(fh);
return MyFONT_STATUS_ERROR_MEMORY_ALLOCATION;
}
- if(fread(mf->file_data, 1, file_size, fh) != file_size) {
- fclose(fh);
+ if(mycore_fread(data, 1, file_size, fh) != file_size) {
+ mycore_fclose(fh);
return MyFONT_STATUS_ERROR_FILE_READ;
}
- fclose(fh);
+ mycore_fclose(fh);
- if(mf->file_size < 12)
+ if(return_data)
+ *return_data = data;
+
+ if(data_size)
+ *data_size = file_data_size;
+
+ return myfont_load(mf, data, file_data_size);
+}
+
+void * myfont_destroy_font_data(myfont_font_t *mf, uint8_t* return_data)
+{
+ if(return_data)
+ return mycore_free(return_data);
+
+ return NULL;
+}
+
+mystatus_t myfont_load(myfont_font_t *mf, uint8_t* font_data, size_t data_size)
+{
+ if(data_size < 12)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
- uint8_t *data = mf->file_data;
+ uint8_t* data = font_data;
mf->header.version_major = myfont_read_u16(&data);
mf->header.version_minor = myfont_read_u16(&data);
@@ -166,7 +181,7 @@ myfont_status_t myfont_load(myfont_font_t *mf, const char *filepath)
mf->header.entrySelector = myfont_read_u16(&data);
mf->header.rangeShift = myfont_read_u16(&data);
- if(mf->file_size < (12 + (mf->header.numTables * 16)))
+ if(data_size < (12 + (mf->header.numTables * 16)))
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
for(uint16_t i = 0; i < mf->header.numTables; i++)
@@ -224,54 +239,48 @@ myfont_status_t myfont_load(myfont_font_t *mf, const char *filepath)
if(myfont_check_required_tables(mf))
return MyFONT_STATUS_ERROR_TABLE_LACKS_REQUIRED;
- mf->file_path = (char *)myhtml_calloc(strlen(filepath), sizeof(char));
+ mystatus_t status;
- if(mf->file_path) {
- strncpy(mf->file_path, filepath, strlen(filepath));
- }
-
- myfont_status_t status;
-
- if((status = myfont_load_table_cmap(mf)))
+ if((status = myfont_load_table_cmap(mf, font_data, data_size)))
return MyFONT_STATUS_ERROR_TABLE_LOAD_CMAP;
- if((status = myfont_load_table_head(mf)))
+ if((status = myfont_load_table_head(mf, font_data, data_size)))
return MyFONT_STATUS_ERROR_TABLE_LOAD_HEAD;
- if((status = myfont_load_table_name(mf)))
+ if((status = myfont_load_table_name(mf, font_data, data_size)))
return MyFONT_STATUS_ERROR_TABLE_LOAD_NAME;
- if((status = myfont_load_table_os_2(mf)))
+ if((status = myfont_load_table_os_2(mf, font_data, data_size)))
return MyFONT_STATUS_ERROR_TABLE_LOAD_OS_2;
- if((status = myfont_load_table_maxp(mf)))
+ if((status = myfont_load_table_maxp(mf, font_data, data_size)))
return MyFONT_STATUS_ERROR_TABLE_LOAD_MAXP;
- if((status = myfont_load_table_hhea(mf)))
+ if((status = myfont_load_table_hhea(mf, font_data, data_size)))
return MyFONT_STATUS_ERROR_TABLE_LOAD_HHEA;
- if((status = myfont_load_table_hmtx(mf)))
+ if((status = myfont_load_table_hmtx(mf, font_data, data_size)))
return MyFONT_STATUS_ERROR_TABLE_LOAD_HMTX;
- if((status = myfont_load_table_loca(mf)))
+ if((status = myfont_load_table_loca(mf, font_data, data_size)))
return MyFONT_STATUS_ERROR_TABLE_LOAD_LOCA;
- if((status = myfont_load_table_glyf(mf)))
+ if((status = myfont_load_table_glyf(mf, font_data, data_size)))
return MyFONT_STATUS_ERROR_TABLE_LOAD_GLYF;
- if((status = myfont_load_table_vhea(mf)))
+ if((status = myfont_load_table_vhea(mf, font_data, data_size)))
return MyFONT_STATUS_ERROR_TABLE_LOAD_VHEA;
- if((status = myfont_load_table_vmtx(mf)))
+ if((status = myfont_load_table_vmtx(mf, font_data, data_size)))
return MyFONT_STATUS_ERROR_TABLE_LOAD_VMTX;
- if((status = myfont_load_table_pclt(mf)))
+ if((status = myfont_load_table_pclt(mf, font_data, data_size)))
return MyFONT_STATUS_ERROR_TABLE_LOAD_PCLT;
return MyFONT_STATUS_OK;
}
-myfont_status_t myfont_check_required_tables(myfont_font_t *mf)
+mystatus_t myfont_check_required_tables(myfont_font_t *mf)
{
if(mf->cache.tables_offset[ MyFONT_TKEY_cmap ] == 0 ||
mf->cache.tables_offset[ MyFONT_TKEY_glyf ] == 0 ||
@@ -287,17 +296,6 @@ myfont_status_t myfont_check_required_tables(myfont_font_t *mf)
return MyFONT_STATUS_OK;
}
-void myfont_font_print_exists_table(myfont_font_t *mf, FILE *file)
-{
- size_t i;
- for(i = 0; i < MyFONT_TKEY_LAST_KEY; i++)
- {
- if(mf->cache.tables_offset[i]) {
- fprintf(file, "%s = %u\n", myfont_table_name[i], mf->cache.tables_offset[i]);
- }
- }
-}
-
// metrics
float myfont_metrics_baseline(myfont_font_t *mf, float font_size)
{
@@ -334,7 +332,7 @@ float myfont_metrics_x_height(myfont_font_t *mf, float font_size)
if(xheight == 0)
{
- myfont_status_t mf_status;
+ mystatus_t mf_status;
uint16_t glyph_index = myfont_glyph_index_by_codepoint(mf, (unsigned long)('x'), &mf_status);
if(mf_status == MyFONT_STATUS_OK) {
@@ -360,7 +358,7 @@ float myfont_metrics_cap_height(myfont_font_t *mf, float font_size)
if(cap_height == 0)
{
- myfont_status_t mf_status;
+ mystatus_t mf_status;
uint16_t glyph_index = myfont_glyph_index_by_codepoint(mf, (unsigned long)('H'), &mf_status);
if(mf_status == MyFONT_STATUS_OK) {
@@ -378,12 +376,12 @@ float myfont_metrics_font_height(myfont_font_t *mf, float font_size)
}
// width, height and ...
-float myfont_metrics_width(myfont_font_t *mf, unsigned long codepoint, float font_size, myfont_status_t* status)
+float myfont_metrics_width(myfont_font_t *mf, unsigned long codepoint, float font_size, mystatus_t* status)
{
if(mf->table_hhea.numberOfHMetrics == 0 || mf->table_hmtx.hMetrics == NULL)
return 0.0f;
- myfont_status_t mf_status;
+ mystatus_t mf_status;
uint16_t glyph_index = myfont_glyph_index_by_codepoint(mf, codepoint, &mf_status);
@@ -397,12 +395,12 @@ float myfont_metrics_width(myfont_font_t *mf, unsigned long codepoint, float fon
return (float)(mf->table_hmtx.hMetrics[glyph_index].advanceWidth) * font_size / (float)(mf->table_head.unitsPerEm);
}
-float myfont_metrics_height(myfont_font_t *mf, unsigned long codepoint, float font_size, myfont_status_t* status)
+float myfont_metrics_height(myfont_font_t *mf, unsigned long codepoint, float font_size, mystatus_t* status)
{
if(mf->table_vhea.numOfLongVerMetrics == 0 || mf->table_vmtx.vMetrics == NULL)
return myfont_metrics_font_height(mf, font_size);
- myfont_status_t mf_status;
+ mystatus_t mf_status;
uint16_t glyph_index = myfont_glyph_index_by_codepoint(mf, codepoint, &mf_status);
@@ -416,9 +414,9 @@ float myfont_metrics_height(myfont_font_t *mf, unsigned long codepoint, float fo
return (float)(mf->table_vmtx.vMetrics[glyph_index].advanceHeight) * font_size / (float)(mf->table_head.unitsPerEm);
}
-float myfont_metrics_glyph_offset_y(myfont_font_t *mf, unsigned long codepoint, float font_size, myfont_status_t* status)
+float myfont_metrics_glyph_offset_y(myfont_font_t *mf, unsigned long codepoint, float font_size, mystatus_t* status)
{
- myfont_status_t mf_status;
+ mystatus_t mf_status;
uint16_t glyph_index = myfont_glyph_index_by_codepoint(mf, codepoint, &mf_status);
diff --git a/source/myfont/myfont.h b/source/myfont/myfont.h
index 02755ab..6077be6 100644
--- a/source/myfont/myfont.h
+++ b/source/myfont/myfont.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -22,6 +22,8 @@
#define MyFONT_MyFONT_H
#pragma once
+#include <string.h>
+
#include "myfont/myosi.h"
#include "myfont/cmap.h"
#include "myfont/head.h"
@@ -36,7 +38,13 @@
#include "myfont/pclt.h"
#include "myfont/loca.h"
-#include "myhtml/utils/mchar_async.h"
+#include "mycore/utils/mchar_async.h"
+
+#define MyFONT_VERSION_MAJOR 0
+#define MyFONT_VERSION_MINOR 0
+#define MyFONT_VERSION_PATCH 2
+
+#define MyFONT_VERSION_STRING MyCORE_STR(MyFONT_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyFONT_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyFONT_VERSION_PATCH)
#ifdef __cplusplus
extern "C" {
@@ -83,16 +91,12 @@ struct myfont_font {
myfont_table_pclt_t table_pclt;
myfont_table_loca_t table_loca;
- char* file_path;
- size_t file_size;
- uint8_t* file_data;
-
mchar_async_t* mchar;
size_t mchar_node_id;
};
myfont_font_t * myfont_create(void);
-myfont_status_t myfont_init(myfont_font_t *mf);
+mystatus_t myfont_init(myfont_font_t *mf);
void myfont_clean(myfont_font_t *mf);
myfont_font_t * myfont_destroy(myfont_font_t *mf, bool self_destroy);
@@ -100,10 +104,11 @@ void * myfont_malloc(myfont_font_t* mf, size_t size);
void * myfont_calloc(myfont_font_t* mf, size_t count, size_t size);
void myfont_free(myfont_font_t *mf, void* data);
-myfont_status_t myfont_load(myfont_font_t *mf, const char *filepath);
+mystatus_t myfont_load(myfont_font_t* mf, uint8_t* data, size_t data_size);
+mystatus_t myfont_load_from_file(myfont_font_t* mf, const char* filepath, uint8_t** return_data, size_t* data_size);
+void * myfont_destroy_font_data(myfont_font_t* mf, uint8_t* return_data);
-void myfont_font_print_exists_table(myfont_font_t *mf, FILE *file);
-myfont_status_t myfont_check_required_tables(myfont_font_t *mf);
+mystatus_t myfont_check_required_tables(myfont_font_t *mf);
float myfont_metrics_baseline(myfont_font_t *mf, float font_size);
float myfont_metrics_ascender(myfont_font_t *mf, float font_size);
@@ -113,11 +118,11 @@ float myfont_metrics_x_height(myfont_font_t *mf, float font_size);
float myfont_metrics_cap_height(myfont_font_t *mf, float font_size);
float myfont_metrics_font_height(myfont_font_t *mf, float font_size);
-float myfont_metrics_width(myfont_font_t *mf, unsigned long codepoint, float font_size, myfont_status_t* status);
-float myfont_metrics_height(myfont_font_t *mf, unsigned long codepoint, float font_size, myfont_status_t* status);
-float myfont_metrics_glyph_offset_y(myfont_font_t *mf, unsigned long codepoint, float font_size, myfont_status_t* status);
+float myfont_metrics_width(myfont_font_t *mf, unsigned long codepoint, float font_size, mystatus_t* status);
+float myfont_metrics_height(myfont_font_t *mf, unsigned long codepoint, float font_size, mystatus_t* status);
+float myfont_metrics_glyph_offset_y(myfont_font_t *mf, unsigned long codepoint, float font_size, mystatus_t* status);
-myfont_status_t myfont_load_table(myfont_font_t *mf, void *table, size_t size, enum myfont_table_key tkey);
+mystatus_t myfont_load_table(myfont_font_t *mf, void *table, size_t size, enum myfont_table_key tkey);
int16_t myfont_table_version_major(uint32_t version);
int16_t myfont_table_version_minor(uint32_t version);
diff --git a/source/myfont/myosi.c b/source/myfont/myosi.c
index 39cb0d4..e252208 100644
--- a/source/myfont/myosi.c
+++ b/source/myfont/myosi.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
diff --git a/source/myfont/myosi.h b/source/myfont/myosi.h
index 35904b8..80612f9 100644
--- a/source/myfont/myosi.h
+++ b/source/myfont/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -85,7 +85,6 @@ extern "C" {
// base
/*
Very important!!!
- see modest/myosi.h:modest_status_t
*/
enum myfont_status {
MyFONT_STATUS_OK = 0x000000,
diff --git a/source/myfont/name.c b/source/myfont/name.c
index e2f0c33..a89371e 100644
--- a/source/myfont/name.c
+++ b/source/myfont/name.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "myfont/name.h"
-myfont_status_t myfont_load_table_name(myfont_font_t *mf)
+mystatus_t myfont_load_table_name(myfont_font_t *mf, uint8_t* font_data, size_t data_size)
{
memset(&mf->table_name, 0, sizeof(myfont_table_name_t));
@@ -31,18 +31,18 @@ myfont_status_t myfont_load_table_name(myfont_font_t *mf)
const uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_name];
uint32_t pos = table_offset + 6;
- if(pos > mf->file_size)
+ if(pos > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
/* get current data */
- uint8_t *data = &mf->file_data[table_offset];
+ uint8_t *data = &font_data[table_offset];
tname->format = myfont_read_u16(&data);
tname->count = myfont_read_u16(&data);
tname->stringOffset = myfont_read_u16(&data);
pos = pos + (tname->count * 12);
- if(pos > mf->file_size) {
+ if(pos > data_size) {
tname->count = 0;
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
}
@@ -66,13 +66,13 @@ myfont_status_t myfont_load_table_name(myfont_font_t *mf)
if(tname->format == 1)
{
pos += 2;
- if(pos > mf->file_size)
+ if(pos > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
tname->langTagCount = myfont_read_u16(&data);
pos = pos + (tname->langTagCount * 4);
- if(pos > mf->file_size) {
+ if(pos > data_size) {
tname->langTagCount = 0;
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
}
diff --git a/source/myfont/name.h b/source/myfont/name.h
index ffcbe0a..7520f20 100644
--- a/source/myfont/name.h
+++ b/source/myfont/name.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -60,8 +60,8 @@ typedef myfont_table_name_t;
struct myfont_font;
-myfont_status_t myfont_load_table_name(struct myfont_font *mf);
-
+mystatus_t myfont_load_table_name(myfont_font_t *mf, uint8_t* data, size_t data_size);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/source/myfont/os_2.c b/source/myfont/os_2.c
index fc4c8bc..4b5e077 100644
--- a/source/myfont/os_2.c
+++ b/source/myfont/os_2.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "myfont/os_2.h"
-myfont_status_t myfont_load_table_os_2(myfont_font_t *mf)
+mystatus_t myfont_load_table_os_2(myfont_font_t* mf, uint8_t* font_data, size_t data_size)
{
memset(&mf->table_os_2, 0, sizeof(myfont_table_os_2_t));
@@ -31,10 +31,10 @@ myfont_status_t myfont_load_table_os_2(myfont_font_t *mf)
const uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_OS_2];
/* get current data */
- uint8_t *data = &mf->file_data[table_offset];
+ uint8_t *data = &font_data[table_offset];
uint32_t pos = table_offset + 32 + 10 + 16 + 4 + 16;
- if(pos > mf->file_size)
+ if(pos > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
tos_2->version = myfont_read_u16(&data);
@@ -77,7 +77,7 @@ myfont_status_t myfont_load_table_os_2(myfont_font_t *mf)
switch (tos_2->version) {
case 1:
pos += 8;
- if(pos > mf->file_size)
+ if(pos > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
tos_2->ulCodePageRange1 = myfont_read_u32(&data);
@@ -88,7 +88,7 @@ myfont_status_t myfont_load_table_os_2(myfont_font_t *mf)
case 3:
case 4:
pos += 18;
- if(pos > mf->file_size)
+ if(pos > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
tos_2->ulCodePageRange1 = myfont_read_u32(&data);
@@ -102,7 +102,7 @@ myfont_status_t myfont_load_table_os_2(myfont_font_t *mf)
break;
case 5:
pos += 22;
- if(pos > mf->file_size)
+ if(pos > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
tos_2->ulCodePageRange1 = myfont_read_u32(&data);
diff --git a/source/myfont/os_2.h b/source/myfont/os_2.h
index c1550f1..323c76a 100644
--- a/source/myfont/os_2.h
+++ b/source/myfont/os_2.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -90,9 +90,9 @@ typedef myfont_table_os_2_t;
struct myfont_font;
-myfont_status_t myfont_load_table_os_2(struct myfont_font *mf);
+mystatus_t myfont_load_table_os_2(myfont_font_t* mf, uint8_t* data, size_t data_size);
-int8_t myfont_os_2_panose(struct myfont_font *mf, myfont_table_os_2_panose_t id);
+int8_t myfont_os_2_panose(myfont_font_t* mf, myfont_table_os_2_panose_t id);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myfont/pclt.c b/source/myfont/pclt.c
index ec6b04a..85d86a0 100644
--- a/source/myfont/pclt.c
+++ b/source/myfont/pclt.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "myfont/pclt.h"
-myfont_status_t myfont_load_table_pclt(struct myfont_font *mf)
+mystatus_t myfont_load_table_pclt(myfont_font_t* mf, uint8_t* font_data, size_t data_size)
{
memset(&mf->table_pclt, 0, sizeof(myfont_table_pclt_t));
@@ -31,11 +31,11 @@ myfont_status_t myfont_load_table_pclt(struct myfont_font *mf)
const uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_PCLT];
uint32_t pos = table_offset + 4 + 16 + 16 + 8 + 6 + 4;
- if(pos > mf->file_size)
+ if(pos > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
/* get current data */
- uint8_t *data = &mf->file_data[table_offset];
+ uint8_t *data = &font_data[table_offset];
tpclt->version = myfont_read_u32_as_net(&data);
diff --git a/source/myfont/pclt.h b/source/myfont/pclt.h
index 9d44bd0..9b1054d 100644
--- a/source/myfont/pclt.h
+++ b/source/myfont/pclt.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -52,7 +52,7 @@ typedef myfont_table_pclt_t;
struct myfont_font;
-myfont_status_t myfont_load_table_pclt(struct myfont_font *mf);
+mystatus_t myfont_load_table_pclt(myfont_font_t* mf, uint8_t* data, size_t data_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myfont/vhea.c b/source/myfont/vhea.c
index d0b7b16..8657594 100644
--- a/source/myfont/vhea.c
+++ b/source/myfont/vhea.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "myfont/vhea.h"
-myfont_status_t myfont_load_table_vhea(myfont_font_t *mf)
+mystatus_t myfont_load_table_vhea(myfont_font_t *mf, uint8_t* font_data, size_t data_size)
{
memset(&mf->table_vhea, 0, sizeof(myfont_table_vhea_t));
@@ -30,11 +30,11 @@ myfont_status_t myfont_load_table_vhea(myfont_font_t *mf)
myfont_table_vhea_t *tvhea = &mf->table_vhea;
const uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_vhea];
- if((table_offset + 4 + 32) > mf->file_size)
+ if((table_offset + 4 + 32) > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
/* get current data */
- uint8_t *data = &mf->file_data[table_offset];
+ uint8_t *data = &font_data[table_offset];
tvhea->version = myfont_read_u32_as_net(&data);
tvhea->Ascender = myfont_read_16(&data);
diff --git a/source/myfont/vhea.h b/source/myfont/vhea.h
index bb89d14..fb29222 100644
--- a/source/myfont/vhea.h
+++ b/source/myfont/vhea.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -54,7 +54,7 @@ typedef myfont_table_vhea_t;
struct myfont_font;
-myfont_status_t myfont_load_table_vhea(struct myfont_font *mf);
+mystatus_t myfont_load_table_vhea(myfont_font_t* mf, uint8_t* data, size_t data_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myfont/vmtx.c b/source/myfont/vmtx.c
index 3f986b6..2c13652 100644
--- a/source/myfont/vmtx.c
+++ b/source/myfont/vmtx.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -20,7 +20,7 @@
#include "myfont/vmtx.h"
-myfont_status_t myfont_load_table_vmtx(myfont_font_t *mf)
+mystatus_t myfont_load_table_vmtx(myfont_font_t* mf, uint8_t* font_data, size_t data_size)
{
memset(&mf->table_vmtx, 0, sizeof(myfont_table_vmtx_t));
@@ -31,14 +31,14 @@ myfont_status_t myfont_load_table_vmtx(myfont_font_t *mf)
const uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_vmtx];
/* get current data */
- uint8_t *data = &mf->file_data[table_offset];
+ uint8_t *data = &font_data[table_offset];
uint16_t num_metrics = mf->table_vhea.numOfLongVerMetrics;
if(num_metrics == 0)
return MyFONT_STATUS_OK;
uint32_t pos = table_offset + (num_metrics * 4);
- if(pos > mf->file_size)
+ if(pos > data_size)
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
myfont_long_ver_metric_t *lver_metric = (myfont_long_ver_metric_t *)myfont_calloc(mf, num_metrics, sizeof(myfont_long_ver_metric_t));
@@ -60,7 +60,7 @@ myfont_status_t myfont_load_table_vmtx(myfont_font_t *mf)
pos = pos + (numOfTSB * 2);
- if(pos > mf->file_size) {
+ if(pos > data_size) {
myfont_free(mf, lver_metric);
return MyFONT_STATUS_ERROR_TABLE_UNEXPECTED_ENDING;
}
diff --git a/source/myfont/vmtx.h b/source/myfont/vmtx.h
index 7caa8fe..148563b 100644
--- a/source/myfont/vmtx.h
+++ b/source/myfont/vmtx.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -45,7 +45,7 @@ typedef myfont_table_vmtx_t;
struct myfont_font;
-myfont_status_t myfont_load_table_vmtx(struct myfont_font *mf);
+mystatus_t myfont_load_table_vmtx(myfont_font_t* mf, uint8_t* data, size_t data_size);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myhtml/Makefile.mk b/source/myhtml/Makefile.mk
index 81d5d63..b4b30cb 100644
--- a/source/myhtml/Makefile.mk
+++ b/source/myhtml/Makefile.mk
@@ -1,14 +1,13 @@
-find_files_h = $(wildcard $(SRCDIR)/myhtml/$(dir)/*.h)
-find_files_c = $(wildcard $(SRCDIR)/myhtml/$(dir)/*.c)
+myhtml_dirs := .
+myhtml_objs := $(call MODEST_UTILS_OBJS,myhtml,$(myhtml_dirs))
-SUBDIRS := . utils
-HDRS += $(foreach dir,$(SUBDIRS),$(find_files_h))
-SRCS += $(foreach dir,$(SUBDIRS),$(find_files_c))
+myhtml_description := HTML parser by https://html.spec.whatwg.org/multipage/
+myhtml_dependencies := mycore myencoding myport
-myhtml_clone: MyHTML_DIR_$(SUBDIRS)
- mkdir -p $(INCLUDE_TMP)/myhtml/utils
- cp $(SRCDIR)/myhtml/utils/*.h $(INCLUDE_TMP)/myhtml/utils
+myhtml_all: $(myhtml_objs)
-MyHTML_DIR_$(SUBDIRS):
- mkdir -p $(INCLUDE_TMP)/myhtml/$(patsubst MyHTML_DIR_%,%,$@)
- cp $(SRCDIR)/myhtml/$(patsubst MyHTML_DIR_%,%,$@)/*.h $(INCLUDE_TMP)/myhtml/$(patsubst MyHTML_DIR_%,%,$@)/
+myhtml_clean:
+ rm -f $(myhtml_objs)
+
+myhtml_clone:
+ $(call MODEST_UTILS_HDRS_CLONE,myhtml,$(myhtml_dirs))
diff --git a/source/myhtml/api.h b/source/myhtml/api.h
index e7eb4a6..9599750 100755
--- a/source/myhtml/api.h
+++ b/source/myhtml/api.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -34,14 +34,22 @@
*
*/
-#define MyHTML_VERSION_MAJOR 3
+#define MyHTML_VERSION_MAJOR 4
#define MyHTML_VERSION_MINOR 0
#define MyHTML_VERSION_PATCH 0
+#define MyHTML_VERSION_STRING MyCORE_STR(MyHTML_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyHTML_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyHTML_VERSION_PATCH)
+
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
+#include <mycore/myosi.h>
+#include <mycore/incoming.h>
+#include <mycore/mystring.h>
+#include <mycore/utils/mchar_async.h>
+#include <myencoding/myosi.h>
+
#if defined(_MSC_VER)
# define MyHTML_DEPRECATED(func) __declspec(deprecated) func
#elif defined(__GNUC__) || defined(__INTEL_COMPILER)
@@ -55,56 +63,6 @@ extern "C" {
#endif
/**
- * encodings type
- */
-enum myhtml_encoding_list {
- MyHTML_ENCODING_DEFAULT = 0x00,
-// MyHTML_ENCODING_AUTO = 0x01, // future
- MyHTML_ENCODING_NOT_DETERMINED = 0x02,
- MyHTML_ENCODING_UTF_8 = 0x00, // default encoding
- MyHTML_ENCODING_UTF_16LE = 0x04,
- MyHTML_ENCODING_UTF_16BE = 0x05,
- MyHTML_ENCODING_X_USER_DEFINED = 0x06,
- MyHTML_ENCODING_BIG5 = 0x07,
- MyHTML_ENCODING_EUC_JP = 0x08,
- MyHTML_ENCODING_EUC_KR = 0x09,
- MyHTML_ENCODING_GB18030 = 0x0a,
- MyHTML_ENCODING_GBK = 0x0b,
- MyHTML_ENCODING_IBM866 = 0x0c,
- MyHTML_ENCODING_ISO_2022_JP = 0x0d,
- MyHTML_ENCODING_ISO_8859_10 = 0x0e,
- MyHTML_ENCODING_ISO_8859_13 = 0x0f,
- MyHTML_ENCODING_ISO_8859_14 = 0x10,
- MyHTML_ENCODING_ISO_8859_15 = 0x11,
- MyHTML_ENCODING_ISO_8859_16 = 0x12,
- MyHTML_ENCODING_ISO_8859_2 = 0x13,
- MyHTML_ENCODING_ISO_8859_3 = 0x14,
- MyHTML_ENCODING_ISO_8859_4 = 0x15,
- MyHTML_ENCODING_ISO_8859_5 = 0x16,
- MyHTML_ENCODING_ISO_8859_6 = 0x17,
- MyHTML_ENCODING_ISO_8859_7 = 0x18,
- MyHTML_ENCODING_ISO_8859_8 = 0x19,
- MyHTML_ENCODING_ISO_8859_8_I = 0x1a,
- MyHTML_ENCODING_KOI8_R = 0x1b,
- MyHTML_ENCODING_KOI8_U = 0x1c,
- MyHTML_ENCODING_MACINTOSH = 0x1d,
- MyHTML_ENCODING_SHIFT_JIS = 0x1e,
- MyHTML_ENCODING_WINDOWS_1250 = 0x1f,
- MyHTML_ENCODING_WINDOWS_1251 = 0x20,
- MyHTML_ENCODING_WINDOWS_1252 = 0x21,
- MyHTML_ENCODING_WINDOWS_1253 = 0x22,
- MyHTML_ENCODING_WINDOWS_1254 = 0x23,
- MyHTML_ENCODING_WINDOWS_1255 = 0x24,
- MyHTML_ENCODING_WINDOWS_1256 = 0x25,
- MyHTML_ENCODING_WINDOWS_1257 = 0x26,
- MyHTML_ENCODING_WINDOWS_1258 = 0x27,
- MyHTML_ENCODING_WINDOWS_874 = 0x28,
- MyHTML_ENCODING_X_MAC_CYRILLIC = 0x29,
- MyHTML_ENCODING_LAST_ENTRY = 0x2a
-}
-typedef myhtml_encoding_t;
-
-/**
* @struct basic tag ids
*/
enum myhtml_tags {
@@ -384,54 +342,27 @@ enum myhtml_status {
MyHTML_STATUS_OK = 0x0000,
MyHTML_STATUS_ERROR = 0x0001,
MyHTML_STATUS_ERROR_MEMORY_ALLOCATION = 0x0002,
- MyHTML_STATUS_THREAD_ERROR_MEMORY_ALLOCATION = 0x0009,
- MyHTML_STATUS_THREAD_ERROR_LIST_INIT = 0x000a,
- MyHTML_STATUS_THREAD_ERROR_ATTR_MALLOC = 0x000b,
- MyHTML_STATUS_THREAD_ERROR_ATTR_INIT = 0x000c,
- MyHTML_STATUS_THREAD_ERROR_ATTR_SET = 0x000d,
- MyHTML_STATUS_THREAD_ERROR_ATTR_DESTROY = 0x000e,
- MyHTML_STATUS_THREAD_ERROR_NO_SLOTS = 0x000f,
- MyHTML_STATUS_THREAD_ERROR_BATCH_INIT = 0x0010,
- MyHTML_STATUS_THREAD_ERROR_WORKER_MALLOC = 0x0011,
- MyHTML_STATUS_THREAD_ERROR_WORKER_SEM_CREATE = 0x0012,
- MyHTML_STATUS_THREAD_ERROR_WORKER_THREAD_CREATE = 0x0013,
- MyHTML_STATUS_THREAD_ERROR_MASTER_THREAD_CREATE = 0x0014,
- MyHTML_STATUS_THREAD_ERROR_SEM_PREFIX_MALLOC = 0x0032,
- MyHTML_STATUS_THREAD_ERROR_SEM_CREATE = 0x0033,
- MyHTML_STATUS_THREAD_ERROR_QUEUE_MALLOC = 0x003c,
- MyHTML_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC = 0x003d,
- MyHTML_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC = 0x003e,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_MALLOC = 0x0046,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_INIT = 0x0047,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_LOCK = 0x0048,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_UNLOCK = 0x0049,
- MyHTML_STATUS_RULES_ERROR_MEMORY_ALLOCATION = 0x0064,
- MyHTML_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF = 0x00c8,
- MyHTML_STATUS_PERF_ERROR_FIND_CPU_CLOCK = 0x00c9,
- MyHTML_STATUS_TOKENIZER_ERROR_MEMORY_ALLOCATION = 0x012c,
- MyHTML_STATUS_TOKENIZER_ERROR_FRAGMENT_INIT = 0x012d,
- MyHTML_STATUS_TAGS_ERROR_MEMORY_ALLOCATION = 0x0190,
- MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE = 0x0191,
- MyHTML_STATUS_TAGS_ERROR_MCOBJECT_MALLOC = 0x0192,
- MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE_NODE = 0x0193,
- MyHTML_STATUS_TAGS_ERROR_CACHE_MEMORY_ALLOCATION = 0x0194,
- MyHTML_STATUS_TAGS_ERROR_INDEX_MEMORY_ALLOCATION = 0x0195,
- MyHTML_STATUS_TREE_ERROR_MEMORY_ALLOCATION = 0x01f4,
- MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE = 0x01f5,
- MyHTML_STATUS_TREE_ERROR_MCOBJECT_INIT = 0x01f6,
- MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE_NODE = 0x01f7,
- MyHTML_STATUS_TREE_ERROR_INCOMING_BUFFER_CREATE = 0x01f8,
- MyHTML_STATUS_ATTR_ERROR_ALLOCATION = 0x0258,
- MyHTML_STATUS_ATTR_ERROR_CREATE = 0x0259,
- MyHTML_STATUS_STREAM_BUFFER_ERROR_CREATE = 0x0300,
- MyHTML_STATUS_STREAM_BUFFER_ERROR_INIT = 0x0301,
- MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_CREATE = 0x0302,
- MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_INIT = 0x0303,
- MyHTML_STATUS_STREAM_BUFFER_ERROR_ADD_ENTRY = 0x0304,
- MyHTML_STATUS_MCOBJECT_ERROR_CACHE_CREATE = 0x0340,
- MyHTML_STATUS_MCOBJECT_ERROR_CHUNK_CREATE = 0x0341,
- MyHTML_STATUS_MCOBJECT_ERROR_CHUNK_INIT = 0x0342,
- MyHTML_STATUS_MCOBJECT_ERROR_CACHE_REALLOC = 0x0343
+ MyHTML_STATUS_RULES_ERROR_MEMORY_ALLOCATION = 0x9064,
+ MyHTML_STATUS_TOKENIZER_ERROR_MEMORY_ALLOCATION = 0x912c,
+ MyHTML_STATUS_TOKENIZER_ERROR_FRAGMENT_INIT = 0x912d,
+ MyHTML_STATUS_TAGS_ERROR_MEMORY_ALLOCATION = 0x9190,
+ MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE = 0x9191,
+ MyHTML_STATUS_TAGS_ERROR_MCOBJECT_MALLOC = 0x9192,
+ MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE_NODE = 0x9193,
+ MyHTML_STATUS_TAGS_ERROR_CACHE_MEMORY_ALLOCATION = 0x9194,
+ MyHTML_STATUS_TAGS_ERROR_INDEX_MEMORY_ALLOCATION = 0x9195,
+ MyHTML_STATUS_TREE_ERROR_MEMORY_ALLOCATION = 0x91f4,
+ MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE = 0x91f5,
+ MyHTML_STATUS_TREE_ERROR_MCOBJECT_INIT = 0x91f6,
+ MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE_NODE = 0x91f7,
+ MyHTML_STATUS_TREE_ERROR_INCOMING_BUFFER_CREATE = 0x91f8,
+ MyHTML_STATUS_ATTR_ERROR_ALLOCATION = 0x9258,
+ MyHTML_STATUS_ATTR_ERROR_CREATE = 0x9259,
+ MyHTML_STATUS_STREAM_BUFFER_ERROR_CREATE = 0x9300,
+ MyHTML_STATUS_STREAM_BUFFER_ERROR_INIT = 0x9301,
+ MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_CREATE = 0x9302,
+ MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_INIT = 0x9303,
+ MyHTML_STATUS_STREAM_BUFFER_ERROR_ADD_ENTRY = 0x9304
}
typedef myhtml_status_t;
@@ -492,6 +423,11 @@ typedef struct myhtml myhtml_t;
*/
typedef struct myhtml_tree myhtml_tree_t;
+/**
+ * @struct myhtml_token_t MyHTML_TOKEN
+ */
+typedef struct myhtml_token myhtml_token_t;
+
typedef struct myhtml_token_attr myhtml_tree_attr_t;
typedef struct myhtml_tree_node myhtml_tree_node_t;
@@ -503,39 +439,6 @@ typedef size_t myhtml_tag_id_t;
typedef struct myhtml_tag myhtml_tag_t;
/**
- * MCHAR_ASYNC structures
- *
- */
-typedef struct mchar_async mchar_async_t;
-
-/**
- * MyHTML_INCOMING structures
- *
- */
-typedef struct myhtml_incoming_buffer myhtml_incoming_buffer_t;
-
-/**
- * MyHTML_STRING structures
- *
- */
-struct myhtml_string {
- char* data;
- size_t size;
- size_t length;
-
- mchar_async_t *mchar;
- size_t node_idx;
-}
-typedef myhtml_string_t;
-
-struct myhtml_string_raw {
- char* data;
- size_t size;
- size_t length;
-}
-typedef myhtml_string_raw_t;
-
-/**
* @struct myhtml_collection_t
*/
struct myhtml_collection {
@@ -572,7 +475,6 @@ typedef myhtml_version_t;
// callback functions
typedef void* (*myhtml_callback_token_f)(myhtml_tree_t* tree, myhtml_token_node_t* token, void* ctx);
typedef void (*myhtml_callback_tree_node_f)(myhtml_tree_t* tree, myhtml_tree_node_t* node, void* ctx);
-typedef void (*myhtml_callback_serialize_f)(const char* buffer, size_t size, void* ctx);
/***********************************************************************************
*
@@ -602,7 +504,7 @@ myhtml_create(void);
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status value.
*/
-myhtml_status_t
+mystatus_t
myhtml_init(myhtml_t* myhtml, enum myhtml_options opt,
size_t thread_count, size_t queue_size);
@@ -627,7 +529,7 @@ myhtml_destroy(myhtml_t* myhtml);
* Parsing HTML
*
* @param[in] previously created structure myhtml_tree_t*
- * @param[in] Input character encoding; Default: MyHTML_ENCODING_UTF_8 or MyHTML_ENCODING_DEFAULT or 0
+ * @param[in] Input character encoding; Default: MyENCODING_UTF_8 or MyENCODING_DEFAULT or 0
* @param[in] HTML
* @param[in] HTML size
*
@@ -635,15 +537,15 @@ myhtml_destroy(myhtml_t* myhtml);
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
-myhtml_parse(myhtml_tree_t* tree, myhtml_encoding_t encoding,
+mystatus_t
+myhtml_parse(myhtml_tree_t* tree, myencoding_t encoding,
const char* html, size_t html_size);
/**
* Parsing fragment of HTML
*
* @param[in] previously created structure myhtml_tree_t*
- * @param[in] Input character encoding; Default: MyHTML_ENCODING_UTF_8 or MyHTML_ENCODING_DEFAULT or 0
+ * @param[in] Input character encoding; Default: MyENCODING_UTF_8 or MyENCODING_DEFAULT or 0
* @param[in] HTML
* @param[in] HTML size
* @param[in] fragment base (root) tag id. Default: MyHTML_TAG_DIV if set 0
@@ -653,8 +555,8 @@ myhtml_parse(myhtml_tree_t* tree, myhtml_encoding_t encoding,
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
-myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t encoding,
+mystatus_t
+myhtml_parse_fragment(myhtml_tree_t* tree, myencoding_t encoding,
const char* html, size_t html_size,
myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
@@ -663,7 +565,7 @@ myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t encoding,
* No matter what was said during initialization MyHTML
*
* @param[in] previously created structure myhtml_tree_t*
- * @param[in] Input character encoding; Default: MyHTML_ENCODING_UTF_8 or MyHTML_ENCODING_DEFAULT or 0
+ * @param[in] Input character encoding; Default: MyENCODING_UTF_8 or MyENCODING_DEFAULT or 0
* @param[in] HTML
* @param[in] HTML size
*
@@ -671,8 +573,8 @@ myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t encoding,
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
-myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encoding,
+mystatus_t
+myhtml_parse_single(myhtml_tree_t* tree, myencoding_t encoding,
const char* html, size_t html_size);
/**
@@ -680,7 +582,7 @@ myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encoding,
* No matter what was said during initialization MyHTML
*
* @param[in] previously created structure myhtml_tree_t*
- * @param[in] Input character encoding; Default: MyHTML_ENCODING_UTF_8 or MyHTML_ENCODING_DEFAULT or 0
+ * @param[in] Input character encoding; Default: MyENCODING_UTF_8 or MyENCODING_DEFAULT or 0
* @param[in] HTML
* @param[in] HTML size
* @param[in] fragment base (root) tag id. Default: MyHTML_TAG_DIV if set 0
@@ -690,8 +592,8 @@ myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encoding,
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
-myhtml_parse_fragment_single(myhtml_tree_t* tree, myhtml_encoding_t encoding,
+mystatus_t
+myhtml_parse_fragment_single(myhtml_tree_t* tree, myencoding_t encoding,
const char* html, size_t html_size,
myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
@@ -704,7 +606,7 @@ myhtml_parse_fragment_single(myhtml_tree_t* tree, myhtml_encoding_t encoding,
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
+mystatus_t
myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t html_size);
/**
@@ -718,7 +620,7 @@ myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t html_size);
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
+mystatus_t
myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* html,size_t html_size,
myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
@@ -732,7 +634,7 @@ myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* html,size_t html_si
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
+mystatus_t
myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, size_t html_size);
/**
@@ -747,7 +649,7 @@ myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, size_t html_siz
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
+mystatus_t
myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const char* html, size_t html_size,
myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
@@ -758,7 +660,7 @@ myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const char* html, size_t
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
+mystatus_t
myhtml_parse_chunk_end(myhtml_tree_t* tree);
/***********************************************************************************
@@ -783,7 +685,7 @@ myhtml_tree_create(void);
*
* @return MyHTML_STATUS_OK if successful, otherwise an error status
*/
-myhtml_status_t
+mystatus_t
myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml);
/**
@@ -936,47 +838,13 @@ size_t
myhtml_tree_get_mchar_node_id(myhtml_tree_t* tree);
/**
- * Print tree of a node. Print including current node
- *
- * @param[in] myhtml_tree_t*
- * @param[in] myhtml_tree_node_t*
- * @param[in] file handle, for example use stdout
- * @param[in] tab (\t) increment for pretty print, set 0
- */
-void
-myhtml_tree_print_by_node(myhtml_tree_t* tree, myhtml_tree_node_t* node,
- FILE* out, size_t inc);
-
-/**
- * Print tree of a node. Print excluding current node
- *
- * @param[in] myhtml_tree_t*
- * @param[in] myhtml_tree_node_t*
- * @param[in] file handle, for example use stdout
- * @param[in] tab (\t) increment for pretty print, set 0
- */
-void
-myhtml_tree_print_node_children(myhtml_tree_t* tree, myhtml_tree_node_t* node,
- FILE* out, size_t inc);
-
-/**
- * Print a node
- *
- * @param[in] myhtml_tree_t*
- * @param[in] myhtml_tree_node_t*
- * @param[in] file handle, for example use stdout
- */
-void
-myhtml_tree_print_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out);
-
-/**
* Get first Incoming Buffer
*
* @param[in] myhtml_tree_t*
*
- * @return myhtml_incoming_buffer_t* if successful, otherwise a NULL value
+ * @return mycore_incoming_buffer_t* if successful, otherwise a NULL value
*/
-myhtml_incoming_buffer_t*
+mycore_incoming_buffer_t*
myhtml_tree_incoming_buffer_first(myhtml_tree_t *tree);
/***********************************************************************************
@@ -1007,7 +875,7 @@ myhtml_node_first(myhtml_tree_t* tree);
*/
myhtml_collection_t*
myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_collection_t *collection,
- myhtml_tag_id_t tag_id, myhtml_status_t *status);
+ myhtml_tag_id_t tag_id, mystatus_t *status);
/**
* Get nodes by tag name
@@ -1022,7 +890,7 @@ myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_collection_t *collection,
*/
myhtml_collection_t*
myhtml_get_nodes_by_name(myhtml_tree_t* tree, myhtml_collection_t *collection,
- const char* name, size_t length, myhtml_status_t *status);
+ const char* name, size_t length, mystatus_t *status);
/**
* Get nodes by attribute key
@@ -1039,7 +907,7 @@ myhtml_get_nodes_by_name(myhtml_tree_t* tree, myhtml_collection_t *collection,
myhtml_collection_t*
myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myhtml_collection_t* collection,
myhtml_tree_node_t* scope_node,
- const char* key, size_t key_len, myhtml_status_t* status);
+ const char* key, size_t key_len, mystatus_t* status);
/**
* Get nodes by attribute value; exactly equal; like a [foo="bar"]
@@ -1063,7 +931,7 @@ myhtml_get_nodes_by_attribute_value(myhtml_tree_t *tree,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/**
* Get nodes by attribute value; whitespace separated; like a [foo~="bar"]
@@ -1089,7 +957,7 @@ myhtml_get_nodes_by_attribute_value_whitespace_separated(myhtml_tree_t *tree,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/**
* Get nodes by attribute value; value begins exactly with the string; like a [foo^="bar"]
@@ -1115,7 +983,7 @@ myhtml_get_nodes_by_attribute_value_begin(myhtml_tree_t *tree,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/**
@@ -1142,7 +1010,7 @@ myhtml_get_nodes_by_attribute_value_end(myhtml_tree_t *tree,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/**
* Get nodes by attribute value; value contains the substring; like a [foo*="bar"]
@@ -1168,7 +1036,7 @@ myhtml_get_nodes_by_attribute_value_contain(myhtml_tree_t *tree,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/**
* Get nodes by attribute value; attribute value is a hyphen-separated list of values beginning;
@@ -1193,7 +1061,7 @@ myhtml_get_nodes_by_attribute_value_hyphen_separated(myhtml_tree_t *tree,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/**
* Get nodes by tag id in node scope
@@ -1209,7 +1077,7 @@ myhtml_get_nodes_by_attribute_value_hyphen_separated(myhtml_tree_t *tree,
myhtml_collection_t*
myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection,
myhtml_tree_node_t *node, myhtml_tag_id_t tag_id,
- myhtml_status_t *status);
+ mystatus_t *status);
/**
* Get nodes by tag name in node scope
@@ -1226,7 +1094,7 @@ myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, myhtml_collection_t *co
myhtml_collection_t*
myhtml_get_nodes_by_name_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection,
myhtml_tree_node_t *node, const char* html, size_t length,
- myhtml_status_t *status);
+ mystatus_t *status);
/**
* Get next sibling node
@@ -1378,11 +1246,11 @@ myhtml_node_insert_before(myhtml_tree_node_t *target, myhtml_tree_node_t *node);
* @param[in] text length
* @param[in] character encoding
*
- * @return myhtml_string_t* if successful, otherwise a NULL value
+ * @return mycore_string_t* if successful, otherwise a NULL value
*/
-myhtml_string_t*
+mycore_string_t*
myhtml_node_text_set(myhtml_tree_node_t *node, const char* text, size_t length,
- myhtml_encoding_t encoding);
+ myencoding_t encoding);
/**
* Add text for a node with convert character encoding.
@@ -1392,11 +1260,11 @@ myhtml_node_text_set(myhtml_tree_node_t *node, const char* text, size_t length,
* @param[in] text length
* @param[in] character encoding
*
- * @return myhtml_string_t* if successful, otherwise a NULL value
+ * @return mycore_string_t* if successful, otherwise a NULL value
*/
-myhtml_string_t*
+mycore_string_t*
myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, const char* text, size_t length,
- myhtml_encoding_t encoding);
+ myencoding_t encoding);
/**
* Get token node
@@ -1479,13 +1347,13 @@ const char*
myhtml_node_text(myhtml_tree_node_t *node, size_t *length);
/**
- * Get myhtml_string_t object by Tree node
+ * Get mycore_string_t object by Tree node
*
* @param[in] myhtml_tree_node_t*
*
- * @return myhtml_string_t* if exists, otherwise an NULL value
+ * @return mycore_string_t* if exists, otherwise an NULL value
*/
-myhtml_string_t*
+mycore_string_t*
myhtml_node_string(myhtml_tree_node_t *node);
/**
@@ -1613,9 +1481,9 @@ myhtml_attribute_value(myhtml_tree_attr_t *attr, size_t *length);
*
* @param[in] myhtml_tree_attr_t*
*
- * @return myhtml_string_t* if exists, otherwise an NULL value
+ * @return mycore_string_t* if exists, otherwise an NULL value
*/
-myhtml_string_t*
+mycore_string_t*
myhtml_attribute_key_string(myhtml_tree_attr_t* attr);
/**
@@ -1623,9 +1491,9 @@ myhtml_attribute_key_string(myhtml_tree_attr_t* attr);
*
* @param[in] myhtml_tree_attr_t*
*
- * @return myhtml_string_t* if exists, otherwise an NULL value
+ * @return mycore_string_t* if exists, otherwise an NULL value
*/
-myhtml_string_t*
+mycore_string_t*
myhtml_attribute_value_string(myhtml_tree_attr_t* attr);
/**
@@ -1649,7 +1517,7 @@ myhtml_attribute_by_key(myhtml_tree_node_t *node,
* @param[in] attr key name length
* @param[in] attr value name
* @param[in] attr value name length
- * @param[in] character encoding; Default: MyHTML_ENCODING_UTF_8 or MyHTML_ENCODING_DEFAULT or 0
+ * @param[in] character encoding; Default: MyENCODING_UTF_8 or MyENCODING_DEFAULT or 0
*
* @return created myhtml_tree_attr_t* if successful, otherwise a NULL value
*/
@@ -1657,7 +1525,7 @@ myhtml_tree_attr_t*
myhtml_attribute_add(myhtml_tree_node_t *node,
const char *key, size_t key_len,
const char *value, size_t value_len,
- myhtml_encoding_t encoding);
+ myencoding_t encoding);
/**
* Remove attribute reference. Not release the resources
@@ -1797,13 +1665,13 @@ const char*
myhtml_token_node_text(myhtml_token_node_t *token_node, size_t *length);
/**
- * Get myhtml_string_t object by token node
+ * Get mycore_string_t object by token node
*
* @param[in] myhtml_token_node_t*
*
- * @return myhtml_string_t* if exists, otherwise an NULL value
+ * @return mycore_string_t* if exists, otherwise an NULL value
*/
-myhtml_string_t*
+mycore_string_t*
myhtml_token_node_string(myhtml_token_node_t *token_node);
/**
@@ -1829,10 +1697,11 @@ myhtml_token_node_is_close_self(myhtml_token_node_t *token_node);
/**
* Wait for process token all parsing stage. Need if you use thread mode
*
+ * @param[in] myhtml_token_t*
* @param[in] myhtml_token_node_t*
*/
void
-myhtml_token_node_wait_for_done(myhtml_token_node_t* node);
+myhtml_token_node_wait_for_done(myhtml_token_t* token, myhtml_token_node_t* node);
/***********************************************************************************
*
@@ -1881,7 +1750,7 @@ myhtml_tag_id_by_name(myhtml_tree_t* tree,
* @return myhtml_collection_t* if successful, otherwise an NULL value
*/
myhtml_collection_t*
-myhtml_collection_create(size_t size, myhtml_status_t *status);
+myhtml_collection_create(size_t size, mystatus_t *status);
/**
* Clears collection
@@ -1911,7 +1780,7 @@ myhtml_collection_destroy(myhtml_collection_t *collection);
*
* @return NULL if successful, otherwise an myhtml_collection_t* structure
*/
-myhtml_status_t
+mystatus_t
myhtml_collection_check_size(myhtml_collection_t *collection, size_t need, size_t upto_length);
/***********************************************************************************
@@ -1928,16 +1797,16 @@ myhtml_collection_check_size(myhtml_collection_t *collection, size_t need, size_
*
*/
void
-myhtml_encoding_set(myhtml_tree_t* tree, myhtml_encoding_t encoding);
+myhtml_encoding_set(myhtml_tree_t* tree, myencoding_t encoding);
/**
* Get character encoding for current stream
*
* @param[in] myhtml_tree_t*
*
- * @return myhtml_encoding_t
+ * @return myencoding_t
*/
-myhtml_encoding_t
+myencoding_t
myhtml_encoding_get(myhtml_tree_t* tree);
/**
@@ -1950,7 +1819,7 @@ myhtml_encoding_get(myhtml_tree_t* tree);
* @return size character set
*/
size_t
-myhtml_encoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data);
+myencoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data);
/**
* Convert Unicode Codepoint to UTF-16LE
@@ -1964,7 +1833,7 @@ myhtml_encoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data);
* @return size character set
*/
size_t
-myhtml_encoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data);
+myencoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data);
/**
* Detect character encoding
@@ -1980,7 +1849,7 @@ myhtml_encoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data);
* @return true if encoding found, otherwise false
*/
bool
-myhtml_encoding_detect(const char *text, size_t length, myhtml_encoding_t *encoding);
+myencoding_detect(const char *text, size_t length, myencoding_t *encoding);
/**
* Detect Russian character encoding
@@ -1994,7 +1863,7 @@ myhtml_encoding_detect(const char *text, size_t length, myhtml_encoding_t *encod
* @return true if encoding found, otherwise false
*/
bool
-myhtml_encoding_detect_russian(const char *text, size_t length, myhtml_encoding_t *encoding);
+myencoding_detect_russian(const char *text, size_t length, myencoding_t *encoding);
/**
* Detect Unicode character encoding
@@ -2008,7 +1877,7 @@ myhtml_encoding_detect_russian(const char *text, size_t length, myhtml_encoding_
* @return true if encoding found, otherwise false
*/
bool
-myhtml_encoding_detect_unicode(const char *text, size_t length, myhtml_encoding_t *encoding);
+myencoding_detect_unicode(const char *text, size_t length, myencoding_t *encoding);
/**
* Detect Unicode character encoding by BOM
@@ -2022,7 +1891,7 @@ myhtml_encoding_detect_unicode(const char *text, size_t length, myhtml_encoding_
* @return true if encoding found, otherwise false
*/
bool
-myhtml_encoding_detect_bom(const char *text, size_t length, myhtml_encoding_t *encoding);
+myencoding_detect_bom(const char *text, size_t length, myencoding_t *encoding);
/**
* Detect Unicode character encoding by BOM. Cut BOM if will be found
@@ -2038,13 +1907,13 @@ myhtml_encoding_detect_bom(const char *text, size_t length, myhtml_encoding_t *e
* @return true if encoding found, otherwise false
*/
bool
-myhtml_encoding_detect_and_cut_bom(const char *text, size_t length, myhtml_encoding_t *encoding,
+myencoding_detect_and_cut_bom(const char *text, size_t length, myencoding_t *encoding,
const char **new_text, size_t *new_size);
/**
* Detect encoding by name
- * Names like: windows-1258 return MyHTML_ENCODING_WINDOWS_1258
- * cp1251 or windows-1251 return MyHTML_ENCODING_WINDOWS_1251
+ * Names like: windows-1258 return MyENCODING_WINDOWS_1258
+ * cp1251 or windows-1251 return MyENCODING_WINDOWS_1251
*
* See https://encoding.spec.whatwg.org/#names-and-labels
*
@@ -2055,18 +1924,18 @@ myhtml_encoding_detect_and_cut_bom(const char *text, size_t length, myhtml_encod
* @return true if encoding found, otherwise false
*/
bool
-myhtml_encoding_by_name(const char *name, size_t length, myhtml_encoding_t *encoding);
+myencoding_by_name(const char *name, size_t length, myencoding_t *encoding);
/**
- * Get Encoding name by myhtml_encoding_t (by id)
+ * Get Encoding name by myencoding_t (by id)
*
- * @param[in] myhtml_encoding_t, encoding id
+ * @param[in] myencoding_t, encoding id
* @param[out] return name length
*
* @return encoding name, otherwise NULL value
*/
const char*
-myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *length);
+myencoding_name_by_id(myencoding_t encoding, size_t *length);
/**
* Detect encoding in meta tag (<meta ...>) before start parsing
@@ -2076,10 +1945,27 @@ myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *length);
* @param[in] html data bytes
* @param[in] html data length
*
- * @return detected encoding if encoding found, otherwise MyHTML_ENCODING_NOT_DETERMINED
+ * @return detected encoding if encoding found, otherwise MyENCODING_NOT_DETERMINED
*/
-myhtml_encoding_t
-myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size);
+myencoding_t
+myencoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size);
+
+/**
+ * Extracting character encoding from string. Find "charset=" and see encoding.
+ * For example: "text/html; charset=windows-1251". Return MyENCODING_WINDOWS_1251
+ *
+ *
+ * See https://html.spec.whatwg.org/multipage/infrastructure.html#algorithm-for-extracting-a-character-encoding-from-a-meta-element
+ *
+ * @param[in] data
+ * @param[in] data length
+ * @param[out] return encoding
+ *
+ * @return true if encoding found
+ */
+bool
+myencoding_extracting_character_encoding_from_charset(const char *data, size_t data_size,
+ myencoding_t *encoding);
/***********************************************************************************
*
@@ -2088,7 +1974,7 @@ myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t da
***********************************************************************************/
/**
- * Init myhtml_string_t structure
+ * Init mycore_string_t structure
*
* @param[in] mchar_async_t*. It can be obtained from myhtml_tree_t object
* (see myhtml_tree_get_mchar function) or create manualy
@@ -2098,7 +1984,7 @@ myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t da
* if created mchar_async_t object manually you know it, if not then take from the Tree
* (see myhtml_tree_get_mchar_node_id)
*
- * @param[in] myhtml_string_t*. It can be obtained from myhtml_tree_node_t object
+ * @param[in] mycore_string_t*. It can be obtained from myhtml_tree_node_t object
* (see myhtml_node_string function) or create manualy
*
* @param[in] data size. Set the size you want for char*
@@ -2106,137 +1992,137 @@ myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t da
* @return char* of the size if successful, otherwise a NULL value
*/
char*
-myhtml_string_init(mchar_async_t *mchar, size_t node_id,
- myhtml_string_t* str, size_t size);
+mycore_string_init(mchar_async_t *mchar, size_t node_id,
+ mycore_string_t* str, size_t size);
/**
- * Increase the current size for myhtml_string_t object
+ * Increase the current size for mycore_string_t object
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
- * @param[in] data size. Set the new size you want for myhtml_string_t object
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
+ * @param[in] data size. Set the new size you want for mycore_string_t object
*
* @return char* of the size if successful, otherwise a NULL value
*/
char*
-myhtml_string_realloc(myhtml_string_t *str, size_t new_size);
+mycore_string_realloc(mycore_string_t *str, size_t new_size);
/**
- * Clean myhtml_string_t object. In reality, data length set to 0
- * Equivalently: myhtml_string_length_set(str, 0);
+ * Clean mycore_string_t object. In reality, data length set to 0
+ * Equivalently: mycore_string_length_set(str, 0);
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
*/
void
-myhtml_string_clean(myhtml_string_t* str);
+mycore_string_clean(mycore_string_t* str);
/**
- * Clean myhtml_string_t object. Equivalently: memset(str, 0, sizeof(myhtml_string_t))
+ * Clean mycore_string_t object. Equivalently: memset(str, 0, sizeof(mycore_string_t))
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
*/
void
-myhtml_string_clean_all(myhtml_string_t* str);
+mycore_string_clean_all(mycore_string_t* str);
/**
- * Release all resources for myhtml_string_t object
+ * Release all resources for mycore_string_t object
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
* @param[in] call free function for current object or not
*
- * @return NULL if destroy_obj set true, otherwise a current myhtml_string_t object
+ * @return NULL if destroy_obj set true, otherwise a current mycore_string_t object
*/
-myhtml_string_t*
-myhtml_string_destroy(myhtml_string_t* str, bool destroy_obj);
+mycore_string_t*
+mycore_string_destroy(mycore_string_t* str, bool destroy_obj);
/**
- * Get data (char*) from a myhtml_string_t object
+ * Get data (char*) from a mycore_string_t object
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
*
* @return char* if exists, otherwise a NULL value
*/
char*
-myhtml_string_data(myhtml_string_t *str);
+mycore_string_data(mycore_string_t *str);
/**
- * Get data length from a myhtml_string_t object
+ * Get data length from a mycore_string_t object
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
*
* @return data length
*/
size_t
-myhtml_string_length(myhtml_string_t *str);
+mycore_string_length(mycore_string_t *str);
/**
- * Get data size from a myhtml_string_t object
+ * Get data size from a mycore_string_t object
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
*
* @return data size
*/
size_t
-myhtml_string_size(myhtml_string_t *str);
+mycore_string_size(mycore_string_t *str);
/**
- * Set data (char *) for a myhtml_string_t object.
+ * Set data (char *) for a mycore_string_t object.
*
* Attention!!! Attention!!! Attention!!!
*
* You can assign only that it has been allocated from functions:
- * myhtml_string_data_alloc
- * myhtml_string_data_realloc
+ * mycore_string_data_alloc
+ * mycore_string_data_realloc
* or obtained manually created from mchar_async_t object
*
* Attention!!! Do not try set chat* from allocated by malloc or realloc!!!
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
* @param[in] you data to want assign
*
* @return assigned data if successful, otherwise a NULL value
*/
char*
-myhtml_string_data_set(myhtml_string_t *str, char *data);
+mycore_string_data_set(mycore_string_t *str, char *data);
/**
- * Set data size for a myhtml_string_t object.
+ * Set data size for a mycore_string_t object.
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
* @param[in] you size to want assign
*
* @return assigned size
*/
size_t
-myhtml_string_size_set(myhtml_string_t *str, size_t size);
+mycore_string_size_set(mycore_string_t *str, size_t size);
/**
- * Set data length for a myhtml_string_t object.
+ * Set data length for a mycore_string_t object.
*
- * @param[in] myhtml_string_t*. See description for myhtml_string_init function
+ * @param[in] mycore_string_t*. See description for mycore_string_init function
* @param[in] you length to want assign
*
* @return assigned length
*/
size_t
-myhtml_string_length_set(myhtml_string_t *str, size_t length);
+mycore_string_length_set(mycore_string_t *str, size_t length);
/**
* Allocate data (char*) from a mchar_async_t object
*
- * @param[in] mchar_async_t*. See description for myhtml_string_init function
- * @param[in] node id. See description for myhtml_string_init function
+ * @param[in] mchar_async_t*. See description for mycore_string_init function
+ * @param[in] node id. See description for mycore_string_init function
* @param[in] you size to want assign
*
* @return data if successful, otherwise a NULL value
*/
char*
-myhtml_string_data_alloc(mchar_async_t *mchar, size_t node_id, size_t size);
+mycore_string_data_alloc(mchar_async_t *mchar, size_t node_id, size_t size);
/**
* Allocate data (char*) from a mchar_async_t object
*
- * @param[in] mchar_async_t*. See description for myhtml_string_init function
- * @param[in] node id. See description for myhtml_string_init function
+ * @param[in] mchar_async_t*. See description for mycore_string_init function
+ * @param[in] node id. See description for mycore_string_init function
* @param[in] old data
* @param[in] how much data is copied from the old data to new data
* @param[in] new size
@@ -2244,28 +2130,28 @@ myhtml_string_data_alloc(mchar_async_t *mchar, size_t node_id, size_t size);
* @return data if successful, otherwise a NULL value
*/
char*
-myhtml_string_data_realloc(mchar_async_t *mchar, size_t node_id,
+mycore_string_data_realloc(mchar_async_t *mchar, size_t node_id,
char *data, size_t len_to_copy, size_t size);
/**
* Release allocated data
*
- * @param[in] mchar_async_t*. See description for myhtml_string_init function
- * @param[in] node id. See description for myhtml_string_init function
+ * @param[in] mchar_async_t*. See description for mycore_string_init function
+ * @param[in] node id. See description for mycore_string_init function
* @param[in] data to release
*
* @return data if successful, otherwise a NULL value
*/
void
-myhtml_string_data_free(mchar_async_t *mchar, size_t node_id, char *data);
+mycore_string_data_free(mchar_async_t *mchar, size_t node_id, char *data);
/***********************************************************************************
*
* MyHTML_STRING_RAW
*
- * All work with myhtml_string_raw_t object occurs through
- * myhtml_malloc (standart malloc), myhtml_realloc (standart realloc),
- * myhtml_free (standart free).
+ * All work with mycore_string_raw_t object occurs through
+ * mycore_malloc (standart malloc), mycore_realloc (standart realloc),
+ * mycore_free (standart free).
*
* You are free to change them on without fear that something will happen
* You can call free for str_raw.data, or change str_raw.length = 0
@@ -2273,32 +2159,32 @@ myhtml_string_data_free(mchar_async_t *mchar, size_t node_id, char *data);
***********************************************************************************/
/**
- * Clean myhtml_string_raw_t object. In reality, data length set to 0
+ * Clean mycore_string_raw_t object. In reality, data length set to 0
*
- * @param[in] myhtml_string_raw_t*
+ * @param[in] mycore_string_raw_t*
*/
void
-myhtml_string_raw_clean(myhtml_string_raw_t* str_raw);
+mycore_string_raw_clean(mycore_string_raw_t* str_raw);
/**
- * Full clean myhtml_string_raw_t object.
- * Equivalently: memset(str_raw, 0, sizeof(myhtml_string_raw_t))
+ * Full clean mycore_string_raw_t object.
+ * Equivalently: memset(str_raw, 0, sizeof(mycore_string_raw_t))
*
- * @param[in] myhtml_string_raw_t*
+ * @param[in] mycore_string_raw_t*
*/
void
-myhtml_string_raw_clean_all(myhtml_string_raw_t* str_raw);
+mycore_string_raw_clean_all(mycore_string_raw_t* str_raw);
/**
- * Free resources for myhtml_string_raw_t object
+ * Free resources for mycore_string_raw_t object
*
- * @param[in] myhtml_string_raw_t*
+ * @param[in] mycore_string_raw_t*
* @param[in] call free function for current object or not
*
- * @return NULL if destroy_obj set true, otherwise a current myhtml_string_raw_t object
+ * @return NULL if destroy_obj set true, otherwise a current mycore_string_raw_t object
*/
-myhtml_string_raw_t*
-myhtml_string_raw_destroy(myhtml_string_raw_t* str_raw, bool destroy_obj);
+mycore_string_raw_t*
+mycore_string_raw_destroy(mycore_string_raw_t* str_raw, bool destroy_obj);
/***********************************************************************************
@@ -2316,99 +2202,99 @@ myhtml_string_raw_destroy(myhtml_string_raw_t* str_raw, bool destroy_obj);
/**
* Get Incoming Buffer by position
*
- * @param[in] current myhtml_incoming_buffer_t*
+ * @param[in] current mycore_incoming_buffer_t*
* @param[in] begin position
*
- * @return myhtml_incoming_buffer_t if successful, otherwise a NULL value
+ * @return mycore_incoming_buffer_t if successful, otherwise a NULL value
*/
-myhtml_incoming_buffer_t*
-myhtml_incoming_buffer_find_by_position(myhtml_incoming_buffer_t *inc_buf, size_t begin);
+mycore_incoming_buffer_t*
+mycore_incoming_buffer_find_by_position(mycore_incoming_buffer_t *inc_buf, size_t begin);
/**
* Get data of Incoming Buffer
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
*
* @return const char* if successful, otherwise a NULL value
*/
const char*
-myhtml_incoming_buffer_data(myhtml_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_data(mycore_incoming_buffer_t *inc_buf);
/**
* Get data length of Incoming Buffer
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
*
* @return size_t
*/
size_t
-myhtml_incoming_buffer_length(myhtml_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_length(mycore_incoming_buffer_t *inc_buf);
/**
* Get data size of Incoming Buffer
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
*
* @return size_t
*/
size_t
-myhtml_incoming_buffer_size(myhtml_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_size(mycore_incoming_buffer_t *inc_buf);
/**
* Get data offset of Incoming Buffer. Global position of begin Incoming Buffer.
* See description for MyHTML_INCOMING title
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
*
* @return size_t
*/
size_t
-myhtml_incoming_buffer_offset(myhtml_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_offset(mycore_incoming_buffer_t *inc_buf);
/**
* Get Relative Position for Incoming Buffer.
- * Incoming Buffer should be prepared by myhtml_incoming_buffer_find_by_position
+ * Incoming Buffer should be prepared by mycore_incoming_buffer_find_by_position
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
* @param[in] global begin
*
* @return size_t
*/
size_t
-myhtml_incoming_buffer_relative_begin(myhtml_incoming_buffer_t *inc_buf, size_t begin);
+mycore_incoming_buffer_relative_begin(mycore_incoming_buffer_t *inc_buf, size_t begin);
/**
* This function returns number of available data by Incoming Buffer
- * Incoming buffer may be incomplete. See myhtml_incoming_buffer_next
+ * Incoming buffer may be incomplete. See mycore_incoming_buffer_next
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
* @param[in] global begin
*
* @return size_t
*/
size_t
-myhtml_incoming_buffer_available_length(myhtml_incoming_buffer_t *inc_buf,
+mycore_incoming_buffer_available_length(mycore_incoming_buffer_t *inc_buf,
size_t relative_begin, size_t length);
/**
* Get next buffer
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
*
- * @return myhtml_incoming_buffer_t*
+ * @return mycore_incoming_buffer_t*
*/
-myhtml_incoming_buffer_t*
-myhtml_incoming_buffer_next(myhtml_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_t*
+mycore_incoming_buffer_next(mycore_incoming_buffer_t *inc_buf);
/**
* Get prev buffer
*
- * @param[in] myhtml_incoming_buffer_t*
+ * @param[in] mycore_incoming_buffer_t*
*
- * @return myhtml_incoming_buffer_t*
+ * @return mycore_incoming_buffer_t*
*/
-myhtml_incoming_buffer_t*
-myhtml_incoming_buffer_prev(myhtml_incoming_buffer_t *inc_buf);
+mycore_incoming_buffer_t*
+mycore_incoming_buffer_prev(mycore_incoming_buffer_t *inc_buf);
/***********************************************************************************
*
@@ -2564,7 +2450,7 @@ myhtml_callback_tree_node_remove_set(myhtml_tree_t* tree, myhtml_callback_tree_n
* @return 0 if match, otherwise index of break position
*/
size_t
-myhtml_strcasecmp(const char* str1, const char* str2);
+mycore_strcasecmp(const char* str1, const char* str2);
/**
* Compare two strings ignoring case of the first n characters
@@ -2575,7 +2461,7 @@ myhtml_strcasecmp(const char* str1, const char* str2);
* @return 0 if match, otherwise index of break position
*/
size_t
-myhtml_strncasecmp(const char* str1, const char* str2, size_t size);
+mycore_strncasecmp(const char* str1, const char* str2, size_t size);
/***********************************************************************************
*
@@ -2587,39 +2473,39 @@ myhtml_strncasecmp(const char* str1, const char* str2, size_t size);
* Tree fragment serialization
* The same as myhtml_serialization_tree_buffer function
*/
-bool
-myhtml_serialization(myhtml_tree_node_t* scope_node, myhtml_string_raw_t* str);
+mystatus_t
+myhtml_serialization(myhtml_tree_node_t* scope_node, mycore_string_raw_t* str);
/**
* Only one tree node serialization
* The same as myhtml_serialization_node_buffer function
*/
-bool
-myhtml_serialization_node(myhtml_tree_node_t* node, myhtml_string_raw_t* str);
+mystatus_t
+myhtml_serialization_node(myhtml_tree_node_t* node, mycore_string_raw_t* str);
/**
* Serialize tree to an output string
*
* @param[in] myhtml_tree_t*
* @param[in] scope node
- * @param[in] myhtml_string_raw_t*
+ * @param[in] mycore_string_raw_t*
*
* @return true if successful, otherwise false
*/
-bool
-myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, myhtml_string_raw_t* str);
+mystatus_t
+myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, mycore_string_raw_t* str);
/**
* Serialize node to an output string
*
* @param[in] myhtml_tree_t*
* @param[in] node
- * @param[in] myhtml_string_raw_t*
+ * @param[in] mycore_string_raw_t*
*
* @return true if successful, otherwise false
*/
-bool
-myhtml_serialization_node_buffer(myhtml_tree_node_t* node, myhtml_string_raw_t* str);
+mystatus_t
+myhtml_serialization_node_buffer(myhtml_tree_node_t* node, mycore_string_raw_t* str);
/**
* The serialize function for an entire tree
@@ -2631,9 +2517,9 @@ myhtml_serialization_node_buffer(myhtml_tree_node_t* node, myhtml_string_raw_t*
*
* @return true if successful, otherwise false
*/
-bool
+mystatus_t
myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node,
- myhtml_callback_serialize_f callback, void* ptr);
+ mycore_callback_serialize_f callback, void* ptr);
/**
* The serialize function for a single node
@@ -2645,9 +2531,9 @@ myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node,
*
* @return true if successful, otherwise false
*/
-bool
+mystatus_t
myhtml_serialization_node_callback(myhtml_tree_node_t* node,
- myhtml_callback_serialize_f callback, void* ptr);
+ mycore_callback_serialize_f callback, void* ptr);
/***********************************************************************************
*
diff --git a/source/myhtml/api_encoding.h b/source/myhtml/api_encoding.h
deleted file mode 100644
index d32aa4a..0000000
--- a/source/myhtml/api_encoding.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- Copyright (C) 2015-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 MyHTML_API_ENCODING_H
-#define MyHTML_API_ENCODING_H
-#pragma once
-
-#include "myhtml/api.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum myhtml_encoding_status {
- MyHTML_ENCODING_STATUS_OK = 0x00,
- MyHTML_ENCODING_STATUS_ERROR = 0x01,
- MyHTML_ENCODING_STATUS_CONTINUE = 0x02,
- MyHTML_ENCODING_STATUS_DONE = 0x04
-}
-typedef myhtml_encoding_status_t;
-
-struct myhtml_encoding_result {
- unsigned long first;
- unsigned long second;
- unsigned long third;
- unsigned long result;
- unsigned long result_aux;
- unsigned long flag;
-}
-typedef myhtml_encoding_result_t;
-
-typedef myhtml_encoding_status_t
-(*myhtml_encoding_custom_f)(unsigned const char byte, myhtml_encoding_result_t *res);
-
-/***********************************************************************************
- *
- * MyHTML_ENCODING
- *
- ***********************************************************************************/
-
-/**
- * Clean myhtml_encoding_result_t. Use this function before and after text decode
- *
- * @param[in] myhtml_encoding_result_t*
- */
-void
-myhtml_encoding_result_clean(myhtml_encoding_result_t *res);
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* api_encoding_h */
diff --git a/source/myhtml/callback.c b/source/myhtml/callback.c
index b26377e..a5016b3 100644
--- a/source/myhtml/callback.c
+++ b/source/myhtml/callback.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/source/myhtml/callback.h b/source/myhtml/callback.h
index fd6420a..ad2dc59 100644
--- a/source/myhtml/callback.h
+++ b/source/myhtml/callback.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/source/myhtml/charef.c b/source/myhtml/charef.c
index 5947c11..1930f0c 100644
--- a/source/myhtml/charef.c
+++ b/source/myhtml/charef.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/source/myhtml/charef.h b/source/myhtml/charef.h
index 53e3436..09688df 100644
--- a/source/myhtml/charef.h
+++ b/source/myhtml/charef.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/source/myhtml/charef_resource.h b/source/myhtml/charef_resource.h
index 79c2086..59d93db 100644
--- a/source/myhtml/charef_resource.h
+++ b/source/myhtml/charef_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/source/myhtml/data_process.c b/source/myhtml/data_process.c
index a5081db..4b680c5 100644
--- a/source/myhtml/data_process.c
+++ b/source/myhtml/data_process.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -19,13 +19,13 @@
*/
#include "myhtml/data_process.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
#define MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING() \
tmp_offset += myhtml_string_before_append_any_preprocessing(str, &data[tmp_offset], (offset - tmp_offset), \
proc_entry->tmp_str_pos_proc); \
if(offset != tmp_offset) { \
- if(proc_entry->encoding == MyHTML_ENCODING_UTF_8) \
+ if(proc_entry->encoding == MyENCODING_UTF_8) \
proc_entry->tmp_str_pos_proc = myhtml_string_append_with_preprocessing(str, &data[tmp_offset], (offset - tmp_offset), \
proc_entry->emit_null_char); \
else { \
@@ -42,9 +42,9 @@ void myhtml_data_process_entry_clean(myhtml_data_process_entry_t* proc_entry)
proc_entry->state = myhtml_data_process_state_data;
}
-void myhtml_data_process_string_append_char(myhtml_string_t* str, const char sm)
+void myhtml_data_process_string_append_char(mycore_string_t* str, const char sm)
{
- MyHTML_STRING_REALLOC_IF_NEED(str, 2, 0);
+ MyCORE_STRING_REALLOC_IF_NEED(str, 2, 0);
str->data[str->length] = sm;
str->length++;
@@ -52,7 +52,7 @@ void myhtml_data_process_string_append_char(myhtml_string_t* str, const char sm)
str->data[str->length] = '\0';
}
-size_t myhtml_data_process_state_data(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size)
+size_t myhtml_data_process_state_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size)
{
size_t tmp_offset = offset;
@@ -63,7 +63,7 @@ size_t myhtml_data_process_state_data(myhtml_data_process_entry_t* proc_entry, m
tmp_offset += myhtml_string_before_append_any_preprocessing(str, &data[tmp_offset], (offset - tmp_offset),
proc_entry->tmp_str_pos_proc);
if(offset != tmp_offset) {
- if(proc_entry->encoding == MyHTML_ENCODING_UTF_8)
+ if(proc_entry->encoding == MyENCODING_UTF_8)
proc_entry->tmp_str_pos_proc = myhtml_string_append_with_preprocessing(str, &data[tmp_offset],
(offset - tmp_offset),
proc_entry->emit_null_char);
@@ -72,7 +72,7 @@ size_t myhtml_data_process_state_data(myhtml_data_process_entry_t* proc_entry, m
myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(str, &proc_entry->res,
&data[tmp_offset], (offset - tmp_offset),
proc_entry->encoding, proc_entry->emit_null_char);
- myhtml_encoding_result_clean(&proc_entry->res);
+ myencoding_result_clean(&proc_entry->res);
}
}
@@ -93,7 +93,7 @@ size_t myhtml_data_process_state_data(myhtml_data_process_entry_t* proc_entry, m
return offset;
}
-size_t myhtml_data_process_state_ampersand(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size)
+size_t myhtml_data_process_state_ampersand(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size)
{
if(data[offset] == '#')
{
@@ -133,7 +133,7 @@ size_t myhtml_data_process_state_ampersand(myhtml_data_process_entry_t* proc_ent
return offset;
}
-size_t myhtml_data_process_state_ampersand_data(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size)
+size_t myhtml_data_process_state_ampersand_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size)
{
size_t tmp_offset = offset;
@@ -147,7 +147,7 @@ size_t myhtml_data_process_state_ampersand_data(myhtml_data_process_entry_t* pro
else {
/* if current charef is atrribute */
if(proc_entry->is_attributes &&
- (data[offset] == '=' || myhtml_string_alphanumeric_character[ (unsigned char)data[offset] ] != 0xff))
+ (data[offset] == '=' || mycore_string_alphanumeric_character[ (unsigned char)data[offset] ] != 0xff))
{
MyHTML_DATA_PROCESS_APPEND_WITH_PREPROCESSING()
@@ -157,9 +157,9 @@ size_t myhtml_data_process_state_ampersand_data(myhtml_data_process_entry_t* pro
if(current_entry->codepoints_len) {
for (size_t i = 0; i < current_entry->codepoints_len; i++) {
- MyHTML_STRING_REALLOC_IF_NEED(str, 5, 0);
+ MyCORE_STRING_REALLOC_IF_NEED(str, 5, 0);
- proc_entry->tmp_str_pos += myhtml_encoding_codepoint_to_ascii_utf_8(current_entry->codepoints[i], &str->data[proc_entry->tmp_str_pos]);
+ proc_entry->tmp_str_pos += myencoding_codepoint_to_ascii_utf_8(current_entry->codepoints[i], &str->data[proc_entry->tmp_str_pos]);
}
str->length = proc_entry->tmp_str_pos;
@@ -178,7 +178,7 @@ size_t myhtml_data_process_state_ampersand_data(myhtml_data_process_entry_t* pro
return offset;
}
-size_t myhtml_data_process_state_ampersand_hash(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size)
+size_t myhtml_data_process_state_ampersand_hash(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size)
{
if(data[offset] == 'x' || data[offset] == 'X') {
myhtml_data_process_string_append_char(str, data[offset]);
@@ -192,14 +192,14 @@ size_t myhtml_data_process_state_ampersand_hash(myhtml_data_process_entry_t* pro
return offset;
}
-size_t myhtml_data_process_state_ampersand_hash_data(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size)
+size_t myhtml_data_process_state_ampersand_hash_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size)
{
const unsigned char *u_data = (const unsigned char*)data;
size_t tmp_offset = offset;
while(offset < size)
{
- if(myhtml_string_chars_num_map[ u_data[offset] ] == 0xff)
+ if(mycore_string_chars_num_map[ u_data[offset] ] == 0xff)
{
proc_entry->state = myhtml_data_process_state_data;
@@ -217,7 +217,7 @@ size_t myhtml_data_process_state_ampersand_hash_data(myhtml_data_process_entry_t
}
if(proc_entry->tmp_num <= 0x10FFFF) {
- proc_entry->tmp_num = myhtml_string_chars_num_map[ u_data[offset] ] + proc_entry->tmp_num * 10;
+ proc_entry->tmp_num = mycore_string_chars_num_map[ u_data[offset] ] + proc_entry->tmp_num * 10;
}
offset++;
@@ -228,14 +228,14 @@ size_t myhtml_data_process_state_ampersand_hash_data(myhtml_data_process_entry_t
return offset;
}
-size_t myhtml_data_process_state_ampersand_hash_x_data(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size)
+size_t myhtml_data_process_state_ampersand_hash_x_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size)
{
unsigned const char *u_data = (unsigned const char*)data;
size_t tmp_offset = offset;
while(offset < size)
{
- if(myhtml_string_chars_hex_map[ u_data[offset] ] == 0xff)
+ if(mycore_string_chars_hex_map[ u_data[offset] ] == 0xff)
{
proc_entry->state = myhtml_data_process_state_data;
@@ -254,7 +254,7 @@ size_t myhtml_data_process_state_ampersand_hash_x_data(myhtml_data_process_entry
if(proc_entry->tmp_num <= 0x10FFFF) {
proc_entry->tmp_num <<= 4;
- proc_entry->tmp_num |= myhtml_string_chars_hex_map[ u_data[offset] ];
+ proc_entry->tmp_num |= mycore_string_chars_hex_map[ u_data[offset] ];
}
offset++;
@@ -265,10 +265,10 @@ size_t myhtml_data_process_state_ampersand_hash_x_data(myhtml_data_process_entry
return offset;
}
-void myhtml_data_process_state_end(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str)
+void myhtml_data_process_state_end(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str)
{
/* 4 is max utf8 byte + \0 */
- MyHTML_STRING_REALLOC_IF_NEED(str, 5, 0);
+ MyCORE_STRING_REALLOC_IF_NEED(str, 5, 0);
if(proc_entry->tmp_num <= 0x9F)
proc_entry->tmp_num = replacement_character[proc_entry->tmp_num];
@@ -278,12 +278,12 @@ void myhtml_data_process_state_end(myhtml_data_process_entry_t* proc_entry, myht
proc_entry->tmp_num = replacement_character[0];
str->length = proc_entry->tmp_str_pos +
- myhtml_encoding_codepoint_to_ascii_utf_8(proc_entry->tmp_num, &str->data[proc_entry->tmp_str_pos]);
+ myencoding_codepoint_to_ascii_utf_8(proc_entry->tmp_num, &str->data[proc_entry->tmp_str_pos]);
str->data[str->length] = '\0';
}
-void myhtml_data_process(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t size)
+void myhtml_data_process(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t size)
{
size_t offset = 0;
@@ -292,16 +292,16 @@ void myhtml_data_process(myhtml_data_process_entry_t* proc_entry, myhtml_string_
}
}
-void myhtml_data_process_end(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str)
+void myhtml_data_process_end(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str)
{
if(proc_entry->state == myhtml_data_process_state_ampersand_data && proc_entry->charef_res.last_entry)
{
const charef_entry_t *entry = proc_entry->charef_res.last_entry;
for (size_t i = 0; i < entry->codepoints_len; i++) {
- MyHTML_STRING_REALLOC_IF_NEED(str, 5, 0);
+ MyCORE_STRING_REALLOC_IF_NEED(str, 5, 0);
- proc_entry->tmp_str_pos += myhtml_encoding_codepoint_to_ascii_utf_8(entry->codepoints[i], &str->data[proc_entry->tmp_str_pos]);
+ proc_entry->tmp_str_pos += myencoding_codepoint_to_ascii_utf_8(entry->codepoints[i], &str->data[proc_entry->tmp_str_pos]);
}
str->length = proc_entry->tmp_str_pos;
diff --git a/source/myhtml/data_process.h b/source/myhtml/data_process.h
index 558a5aa..a461d10 100644
--- a/source/myhtml/data_process.h
+++ b/source/myhtml/data_process.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -35,8 +35,8 @@ struct myhtml_data_process_entry {
myhtml_data_process_state_f state;
/* for encodings */
- myhtml_encoding_t encoding;
- myhtml_encoding_result_t res;
+ myencoding_t encoding;
+ myencoding_result_t res;
/* temp */
size_t tmp_str_pos_proc;
@@ -53,16 +53,16 @@ struct myhtml_data_process_entry {
void myhtml_data_process_entry_clean(myhtml_data_process_entry_t* proc_entry);
-void myhtml_data_process(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t size);
-void myhtml_data_process_end(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str);
+void myhtml_data_process(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t size);
+void myhtml_data_process_end(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str);
-size_t myhtml_data_process_state_data(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size);
-size_t myhtml_data_process_state_ampersand(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size);
-size_t myhtml_data_process_state_ampersand_data(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size);
-size_t myhtml_data_process_state_ampersand_hash(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size);
-size_t myhtml_data_process_state_ampersand_hash_data(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char *data, size_t offset, size_t size);
-size_t myhtml_data_process_state_ampersand_hash_x_data(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str, const char* data, size_t offset, size_t size);
-void myhtml_data_process_state_end(myhtml_data_process_entry_t* proc_entry, myhtml_string_t* str);
+size_t myhtml_data_process_state_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size);
+size_t myhtml_data_process_state_ampersand(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size);
+size_t myhtml_data_process_state_ampersand_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size);
+size_t myhtml_data_process_state_ampersand_hash(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size);
+size_t myhtml_data_process_state_ampersand_hash_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char *data, size_t offset, size_t size);
+size_t myhtml_data_process_state_ampersand_hash_x_data(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str, const char* data, size_t offset, size_t size);
+void myhtml_data_process_state_end(myhtml_data_process_entry_t* proc_entry, mycore_string_t* str);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myhtml/def.h b/source/myhtml/def.h
index 389b198..8ec75e6 100644
--- a/source/myhtml/def.h
+++ b/source/myhtml/def.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/source/myhtml/encoding.h b/source/myhtml/encoding.h
deleted file mode 100644
index e575690..0000000
--- a/source/myhtml/encoding.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- Copyright (C) 2015-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 MyHTML_ENCODING_H
-#define MyHTML_ENCODING_H
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "myhtml/myosi.h"
-#include "myhtml/utils.h"
-#include "myhtml/mystring.h"
-
-enum myhtml_encoding_status {
- MyHTML_ENCODING_STATUS_OK = 0x00,
- MyHTML_ENCODING_STATUS_ERROR = 0x01,
- MyHTML_ENCODING_STATUS_CONTINUE = 0x02,
- MyHTML_ENCODING_STATUS_DONE = 0x04
-}
-typedef myhtml_encoding_status_t;
-
-struct myhtml_encoding_result {
- unsigned long first;
- unsigned long second;
- unsigned long third;
- unsigned long result;
- unsigned long result_aux;
- unsigned long flag;
-};
-
-struct myhtml_encoding_trigram {
- const unsigned char trigram[3];
- size_t value;
-};
-
-struct myhtml_encoding_trigram_result {
- size_t count;
- size_t value;
-};
-
-struct myhtml_encoding_unicode_result {
- size_t count_ascii;
- size_t count_good;
- size_t count_bad;
-};
-
-struct myhtml_encoding_detect_name_entry {
- const char* name;
- size_t name_length;
- const char* label;
- size_t label_length;
-
- myhtml_encoding_t encoding;
-
- size_t next;
- size_t curr;
-};
-
-struct myhtml_encoding_detect_attr {
- size_t key_begin;
- size_t key_length;
- size_t value_begin;
- size_t value_length;
-
- myhtml_encoding_detect_attr_t *next;
-};
-
-struct myhtml_encoding_entry_name_index {
- const char *name;
- size_t length;
-};
-
-typedef myhtml_encoding_status_t (*myhtml_encoding_custom_f)(unsigned const char data, myhtml_encoding_result_t *res);
-
-myhtml_encoding_custom_f myhtml_encoding_get_function_by_id(myhtml_encoding_t idx);
-
-enum myhtml_encoding_status myhtml_encoding_decode_utf_8(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_ibm866(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_2(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_3(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_4(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_5(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_6(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_7(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_8(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_8_i(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_10(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_13(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_14(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_15(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_8859_16(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_koi8_r(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_koi8_u(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_macintosh(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_874(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1250(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1251(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1252(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1253(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1254(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1255(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1256(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1257(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_windows_1258(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_x_mac_cyrillic(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_gbk(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_gb18030(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_big5(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_euc_jp(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_iso_2022_jp(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_shift_jis(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_euc_kr(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_shared_utf_16(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_utf_16be(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_utf_16le(unsigned const char data, myhtml_encoding_result_t *res);
-enum myhtml_encoding_status myhtml_encoding_decode_x_user_defined(unsigned const char data, myhtml_encoding_result_t *res);
-
-size_t myhtml_encoding_codepoint_ascii_length(size_t codepoint);
-size_t myhtml_encoding_codepoint_to_ascii_utf_8(size_t codepoint, char *data);
-size_t myhtml_encoding_codepoint_to_lowercase_ascii_utf_8(size_t codepoint, char *data);
-size_t myhtml_encoding_codepoint_to_ascii_utf_16(size_t codepoint, char *data);
-size_t myhtml_encoding_ascii_utf_8_to_codepoint(const unsigned char* data, size_t* codepoint);
-
-void myhtml_encoding_result_clean(myhtml_encoding_result_t *res);
-
-bool myhtml_encoding_detect(const char *text, size_t length, myhtml_encoding_t *encoding);
-bool myhtml_encoding_detect_russian(const char *text, size_t length, myhtml_encoding_t *encoding);
-bool myhtml_encoding_detect_unicode(const char *text, size_t length, myhtml_encoding_t *encoding);
-bool myhtml_encoding_detect_bom(const char *text, size_t length, myhtml_encoding_t *encoding);
-bool myhtml_encoding_detect_and_cut_bom(const char *text, size_t length, myhtml_encoding_t *encoding, const char **new_text, size_t *new_size);
-
-size_t myhtml_encoding_convert_to_ascii_utf_8(myhtml_string_raw_t* raw_str, const char* buff, size_t length, myhtml_encoding_t encoding);
-
-const myhtml_encoding_detect_name_entry_t * myhtml_encoding_name_entry_by_name(const char* name, size_t length);
-bool myhtml_encoding_by_name(const char *name, size_t length, myhtml_encoding_t *encoding);
-const char * myhtml_encoding_name_by_id(myhtml_encoding_t encoding, size_t *length);
-
-myhtml_encoding_t myhtml_encoding_prescan_stream_to_determine_encoding(const char *data, size_t data_size);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* encoding_h */
diff --git a/source/myhtml/myhtml.c b/source/myhtml/myhtml.c
index 767603e..479f33e 100644
--- a/source/myhtml/myhtml.c
+++ b/source/myhtml/myhtml.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -22,7 +22,7 @@
void myhtml_init_marker(myhtml_t* myhtml)
{
- myhtml->marker = (myhtml_tree_node_t*)myhtml_malloc(sizeof(myhtml_tree_node_t));
+ myhtml->marker = (myhtml_tree_node_t*)mycore_malloc(sizeof(myhtml_tree_node_t));
if(myhtml->marker)
myhtml_tree_node_clean(myhtml->marker);
@@ -31,92 +31,152 @@ void myhtml_init_marker(myhtml_t* myhtml)
void myhtml_destroy_marker(myhtml_t* myhtml)
{
if(myhtml->marker)
- myhtml_free(myhtml->marker);
+ mycore_free(myhtml->marker);
}
-myhtml_t * myhtml_create(void)
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+mystatus_t myhtml_stream_create(myhtml_t* myhtml, mystatus_t* status, size_t count, size_t id_increase)
{
- return (myhtml_t*)myhtml_malloc(sizeof(myhtml_t));
+ if(count == 0) {
+ myhtml->thread_stream = NULL;
+
+ *status = MyHTML_STATUS_OK;
+ return *status;
+ }
+
+ myhtml->thread_stream = mythread_create();
+ if(myhtml->thread_stream == NULL)
+ *status = MyCORE_STATUS_THREAD_ERROR_MEMORY_ALLOCATION;
+
+ *status = mythread_init(myhtml->thread_stream, MyTHREAD_TYPE_STREAM, count, id_increase);
+
+ if(*status)
+ myhtml->thread_stream = mythread_destroy(myhtml->thread_stream, NULL, NULL, true);
+
+ return *status;
}
-myhtml_status_t myhtml_init(myhtml_t* myhtml, enum myhtml_options opt, size_t thread_count, size_t queue_size)
+mystatus_t myhtml_batch_create(myhtml_t* myhtml, mystatus_t* status, size_t count, size_t id_increase)
{
- myhtml_status_t status;
+ if(count == 0) {
+ myhtml->thread_batch = NULL;
+
+ *status = MyHTML_STATUS_OK;
+ return *status;
+ }
- myhtml_init_marker(myhtml);
+ myhtml->thread_batch = mythread_create();
+ if(myhtml->thread_stream == NULL) {
+ myhtml->thread_stream = mythread_destroy(myhtml->thread_stream, NULL, NULL, true);
+ *status = MyCORE_STATUS_THREAD_ERROR_MEMORY_ALLOCATION;
+ }
- status = myhtml_tokenizer_state_init(myhtml);
- if(status) {
- myhtml->insertion_func = NULL;
- myhtml->thread = NULL;
-
+ *status = mythread_init(myhtml->thread_batch, MyTHREAD_TYPE_BATCH, count, id_increase);
+
+ if(*status)
+ myhtml->thread_batch = mythread_destroy(myhtml->thread_batch , NULL, NULL, true);
+
+ return *status;
+}
+
+mystatus_t myhtml_create_stream_and_batch(myhtml_t* myhtml, size_t stream_count, size_t batch_count)
+{
+ mystatus_t status;
+
+ /* stream */
+ if(myhtml_stream_create(myhtml, &status, stream_count, 0)) {
return status;
}
- status = myhtml_rules_init(myhtml);
- if(status) {
- myhtml->thread = NULL;
-
+ /* batch */
+ if(myhtml_batch_create(myhtml, &status, batch_count, stream_count)) {
+ myhtml->thread_stream = mythread_destroy(myhtml->thread_stream, NULL, NULL, true);
return status;
}
+ return status;
+}
+#endif /* if undef MyCORE_BUILD_WITHOUT_THREADS */
+
+myhtml_t * myhtml_create(void)
+{
+ return (myhtml_t*)mycore_calloc(1, sizeof(myhtml_t));
+}
+
+mystatus_t myhtml_init(myhtml_t* myhtml, enum myhtml_options opt, size_t thread_count, size_t queue_size)
+{
+ mystatus_t status;
+
myhtml->opt = opt;
- myhtml->thread = mythread_create();
+ myhtml_init_marker(myhtml);
- if(myhtml->thread == NULL)
- return MyHTML_STATUS_THREAD_ERROR_MEMORY_ALLOCATION;
+ status = myhtml_tokenizer_state_init(myhtml);
+ if(status)
+ return status;
-#ifdef MyHTML_BUILD_WITHOUT_THREADS
+ status = myhtml_rules_init(myhtml);
+
+#ifdef MyCORE_BUILD_WITHOUT_THREADS
- status = mythread_init(myhtml->thread, NULL, thread_count);
+ myhtml->thread_stream = NULL;
+ myhtml->thread_batch = NULL;
+ myhtml->thread_total = 0;
+#else /* if undef MyCORE_BUILD_WITHOUT_THREADS */
if(status)
return status;
-#else /* MyHTML_BUILD_WITHOUT_THREADS */
switch (opt) {
case MyHTML_OPTIONS_PARSE_MODE_SINGLE:
- status = mythread_init(myhtml->thread, "lastmac", 0);
- if(status)
- return status;
-
- myhtml->thread->context = mythread_queue_list_create(&status);
- if(status)
+ if((status = myhtml_create_stream_and_batch(myhtml, 0, 0)))
return status;
break;
case MyHTML_OPTIONS_PARSE_MODE_ALL_IN_ONE:
- status = mythread_init(myhtml->thread, "lastmac", 1);
- if(status)
+ if((status = myhtml_create_stream_and_batch(myhtml, 1, 0)))
return status;
- myhtml->thread->context = mythread_queue_list_create(&status);
- if(status)
- return status;
+ myhtml->thread_stream->context = mythread_queue_list_create(&status);
+ status = myhread_entry_create(myhtml->thread_stream, mythread_function_queue_stream, myhtml_parser_worker_stream, MyTHREAD_OPT_STOP);
- myhread_create_stream(myhtml->thread, mythread_function_queue_stream, myhtml_parser_worker_stream, MyTHREAD_OPT_STOP, &status);
break;
default:
// default MyHTML_OPTIONS_PARSE_MODE_SEPARATELY
- if(thread_count == 0)
- thread_count = 1;
+ if(thread_count < 2)
+ thread_count = 2;
- status = mythread_init(myhtml->thread, "lastmac", (thread_count + 1));
- if(status)
+ if((status = myhtml_create_stream_and_batch(myhtml, 1, (thread_count - 1))))
return status;
- myhtml->thread->context = mythread_queue_list_create(&status);
+ myhtml->thread_stream->context = mythread_queue_list_create(&status);
+ myhtml->thread_batch->context = myhtml->thread_stream->context;
+
+ status = myhread_entry_create(myhtml->thread_stream, mythread_function_queue_stream, myhtml_parser_stream, MyTHREAD_OPT_STOP);
if(status)
return status;
- myhread_create_stream(myhtml->thread, mythread_function_queue_stream, myhtml_parser_stream, MyTHREAD_OPT_STOP, &status);
- myhread_create_batch(myhtml->thread, mythread_function_queue_batch, myhtml_parser_worker, MyTHREAD_OPT_STOP, &status, thread_count);
+ for(size_t i = 0; i < myhtml->thread_batch->entries_size; i++) {
+ status = myhread_entry_create(myhtml->thread_batch, mythread_function_queue_batch, myhtml_parser_worker, MyTHREAD_OPT_STOP);
+
+ if(status)
+ return status;
+ }
+
break;
}
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
+ myhtml->thread_total = thread_count;
+
+ myhtml->thread_list[0] = myhtml->thread_stream;
+ myhtml->thread_list[1] = myhtml->thread_batch;
+ myhtml->thread_list[2] = NULL;
+
+#endif /* if undef MyCORE_BUILD_WITHOUT_THREADS */
+
+ if(status)
+ return status;
myhtml_clean(myhtml);
@@ -125,7 +185,7 @@ myhtml_status_t myhtml_init(myhtml_t* myhtml, enum myhtml_options opt, size_t th
void myhtml_clean(myhtml_t* myhtml)
{
- mythread_clean(myhtml->thread);
+ /* some code */
}
myhtml_t* myhtml_destroy(myhtml_t* myhtml)
@@ -135,36 +195,41 @@ myhtml_t* myhtml_destroy(myhtml_t* myhtml)
myhtml_destroy_marker(myhtml);
- if(myhtml->thread) {
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
- mythread_queue_list_t* queue_list = myhtml->thread->context;
-#endif
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ if(myhtml->thread_stream) {
+ mythread_queue_list_t* queue_list = myhtml->thread_stream->context;
+
+ if(queue_list)
+ mythread_queue_list_wait_for_done(myhtml->thread_stream, queue_list);
- myhtml->thread = mythread_destroy(myhtml->thread, mythread_queue_wait_all_for_done, true);
+ myhtml->thread_stream = mythread_destroy(myhtml->thread_stream, mythread_callback_quit, NULL, true);
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
- mythread_queue_list_destroy(queue_list);
-#endif
+ if(myhtml->thread_batch)
+ myhtml->thread_batch = mythread_destroy(myhtml->thread_batch, mythread_callback_quit, NULL, true);
+
+ if(queue_list)
+ mythread_queue_list_destroy(queue_list);
}
+#endif /* if undef MyCORE_BUILD_WITHOUT_THREADS */
myhtml_tokenizer_state_destroy(myhtml);
if(myhtml->insertion_func)
- myhtml_free(myhtml->insertion_func);
+ mycore_free(myhtml->insertion_func);
- myhtml_free(myhtml);
+ mycore_free(myhtml);
return NULL;
}
-myhtml_status_t myhtml_parse(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size)
+mystatus_t myhtml_parse(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size)
{
if(tree->flags & MyHTML_TREE_FLAGS_PARSE_END) {
myhtml_tree_clean(tree);
}
myhtml_encoding_set(tree, encoding);
- myhtml_status_t status = myhtml_tokenizer_begin(tree, html, html_size);
+ mystatus_t status = myhtml_tokenizer_begin(tree, html, html_size);
if(status)
return status;
@@ -172,7 +237,7 @@ myhtml_status_t myhtml_parse(myhtml_tree_t* tree, myhtml_encoding_t encoding, co
return myhtml_tokenizer_end(tree);
}
-myhtml_status_t myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns)
+mystatus_t myhtml_parse_fragment(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns)
{
if(tree->flags & MyHTML_TREE_FLAGS_PARSE_END) {
myhtml_tree_clean(tree);
@@ -188,7 +253,7 @@ myhtml_status_t myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t enc
return MyHTML_STATUS_TOKENIZER_ERROR_FRAGMENT_INIT;
myhtml_encoding_set(tree, encoding);
- myhtml_status_t status = myhtml_tokenizer_begin(tree, html, html_size);
+ mystatus_t status = myhtml_tokenizer_begin(tree, html, html_size);
if(status)
return status;
@@ -196,7 +261,7 @@ myhtml_status_t myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t enc
return myhtml_tokenizer_end(tree);
}
-myhtml_status_t myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size)
+mystatus_t myhtml_parse_single(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size)
{
if(tree->flags & MyHTML_TREE_FLAGS_PARSE_END) {
myhtml_tree_clean(tree);
@@ -206,7 +271,7 @@ myhtml_status_t myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encod
myhtml_encoding_set(tree, encoding);
- myhtml_status_t status = myhtml_tokenizer_begin(tree, html, html_size);
+ mystatus_t status = myhtml_tokenizer_begin(tree, html, html_size);
if(status)
return status;
@@ -214,7 +279,7 @@ myhtml_status_t myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encod
return myhtml_tokenizer_end(tree);
}
-myhtml_status_t myhtml_parse_fragment_single(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns)
+mystatus_t myhtml_parse_fragment_single(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns)
{
if(tree->flags & MyHTML_TREE_FLAGS_PARSE_END) {
myhtml_tree_clean(tree);
@@ -233,7 +298,7 @@ myhtml_status_t myhtml_parse_fragment_single(myhtml_tree_t* tree, myhtml_encodin
myhtml_encoding_set(tree, encoding);
- myhtml_status_t status = myhtml_tokenizer_begin(tree, html, html_size);
+ mystatus_t status = myhtml_tokenizer_begin(tree, html, html_size);
if(status)
return status;
@@ -241,7 +306,7 @@ myhtml_status_t myhtml_parse_fragment_single(myhtml_tree_t* tree, myhtml_encodin
return myhtml_tokenizer_end(tree);
}
-myhtml_status_t myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t html_size)
+mystatus_t myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t html_size)
{
if(tree->flags & MyHTML_TREE_FLAGS_PARSE_END) {
myhtml_tree_clean(tree);
@@ -250,7 +315,7 @@ myhtml_status_t myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t
return myhtml_tokenizer_chunk(tree, html, html_size);
}
-myhtml_status_t myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns)
+mystatus_t myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns)
{
if(tree->flags & MyHTML_TREE_FLAGS_PARSE_END) {
myhtml_tree_clean(tree);
@@ -268,7 +333,7 @@ myhtml_status_t myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* htm
return myhtml_tokenizer_chunk(tree, html, html_size);
}
-myhtml_status_t myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, size_t html_size)
+mystatus_t myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, size_t html_size)
{
if((tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0)
tree->flags |= MyHTML_TREE_FLAGS_SINGLE_MODE;
@@ -276,7 +341,7 @@ myhtml_status_t myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html,
return myhtml_parse_chunk(tree, html, html_size);
}
-myhtml_status_t myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns)
+mystatus_t myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns)
{
if((tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0)
tree->flags |= MyHTML_TREE_FLAGS_SINGLE_MODE;
@@ -284,21 +349,21 @@ myhtml_status_t myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const ch
return myhtml_parse_chunk_fragment(tree, html, html_size, tag_id, ns);
}
-myhtml_status_t myhtml_parse_chunk_end(myhtml_tree_t* tree)
+mystatus_t myhtml_parse_chunk_end(myhtml_tree_t* tree)
{
return myhtml_tokenizer_end(tree);
}
-void myhtml_encoding_set(myhtml_tree_t* tree, myhtml_encoding_t encoding)
+void myhtml_encoding_set(myhtml_tree_t* tree, myencoding_t encoding)
{
- if(encoding >= MyHTML_ENCODING_LAST_ENTRY)
+ if(encoding >= MyENCODING_LAST_ENTRY)
return;
tree->encoding_usereq = encoding;
tree->encoding = encoding;
}
-myhtml_encoding_t myhtml_encoding_get(myhtml_tree_t* tree)
+myencoding_t myhtml_encoding_get(myhtml_tree_t* tree)
{
return tree->encoding;
}
@@ -307,7 +372,7 @@ myhtml_encoding_t myhtml_encoding_get(myhtml_tree_t* tree)
* Nodes
*/
-myhtml_status_t myhtml_get_nodes_by_tag_id_in_scope_find_recursion(myhtml_tree_node_t *node, myhtml_collection_t *collection, myhtml_tag_id_t tag_id)
+mystatus_t myhtml_get_nodes_by_tag_id_in_scope_find_recursion(myhtml_tree_node_t *node, myhtml_collection_t *collection, myhtml_tag_id_t tag_id)
{
while(node) {
if(node->tag_id == tag_id) {
@@ -316,7 +381,7 @@ myhtml_status_t myhtml_get_nodes_by_tag_id_in_scope_find_recursion(myhtml_tree_n
if(collection->length >= collection->size)
{
- myhtml_status_t mystatus = myhtml_collection_check_size(collection, 1024, 0);
+ mystatus_t mystatus = myhtml_collection_check_size(collection, 1024, 0);
if(mystatus != MyHTML_STATUS_OK)
return mystatus;
@@ -332,12 +397,12 @@ myhtml_status_t myhtml_get_nodes_by_tag_id_in_scope_find_recursion(myhtml_tree_n
return MyHTML_STATUS_OK;
}
-myhtml_collection_t * myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, myhtml_tag_id_t tag_id, myhtml_status_t *status)
+myhtml_collection_t * myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, myhtml_tag_id_t tag_id, mystatus_t *status)
{
if(node == NULL)
return NULL;
- myhtml_status_t mystatus = MyHTML_STATUS_OK;
+ mystatus_t mystatus = MyHTML_STATUS_OK;
if(collection == NULL) {
collection = myhtml_collection_create(1024, &mystatus);
@@ -361,13 +426,13 @@ myhtml_collection_t * myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, m
return collection;
}
-myhtml_collection_t * myhtml_get_nodes_by_name_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, const char* html, size_t length, myhtml_status_t *status)
+myhtml_collection_t * myhtml_get_nodes_by_name_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, const char* html, size_t length, mystatus_t *status)
{
const myhtml_tag_context_t *tag_ctx = myhtml_tag_get_by_name(tree->tags, html, length);
return myhtml_get_nodes_by_tag_id_in_scope(tree, collection, node, tag_ctx->id, status);
}
-myhtml_collection_t * myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tag_id_t tag_id, myhtml_status_t *status)
+myhtml_collection_t * myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tag_id_t tag_id, mystatus_t *status)
{
if(collection == NULL) {
collection = myhtml_collection_create(1024, NULL);
@@ -417,7 +482,7 @@ myhtml_collection_t * myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_col
return collection;
}
-myhtml_collection_t * myhtml_get_nodes_by_name(myhtml_tree_t* tree, myhtml_collection_t *collection, const char* html, size_t length, myhtml_status_t *status)
+myhtml_collection_t * myhtml_get_nodes_by_name(myhtml_tree_t* tree, myhtml_collection_t *collection, const char* html, size_t length, mystatus_t *status)
{
const myhtml_tag_context_t *tag_ctx = myhtml_tag_get_by_name(tree->tags, html, length);
@@ -546,12 +611,12 @@ myhtml_tree_node_t * myhtml_node_insert_to_appropriate_place(myhtml_tree_node_t
return node;
}
-myhtml_string_t * myhtml_node_text_set(myhtml_tree_node_t *node, const char* text, size_t length, myhtml_encoding_t encoding)
+mycore_string_t * myhtml_node_text_set(myhtml_tree_node_t *node, const char* text, size_t length, myencoding_t encoding)
{
if(node == NULL)
return NULL;
- if(encoding >= MyHTML_ENCODING_LAST_ENTRY)
+ if(encoding >= MyENCODING_LAST_ENTRY)
return NULL;
myhtml_tree_t* tree = node->tree;
@@ -564,22 +629,22 @@ myhtml_string_t * myhtml_node_text_set(myhtml_tree_node_t *node, const char* tex
}
if(node->token->str.data == NULL) {
- myhtml_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, (length + 2));
+ mycore_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, (length + 2));
}
else {
if(node->token->str.size < length) {
mchar_async_free(tree->mchar, node->token->str.node_idx, node->token->str.data);
- myhtml_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, length);
+ mycore_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, length);
}
else
node->token->str.length = 0;
}
- if(encoding != MyHTML_ENCODING_UTF_8) {
- myhtml_string_append_with_convert_encoding(&node->token->str, text, length, encoding);
+ if(encoding != MyENCODING_UTF_8) {
+ myencoding_string_append(&node->token->str, text, length, encoding);
}
else {
- myhtml_string_append(&node->token->str, text, length);
+ mycore_string_append(&node->token->str, text, length);
}
node->token->raw_begin = 0;
@@ -588,12 +653,12 @@ myhtml_string_t * myhtml_node_text_set(myhtml_tree_node_t *node, const char* tex
return &node->token->str;
}
-myhtml_string_t * myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, const char* text, size_t length, myhtml_encoding_t encoding)
+mycore_string_t * myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, const char* text, size_t length, myencoding_t encoding)
{
if(node == NULL)
return NULL;
- if(encoding >= MyHTML_ENCODING_LAST_ENTRY)
+ if(encoding >= MyENCODING_LAST_ENTRY)
return NULL;
myhtml_tree_t* tree = node->tree;
@@ -606,12 +671,12 @@ myhtml_string_t * myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, con
}
if(node->token->str.data == NULL) {
- myhtml_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, (length + 2));
+ mycore_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, (length + 2));
}
else {
if(node->token->str.size < length) {
mchar_async_free(tree->mchar, node->token->str.node_idx, node->token->str.data);
- myhtml_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, length);
+ mycore_string_init(tree->mchar, tree->mchar_node_id, &node->token->str, length);
}
else
node->token->str.length = 0;
@@ -621,7 +686,7 @@ myhtml_string_t * myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, con
myhtml_data_process_entry_clean(&proc_entry);
proc_entry.encoding = encoding;
- myhtml_encoding_result_clean(&proc_entry.res);
+ myencoding_result_clean(&proc_entry.res);
myhtml_data_process(&proc_entry, &node->token->str, text, length);
myhtml_data_process_end(&proc_entry, &node->token->str);
@@ -724,7 +789,7 @@ const char * myhtml_node_text(myhtml_tree_node_t *node, size_t *length)
return NULL;
}
-myhtml_string_t * myhtml_node_string(myhtml_tree_node_t *node)
+mycore_string_t * myhtml_node_string(myhtml_tree_node_t *node)
{
if(node && node->token)
return &node->token->str;
@@ -763,7 +828,7 @@ myhtml_tree_t * myhtml_node_tree(myhtml_tree_node_t *node)
return node->tree;
}
-myhtml_status_t myhtml_get_nodes_by_attribute_key_recursion(myhtml_tree_node_t* node, myhtml_collection_t* collection, const char* key, size_t key_len)
+mystatus_t myhtml_get_nodes_by_attribute_key_recursion(myhtml_tree_node_t* node, myhtml_collection_t* collection, const char* key, size_t key_len)
{
while(node)
{
@@ -771,14 +836,14 @@ myhtml_status_t myhtml_get_nodes_by_attribute_key_recursion(myhtml_tree_node_t*
myhtml_tree_attr_t* attr = node->token->attr_first;
while(attr) {
- myhtml_string_t* str_key = &attr->key;
+ mycore_string_t* str_key = &attr->key;
- if(str_key->length == key_len && myhtml_strncasecmp(str_key->data, key, key_len) == 0) {
+ if(str_key->length == key_len && mycore_strncasecmp(str_key->data, key, key_len) == 0) {
collection->list[ collection->length ] = node;
collection->length++;
if(collection->length >= collection->size) {
- myhtml_status_t status = myhtml_collection_check_size(collection, 1024, 0);
+ mystatus_t status = myhtml_collection_check_size(collection, 1024, 0);
if(status)
return status;
@@ -790,7 +855,7 @@ myhtml_status_t myhtml_get_nodes_by_attribute_key_recursion(myhtml_tree_node_t*
}
if(node->child) {
- myhtml_status_t status = myhtml_get_nodes_by_attribute_key_recursion(node->child, collection, key, key_len);
+ mystatus_t status = myhtml_get_nodes_by_attribute_key_recursion(node->child, collection, key, key_len);
if(status)
return status;
@@ -802,7 +867,7 @@ myhtml_status_t myhtml_get_nodes_by_attribute_key_recursion(myhtml_tree_node_t*
return MyHTML_STATUS_OK;
}
-myhtml_collection_t * myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* scope_node, const char* key, size_t key_len, myhtml_status_t* status)
+myhtml_collection_t * myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* scope_node, const char* key, size_t key_len, mystatus_t* status)
{
if(collection == NULL) {
collection = myhtml_collection_create(1024, status);
@@ -814,7 +879,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myh
if(scope_node == NULL)
scope_node = tree->node_html;
- myhtml_status_t rec_status = myhtml_get_nodes_by_attribute_key_recursion(scope_node, collection, key, key_len);
+ mystatus_t rec_status = myhtml_get_nodes_by_attribute_key_recursion(scope_node, collection, key, key_len);
if(rec_status && status)
*status = rec_status;
@@ -823,28 +888,28 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myh
}
/* find by attribute value; case-sensitivity */
-bool myhtml_get_nodes_by_attribute_value_recursion_eq(myhtml_string_t* str, const char* value, size_t value_len)
+bool myhtml_get_nodes_by_attribute_value_recursion_eq(mycore_string_t* str, const char* value, size_t value_len)
{
- return str->length == value_len && myhtml_strncmp(str->data, value, value_len) == 0;
+ return str->length == value_len && mycore_strncmp(str->data, value, value_len) == 0;
}
-bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated(myhtml_string_t* str, const char* value, size_t value_len)
+bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated(mycore_string_t* str, const char* value, size_t value_len)
{
if(str->length < value_len)
return false;
const char *data = str->data;
- if(myhtml_strncmp(data, value, value_len) == 0) {
- if((str->length > value_len && myhtml_utils_whithspace(data[value_len], ==, ||)) || str->length == value_len)
+ if(mycore_strncmp(data, value, value_len) == 0) {
+ if((str->length > value_len && mycore_utils_whithspace(data[value_len], ==, ||)) || str->length == value_len)
return true;
}
for(size_t i = 1; (str->length - i) >= value_len; i++)
{
- if(myhtml_utils_whithspace(data[(i - 1)], ==, ||)) {
- if(myhtml_strncmp(&data[i], value, value_len) == 0) {
- if((i > value_len && myhtml_utils_whithspace(data[(i + value_len)], ==, ||)) || (str->length - i) == value_len)
+ if(mycore_utils_whithspace(data[(i - 1)], ==, ||)) {
+ if(mycore_strncmp(&data[i], value, value_len) == 0) {
+ if((i > value_len && mycore_utils_whithspace(data[(i + value_len)], ==, ||)) || (str->length - i) == value_len)
return true;
}
}
@@ -853,23 +918,23 @@ bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated(myhtml_s
return false;
}
-bool myhtml_get_nodes_by_attribute_value_recursion_begin(myhtml_string_t* str, const char* value, size_t value_len)
+bool myhtml_get_nodes_by_attribute_value_recursion_begin(mycore_string_t* str, const char* value, size_t value_len)
{
if(str->length < value_len)
return false;
- return myhtml_strncmp(str->data, value, value_len) == 0;
+ return mycore_strncmp(str->data, value, value_len) == 0;
}
-bool myhtml_get_nodes_by_attribute_value_recursion_end(myhtml_string_t* str, const char* value, size_t value_len)
+bool myhtml_get_nodes_by_attribute_value_recursion_end(mycore_string_t* str, const char* value, size_t value_len)
{
if(str->length < value_len)
return false;
- return myhtml_strncmp(&str->data[ (str->length - (str->length - value_len)) ], value, value_len) == 0;
+ return mycore_strncmp(&str->data[ (str->length - (str->length - value_len)) ], value, value_len) == 0;
}
-bool myhtml_get_nodes_by_attribute_value_recursion_contain(myhtml_string_t* str, const char* value, size_t value_len)
+bool myhtml_get_nodes_by_attribute_value_recursion_contain(mycore_string_t* str, const char* value, size_t value_len)
{
if(str->length < value_len)
return false;
@@ -878,7 +943,7 @@ bool myhtml_get_nodes_by_attribute_value_recursion_contain(myhtml_string_t* str,
for(size_t i = 0; (str->length - i) >= value_len; i++)
{
- if(myhtml_strncmp(&data[i], value, value_len) == 0) {
+ if(mycore_strncmp(&data[i], value, value_len) == 0) {
return true;
}
}
@@ -886,16 +951,16 @@ bool myhtml_get_nodes_by_attribute_value_recursion_contain(myhtml_string_t* str,
return false;
}
-bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated(myhtml_string_t* str, const char* value, size_t value_len)
+bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated(mycore_string_t* str, const char* value, size_t value_len)
{
const char *data = str->data;
if(str->length < value_len)
return false;
- else if(str->length == value_len && myhtml_strncmp(data, value, value_len) == 0) {
+ else if(str->length == value_len && mycore_strncmp(data, value, value_len) == 0) {
return true;
}
- else if(myhtml_strncmp(data, value, value_len) == 0 && data[value_len] == '-') {
+ else if(mycore_strncmp(data, value, value_len) == 0 && data[value_len] == '-') {
return true;
}
@@ -903,28 +968,28 @@ bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated(myhtml_strin
}
/* find by attribute value; case-insensitive */
-bool myhtml_get_nodes_by_attribute_value_recursion_eq_i(myhtml_string_t* str, const char* value, size_t value_len)
+bool myhtml_get_nodes_by_attribute_value_recursion_eq_i(mycore_string_t* str, const char* value, size_t value_len)
{
- return str->length == value_len && myhtml_strncasecmp(str->data, value, value_len) == 0;
+ return str->length == value_len && mycore_strncasecmp(str->data, value, value_len) == 0;
}
-bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated_i(myhtml_string_t* str, const char* value, size_t value_len)
+bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated_i(mycore_string_t* str, const char* value, size_t value_len)
{
if(str->length < value_len)
return false;
const char *data = str->data;
- if(myhtml_strncasecmp(data, value, value_len) == 0) {
- if((str->length > value_len && myhtml_utils_whithspace(data[value_len], ==, ||)) || str->length == value_len)
+ if(mycore_strncasecmp(data, value, value_len) == 0) {
+ if((str->length > value_len && mycore_utils_whithspace(data[value_len], ==, ||)) || str->length == value_len)
return true;
}
for(size_t i = 1; (str->length - i) >= value_len; i++)
{
- if(myhtml_utils_whithspace(data[(i - 1)], ==, ||)) {
- if(myhtml_strncasecmp(&data[i], value, value_len) == 0) {
- if((i > value_len && myhtml_utils_whithspace(data[(i + value_len)], ==, ||)) || (str->length - i) == value_len)
+ if(mycore_utils_whithspace(data[(i - 1)], ==, ||)) {
+ if(mycore_strncasecmp(&data[i], value, value_len) == 0) {
+ if((i > value_len && mycore_utils_whithspace(data[(i + value_len)], ==, ||)) || (str->length - i) == value_len)
return true;
}
}
@@ -933,23 +998,23 @@ bool myhtml_get_nodes_by_attribute_value_recursion_whitespace_separated_i(myhtml
return false;
}
-bool myhtml_get_nodes_by_attribute_value_recursion_begin_i(myhtml_string_t* str, const char* value, size_t value_len)
+bool myhtml_get_nodes_by_attribute_value_recursion_begin_i(mycore_string_t* str, const char* value, size_t value_len)
{
if(str->length < value_len)
return false;
- return myhtml_strncasecmp(str->data, value, value_len) == 0;
+ return mycore_strncasecmp(str->data, value, value_len) == 0;
}
-bool myhtml_get_nodes_by_attribute_value_recursion_end_i(myhtml_string_t* str, const char* value, size_t value_len)
+bool myhtml_get_nodes_by_attribute_value_recursion_end_i(mycore_string_t* str, const char* value, size_t value_len)
{
if(str->length < value_len)
return false;
- return myhtml_strncasecmp(&str->data[ (str->length - (str->length - value_len)) ], value, value_len) == 0;
+ return mycore_strncasecmp(&str->data[ (str->length - (str->length - value_len)) ], value, value_len) == 0;
}
-bool myhtml_get_nodes_by_attribute_value_recursion_contain_i(myhtml_string_t* str, const char* value, size_t value_len)
+bool myhtml_get_nodes_by_attribute_value_recursion_contain_i(mycore_string_t* str, const char* value, size_t value_len)
{
if(str->length < value_len)
return false;
@@ -958,7 +1023,7 @@ bool myhtml_get_nodes_by_attribute_value_recursion_contain_i(myhtml_string_t* st
for(size_t i = 0; (str->length - i) >= value_len; i++)
{
- if(myhtml_strncasecmp(&data[i], value, value_len) == 0) {
+ if(mycore_strncasecmp(&data[i], value, value_len) == 0) {
return true;
}
}
@@ -966,16 +1031,16 @@ bool myhtml_get_nodes_by_attribute_value_recursion_contain_i(myhtml_string_t* st
return false;
}
-bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated_i(myhtml_string_t* str, const char* value, size_t value_len)
+bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated_i(mycore_string_t* str, const char* value, size_t value_len)
{
const char *data = str->data;
if(str->length < value_len)
return false;
- else if(str->length == value_len && myhtml_strncasecmp(data, value, value_len) == 0) {
+ else if(str->length == value_len && mycore_strncasecmp(data, value, value_len) == 0) {
return true;
}
- else if(myhtml_strncasecmp(data, value, value_len) == 0 && data[value_len] == '-') {
+ else if(mycore_strncasecmp(data, value, value_len) == 0 && data[value_len] == '-') {
return true;
}
@@ -983,7 +1048,7 @@ bool myhtml_get_nodes_by_attribute_value_recursion_hyphen_separated_i(myhtml_str
}
/* find by attribute value; basic functions */
-myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion(myhtml_tree_node_t* node, myhtml_collection_t* collection,
+mystatus_t myhtml_get_nodes_by_attribute_value_recursion(myhtml_tree_node_t* node, myhtml_collection_t* collection,
myhtml_attribute_value_find_f func_eq,
const char* value, size_t value_len)
{
@@ -993,14 +1058,14 @@ myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion(myhtml_tree_node_t
myhtml_tree_attr_t* attr = node->token->attr_first;
while(attr) {
- myhtml_string_t* str = &attr->value;
+ mycore_string_t* str = &attr->value;
if(func_eq(str, value, value_len)) {
collection->list[ collection->length ] = node;
collection->length++;
if(collection->length >= collection->size) {
- myhtml_status_t status = myhtml_collection_check_size(collection, 1024, 0);
+ mystatus_t status = myhtml_collection_check_size(collection, 1024, 0);
if(status)
return status;
@@ -1012,7 +1077,7 @@ myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion(myhtml_tree_node_t
}
if(node->child) {
- myhtml_status_t status = myhtml_get_nodes_by_attribute_value_recursion(node->child, collection, func_eq, value, value_len);
+ mystatus_t status = myhtml_get_nodes_by_attribute_value_recursion(node->child, collection, func_eq, value, value_len);
if(status)
return status;
@@ -1024,7 +1089,7 @@ myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion(myhtml_tree_node_t
return MyHTML_STATUS_OK;
}
-myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion_by_key(myhtml_tree_node_t* node, myhtml_collection_t* collection,
+mystatus_t myhtml_get_nodes_by_attribute_value_recursion_by_key(myhtml_tree_node_t* node, myhtml_collection_t* collection,
myhtml_attribute_value_find_f func_eq,
const char* key, size_t key_len,
const char* value, size_t value_len)
@@ -1035,17 +1100,17 @@ myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion_by_key(myhtml_tree
myhtml_tree_attr_t* attr = node->token->attr_first;
while(attr) {
- myhtml_string_t* str_key = &attr->key;
- myhtml_string_t* str = &attr->value;
+ mycore_string_t* str_key = &attr->key;
+ mycore_string_t* str = &attr->value;
- if(str_key->length == key_len && myhtml_strncasecmp(str_key->data, key, key_len) == 0)
+ if(str_key->length == key_len && mycore_strncasecmp(str_key->data, key, key_len) == 0)
{
if(func_eq(str, value, value_len)) {
collection->list[ collection->length ] = node;
collection->length++;
if(collection->length >= collection->size) {
- myhtml_status_t status = myhtml_collection_check_size(collection, 1024, 0);
+ mystatus_t status = myhtml_collection_check_size(collection, 1024, 0);
if(status)
return status;
@@ -1058,7 +1123,7 @@ myhtml_status_t myhtml_get_nodes_by_attribute_value_recursion_by_key(myhtml_tree
}
if(node->child) {
- myhtml_status_t status = myhtml_get_nodes_by_attribute_value_recursion_by_key(node->child, collection, func_eq,
+ mystatus_t status = myhtml_get_nodes_by_attribute_value_recursion_by_key(node->child, collection, func_eq,
key, key_len, value, value_len);
if(status)
@@ -1075,7 +1140,7 @@ myhtml_collection_t * _myhtml_get_nodes_by_attribute_value(myhtml_tree_t *tree,
myhtml_attribute_value_find_f func_eq,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status)
+ mystatus_t* status)
{
if(collection == NULL) {
collection = myhtml_collection_create(1024, status);
@@ -1087,7 +1152,7 @@ myhtml_collection_t * _myhtml_get_nodes_by_attribute_value(myhtml_tree_t *tree,
if(node == NULL)
node = tree->node_html;
- myhtml_status_t rec_status;
+ mystatus_t rec_status;
if(key && key_len)
rec_status = myhtml_get_nodes_by_attribute_value_recursion_by_key(node, collection, func_eq, key, key_len, value, value_len);
@@ -1104,7 +1169,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_value(myhtml_tree_t *tree, m
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status)
+ mystatus_t* status)
{
if(case_insensitive) {
return _myhtml_get_nodes_by_attribute_value(tree, collection, node,
@@ -1121,7 +1186,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_value_whitespace_separated(m
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status)
+ mystatus_t* status)
{
if(case_insensitive) {
return _myhtml_get_nodes_by_attribute_value(tree, collection, node,
@@ -1138,7 +1203,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_value_begin(myhtml_tree_t *t
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status)
+ mystatus_t* status)
{
if(case_insensitive) {
return _myhtml_get_nodes_by_attribute_value(tree, collection, node,
@@ -1155,7 +1220,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_value_end(myhtml_tree_t *tre
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status)
+ mystatus_t* status)
{
if(case_insensitive) {
return _myhtml_get_nodes_by_attribute_value(tree, collection, node,
@@ -1172,7 +1237,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_value_contain(myhtml_tree_t
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status)
+ mystatus_t* status)
{
if(case_insensitive) {
return _myhtml_get_nodes_by_attribute_value(tree, collection, node,
@@ -1189,7 +1254,7 @@ myhtml_collection_t * myhtml_get_nodes_by_attribute_value_hyphen_separated(myhtm
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status)
+ mystatus_t* status)
{
if(case_insensitive) {
return _myhtml_get_nodes_by_attribute_value(tree, collection, node,
@@ -1257,7 +1322,7 @@ const char * myhtml_attribute_value(myhtml_tree_attr_t *attr, size_t *length)
return NULL;
}
-myhtml_string_t * myhtml_attribute_key_string(myhtml_tree_attr_t* attr)
+mycore_string_t * myhtml_attribute_key_string(myhtml_tree_attr_t* attr)
{
if(attr)
return &attr->key;
@@ -1265,7 +1330,7 @@ myhtml_string_t * myhtml_attribute_key_string(myhtml_tree_attr_t* attr)
return NULL;
}
-myhtml_string_t * myhtml_attribute_value_string(myhtml_tree_attr_t* attr)
+mycore_string_t * myhtml_attribute_value_string(myhtml_tree_attr_t* attr)
{
if(attr)
return &attr->value;
@@ -1281,7 +1346,7 @@ myhtml_tree_attr_t * myhtml_attribute_by_key(myhtml_tree_node_t *node, const cha
return myhtml_token_attr_by_name(node->token, key, key_len);
}
-myhtml_tree_attr_t * myhtml_attribute_add(myhtml_tree_node_t *node, const char *key, size_t key_len, const char *value, size_t value_len, myhtml_encoding_t encoding)
+myhtml_tree_attr_t * myhtml_attribute_add(myhtml_tree_node_t *node, const char *key, size_t key_len, const char *value, size_t value_len, myencoding_t encoding)
{
if(node == NULL)
return NULL;
@@ -1353,9 +1418,9 @@ myhtml_position_t myhtml_attribute_value_raw_position(myhtml_tree_attr_t *attr)
/*
* Collections
*/
-myhtml_collection_t * myhtml_collection_create(size_t size, myhtml_status_t *status)
+myhtml_collection_t * myhtml_collection_create(size_t size, mystatus_t *status)
{
- myhtml_collection_t *collection = (myhtml_collection_t*)myhtml_malloc(sizeof(myhtml_collection_t));
+ myhtml_collection_t *collection = (myhtml_collection_t*)mycore_malloc(sizeof(myhtml_collection_t));
if(collection == NULL) {
if(status)
@@ -1366,10 +1431,10 @@ myhtml_collection_t * myhtml_collection_create(size_t size, myhtml_status_t *sta
collection->size = size;
collection->length = 0;
- collection->list = (myhtml_tree_node_t **)myhtml_malloc(sizeof(myhtml_tree_node_t*) * size);
+ collection->list = (myhtml_tree_node_t **)mycore_malloc(sizeof(myhtml_tree_node_t*) * size);
if(collection->list == NULL) {
- myhtml_free(collection);
+ mycore_free(collection);
if(status)
*status = MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
@@ -1383,12 +1448,12 @@ myhtml_collection_t * myhtml_collection_create(size_t size, myhtml_status_t *sta
return collection;
}
-myhtml_status_t myhtml_collection_check_size(myhtml_collection_t *collection, size_t need, size_t upto_length)
+mystatus_t myhtml_collection_check_size(myhtml_collection_t *collection, size_t need, size_t upto_length)
{
if((collection->length + need) >= collection->size)
{
size_t tmp_size = collection->length + need + upto_length + 1;
- myhtml_tree_node_t **tmp = (myhtml_tree_node_t **)myhtml_realloc(collection->list, sizeof(myhtml_tree_node_t*) * tmp_size);
+ myhtml_tree_node_t **tmp = (myhtml_tree_node_t **)mycore_realloc(collection->list, sizeof(myhtml_tree_node_t*) * tmp_size);
if(tmp) {
collection->size = tmp_size;
@@ -1413,15 +1478,15 @@ myhtml_collection_t * myhtml_collection_destroy(myhtml_collection_t *collection)
return NULL;
if(collection->list)
- myhtml_free(collection->list);
+ mycore_free(collection->list);
- myhtml_free(collection);
+ mycore_free(collection);
return NULL;
}
/* queue */
-myhtml_status_t myhtml_queue_add(myhtml_tree_t *tree, size_t begin, myhtml_token_node_t* token)
+mystatus_t myhtml_queue_add(myhtml_tree_t *tree, size_t begin, myhtml_token_node_t* token)
{
// TODO: need refactoring this code
// too many conditions
@@ -1437,50 +1502,48 @@ myhtml_status_t myhtml_queue_add(myhtml_tree_t *tree, size_t begin, myhtml_token
}
}
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
if(tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) {
if(qnode && token) {
- qnode->token = token;
+ qnode->args = token;
myhtml_parser_worker(0, qnode);
myhtml_parser_stream(0, qnode);
}
- tree->current_qnode = mythread_queue_node_malloc_limit(tree->myhtml->thread, tree->queue, 4, NULL);
+ tree->current_qnode = mythread_queue_node_malloc_limit(tree->myhtml->thread_stream, tree->queue, 4, NULL);
}
else {
if(qnode)
- qnode->token = token;
+ qnode->args = token;
- tree->current_qnode = mythread_queue_node_malloc_round(tree->myhtml->thread, tree->queue_entry, NULL);
+ tree->current_qnode = mythread_queue_node_malloc_round(tree->myhtml->thread_stream, tree->queue_entry, NULL);
}
#else
if(qnode && token) {
- qnode->token = token;
+ qnode->args = token;
myhtml_parser_worker(0, qnode);
myhtml_parser_stream(0, qnode);
}
- tree->current_qnode = mythread_queue_node_malloc_limit(tree->myhtml->thread, tree->queue, 4, NULL);
+ tree->current_qnode = mythread_queue_node_malloc_limit(tree->myhtml->thread_stream, tree->queue, 4, NULL);
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
+#endif /* MyCORE_BUILD_WITHOUT_THREADS */
- if(tree->current_qnode == NULL) {
+ if(tree->current_qnode == NULL)
return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
- }
- tree->current_qnode->tree = tree;
+ tree->current_qnode->context = tree;
tree->current_qnode->prev = qnode;
if(qnode && token)
myhtml_tokenizer_calc_current_namespace(tree, token);
tree->current_token_node = myhtml_token_node_create(tree->token, tree->token->mcasync_token_id);
-
if(tree->current_token_node == NULL)
return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
diff --git a/source/myhtml/myhtml.h b/source/myhtml/myhtml.h
index 9a049e2..1bc94e1 100644
--- a/source/myhtml/myhtml.h
+++ b/source/myhtml/myhtml.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -28,19 +28,19 @@ extern "C" {
#include "myhtml/myosi.h"
-#include "myhtml/utils/mctree.h"
-#include "myhtml/utils/mcobject_async.h"
+#include "mycore/utils/mctree.h"
+#include "mycore/utils/mcobject_async.h"
+#include "mycore/mythread.h"
+#include "mycore/incoming.h"
+#include "myencoding/encoding.h"
#include "myhtml/tree.h"
#include "myhtml/tag.h"
#include "myhtml/def.h"
#include "myhtml/parser.h"
#include "myhtml/tokenizer.h"
-#include "myhtml/thread.h"
#include "myhtml/rules.h"
#include "myhtml/token.h"
#include "myhtml/charef.h"
-#include "myhtml/encoding.h"
-#include "myhtml/incoming.h"
#include "myhtml/callback.h"
#define mh_queue_current() tree->queue
@@ -65,8 +65,10 @@ extern "C" {
(onechar < 'A' || onechar > 'Z'))
struct myhtml {
- mythread_t *thread;
- //mchar_async_t *mchar; // for all
+ mythread_t* thread_stream;
+ mythread_t* thread_batch;
+ mythread_t* thread_list[3];
+ size_t thread_total;
myhtml_tokenizer_state_f* parse_state_func;
myhtml_insertion_f* insertion_func;
@@ -83,68 +85,68 @@ struct myhtml_collection {
myhtml_t * myhtml_create(void);
-myhtml_status_t myhtml_init(myhtml_t* myhtml, enum myhtml_options opt, size_t thread_count, size_t queue_size);
+mystatus_t myhtml_init(myhtml_t* myhtml, enum myhtml_options opt, size_t thread_count, size_t queue_size);
void myhtml_clean(myhtml_t* myhtml);
myhtml_t* myhtml_destroy(myhtml_t* myhtml);
-myhtml_status_t myhtml_parse(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size);
-myhtml_status_t myhtml_parse_fragment(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
+mystatus_t myhtml_parse(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size);
+mystatus_t myhtml_parse_fragment(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
-myhtml_status_t myhtml_parse_single(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size);
-myhtml_status_t myhtml_parse_fragment_single(myhtml_tree_t* tree, myhtml_encoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
+mystatus_t myhtml_parse_single(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size);
+mystatus_t myhtml_parse_fragment_single(myhtml_tree_t* tree, myencoding_t encoding, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
-myhtml_status_t myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t html_size);
-myhtml_status_t myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
-myhtml_status_t myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, size_t html_size);
-myhtml_status_t myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
-myhtml_status_t myhtml_parse_chunk_end(myhtml_tree_t* tree);
+mystatus_t myhtml_parse_chunk(myhtml_tree_t* tree, const char* html, size_t html_size);
+mystatus_t myhtml_parse_chunk_fragment(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
+mystatus_t myhtml_parse_chunk_single(myhtml_tree_t* tree, const char* html, size_t html_size);
+mystatus_t myhtml_parse_chunk_fragment_single(myhtml_tree_t* tree, const char* html, size_t html_size, myhtml_tag_id_t tag_id, enum myhtml_namespace ns);
+mystatus_t myhtml_parse_chunk_end(myhtml_tree_t* tree);
// encoding
-void myhtml_encoding_set(myhtml_tree_t* tree, myhtml_encoding_t encoding);
-myhtml_encoding_t myhtml_encoding_get(myhtml_tree_t* tree);
+void myhtml_encoding_set(myhtml_tree_t* tree, myencoding_t encoding);
+myencoding_t myhtml_encoding_get(myhtml_tree_t* tree);
-myhtml_collection_t * myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tag_id_t tag_id, myhtml_status_t *status);
-myhtml_collection_t * myhtml_get_nodes_by_name(myhtml_tree_t* tree, myhtml_collection_t *collection, const char* html, size_t length, myhtml_status_t *status);
-myhtml_collection_t * myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* scope_node, const char* key, size_t key_len, myhtml_status_t* status);
+myhtml_collection_t * myhtml_get_nodes_by_tag_id(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tag_id_t tag_id, mystatus_t *status);
+myhtml_collection_t * myhtml_get_nodes_by_name(myhtml_tree_t* tree, myhtml_collection_t *collection, const char* html, size_t length, mystatus_t *status);
+myhtml_collection_t * myhtml_get_nodes_by_attribute_key(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* scope_node, const char* key, size_t key_len, mystatus_t* status);
/* like a [some=value] or #id */
myhtml_collection_t * myhtml_get_nodes_by_attribute_value(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* node,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/* like a [some~=value] or .class */
myhtml_collection_t * myhtml_get_nodes_by_attribute_value_whitespace_separated(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* node,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/* like a [some^=value] */
myhtml_collection_t * myhtml_get_nodes_by_attribute_value_begin(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* node,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/* like a [some$=value] */
myhtml_collection_t * myhtml_get_nodes_by_attribute_value_end(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* node,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/* like a [some*=value] */
myhtml_collection_t * myhtml_get_nodes_by_attribute_value_contain(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* node,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
/* like a [some|=value] */
myhtml_collection_t * myhtml_get_nodes_by_attribute_value_hyphen_separated(myhtml_tree_t *tree, myhtml_collection_t* collection, myhtml_tree_node_t* node,
bool case_insensitive,
const char* key, size_t key_len,
const char* value, size_t value_len,
- myhtml_status_t* status);
+ mystatus_t* status);
-myhtml_collection_t * myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, myhtml_tag_id_t tag_id, myhtml_status_t *status);
-myhtml_collection_t * myhtml_get_nodes_by_name_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, const char* html, size_t length, myhtml_status_t *status);
+myhtml_collection_t * myhtml_get_nodes_by_tag_id_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, myhtml_tag_id_t tag_id, mystatus_t *status);
+myhtml_collection_t * myhtml_get_nodes_by_name_in_scope(myhtml_tree_t* tree, myhtml_collection_t *collection, myhtml_tree_node_t *node, const char* html, size_t length, mystatus_t *status);
myhtml_tree_node_t * myhtml_node_first(myhtml_tree_t* tree);
myhtml_tree_node_t * myhtml_node_next(myhtml_tree_node_t *node);
@@ -174,7 +176,7 @@ bool myhtml_node_is_close_self(myhtml_tree_node_t *node);
myhtml_tree_attr_t * myhtml_node_attribute_first(myhtml_tree_node_t *node);
myhtml_tree_attr_t * myhtml_node_attribute_last(myhtml_tree_node_t *node);
const char * myhtml_node_text(myhtml_tree_node_t *node, size_t *length);
-myhtml_string_t * myhtml_node_string(myhtml_tree_node_t *node);
+mycore_string_t * myhtml_node_string(myhtml_tree_node_t *node);
myhtml_position_t myhtml_node_raw_pasition(myhtml_tree_node_t *node);
myhtml_position_t myhtml_node_element_pasition(myhtml_tree_node_t *node);
void myhtml_node_set_data(myhtml_tree_node_t *node, void* data);
@@ -188,10 +190,10 @@ void myhtml_attribute_namespace_set(myhtml_tree_attr_t *attr, myhtml_namespace_t
const char * myhtml_attribute_key(myhtml_tree_attr_t *attr, size_t *length);
const char * myhtml_attribute_value(myhtml_tree_attr_t *attr, size_t *length);
-myhtml_string_t * myhtml_attribute_key_string(myhtml_tree_attr_t* attr);
-myhtml_string_t * myhtml_attribute_value_string(myhtml_tree_attr_t* attr);
+mycore_string_t * myhtml_attribute_key_string(myhtml_tree_attr_t* attr);
+mycore_string_t * myhtml_attribute_value_string(myhtml_tree_attr_t* attr);
myhtml_tree_attr_t * myhtml_attribute_by_key(myhtml_tree_node_t *node, const char *key, size_t key_len);
-myhtml_tree_attr_t * myhtml_attribute_add(myhtml_tree_node_t *node, const char *key, size_t key_len, const char *value, size_t value_len, myhtml_encoding_t encoding);
+myhtml_tree_attr_t * myhtml_attribute_add(myhtml_tree_node_t *node, const char *key, size_t key_len, const char *value, size_t value_len, myencoding_t encoding);
myhtml_tree_attr_t * myhtml_attribute_remove(myhtml_tree_node_t *node, myhtml_tree_attr_t *attr);
myhtml_tree_attr_t * myhtml_attribute_remove_by_key(myhtml_tree_node_t *node, const char *key, size_t key_len);
void myhtml_attribute_delete(myhtml_tree_t *tree, myhtml_tree_node_t *node, myhtml_tree_attr_t *attr);
@@ -200,35 +202,20 @@ myhtml_position_t myhtml_attribute_key_raw_position(myhtml_tree_attr_t *attr);
myhtml_position_t myhtml_attribute_value_raw_position(myhtml_tree_attr_t *attr);
/* collection */
-myhtml_collection_t * myhtml_collection_create(size_t size, myhtml_status_t *status);
+myhtml_collection_t * myhtml_collection_create(size_t size, mystatus_t *status);
void myhtml_collection_clean(myhtml_collection_t *collection);
myhtml_collection_t * myhtml_collection_destroy(myhtml_collection_t *collection);
-myhtml_status_t myhtml_collection_check_size(myhtml_collection_t *collection, size_t need, size_t upto_length);
+mystatus_t myhtml_collection_check_size(myhtml_collection_t *collection, size_t need, size_t upto_length);
// strings
-myhtml_string_t * myhtml_node_text_set(myhtml_tree_node_t *node, const char* text, size_t length, myhtml_encoding_t encoding);
-myhtml_string_t * myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, const char* text, size_t length, myhtml_encoding_t encoding);
+mycore_string_t * myhtml_node_text_set(myhtml_tree_node_t *node, const char* text, size_t length, myencoding_t encoding);
+mycore_string_t * myhtml_node_text_set_with_charef(myhtml_tree_node_t *node, const char* text, size_t length, myencoding_t encoding);
bool myhtml_utils_strcmp(const char* ab, const char* to_lowercase, size_t size);
bool myhtml_is_html_node(myhtml_tree_node_t *node, myhtml_tag_id_t tag_id);
// queue
-myhtml_status_t myhtml_queue_add(myhtml_tree_t *tree, size_t begin, myhtml_token_node_t* token);
-
-/**
- * Platform-specific hdef performance clock queries.
- * Implemented in perf.c
- */
-
-/** Get clock resolution */
-uint64_t myhtml_hperf_res(myhtml_status_t *status);
-
-/** Get current value in clock ticks */
-uint64_t myhtml_hperf_clock(myhtml_status_t *status);
-
-/** Print an hperf measure */
-myhtml_status_t myhtml_hperf_print(const char *name, uint64_t x, uint64_t y, FILE *fh);
-myhtml_status_t myhtml_hperf_print_by_val(const char *name, uint64_t x, FILE *fh);
+mystatus_t myhtml_queue_add(myhtml_tree_t *tree, size_t begin, myhtml_token_node_t* token);
/* version */
myhtml_version_t myhtml_version(void);
diff --git a/source/myhtml/mynamespace.c b/source/myhtml/mynamespace.c
index 596b518..4821c75 100644
--- a/source/myhtml/mynamespace.c
+++ b/source/myhtml/mynamespace.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -20,19 +20,19 @@
#include "myhtml/mynamespace.h"
#include "myhtml/mynamespace_resource.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
const myhtml_namespace_detect_name_entry_t * myhtml_namespace_name_entry_by_name(const char* name, size_t length)
{
- size_t idx = ((myhtml_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
- myhtml_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
+ size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
+ mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
length)
% MyHTML_NAMESPACE_DETECT_NAME_STATIC_SIZE) + 1;
while (myhtml_namespace_detect_name_entry_static_list_index[idx].name)
{
if(myhtml_namespace_detect_name_entry_static_list_index[idx].name_length == length) {
- if(myhtml_strncasecmp(myhtml_namespace_detect_name_entry_static_list_index[idx].name, name, length) == 0)
+ if(mycore_strncasecmp(myhtml_namespace_detect_name_entry_static_list_index[idx].name, name, length) == 0)
return &myhtml_namespace_detect_name_entry_static_list_index[idx];
if(myhtml_namespace_detect_name_entry_static_list_index[idx].next)
diff --git a/source/myhtml/mynamespace.h b/source/myhtml/mynamespace.h
index 0d8d0e9..755cd09 100644
--- a/source/myhtml/mynamespace.h
+++ b/source/myhtml/mynamespace.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -31,7 +31,7 @@ extern "C" {
#include <string.h>
#include "myhtml/myosi.h"
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
struct myhtml_namespace_detect_name_entry {
const char* name;
diff --git a/source/myhtml/mynamespace_resource.h b/source/myhtml/mynamespace_resource.h
index e584cb7..be20f0b 100644
--- a/source/myhtml/mynamespace_resource.h
+++ b/source/myhtml/mynamespace_resource.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/source/myhtml/myosi.h b/source/myhtml/myosi.h
index 3901fae..cdc14db 100644
--- a/source/myhtml/myosi.h
+++ b/source/myhtml/myosi.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -22,181 +22,23 @@
#define MyHTML_MYOSI_H
#pragma once
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-#include <stdint.h>
-#include <stdarg.h>
+#include "mycore/myosi.h"
-#define MyHTML_VERSION_MAJOR 3
+#define MyHTML_VERSION_MAJOR 4
#define MyHTML_VERSION_MINOR 0
#define MyHTML_VERSION_PATCH 0
-#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WINPTHREADS_VERSION)
-#define IS_OS_WINDOWS
-#include <windows.h>
-#endif
-
-#if defined(_MSC_VER)
-# define MyHTML_DEPRECATED(func) __declspec(deprecated) func
-#elif defined(__GNUC__) || defined(__INTEL_COMPILER)
-# define MyHTML_DEPRECATED(func) func __attribute__((deprecated))
-#else
-# define MyHTML_DEPRECATED(func) func
-#endif
+#define MyHTML_VERSION_STRING MyCORE_STR(MyHTML_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyHTML_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyHTML_VERSION_PATCH)
#ifdef __cplusplus
extern "C" {
#endif
-/* Mem */
-#ifdef MyHTML_EXTERN_MALLOC
- extern void * MyHTML_EXTERN_MALLOC(size_t size);
- #define myhtml_malloc MyHTML_EXTERN_MALLOC
-#else
- #define myhtml_malloc myhtml_mem_malloc
-#endif
-
-#ifdef MyHTML_EXTERN_REALLOC
- extern void * MyHTML_EXTERN_REALLOC(void* dst, size_t size);
- #define myhtml_realloc MyHTML_EXTERN_REALLOC
-#else
- #define myhtml_realloc myhtml_mem_realloc
-#endif
-
-#ifdef MyHTML_EXTERN_CALLOC
- extern void * MyHTML_EXTERN_CALLOC(size_t num, size_t size);
- #define myhtml_calloc MyHTML_EXTERN_CALLOC
-#else
- #define myhtml_calloc myhtml_mem_calloc
-#endif
-
-#ifdef MyHTML_EXTERN_FREE
- extern void MyHTML_EXTERN_FREE(void* dst);
- #define myhtml_free MyHTML_EXTERN_FREE
-#else
- #define myhtml_free myhtml_mem_free
-#endif
-
-/* Debug */
-#ifdef DEBUG_MODE
- #define MyHTML_DEBUG(format, ...) \
- myhtml_print(stderr, "DEBUG: "format"\n", ##__VA_ARGS__)
-#else
- #define MyHTML_DEBUG(format, ...)
-#endif
-
-#ifdef DEBUG_MODE
- #define MyHTML_DEBUG_ERROR(format, ...) \
- myhtml_print(stderr, "DEBUG ERROR: "format"\n", ##__VA_ARGS__)
-#else
- #define MyHTML_DEBUG_ERROR(format, ...)
-#endif
-
-#define myhtml_base_add(myhtml, point, lenn, sizen, strcn, size) \
- myhtml->Lenn++; \
- if(myhtml->lenn == myhtml->sizen) { \
- myhtml->sizen += size; \
- myhtml->point = (strcn*)myhtml_realloc(myhtml->point, \
- sizeof(strcn) * myhtml->sizen); \
- }
-
#define MyHTML_FAILED(_status_) ((_status_) != MyHTML_STATUS_OK)
-// encoding
-// https://encoding.spec.whatwg.org/#the-encoding
-// https://encoding.spec.whatwg.org/#legacy-single-byte-encodings
-// https://encoding.spec.whatwg.org/#legacy-multi-byte-chinese-(simplified)-encodings
-// https://encoding.spec.whatwg.org/#legacy-multi-byte-chinese-(traditional)-encodings
-// https://encoding.spec.whatwg.org/#legacy-multi-byte-japanese-encodings
-// https://encoding.spec.whatwg.org/#legacy-multi-byte-korean-encodings
-// https://encoding.spec.whatwg.org/#legacy-miscellaneous-encodings
-
-enum myhtml_encoding_list {
- MyHTML_ENCODING_DEFAULT = 0x00,
-// MyHTML_ENCODING_AUTO = 0x01, // future
- MyHTML_ENCODING_NOT_DETERMINED = 0x02,
- MyHTML_ENCODING_UTF_8 = 0x00, // default encoding
- MyHTML_ENCODING_UTF_16LE = 0x04,
- MyHTML_ENCODING_UTF_16BE = 0x05,
- MyHTML_ENCODING_X_USER_DEFINED = 0x06,
- MyHTML_ENCODING_BIG5 = 0x07,
- MyHTML_ENCODING_EUC_JP = 0x08,
- MyHTML_ENCODING_EUC_KR = 0x09,
- MyHTML_ENCODING_GB18030 = 0x0a,
- MyHTML_ENCODING_GBK = 0x0b,
- MyHTML_ENCODING_IBM866 = 0x0c,
- MyHTML_ENCODING_ISO_2022_JP = 0x0d,
- MyHTML_ENCODING_ISO_8859_10 = 0x0e,
- MyHTML_ENCODING_ISO_8859_13 = 0x0f,
- MyHTML_ENCODING_ISO_8859_14 = 0x10,
- MyHTML_ENCODING_ISO_8859_15 = 0x11,
- MyHTML_ENCODING_ISO_8859_16 = 0x12,
- MyHTML_ENCODING_ISO_8859_2 = 0x13,
- MyHTML_ENCODING_ISO_8859_3 = 0x14,
- MyHTML_ENCODING_ISO_8859_4 = 0x15,
- MyHTML_ENCODING_ISO_8859_5 = 0x16,
- MyHTML_ENCODING_ISO_8859_6 = 0x17,
- MyHTML_ENCODING_ISO_8859_7 = 0x18,
- MyHTML_ENCODING_ISO_8859_8 = 0x19,
- MyHTML_ENCODING_ISO_8859_8_I = 0x1a,
- MyHTML_ENCODING_KOI8_R = 0x1b,
- MyHTML_ENCODING_KOI8_U = 0x1c,
- MyHTML_ENCODING_MACINTOSH = 0x1d,
- MyHTML_ENCODING_SHIFT_JIS = 0x1e,
- MyHTML_ENCODING_WINDOWS_1250 = 0x1f,
- MyHTML_ENCODING_WINDOWS_1251 = 0x20,
- MyHTML_ENCODING_WINDOWS_1252 = 0x21,
- MyHTML_ENCODING_WINDOWS_1253 = 0x22,
- MyHTML_ENCODING_WINDOWS_1254 = 0x23,
- MyHTML_ENCODING_WINDOWS_1255 = 0x24,
- MyHTML_ENCODING_WINDOWS_1256 = 0x25,
- MyHTML_ENCODING_WINDOWS_1257 = 0x26,
- MyHTML_ENCODING_WINDOWS_1258 = 0x27,
- MyHTML_ENCODING_WINDOWS_874 = 0x28,
- MyHTML_ENCODING_X_MAC_CYRILLIC = 0x29,
- MyHTML_ENCODING_LAST_ENTRY = 0x2a
-}
-typedef myhtml_encoding_t;
-
-typedef struct myhtml_encoding_result myhtml_encoding_result_t;
-typedef struct myhtml_encoding_trigram myhtml_encoding_trigram_t;
-typedef struct myhtml_encoding_trigram_result myhtml_encoding_trigram_result_t;
-typedef struct myhtml_encoding_unicode_result myhtml_encoding_unicode_result_t;
-typedef struct myhtml_encoding_detect_name_entry myhtml_encoding_detect_name_entry_t;
-typedef struct myhtml_encoding_detect_attr myhtml_encoding_detect_attr_t;
-typedef struct myhtml_encoding_entry_name_index myhtml_encoding_entry_name_index_t;
-
// char references
typedef struct myhtml_data_process_entry myhtml_data_process_entry_t;
-// strings
-typedef struct myhtml_string_raw myhtml_string_raw_t;
-typedef struct myhtml_string myhtml_string_t;
-
-// thread
-enum mythread_thread_opt {
- MyTHREAD_OPT_UNDEF = 0x00,
- MyTHREAD_OPT_WAIT = 0x01,
- MyTHREAD_OPT_QUIT = 0x02,
- MyTHREAD_OPT_STOP = 0x04,
- MyTHREAD_OPT_DONE = 0x08
-}
-typedef mythread_thread_opt_t;
-
-typedef struct mythread_queue_list_entry mythread_queue_list_entry_t;
-typedef struct mythread_queue_thread_param mythread_queue_thread_param_t;
-typedef struct mythread_queue_list mythread_queue_list_t;
-typedef struct mythread_queue_node mythread_queue_node_t;
-typedef struct mythread_queue mythread_queue_t;
-
-typedef size_t mythread_id_t;
-typedef struct mythread_workers_list mythread_workers_list_t;
-typedef struct mythread_context mythread_context_t;
-typedef struct mythread_list mythread_list_t;
-typedef struct mythread mythread_t;
-
// tree
enum myhtml_tree_flags {
MyHTML_TREE_FLAGS_CLEAN = 0x000,
@@ -386,68 +228,33 @@ enum myhtml_insertion_mode {
// base
/*
Very important!!!
-
- for myhtml 0..00ffff; MyHTML_STATUS_OK == 0x000000
- for mycss and modules 010000..01ffff; MyCSS_STATUS_OK == 0x000000
- for modest 020000..02ffff; MODEST_STATUS_OK == 0x000000
- for myrender 030000..03ffff; MyRENDER_STATUS_OK == 0x000000
- for mydom 040000..04ffff; MyDOM_STATUS_OK == 0x000000
- for mynetwork 050000..05ffff; MyNETWORK_STATUS_OK == 0x000000
- for myecma 060000..06ffff; MyECMA_STATUS_OK == 0x000000
- not occupied 070000..
+ See mycore/myosi.h:mystatus_t
*/
enum myhtml_status {
MyHTML_STATUS_OK = 0x0000,
MyHTML_STATUS_ERROR = 0x0001,
MyHTML_STATUS_ERROR_MEMORY_ALLOCATION = 0x0002,
- MyHTML_STATUS_THREAD_ERROR_MEMORY_ALLOCATION = 0x0009,
- MyHTML_STATUS_THREAD_ERROR_LIST_INIT = 0x000a,
- MyHTML_STATUS_THREAD_ERROR_ATTR_MALLOC = 0x000b,
- MyHTML_STATUS_THREAD_ERROR_ATTR_INIT = 0x000c,
- MyHTML_STATUS_THREAD_ERROR_ATTR_SET = 0x000d,
- MyHTML_STATUS_THREAD_ERROR_ATTR_DESTROY = 0x000e,
- MyHTML_STATUS_THREAD_ERROR_NO_SLOTS = 0x000f,
- MyHTML_STATUS_THREAD_ERROR_BATCH_INIT = 0x0010,
- MyHTML_STATUS_THREAD_ERROR_WORKER_MALLOC = 0x0011,
- MyHTML_STATUS_THREAD_ERROR_WORKER_SEM_CREATE = 0x0012,
- MyHTML_STATUS_THREAD_ERROR_WORKER_THREAD_CREATE = 0x0013,
- MyHTML_STATUS_THREAD_ERROR_MASTER_THREAD_CREATE = 0x0014,
- MyHTML_STATUS_THREAD_ERROR_SEM_PREFIX_MALLOC = 0x0032,
- MyHTML_STATUS_THREAD_ERROR_SEM_CREATE = 0x0033,
- MyHTML_STATUS_THREAD_ERROR_QUEUE_MALLOC = 0x003c,
- MyHTML_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC = 0x003d,
- MyHTML_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC = 0x003e,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_MALLOC = 0x0046,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_INIT = 0x0047,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_LOCK = 0x0048,
- MyHTML_STATUS_THREAD_ERROR_MUTEX_UNLOCK = 0x0049,
- MyHTML_STATUS_RULES_ERROR_MEMORY_ALLOCATION = 0x0064,
- MyHTML_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF = 0x00c8,
- MyHTML_STATUS_PERF_ERROR_FIND_CPU_CLOCK = 0x00c9,
- MyHTML_STATUS_TOKENIZER_ERROR_MEMORY_ALLOCATION = 0x012c,
- MyHTML_STATUS_TOKENIZER_ERROR_FRAGMENT_INIT = 0x012d,
- MyHTML_STATUS_TAGS_ERROR_MEMORY_ALLOCATION = 0x0190,
- MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE = 0x0191,
- MyHTML_STATUS_TAGS_ERROR_MCOBJECT_MALLOC = 0x0192,
- MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE_NODE = 0x0193,
- MyHTML_STATUS_TAGS_ERROR_CACHE_MEMORY_ALLOCATION = 0x0194,
- MyHTML_STATUS_TAGS_ERROR_INDEX_MEMORY_ALLOCATION = 0x0195,
- MyHTML_STATUS_TREE_ERROR_MEMORY_ALLOCATION = 0x01f4,
- MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE = 0x01f5,
- MyHTML_STATUS_TREE_ERROR_MCOBJECT_INIT = 0x01f6,
- MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE_NODE = 0x01f7,
- MyHTML_STATUS_TREE_ERROR_INCOMING_BUFFER_CREATE = 0x01f8,
- MyHTML_STATUS_ATTR_ERROR_ALLOCATION = 0x0258,
- MyHTML_STATUS_ATTR_ERROR_CREATE = 0x0259,
- MyHTML_STATUS_STREAM_BUFFER_ERROR_CREATE = 0x0300,
- MyHTML_STATUS_STREAM_BUFFER_ERROR_INIT = 0x0301,
- MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_CREATE = 0x0302,
- MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_INIT = 0x0303,
- MyHTML_STATUS_STREAM_BUFFER_ERROR_ADD_ENTRY = 0x0304,
- MyHTML_STATUS_MCOBJECT_ERROR_CACHE_CREATE = 0x0340,
- MyHTML_STATUS_MCOBJECT_ERROR_CHUNK_CREATE = 0x0341,
- MyHTML_STATUS_MCOBJECT_ERROR_CHUNK_INIT = 0x0342,
- MyHTML_STATUS_MCOBJECT_ERROR_CACHE_REALLOC = 0x0343
+ MyHTML_STATUS_RULES_ERROR_MEMORY_ALLOCATION = 0x9064,
+ MyHTML_STATUS_TOKENIZER_ERROR_MEMORY_ALLOCATION = 0x912c,
+ MyHTML_STATUS_TOKENIZER_ERROR_FRAGMENT_INIT = 0x912d,
+ MyHTML_STATUS_TAGS_ERROR_MEMORY_ALLOCATION = 0x9190,
+ MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE = 0x9191,
+ MyHTML_STATUS_TAGS_ERROR_MCOBJECT_MALLOC = 0x9192,
+ MyHTML_STATUS_TAGS_ERROR_MCOBJECT_CREATE_NODE = 0x9193,
+ MyHTML_STATUS_TAGS_ERROR_CACHE_MEMORY_ALLOCATION = 0x9194,
+ MyHTML_STATUS_TAGS_ERROR_INDEX_MEMORY_ALLOCATION = 0x9195,
+ MyHTML_STATUS_TREE_ERROR_MEMORY_ALLOCATION = 0x91f4,
+ MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE = 0x91f5,
+ MyHTML_STATUS_TREE_ERROR_MCOBJECT_INIT = 0x91f6,
+ MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE_NODE = 0x91f7,
+ MyHTML_STATUS_TREE_ERROR_INCOMING_BUFFER_CREATE = 0x91f8,
+ MyHTML_STATUS_ATTR_ERROR_ALLOCATION = 0x9258,
+ MyHTML_STATUS_ATTR_ERROR_CREATE = 0x9259,
+ MyHTML_STATUS_STREAM_BUFFER_ERROR_CREATE = 0x9300,
+ MyHTML_STATUS_STREAM_BUFFER_ERROR_INIT = 0x9301,
+ MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_CREATE = 0x9302,
+ MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_INIT = 0x9303,
+ MyHTML_STATUS_STREAM_BUFFER_ERROR_ADD_ENTRY = 0x9304
}
typedef myhtml_status_t;
@@ -486,7 +293,6 @@ struct myhtml_version {
}
typedef myhtml_version_t;
-typedef struct myhtml_incoming_buffer myhtml_incoming_buffer_t;
typedef myhtml_token_attr_t myhtml_tree_attr_t;
typedef struct myhtml_collection myhtml_collection_t;
typedef struct myhtml myhtml_t;
@@ -498,24 +304,14 @@ typedef size_t (*myhtml_tokenizer_state_f)(myhtml_tree_t* tree, myhtml_token_nod
typedef bool (*myhtml_insertion_f)(myhtml_tree_t* tree, myhtml_token_node_t* token);
// char references state
-typedef size_t (*myhtml_data_process_state_f)(myhtml_data_process_entry_t* charef, myhtml_string_t* str, const char* data, size_t offset, size_t size);
+typedef size_t (*myhtml_data_process_state_f)(myhtml_data_process_entry_t* charef, mycore_string_t* str, const char* data, size_t offset, size_t size);
// callback functions
typedef void* (*myhtml_callback_token_f)(myhtml_tree_t* tree, myhtml_token_node_t* token, void* ctx);
typedef void (*myhtml_callback_tree_node_f)(myhtml_tree_t* tree, myhtml_tree_node_t* node, void* ctx);
// find attribute value functions
-typedef bool (*myhtml_attribute_value_find_f)(myhtml_string_t* str_key, const char* value, size_t value_len);
-
-// callback to be implemented by the user
-typedef void (*myhtml_callback_serialize_f)(const char* buffer, size_t size, void* ctx);
-
-void * myhtml_mem_malloc(size_t size);
-void * myhtml_mem_realloc(void* dst, size_t size);
-void * myhtml_mem_calloc(size_t num, size_t size);
-void myhtml_mem_free(void* dst);
-
-void myhtml_print(FILE* out, const char* format, ...);
+typedef bool (*myhtml_attribute_value_find_f)(mycore_string_t* str_key, const char* value, size_t value_len);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myhtml/mystring.c b/source/myhtml/mystring.c
index a353e60..71888e4 100644
--- a/source/myhtml/mystring.c
+++ b/source/myhtml/mystring.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -19,205 +19,11 @@
*/
#include "myhtml/mystring.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
-/////////////////////////////////////////////////////////
-//// Init, Clean, Destroy
-////
-/////////////////////////////////////////////////////////
-char * myhtml_string_init(mchar_async_t *mchar, size_t node_idx, myhtml_string_t* str, size_t size)
-{
- str->data = mchar_async_malloc(mchar, node_idx, size);
- str->size = size;
- str->node_idx = node_idx;
- str->mchar = mchar;
-
- myhtml_string_clean(str);
-
- return str->data;
-}
-
-void myhtml_string_clean(myhtml_string_t* str)
-{
- str->length = 0;
-}
-
-void myhtml_string_clean_all(myhtml_string_t* str)
-{
- memset(str, 0, sizeof(myhtml_string_t));
-}
-
-myhtml_string_t * myhtml_string_destroy(myhtml_string_t* str, bool destroy_obj)
-{
- if(str == NULL)
- return NULL;
-
- if(str->data && str->mchar)
- mchar_async_free(str->mchar, str->node_idx, str->data);
-
- if(destroy_obj && str) {
- myhtml_free(str);
- return NULL;
- }
-
- return str;
-}
-
-void myhtml_string_raw_clean(myhtml_string_raw_t* str_raw)
-{
- str_raw->length = 0;
-}
-
-void myhtml_string_raw_clean_all(myhtml_string_raw_t* str_raw)
-{
- memset(str_raw, 0, sizeof(myhtml_string_raw_t));
-}
-
-myhtml_string_raw_t * myhtml_string_raw_destroy(myhtml_string_raw_t* str_raw, bool destroy_obj)
-{
- if(str_raw == NULL)
- return NULL;
-
- if(str_raw->data) {
- myhtml_free(str_raw->data);
- str_raw->data = NULL;
- }
-
- if(destroy_obj && str_raw) {
- myhtml_free(str_raw);
- return NULL;
- }
-
- return str_raw;
-}
-
-char * myhtml_string_realloc(myhtml_string_t *str, size_t new_size)
-{
- if(str == NULL)
- return NULL;
-
- char *tmp = mchar_async_realloc(str->mchar, str->node_idx, str->data, str->length, new_size);
-
- if(tmp) {
- str->size = new_size;
- str->data = tmp;
- }
- else
- return NULL;
-
- return tmp;
-}
-
-/////////////////////////////////////////////////////////
-//// Basic API
-////
-/////////////////////////////////////////////////////////
-char * myhtml_string_data_alloc(mchar_async_t *mchar, size_t node_id, size_t size)
-{
- return mchar_async_malloc(mchar, node_id, size);
-}
-
-char * myhtml_string_data_realloc(mchar_async_t *mchar, size_t node_id, char *data, size_t len_to_copy, size_t size)
-{
- return mchar_async_realloc(mchar, node_id, data, len_to_copy, size);
-}
-
-void myhtml_string_data_free(mchar_async_t *mchar, size_t node_id, char *data)
+size_t myhtml_string_append_with_preprocessing(mycore_string_t* str, const char* buff, size_t length, bool emit_null_chars)
{
- mchar_async_free(mchar, node_id, data);
-}
-
-char * myhtml_string_data(myhtml_string_t *str)
-{
- if(str == NULL)
- return NULL;
-
- return str->data;
-}
-
-size_t myhtml_string_length(myhtml_string_t *str)
-{
- if(str == NULL)
- return 0;
-
- return str->length;
-}
-
-size_t myhtml_string_size(myhtml_string_t *str)
-{
- if(str == NULL)
- return 0;
-
- return str->size;
-}
-
-char * myhtml_string_data_set(myhtml_string_t *str, char *data)
-{
- if(str == NULL)
- return NULL;
-
- str->data = data;
- return str->data;
-}
-
-size_t myhtml_string_size_set(myhtml_string_t *str, size_t size)
-{
- if(str == NULL)
- return 0;
-
- str->size = size;
- return str->size;
-}
-
-size_t myhtml_string_length_set(myhtml_string_t *str, size_t length)
-{
- if(str == NULL)
- return 0;
-
- str->length = length;
- return str->length;
-}
-
-/////////////////////////////////////////////////////////
-//// Append API
-////
-/////////////////////////////////////////////////////////
-void myhtml_string_append(myhtml_string_t* str, const char* buff, size_t length)
-{
- MyHTML_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
-
- memcpy(&str->data[str->length], buff, (sizeof(char) * length));
-
- str->length += length;
- str->data[str->length] = '\0';
-}
-
-void myhtml_string_append_one(myhtml_string_t* str, const char data)
-{
- MyHTML_STRING_REALLOC_IF_NEED(str, 2, 1);
- MyHTML_STRING_APPEND_BYTE_WITHOUT_REALLOC(data, str);
- MyHTML_STRING_APPEND_BYTE_WITHOUT_INCREMENT_REALLOC('\0', str);
-}
-
-void myhtml_string_append_lowercase(myhtml_string_t* str, const char* data, size_t length)
-{
- MyHTML_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
-
- unsigned char *ref = (unsigned char*)&str->data[str->length];
- const unsigned char *buf = (const unsigned char*)data;
-
- size_t i;
- for(i = 0; i < length; i++) {
- ref[i] = myhtml_string_chars_lowercase_map[ buf[i] ];
- }
-
- ref[i] = '\0';
- str->length += length;
-}
-
-size_t myhtml_string_append_with_preprocessing(myhtml_string_t* str, const char* buff, size_t length, bool emit_null_chars)
-{
- MyHTML_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
+ MyCORE_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
unsigned char *data = (unsigned char*)str->data;
const unsigned char *u_buff = (const unsigned char*)buff;
@@ -236,12 +42,16 @@ size_t myhtml_string_append_with_preprocessing(myhtml_string_t* str, const char*
}
else {
str->length++;
+
+ MyCORE_STRING_REALLOC_IF_NEED(str, 0, 2);
+ str->data[str->length] = '\0';
+
return str->length;
}
}
else if(u_buff[i] == 0x00 && emit_null_chars == false)
{
- myhtml_string_realloc(str, (str->size + 5));
+ mycore_string_realloc(str, (str->size + 5));
data = (unsigned char*)str->data;
// Unicode Character 'REPLACEMENT CHARACTER' (U+FFFD)
@@ -260,9 +70,9 @@ size_t myhtml_string_append_with_preprocessing(myhtml_string_t* str, const char*
return 0;
}
-size_t myhtml_string_append_lowercase_with_preprocessing(myhtml_string_t* str, const char* buff, size_t length, bool emit_null_chars)
+size_t myhtml_string_append_lowercase_with_preprocessing(mycore_string_t* str, const char* buff, size_t length, bool emit_null_chars)
{
- MyHTML_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
+ MyCORE_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
unsigned char *data = (unsigned char*)str->data;
const unsigned char *u_buff = (const unsigned char*)buff;
@@ -278,12 +88,16 @@ size_t myhtml_string_append_lowercase_with_preprocessing(myhtml_string_t* str, c
}
else {
str->length++;
+
+ MyCORE_STRING_REALLOC_IF_NEED(str, 0, 2);
+ str->data[str->length] = '\0';
+
return str->length;
}
}
else if(u_buff[i] == 0x00 && emit_null_chars == false)
{
- myhtml_string_realloc(str, (str->size + 5));
+ mycore_string_realloc(str, (str->size + 5));
data = (unsigned char*)str->data;
// Unicode Character 'REPLACEMENT CHARACTER' (U+FFFD)
@@ -292,7 +106,7 @@ size_t myhtml_string_append_lowercase_with_preprocessing(myhtml_string_t* str, c
data[str->length] = 0xBD;
}
else {
- data[str->length] = myhtml_string_chars_lowercase_map[ u_buff[i] ];
+ data[str->length] = mycore_string_chars_lowercase_map[ u_buff[i] ];
}
str->length++;
@@ -303,7 +117,7 @@ size_t myhtml_string_append_lowercase_with_preprocessing(myhtml_string_t* str, c
return 0;
}
-size_t myhtml_string_before_append_any_preprocessing(myhtml_string_t* str, const char* buff, size_t length, size_t last_position)
+size_t myhtml_string_before_append_any_preprocessing(mycore_string_t* str, const char* buff, size_t length, size_t last_position)
{
if(last_position == 0 || length == 0)
return 0;
@@ -318,27 +132,27 @@ size_t myhtml_string_before_append_any_preprocessing(myhtml_string_t* str, const
//// Append With Convert Encoding and Preprocessing API
////
/////////////////////////////////////////////////////////
-size_t myhtml_string_append_with_convert_encoding_with_preprocessing(myhtml_string_t* str, const char* buff, size_t length, myhtml_encoding_t encoding, bool emit_null_chars)
+size_t myhtml_string_append_with_convert_encoding_with_preprocessing(mycore_string_t* str, const char* buff, size_t length, myencoding_t encoding, bool emit_null_chars)
{
- myhtml_encoding_result_t res;
- myhtml_encoding_result_clean(&res);
+ myencoding_result_t res;
+ myencoding_result_clean(&res);
return myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(str, &res, buff, length, encoding, emit_null_chars);
}
-size_t myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(myhtml_string_t* str, myhtml_encoding_result_t* res, const char* buff, size_t length, myhtml_encoding_t encoding, bool emit_null_chars)
+size_t myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(mycore_string_t* str, myencoding_result_t* res, const char* buff, size_t length, myencoding_t encoding, bool emit_null_chars)
{
- MyHTML_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
+ MyCORE_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
unsigned const char* u_buff = (unsigned const char*)buff;
- const myhtml_encoding_custom_f func = myhtml_encoding_get_function_by_id(encoding);
+ const myencoding_custom_f func = myencoding_get_function_by_id(encoding);
for (size_t i = 0; i < length; i++)
{
- if(func(u_buff[i], res) == MyHTML_ENCODING_STATUS_OK) {
- MyHTML_STRING_REALLOC_IF_NEED(str, 5, 1);
+ if(func(u_buff[i], res) == MyENCODING_STATUS_OK) {
+ MyCORE_STRING_REALLOC_IF_NEED(str, 5, 1);
- size_t len = myhtml_encoding_codepoint_to_ascii_utf_8(res->result, &str->data[str->length]);
+ size_t len = myencoding_codepoint_to_ascii_utf_8(res->result, &str->data[str->length]);
if(len == 1) {
if(str->data[str->length] == '\r') {
@@ -350,12 +164,16 @@ size_t myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(myhtm
}
else {
str->length++;
+
+ MyCORE_STRING_REALLOC_IF_NEED(str, 0, 2);
+ str->data[str->length] = '\0';
+
return str->length;
}
}
else if(str->data[str->length] == 0x00 && emit_null_chars == false)
{
- myhtml_string_realloc(str, (str->size + 5));
+ mycore_string_realloc(str, (str->size + 5));
// Unicode Character 'REPLACEMENT CHARACTER' (U+FFFD)
str->data[str->length] = (char)0xEF; str->length++;
@@ -368,32 +186,32 @@ size_t myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(myhtm
}
}
- MyHTML_STRING_APPEND_BYTE_WITHOUT_INCREMENT('\0', str, 1);
+ MyCORE_STRING_APPEND_BYTE_WITHOUT_INCREMENT('\0', str, 1);
return 0;
}
-size_t myhtml_string_append_lowercase_with_convert_encoding_with_preprocessing(myhtml_string_t* str, const char* buff, size_t length, myhtml_encoding_t encoding, bool emit_null_chars)
+size_t myhtml_string_append_lowercase_with_convert_encoding_with_preprocessing(mycore_string_t* str, const char* buff, size_t length, myencoding_t encoding, bool emit_null_chars)
{
- myhtml_encoding_result_t res;
- myhtml_encoding_result_clean(&res);
+ myencoding_result_t res;
+ myencoding_result_clean(&res);
return myhtml_string_append_lowercase_chunk_with_convert_encoding_with_preprocessing(str, &res, buff, length, encoding, emit_null_chars);
}
-size_t myhtml_string_append_lowercase_chunk_with_convert_encoding_with_preprocessing(myhtml_string_t* str, myhtml_encoding_result_t* res, const char* buff, size_t length, myhtml_encoding_t encoding, bool emit_null_chars)
+size_t myhtml_string_append_lowercase_chunk_with_convert_encoding_with_preprocessing(mycore_string_t* str, myencoding_result_t* res, const char* buff, size_t length, myencoding_t encoding, bool emit_null_chars)
{
- MyHTML_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
+ MyCORE_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
unsigned const char* u_buff = (unsigned const char*)buff;
- const myhtml_encoding_custom_f func = myhtml_encoding_get_function_by_id(encoding);
+ const myencoding_custom_f func = myencoding_get_function_by_id(encoding);
for (size_t i = 0; i < length; i++)
{
- if(func(u_buff[i], res) == MyHTML_ENCODING_STATUS_OK) {
- MyHTML_STRING_REALLOC_IF_NEED(str, 5, 1);
+ if(func(u_buff[i], res) == MyENCODING_STATUS_OK) {
+ MyCORE_STRING_REALLOC_IF_NEED(str, 5, 1);
- size_t len = myhtml_encoding_codepoint_to_lowercase_ascii_utf_8(res->result, &str->data[str->length]);
+ size_t len = myencoding_codepoint_to_lowercase_ascii_utf_8(res->result, &str->data[str->length]);
if(len == 1) {
if(str->data[str->length] == '\r') {
@@ -405,12 +223,16 @@ size_t myhtml_string_append_lowercase_chunk_with_convert_encoding_with_preproces
}
else {
str->length++;
+
+ MyCORE_STRING_REALLOC_IF_NEED(str, 0, 2);
+ str->data[str->length] = '\0';
+
return str->length;
}
}
else if(str->data[str->length] == 0x00 && emit_null_chars == false)
{
- myhtml_string_realloc(str, (str->size + 5));
+ mycore_string_realloc(str, (str->size + 5));
// Unicode Character 'REPLACEMENT CHARACTER' (U+FFFD)
str->data[str->length] = (char)0xEF; str->length++;
@@ -423,182 +245,7 @@ size_t myhtml_string_append_lowercase_chunk_with_convert_encoding_with_preproces
}
}
- MyHTML_STRING_APPEND_BYTE_WITHOUT_INCREMENT('\0', str, 1);
+ MyCORE_STRING_APPEND_BYTE_WITHOUT_INCREMENT('\0', str, 1);
return 0;
}
-
-/////////////////////////////////////////////////////////
-//// Append With Convert Encoding without Preprocessing API
-////
-/////////////////////////////////////////////////////////
-void myhtml_string_append_with_convert_encoding(myhtml_string_t* str, const char* buff, size_t length, myhtml_encoding_t encoding)
-{
- myhtml_encoding_result_t res;
- myhtml_encoding_result_clean(&res);
-
- myhtml_string_append_chunk_with_convert_encoding(str, &res, buff, length, encoding);
-}
-
-void myhtml_string_append_chunk_with_convert_encoding(myhtml_string_t* str, myhtml_encoding_result_t* res, const char* buff, size_t length, myhtml_encoding_t encoding)
-{
- unsigned const char* u_buff = (unsigned const char*)buff;
- const myhtml_encoding_custom_f func = myhtml_encoding_get_function_by_id(encoding);
-
- for (size_t i = 0; i < length; i++)
- {
- if(func(u_buff[i], res) == MyHTML_ENCODING_STATUS_OK) {
- MyHTML_STRING_REALLOC_IF_NEED(str, 5, 0);
- str->length += myhtml_encoding_codepoint_to_ascii_utf_8(res->result, &str->data[str->length]);
- }
- }
-
- MyHTML_STRING_APPEND_BYTE_WITHOUT_INCREMENT('\0', str, 1);
-}
-
-void myhtml_string_append_one_with_convert_encoding(myhtml_string_t* str, myhtml_encoding_result_t* res, const char data, myhtml_encoding_t encoding)
-{
- const myhtml_encoding_custom_f func = myhtml_encoding_get_function_by_id(encoding);
-
- if(func((unsigned const char)data, res) == MyHTML_ENCODING_STATUS_OK) {
- MyHTML_STRING_REALLOC_IF_NEED(str, 5, 0);
- str->length += myhtml_encoding_codepoint_to_ascii_utf_8(res->result, &str->data[str->length]);
-
- MyHTML_STRING_APPEND_BYTE_WITHOUT_INCREMENT_REALLOC('\0', str);
- }
-}
-
-
-void myhtml_string_append_lowercase_ascii_with_convert_encoding(myhtml_string_t* str, const char* buff, size_t length, myhtml_encoding_t encoding)
-{
- myhtml_encoding_result_t res;
- myhtml_encoding_result_clean(&res);
-
- myhtml_string_append_chunk_lowercase_ascii_with_convert_encoding(str, &res, buff, length, encoding);
-}
-
-void myhtml_string_append_chunk_lowercase_ascii_with_convert_encoding(myhtml_string_t* str, myhtml_encoding_result_t* res, const char* buff, size_t length, myhtml_encoding_t encoding)
-{
- unsigned const char* u_buff = (unsigned const char*)buff;
- const myhtml_encoding_custom_f func = myhtml_encoding_get_function_by_id(encoding);
-
- for (size_t i = 0; i < length; i++)
- {
- if(func(u_buff[i], res) == MyHTML_ENCODING_STATUS_OK) {
- MyHTML_STRING_REALLOC_IF_NEED(str, 5, 1);
-
- size_t insert_len = myhtml_encoding_codepoint_to_ascii_utf_8(res->result, &str->data[str->length]);
-
- if(insert_len == 1) {
- str->data[str->length] = (const char)myhtml_string_chars_lowercase_map[ u_buff[i] ];
- }
-
- str->length += insert_len;
- }
- }
-
- MyHTML_STRING_APPEND_BYTE_WITHOUT_INCREMENT('\0', str, 1);
-}
-
-void myhtml_string_copy(myhtml_string_t* dest, myhtml_string_t* target)
-{
- myhtml_string_append(dest, target->data, target->length);
-}
-
-size_t myhtml_string_raw_copy(char* str1, const char* str2, size_t size)
-{
- str1[size] = '\0';
-
- while(size) {
- size--;
- str1[size] = str2[size];
- }
-
- return size;
-}
-
-size_t myhtml_string_raw_set_replacement_character(myhtml_string_t* target, size_t position)
-{
- // Unicode Character 'REPLACEMENT CHARACTER' (U+FFFD)
- target->data[(position)] = (char)0xEF;
- target->data[(position + 1)] = (char)0xBF;
- target->data[(position + 2)] = (char)0xBD;
-
- return 3;
-}
-
-void myhtml_string_append_with_replacement_null_characters_only(myhtml_string_t* str, const char* buff, size_t length)
-{
- MyHTML_STRING_REALLOC_IF_NEED(str, (length + 1), 0);
-
- unsigned char *data = (unsigned char*)str->data;
- const unsigned char *u_buff = (const unsigned char*)buff;
-
- for (size_t i = 0; i < length; i++)
- {
- if(u_buff[i] == 0x00) {
- myhtml_string_realloc(str, (str->size + 5));
- data = (unsigned char*)str->data;
-
- // Unicode Character 'REPLACEMENT CHARACTER' (U+FFFD)
- data[str->length] = 0xEF; str->length++;
- data[str->length] = 0xBF; str->length++;
- data[str->length] = 0xBD;
- }
- else
- data[str->length] = u_buff[i];
-
- str->length++;
- }
-
- str->data[str->length] = '\0';
-}
-
-void myhtml_string_stay_only_whitespace(myhtml_string_t* target)
-{
- char *data = target->data;
- size_t pos = 0;
-
- for(size_t i = 0; i < target->length; i++)
- {
- if(myhtml_mystring_whitespace(data[i], ==, ||)) {
- data[pos] = data[i];
- pos++;
- }
- }
-
- target->length = pos;
-}
-
-size_t myhtml_string_crop_whitespace_from_begin(myhtml_string_t* target)
-{
- char *data = target->data;
- size_t i;
-
- for(i = 0; i < target->length; i++) {
- if(myhtml_mystring_whitespace(data[i], !=, &&))
- break;
- }
-
- if(i)
- target->data = mchar_async_crop_first_chars_without_cache(target->data, i);
-
- target->length -= i;
-
- return i;
-}
-
-size_t myhtml_string_whitespace_from_begin(myhtml_string_t* target)
-{
- char *data = target->data;
- size_t i;
-
- for(i = 0; i < target->length; i++) {
- if(myhtml_mystring_whitespace(data[i], !=, &&))
- break;
- }
-
- return i;
-}
-
-
diff --git a/source/myhtml/mystring.h b/source/myhtml/mystring.h
index 0a0c02c..2906d59 100644
--- a/source/myhtml/mystring.h
+++ b/source/myhtml/mystring.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -25,129 +25,31 @@
#ifdef __cplusplus
extern "C" {
#endif
-
+
#include "myhtml/myosi.h"
-#include "myhtml/encoding.h"
-#include "myhtml/utils/mchar_async.h"
+
+#include "myencoding/encoding.h"
+#include "myencoding/mystring.h"
+
+#include "mycore/mystring.h"
+#include "mycore/utils/mchar_async.h"
#define myhtml_string_get(str, attr) str->attr
#define myhtml_string_set(str, attr) myhtml_string_get(str, attr)
#define myhtml_string_len(str) myhtml_string_get(str, length)
-#define MyHTML_STRING_PREPROCESSOR_CHECK_BUFFER_SIZE(str, unsigned_data) \
- if(str->length >= str->size) { \
- myhtml_string_realloc(str, (str->length + 5)); \
- \
- unsigned_data = (unsigned char*)str->data; \
- }
-
-#define MyHTML_STRING_REALLOC_IF_NEED(str, need_length, upto) \
- if((str->length + need_length) >= str->size) { \
- myhtml_string_realloc(str, (str->length + need_length + upto)); \
- } \
-
-#define MyHTML_STRING_APPEND_BYTE_WITHOUT_REALLOC(onechar, str) \
- str->data[str->length] = onechar; \
- str->length++
-
-#define MyHTML_STRING_APPEND_BYTE_WITHOUT_INCREMENT(onechar, str, upto) \
- if(str->length >= str->size) { \
- myhtml_string_realloc(str, (str->length + upto)); \
- } \
- str->data[str->length] = onechar
-
-#define MyHTML_STRING_APPEND_BYTE_WITHOUT_INCREMENT_REALLOC(onechar, str) \
- str->data[str->length] = onechar
-
-#define MyHTML_STRING_APPEND_BYTE(onechar, str, upto) \
- MyHTML_STRING_APPEND_BYTE_WITHOUT_INCREMENT(onechar, str, upto); \
- str->length++
-
-#define myhtml_mystring_whitespace(onechar, action, logic) \
- (onechar action ' ' logic \
- onechar action '\t' logic \
- onechar action '\n' logic \
- onechar action '\f' logic \
- onechar action '\r')
-
-struct myhtml_string {
- char* data;
- size_t size;
- size_t length;
-
- mchar_async_t *mchar;
- size_t node_idx;
-};
-
-struct myhtml_string_raw {
- char* data;
- size_t size;
- size_t length;
-};
-
-typedef size_t myhtml_string_index_t;
-
-char * myhtml_string_init(mchar_async_t *mchar, size_t node_idx, myhtml_string_t* str, size_t size);
-char * myhtml_string_realloc(myhtml_string_t *str, size_t new_size);
-
-void myhtml_string_clean(myhtml_string_t* str);
-void myhtml_string_clean_all(myhtml_string_t* str);
-myhtml_string_t * myhtml_string_destroy(myhtml_string_t* str, bool destroy_obj);
-
-void myhtml_string_raw_clean(myhtml_string_raw_t* str_raw);
-void myhtml_string_raw_clean_all(myhtml_string_raw_t* str_raw);
-myhtml_string_raw_t * myhtml_string_raw_destroy(myhtml_string_raw_t* str_raw, bool destroy_obj);
-
-/* basic api */
-char * myhtml_string_data_alloc(mchar_async_t *mchar, size_t node_id, size_t size);
-char * myhtml_string_data_realloc(mchar_async_t *mchar, size_t node_id, char *data, size_t len_to_copy, size_t size);
-void myhtml_string_data_free(mchar_async_t *mchar, size_t node_id, char *data);
-
-char * myhtml_string_data(myhtml_string_t *str);
-size_t myhtml_string_length(myhtml_string_t *str);
-size_t myhtml_string_size(myhtml_string_t *str);
-char * myhtml_string_data_set(myhtml_string_t *str, char *data);
-size_t myhtml_string_size_set(myhtml_string_t *str, size_t size);
-size_t myhtml_string_length_set(myhtml_string_t *str, size_t length);
-
-/* append */
-void myhtml_string_append(myhtml_string_t* str, const char* data, size_t length);
-void myhtml_string_append_one(myhtml_string_t* str, const char data);
-void myhtml_string_append_lowercase(myhtml_string_t* str, const char* data, size_t length);
-void myhtml_string_append_with_convert_encoding(myhtml_string_t* str, const char* buff, size_t length, myhtml_encoding_t encoding);
-
-/* append with convert encoding */
-void myhtml_string_append_chunk_with_convert_encoding(myhtml_string_t* str, myhtml_encoding_result_t* res, const char* buff, size_t length, myhtml_encoding_t encoding);
-void myhtml_string_append_one_with_convert_encoding(myhtml_string_t* str, myhtml_encoding_result_t* res, const char data, myhtml_encoding_t encoding);
-
-/* append with convert encoding lowercase */
-void myhtml_string_append_lowercase_ascii_with_convert_encoding(myhtml_string_t* str, const char* buff, size_t length, myhtml_encoding_t encoding);
-void myhtml_string_append_chunk_lowercase_ascii_with_convert_encoding(myhtml_string_t* str, myhtml_encoding_result_t* res, const char* buff, size_t length, myhtml_encoding_t encoding);
-
-/* Oh, long long long name */
-
/* append with convert encoding with preprocessing */
-size_t myhtml_string_append_with_convert_encoding_with_preprocessing(myhtml_string_t* str, const char* buff, size_t length, myhtml_encoding_t encoding, bool emit_null_chars);
-size_t myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(myhtml_string_t* str, myhtml_encoding_result_t* res, const char* buff, size_t length, myhtml_encoding_t encoding, bool emit_null_chars);
+size_t myhtml_string_append_with_convert_encoding_with_preprocessing(mycore_string_t* str, const char* buff, size_t length, myencoding_t encoding, bool emit_null_chars);
+size_t myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(mycore_string_t* str, myencoding_result_t* res, const char* buff, size_t length, myencoding_t encoding, bool emit_null_chars);
/* append with convert encoding lowercase with preprocessing */
-size_t myhtml_string_append_lowercase_with_convert_encoding_with_preprocessing(myhtml_string_t* str, const char* buff, size_t length, myhtml_encoding_t encoding, bool emit_null_chars);
-size_t myhtml_string_append_lowercase_chunk_with_convert_encoding_with_preprocessing(myhtml_string_t* str, myhtml_encoding_result_t* res, const char* buff, size_t length, myhtml_encoding_t encoding, bool emit_null_chars);
-
-void myhtml_string_append_with_replacement_null_characters_only(myhtml_string_t* str, const char* buff, size_t length);
+size_t myhtml_string_append_lowercase_with_convert_encoding_with_preprocessing(mycore_string_t* str, const char* buff, size_t length, myencoding_t encoding, bool emit_null_chars);
+size_t myhtml_string_append_lowercase_chunk_with_convert_encoding_with_preprocessing(mycore_string_t* str, myencoding_result_t* res, const char* buff, size_t length, myencoding_t encoding, bool emit_null_chars);
/* append with preprocessing */
-size_t myhtml_string_before_append_any_preprocessing(myhtml_string_t* str, const char* buff, size_t length, size_t last_position);
-size_t myhtml_string_append_with_preprocessing(myhtml_string_t* str, const char* buff, size_t length, bool emit_null_chars);
-size_t myhtml_string_append_lowercase_with_preprocessing(myhtml_string_t* str, const char* buff, size_t length, bool emit_null_chars);
-size_t myhtml_string_raw_set_replacement_character(myhtml_string_t* target, size_t position);
-
-/* other functions */
-void myhtml_string_copy(myhtml_string_t* dest, myhtml_string_t* target);
-size_t myhtml_string_raw_copy(char* str1, const char* str2, size_t size);
-void myhtml_string_stay_only_whitespace(myhtml_string_t* target);
-size_t myhtml_string_crop_whitespace_from_begin(myhtml_string_t* target);
-size_t myhtml_string_whitespace_from_begin(myhtml_string_t* target);
+size_t myhtml_string_before_append_any_preprocessing(mycore_string_t* str, const char* buff, size_t length, size_t last_position);
+size_t myhtml_string_append_with_preprocessing(mycore_string_t* str, const char* buff, size_t length, bool emit_null_chars);
+size_t myhtml_string_append_lowercase_with_preprocessing(mycore_string_t* str, const char* buff, size_t length, bool emit_null_chars);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myhtml/parser.c b/source/myhtml/parser.c
index 95cdc1b..95a7764 100644
--- a/source/myhtml/parser.c
+++ b/source/myhtml/parser.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -24,19 +24,19 @@ void myhtml_parser_stream(mythread_id_t thread_id, void* ctx)
{
mythread_queue_node_t *qnode = (mythread_queue_node_t*)ctx;
- if((qnode->tree->parse_flags & MyHTML_TREE_PARSE_FLAGS_WITHOUT_BUILD_TREE) == 0) {
- while(myhtml_rules_tree_dispatcher(qnode->tree, qnode->token)){}
+ if((((myhtml_tree_t*)(qnode->context))->parse_flags & MyHTML_TREE_PARSE_FLAGS_WITHOUT_BUILD_TREE) == 0) {
+ while(myhtml_rules_tree_dispatcher(qnode->context, qnode->args)){}
}
}
-size_t myhtml_parser_token_data_to_string_lowercase(myhtml_tree_t *tree, myhtml_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length)
+size_t myhtml_parser_token_data_to_string_lowercase(myhtml_tree_t *tree, mycore_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length)
{
- myhtml_incoming_buffer_t *buffer = myhtml_incoming_buffer_find_by_position(tree->incoming_buf_first, begin);
+ mycore_incoming_buffer_t *buffer = mycore_incoming_buffer_find_by_position(tree->incoming_buf_first, begin);
size_t relative_begin = begin - buffer->offset;
// if token data length in one buffer then print them all at once
if((relative_begin + length) <= buffer->size) {
- if(tree->encoding == MyHTML_ENCODING_UTF_8)
+ if(tree->encoding == MyENCODING_UTF_8)
myhtml_string_append_lowercase_with_preprocessing(str, &buffer->data[relative_begin], length, proc_entry->emit_null_char);
else
myhtml_string_append_lowercase_chunk_with_convert_encoding_with_preprocessing(str, &proc_entry->res,
@@ -57,7 +57,7 @@ size_t myhtml_parser_token_data_to_string_lowercase(myhtml_tree_t *tree, myhtml_
size_t tmp_offset = myhtml_string_before_append_any_preprocessing(str, &buffer->data[relative_begin], relative_end, save_position);
if(relative_end > 0) {
- if(tree->encoding == MyHTML_ENCODING_UTF_8)
+ if(tree->encoding == MyENCODING_UTF_8)
save_position = myhtml_string_append_lowercase_with_preprocessing(str, &buffer->data[(relative_begin + tmp_offset)], (relative_end - tmp_offset), proc_entry->emit_null_char);
else
save_position = myhtml_string_append_lowercase_chunk_with_convert_encoding_with_preprocessing(str, &proc_entry->res,
@@ -72,7 +72,7 @@ size_t myhtml_parser_token_data_to_string_lowercase(myhtml_tree_t *tree, myhtml_
size_t tmp_offset = myhtml_string_before_append_any_preprocessing(str, &buffer->data[relative_begin], length, save_position);
if(length > 0) {
- if(tree->encoding == MyHTML_ENCODING_UTF_8)
+ if(tree->encoding == MyENCODING_UTF_8)
myhtml_string_append_lowercase_with_preprocessing(str, &buffer->data[(relative_begin + tmp_offset)], (length - tmp_offset), proc_entry->emit_null_char);
else
myhtml_string_append_lowercase_chunk_with_convert_encoding_with_preprocessing(str, &proc_entry->res,
@@ -87,14 +87,14 @@ size_t myhtml_parser_token_data_to_string_lowercase(myhtml_tree_t *tree, myhtml_
return str->length;
}
-size_t myhtml_parser_token_data_to_string(myhtml_tree_t *tree, myhtml_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length)
+size_t myhtml_parser_token_data_to_string(myhtml_tree_t *tree, mycore_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length)
{
- myhtml_incoming_buffer_t *buffer = myhtml_incoming_buffer_find_by_position(tree->incoming_buf_first, begin);
+ mycore_incoming_buffer_t *buffer = mycore_incoming_buffer_find_by_position(tree->incoming_buf_first, begin);
size_t relative_begin = begin - buffer->offset;
// if token data length in one buffer then print them all at once
if((relative_begin + length) <= buffer->size) {
- if(tree->encoding == MyHTML_ENCODING_UTF_8)
+ if(tree->encoding == MyENCODING_UTF_8)
myhtml_string_append_with_preprocessing(str, &buffer->data[relative_begin], length, proc_entry->emit_null_char);
else
myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(str, &proc_entry->res,
@@ -115,7 +115,7 @@ size_t myhtml_parser_token_data_to_string(myhtml_tree_t *tree, myhtml_string_t*
size_t tmp_offset = myhtml_string_before_append_any_preprocessing(str, &buffer->data[relative_begin], relative_end, save_position);
if(relative_end > 0) {
- if(tree->encoding == MyHTML_ENCODING_UTF_8)
+ if(tree->encoding == MyENCODING_UTF_8)
save_position = myhtml_string_append_with_preprocessing(str, &buffer->data[(relative_begin + tmp_offset)], (relative_end - tmp_offset), proc_entry->emit_null_char);
else
save_position = myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(str, &proc_entry->res,
@@ -131,12 +131,12 @@ size_t myhtml_parser_token_data_to_string(myhtml_tree_t *tree, myhtml_string_t*
size_t tmp_offset = myhtml_string_before_append_any_preprocessing(str, &buffer->data[relative_begin], length, save_position);
if(length > 0) {
- if(tree->encoding == MyHTML_ENCODING_UTF_8)
+ if(tree->encoding == MyENCODING_UTF_8)
myhtml_string_append_with_preprocessing(str, &buffer->data[(relative_begin + tmp_offset)], (length - tmp_offset), proc_entry->emit_null_char);
else
myhtml_string_append_chunk_with_convert_encoding_with_preprocessing(str, &proc_entry->res,
- &buffer->data[(relative_begin + tmp_offset)], (length - tmp_offset),
- proc_entry->encoding, proc_entry->emit_null_char);
+ &buffer->data[(relative_begin + tmp_offset)], (length - tmp_offset),
+ proc_entry->encoding, proc_entry->emit_null_char);
}
break;
@@ -146,9 +146,9 @@ size_t myhtml_parser_token_data_to_string(myhtml_tree_t *tree, myhtml_string_t*
return str->length;
}
-size_t myhtml_parser_token_data_to_string_charef(myhtml_tree_t *tree, myhtml_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length)
+size_t myhtml_parser_token_data_to_string_charef(myhtml_tree_t *tree, mycore_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length)
{
- myhtml_incoming_buffer_t *buffer = myhtml_incoming_buffer_find_by_position(tree->incoming_buf_first, begin);
+ mycore_incoming_buffer_t *buffer = mycore_incoming_buffer_find_by_position(tree->incoming_buf_first, begin);
size_t relative_begin = begin - buffer->offset;
// if token data length in one buffer then print them all at once
@@ -186,8 +186,8 @@ void myhtml_parser_worker(mythread_id_t thread_id, void* ctx)
{
mythread_queue_node_t *qnode = (mythread_queue_node_t*)ctx;
- myhtml_tree_t* tree = qnode->tree;
- myhtml_token_node_t* token = qnode->token;
+ myhtml_tree_t* tree = qnode->context;
+ myhtml_token_node_t* token = qnode->args;
/*
* Tree can not be built without tokens
@@ -201,8 +201,8 @@ void myhtml_parser_worker(mythread_id_t thread_id, void* ctx)
* return true
* we need check both, 1 and 2
*/
- if((qnode->tree->parse_flags & MyHTML_TREE_PARSE_FLAGS_WITHOUT_PROCESS_TOKEN) &&
- (qnode->tree->parse_flags & 2))
+ if((tree->parse_flags & MyHTML_TREE_PARSE_FLAGS_WITHOUT_PROCESS_TOKEN) &&
+ (tree->parse_flags & 2))
{
if(tree->callback_before_token)
tree->callback_before_token_ctx = tree->callback_before_token(tree, token, tree->callback_before_token_ctx);
@@ -215,15 +215,21 @@ void myhtml_parser_worker(mythread_id_t thread_id, void* ctx)
return;
}
+ size_t mchar_node_id;
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ if(tree->myhtml->thread_batch)
+ mchar_node_id = tree->async_args[(thread_id + tree->myhtml->thread_batch->id_increase)].mchar_node_id;
+ else
+#endif
+ mchar_node_id = tree->async_args[thread_id].mchar_node_id;
+
if(tree->callback_before_token)
tree->callback_before_token_ctx = tree->callback_before_token(tree, token, tree->callback_before_token_ctx);
- size_t mchar_node_id = qnode->tree->async_args[thread_id].mchar_node_id;
-
if(token->tag_id == MyHTML_TAG__TEXT ||
token->tag_id == MyHTML_TAG__COMMENT)
{
- myhtml_string_init(tree->mchar, mchar_node_id, &token->str, (token->raw_length + 1));
+ mycore_string_init(tree->mchar, mchar_node_id, &token->str, (token->raw_length + 1));
token->attr_first = NULL;
token->attr_last = NULL;
@@ -246,7 +252,7 @@ void myhtml_parser_worker(mythread_id_t thread_id, void* ctx)
}
else if(token->attr_first)
{
- myhtml_string_clean_all(&token->str);
+ mycore_string_clean_all(&token->str);
myhtml_token_attr_t* attr = token->attr_first;
myhtml_data_process_entry_t proc_entry;
@@ -257,22 +263,22 @@ void myhtml_parser_worker(mythread_id_t thread_id, void* ctx)
myhtml_data_process_entry_clean(&proc_entry);
proc_entry.encoding = tree->encoding;
- myhtml_string_init(tree->mchar, mchar_node_id, &attr->key, (attr->raw_key_length + 1));
+ mycore_string_init(tree->mchar, mchar_node_id, &attr->key, (attr->raw_key_length + 1));
myhtml_parser_token_data_to_string_lowercase(tree, &attr->key, &proc_entry, attr->raw_key_begin, attr->raw_key_length);
}
else
- myhtml_string_clean_all(&attr->key);
+ mycore_string_clean_all(&attr->key);
if(attr->raw_value_length) {
myhtml_data_process_entry_clean(&proc_entry);
proc_entry.encoding = tree->encoding;
proc_entry.is_attributes = true;
- myhtml_string_init(tree->mchar, mchar_node_id, &attr->value, (attr->raw_value_length + 1));
+ mycore_string_init(tree->mchar, mchar_node_id, &attr->value, (attr->raw_value_length + 1));
myhtml_parser_token_data_to_string_charef(tree, &attr->value, &proc_entry, attr->raw_value_begin, attr->raw_value_length);
}
else
- myhtml_string_clean_all(&attr->value);
+ mycore_string_clean_all(&attr->value);
attr = attr->next;
}
@@ -281,7 +287,7 @@ void myhtml_parser_worker(mythread_id_t thread_id, void* ctx)
token->attr_first = NULL;
token->attr_last = NULL;
- myhtml_string_clean_all(&token->str);
+ mycore_string_clean_all(&token->str);
}
token->type |= MyHTML_TOKEN_TYPE_DONE;
diff --git a/source/myhtml/parser.h b/source/myhtml/parser.h
index a4d1ab9..d04e043 100644
--- a/source/myhtml/parser.h
+++ b/source/myhtml/parser.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -37,9 +37,9 @@ void myhtml_parser_stream(mythread_id_t thread_id, void* ctx);
void myhtml_parser_worker(mythread_id_t thread_id, void* ctx);
void myhtml_parser_worker_stream(mythread_id_t thread_id, void* ctx);
-size_t myhtml_parser_token_data_to_string(myhtml_tree_t *tree, myhtml_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length);
-size_t myhtml_parser_token_data_to_string_lowercase(myhtml_tree_t *tree, myhtml_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length);
-size_t myhtml_parser_token_data_to_string_charef(myhtml_tree_t *tree, myhtml_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length);
+size_t myhtml_parser_token_data_to_string(myhtml_tree_t *tree, mycore_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length);
+size_t myhtml_parser_token_data_to_string_lowercase(myhtml_tree_t *tree, mycore_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length);
+size_t myhtml_parser_token_data_to_string_charef(myhtml_tree_t *tree, mycore_string_t* str, myhtml_data_process_entry_t* proc_entry, size_t begin, size_t length);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myhtml/perf.c b/source/myhtml/perf.c
deleted file mode 100644
index f95faab..0000000
--- a/source/myhtml/perf.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- Copyright (C) 2015-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
-
- Authors: insoreiges@gmail.com (Evgeny Yakovlev), lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-/**
- * Platform-specific hdef performance clock value.
- */
-
-#include "myhtml/myhtml.h"
-#include <time.h>
-
-#if !defined(IS_OS_WINDOWS)
-#include <unistd.h>
-#endif
-
-#if !defined(MyHTML_WITH_PERF)
-
-uint64_t myhtml_hperf_res(myhtml_status_t *status)
-{
- if(status)
- *status = MyHTML_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF;
-
- return 0;
-}
-
-uint64_t myhtml_hperf_clock(myhtml_status_t *status)
-{
- if(status)
- *status = MyHTML_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF;
-
- return 0;
-}
-
-#else
-
-#if defined(__APPLE__)
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#elif defined(IS_OS_WINDOWS)
-#endif
-
-#if defined(MyHTML_FORCE_RDTSC) /* Force using rdtsc, useful for comparison */
-
-/**
- * Get CPU rdtsc frequency.
- *
- * TODO: I think using rdtsc for measuring user-space counters is not correct:
- * - rdtsc does not have a constant rate. instead ot is scaled to physical core's internal clock which changes due to power saving modes on modern CPUs
- * - rdtsc is software-emulated in virtual machines which will introduce an inconsistency in reported ticks
- * - user space process can be preempted between consecutive rdtsc measures but the physical clock will still tick while it is executing a different thread.
- * also think what would happen if preempted process will be re-scheduled on a different physical core which has a different tsc value.
- * - computing rdtsc frequency produces unreliable results (due to all of the above)
- *
- * Consider using platform-specific monotonic hperf timers (ftrace/dtrace) or even clock().
- */
-uint64_t myhtml_hperf_res(myhtml_status_t *status)
-{
- if(status)
- *status = MyHTML_STATUS_OK;
-
-#if defined(__APPLE__) && defined(CTL_HW) && defined(HW_CPU_FREQ)
- unsigned long long freq = 0;
-
- /* OSX kernel: sysctl(CTL_HW | HW_CPU_FREQ) */
- size_t len = sizeof(freq);
- int mib[2] = {CTL_HW, HW_CPU_FREQ};
-
- int error = sysctl(mib, 2, &freq, &len, NULL, 0);
- if (error) {
- if(status)
- *status = MyHTML_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- return freq;
-
-#elif defined(__linux__)
- unsigned long long freq = 0;
-
- /* Use procfs on linux */
- FILE* fp = NULL;
- fp = fopen("/proc/cpuinfo", "r");
- if (fp == NULL) {
- if(status)
- *status = MyHTML_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- /* Find 'CPU MHz :' */
- char buf[1024] = {0};
- double fval = 0.0;
- while (fgets(buf, sizeof(buf), fp) != NULL) {
- if (sscanf(buf, "cpu MHz : %lf\n", &fval) == 1) {
- freq = (unsigned long long)(fval * 1000000ull);
- break;
- }
- }
-
- fclose(fp);
- return freq;
-
-#else
-# warning Cant figure out cpu frequency on this platfrom
-
- if(status)
- *status = MyHTML_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
-#endif /* defined __APPLE__ || __linux__ ... */
-}
-
-uint64_t myhtml_hperf_clock(myhtml_status_t *status)
-{
- uint64_t x;
-
- __asm__ volatile (
- "cpuid\n\t" /* cpuid serializes any out-of-order prefetches before executing rdtsc (clobbers ebx, ecx, edx) */
- "rdtsc\n\t"
- "shl $32, %%rdx\n\t"
- "or %%rdx, %%rax"
- : "=a" (x)
- :
- : "rdx", "ebx", "ecx");
-
- return x;
-}
-
-#elif defined(_POSIX_TIMERS) && defined(_POSIX_CPUTIME) \
- && defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 199309L) /* Do we have clock_gettime? */
-
-#define NSEC_PER_SECOND 1000000000ull
-#define TIMESPEC_TO_USEC(tspec) (((uint64_t)(tspec).tv_sec * NSEC_PER_SECOND) + (tspec).tv_nsec)
-
-uint64_t myhtml_hperf_res(myhtml_status_t *status)
-{
- if(status)
- *status = MyHTML_STATUS_OK;
-
- struct timespec tspec;
- int error = clock_getres(CLOCK_PROCESS_CPUTIME_ID, &tspec);
- if (error) {
- if(status)
- *status = MyHTML_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- unsigned long long ticks_per_sec = (unsigned long long)((double)NSEC_PER_SECOND / TIMESPEC_TO_USEC(tspec));
- return ticks_per_sec;
-}
-
-uint64_t myhtml_hperf_clock(myhtml_status_t *status)
-{
- if(status)
- *status = MyHTML_STATUS_OK;
-
- struct timespec tspec;
- int error = clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tspec);
- if (error) {
- if(status)
- *status = MyHTML_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- return TIMESPEC_TO_USEC(tspec);
-}
-
-#elif defined(__APPLE__) && defined(__MACH__)
-
-/*
- * TODO: on OSX we can use clock_get_time: http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x
- * Or this: http://web.archive.org/web/20100517095152/http://www.wand.net.nz/~smr26/wordpress/2009/01/19/monotonic-time-in-mac-os-x/comment-page-1/
- */
-
-// TODO: this is incorrect plug for mac os x
-// look at links before this comment
-
-#include <mach/mach_time.h>
-
-uint64_t myhtml_hperf_res(myhtml_status_t *status)
-{
- if(status)
- *status = MyHTML_STATUS_OK;
-
- unsigned long long freq = 0;
-
- size_t len = sizeof(freq);
- int mib[2] = {CTL_HW, HW_CPU_FREQ};
-
- int error = sysctl(mib, 2, &freq, &len, NULL, 0);
- if (error) {
- if(status)
- *status = MyHTML_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- return freq;
-}
-
-uint64_t myhtml_hperf_clock(myhtml_status_t *status)
-{
- if(status)
- *status = MyHTML_STATUS_OK;
-
- return mach_absolute_time();
-}
-
-#else
-
-# warning No hperf implementation for this platform
-
-uint64_t myhtml_hperf_res(myhtml_status_t *status)
-{
- if(status)
- *status = MyHTML_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
-}
-
-uint64_t myhtml_hperf_clock(myhtml_status_t *status)
-{
- if(status)
- *status = MyHTML_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
-}
-
-#endif /* defined(MyHTML_FORCE_RDTSC) ... */
-#endif /* MyHTML_WITH_PERF */
-
-#define _MyHTML_CHECK_STATUS_AND_PRINT_ERROR \
- if(status == MyHTML_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF) { \
- fprintf(fh, "MyHTML: Library compiled without perf source. Please, build library with -DMyHTML_WITH_PERF flag\n"); \
- } \
- else if(status) { \
- fprintf(fh, "MyHTML: Something wrong! Perhaps, your platform does not support the measurement of performance\n"); \
- } \
- else
-
-myhtml_status_t myhtml_hperf_print(const char *name, uint64_t x, uint64_t y, FILE *fh) {
- myhtml_status_t status;
-
- unsigned long long freq = myhtml_hperf_res(&status);
-
- if(freq) {
- _MyHTML_CHECK_STATUS_AND_PRINT_ERROR {
- fprintf(fh, "%s: %0.5f\n", name, (((float)(y - x) / (float)freq)));
- }
- }
-
- return status;
-}
-
-myhtml_status_t myhtml_hperf_print_by_val(const char *name, uint64_t x, FILE *fh) {
- myhtml_status_t status;
-
- unsigned long long freq = myhtml_hperf_res(&status);
-
- if(freq) {
- _MyHTML_CHECK_STATUS_AND_PRINT_ERROR {
- fprintf(fh, "%s: %0.5f\n", name, ((float)x / (float)freq));
- }
- }
-
- return status;
-}
-
-
diff --git a/source/myhtml/rules.c b/source/myhtml/rules.c
index 3921952..17e08ce 100644
--- a/source/myhtml/rules.c
+++ b/source/myhtml/rules.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -20,16 +20,16 @@
#include "myhtml/rules.h"
-void myhtml_insertion_fix_emit_for_text_begin_ws(myhtml_token_node_t* token)
+void myhtml_insertion_fix_emit_for_text_begin_ws(myhtml_token_t* token, myhtml_token_node_t* node)
{
- myhtml_token_node_wait_for_done(token);
- myhtml_string_crop_whitespace_from_begin(&token->str);
+ myhtml_token_node_wait_for_done(token, node);
+ mycore_string_crop_whitespace_from_begin(&node->str);
}
myhtml_token_node_t * myhtml_insertion_fix_split_for_text_begin_ws(myhtml_tree_t* tree, myhtml_token_node_t* token)
{
- myhtml_token_node_wait_for_done(token);
- size_t len = myhtml_string_whitespace_from_begin(&token->str);
+ myhtml_token_node_wait_for_done(tree->token, token);
+ size_t len = mycore_string_whitespace_from_begin(&token->str);
if(len == 0)
return NULL;
@@ -40,9 +40,9 @@ myhtml_token_node_t * myhtml_insertion_fix_split_for_text_begin_ws(myhtml_tree_t
if(new_token == NULL)
return NULL;
- myhtml_string_init(tree->mchar, tree->mchar_node_id, &new_token->str, (len + 2));
+ mycore_string_init(tree->mchar, tree->mchar_node_id, &new_token->str, (len + 2));
- myhtml_string_append(&new_token->str, token->str.data, len);
+ mycore_string_append(&new_token->str, token->str.data, len);
new_token->type |= MyHTML_TOKEN_TYPE_DONE;
@@ -55,9 +55,9 @@ myhtml_token_node_t * myhtml_insertion_fix_split_for_text_begin_ws(myhtml_tree_t
void myhtml_insertion_fix_for_null_char_drop_all(myhtml_tree_t* tree, myhtml_token_node_t* token)
{
- myhtml_token_node_wait_for_done(token);
+ myhtml_token_node_wait_for_done(tree->token, token);
- myhtml_string_t *str = &token->str;
+ mycore_string_t *str = &token->str;
size_t len = str->length;
size_t offset = 0;
@@ -93,7 +93,7 @@ bool myhtml_insertion_mode_initial(myhtml_tree_t* tree, myhtml_token_node_t* tok
return false;
}
- myhtml_insertion_fix_emit_for_text_begin_ws(token);
+ myhtml_insertion_fix_emit_for_text_begin_ws(tree->token, token);
// default, other token
tree->compat_mode = MyHTML_TREE_COMPAT_MODE_QUIRKS;
@@ -109,7 +109,7 @@ bool myhtml_insertion_mode_initial(myhtml_tree_t* tree, myhtml_token_node_t* tok
case MyHTML_TAG__DOCTYPE:
{
- myhtml_token_node_wait_for_done(token);
+ myhtml_token_node_wait_for_done(tree->token, token);
myhtml_token_release_and_check_doctype_attributes(tree->token, token, &tree->doctype);
@@ -183,7 +183,7 @@ bool myhtml_insertion_mode_before_html(myhtml_tree_t* tree, myhtml_token_node_t*
break;
}
- myhtml_insertion_fix_emit_for_text_begin_ws(token);
+ myhtml_insertion_fix_emit_for_text_begin_ws(tree->token, token);
// default, other token
myhtml_tree_node_insert_root(tree, NULL, MyHTML_NAMESPACE_HTML);
@@ -246,7 +246,7 @@ bool myhtml_insertion_mode_before_head(myhtml_tree_t* tree, myhtml_token_node_t*
break;
}
- myhtml_insertion_fix_emit_for_text_begin_ws(token);
+ myhtml_insertion_fix_emit_for_text_begin_ws(tree->token, token);
// default, other token
tree->node_head = myhtml_tree_node_insert(tree, MyHTML_TAG_HEAD, MyHTML_NAMESPACE_HTML);
@@ -1207,8 +1207,8 @@ bool myhtml_insertion_mode_in_body(myhtml_tree_t* tree, myhtml_token_node_t* tok
myhtml_tree_node_t* top_node = tree->open_elements->list[0];
if(top_node->token) {
- myhtml_token_node_wait_for_done(token);
- myhtml_token_node_wait_for_done(top_node->token);
+ myhtml_token_node_wait_for_done(tree->token, token);
+ myhtml_token_node_wait_for_done(tree->token, top_node->token);
myhtml_token_node_attr_copy_with_check(tree->token, token, top_node->token, tree->mcasync_rules_attr_id);
}
else {
@@ -1259,8 +1259,8 @@ bool myhtml_insertion_mode_in_body(myhtml_tree_t* tree, myhtml_token_node_t* tok
myhtml_tree_node_t* top_node = tree->open_elements->list[1];
if(top_node->token) {
- myhtml_token_node_wait_for_done(token);
- myhtml_token_node_wait_for_done(top_node->token);
+ myhtml_token_node_wait_for_done(tree->token, token);
+ myhtml_token_node_wait_for_done(tree->token, top_node->token);
myhtml_token_node_attr_copy_with_check(tree->token, token, top_node->token, tree->mcasync_rules_attr_id);
}
else {
@@ -1701,7 +1701,7 @@ bool myhtml_insertion_mode_in_body(myhtml_tree_t* tree, myhtml_token_node_t* tok
myhtml_tree_node_insert_html_element(tree, token);
myhtml_tree_open_elements_pop(tree);
- myhtml_token_node_wait_for_done(token);
+ myhtml_token_node_wait_for_done(tree->token, token);
if(myhtml_token_attr_match_case(tree->token, token, "type", 4, "hidden", 6) == NULL) {
tree->flags ^= (tree->flags & MyHTML_TREE_FLAGS_FRAMESET_OK);
}
@@ -1902,7 +1902,7 @@ bool myhtml_insertion_mode_in_body(myhtml_tree_t* tree, myhtml_token_node_t* tok
{
myhtml_tree_active_formatting_reconstruction(tree);
- myhtml_token_node_wait_for_done(token);
+ myhtml_token_node_wait_for_done(tree->token, token);
myhtml_token_adjust_mathml_attributes(token);
myhtml_token_adjust_foreign_attributes(token);
@@ -1920,7 +1920,7 @@ bool myhtml_insertion_mode_in_body(myhtml_tree_t* tree, myhtml_token_node_t* tok
{
myhtml_tree_active_formatting_reconstruction(tree);
- myhtml_token_node_wait_for_done(token);
+ myhtml_token_node_wait_for_done(tree->token, token);
myhtml_token_adjust_svg_attributes(token);
myhtml_token_adjust_foreign_attributes(token);
@@ -2182,7 +2182,8 @@ bool myhtml_insertion_mode_in_table(myhtml_tree_t* tree, myhtml_token_node_t* to
case MyHTML_TAG_INPUT:
{
- myhtml_token_node_wait_for_done(token);
+ myhtml_token_node_wait_for_done(tree->token, token);
+
if(myhtml_token_attr_match_case(tree->token, token, "type", 4, "hidden", 6) == NULL) {
tree->foster_parenting = true;
myhtml_insertion_mode_in_body(tree, token);
@@ -3301,7 +3302,7 @@ bool myhtml_insertion_mode_after_body(myhtml_tree_t* tree, myhtml_token_node_t*
case MyHTML_TAG__COMMENT:
{
if(tree->open_elements->length == 0) {
- MyHTML_DEBUG_ERROR("after body state; open_elements length < 1");
+ MyCORE_DEBUG_ERROR("after body state; open_elements length < 1");
break;
}
@@ -3396,8 +3397,8 @@ bool myhtml_insertion_mode_in_frameset(myhtml_tree_t* tree, myhtml_token_node_t*
// parse error
/* %EXTERNAL% VALIDATOR:RULES TOKEN STATUS:ELEMENT_UNNECESSARY ACTION:IGNORE LEVEL:ERROR */
- myhtml_token_node_wait_for_done(token);
- myhtml_string_stay_only_whitespace(&token->str);
+ myhtml_token_node_wait_for_done(tree->token, token);
+ mycore_string_stay_only_whitespace(&token->str);
if(token->str.length)
myhtml_tree_node_insert_text(tree, token);
@@ -3488,8 +3489,8 @@ bool myhtml_insertion_mode_after_frameset(myhtml_tree_t* tree, myhtml_token_node
// parse error
/* %EXTERNAL% VALIDATOR:RULES TOKEN STATUS:ELEMENT_UNNECESSARY ACTION:IGNORE LEVEL:ERROR */
- myhtml_token_node_wait_for_done(token);
- myhtml_string_stay_only_whitespace(&token->str);
+ myhtml_token_node_wait_for_done(tree->token, token);
+ mycore_string_stay_only_whitespace(&token->str);
if(token->str.length)
myhtml_tree_node_insert_text(tree, token);
@@ -3684,7 +3685,7 @@ bool myhtml_insertion_mode_in_foreign_content_start_other(myhtml_tree_t* tree, m
{
myhtml_tree_node_t* adjusted_node = myhtml_tree_adjusted_current_node(tree);
- myhtml_token_node_wait_for_done(token);
+ myhtml_token_node_wait_for_done(tree->token, token);
if(adjusted_node->ns == MyHTML_NAMESPACE_MATHML) {
myhtml_token_adjust_mathml_attributes(token);
@@ -3738,7 +3739,7 @@ bool myhtml_insertion_mode_in_foreign_content(myhtml_tree_t* tree, myhtml_token_
// parse error
/* %EXTERNAL% VALIDATOR:RULES TOKEN STATUS:NULL_CHAR LEVEL:ERROR */
- myhtml_token_node_wait_for_done(token);
+ myhtml_token_node_wait_for_done(tree->token, token);
myhtml_token_set_replacement_character_for_null_token(tree, token);
}
@@ -3812,12 +3813,14 @@ bool myhtml_insertion_mode_in_foreign_content(myhtml_tree_t* tree, myhtml_token_
if(token->tag_id == MyHTML_TAG_FONT)
{
- myhtml_token_node_wait_for_done(token);
+ myhtml_token_node_wait_for_done(tree->token, token);
if(myhtml_token_attr_by_name(token, "color", 5) == NULL &&
myhtml_token_attr_by_name(token, "face" , 4) == NULL &&
myhtml_token_attr_by_name(token, "size" , 4) == NULL)
+ {
return myhtml_insertion_mode_in_foreign_content_start_other(tree, token);
+ }
}
if(tree->fragment == NULL) {
@@ -3854,7 +3857,7 @@ bool myhtml_rules_check_for_first_newline(myhtml_tree_t* tree, myhtml_token_node
if(tree->flags &MyHTML_TREE_FLAGS_PARSE_FLAG_EMIT_NEWLINE)
{
if(token->tag_id == MyHTML_TAG__TEXT) {
- myhtml_token_node_wait_for_done(token);
+ myhtml_token_node_wait_for_done(tree->token, token);
if(token->str.length > 0) {
if(token->str.data[0] == '\n') {
@@ -3924,9 +3927,9 @@ bool myhtml_rules_tree_dispatcher(myhtml_tree_t* tree, myhtml_token_node_t* toke
return reprocess;
}
-myhtml_status_t myhtml_rules_init(myhtml_t* myhtml)
+mystatus_t myhtml_rules_init(myhtml_t* myhtml)
{
- myhtml->insertion_func = (myhtml_insertion_f*)myhtml_malloc(sizeof(myhtml_insertion_f) * MyHTML_INSERTION_MODE_LAST_ENTRY);
+ myhtml->insertion_func = (myhtml_insertion_f*)mycore_malloc(sizeof(myhtml_insertion_f) * MyHTML_INSERTION_MODE_LAST_ENTRY);
if(myhtml->insertion_func == NULL)
return MyHTML_STATUS_RULES_ERROR_MEMORY_ALLOCATION;
diff --git a/source/myhtml/rules.h b/source/myhtml/rules.h
index 1724e22..7610115 100644
--- a/source/myhtml/rules.h
+++ b/source/myhtml/rules.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -30,8 +30,7 @@ extern "C" {
#include "myhtml/myhtml.h"
#include "myhtml/tree.h"
-
-myhtml_status_t myhtml_rules_init(myhtml_t* myhtml);
+mystatus_t myhtml_rules_init(myhtml_t* myhtml);
void myhtml_rules_stop_parsing(myhtml_tree_t* tree);
bool myhtml_rules_tree_dispatcher(myhtml_tree_t* tree, myhtml_token_node_t* token);
@@ -39,7 +38,6 @@ bool myhtml_insertion_mode_in_body_other_end_tag(myhtml_tree_t* tree, myhtml_tok
bool myhtml_insertion_mode_in_body(myhtml_tree_t* tree, myhtml_token_node_t* token);
bool myhtml_insertion_mode_in_template(myhtml_tree_t* tree, myhtml_token_node_t* token);
-
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/source/myhtml/serialization.c b/source/myhtml/serialization.c
index 75003f3..c142c91 100755
--- a/source/myhtml/serialization.c
+++ b/source/myhtml/serialization.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -19,22 +19,21 @@
Author: https://github.com/EmielBruijntjes (Emiel Bruijntjes)
*/
-#include <setjmp.h>
#include "myhtml/serialization.h"
/**
* Forward declaration of all the functions that are used inside this module
*/
-static void myhtml_serialization_append(const char* str, size_t size, myhtml_callback_serialize_f callback, void *ptr);
-static void myhtml_serialization_append_attr(const char* str, size_t length, myhtml_callback_serialize_f callback, void *ptr);
-static void myhtml_serialization_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* attr, myhtml_callback_serialize_f callback, void *ptr);
-static void myhtml_serialization_node_append_text_node(myhtml_tree_node_t* node, myhtml_callback_serialize_f callback, void *ptr);
-static void myhtml_serialization_node_append_close(myhtml_tree_node_t* node, myhtml_callback_serialize_f callback, void *ptr);
+static mystatus_t myhtml_serialization_append(const char* str, size_t size, mycore_callback_serialize_f callback, void *ptr);
+static mystatus_t myhtml_serialization_append_attr(const char* str, size_t length, mycore_callback_serialize_f callback, void *ptr);
+static mystatus_t myhtml_serialization_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* attr, mycore_callback_serialize_f callback, void *ptr);
+static mystatus_t myhtml_serialization_node_append_text_node(myhtml_tree_node_t* node, mycore_callback_serialize_f callback, void *ptr);
+static mystatus_t myhtml_serialization_node_append_close(myhtml_tree_node_t* node, mycore_callback_serialize_f callback, void *ptr);
/**
* See the function myhtml_serialization_tree_buffer
*/
-bool myhtml_serialization(myhtml_tree_node_t* scope_node, myhtml_string_raw_t* str)
+mystatus_t myhtml_serialization(myhtml_tree_node_t* scope_node, mycore_string_raw_t* str)
{
return myhtml_serialization_tree_buffer(scope_node, str);
}
@@ -42,7 +41,7 @@ bool myhtml_serialization(myhtml_tree_node_t* scope_node, myhtml_string_raw_t* s
/**
* See the function myhtml_serialization_node_buffer
*/
-bool myhtml_serialization_node(myhtml_tree_node_t* node, myhtml_string_raw_t* str)
+mystatus_t myhtml_serialization_node(myhtml_tree_node_t* node, mycore_string_raw_t* str)
{
return myhtml_serialization_node_buffer(node, str);
}
@@ -55,32 +54,41 @@ bool myhtml_serialization_node(myhtml_tree_node_t* node, myhtml_string_raw_t* st
* @param ptr user-supplied pointer
* @return bool
*/
-bool myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node, myhtml_callback_serialize_f callback, void *ptr)
+mystatus_t myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node, mycore_callback_serialize_f callback, void *ptr)
{
myhtml_tree_node_t* node = scope_node;
while(node) {
- if(!myhtml_serialization_node_callback(node, callback, ptr)) return false;
+ if(myhtml_serialization_node_callback(node, callback, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
if(node->child)
node = node->child;
else {
while(node != scope_node && node->next == NULL) {
- myhtml_serialization_node_append_close(node, callback, ptr);
+ if(myhtml_serialization_node_append_close(node, callback, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
node = node->parent;
}
if(node == scope_node) {
- if(node != node->tree->document) myhtml_serialization_node_append_close(node, callback, ptr);
+ if(node != node->tree->document) {
+ if(myhtml_serialization_node_append_close(node, callback, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
break;
}
- myhtml_serialization_node_append_close(node, callback, ptr);
+ if(myhtml_serialization_node_append_close(node, callback, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
node = node->next;
}
}
- return true;
+ return MyCORE_STATUS_OK;
}
/**
@@ -91,46 +99,73 @@ bool myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node, myhtml_c
* @param ptr user-supplied pointer
* @return bool
*/
-bool myhtml_serialization_node_callback(myhtml_tree_node_t* node, myhtml_callback_serialize_f callback, void *ptr)
+mystatus_t myhtml_serialization_node_callback(myhtml_tree_node_t* node, mycore_callback_serialize_f callback, void *ptr)
{
switch (node->tag_id) {
case MyHTML_TAG__TEXT: {
- myhtml_serialization_node_append_text_node(node, callback, ptr);
+ if(myhtml_serialization_node_append_text_node(node, callback, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
break;
}
case MyHTML_TAG__COMMENT: {
- callback("<!--", 4, ptr);
- if(node->token && node->token->str.data) callback(node->token->str.data, node->token->str.length, ptr);
- callback("-->", 3, ptr);
+ if(callback("<!--", 4, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if(node->token && node->token->str.data) {
+ if(callback(node->token->str.data, node->token->str.length, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ if(callback("-->", 3, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
break;
}
case MyHTML_TAG__DOCTYPE: {
- callback("<!DOCTYPE", 9, ptr);
+ if(callback("<!DOCTYPE", 9, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
if(node->token) {
myhtml_tree_attr_t* attr = node->token->attr_first;
if(attr->key.data && attr->key.length) {
- callback(" ", 1, ptr);
- callback(attr->key.data, attr->key.length, ptr);
+ if(callback(" ", 1, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if(callback(attr->key.data, attr->key.length, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
}
}
- callback(">", 1, ptr);
+
+ if(callback(">", 1, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
break;
}
default: {
size_t length;
const char *tag = myhtml_tag_name_by_id(node->tree, node->tag_id, &length);
- callback("<", 1, ptr);
- callback(tag, length, ptr);
- if(node->token) myhtml_serialization_attributes(node->tree, node->token->attr_first, callback, ptr);
- callback(">", 1, ptr);
+ if(callback("<", 1, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if(callback(tag, length, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if(node->token) {
+ if(myhtml_serialization_attributes(node->tree, node->token->attr_first, callback, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ if(callback(">", 1, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
break;
}
}
- return true;
+ return MyCORE_STATUS_OK;
}
/**
@@ -140,28 +175,33 @@ bool myhtml_serialization_node_callback(myhtml_tree_node_t* node, myhtml_callbac
* @param callback
* @param ptr
*/
-void myhtml_serialization_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* attr, myhtml_callback_serialize_f callback, void* ptr)
+mystatus_t myhtml_serialization_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* attr, mycore_callback_serialize_f callback, void* ptr)
{
while(attr) {
- callback(" ", 1, ptr);
+ if(callback(" ", 1, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
switch (attr->ns) {
case MyHTML_NAMESPACE_XML:
- callback("xml:", 4, ptr);
+ if(callback("xml:", 4, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
break;
case MyHTML_NAMESPACE_XMLNS: {
/*
If the attribute is in the XMLNS namespace and the attribute's local name is not xmlns
The attribute's serialized name is the string "xmlns:" followed by the attribute's local name.
*/
- if(attr->key.data && attr->key.length == 5 && myhtml_strcmp(attr->key.data, "xmlns")) {
- callback("xmlns:", 6, ptr);
+ if(attr->key.data && attr->key.length == 5 && mycore_strcmp(attr->key.data, "xmlns")) {
+ if(callback("xmlns:", 6, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
}
break;
}
case MyHTML_NAMESPACE_XLINK: {
- callback("xlink:", 6, ptr);
+ if(callback("xlink:", 6, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
break;
}
@@ -172,14 +212,25 @@ void myhtml_serialization_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* at
size_t length;
const char *data = myhtml_attribute_key(attr, &length);
- if(data) callback(data, length, ptr);
- callback("=\"", 2, ptr);
+ if(data) {
+ if(callback(data, length, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+ if(callback("=\"", 2, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
data = myhtml_attribute_value(attr, &length);
- if(data) myhtml_serialization_append_attr(data, length, callback, ptr);
- callback("\"", 1, ptr);
+ if(data) {
+ if(myhtml_serialization_append_attr(data, length, callback, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+ if(callback("\"", 1, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
attr = attr->next;
}
+
+ return MyCORE_STATUS_OK;
}
/**
@@ -189,7 +240,7 @@ void myhtml_serialization_attributes(myhtml_tree_t* tree, myhtml_tree_attr_t* at
* @param callback
* @param ptr
*/
-void myhtml_serialization_node_append_close(myhtml_tree_node_t* node, myhtml_callback_serialize_f callback, void* ptr)
+mystatus_t myhtml_serialization_node_append_close(myhtml_tree_node_t* node, mycore_callback_serialize_f callback, void* ptr)
{
if(node->tag_id != MyHTML_TAG__TEXT &&
node->tag_id != MyHTML_TAG__COMMENT &&
@@ -198,10 +249,17 @@ void myhtml_serialization_node_append_close(myhtml_tree_node_t* node, myhtml_cal
size_t length;
const char *tag = myhtml_tag_name_by_id(node->tree, node->tag_id, &length);
- callback("</", 2, ptr);
- callback(tag, length, ptr);
- callback(">", 1, ptr);
+ if(callback("</", 2, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if(callback(tag, length, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if(callback(">", 1, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
}
+
+ return MyCORE_STATUS_OK;
}
/**
@@ -211,11 +269,16 @@ void myhtml_serialization_node_append_close(myhtml_tree_node_t* node, myhtml_cal
* @param callback
* @param ptr
*/
-void myhtml_serialization_node_append_text_node(myhtml_tree_node_t* node, myhtml_callback_serialize_f callback, void* ptr)
+mystatus_t myhtml_serialization_node_append_text_node(myhtml_tree_node_t* node, mycore_callback_serialize_f callback, void* ptr)
{
- if(node->token == NULL || node->token->str.data == NULL) return;
+ if(node->token == NULL || node->token->str.data == NULL) return MyCORE_STATUS_OK;
- if(node->parent == NULL) return myhtml_serialization_append(node->token->str.data, node->token->str.length, callback, ptr);
+ if(node->parent == NULL) {
+ if(myhtml_serialization_append(node->token->str.data, node->token->str.length, callback, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ return MyCORE_STATUS_OK;
+ }
switch (node->parent->tag_id) {
case MyHTML_TAG_STYLE:
@@ -225,12 +288,17 @@ void myhtml_serialization_node_append_text_node(myhtml_tree_node_t* node, myhtml
case MyHTML_TAG_NOEMBED:
case MyHTML_TAG_NOFRAMES:
case MyHTML_TAG_PLAINTEXT:
- callback(node->token->str.data, node->token->str.length, ptr);
+ if(callback(node->token->str.data, node->token->str.length, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
break;
default:
- myhtml_serialization_append(node->token->str.data, node->token->str.length, callback, ptr);
+ if(myhtml_serialization_append(node->token->str.data, node->token->str.length, callback, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
break;
}
+
+ return MyCORE_STATUS_OK;
}
/**
@@ -240,7 +308,7 @@ void myhtml_serialization_node_append_text_node(myhtml_tree_node_t* node, myhtml
* @param callback
* @param ptr
*/
-void myhtml_serialization_append(const char *data, size_t size, myhtml_callback_serialize_f callback, void* ptr)
+mystatus_t myhtml_serialization_append(const char *data, size_t size, mycore_callback_serialize_f callback, void* ptr)
{
// number of chars not yet displayed
size_t notwritten = 0;
@@ -249,24 +317,48 @@ void myhtml_serialization_append(const char *data, size_t size, myhtml_callback_
for (size_t i = 0; i < size; ++i) {
switch ((unsigned char)data[i]) {
case '&':
- if (notwritten) callback(data + i - notwritten, notwritten, ptr);
- callback("&amp;", 5, ptr);
+ if(notwritten) {
+ if(callback(data + i - notwritten, notwritten, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ if(callback("&amp;", 5, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
notwritten = 0;
break;
case '<':
- if (notwritten) callback(data + i - notwritten, notwritten, ptr);
- callback("&lt;", 4, ptr);
+ if(notwritten) {
+ if(callback(data + i - notwritten, notwritten, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ if(callback("&lt;", 4, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
notwritten = 0;
break;
case '>':
- if (notwritten) callback(data + i - notwritten, notwritten, ptr);
- callback("&gt;", 4, ptr);
+ if(notwritten) {
+ if(callback(data + i - notwritten, notwritten, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ if(callback("&gt;", 4, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
notwritten = 0;
break;
case 0xA0:
if(i > 0 && (unsigned char)(data[(i - 1)]) == 0xC2) {
- if (notwritten) callback(data + i - notwritten, (notwritten - 1), ptr);
- callback("&nbsp;", 6, ptr);
+ if(notwritten) {
+ if(callback(data + i - notwritten, (notwritten - 1), ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ if(callback("&nbsp;", 6, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
notwritten = 0;
}
else {
@@ -280,7 +372,11 @@ void myhtml_serialization_append(const char *data, size_t size, myhtml_callback_
}
}
- if (notwritten) callback(data + size - notwritten, notwritten, ptr);
+ if(notwritten)
+ if(callback(data + size - notwritten, notwritten, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ return MyCORE_STATUS_OK;
}
/**
@@ -290,7 +386,7 @@ void myhtml_serialization_append(const char *data, size_t size, myhtml_callback_
* @param callback
* @param ptr
*/
-void myhtml_serialization_append_attr(const char* data, size_t size, myhtml_callback_serialize_f callback, void* ptr)
+mystatus_t myhtml_serialization_append_attr(const char* data, size_t size, mycore_callback_serialize_f callback, void* ptr)
{
// number of chars not yet displayed
size_t notwritten = 0;
@@ -299,19 +395,37 @@ void myhtml_serialization_append_attr(const char* data, size_t size, myhtml_call
for (size_t i = 0; i < size; ++i) {
switch ((unsigned char)data[i]) {
case '&':
- if (notwritten) callback(data + i - notwritten, notwritten, ptr);
- callback("&amp;", 5, ptr);
+ if(notwritten) {
+ if(callback(data + i - notwritten, notwritten, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ if(callback("&amp;", 5, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
notwritten = 0;
break;
case '"':
- if (notwritten) callback(data + i - notwritten, notwritten, ptr);
- callback("&quot;", 6, ptr);
+ if(notwritten) {
+ if(callback(data + i - notwritten, notwritten, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ if(callback("&quot;", 6, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
notwritten = 0;
break;
case 0xA0:
if(i > 0 && (unsigned char)(data[(i - 1)]) == 0xC2) {
- if (notwritten) callback(data + i - notwritten, (notwritten - 1), ptr);
- callback("&nbsp;", 6, ptr);
+ if(notwritten) {
+ if(callback(data + i - notwritten, (notwritten - 1), ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ if(callback("&nbsp;", 6, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
notwritten = 0;
}
else {
@@ -325,57 +439,53 @@ void myhtml_serialization_append_attr(const char* data, size_t size, myhtml_call
}
}
- if (notwritten) callback(data + size - notwritten, notwritten, ptr);
+ if(notwritten) {
+ if(callback(data + size - notwritten, notwritten, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ return MyCORE_STATUS_OK;
}
/**
- * Because we want to leap out of the algorithm if we're halfway through
- * serializing, we use a longjmp() call to jump back to the public APP
- * @var jmp_buf
- */
-static jmp_buf leap;
-
-/**
* Reallocate the buffer
* @param str the buffer to reallocate
* @param size new size
*/
-void myhtml_serialization_reallocate(myhtml_string_raw_t *str, size_t size)
+mystatus_t myhtml_serialization_reallocate(mycore_string_raw_t *str, size_t size)
{
// construct a buffer
- char *data = (char*)myhtml_realloc(str->data, size * sizeof(char));
+ char *data = (char*)mycore_realloc(str->data, size * sizeof(char));
// was it ok?
- if (data == NULL) {
-
- // allocation failed, reset the string object
- myhtml_free(str->data);
- memset(str, 0, sizeof(myhtml_string_raw_t));
-
- // leap back to the source of the serialization algorithm
- longjmp(leap, 1);
+ if(data == NULL) {
+ memset(str, 0, sizeof(mycore_string_raw_t));
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
}
else {
-
// reallocation succeeded
str->data = data;
str->size = size;
}
+
+ return MyCORE_STATUS_OK;
}
/**
- * Implementation of the myhtml_callback_serialize_f function for internal
+ * Implementation of the mycore_callback_serialize_f function for internal
* use that concatenats everything to a string
* @param data
* @param size
*/
-void myhtml_serialization_concatenate(const char* data, size_t length, void *ptr)
+mystatus_t myhtml_serialization_concatenate(const char* data, size_t length, void *ptr)
{
- // get the string back
- myhtml_string_raw_t* str = (myhtml_string_raw_t *)ptr;
+ mycore_string_raw_t *str = (mycore_string_raw_t*)ptr;
// do we still have enough size in the output buffer?
- if ((length + str->length) >= str->size) myhtml_serialization_reallocate(str, length + str->length + 4096);
+ if ((length + str->length) >= str->size) {
+ if(myhtml_serialization_reallocate(str, length + str->length + 4096))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
// copy data
strncpy(&str->data[ str->length ], data, length);
@@ -383,6 +493,8 @@ void myhtml_serialization_concatenate(const char* data, size_t length, void *ptr
// update counters
str->length += length;
str->data[ str->length ] = '\0';
+
+ return MyCORE_STATUS_OK;
}
/**
@@ -392,7 +504,7 @@ void myhtml_serialization_concatenate(const char* data, size_t length, void *ptr
* @param str
* @return bool
*/
-bool myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, myhtml_string_raw_t* str) {
+mystatus_t myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, mycore_string_raw_t* str) {
// we need an output variable
if(str == NULL) return false;
@@ -401,25 +513,15 @@ bool myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, myhtml_str
if(str->data == NULL) {
str->size = 4098 * 5;
str->length = 0;
- str->data = (char*)myhtml_malloc(str->size * sizeof(char));
+ str->data = (char*)mycore_malloc(str->size * sizeof(char));
if(str->data == NULL) {
str->size = 0;
- return false;
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
}
}
- // if allocation halfway the algorithm fails, we want to leap back
- if (setjmp(leap) == 0)
- {
- // serialize the entire tree
- return myhtml_serialization_tree_callback(scope_node, myhtml_serialization_concatenate, str);
- }
- else
- {
- // the serialization algorithm failed because of a memory-allocation failure
- return false;
- }
+ return myhtml_serialization_tree_callback(scope_node, myhtml_serialization_concatenate, str);
}
/**
@@ -429,7 +531,7 @@ bool myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, myhtml_str
* @param str
* @return bool
*/
-bool myhtml_serialization_node_buffer(myhtml_tree_node_t* node, myhtml_string_raw_t* str) {
+mystatus_t myhtml_serialization_node_buffer(myhtml_tree_node_t* node, mycore_string_raw_t* str) {
// we need an output variable
if(str == NULL) return false;
@@ -438,24 +540,14 @@ bool myhtml_serialization_node_buffer(myhtml_tree_node_t* node, myhtml_string_ra
if(str->data == NULL) {
str->size = 2048;
str->length = 0;
- str->data = (char*)myhtml_malloc(str->size * sizeof(char));
+ str->data = (char*)mycore_malloc(str->size * sizeof(char));
if(str->data == NULL) {
str->size = 0;
return false;
}
}
-
- // if allocation halfway the algorithm fails, we want to leap back
- if (setjmp(leap) == 0)
- {
- // pass on
- return myhtml_serialization_node_callback(node, myhtml_serialization_concatenate, str);
- }
- else
- {
- // the serialization algorithm failed because of a memory-allocation failure
- return false;
- }
+
+ return myhtml_serialization_node_callback(node, myhtml_serialization_concatenate, str);
}
diff --git a/source/myhtml/serialization.h b/source/myhtml/serialization.h
index e651769..d21fd70 100644
--- a/source/myhtml/serialization.h
+++ b/source/myhtml/serialization.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Alexander Borisov
+ 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
@@ -31,15 +31,15 @@ extern "C" {
#endif
// the serialization functions
-bool myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, myhtml_string_raw_t* str);
-bool myhtml_serialization_node_buffer(myhtml_tree_node_t* node, myhtml_string_raw_t* str);
-bool myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node, myhtml_callback_serialize_f callback, void* ptr);
-bool myhtml_serialization_node_callback(myhtml_tree_node_t* node, myhtml_callback_serialize_f callback, void* ptr);
+mystatus_t myhtml_serialization_tree_buffer(myhtml_tree_node_t* scope_node, mycore_string_raw_t* str);
+mystatus_t myhtml_serialization_node_buffer(myhtml_tree_node_t* node, mycore_string_raw_t* str);
+mystatus_t myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node, mycore_callback_serialize_f callback, void* ptr);
+mystatus_t myhtml_serialization_node_callback(myhtml_tree_node_t* node, mycore_callback_serialize_f callback, void* ptr);
// in versuon 1.0.3 this is in public api.
// Need to set deprecated?
-bool myhtml_serialization(myhtml_tree_node_t* scope_node, myhtml_string_raw_t* str);
-bool myhtml_serialization_node(myhtml_tree_node_t* node, myhtml_string_raw_t* str);
+mystatus_t myhtml_serialization(myhtml_tree_node_t* scope_node, mycore_string_raw_t* str);
+mystatus_t myhtml_serialization_node(myhtml_tree_node_t* node, mycore_string_raw_t* str);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/myhtml/stream.c b/source/myhtml/stream.c
index b0779df..0090301 100644
--- a/source/myhtml/stream.c
+++ b/source/myhtml/stream.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -22,14 +22,14 @@
myhtml_stream_buffer_t * myhtml_stream_buffer_create(void)
{
- return myhtml_calloc(1, sizeof(myhtml_stream_buffer_t));
+ return mycore_calloc(1, sizeof(myhtml_stream_buffer_t));
}
-myhtml_status_t myhtml_stream_buffer_init(myhtml_stream_buffer_t* stream_buffer, size_t entries_size)
+mystatus_t myhtml_stream_buffer_init(myhtml_stream_buffer_t* stream_buffer, size_t entries_size)
{
stream_buffer->length = 0;
stream_buffer->size = entries_size;
- stream_buffer->entries = myhtml_calloc(entries_size, sizeof(myhtml_stream_buffer_entry_t));
+ stream_buffer->entries = mycore_calloc(entries_size, sizeof(myhtml_stream_buffer_entry_t));
if(stream_buffer->entries == NULL)
return MyHTML_STATUS_STREAM_BUFFER_ERROR_INIT;
@@ -37,18 +37,18 @@ myhtml_status_t myhtml_stream_buffer_init(myhtml_stream_buffer_t* stream_buffer,
return MyHTML_STATUS_OK;
}
-myhtml_status_t myhtml_stream_buffer_entry_init(myhtml_stream_buffer_entry_t* stream_buffer_entry, size_t size)
+mystatus_t myhtml_stream_buffer_entry_init(myhtml_stream_buffer_entry_t* stream_buffer_entry, size_t size)
{
if(stream_buffer_entry->data) {
if(size <= stream_buffer_entry->size)
return MyHTML_STATUS_OK;
else
- myhtml_free(stream_buffer_entry->data);
+ mycore_free(stream_buffer_entry->data);
}
stream_buffer_entry->length = 0;
stream_buffer_entry->size = size;
- stream_buffer_entry->data = myhtml_malloc(size * sizeof(char));
+ stream_buffer_entry->data = mycore_malloc(size * sizeof(char));
if(stream_buffer_entry->data == NULL)
return MyHTML_STATUS_STREAM_BUFFER_ENTRY_ERROR_INIT;
@@ -68,10 +68,10 @@ myhtml_stream_buffer_entry_t * myhtml_stream_buffer_entry_destroy(myhtml_stream_
return NULL;
if(stream_buffer_entry->data)
- myhtml_free(stream_buffer_entry->data);
+ mycore_free(stream_buffer_entry->data);
if(self_destroy) {
- myhtml_free(stream_buffer_entry);
+ mycore_free(stream_buffer_entry);
return NULL;
}
@@ -93,11 +93,11 @@ myhtml_stream_buffer_t * myhtml_stream_buffer_destroy(myhtml_stream_buffer_t* st
for(size_t i = 0; i < stream_buffer->length; i++)
myhtml_stream_buffer_entry_destroy(&stream_buffer->entries[i], false);
- myhtml_free(stream_buffer->entries);
+ mycore_free(stream_buffer->entries);
}
if(self_destroy) {
- myhtml_free(stream_buffer);
+ mycore_free(stream_buffer);
return NULL;
}
@@ -109,7 +109,7 @@ myhtml_stream_buffer_entry_t * myhtml_stream_buffer_add_entry(myhtml_stream_buff
if(stream_buffer->length >= stream_buffer->size) {
size_t new_size = stream_buffer->size << 1;
- myhtml_stream_buffer_entry_t *entries = myhtml_realloc(stream_buffer, sizeof(myhtml_stream_buffer_entry_t) * new_size);
+ myhtml_stream_buffer_entry_t *entries = mycore_realloc(stream_buffer, sizeof(myhtml_stream_buffer_entry_t) * new_size);
if(entries) {
memset(&entries[stream_buffer->size], 0, (new_size - stream_buffer->size));
@@ -122,7 +122,7 @@ myhtml_stream_buffer_entry_t * myhtml_stream_buffer_add_entry(myhtml_stream_buff
}
myhtml_stream_buffer_entry_t *entry = &stream_buffer->entries[ stream_buffer->length ];
- myhtml_status_t status = myhtml_stream_buffer_entry_init(entry, entry_data_size);
+ mystatus_t status = myhtml_stream_buffer_entry_init(entry, entry_data_size);
if(status != MyHTML_STATUS_OK)
return NULL;
diff --git a/source/myhtml/stream.h b/source/myhtml/stream.h
index e015438..94c4fc2 100644
--- a/source/myhtml/stream.h
+++ b/source/myhtml/stream.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -41,17 +41,17 @@ struct myhtml_stream_buffer {
size_t length;
size_t size;
- myhtml_encoding_result_t res;
+ myencoding_result_t res;
};
myhtml_stream_buffer_t * myhtml_stream_buffer_create(void);
-myhtml_status_t myhtml_stream_buffer_init(myhtml_stream_buffer_t* stream_buffer, size_t entries_size);
+mystatus_t myhtml_stream_buffer_init(myhtml_stream_buffer_t* stream_buffer, size_t entries_size);
void myhtml_stream_buffer_clean(myhtml_stream_buffer_t* stream_buffer);
myhtml_stream_buffer_t * myhtml_stream_buffer_destroy(myhtml_stream_buffer_t* stream_buffer, bool self_destroy);
myhtml_stream_buffer_entry_t * myhtml_stream_buffer_add_entry(myhtml_stream_buffer_t* stream_buffer, size_t entry_data_size);
myhtml_stream_buffer_entry_t * myhtml_stream_buffer_current_entry(myhtml_stream_buffer_t* stream_buffer);
-myhtml_status_t myhtml_stream_buffer_entry_init(myhtml_stream_buffer_entry_t* stream_buffer_entry, size_t size);
+mystatus_t myhtml_stream_buffer_entry_init(myhtml_stream_buffer_entry_t* stream_buffer_entry, size_t size);
void myhtml_stream_buffer_entry_clean(myhtml_stream_buffer_entry_t* stream_buffer_entry);
myhtml_stream_buffer_entry_t * myhtml_stream_buffer_entry_destroy(myhtml_stream_buffer_entry_t* stream_buffer_entry, bool self_destroy);
diff --git a/source/myhtml/tag.c b/source/myhtml/tag.c
index 65a8f56..4664bb1 100755
--- a/source/myhtml/tag.c
+++ b/source/myhtml/tag.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -23,11 +23,13 @@
myhtml_tag_t * myhtml_tag_create(void)
{
- return (myhtml_tag_t*)myhtml_malloc(sizeof(myhtml_tag_t));
+ return (myhtml_tag_t*)mycore_malloc(sizeof(myhtml_tag_t));
}
-myhtml_status_t myhtml_tag_init(myhtml_tree_t *tree, myhtml_tag_t *tags)
+mystatus_t myhtml_tag_init(myhtml_tree_t *tree, myhtml_tag_t *tags)
{
+ mystatus_t status;
+
tags->mcsimple_context = mcsimple_create();
if(tags->mcsimple_context == NULL)
@@ -35,10 +37,16 @@ myhtml_status_t myhtml_tag_init(myhtml_tree_t *tree, myhtml_tag_t *tags)
mcsimple_init(tags->mcsimple_context, 128, 1024, sizeof(myhtml_tag_context_t));
- tags->mchar_node = mchar_async_node_add(tree->mchar);
- tags->tree = mctree_create(2);
- tags->mchar = tree->mchar;
- tags->tags_count = MyHTML_TAG_LAST_ENTRY;
+ tags->mchar_node = mchar_async_node_add(tree->mchar, &status);
+ tags->tree = mctree_create(2);
+ tags->mchar = tree->mchar;
+ tags->tags_count = MyHTML_TAG_LAST_ENTRY;
+
+ if(status)
+ return status;
+
+ if(tags->tree == NULL)
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
myhtml_tag_clean(tags);
@@ -64,7 +72,7 @@ myhtml_tag_t * myhtml_tag_destroy(myhtml_tag_t* tags)
mchar_async_node_delete(tags->mchar, tags->mchar_node);
- myhtml_free(tags);
+ mycore_free(tags);
return NULL;
}
@@ -134,24 +142,3 @@ const myhtml_tag_context_t * myhtml_tag_get_by_name(myhtml_tag_t* tags, const ch
return (myhtml_tag_context_t*)tags->tree->nodes[idx].value;
}
-
-void myhtml_tag_print(myhtml_tag_t* tags, FILE* fh)
-{
- size_t i;
- for(i = MyHTML_TAG_FIRST_ENTRY; i < MyHTML_TAG_LAST_ENTRY; i++)
- {
- const myhtml_tag_context_t *ctx = myhtml_tag_get_by_id(tags, i);
-
- fprintf(fh, "<%s id=\"%zu\">\n", ctx->name, i);
- }
-
- for(i = (MyHTML_TAG_LAST_ENTRY + 1); i < tags->tags_count; i++)
- {
- const myhtml_tag_context_t *ctx = myhtml_tag_get_by_id(tags, i);
-
- fprintf(fh, "<%s id=\"%zu\">\n", ctx->name, i);
- }
-}
-
-
-
diff --git a/source/myhtml/tag.h b/source/myhtml/tag.h
index 3814ef9..945b65a 100644
--- a/source/myhtml/tag.h
+++ b/source/myhtml/tag.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -31,12 +31,12 @@ extern "C" {
#include "myhtml/tag_const.h"
#include "myhtml/tokenizer.h"
#include "myhtml/tree.h"
-#include "myhtml/utils.h"
-#include "myhtml/utils/mctree.h"
-#include "myhtml/utils/mchar_async.h"
-#include "myhtml/utils/mcobject.h"
-#include "myhtml/utils/mcobject_async.h"
-#include "myhtml/utils/mcsimple.h"
+#include "mycore/utils.h"
+#include "mycore/utils/mctree.h"
+#include "mycore/utils/mchar_async.h"
+#include "mycore/utils/mcobject.h"
+#include "mycore/utils/mcobject_async.h"
+#include "mycore/utils/mcsimple.h"
#define myhtml_tag_get(tags, idx, attr) tags->context[idx].attr
@@ -52,7 +52,7 @@ extern "C" {
tags->context_length++; \
if(tags->context_length == tags->context_size) { \
tags->context_size += 4096; \
- tags->context = (myhtml_tag_context_t*)myhtml_realloc(tags->context, \
+ tags->context = (myhtml_tag_context_t*)mycore_realloc(tags->context, \
sizeof(myhtml_tag_context_t) * tags->context_size); \
} \
myhtml_tag_context_clean(tags, tags->context_length)
@@ -89,7 +89,7 @@ struct myhtml_tag {
};
myhtml_tag_t * myhtml_tag_create(void);
-myhtml_status_t myhtml_tag_init(myhtml_tree_t *tree, myhtml_tag_t *tags);
+mystatus_t myhtml_tag_init(myhtml_tree_t *tree, myhtml_tag_t *tags);
void myhtml_tag_clean(myhtml_tag_t* tags);
myhtml_tag_t * myhtml_tag_destroy(myhtml_tag_t* tags);
@@ -105,8 +105,6 @@ const myhtml_tag_context_t * myhtml_tag_get_by_name(myhtml_tag_t* tags, const ch
const myhtml_tag_context_t * myhtml_tag_static_get_by_id(size_t idx);
const myhtml_tag_context_t * myhtml_tag_static_search(const char* name, size_t length);
-void myhtml_tag_print(myhtml_tag_t* tags, FILE* fh);
-
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/source/myhtml/tag_const.h b/source/myhtml/tag_const.h
index 0f5b389..1b29934 100644
--- a/source/myhtml/tag_const.h
+++ b/source/myhtml/tag_const.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/source/myhtml/tag_init.c b/source/myhtml/tag_init.c
index c66c266..d96e62f 100755
--- a/source/myhtml/tag_init.c
+++ b/source/myhtml/tag_init.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,8 +18,8 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/utils/resources.h"
-#include "tag.h"
+#include "mycore/utils/resources.h"
+#include "myhtml/tag.h"
static const myhtml_tag_context_t myhtml_tag_base_list[MyHTML_TAG_LAST_ENTRY] =
{
@@ -2591,15 +2591,15 @@ static const myhtml_tag_static_list_t myhtml_tag_static_list_index[] =
const myhtml_tag_context_t * myhtml_tag_static_search(const char* name, size_t length)
{
- size_t idx = ((myhtml_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
- myhtml_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
+ size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
+ mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
length)
% MyHTML_BASE_STATIC_SIZE) + 1;
while (myhtml_tag_static_list_index[idx].ctx)
{
if(myhtml_tag_static_list_index[idx].ctx->name_length == length) {
- if(myhtml_strncasecmp(myhtml_tag_static_list_index[idx].ctx->name, name, length) == 0)
+ if(mycore_strncasecmp(myhtml_tag_static_list_index[idx].ctx->name, name, length) == 0)
return myhtml_tag_static_list_index[idx].ctx;
if(myhtml_tag_static_list_index[idx].next)
diff --git a/source/myhtml/thread.c b/source/myhtml/thread.c
deleted file mode 100644
index 94e277a..0000000
--- a/source/myhtml/thread.c
+++ /dev/null
@@ -1,1185 +0,0 @@
-/*
- Copyright (C) 2015-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)
-*/
-
-#include "myhtml/thread.h"
-
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
-
-#if defined(IS_OS_WINDOWS)
-/***********************************************************************************
- *
- * For Windows
- *
- ***********************************************************************************/
-myhtml_status_t myhtml_thread_create(mythread_t *mythread, mythread_list_t *thr, void *work_func)
-{
- thr->pth = CreateThread(NULL, // default security attributes
- 0, // use default stack size
- work_func, // thread function name
- &thr->data, // argument to thread function
- 0, // use default creation flags
- NULL); // returns the thread identifier
-
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_thread_join(mythread_t *mythread, mythread_list_t *thr)
-{
- WaitForSingleObject(thr->pth, INFINITE);
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_thread_cancel(mythread_t *mythread, mythread_list_t *thr)
-{
- TerminateThread(thr->pth, 0);
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_thread_attr_init(mythread_t *mythread)
-{
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_thread_attr_clean(mythread_t *mythread)
-{
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_thread_attr_destroy(mythread_t *mythread)
-{
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_hread_mutex_create(mythread_t *mythread, mythread_context_t *ctx, size_t prefix_id)
-{
- ctx->mutex = CreateSemaphore(NULL, 0, 1, NULL);
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_hread_mutex_post(mythread_t *mythread, mythread_context_t *ctx)
-{
- ReleaseSemaphore(ctx->mutex, 1, NULL);
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_hread_mutex_wait(mythread_t *mythread, mythread_context_t *ctx)
-{
- WaitForSingleObject(ctx->mutex, INFINITE);
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_hread_mutex_try_wait(mythread_t *mythread, mythread_context_t *ctx)
-{
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_hread_mutex_close(mythread_t *mythread, mythread_context_t *ctx)
-{
- CloseHandle(ctx->mutex);
-
- return MyHTML_STATUS_OK;
-}
-
-void myhtml_thread_nanosleep(const struct timespec *tomeout)
-{
- Sleep(0);
-}
-
-#else /* defined(IS_OS_WINDOWS) */
-/***********************************************************************************
- *
- * For all unix system. POSIX pthread
- *
- ***********************************************************************************/
-
-myhtml_status_t myhtml_thread_create(mythread_t *mythread, mythread_list_t *thr, void *work_func)
-{
- pthread_create(&thr->pth, mythread->attr,
- work_func,
- (void*)(&thr->data));
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_thread_join(mythread_t *mythread, mythread_list_t *thr)
-{
- pthread_join(thr->pth, NULL);
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_thread_cancel(mythread_t *mythread, mythread_list_t *thr)
-{
- pthread_cancel(thr->pth);
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_thread_attr_init(mythread_t *mythread)
-{
- mythread->attr = (pthread_attr_t*)myhtml_calloc(1, sizeof(pthread_attr_t));
-
- if(mythread->attr == NULL)
- return MyHTML_STATUS_THREAD_ERROR_ATTR_MALLOC;
-
- mythread->sys_last_error = pthread_attr_init(mythread->attr);
- if(mythread->sys_last_error)
- return MyHTML_STATUS_THREAD_ERROR_ATTR_INIT;
-
- mythread->sys_last_error = pthread_attr_setdetachstate(mythread->attr, PTHREAD_CREATE_JOINABLE);
- if(mythread->sys_last_error)
- return MyHTML_STATUS_THREAD_ERROR_ATTR_SET;
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_thread_attr_clean(mythread_t *mythread)
-{
- mythread->attr = NULL;
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_thread_attr_destroy(mythread_t *mythread)
-{
- if(mythread->attr) {
- mythread->sys_last_error = pthread_attr_destroy(mythread->attr);
-
- myhtml_free(mythread->attr);
- mythread->attr = NULL;
-
- if(mythread->sys_last_error)
- return MyHTML_STATUS_THREAD_ERROR_ATTR_DESTROY;
- }
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_hread_mutex_create(mythread_t *mythread, mythread_context_t *ctx, size_t prefix_id)
-{
- ctx->mutex = (pthread_mutex_t*)myhtml_calloc(1, sizeof(pthread_mutex_t));
-
- if(ctx->mutex == NULL)
- return MyHTML_STATUS_THREAD_ERROR_MUTEX_MALLOC;
-
- if(pthread_mutex_init(ctx->mutex, NULL)) {
- mythread->sys_last_error = errno;
- return MyHTML_STATUS_THREAD_ERROR_MUTEX_INIT;
- }
-
- if(pthread_mutex_lock(ctx->mutex)) {
- mythread->sys_last_error = errno;
- return MyHTML_STATUS_THREAD_ERROR_MUTEX_LOCK;
- }
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_hread_mutex_post(mythread_t *mythread, mythread_context_t *ctx)
-{
- if(pthread_mutex_unlock(ctx->mutex)) {
- mythread->sys_last_error = errno;
- return MyHTML_STATUS_THREAD_ERROR_MUTEX_UNLOCK;
- }
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_hread_mutex_wait(mythread_t *mythread, mythread_context_t *ctx)
-{
- if(pthread_mutex_lock(ctx->mutex)) {
- mythread->sys_last_error = errno;
- return MyHTML_STATUS_THREAD_ERROR_MUTEX_LOCK;
- }
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_hread_mutex_try_wait(mythread_t *mythread, mythread_context_t *ctx)
-{
- if(pthread_mutex_trylock(ctx->mutex)) {
- mythread->sys_last_error = errno;
- return MyHTML_STATUS_THREAD_ERROR_MUTEX_LOCK;
- }
-
- return MyHTML_STATUS_OK;
-}
-
-myhtml_status_t myhtml_hread_mutex_close(mythread_t *mythread, mythread_context_t *ctx)
-{
- if(ctx->mutex) {
- pthread_mutex_destroy(ctx->mutex);
- myhtml_free(ctx->mutex);
-
- ctx->mutex = NULL;
- }
-
- return MyHTML_STATUS_OK;
-}
-
-void myhtml_thread_nanosleep(const struct timespec *tomeout)
-{
- nanosleep(tomeout, NULL);
-}
-
-#endif /* !defined(IS_OS_WINDOWS) */
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
-/*
- *
- * MyTHREAD logic
- *
- */
-
-mythread_t * mythread_create(void)
-{
- return myhtml_calloc(1, sizeof(mythread_t));
-}
-
-#ifdef MyHTML_BUILD_WITHOUT_THREADS
-
-myhtml_status_t mythread_init(mythread_t *mythread, const char *sem_prefix, size_t thread_count)
-{
- return MyHTML_STATUS_OK;
-}
-
-#else /* MyHTML_BUILD_WITHOUT_THREADS */
-
-myhtml_status_t mythread_init(mythread_t *mythread, const char *sem_prefix, size_t thread_count)
-{
- mythread->batch_count = 0;
- mythread->batch_first_id = 0;
- mythread->stream_opt = MyTHREAD_OPT_STOP;
- mythread->batch_opt = MyTHREAD_OPT_STOP;
-
- if(thread_count)
- {
- myhtml_status_t status = myhtml_thread_attr_init(mythread);
- if(status)
- return status;
-
- mythread->pth_list_root = 1;
- mythread->pth_list_length = 1;
- mythread->pth_list_size = thread_count + 1;
- mythread->pth_list = (mythread_list_t*)myhtml_calloc(mythread->pth_list_size, sizeof(mythread_list_t));
-
- if(mythread->pth_list == NULL)
- return MyHTML_STATUS_THREAD_ERROR_LIST_INIT;
- }
- else {
- myhtml_thread_attr_clean(mythread);
-
- mythread->sys_last_error = 0;
- mythread->pth_list_root = 1;
- mythread->pth_list_length = 1;
- mythread->pth_list_size = 0;
- mythread->pth_list = NULL;
- }
-
- if(sem_prefix)
- {
- mythread->sem_prefix_length = strlen(sem_prefix);
-
- if(mythread->sem_prefix_length) {
- mythread->sem_prefix = myhtml_calloc((mythread->sem_prefix_length + 1), sizeof(char));
-
- if(mythread->sem_prefix == NULL) {
- mythread->sem_prefix_length = 0;
- return MyHTML_STATUS_THREAD_ERROR_SEM_PREFIX_MALLOC;
- }
-
- myhtml_string_raw_copy(mythread->sem_prefix, sem_prefix, mythread->sem_prefix_length);
- }
- }
-
- return MyHTML_STATUS_OK;
-}
-
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
-void mythread_clean(mythread_t *mythread)
-{
- mythread->sys_last_error = 0;
-}
-
-mythread_t * mythread_destroy(mythread_t *mythread, mythread_callback_before_join_f before_join, bool self_destroy)
-{
- if(mythread == NULL)
- return NULL;
-
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
-
- myhtml_thread_attr_destroy(mythread);
-
- if(mythread->pth_list) {
- mythread_resume_all(mythread);
- mythread_stream_quit_all(mythread);
- mythread_batch_quit_all(mythread);
-
- if(before_join)
- before_join(mythread);
-
- for (size_t i = mythread->pth_list_root; i < mythread->pth_list_length; i++)
- {
- myhtml_thread_join(mythread, &mythread->pth_list[i]);
- }
-
- myhtml_free(mythread->pth_list);
- mythread->pth_list = NULL;
- }
-
- if(mythread->sem_prefix) {
- myhtml_free(mythread->sem_prefix);
-
- mythread->sem_prefix = NULL;
- mythread->sem_prefix_length = 0;
- }
-
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
- if(self_destroy) {
- myhtml_free(mythread);
- return NULL;
- }
-
- return mythread;
-}
-
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
-
-mythread_id_t _myhread_create_stream_raw(mythread_t *mythread, mythread_work_f work_func, void *process_func, mythread_thread_opt_t opt, myhtml_status_t *status, size_t total_count)
-{
- mythread->sys_last_error = 0;
-
- if(status)
- *status = MyHTML_STATUS_OK;
-
- if(mythread->pth_list_length >= mythread->pth_list_size) {
- if(status)
- *status = MyHTML_STATUS_THREAD_ERROR_NO_SLOTS;
-
- return 0;
- }
-
- mythread_list_t *thr = &mythread->pth_list[mythread->pth_list_length];
-
- thr->data.mythread = mythread;
- thr->data.func = work_func;
- thr->data.id = mythread->pth_list_length;
- thr->data.t_count = total_count;
- thr->data.opt = opt;
- thr->data.status = 0;
-
- myhtml_status_t m_status = myhtml_hread_mutex_create(mythread, &thr->data, 0);
-
- if(m_status != MyHTML_STATUS_OK && status) {
- *status = m_status;
- return 0;
- }
-
- m_status = myhtml_thread_create(mythread, thr, process_func);
- if(m_status != MyHTML_STATUS_OK)
- return 0;
-
- mythread->pth_list_length++;
- return thr->data.id;
-}
-
-mythread_id_t myhread_create_stream(mythread_t *mythread, mythread_process_f process_func, mythread_work_f work_func, mythread_thread_opt_t opt, myhtml_status_t *status)
-{
- return _myhread_create_stream_raw(mythread, work_func, process_func, opt, status, 0);
-}
-
-mythread_id_t myhread_create_batch(mythread_t *mythread, mythread_process_f process_func, mythread_work_f work_func, mythread_thread_opt_t opt, myhtml_status_t *status, size_t count)
-{
- if(mythread->batch_count) {
- *status = MyHTML_STATUS_THREAD_ERROR_BATCH_INIT;
- return 0;
- }
- else if((mythread->pth_list_length + count) > mythread->pth_list_size) {
- if(status)
- *status = MyHTML_STATUS_THREAD_ERROR_NO_SLOTS;
-
- return 0;
- }
-
- if(count == 0)
- count = 1;
-
- mythread->batch_first_id = 0;
- mythread->batch_count = count;
-
- size_t start = mythread->pth_list_length;
- *status = MyHTML_STATUS_OK;
-
- bool init_first = false;
-
- for (size_t i = 0; i < count; i++)
- {
- mythread_id_t curr_id = _myhread_create_stream_raw(mythread, work_func, process_func, opt, status, i);
-
- if(init_first == false) {
- mythread->batch_first_id = curr_id;
- init_first = true;
- }
-
- if(*status)
- {
- for (size_t n = start; n < (start + i); n++)
- {
- mythread_list_t *thr = &mythread->pth_list[n];
-
- myhtml_thread_cancel(mythread, thr);
-
- myhtml_hread_mutex_post(mythread, &thr->data);
- myhtml_hread_mutex_close(mythread, &thr->data);
- }
-
- mythread->batch_first_id = 0;
- mythread->batch_count = 0;
-
- break;
- }
- }
-
- return mythread->batch_first_id;
-}
-
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
-// mythread queue functions
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
-mythread_queue_list_t * mythread_queue_list_create(myhtml_status_t *status)
-{
- if(status)
- *status = MyHTML_STATUS_OK;
-
- mythread_queue_list_t* queue_list = (mythread_queue_list_t*)myhtml_calloc(1, sizeof(mythread_queue_list_t));
-
- if(queue_list == NULL) {
- if(status)
- *status = MyHTML_STATUS_THREAD_ERROR_QUEUE_MALLOC;
- return NULL;
- }
-
- return queue_list;
-}
-
-void mythread_queue_list_destroy(mythread_queue_list_t* queue_list)
-{
- if(queue_list == NULL)
- return;
-
- myhtml_free(queue_list);
-}
-
-size_t mythread_queue_list_get_count(mythread_queue_list_t* queue_list)
-{
- return queue_list->count;
-}
-
-mythread_queue_list_entry_t * mythread_queue_list_entry_push(mythread_t *mythread, mythread_queue_t *queue, myhtml_status_t *status)
-{
- mythread_queue_list_t *queue_list = (mythread_queue_list_t*)mythread->context;
-
- if(status)
- *status = MyHTML_STATUS_OK;
-
- mythread_queue_list_entry_t* entry = (mythread_queue_list_entry_t*)myhtml_calloc(1, sizeof(mythread_queue_list_entry_t));
-
- if(entry == NULL) {
- if(status)
- *status = MyHTML_STATUS_THREAD_ERROR_QUEUE_MALLOC;
- return NULL;
- }
-
- entry->thread_param = (mythread_queue_thread_param_t*)myhtml_calloc(mythread->pth_list_size, sizeof(mythread_queue_thread_param_t));
-
- if(entry->thread_param == NULL) {
- myhtml_free(entry);
-
- if(status)
- *status = MyHTML_STATUS_THREAD_ERROR_QUEUE_MALLOC;
- return NULL;
- }
-
- size_t idx;
- for (idx = mythread->batch_first_id; idx < (mythread->batch_first_id + mythread->batch_count); idx++) {
- entry->thread_param[idx].use = mythread->pth_list[idx].data.t_count;
- }
-
- entry->queue = queue;
-
- if(mythread->stream_opt == MyTHREAD_OPT_UNDEF) {
- mythread_suspend_all(mythread);
- }
- else if(mythread->stream_opt == MyTHREAD_OPT_STOP) {
- mythread_stop_all(mythread);
- }
-
- if(queue_list->first) {
- queue_list->last->next = entry;
- entry->prev = queue_list->last;
-
- queue_list->last = entry;
- }
- else {
- queue_list->first = entry;
- queue_list->last = entry;
- }
-
- queue_list->count++;
-
- if(mythread->stream_opt != MyTHREAD_OPT_STOP)
- mythread_resume_all(mythread);
-
- return entry;
-}
-
-mythread_queue_list_entry_t * mythread_queue_list_entry_delete(mythread_t *mythread, mythread_queue_list_entry_t *entry, bool destroy_queue)
-{
- mythread_queue_list_t *queue_list = (mythread_queue_list_t*)mythread->context;
-
- mythread_queue_list_entry_t *next = entry->next;
- mythread_queue_list_entry_t *prev = entry->prev;
-
- if(mythread->stream_opt == MyTHREAD_OPT_UNDEF) {
- mythread_suspend_all(mythread);
- }
- else if(mythread->stream_opt == MyTHREAD_OPT_STOP) {
- mythread_stop_all(mythread);
- }
-
- if(prev)
- prev->next = next;
-
- if(next)
- next->prev = prev;
-
- if(queue_list->first == entry)
- queue_list->first = next;
-
- if(queue_list->last == entry)
- queue_list->last = prev;
-
- if(mythread->stream_opt != MyTHREAD_OPT_STOP)
- mythread_resume_all(mythread);
-
- if(destroy_queue && entry->queue)
- mythread_queue_destroy(entry->queue);
-
- if(entry->thread_param)
- myhtml_free(entry->thread_param);
-
- myhtml_free(entry);
-
- queue_list->count--;
-
- return NULL;
-}
-
-void mythread_queue_list_entry_clean(mythread_t *mythread, mythread_queue_list_entry_t *entry)
-{
- if(entry == NULL)
- return;
-
- mythread_queue_clean(entry->queue);
-
- size_t idx;
- for (idx = mythread->pth_list_root; idx < mythread->batch_first_id; idx++) {
- entry->thread_param[idx].use = 0;
- }
-
- for (idx = mythread->batch_first_id; idx < (mythread->batch_first_id + mythread->batch_count); idx++) {
- entry->thread_param[idx].use = mythread->pth_list[idx].data.t_count;
- }
-}
-
-void mythread_queue_list_entry_wait_for_done(mythread_t *mythread, mythread_queue_list_entry_t *entry)
-{
- if(entry == NULL)
- return;
-
- size_t idx;
- const struct timespec tomeout = {0, 0};
-
- for (idx = mythread->pth_list_root; idx < mythread->pth_list_size; idx++) {
- mythread_queue_thread_param_t *thread_param = &entry->thread_param[ idx ];
- while(thread_param->use < entry->queue->nodes_uses) {
- myhtml_thread_nanosleep(&tomeout);
- }
- }
-}
-
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
-mythread_queue_t * mythread_queue_create(size_t size, myhtml_status_t *status)
-{
- if(status)
- *status = MyHTML_STATUS_OK;
-
- if(size < 4096)
- size = 4096;
-
- mythread_queue_t* queue = (mythread_queue_t*)myhtml_malloc(sizeof(mythread_queue_t));
-
- if(queue == NULL) {
- if(status)
- *status = MyHTML_STATUS_THREAD_ERROR_QUEUE_MALLOC;
- return NULL;
- }
-
- queue->nodes_pos_size = 512;
- queue->nodes_size = size;
- queue->nodes = (mythread_queue_node_t**)myhtml_calloc(queue->nodes_pos_size, sizeof(mythread_queue_node_t*));
-
- if(queue->nodes == NULL) {
- myhtml_free(queue);
-
- if(status)
- *status = MyHTML_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC;
- return NULL;
- }
-
- mythread_queue_clean(queue);
-
- queue->nodes[queue->nodes_pos] = (mythread_queue_node_t*)myhtml_malloc(sizeof(mythread_queue_node_t) * queue->nodes_size);
-
- if(queue->nodes[queue->nodes_pos] == NULL) {
- myhtml_free(queue->nodes);
- myhtml_free(queue);
-
- if(status)
- *status = MyHTML_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC;
- return NULL;
- }
-
- return queue;
-}
-
-void mythread_queue_clean(mythread_queue_t* queue)
-{
- queue->nodes_length = 0;
- queue->nodes_pos = 0;
- queue->nodes_root = 0;
- queue->nodes_uses = 0;
-
- if(queue->nodes[queue->nodes_pos])
- mythread_queue_node_clean(&queue->nodes[queue->nodes_pos][queue->nodes_length]);
-}
-
-mythread_queue_t * mythread_queue_destroy(mythread_queue_t* queue)
-{
- if(queue == NULL)
- return NULL;
-
- if(queue->nodes) {
- for (size_t i = 0; i <= queue->nodes_pos; i++) {
- myhtml_free(queue->nodes[i]);
- }
-
- myhtml_free(queue->nodes);
- }
-
- myhtml_free(queue);
-
- return NULL;
-}
-
-void mythread_queue_node_clean(mythread_queue_node_t* qnode)
-{
- memset(qnode, 0, sizeof(mythread_queue_node_t));
-}
-
-mythread_queue_node_t * mythread_queue_get_prev_node(mythread_queue_node_t* qnode)
-{
- return qnode->prev;
-}
-
-mythread_queue_node_t * mythread_queue_get_current_node(mythread_queue_t* queue)
-{
- return &queue->nodes[queue->nodes_pos][queue->nodes_length];
-}
-
-mythread_queue_node_t * mythread_queue_get_first_node(mythread_queue_t* queue)
-{
- return &queue->nodes[0][0];
-}
-
-size_t mythread_queue_count_used_node(mythread_queue_t* queue)
-{
- return queue->nodes_uses;
-}
-
-mythread_queue_node_t * mythread_queue_node_malloc(mythread_t *mythread, mythread_queue_t* queue, myhtml_status_t *status)
-{
- queue->nodes_length++;
-
- if(queue->nodes_length >= queue->nodes_size)
- {
- queue->nodes_pos++;
-
- if(queue->nodes_pos >= queue->nodes_pos_size)
- {
- mythread_queue_wait_all_for_done(mythread);
-
- queue->nodes_pos_size <<= 1;
- mythread_queue_node_t** tmp = myhtml_realloc(queue->nodes, sizeof(mythread_queue_node_t*) * queue->nodes_pos_size);
-
- if(tmp) {
- memset(&tmp[queue->nodes_pos], 0, sizeof(mythread_queue_node_t*) * (queue->nodes_pos_size - queue->nodes_pos));
-
- queue->nodes = tmp;
- }
- else {
- if(status)
- *status = MyHTML_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC;
-
- return NULL;
- }
- }
-
- if(queue->nodes[queue->nodes_pos] == NULL) {
- queue->nodes[queue->nodes_pos] = (mythread_queue_node_t*)myhtml_malloc(sizeof(mythread_queue_node_t) * queue->nodes_size);
-
- if(queue->nodes[queue->nodes_pos] == NULL) {
- if(status)
- *status = MyHTML_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC;
-
- return NULL;
- }
- }
-
- queue->nodes_length = 0;
- }
-
- queue->nodes_uses++;
-
- return &queue->nodes[queue->nodes_pos][queue->nodes_length];
-}
-
-mythread_queue_node_t * mythread_queue_node_malloc_limit(mythread_t *mythread, mythread_queue_t* queue, size_t limit, myhtml_status_t *status)
-{
- queue->nodes_length++;
-
- if(queue->nodes_uses >= limit) {
- queue->nodes_uses++;
- mythread_queue_wait_all_for_done(mythread);
-
- queue->nodes_length = 0;
- queue->nodes_pos = 0;
- queue->nodes_root = 0;
- queue->nodes_uses = 0;
- }
- else if(queue->nodes_length >= queue->nodes_size)
- {
- queue->nodes_pos++;
-
- if(queue->nodes_pos >= queue->nodes_pos_size)
- {
- mythread_queue_wait_all_for_done(mythread);
-
- queue->nodes_pos_size <<= 1;
- mythread_queue_node_t** tmp = myhtml_realloc(queue->nodes, sizeof(mythread_queue_node_t*) * queue->nodes_pos_size);
-
- if(tmp) {
- memset(&tmp[queue->nodes_pos], 0, sizeof(mythread_queue_node_t*) * (queue->nodes_pos_size - queue->nodes_pos));
-
- queue->nodes = tmp;
- }
- else {
- if(status)
- *status = MyHTML_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC;
-
- return NULL;
- }
- }
-
- if(queue->nodes[queue->nodes_pos] == NULL) {
- queue->nodes[queue->nodes_pos] = (mythread_queue_node_t*)myhtml_malloc(sizeof(mythread_queue_node_t) * queue->nodes_size);
-
- if(queue->nodes[queue->nodes_pos] == NULL) {
- if(status)
- *status = MyHTML_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC;
-
- return NULL;
- }
- }
-
- queue->nodes_length = 0;
- }
-
- queue->nodes_uses++;
-
- return &queue->nodes[queue->nodes_pos][queue->nodes_length];
-}
-
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
-
-mythread_queue_node_t * mythread_queue_node_malloc_round(mythread_t *mythread, mythread_queue_list_entry_t *entry, myhtml_status_t *status)
-{
- mythread_queue_t* queue = entry->queue;
-
- queue->nodes_length++;
-
- if(queue->nodes_length >= queue->nodes_size) {
- queue->nodes_uses++;
-
- mythread_queue_list_entry_wait_for_done(mythread, entry);
- mythread_queue_list_entry_clean(mythread, entry);
- }
- else
- queue->nodes_uses++;
-
- return &queue->nodes[queue->nodes_pos][queue->nodes_length];
-}
-
-void mythread_queue_wait_all_for_done(mythread_t *mythread)
-{
- const struct timespec tomeout = {0, 0};
-
- mythread_queue_list_t *queue_list = (mythread_queue_list_t*)mythread->context;
- mythread_queue_list_entry_t *entry = queue_list->first;
-
- while(entry)
- {
- for (size_t idx = mythread->pth_list_root; idx < mythread->pth_list_size; idx++) {
- while(entry->thread_param[idx].use < entry->queue->nodes_uses) {
- myhtml_thread_nanosleep(&tomeout);
- }
- }
-
- entry = entry->next;
- }
-}
-
-#else
-
-void mythread_queue_wait_all_for_done(mythread_t *mythread) {}
-
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
-#ifdef MyHTML_BUILD_WITHOUT_THREADS
-
-void mythread_stream_quit_all(mythread_t *mythread) {}
-void mythread_batch_quit_all(mythread_t *mythread) {}
-void mythread_stream_stop_all(mythread_t *mythread) {}
-void mythread_batch_stop_all(mythread_t *mythread) {}
-void mythread_stop_all(mythread_t *mythread) {}
-void mythread_resume_all(mythread_t *mythread) {}
-void mythread_suspend_all(mythread_t *mythread) {}
-
-#else /* MyHTML_BUILD_WITHOUT_THREADS */
-
-// mythread functions
-void mythread_stream_quit_all(mythread_t *mythread)
-{
- mythread->stream_opt = MyTHREAD_OPT_QUIT;
-}
-
-void mythread_batch_quit_all(mythread_t *mythread)
-{
- mythread->batch_opt = MyTHREAD_OPT_QUIT;
-}
-
-void mythread_stream_stop_all(mythread_t *mythread)
-{
- if(mythread->stream_opt != MyTHREAD_OPT_STOP)
- mythread->stream_opt = MyTHREAD_OPT_STOP;
-
- size_t idx;
- const struct timespec tomeout = {0, 0};
-
- for (idx = mythread->pth_list_root; idx < mythread->batch_first_id; idx++) {
- while(mythread->pth_list[idx].data.opt != MyTHREAD_OPT_STOP) {
- myhtml_thread_nanosleep(&tomeout);
- }
- }
-}
-
-void mythread_batch_stop_all(mythread_t *mythread)
-{
- if(mythread->batch_opt != MyTHREAD_OPT_STOP)
- mythread->batch_opt = MyTHREAD_OPT_STOP;
-
- size_t idx;
- const struct timespec tomeout = {0, 0};
-
- for (idx = mythread->batch_first_id; idx < (mythread->batch_first_id + mythread->batch_count); idx++) {
- while(mythread->pth_list[idx].data.opt != MyTHREAD_OPT_STOP) {
- myhtml_thread_nanosleep(&tomeout);
- }
- }
-}
-
-void mythread_stop_all(mythread_t *mythread)
-{
- mythread_stream_stop_all(mythread);
- mythread_batch_stop_all(mythread);
-}
-
-void mythread_resume_all(mythread_t *mythread)
-{
- if(mythread->stream_opt == MyTHREAD_OPT_UNDEF &&
- mythread->batch_opt == MyTHREAD_OPT_UNDEF)
- return;
-
- if(mythread->stream_opt == MyTHREAD_OPT_WAIT ||
- mythread->batch_opt == MyTHREAD_OPT_WAIT)
- {
- mythread->stream_opt = MyTHREAD_OPT_UNDEF;
- mythread->batch_opt = MyTHREAD_OPT_UNDEF;
- }
- else {
- mythread->stream_opt = MyTHREAD_OPT_UNDEF;
- mythread->batch_opt = MyTHREAD_OPT_UNDEF;
-
- for (size_t idx = mythread->pth_list_root; idx < mythread->pth_list_size; idx++) {
- myhtml_hread_mutex_post(mythread, &mythread->pth_list[idx].data);
- }
- }
-}
-
-void mythread_suspend_all(mythread_t *mythread)
-{
- if(mythread->stream_opt != MyTHREAD_OPT_WAIT)
- mythread->stream_opt = MyTHREAD_OPT_WAIT;
-
- if(mythread->batch_opt != MyTHREAD_OPT_WAIT)
- mythread->batch_opt = MyTHREAD_OPT_WAIT;
-
- const struct timespec tomeout = {0, 0};
-
- for (size_t idx = mythread->pth_list_root; idx < mythread->pth_list_size; idx++) {
- myhtml_hread_mutex_try_wait(mythread, &mythread->pth_list[idx].data);
-
- while(mythread->pth_list[idx].data.opt != MyTHREAD_OPT_WAIT) {
- myhtml_thread_nanosleep(&tomeout);
- }
- }
-}
-
-unsigned int mythread_check_status(mythread_t *mythread)
-{
- for (size_t idx = mythread->pth_list_root; idx < mythread->pth_list_size; idx++) {
- if(mythread->pth_list[idx].data.status) {
- return mythread->pth_list[idx].data.status;
- }
- }
-
- return MyHTML_STATUS_OK;
-}
-
-bool mythread_function_see_for_all_done(mythread_queue_list_t *queue_list, size_t thread_id)
-{
- size_t done_count = 0;
-
- mythread_queue_list_entry_t *entry = queue_list->first;
- while(entry)
- {
- if(entry->thread_param[ thread_id ].use >= entry->queue->nodes_uses) {
- done_count++;
- entry = entry->next;
- }
- else
- break;
- }
-
- return done_count == queue_list->count;
-}
-
-bool mythread_function_see_opt(mythread_context_t *ctx, volatile mythread_thread_opt_t opt, size_t done_count, const struct timespec *timeout)
-{
- mythread_t * mythread = ctx->mythread;
- mythread_queue_list_t *queue_list = (mythread_queue_list_t*)mythread->context;
-
- if(done_count != queue_list->count)
- return false;
-
- if(opt & MyTHREAD_OPT_STOP)
- {
- if(mythread_function_see_for_all_done(queue_list, ctx->id))
- {
- ctx->opt = MyTHREAD_OPT_STOP;
- myhtml_hread_mutex_wait(mythread, ctx);
- ctx->opt = MyTHREAD_OPT_UNDEF;
-
- return false;
- }
- }
- else if(opt & MyTHREAD_OPT_QUIT)
- {
- if(mythread_function_see_for_all_done(queue_list, ctx->id))
- {
- myhtml_hread_mutex_close(mythread, ctx);
- ctx->opt = MyTHREAD_OPT_QUIT;
- return true;
- }
- }
-
- myhtml_thread_nanosleep(timeout);
-
- return false;
-}
-
-void mythread_function_queue_batch(void *arg)
-{
- mythread_context_t *ctx = (mythread_context_t*)arg;
- mythread_t * mythread = ctx->mythread;
- mythread_queue_list_t *queue_list = (mythread_queue_list_t*)mythread->context;
-
- const struct timespec timeout = {0, 0};
- myhtml_hread_mutex_wait(mythread, ctx);
-
- do {
- if(mythread->batch_opt & MyTHREAD_OPT_WAIT) {
- ctx->opt = MyTHREAD_OPT_WAIT;
-
- while (mythread->batch_opt & MyTHREAD_OPT_WAIT) {
- myhtml_thread_nanosleep(&timeout);
- }
-
- ctx->opt = MyTHREAD_OPT_UNDEF;
- }
-
- mythread_queue_list_entry_t *entry = queue_list->first;
- size_t done_count = 0;
-
- while(entry)
- {
- mythread_queue_thread_param_t *thread_param = &entry->thread_param[ ctx->id ];
-
- if(thread_param->use < entry->queue->nodes_uses)
- {
- size_t pos = thread_param->use / entry->queue->nodes_size;
- size_t len = thread_param->use % entry->queue->nodes_size;
-
- mythread_queue_node_t *qnode = &entry->queue->nodes[pos][len];
-
- if((qnode->tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0)
- ctx->func(ctx->id, (void*)qnode);
-
- thread_param->use += mythread->batch_count;
- }
- else
- done_count++;
-
- entry = entry->next;
- }
-
- if(done_count == queue_list->count &&
- mythread_function_see_opt(ctx, mythread->batch_opt, done_count, &timeout))
- break;
- }
- while (1);
-}
-
-void mythread_function_queue_stream(void *arg)
-{
- mythread_context_t *ctx = (mythread_context_t*)arg;
- mythread_t * mythread = ctx->mythread;
- mythread_queue_list_t *queue_list = (mythread_queue_list_t*)mythread->context;
-
- const struct timespec timeout = {0, 0};
- myhtml_hread_mutex_wait(mythread, ctx);
-
- do {
- if(mythread->stream_opt & MyTHREAD_OPT_WAIT) {
- ctx->opt = MyTHREAD_OPT_WAIT;
-
- while (mythread->stream_opt & MyTHREAD_OPT_WAIT) {
- myhtml_thread_nanosleep(&timeout);
- }
-
- ctx->opt = MyTHREAD_OPT_UNDEF;
- }
-
- mythread_queue_list_entry_t *entry = queue_list->first;
- size_t done_count = 0;
-
- while(entry)
- {
- mythread_queue_thread_param_t *thread_param = &entry->thread_param[ ctx->id ];
-
- if(thread_param->use < entry->queue->nodes_uses)
- {
- size_t pos = thread_param->use / entry->queue->nodes_size;
- size_t len = thread_param->use % entry->queue->nodes_size;
-
- mythread_queue_node_t *qnode = &entry->queue->nodes[pos][len];
-
- if((qnode->tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0)
- ctx->func(ctx->id, (void*)qnode);
-
- thread_param->use++;
- }
- else
- done_count++;
-
- entry = entry->next;
- }
-
- if(done_count == queue_list->count &&
- mythread_function_see_opt(ctx, mythread->stream_opt, done_count, &timeout))
- break;
- }
- while (1);
-}
-
-void mythread_function(void *arg)
-{
- mythread_context_t *ctx = (mythread_context_t*)arg;
- mythread_t * mythread = ctx->mythread;
-
- myhtml_hread_mutex_wait(mythread, ctx);
-
- do {
- if(mythread->stream_opt & MyTHREAD_OPT_STOP || ctx->opt & MyTHREAD_OPT_STOP)
- {
- ctx->opt |= MyTHREAD_OPT_DONE;
- myhtml_hread_mutex_wait(mythread, ctx);
-
- if(mythread->stream_opt & MyTHREAD_OPT_QUIT || ctx->opt & MyTHREAD_OPT_QUIT)
- {
- myhtml_hread_mutex_close(mythread, ctx);
- ctx->opt = MyTHREAD_OPT_QUIT;
- break;
- }
-
- ctx->opt = MyTHREAD_OPT_UNDEF;
- }
- else if(mythread->stream_opt & MyTHREAD_OPT_QUIT || ctx->opt & MyTHREAD_OPT_QUIT)
- {
- myhtml_hread_mutex_close(mythread, ctx);
- ctx->opt = MyTHREAD_OPT_QUIT;
- break;
- }
-
- ctx->func(ctx->id, ctx);
- }
- while (1);
-}
-
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
-
diff --git a/source/myhtml/thread.h b/source/myhtml/thread.h
deleted file mode 100644
index 208f6df..0000000
--- a/source/myhtml/thread.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- Copyright (C) 2015-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 MyHTML_THREAD_H
-#define MyHTML_THREAD_H
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "myhtml/myosi.h"
-
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
-
-#if !defined(IS_OS_WINDOWS)
-# include <pthread.h>
-# include <semaphore.h>
-#endif
-
-#include <time.h>
-#include <sys/stat.h>
-
-#include <fcntl.h>
-#include <errno.h>
-
-#include "myhtml/myhtml.h"
-#include "myhtml/tree.h"
-#include "myhtml/mystring.h"
-
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
-#define MyTHREAD_SEM_NAME "myhtml"
-
-/* functions */
-typedef void (*mythread_callback_before_join_f)(mythread_t* mythread);
-typedef void (*mythread_process_f)(void* arg);
-typedef void (*mythread_work_f)(mythread_id_t thread_id, void* arg);
-
-#ifdef MyHTML_BUILD_WITHOUT_THREADS
-
-struct mythread {
- int sys_last_error;
-};
-
-#else /* MyHTML_BUILD_WITHOUT_THREADS */
-
-void mythread_function_queue_stream(void *arg);
-void mythread_function_queue_batch(void *arg);
-void mythread_function(void *arg);
-
-// thread
-struct mythread_context {
- mythread_id_t id;
-
-#if defined(IS_OS_WINDOWS)
- HANDLE mutex;
-#else
- pthread_mutex_t *mutex;
-#endif
-
- size_t sem_name_size;
-
- mythread_work_f func;
-
- volatile size_t t_count;
- volatile mythread_thread_opt_t opt;
-
- mythread_t *mythread;
- unsigned int status;
-};
-
-struct mythread_list {
-#if defined(IS_OS_WINDOWS)
- HANDLE pth;
-#else
- pthread_t pth;
-#endif
- mythread_context_t data;
- mythread_process_f process_func;
-};
-
-struct mythread_workers_list {
- mythread_list_t *list;
- size_t count;
-};
-
-struct mythread {
- mythread_list_t *pth_list;
- size_t pth_list_length;
- size_t pth_list_size;
- size_t pth_list_root;
-
- void *context;
-
- char *sem_prefix;
- size_t sem_prefix_length;
-
-#if !defined(IS_OS_WINDOWS)
- pthread_attr_t *attr;
-#endif
-
- int sys_last_error;
-
- mythread_id_t batch_first_id;
- mythread_id_t batch_count;
-
- volatile mythread_thread_opt_t stream_opt;
- volatile mythread_thread_opt_t batch_opt;
-};
-
-mythread_id_t myhread_create_stream(mythread_t *mythread, mythread_process_f process_func, mythread_work_f func, mythread_thread_opt_t opt, myhtml_status_t *status);
-mythread_id_t myhread_create_batch(mythread_t *mythread, mythread_process_f process_func, mythread_work_f func, mythread_thread_opt_t opt, myhtml_status_t *status, size_t count);
-
-void myhtml_thread_nanosleep(const struct timespec *tomeout);
-
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
-mythread_t * mythread_create(void);
-myhtml_status_t mythread_init(mythread_t *mythread, const char *sem_prefix, size_t thread_count);
-void mythread_clean(mythread_t *mythread);
-mythread_t * mythread_destroy(mythread_t *mythread, mythread_callback_before_join_f before_join, bool self_destroy);
-
-void mythread_stream_quit_all(mythread_t *mythread);
-void mythread_batch_quit_all(mythread_t *mythread);
-
-void mythread_stream_stop_all(mythread_t *mythread);
-void mythread_batch_stop_all(mythread_t *mythread);
-
-void mythread_stop_all(mythread_t *mythread);
-void mythread_queue_wait_all_for_done(mythread_t *mythread);
-void mythread_resume_all(mythread_t *mythread);
-void mythread_suspend_all(mythread_t *mythread);
-unsigned int mythread_check_status(mythread_t *mythread);
-
-// queue
-struct mythread_queue_node {
- mythread_queue_node_t *prev;
- myhtml_token_node_t *token;
- myhtml_tree_t *tree;
-};
-
-struct mythread_queue_thread_param {
- volatile size_t use;
-};
-
-struct mythread_queue_list_entry {
- mythread_queue_list_entry_t *next;
- mythread_queue_list_entry_t *prev;
- mythread_queue_t *queue;
- mythread_queue_thread_param_t *thread_param;
-};
-
-struct mythread_queue_list {
- mythread_queue_list_entry_t *first;
- mythread_queue_list_entry_t *last;
-
- volatile size_t count;
-};
-
-struct mythread_queue {
- mythread_queue_node_t **nodes;
-
- size_t nodes_pos;
- size_t nodes_pos_size;
- size_t nodes_length;
-
- volatile size_t nodes_uses;
- volatile size_t nodes_size;
- volatile size_t nodes_root;
-};
-
-mythread_queue_t * mythread_queue_create(size_t size, myhtml_status_t *status);
-void mythread_queue_clean(mythread_queue_t* queue);
-mythread_queue_t * mythread_queue_destroy(mythread_queue_t* token);
-
-void mythread_queue_node_clean(mythread_queue_node_t* qnode);
-
-size_t mythread_queue_count_used_node(mythread_queue_t* queue);
-mythread_queue_node_t * mythread_queue_get_first_node(mythread_queue_t* queue);
-mythread_queue_node_t * mythread_queue_get_prev_node(mythread_queue_node_t* qnode);
-mythread_queue_node_t * mythread_queue_get_current_node(mythread_queue_t* queue);
-mythread_queue_node_t * mythread_queue_node_malloc(mythread_t *mythread, mythread_queue_t* queue, myhtml_status_t *status);
-mythread_queue_node_t * mythread_queue_node_malloc_limit(mythread_t *mythread, mythread_queue_t* queue, size_t limit, myhtml_status_t *status);
-
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
-
-mythread_queue_list_t * mythread_queue_list_create(myhtml_status_t *status);
-void mythread_queue_list_destroy(mythread_queue_list_t* queue_list);
-
-size_t mythread_queue_list_get_count(mythread_queue_list_t* queue_list);
-
-mythread_queue_list_entry_t * mythread_queue_list_entry_push(mythread_t *mythread, mythread_queue_t *queue, myhtml_status_t *status);
-mythread_queue_list_entry_t * mythread_queue_list_entry_delete(mythread_t *mythread, mythread_queue_list_entry_t *entry, bool destroy_queue);
-void mythread_queue_list_entry_clean(mythread_t *mythread, mythread_queue_list_entry_t *entry);
-void mythread_queue_list_entry_wait_for_done(mythread_t *mythread, mythread_queue_list_entry_t *entry);
-
-mythread_queue_node_t * mythread_queue_node_malloc_round(mythread_t *mythread, mythread_queue_list_entry_t *entry, myhtml_status_t *status);
-
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* defined(__myhtml__myhtml_thread__) */
-
diff --git a/source/myhtml/token.c b/source/myhtml/token.c
index 1536764..0828dfc 100644
--- a/source/myhtml/token.c
+++ b/source/myhtml/token.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -102,7 +102,7 @@ myhtml_token_t * myhtml_token_create(myhtml_tree_t* tree, size_t size)
if(size == 0)
size = 4096;
- myhtml_token_t* token = (myhtml_token_t*)myhtml_malloc(sizeof(myhtml_token_t));
+ myhtml_token_t* token = (myhtml_token_t*)mycore_malloc(sizeof(myhtml_token_t));
if(token == NULL)
return NULL;
@@ -110,15 +110,15 @@ myhtml_token_t * myhtml_token_create(myhtml_tree_t* tree, size_t size)
token->nodes_obj = mcobject_async_create();
if(token->nodes_obj == NULL) {
- free(token);
+ mycore_free(token);
return NULL;
}
token->attr_obj = mcobject_async_create();
if(token->attr_obj == NULL) {
- free(token->nodes_obj);
- free(token);
+ mycore_free(token->nodes_obj);
+ mycore_free(token);
return NULL;
}
@@ -157,7 +157,7 @@ myhtml_token_t * myhtml_token_destroy(myhtml_token_t* token)
if(token->attr_obj)
token->attr_obj = mcobject_async_destroy(token->attr_obj, 1);
- myhtml_free(token);
+ mycore_free(token);
return NULL;
}
@@ -177,7 +177,7 @@ void myhtml_token_node_clean(myhtml_token_node_t* node)
memset(node, 0, sizeof(myhtml_token_node_t));
node->type = MyHTML_TOKEN_TYPE_OPEN|MyHTML_TOKEN_TYPE_WHITESPACE;
- myhtml_string_clean_all(&node->str);
+ mycore_string_clean_all(&node->str);
}
myhtml_token_attr_t * myhtml_token_attr_create(myhtml_token_t* token, size_t async_node_id)
@@ -195,8 +195,8 @@ void myhtml_token_attr_clean(myhtml_token_attr_t* attr)
memset(attr, 0, sizeof(myhtml_token_attr_t));
attr->ns = MyHTML_NAMESPACE_HTML;
- myhtml_string_clean_all(&attr->key);
- myhtml_string_clean_all(&attr->value);
+ mycore_string_clean_all(&attr->key);
+ mycore_string_clean_all(&attr->value);
}
myhtml_tag_id_t myhtml_token_node_tag_id(myhtml_token_node_t *token_node)
@@ -238,7 +238,7 @@ const char * myhtml_token_node_text(myhtml_token_node_t *token_node, size_t *len
return token_node->str.data;
}
-myhtml_string_t * myhtml_token_node_string(myhtml_token_node_t *token_node)
+mycore_string_t * myhtml_token_node_string(myhtml_token_node_t *token_node)
{
return &token_node->str;
}
@@ -253,16 +253,18 @@ bool myhtml_token_node_is_close_self(myhtml_token_node_t *token_node)
return (token_node->type & MyHTML_TOKEN_TYPE_CLOSE_SELF);
}
-void myhtml_token_node_wait_for_done(myhtml_token_node_t* node)
+void myhtml_token_node_wait_for_done(myhtml_token_t* token, myhtml_token_node_t* node)
{
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
-
- const struct timespec timeout = {0, 0};
- while((node->type & MyHTML_TOKEN_TYPE_DONE) == 0) {myhtml_thread_nanosleep(&timeout);}
-
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ while((node->type & MyHTML_TOKEN_TYPE_DONE) == 0) {mythread_nanosleep_sleep(token->tree->myhtml->thread_stream->timespec);}
#endif
}
+void myhtml_token_set_done(myhtml_token_node_t* node)
+{
+ node->type |= MyHTML_TOKEN_TYPE_DONE;
+}
+
myhtml_token_node_t * myhtml_token_node_clone(myhtml_token_t* token, myhtml_token_node_t* node, size_t token_thread_idx, size_t attr_thread_idx)
{
if(node == NULL)
@@ -283,7 +285,7 @@ myhtml_token_node_t * myhtml_token_node_clone(myhtml_token_t* token, myhtml_toke
new_node->element_begin = node->element_begin;
new_node->element_length = node->element_length;
- myhtml_string_init(tree->mchar, tree->mchar_node_id, &new_node->str, node->str.size);
+ mycore_string_init(tree->mchar, tree->mchar_node_id, &new_node->str, node->str.size);
myhtml_token_node_attr_copy(token, node, new_node, attr_thread_idx);
return new_node;
@@ -291,10 +293,10 @@ myhtml_token_node_t * myhtml_token_node_clone(myhtml_token_t* token, myhtml_toke
void myhtml_token_node_text_append(myhtml_token_t* token, myhtml_token_node_t* dest, const char* text, size_t text_len)
{
- myhtml_string_init(token->tree->mchar, token->tree->mchar_node_id, &dest->str, (text_len + 2));
+ mycore_string_init(token->tree->mchar, token->tree->mchar_node_id, &dest->str, (text_len + 2));
- myhtml_string_t* string = &dest->str;
- myhtml_string_append(string, text, text_len);
+ mycore_string_t* string = &dest->str;
+ mycore_string_append(string, text, text_len);
}
myhtml_token_attr_t * myhtml_token_node_attr_append(myhtml_token_t* token, myhtml_token_node_t* dest,
@@ -305,18 +307,18 @@ myhtml_token_attr_t * myhtml_token_node_attr_append(myhtml_token_t* token, myhtm
new_attr->next = 0;
if(key_len) {
- myhtml_string_init(token->tree->mchar, token->tree->mchar_node_id, &new_attr->key, (key_len + 1));
- myhtml_string_append_lowercase(&new_attr->key, key, key_len);
+ mycore_string_init(token->tree->mchar, token->tree->mchar_node_id, &new_attr->key, (key_len + 1));
+ mycore_string_append_lowercase(&new_attr->key, key, key_len);
}
else
- myhtml_string_clean_all(&new_attr->key);
+ mycore_string_clean_all(&new_attr->key);
if(value_len) {
- myhtml_string_init(token->tree->mchar, token->tree->mchar_node_id, &new_attr->value, (value_len + 1));
- myhtml_string_append(&new_attr->value, value, value_len);
+ mycore_string_init(token->tree->mchar, token->tree->mchar_node_id, &new_attr->value, (value_len + 1));
+ mycore_string_append(&new_attr->value, value, value_len);
}
else
- myhtml_string_clean_all(&new_attr->value);
+ mycore_string_clean_all(&new_attr->value);
if(dest->attr_first == NULL) {
new_attr->prev = 0;
@@ -339,32 +341,32 @@ myhtml_token_attr_t * myhtml_token_node_attr_append(myhtml_token_t* token, myhtm
myhtml_token_attr_t * myhtml_token_node_attr_append_with_convert_encoding(myhtml_token_t* token, myhtml_token_node_t* dest,
const char* key, size_t key_len,
const char* value, size_t value_len,
- size_t thread_idx, myhtml_encoding_t encoding)
+ size_t thread_idx, myencoding_t encoding)
{
myhtml_token_attr_t* new_attr = mcobject_async_malloc(token->attr_obj, thread_idx, NULL);
new_attr->next = 0;
if(key_len) {
- myhtml_string_init(token->tree->mchar, token->tree->mchar_node_id, &new_attr->key, (key_len + 1));
+ mycore_string_init(token->tree->mchar, token->tree->mchar_node_id, &new_attr->key, (key_len + 1));
- if(encoding == MyHTML_ENCODING_UTF_8)
- myhtml_string_append_lowercase(&new_attr->key, key, key_len);
+ if(encoding == MyENCODING_UTF_8)
+ mycore_string_append_lowercase(&new_attr->key, key, key_len);
else
- myhtml_string_append_lowercase_ascii_with_convert_encoding(&new_attr->key, key, key_len, encoding);
+ myencoding_string_append_lowercase_ascii(&new_attr->key, key, key_len, encoding);
}
else
- myhtml_string_clean_all(&new_attr->key);
+ mycore_string_clean_all(&new_attr->key);
if(value_len) {
- myhtml_string_init(token->tree->mchar, token->tree->mchar_node_id, &new_attr->value, (value_len + 1));
+ mycore_string_init(token->tree->mchar, token->tree->mchar_node_id, &new_attr->value, (value_len + 1));
- if(encoding == MyHTML_ENCODING_UTF_8)
- myhtml_string_append(&new_attr->value, value, value_len);
+ if(encoding == MyENCODING_UTF_8)
+ mycore_string_append(&new_attr->value, value, value_len);
else
- myhtml_string_append_with_convert_encoding(&new_attr->value, value, value_len, encoding);
+ myencoding_string_append(&new_attr->value, value, value_len, encoding);
}
else
- myhtml_string_clean_all(&new_attr->value);
+ mycore_string_clean_all(&new_attr->value);
if(dest->attr_first == NULL) {
new_attr->prev = 0;
@@ -415,18 +417,18 @@ bool myhtml_token_attr_copy(myhtml_token_t* token, myhtml_token_attr_t* attr, my
new_attr->next = 0;
if(attr->key.length) {
- myhtml_string_init(token->tree->mchar, token->tree->mchar_node_id, &new_attr->key, (attr->key.length + 1));
- myhtml_string_append_lowercase(&new_attr->key, attr->key.data, attr->key.length);
+ mycore_string_init(token->tree->mchar, token->tree->mchar_node_id, &new_attr->key, (attr->key.length + 1));
+ mycore_string_append_lowercase(&new_attr->key, attr->key.data, attr->key.length);
}
else
- myhtml_string_clean_all(&new_attr->key);
+ mycore_string_clean_all(&new_attr->key);
if(attr->value.length) {
- myhtml_string_init(token->tree->mchar, token->tree->mchar_node_id, &new_attr->value, (attr->value.length + 1));
- myhtml_string_append(&new_attr->value, attr->value.data, attr->value.length);
+ mycore_string_init(token->tree->mchar, token->tree->mchar_node_id, &new_attr->value, (attr->value.length + 1));
+ mycore_string_append(&new_attr->value, attr->value.data, attr->value.length);
}
else
- myhtml_string_clean_all(&new_attr->value);
+ mycore_string_clean_all(&new_attr->value);
if(dest->attr_first == NULL) {
new_attr->prev = 0;
@@ -455,8 +457,8 @@ myhtml_token_attr_t * myhtml_token_attr_match(myhtml_token_t* token, myhtml_toke
{
if(attr->key.length == key_size && attr->value.length == value_size)
{
- if((myhtml_strcmp(attr->key.data, key) == 0)) {
- if((myhtml_strcmp(attr->value.data, value) == 0))
+ if((mycore_strcmp(attr->key.data, key) == 0)) {
+ if((mycore_strcmp(attr->value.data, value) == 0))
return attr;
else
return NULL;
@@ -478,8 +480,8 @@ myhtml_token_attr_t * myhtml_token_attr_match_case(myhtml_token_t* token, myhtml
{
if(attr->key.length == key_size && attr->value.length == value_size)
{
- if((myhtml_strcmp(attr->key.data, key) == 0)) {
- if((myhtml_strcasecmp(attr->value.data, value) == 0))
+ if((mycore_strcmp(attr->key.data, key) == 0)) {
+ if((mycore_strcasecmp(attr->value.data, value) == 0))
return attr;
else
return NULL;
@@ -504,7 +506,7 @@ void myhtml_token_adjust_mathml_attributes(myhtml_token_node_t* target)
void _myhtml_token_create_copy_srt(myhtml_token_t* token, const char* from, size_t from_size, char** to)
{
*to = mchar_async_malloc(token->tree->mchar, token->tree->mchar_node_id, (from_size + 2));
- myhtml_string_raw_copy(*to, from, from_size);
+ mycore_string_raw_copy(*to, from, from_size);
}
void myhtml_token_strict_doctype_by_token(myhtml_token_t* token, myhtml_token_node_t* target, myhtml_tree_doctype_t* return_doctype)
@@ -514,7 +516,7 @@ void myhtml_token_strict_doctype_by_token(myhtml_token_t* token, myhtml_token_no
if(attr && attr->key.length) {
_myhtml_token_create_copy_srt(token, attr->key.data, attr->key.length, &return_doctype->attr_name);
- if(myhtml_strcmp("html", return_doctype->attr_name))
+ if(mycore_strcmp("html", return_doctype->attr_name))
return_doctype->is_html = false;
else
return_doctype->is_html = true;
@@ -525,11 +527,11 @@ void myhtml_token_strict_doctype_by_token(myhtml_token_t* token, myhtml_token_no
_myhtml_token_create_copy_srt(token, "\0", 1, &return_doctype->attr_name);
if(return_doctype->attr_public)
- myhtml_free(return_doctype->attr_public);
+ mycore_free(return_doctype->attr_public);
return_doctype->attr_public = NULL;
if(return_doctype->attr_system)
- myhtml_free(return_doctype->attr_system);
+ mycore_free(return_doctype->attr_system);
return_doctype->attr_system = NULL;
return;
@@ -539,7 +541,7 @@ void myhtml_token_strict_doctype_by_token(myhtml_token_t* token, myhtml_token_no
if(attr && attr->value.length)
{
- if(myhtml_strcasecmp(attr->value.data, "PUBLIC") == 0)
+ if(mycore_strcasecmp(attr->value.data, "PUBLIC") == 0)
{
// try see public
attr = attr->next;
@@ -554,22 +556,22 @@ void myhtml_token_strict_doctype_by_token(myhtml_token_t* token, myhtml_token_no
_myhtml_token_create_copy_srt(token, attr->value.data, attr->value.length, &return_doctype->attr_system);
else {
if(return_doctype->attr_system)
- myhtml_free(return_doctype->attr_system);
+ mycore_free(return_doctype->attr_system);
_myhtml_token_create_copy_srt(token, "\0", 1, &return_doctype->attr_system);
}
}
else {
if(return_doctype->attr_public)
- myhtml_free(return_doctype->attr_public);
+ mycore_free(return_doctype->attr_public);
return_doctype->attr_public = NULL;
if(return_doctype->attr_system)
- myhtml_free(return_doctype->attr_system);
+ mycore_free(return_doctype->attr_system);
return_doctype->attr_system = NULL;
}
}
- else if(myhtml_strncasecmp(attr->value.data, "SYSTEM", attr->value.length) == 0)
+ else if(mycore_strncasecmp(attr->value.data, "SYSTEM", attr->value.length) == 0)
{
attr = attr->next;
@@ -579,21 +581,21 @@ void myhtml_token_strict_doctype_by_token(myhtml_token_t* token, myhtml_token_no
}
else {
if(return_doctype->attr_public)
- myhtml_free(return_doctype->attr_public);
+ mycore_free(return_doctype->attr_public);
return_doctype->attr_public = NULL;
if(return_doctype->attr_system)
- myhtml_free(return_doctype->attr_system);
+ mycore_free(return_doctype->attr_system);
return_doctype->attr_system = NULL;
}
}
else {
if(return_doctype->attr_public)
- myhtml_free(return_doctype->attr_public);
+ mycore_free(return_doctype->attr_public);
return_doctype->attr_public = NULL;
if(return_doctype->attr_system)
- myhtml_free(return_doctype->attr_system);
+ mycore_free(return_doctype->attr_system);
return_doctype->attr_system = NULL;
}
}
@@ -601,14 +603,14 @@ void myhtml_token_strict_doctype_by_token(myhtml_token_t* token, myhtml_token_no
bool myhtml_token_doctype_check_html_4_0(myhtml_tree_doctype_t* return_doctype)
{
- return myhtml_strcmp(return_doctype->attr_public, "-//W3C//DTD HTML 4.0//EN") &&
- (return_doctype->attr_system == NULL || myhtml_strcmp(return_doctype->attr_system, "http://www.w3.org/TR/REC-html40/strict.dtd"));
+ return mycore_strcmp(return_doctype->attr_public, "-//W3C//DTD HTML 4.0//EN") &&
+ (return_doctype->attr_system == NULL || mycore_strcmp(return_doctype->attr_system, "http://www.w3.org/TR/REC-html40/strict.dtd"));
}
bool myhtml_token_doctype_check_html_4_01(myhtml_tree_doctype_t* return_doctype)
{
- return myhtml_strcmp(return_doctype->attr_public, "-//W3C//DTD HTML 4.01//EN") &&
- (return_doctype->attr_system == NULL || myhtml_strcmp(return_doctype->attr_system, "http://www.w3.org/TR/html4/strict.dtd"));
+ return mycore_strcmp(return_doctype->attr_public, "-//W3C//DTD HTML 4.01//EN") &&
+ (return_doctype->attr_system == NULL || mycore_strcmp(return_doctype->attr_system, "http://www.w3.org/TR/html4/strict.dtd"));
}
bool myhtml_token_doctype_check_xhtml_1_0(myhtml_tree_doctype_t* return_doctype)
@@ -616,8 +618,8 @@ bool myhtml_token_doctype_check_xhtml_1_0(myhtml_tree_doctype_t* return_doctype)
if(return_doctype->attr_system == NULL)
return true;
- return myhtml_strcmp(return_doctype->attr_public, "-//W3C//DTD XHTML 1.0 Strict//EN") &&
- myhtml_strcmp(return_doctype->attr_system, "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
+ return mycore_strcmp(return_doctype->attr_public, "-//W3C//DTD XHTML 1.0 Strict//EN") &&
+ mycore_strcmp(return_doctype->attr_system, "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
}
bool myhtml_token_doctype_check_xhtml_1_1(myhtml_tree_doctype_t* return_doctype)
@@ -625,8 +627,8 @@ bool myhtml_token_doctype_check_xhtml_1_1(myhtml_tree_doctype_t* return_doctype)
if(return_doctype->attr_system == NULL)
return true;
- return myhtml_strcmp(return_doctype->attr_public, "-//W3C//DTD XHTML 1.1//EN") &&
- myhtml_strcmp(return_doctype->attr_system, "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd");
+ return mycore_strcmp(return_doctype->attr_public, "-//W3C//DTD XHTML 1.1//EN") &&
+ mycore_strcmp(return_doctype->attr_system, "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd");
}
bool myhtml_token_release_and_check_doctype_attributes(myhtml_token_t* token, myhtml_token_node_t* target, myhtml_tree_doctype_t* return_doctype)
@@ -641,7 +643,7 @@ bool myhtml_token_release_and_check_doctype_attributes(myhtml_token_t* token, my
if((return_doctype->is_html ||
return_doctype->attr_public ||
- (return_doctype->attr_system && myhtml_strcmp(return_doctype->attr_system, "about:legacy-compat"))))
+ (return_doctype->attr_system && mycore_strcmp(return_doctype->attr_system, "about:legacy-compat"))))
{
if(return_doctype->attr_public == NULL)
return false;
@@ -669,8 +671,8 @@ void myhtml_token_adjust_svg_attributes(myhtml_token_node_t* target)
myhtml_token_attr_svg_replacement[i].from_size);
if(attr) {
- myhtml_string_clean(&attr->key);
- myhtml_string_append(&attr->key, myhtml_token_attr_svg_replacement[i].to,
+ mycore_string_clean(&attr->key);
+ mycore_string_append(&attr->key, myhtml_token_attr_svg_replacement[i].to,
myhtml_token_attr_svg_replacement[i].to_size);
}
}
@@ -686,8 +688,8 @@ void myhtml_token_adjust_foreign_attributes(myhtml_token_node_t* target)
myhtml_token_attr_namespace_replacement[i].from_size);
if(attr) {
- myhtml_string_clean(&attr->key);
- myhtml_string_append(&attr->key, myhtml_token_attr_namespace_replacement[i].to,
+ mycore_string_clean(&attr->key);
+ mycore_string_append(&attr->key, myhtml_token_attr_namespace_replacement[i].to,
myhtml_token_attr_namespace_replacement[i].to_size);
attr->ns = myhtml_token_attr_namespace_replacement[i].ns;
@@ -708,10 +710,10 @@ bool myhtml_token_attr_compare(myhtml_token_node_t* target, myhtml_token_node_t*
if(target_attr->key.length == dest_attr->key.length &&
target_attr->value.length == dest_attr->value.length)
{
- if(myhtml_strcmp(target_attr->key.data, dest_attr->key.data) != 0)
+ if(mycore_strcmp(target_attr->key.data, dest_attr->key.data) != 0)
break;
- if(myhtml_strcasecmp(target_attr->value.data, dest_attr->value.data) != 0)
+ if(mycore_strcasecmp(target_attr->value.data, dest_attr->value.data) != 0)
break;
}
else
@@ -734,7 +736,7 @@ myhtml_token_attr_t * myhtml_token_attr_by_name(myhtml_token_node_t* node, const
while (attr)
{
if(name_length == attr->key.length) {
- if(myhtml_strcmp(attr->key.data, name) == 0)
+ if(mycore_strcmp(attr->key.data, name) == 0)
break;
}
@@ -803,11 +805,11 @@ myhtml_token_attr_t * myhtml_token_attr_remove_by_name(myhtml_token_node_t* node
myhtml_token_node_t * myhtml_token_merged_two_token_string(myhtml_tree_t* tree, myhtml_token_node_t* token_to, myhtml_token_node_t* token_from, bool cp_reverse)
{
- myhtml_token_node_wait_for_done(token_to);
- myhtml_token_node_wait_for_done(token_from);
+ myhtml_token_node_wait_for_done(tree->token, token_to);
+ myhtml_token_node_wait_for_done(tree->token, token_from);
- myhtml_string_t *string1 = &token_to->str;
- myhtml_string_t *string2 = &token_from->str;
+ mycore_string_t *string1 = &token_to->str;
+ mycore_string_t *string2 = &token_from->str;
token_to->raw_begin = 0;
token_to->raw_length = 0;
@@ -815,10 +817,10 @@ myhtml_token_node_t * myhtml_token_merged_two_token_string(myhtml_tree_t* tree,
if(token_to->str.node_idx == tree->mchar_node_id)
{
if(cp_reverse) {
- //myhtml_string_copy(string2, &string_base);
+ //mycore_string_copy(string2, &string_base);
}
else {
- myhtml_string_copy(string1, string2);
+ mycore_string_copy(string1, string2);
}
return token_to;
@@ -826,25 +828,25 @@ myhtml_token_node_t * myhtml_token_merged_two_token_string(myhtml_tree_t* tree,
if(token_from->str.node_idx == tree->mchar_node_id)
{
if(cp_reverse) {
- myhtml_string_copy(string2, string1);
+ mycore_string_copy(string2, string1);
}
else {
- myhtml_string_copy(string1, string2);
+ mycore_string_copy(string1, string2);
}
return token_from;
}
else {
- myhtml_string_t string_base;
- myhtml_string_init(tree->mchar, tree->mchar_node_id, &string_base, (string1->length + string2->length + 2));
+ mycore_string_t string_base;
+ mycore_string_init(tree->mchar, tree->mchar_node_id, &string_base, (string1->length + string2->length + 2));
if(cp_reverse) {
- myhtml_string_copy(&string_base, string2);
- myhtml_string_copy(&string_base, string1);
+ mycore_string_copy(&string_base, string2);
+ mycore_string_copy(&string_base, string1);
}
else {
- myhtml_string_copy(&string_base, string1);
- myhtml_string_copy(&string_base, string2);
+ mycore_string_copy(&string_base, string1);
+ mycore_string_copy(&string_base, string2);
}
token_to->str = string_base;
@@ -855,117 +857,13 @@ myhtml_token_node_t * myhtml_token_merged_two_token_string(myhtml_tree_t* tree,
void myhtml_token_set_replacement_character_for_null_token(myhtml_tree_t* tree, myhtml_token_node_t* node)
{
- myhtml_token_node_wait_for_done(node);
+ myhtml_token_node_wait_for_done(tree->token, node);
- myhtml_string_t new_str;
- myhtml_string_init(tree->mchar, tree->mchar_node_id, &new_str, (node->str.length + 2));
+ mycore_string_t new_str;
+ mycore_string_init(tree->mchar, tree->mchar_node_id, &new_str, (node->str.length + 2));
- myhtml_string_append_with_replacement_null_characters_only(&new_str, node->str.data, node->str.length);
+ mycore_string_append_with_replacement_null_characters(&new_str, node->str.data, node->str.length);
node->str = new_str;
}
-void myhtml_token_set_done(myhtml_token_node_t* node)
-{
- node->type |= MyHTML_TOKEN_TYPE_DONE;
-}
-
-void myhtml_token_print_param_by_idx(myhtml_tree_t* myhtml_tree, myhtml_token_node_t* node, FILE* out)
-{
- if(node->type & MyHTML_TOKEN_TYPE_CLOSE) {
- fprintf(out, "</");
- }
- else {
- fprintf(out, "<");
- }
-
- fprintf(out, "tag_id=%zu; body_begin=%zu; body_length=%zu; attr_first=%zu; attr_last=%zu",
- node->tag_id, node->raw_begin, node->raw_length,
- (size_t)node->attr_first, (size_t)node->attr_last);
-
- if(node->type & MyHTML_TOKEN_TYPE_CLOSE_SELF) {
- fprintf(out, " />\n");
- }
- else {
- fprintf(out, ">\n");
- }
-}
-
-void myhtml_token_print_by_idx(myhtml_tree_t* tree, myhtml_token_node_t* node, FILE* out)
-{
- const myhtml_tag_context_t *ctx = myhtml_tag_get_by_id(tree->tags, node->tag_id);
-
- if(node->tag_id == MyHTML_TAG__TEXT ||
- node->tag_id == MyHTML_TAG__COMMENT)
- {
- if(node->str.length) {
- fprintf(out, "%.*s: %.*s\n", (int)ctx->name_length, ctx->name,
- (int)node->str.length, node->str.data);
- }
- else {
- fprintf(out, "%.*s is empty\n", (int)ctx->name_length, ctx->name);
- }
- }
- else
- {
- if(node->type & MyHTML_TOKEN_TYPE_CLOSE) {
- fprintf(out, "</");
- }
- else {
- fprintf(out, "<");
- }
-
- fprintf(out, "%.*s tagid=\"%zu\"", (int)ctx->name_length, ctx->name, node->tag_id);
-
- myhtml_token_print_attr(tree, node, out);
-
- if(node->type & MyHTML_TOKEN_TYPE_CLOSE_SELF) {
- fprintf(out, " />\n");
- }
- else {
- fprintf(out, ">\n");
- }
- }
-}
-
-void myhtml_token_print_attr(myhtml_tree_t* tree, myhtml_token_node_t* node, FILE* out)
-{
- myhtml_token_attr_t* attr = node->attr_first;
-
- while(attr)
- {
- fprintf(out, " %s", attr->key.data);
-
- if(attr->ns != MyHTML_NAMESPACE_HTML)
- {
- switch (attr->ns) {
- case MyHTML_NAMESPACE_SVG:
- fprintf(out, ":svg");
- break;
- case MyHTML_NAMESPACE_MATHML:
- fprintf(out, ":math");
- break;
- case MyHTML_NAMESPACE_XLINK:
- fprintf(out, ":xlink");
- break;
- case MyHTML_NAMESPACE_XML:
- fprintf(out, ":xml");
- break;
- case MyHTML_NAMESPACE_XMLNS:
- fprintf(out, ":xmlns");
- break;
- default:
- fprintf(out, ":UNDEF");
- break;
- }
- }
-
- if(attr->value.length) {
- fprintf(out, "=\"%s\"", attr->value.data);
- }
-
- attr = attr->next;
- }
-}
-
-
diff --git a/source/myhtml/token.h b/source/myhtml/token.h
index 0f3de04..3936f4a 100644
--- a/source/myhtml/token.h
+++ b/source/myhtml/token.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -29,13 +29,13 @@ extern "C" {
#include <string.h>
#include "myhtml/myosi.h"
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
#include "myhtml/tag.h"
#include "myhtml/myhtml.h"
#include "myhtml/mystring.h"
-#include "myhtml/utils/mcobject_async.h"
-#include "myhtml/utils/mchar_async.h"
-#include "myhtml/utils/mcsync.h"
+#include "mycore/utils/mcobject_async.h"
+#include "mycore/utils/mchar_async.h"
+#include "mycore/utils/mcsync.h"
#define myhtml_token_node_set_done(token_node) token_node->type |= MyHTML_TOKEN_TYPE_DONE
@@ -61,8 +61,8 @@ struct myhtml_token_attr {
myhtml_token_attr_t* next;
myhtml_token_attr_t* prev;
- myhtml_string_t key;
- myhtml_string_t value;
+ mycore_string_t key;
+ mycore_string_t value;
size_t raw_key_begin;
size_t raw_key_length;
@@ -75,7 +75,7 @@ struct myhtml_token_attr {
struct myhtml_token_node {
myhtml_tag_id_t tag_id;
- myhtml_string_t str;
+ mycore_string_t str;
size_t raw_begin;
size_t raw_length;
@@ -115,7 +115,7 @@ myhtml_tree_attr_t * myhtml_token_node_attribute_first(myhtml_token_node_t *toke
myhtml_tree_attr_t * myhtml_token_node_attribute_last(myhtml_token_node_t *token_node);
const char * myhtml_token_node_text(myhtml_token_node_t *token_node, size_t *length);
-myhtml_string_t * myhtml_token_node_string(myhtml_token_node_t *token_node);
+mycore_string_t * myhtml_token_node_string(myhtml_token_node_t *token_node);
bool myhtml_token_node_is_close(myhtml_token_node_t *token_node);
bool myhtml_token_node_is_close_self(myhtml_token_node_t *token_node);
@@ -130,7 +130,7 @@ myhtml_token_attr_t * myhtml_token_attr_remove_by_name(myhtml_token_node_t* node
void myhtml_token_attr_delete_all(myhtml_token_t* token, myhtml_token_node_t* node);
void myhtml_token_delete(myhtml_token_t* token, myhtml_token_node_t* node);
-void myhtml_token_node_wait_for_done(myhtml_token_node_t* node);
+void myhtml_token_node_wait_for_done(myhtml_token_t* token, myhtml_token_node_t* node);
void myhtml_token_set_done(myhtml_token_node_t* node);
myhtml_token_attr_t * myhtml_token_attr_match(myhtml_token_t* token, myhtml_token_node_t* target, const char* key, size_t key_size, const char* value, size_t value_size);
@@ -143,7 +143,7 @@ void myhtml_token_adjust_svg_attributes(myhtml_token_node_t* target);
void myhtml_token_adjust_foreign_attributes(myhtml_token_node_t* target);
myhtml_token_attr_t * myhtml_token_node_attr_append(myhtml_token_t* token, myhtml_token_node_t* dest, const char* key, size_t key_len, const char* value, size_t value_len, size_t thread_idx);
-myhtml_token_attr_t * myhtml_token_node_attr_append_with_convert_encoding(myhtml_token_t* token, myhtml_token_node_t* dest, const char* key, size_t key_len, const char* value, size_t value_len, size_t thread_idx, myhtml_encoding_t encoding);
+myhtml_token_attr_t * myhtml_token_node_attr_append_with_convert_encoding(myhtml_token_t* token, myhtml_token_node_t* dest, const char* key, size_t key_len, const char* value, size_t value_len, size_t thread_idx, myencoding_t encoding);
void myhtml_token_node_text_append(myhtml_token_t* token, myhtml_token_node_t* dest, const char* text, size_t text_len);
void myhtml_token_node_attr_copy(myhtml_token_t* token, myhtml_token_node_t* target, myhtml_token_node_t* dest, size_t thread_idx);
void myhtml_token_node_attr_copy_with_check(myhtml_token_t* token, myhtml_token_node_t* target, myhtml_token_node_t* dest, size_t thread_idx);
@@ -154,10 +154,6 @@ bool myhtml_token_attr_compare(myhtml_token_node_t* target, myhtml_token_node_t*
myhtml_token_node_t * myhtml_token_merged_two_token_string(myhtml_tree_t* tree, myhtml_token_node_t* token_to, myhtml_token_node_t* token_from, bool cp_reverse);
void myhtml_token_set_replacement_character_for_null_token(myhtml_tree_t* tree, myhtml_token_node_t* node);
-void myhtml_token_print_param_by_idx(myhtml_tree_t* myhtml_tree, myhtml_token_node_t* node, FILE* out);
-void myhtml_token_print_by_idx(myhtml_tree_t* myhtml_tree, myhtml_token_node_t* node, FILE* out);
-void myhtml_token_print_attr(myhtml_tree_t* myhtml_tree, myhtml_token_node_t* node, FILE* out);
-
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/source/myhtml/tokenizer.c b/source/myhtml/tokenizer.c
index 1740a71..1dca519 100644
--- a/source/myhtml/tokenizer.c
+++ b/source/myhtml/tokenizer.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -19,14 +19,14 @@
*/
#include "myhtml/tokenizer.h"
-#include "myhtml/utils/resources.h"
+#include "mycore/utils/resources.h"
-myhtml_status_t myhtml_tokenizer_set_first_settings(myhtml_tree_t* tree, const char* html, size_t html_length)
+mystatus_t myhtml_tokenizer_set_first_settings(myhtml_tree_t* tree, const char* html, size_t html_length)
{
tree->current_qnode = mythread_queue_get_current_node(tree->queue);
mythread_queue_node_clean(tree->current_qnode);
- tree->current_qnode->tree = tree;
+ tree->current_qnode->context = tree;
tree->current_token_node = myhtml_token_node_create(tree->token, tree->token->mcasync_token_id);
if(tree->current_token_node == NULL)
@@ -37,20 +37,20 @@ myhtml_status_t myhtml_tokenizer_set_first_settings(myhtml_tree_t* tree, const c
return MyHTML_STATUS_OK;
}
-myhtml_status_t myhtml_tokenizer_begin(myhtml_tree_t* tree, const char* html, size_t html_length)
+mystatus_t myhtml_tokenizer_begin(myhtml_tree_t* tree, const char* html, size_t html_length)
{
return myhtml_tokenizer_chunk(tree, html, html_length);
}
-myhtml_status_t myhtml_tokenizer_chunk_process(myhtml_tree_t* tree, const char* html, size_t html_length)
+mystatus_t myhtml_tokenizer_chunk_process(myhtml_tree_t* tree, const char* html, size_t html_length)
{
myhtml_t* myhtml = tree->myhtml;
myhtml_tokenizer_state_f* state_f = myhtml->parse_state_func;
// add for a chunk
- tree->incoming_buf = myhtml_incoming_buffer_add(tree->incoming_buf, tree->mcobject_incoming_buf, html, html_length);
+ tree->incoming_buf = mycore_incoming_buffer_add(tree->incoming_buf, tree->mcobject_incoming_buf, html, html_length);
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
if(myhtml->opt & MyHTML_OPTIONS_PARSE_MODE_SINGLE)
tree->flags |= MyHTML_TREE_FLAGS_SINGLE_MODE;
@@ -58,8 +58,10 @@ myhtml_status_t myhtml_tokenizer_chunk_process(myhtml_tree_t* tree, const char*
if((tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0)
{
if(tree->queue_entry == NULL) {
- myhtml_status_t status = MyHTML_STATUS_OK;
- tree->queue_entry = mythread_queue_list_entry_push(myhtml->thread, tree->queue, &status);
+ mystatus_t status = MyHTML_STATUS_OK;
+ tree->queue_entry = mythread_queue_list_entry_push(myhtml->thread_list, 2,
+ myhtml->thread_stream->context, tree->queue,
+ myhtml->thread_total, &status);
if(status)
return status;
@@ -89,10 +91,10 @@ myhtml_status_t myhtml_tokenizer_chunk_process(myhtml_tree_t* tree, const char*
return MyHTML_STATUS_OK;
}
-myhtml_status_t myhtml_tokenizer_chunk(myhtml_tree_t* tree, const char* html, size_t html_length)
+mystatus_t myhtml_tokenizer_chunk(myhtml_tree_t* tree, const char* html, size_t html_length)
{
- if(tree->encoding_usereq == MyHTML_ENCODING_UTF_16LE ||
- tree->encoding_usereq == MyHTML_ENCODING_UTF_16BE)
+ if(tree->encoding_usereq == MyENCODING_UTF_16LE ||
+ tree->encoding_usereq == MyENCODING_UTF_16BE)
{
return myhtml_tokenizer_chunk_with_stream_buffer(tree, html, html_length);
}
@@ -100,10 +102,10 @@ myhtml_status_t myhtml_tokenizer_chunk(myhtml_tree_t* tree, const char* html, si
return myhtml_tokenizer_chunk_process(tree, html, html_length);
}
-myhtml_status_t myhtml_tokenizer_chunk_with_stream_buffer(myhtml_tree_t* tree, const char* html, size_t html_length)
+mystatus_t myhtml_tokenizer_chunk_with_stream_buffer(myhtml_tree_t* tree, const char* html, size_t html_length)
{
unsigned const char* u_html = (unsigned const char*)html;
- const myhtml_encoding_custom_f func = myhtml_encoding_get_function_by_id(tree->encoding);
+ const myencoding_custom_f func = myencoding_get_function_by_id(tree->encoding);
if(tree->stream_buffer == NULL) {
tree->stream_buffer = myhtml_stream_buffer_create();
@@ -111,7 +113,7 @@ myhtml_status_t myhtml_tokenizer_chunk_with_stream_buffer(myhtml_tree_t* tree, c
if(tree->stream_buffer == NULL)
return MyHTML_STATUS_STREAM_BUFFER_ERROR_CREATE;
- myhtml_status_t status = myhtml_stream_buffer_init(tree->stream_buffer, 1024);
+ mystatus_t status = myhtml_stream_buffer_init(tree->stream_buffer, 1024);
if(status)
return status;
@@ -127,11 +129,11 @@ myhtml_status_t myhtml_tokenizer_chunk_with_stream_buffer(myhtml_tree_t* tree, c
for (size_t i = 0; i < html_length; i++)
{
- if(func(u_html[i], &stream_buffer->res) == MyHTML_ENCODING_STATUS_OK)
+ if(func(u_html[i], &stream_buffer->res) == MyENCODING_STATUS_OK)
{
if((stream_entry->length + 4) >= stream_entry->size)
{
- tree->encoding = MyHTML_ENCODING_UTF_8;
+ tree->encoding = MyENCODING_UTF_8;
myhtml_tokenizer_chunk_process(tree, &stream_entry->data[temp_curr_pos], (stream_entry->length - temp_curr_pos));
stream_entry = myhtml_stream_buffer_add_entry(stream_buffer, (4096 * 4));
@@ -142,19 +144,19 @@ myhtml_status_t myhtml_tokenizer_chunk_with_stream_buffer(myhtml_tree_t* tree, c
temp_curr_pos = stream_entry->length;
}
- stream_entry->length += myhtml_encoding_codepoint_to_ascii_utf_8(stream_buffer->res.result, &stream_entry->data[ stream_entry->length ]);
+ stream_entry->length += myencoding_codepoint_to_ascii_utf_8(stream_buffer->res.result, &stream_entry->data[ stream_entry->length ]);
}
}
if((stream_entry->length - temp_curr_pos)) {
- tree->encoding = MyHTML_ENCODING_UTF_8;
+ tree->encoding = MyENCODING_UTF_8;
myhtml_tokenizer_chunk_process(tree, &stream_entry->data[temp_curr_pos], (stream_entry->length - temp_curr_pos));
}
return MyHTML_STATUS_OK;
}
-myhtml_status_t myhtml_tokenizer_end(myhtml_tree_t* tree)
+mystatus_t myhtml_tokenizer_end(myhtml_tree_t* tree)
{
if(tree->incoming_buf)
{
@@ -170,21 +172,24 @@ myhtml_status_t myhtml_tokenizer_end(myhtml_tree_t* tree)
tree->tokenizer_status = MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
}
- myhtml_status_t status = tree->tokenizer_status;
+ mystatus_t status = tree->tokenizer_status;
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
if((tree->flags & MyHTML_TREE_FLAGS_SINGLE_MODE) == 0)
{
- mythread_queue_list_entry_wait_for_done(tree->myhtml->thread, tree->queue_entry);
- tree->queue_entry = mythread_queue_list_entry_delete(tree->myhtml->thread, tree->queue_entry, false);
+ mythread_queue_list_entry_wait_for_done(tree->myhtml->thread_stream, tree->queue_entry);
- if(mythread_queue_list_get_count(tree->myhtml->thread->context) == 0) {
+ tree->queue_entry = mythread_queue_list_entry_delete(tree->myhtml->thread_list, 2,
+ tree->myhtml->thread_stream->context,
+ tree->queue_entry, false);
+
+ /* Further, any work with tree... */
+ if(mythread_queue_list_get_count(tree->myhtml->thread_stream->context) == 0)
myhtml_tokenizer_pause(tree);
- }
if(status == MyHTML_STATUS_OK)
- status = mythread_check_status(tree->myhtml->thread);
+ status = mythread_check_status(tree->myhtml->thread_stream);
}
#endif
@@ -238,17 +243,32 @@ myhtml_tree_node_t * myhtml_tokenizer_fragment_init(myhtml_tree_t* tree, myhtml_
void myhtml_tokenizer_wait(myhtml_tree_t* tree)
{
- mythread_queue_wait_all_for_done(tree->myhtml->thread);
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ if(tree->myhtml->thread_stream)
+ mythread_queue_list_entry_wait_for_done(tree->myhtml->thread_stream, tree->queue_entry);
+#endif
}
void myhtml_tokenizer_post(myhtml_tree_t* tree)
{
- mythread_resume_all(tree->myhtml->thread);
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ if(tree->myhtml->thread_stream)
+ mythread_resume(tree->myhtml->thread_stream, MyTHREAD_OPT_UNDEF);
+
+ if(tree->myhtml->thread_batch)
+ mythread_resume(tree->myhtml->thread_batch, MyTHREAD_OPT_UNDEF);
+#endif
}
void myhtml_tokenizer_pause(myhtml_tree_t* tree)
{
- mythread_stop_all(tree->myhtml->thread);
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ if(tree->myhtml->thread_stream)
+ mythread_stop(tree->myhtml->thread_stream);
+
+ if(tree->myhtml->thread_batch)
+ mythread_stop(tree->myhtml->thread_batch);
+#endif
}
void myhtml_tokenizer_calc_current_namespace(myhtml_tree_t* tree, myhtml_token_node_t* token_node)
@@ -362,8 +382,8 @@ size_t myhtml_tokenizer_state_rcdata(myhtml_tree_t* tree, myhtml_token_node_t* t
mythread_queue_node_t* prev_qnode = mythread_queue_get_prev_node(tree->current_qnode);
- if(prev_qnode && prev_qnode->token) {
- tree->tmp_tag_id = prev_qnode->token->tag_id;
+ if(prev_qnode && prev_qnode->args) {
+ tree->tmp_tag_id = ((myhtml_token_node_t*)(prev_qnode->args))->tag_id;
}
else if(tree->fragment) {
tree->tmp_tag_id = tree->fragment->tag_id;
@@ -404,7 +424,7 @@ size_t myhtml_tokenizer_state_rcdata_less_than_sign(myhtml_tree_t* tree, myhtml_
size_t myhtml_tokenizer_state_rcdata_end_tag_open(myhtml_tree_t* tree, myhtml_token_node_t* token_node, const char* html, size_t html_offset, size_t html_size)
{
- if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z)
+ if(mycore_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyCORE_STRING_MAP_CHAR_A_Z_a_z)
{
myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RCDATA_END_TAG_NAME;
}
@@ -467,7 +487,7 @@ size_t myhtml_tokenizer_state_rcdata_end_tag_name(myhtml_tree_t* tree, myhtml_to
while(html_offset < html_size)
{
- if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_WHITESPACE)
+ if(mycore_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyCORE_STRING_MAP_CHAR_WHITESPACE)
{
if(_myhtml_tokenizer_state_andata_end_tag_name(tree, token_node, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RCDATA)) {
myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME;
@@ -515,7 +535,7 @@ size_t myhtml_tokenizer_state_rcdata_end_tag_name(myhtml_tree_t* tree, myhtml_to
break;
}
- else if (myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] != MyHTML_TOKENIZER_CHAR_A_Z_a_z) {
+ else if (mycore_tokenizer_chars_map[ (unsigned char)html[html_offset] ] != MyCORE_STRING_MAP_CHAR_A_Z_a_z) {
myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RCDATA;
break;
}
@@ -538,8 +558,8 @@ size_t myhtml_tokenizer_state_rawtext(myhtml_tree_t* tree, myhtml_token_node_t*
mythread_queue_node_t* prev_qnode = mythread_queue_get_prev_node(tree->current_qnode);
- if(prev_qnode && prev_qnode->token) {
- tree->tmp_tag_id = prev_qnode->token->tag_id;
+ if(prev_qnode && prev_qnode->args) {
+ tree->tmp_tag_id = ((myhtml_token_node_t*)prev_qnode->args)->tag_id;
}
else if(tree->fragment) {
tree->tmp_tag_id = tree->fragment->tag_id;
@@ -581,7 +601,7 @@ size_t myhtml_tokenizer_state_rawtext_less_than_sign(myhtml_tree_t* tree, myhtml
size_t myhtml_tokenizer_state_rawtext_end_tag_open(myhtml_tree_t* tree, myhtml_token_node_t* token_node, const char* html, size_t html_offset, size_t html_size)
{
- if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z)
+ if(mycore_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyCORE_STRING_MAP_CHAR_A_Z_a_z)
{
myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RAWTEXT_END_TAG_NAME;
}
@@ -599,7 +619,7 @@ size_t myhtml_tokenizer_state_rawtext_end_tag_name(myhtml_tree_t* tree, myhtml_t
while(html_offset < html_size)
{
- if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_WHITESPACE)
+ if(mycore_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyCORE_STRING_MAP_CHAR_WHITESPACE)
{
if(_myhtml_tokenizer_state_andata_end_tag_name(tree, token_node, html, &html_offset, tmp_begin, MyHTML_TOKEN_TYPE_RAWTEXT)) {
myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_ATTRIBUTE_NAME;
@@ -641,7 +661,7 @@ size_t myhtml_tokenizer_state_rawtext_end_tag_name(myhtml_tree_t* tree, myhtml_t
return html_offset;
}
- else if (myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] != MyHTML_TOKENIZER_CHAR_A_Z_a_z) {
+ else if (mycore_tokenizer_chars_map[ (unsigned char)html[html_offset] ] != MyCORE_STRING_MAP_CHAR_A_Z_a_z) {
token_node->raw_begin = tmp_begin;
myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_RAWTEXT;
@@ -751,7 +771,7 @@ size_t myhtml_tokenizer_state_data(myhtml_tree_t* tree, myhtml_token_node_t* tok
token_node->type |= MyHTML_TOKEN_TYPE_NULL;
}
else if(token_node->type & MyHTML_TOKEN_TYPE_WHITESPACE &&
- myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] != MyHTML_TOKENIZER_CHAR_WHITESPACE) {
+ mycore_tokenizer_chars_map[ (unsigned char)html[html_offset] ] != MyCORE_STRING_MAP_CHAR_WHITESPACE) {
token_node->type ^= (token_node->type & MyHTML_TOKEN_TYPE_WHITESPACE);
token_node->type |= MyHTML_TOKEN_TYPE_DATA;
}
@@ -768,7 +788,7 @@ size_t myhtml_tokenizer_state_data(myhtml_tree_t* tree, myhtml_token_node_t* tok
/////////////////////////////////////////////////////////
size_t myhtml_tokenizer_state_tag_open(myhtml_tree_t* tree, myhtml_token_node_t* token_node, const char* html, size_t html_offset, size_t html_size)
{
- if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z)
+ if(mycore_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyCORE_STRING_MAP_CHAR_A_Z_a_z)
{
token_node = myhtml_tokenizer_queue_create_text_node_if_need(tree, token_node, html, ((tree->global_offset + html_offset) - 1), MyHTML_TOKEN_TYPE_DATA);
if(token_node == NULL) {
@@ -830,7 +850,7 @@ size_t myhtml_tokenizer_state_tag_open(myhtml_tree_t* tree, myhtml_token_node_t*
/////////////////////////////////////////////////////////
size_t myhtml_tokenizer_state_end_tag_open(myhtml_tree_t* tree, myhtml_token_node_t* token_node, const char* html, size_t html_offset, size_t html_size)
{
- if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_A_Z_a_z)
+ if(mycore_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyCORE_STRING_MAP_CHAR_A_Z_a_z)
{
token_node = myhtml_tokenizer_queue_create_text_node_if_need(tree, token_node, html, ((tree->global_offset + html_offset) - 2), MyHTML_TOKEN_TYPE_DATA);
if(token_node == NULL) {
@@ -902,7 +922,7 @@ size_t myhtml_tokenizer_state_markup_declaration_open(myhtml_tree_t* tree, myhtm
tagname = myhtml_tree_incomming_buffer_make_data(tree, token_node->raw_begin, 7);
- if(myhtml_strncasecmp(tagname, "DOCTYPE", 7) == 0)
+ if(mycore_strncasecmp(tagname, "DOCTYPE", 7) == 0)
{
myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DOCTYPE;
@@ -916,9 +936,9 @@ size_t myhtml_tokenizer_state_markup_declaration_open(myhtml_tree_t* tree, myhtm
// CDATA sections can only be used in foreign content (MathML or SVG)
if(strncmp(tagname, "[CDATA[", 7) == 0) {
- if(tree->current_qnode->prev && tree->current_qnode->prev->token)
+ if(tree->current_qnode->prev && tree->current_qnode->prev->args)
{
- myhtml_tree_wait_for_last_done_token(tree, tree->current_qnode->prev->token);
+ myhtml_tree_wait_for_last_done_token(tree, tree->current_qnode->prev->args);
myhtml_tree_node_t *adjusted_current_node = myhtml_tree_adjusted_current_node(tree);
if(adjusted_current_node &&
@@ -952,7 +972,7 @@ size_t myhtml_tokenizer_state_tag_name(myhtml_tree_t* tree, myhtml_token_node_t*
{
while(html_offset < html_size)
{
- if(myhtml_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyHTML_TOKENIZER_CHAR_WHITESPACE)
+ if(mycore_tokenizer_chars_map[ (unsigned char)html[html_offset] ] == MyCORE_STRING_MAP_CHAR_WHITESPACE)
{
token_node->raw_length = (tree->global_offset + html_offset) - token_node->raw_begin;
myhtml_check_tag_parser(tree, token_node, html, html_offset);
@@ -1655,9 +1675,9 @@ size_t myhtml_tokenizer_state_parse_error_stop(myhtml_tree_t* tree, myhtml_token
return html_size;
}
-myhtml_status_t myhtml_tokenizer_state_init(myhtml_t* myhtml)
+mystatus_t myhtml_tokenizer_state_init(myhtml_t* myhtml)
{
- myhtml->parse_state_func = (myhtml_tokenizer_state_f*)myhtml_malloc(sizeof(myhtml_tokenizer_state_f) *
+ myhtml->parse_state_func = (myhtml_tokenizer_state_f*)mycore_malloc(sizeof(myhtml_tokenizer_state_f) *
((MyHTML_TOKENIZER_STATE_LAST_ENTRY *
MyHTML_TOKENIZER_STATE_LAST_ENTRY) + 1));
@@ -1896,7 +1916,7 @@ myhtml_status_t myhtml_tokenizer_state_init(myhtml_t* myhtml)
void myhtml_tokenizer_state_destroy(myhtml_t* myhtml)
{
if(myhtml->parse_state_func)
- myhtml_free(myhtml->parse_state_func);
+ mycore_free(myhtml->parse_state_func);
}
diff --git a/source/myhtml/tokenizer.h b/source/myhtml/tokenizer.h
index be1e15f..84cc823 100644
--- a/source/myhtml/tokenizer.h
+++ b/source/myhtml/tokenizer.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -27,23 +27,23 @@ extern "C" {
#endif
#include "myhtml/myosi.h"
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
+#include "mycore/mythread.h"
#include "myhtml/myhtml.h"
#include "myhtml/tag.h"
-#include "myhtml/thread.h"
#include "myhtml/tokenizer_doctype.h"
#include "myhtml/tokenizer_script.h"
#include "myhtml/tokenizer_end.h"
-
+
#define myhtml_tokenizer_inc_html_offset(offset, size) \
offset++; \
if(offset >= size) \
return offset
-myhtml_status_t myhtml_tokenizer_begin(myhtml_tree_t* tree, const char* html, size_t html_length);
-myhtml_status_t myhtml_tokenizer_chunk(myhtml_tree_t* tree, const char* html, size_t html_length);
-myhtml_status_t myhtml_tokenizer_chunk_with_stream_buffer(myhtml_tree_t* tree, const char* html, size_t html_length);
-myhtml_status_t myhtml_tokenizer_end(myhtml_tree_t* tree);
+mystatus_t myhtml_tokenizer_begin(myhtml_tree_t* tree, const char* html, size_t html_length);
+mystatus_t myhtml_tokenizer_chunk(myhtml_tree_t* tree, const char* html, size_t html_length);
+mystatus_t myhtml_tokenizer_chunk_with_stream_buffer(myhtml_tree_t* tree, const char* html, size_t html_length);
+mystatus_t myhtml_tokenizer_end(myhtml_tree_t* tree);
void myhtml_tokenizer_set_state(myhtml_tree_t* tree, myhtml_token_node_t* token_node);
void myhtml_tokenizer_calc_current_namespace(myhtml_tree_t* tree, myhtml_token_node_t* token_node);
@@ -54,7 +54,7 @@ void myhtml_tokenizer_wait(myhtml_tree_t* tree);
void myhtml_tokenizer_post(myhtml_tree_t* tree);
void myhtml_tokenizer_pause(myhtml_tree_t* tree);
-myhtml_status_t myhtml_tokenizer_state_init(myhtml_t* myhtml);
+mystatus_t myhtml_tokenizer_state_init(myhtml_t* myhtml);
void myhtml_tokenizer_state_destroy(myhtml_t* myhtml);
myhtml_token_node_t * myhtml_tokenizer_queue_create_text_node_if_need(myhtml_tree_t* tree, myhtml_token_node_t* token_node, const char* html, size_t absolute_html_offset, enum myhtml_token_type type);
diff --git a/source/myhtml/tokenizer_doctype.c b/source/myhtml/tokenizer_doctype.c
index d63036f..cb649a1 100644
--- a/source/myhtml/tokenizer_doctype.c
+++ b/source/myhtml/tokenizer_doctype.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -169,7 +169,7 @@ size_t myhtml_tokenizer_state_custom_after_doctype_name_a_z(myhtml_tree_t* tree,
const char *param = myhtml_tree_incomming_buffer_make_data(tree, token_node->str.length, 6);
- if(myhtml_strncasecmp(param, "PUBLIC", 6) == 0) {
+ if(mycore_strncasecmp(param, "PUBLIC", 6) == 0) {
myhtml_parser_queue_set_attr(tree, token_node);
tree->attr_current->raw_value_begin = token_node->str.length;
@@ -185,7 +185,7 @@ size_t myhtml_tokenizer_state_custom_after_doctype_name_a_z(myhtml_tree_t* tree,
html_offset = (token_node->str.length + 6) - tree->incoming_buf->offset;
}
- else if(myhtml_strncasecmp(param, "SYSTEM", 6) == 0) {
+ else if(mycore_strncasecmp(param, "SYSTEM", 6) == 0) {
myhtml_parser_queue_set_attr(tree, token_node);
tree->attr_current->raw_value_begin = token_node->str.length;
diff --git a/source/myhtml/tokenizer_doctype.h b/source/myhtml/tokenizer_doctype.h
index a773d10..aedec57 100644
--- a/source/myhtml/tokenizer_doctype.h
+++ b/source/myhtml/tokenizer_doctype.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -27,7 +27,7 @@ extern "C" {
#endif
#include "myhtml/myosi.h"
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
#include "myhtml/myhtml.h"
size_t myhtml_tokenizer_state_doctype(myhtml_tree_t* tree, myhtml_token_node_t* token_node, const char* html, size_t html_offset, size_t html_size);
diff --git a/source/myhtml/tokenizer_end.c b/source/myhtml/tokenizer_end.c
index cca56fc..a80975f 100644
--- a/source/myhtml/tokenizer_end.c
+++ b/source/myhtml/tokenizer_end.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/source/myhtml/tokenizer_end.h b/source/myhtml/tokenizer_end.h
index 3d78807..8b4d953 100644
--- a/source/myhtml/tokenizer_end.h
+++ b/source/myhtml/tokenizer_end.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
diff --git a/source/myhtml/tokenizer_script.c b/source/myhtml/tokenizer_script.c
index f5f473b..2c69cf7 100644
--- a/source/myhtml/tokenizer_script.c
+++ b/source/myhtml/tokenizer_script.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -113,7 +113,7 @@ size_t myhtml_tokenizer_state_script_data_end_tag_name(myhtml_tree_t* tree, myht
size_t tmp_size = token_node->str.length;
const char *tem_name = myhtml_tree_incomming_buffer_make_data(tree, tmp_size, 6);
- if(myhtml_strncasecmp(tem_name, "script", 6) == 0)
+ if(mycore_strncasecmp(tem_name, "script", 6) == 0)
{
token_node = myhtml_tokenizer_queue_create_text_node_if_need(tree, token_node, html, ((html_offset + tree->global_offset) - 8), MyHTML_TOKEN_TYPE_SCRIPT);
if(token_node == NULL) {
@@ -146,7 +146,7 @@ size_t myhtml_tokenizer_state_script_data_end_tag_name(myhtml_tree_t* tree, myht
size_t tmp_size = token_node->str.length;
const char *tem_name = myhtml_tree_incomming_buffer_make_data(tree, tmp_size, 6);
- if(myhtml_strncasecmp(tem_name, "script", 6) == 0)
+ if(mycore_strncasecmp(tem_name, "script", 6) == 0)
{
token_node = myhtml_tokenizer_queue_create_text_node_if_need(tree, token_node, html, ((html_offset + tree->global_offset) - 8), MyHTML_TOKEN_TYPE_SCRIPT);
if(token_node == NULL) {
@@ -179,7 +179,7 @@ size_t myhtml_tokenizer_state_script_data_end_tag_name(myhtml_tree_t* tree, myht
size_t tmp_size = token_node->str.length;
const char *tem_name = myhtml_tree_incomming_buffer_make_data(tree, tmp_size, 6);
- if(myhtml_strncasecmp(tem_name, "script", 6) == 0)
+ if(mycore_strncasecmp(tem_name, "script", 6) == 0)
{
token_node = myhtml_tokenizer_queue_create_text_node_if_need(tree, token_node, html, ((html_offset + tree->global_offset) - 8), MyHTML_TOKEN_TYPE_SCRIPT);
if(token_node == NULL) {
@@ -289,7 +289,7 @@ size_t myhtml_tokenizer_state_script_data_escaped_end_tag_name(myhtml_tree_t* tr
size_t tmp_size = token_node->str.length;
const char *tem_name = myhtml_tree_incomming_buffer_make_data(tree, tmp_size, 6);
- if(myhtml_strncasecmp(tem_name, "script", 6) == 0)
+ if(mycore_strncasecmp(tem_name, "script", 6) == 0)
{
token_node = myhtml_tokenizer_queue_create_text_node_if_need(tree, token_node, html, ((html_offset + tree->global_offset) - 8), MyHTML_TOKEN_TYPE_SCRIPT);
if(token_node == NULL) {
@@ -322,7 +322,7 @@ size_t myhtml_tokenizer_state_script_data_escaped_end_tag_name(myhtml_tree_t* tr
size_t tmp_size = token_node->str.length;
const char *tem_name = myhtml_tree_incomming_buffer_make_data(tree, tmp_size, 6);
- if(myhtml_strncasecmp(tem_name, "script", 6) == 0)
+ if(mycore_strncasecmp(tem_name, "script", 6) == 0)
{
token_node = myhtml_tokenizer_queue_create_text_node_if_need(tree, token_node, html, ((html_offset + tree->global_offset) - 8), MyHTML_TOKEN_TYPE_SCRIPT);
if(token_node == NULL) {
@@ -355,7 +355,7 @@ size_t myhtml_tokenizer_state_script_data_escaped_end_tag_name(myhtml_tree_t* tr
size_t tmp_size = token_node->str.length;
const char *tem_name = myhtml_tree_incomming_buffer_make_data(tree, tmp_size, 6);
- if(myhtml_strncasecmp(tem_name, "script", 6) == 0)
+ if(mycore_strncasecmp(tem_name, "script", 6) == 0)
{
token_node = myhtml_tokenizer_queue_create_text_node_if_need(tree, token_node, html, ((html_offset + tree->global_offset) - 8), MyHTML_TOKEN_TYPE_SCRIPT);
if(token_node == NULL) {
@@ -455,7 +455,7 @@ size_t myhtml_tokenizer_state_script_data_double_escape_start(myhtml_tree_t* tre
size_t tmp_size = token_node->str.length;
const char *tem_name = myhtml_tree_incomming_buffer_make_data(tree, tmp_size, 6);
- if(myhtml_strncasecmp(tem_name, "script", 6) == 0) {
+ if(mycore_strncasecmp(tem_name, "script", 6) == 0) {
myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_SCRIPT_DATA_DOUBLE_ESCAPED;
}
else {
@@ -573,7 +573,7 @@ size_t myhtml_tokenizer_state_script_data_double_escape_end(myhtml_tree_t* tree,
size_t tmp_size = token_node->str.length;
const char *tem_name = myhtml_tree_incomming_buffer_make_data(tree, tmp_size, 6);
- if(myhtml_strncasecmp(tem_name, "script", 6) == 0) {
+ if(mycore_strncasecmp(tem_name, "script", 6) == 0) {
myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_SCRIPT_DATA_ESCAPED;
}
else {
diff --git a/source/myhtml/tokenizer_script.h b/source/myhtml/tokenizer_script.h
index 65cb934..6bbf86b 100644
--- a/source/myhtml/tokenizer_script.h
+++ b/source/myhtml/tokenizer_script.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -27,7 +27,7 @@ extern "C" {
#endif
#include "myhtml/myosi.h"
-#include "myhtml/utils.h"
+#include "mycore/utils.h"
#include "myhtml/myhtml.h"
#include "myhtml/tokenizer.h"
diff --git a/source/myhtml/tree.c b/source/myhtml/tree.c
index 618801e..533c307 100644
--- a/source/myhtml/tree.c
+++ b/source/myhtml/tree.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -22,12 +22,12 @@
myhtml_tree_t * myhtml_tree_create(void)
{
- return (myhtml_tree_t*)myhtml_calloc(1, sizeof(myhtml_tree_t));
+ return (myhtml_tree_t*)mycore_calloc(1, sizeof(myhtml_tree_t));
}
-myhtml_status_t myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml)
+mystatus_t myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml)
{
- myhtml_status_t status = MyHTML_STATUS_OK;
+ mystatus_t status = MyHTML_STATUS_OK;
tree->myhtml = myhtml;
tree->token = myhtml_token_create(tree, 512);
@@ -38,7 +38,6 @@ myhtml_status_t myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml)
tree->temp_tag_name.data = NULL;
tree->stream_buffer = NULL;
tree->parse_flags = MyHTML_TREE_PARSE_FLAGS_CLEAN;
- tree->queue = mythread_queue_create(9182, &status);
tree->context = NULL;
tree->callback_before_token = NULL;
@@ -54,12 +53,21 @@ myhtml_status_t myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml)
if(status)
return status;
- /* init Incoming Buffer objects */
+ /* Thread Queue */
+ tree->queue = mythread_queue_create();
+ if(tree->queue == NULL)
+ return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ status = mythread_queue_init(tree->queue, 9182);
+ if(status)
+ return status;
+
+ /* Init Incoming Buffer objects */
tree->mcobject_incoming_buf = mcobject_create();
if(tree->mcobject_incoming_buf == NULL)
return MyHTML_STATUS_TREE_ERROR_INCOMING_BUFFER_CREATE;
- status = mcobject_init(tree->mcobject_incoming_buf, 256, sizeof(myhtml_incoming_buffer_t));
+ status = mcobject_init(tree->mcobject_incoming_buf, 256, sizeof(mycore_incoming_buffer_t));
if(status)
return status;
@@ -72,13 +80,19 @@ myhtml_status_t myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml)
if(mcstatus)
return MyHTML_STATUS_TREE_ERROR_MCOBJECT_INIT;
- tree->mchar = mchar_async_create(128, (4096 * 5));
+ tree->mchar = mchar_async_create();
tree->active_formatting = myhtml_tree_active_formatting_init(tree);
tree->open_elements = myhtml_tree_open_elements_init(tree);
tree->other_elements = myhtml_tree_list_init();
tree->token_list = myhtml_tree_token_list_init();
tree->template_insertion = myhtml_tree_template_insertion_init(tree);
+ if(tree->mchar == NULL)
+ return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if((status = mchar_async_init(tree->mchar, 128, (4096 * 5))))
+ return status;
+
tree->mcasync_tree_id = mcobject_async_node_add(tree->tree_obj, &mcstatus);
if(mcstatus)
return MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE_NODE;
@@ -91,36 +105,40 @@ myhtml_status_t myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml)
if(mcstatus)
return MyHTML_STATUS_TREE_ERROR_MCOBJECT_CREATE_NODE;
- tree->mchar_node_id = mchar_async_node_add(tree->mchar);
-
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
-
- tree->async_args = (myhtml_async_args_t*)myhtml_calloc(myhtml->thread->pth_list_length, sizeof(myhtml_async_args_t));
-
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ tree->async_args = (myhtml_async_args_t*)mycore_calloc(myhtml->thread_total, sizeof(myhtml_async_args_t));
if(tree->async_args == NULL)
- return MyHTML_STATUS_TREE_ERROR_MEMORY_ALLOCATION;
-
- // for single mode in main thread
- tree->async_args[0].mchar_node_id = tree->mchar_node_id;
+ return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
// for batch thread
- for(size_t i = 0; i < myhtml->thread->batch_count; i++) {
- tree->async_args[(myhtml->thread->batch_first_id + i)].mchar_node_id = mchar_async_node_add(tree->mchar);
+ for(size_t i = 0; i < myhtml->thread_total; i++) {
+ tree->async_args[i].mchar_node_id = mchar_async_node_add(tree->mchar, &status);
+
+ if(status)
+ return status;
}
-
-#else /* MyHTML_BUILD_WITHOUT_THREADS */
-
- tree->async_args = (myhtml_async_args_t*)myhtml_calloc(1, sizeof(myhtml_async_args_t));
+#else /* MyCORE_BUILD_WITHOUT_THREADS */
+ tree->async_args = (myhtml_async_args_t*)mycore_calloc(1, sizeof(myhtml_async_args_t));
if(tree->async_args == NULL)
return MyHTML_STATUS_TREE_ERROR_MEMORY_ALLOCATION;
- tree->async_args->mchar_node_id = tree->mchar_node_id;
+ tree->async_args->mchar_node_id = mchar_async_node_add(tree->mchar, &status);
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
+ if(status)
+ return status;
+
+#endif /* MyCORE_BUILD_WITHOUT_THREADS */
+
+ /* for main thread only after parsing */
+ tree->mchar_node_id = tree->async_args->mchar_node_id;
tree->sync = mcsync_create();
- mcsync_init(tree->sync);
+ if(tree->sync == NULL)
+ return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if(mcsync_init(tree->sync))
+ return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
/* init Tags after create and init mchar */
tree->tags = myhtml_tag_create();
@@ -133,22 +151,23 @@ myhtml_status_t myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml)
void myhtml_tree_clean(myhtml_tree_t* tree)
{
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
myhtml_t* myhtml = tree->myhtml;
- for(size_t i = 0; i < myhtml->thread->batch_count; i++) {
- mchar_async_node_clean(tree->mchar, tree->async_args[(myhtml->thread->batch_first_id + i)].mchar_node_id);
+ for(size_t i = 0; i < myhtml->thread_total; i++) {
+ mchar_async_node_clean(tree->mchar, tree->async_args[i].mchar_node_id);
}
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
+#else
+ mchar_async_node_clean(tree->mchar, tree->mchar_node_id);
+#endif
mcobject_async_node_clean(tree->tree_obj, tree->mcasync_tree_id);
mcobject_async_node_clean(tree->token->nodes_obj, tree->mcasync_rules_token_id);
mcobject_async_node_clean(tree->token->attr_obj, tree->mcasync_rules_attr_id);
- mchar_async_node_clean(tree->mchar, tree->mchar_node_id);
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
- mythread_queue_list_entry_clean(tree->myhtml->thread, tree->queue_entry);
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ mythread_queue_list_entry_clean(tree->queue_entry);
+#endif /* MyCORE_BUILD_WITHOUT_THREADS */
myhtml_token_clean(tree->token);
@@ -184,8 +203,8 @@ void myhtml_tree_clean(myhtml_tree_t* tree)
tree->token_last_done = NULL;
tree->tokenizer_status = MyHTML_STATUS_OK;
- tree->encoding = MyHTML_ENCODING_UTF_8;
- tree->encoding_usereq = MyHTML_ENCODING_DEFAULT;
+ tree->encoding = MyENCODING_UTF_8;
+ tree->encoding_usereq = MyENCODING_DEFAULT;
myhtml_stream_buffer_clean(tree->stream_buffer);
@@ -239,8 +258,8 @@ void myhtml_tree_clean_all(myhtml_tree_t* tree)
tree->token_last_done = NULL;
tree->tokenizer_status = MyHTML_STATUS_OK;
- tree->encoding = MyHTML_ENCODING_UTF_8;
- tree->encoding_usereq = MyHTML_ENCODING_DEFAULT;
+ tree->encoding = MyENCODING_UTF_8;
+ tree->encoding_usereq = MyENCODING_DEFAULT;
myhtml_stream_buffer_clean(tree->stream_buffer);
@@ -252,9 +271,9 @@ void myhtml_tree_clean_all(myhtml_tree_t* tree)
mcobject_clean(tree->mcobject_incoming_buf);
myhtml_tag_clean(tree->tags);
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
- mythread_queue_list_entry_clean(tree->myhtml->thread, tree->queue_entry);
-#endif /* MyHTML_BUILD_WITHOUT_THREADS */
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+ mythread_queue_list_entry_clean(tree->queue_entry);
+#endif
tree->attr_current = myhtml_token_attr_create(tree->token, tree->token->mcasync_attr_id);
}
@@ -281,8 +300,8 @@ myhtml_tree_t * myhtml_tree_destroy(myhtml_tree_t* tree)
myhtml_tree_temp_tag_name_destroy(&tree->temp_tag_name, false);
- myhtml_free(tree->async_args);
- myhtml_free(tree);
+ mycore_free(tree->async_args);
+ mycore_free(tree);
return NULL;
}
@@ -493,7 +512,7 @@ myhtml_tree_node_t * myhtml_tree_node_clone(myhtml_tree_node_t* node)
{
myhtml_tree_node_t* new_node = myhtml_tree_node_create(node->tree);
- myhtml_token_node_wait_for_done(node->token);
+ myhtml_token_node_wait_for_done(node->tree->token, node->token);
new_node->token = myhtml_token_node_clone(node->tree->token, node->token,
node->tree->mcasync_rules_token_id,
@@ -735,11 +754,11 @@ bool myhtml_tree_element_in_scope_by_node(myhtml_tree_node_t* node, enum myhtml_
// list
myhtml_tree_list_t * myhtml_tree_list_init(void)
{
- myhtml_tree_list_t* list = myhtml_malloc(sizeof(myhtml_tree_list_t));
+ myhtml_tree_list_t* list = mycore_malloc(sizeof(myhtml_tree_list_t));
list->length = 0;
list->size = 4096;
- list->list = (myhtml_tree_node_t**)myhtml_malloc(sizeof(myhtml_tree_node_t*) * list->size);
+ list->list = (myhtml_tree_node_t**)mycore_malloc(sizeof(myhtml_tree_node_t*) * list->size);
return list;
}
@@ -755,10 +774,10 @@ myhtml_tree_list_t * myhtml_tree_list_destroy(myhtml_tree_list_t* list, bool des
return NULL;
if(list->list)
- myhtml_free(list->list);
+ mycore_free(list->list);
if(destroy_self && list) {
- myhtml_free(list);
+ mycore_free(list);
return NULL;
}
@@ -770,7 +789,7 @@ void myhtml_tree_list_append(myhtml_tree_list_t* list, myhtml_tree_node_t* node)
if(list->length >= list->size) {
list->size <<= 1;
- myhtml_tree_node_t** tmp = (myhtml_tree_node_t**)myhtml_realloc(list->list, sizeof(myhtml_tree_node_t*) * list->size);
+ myhtml_tree_node_t** tmp = (myhtml_tree_node_t**)mycore_realloc(list->list, sizeof(myhtml_tree_node_t*) * list->size);
if(tmp)
list->list = tmp;
@@ -790,7 +809,7 @@ void myhtml_tree_list_insert_by_index(myhtml_tree_list_t* list, myhtml_tree_node
if(list->length >= list->size) {
list->size <<= 1;
- myhtml_tree_node_t** tmp = (myhtml_tree_node_t**)myhtml_realloc(list->list, sizeof(myhtml_tree_node_t*) * list->size);
+ myhtml_tree_node_t** tmp = (myhtml_tree_node_t**)mycore_realloc(list->list, sizeof(myhtml_tree_node_t*) * list->size);
if(tmp)
list->list = tmp;
@@ -831,7 +850,7 @@ myhtml_tree_list_t * myhtml_tree_open_elements_destroy(myhtml_tree_t* tree)
myhtml_tree_node_t * myhtml_tree_current_node(myhtml_tree_t* tree)
{
if(tree->open_elements->length == 0) {
- MyHTML_DEBUG("Current node; Open elements is 0");
+ MyCORE_DEBUG("Current node; Open elements is 0");
return 0;
}
@@ -861,9 +880,9 @@ void myhtml_tree_open_elements_pop(myhtml_tree_t* tree)
if(tree->open_elements->length)
tree->open_elements->length--;
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(tree->open_elements->length == 0) {
- MyHTML_DEBUG("Pop open elements; Now, Open Elements set 0; Good, if the end of parsing, otherwise is very bad");
+ MyCORE_DEBUG("Pop open elements; Now, Open Elements set 0; Good, if the end of parsing, otherwise is very bad");
}
#endif
}
@@ -886,9 +905,9 @@ void myhtml_tree_open_elements_remove(myhtml_tree_t* tree, myhtml_tree_node_t* n
}
}
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(tree->open_elements->length == 0) {
- MyHTML_DEBUG("Remove open elements; Now, Open Elements set 0; Good, if the end of parsing, otherwise is very bad");
+ MyCORE_DEBUG("Remove open elements; Now, Open Elements set 0; Good, if the end of parsing, otherwise is very bad");
}
#endif
}
@@ -913,9 +932,9 @@ void myhtml_tree_open_elements_pop_until(myhtml_tree_t* tree, myhtml_tag_id_t ta
}
}
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(tree->open_elements->length == 0) {
- MyHTML_DEBUG("Until open elements; Now, Open Elements set 0; Good, if the end of parsing, otherwise is very bad");
+ MyCORE_DEBUG("Until open elements; Now, Open Elements set 0; Good, if the end of parsing, otherwise is very bad");
}
#endif
}
@@ -936,9 +955,9 @@ void myhtml_tree_open_elements_pop_until_by_node(myhtml_tree_t* tree, myhtml_tre
}
}
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(tree->open_elements->length == 0) {
- MyHTML_DEBUG("Until by node open elements; Now, Open Elements set 0; Good, if the end of parsing, otherwise is very bad");
+ MyCORE_DEBUG("Until by node open elements; Now, Open Elements set 0; Good, if the end of parsing, otherwise is very bad");
}
#endif
}
@@ -957,9 +976,9 @@ void myhtml_tree_open_elements_pop_until_by_index(myhtml_tree_t* tree, size_t id
}
}
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(tree->open_elements->length == 0) {
- MyHTML_DEBUG("Until by index open elements; Now, Open Elements set 0; Good, if the end of parsing, otherwise is very bad");
+ MyCORE_DEBUG("Until by index open elements; Now, Open Elements set 0; Good, if the end of parsing, otherwise is very bad");
}
#endif
}
@@ -1045,7 +1064,7 @@ myhtml_tree_node_t * myhtml_tree_open_elements_find_by_tag_idx(myhtml_tree_t* tr
void myhtml_tree_generate_implied_end_tags(myhtml_tree_t* tree, myhtml_tag_id_t exclude_tag_idx, myhtml_namespace_t mynamespace)
{
if(tree->open_elements->length == 0) {
- MyHTML_DEBUG("Generate implied end tags; Open elements is 0");
+ MyCORE_DEBUG("Generate implied end tags; Open elements is 0");
return;
}
@@ -1053,9 +1072,9 @@ void myhtml_tree_generate_implied_end_tags(myhtml_tree_t* tree, myhtml_tag_id_t
{
myhtml_tree_node_t* current_node = myhtml_tree_current_node(tree);
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(current_node == NULL) {
- MyHTML_DEBUG_ERROR("Generate implied end tags; Current node is NULL! This is very bad");
+ MyCORE_DEBUG_ERROR("Generate implied end tags; Current node is NULL! This is very bad");
}
#endif
@@ -1087,7 +1106,7 @@ void myhtml_tree_generate_implied_end_tags(myhtml_tree_t* tree, myhtml_tag_id_t
void myhtml_tree_generate_all_implied_end_tags(myhtml_tree_t* tree, myhtml_tag_id_t exclude_tag_idx, myhtml_namespace_t mynamespace)
{
if(tree->open_elements->length == 0) {
- MyHTML_DEBUG("Generate all implied end tags; Open elements is 0");
+ MyCORE_DEBUG("Generate all implied end tags; Open elements is 0");
return;
}
@@ -1095,9 +1114,9 @@ void myhtml_tree_generate_all_implied_end_tags(myhtml_tree_t* tree, myhtml_tag_i
{
myhtml_tree_node_t* current_node = myhtml_tree_current_node(tree);
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(current_node == NULL) {
- MyHTML_DEBUG_ERROR("Generate all implied end tags; Current node is NULL! This is very bad");
+ MyCORE_DEBUG_ERROR("Generate all implied end tags; Current node is NULL! This is very bad");
}
#endif
@@ -1136,7 +1155,7 @@ void myhtml_tree_generate_all_implied_end_tags(myhtml_tree_t* tree, myhtml_tag_i
void myhtml_tree_reset_insertion_mode_appropriately(myhtml_tree_t* tree)
{
if(tree->open_elements->length == 0) {
- MyHTML_DEBUG("Reset insertion mode appropriately; Open elements is 0");
+ MyCORE_DEBUG("Reset insertion mode appropriately; Open elements is 0");
return;
}
@@ -1154,9 +1173,9 @@ void myhtml_tree_reset_insertion_mode_appropriately(myhtml_tree_t* tree)
// step 2
myhtml_tree_node_t* node = list[i];
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(node == NULL) {
- MyHTML_DEBUG_ERROR("Reset insertion mode appropriately; node is NULL! This is very bad");
+ MyCORE_DEBUG_ERROR("Reset insertion mode appropriately; node is NULL! This is very bad");
}
#endif
@@ -1197,9 +1216,9 @@ void myhtml_tree_reset_insertion_mode_appropriately(myhtml_tree_t* tree)
return;
}
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(ancestor == 0) {
- MyHTML_DEBUG_ERROR("Reset insertion mode appropriately; Ancestor is 0! This is very, very bad");
+ MyCORE_DEBUG_ERROR("Reset insertion mode appropriately; Ancestor is 0! This is very, very bad");
}
#endif
@@ -1315,9 +1334,9 @@ myhtml_tree_list_t * myhtml_tree_active_formatting_destroy(myhtml_tree_t* tree)
bool myhtml_tree_active_formatting_is_marker(myhtml_tree_t* tree, myhtml_tree_node_t* node)
{
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(node == NULL) {
- MyHTML_DEBUG_ERROR("Active formatting is marker; node is NULL!");
+ MyCORE_DEBUG_ERROR("Active formatting is marker; node is NULL!");
}
#endif
@@ -1351,9 +1370,9 @@ void myhtml_tree_active_formatting_pop(myhtml_tree_t* tree)
if(tree->active_formatting->length)
tree->active_formatting->length--;
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(tree->active_formatting->length == 0) {
- MyHTML_DEBUG("Pop active formatting; length is 0");
+ MyCORE_DEBUG("Pop active formatting; length is 0");
}
#endif
}
@@ -1376,9 +1395,9 @@ void myhtml_tree_active_formatting_remove(myhtml_tree_t* tree, myhtml_tree_node_
}
}
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(tree->active_formatting->length == 0) {
- // MyHTML_DEBUG("Remove active formatting; length is 0");
+ // MyCORE_DEBUG("Remove active formatting; length is 0");
}
#endif
}
@@ -1390,9 +1409,9 @@ void myhtml_tree_active_formatting_remove_by_index(myhtml_tree_t* tree, size_t i
memmove(&list[idx], &list[idx + 1], sizeof(myhtml_tree_node_t*) * (tree->active_formatting->length - idx));
tree->active_formatting->length--;
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(tree->active_formatting->length == 0) {
- MyHTML_DEBUG("Remove active formatting by index; length is 0");
+ MyCORE_DEBUG("Remove active formatting by index; length is 0");
}
#endif
}
@@ -1413,9 +1432,9 @@ void myhtml_tree_active_formatting_append_with_check(myhtml_tree_t* tree, myhtml
{
i--;
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(list[i] == NULL) {
- MyHTML_DEBUG("Appen active formatting with check; list[%zu] is NULL", i);
+ MyCORE_DEBUG("Appen active formatting with check; list[" MyCORE_FORMAT_Z "] is NULL", i);
}
#endif
@@ -1424,8 +1443,8 @@ void myhtml_tree_active_formatting_append_with_check(myhtml_tree_t* tree, myhtml
if(list[i]->token && node->token)
{
- myhtml_token_node_wait_for_done(list[i]->token);
- myhtml_token_node_wait_for_done(node->token);
+ myhtml_token_node_wait_for_done(tree->token, list[i]->token);
+ myhtml_token_node_wait_for_done(tree->token, node->token);
if(list[i]->ns == node->ns &&
list[i]->tag_id == node->tag_id &&
@@ -1446,7 +1465,7 @@ void myhtml_tree_active_formatting_append_with_check(myhtml_tree_t* tree, myhtml
myhtml_tree_node_t * myhtml_tree_active_formatting_current_node(myhtml_tree_t* tree)
{
if(tree->active_formatting->length == 0) {
- MyHTML_DEBUG("Current node active formatting; length is 0");
+ MyCORE_DEBUG("Current node active formatting; length is 0");
return 0;
}
@@ -1482,9 +1501,9 @@ void myhtml_tree_active_formatting_up_to_last_marker(myhtml_tree_t* tree)
if(tree->active_formatting->length == 0)
return;
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(list[ tree->active_formatting->length ] == NULL) {
- MyHTML_DEBUG("Up to last marker active formatting; list[%zu] is NULL", tree->active_formatting->length);
+ MyCORE_DEBUG("Up to last marker active formatting; list[" MyCORE_FORMAT_Z "] is NULL", tree->active_formatting->length);
}
#endif
@@ -1492,9 +1511,9 @@ void myhtml_tree_active_formatting_up_to_last_marker(myhtml_tree_t* tree)
{
tree->active_formatting->length--;
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(list[ tree->active_formatting->length ] == NULL) {
- MyHTML_DEBUG("Up to last marker active formatting; list[%zu] is NULL", tree->active_formatting->length);
+ MyCORE_DEBUG("Up to last marker active formatting; list[" MyCORE_FORMAT_Z "] is NULL", tree->active_formatting->length);
}
#endif
@@ -1515,9 +1534,9 @@ myhtml_tree_node_t * myhtml_tree_active_formatting_between_last_marker(myhtml_tr
{
i--;
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(list[i] == NULL) {
- MyHTML_DEBUG("Between last marker active formatting; list[%zu] is NULL", i);
+ MyCORE_DEBUG("Between last marker active formatting; list[" MyCORE_FORMAT_Z "] is NULL", i);
}
#endif
@@ -1554,9 +1573,9 @@ void myhtml_tree_active_formatting_reconstruction(myhtml_tree_t* tree)
{
af_idx--;
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(list[af_idx] == NULL) {
- MyHTML_DEBUG("Formatting reconstruction; Step 4--6; list[%zu] is NULL", af_idx);
+ MyCORE_DEBUG("Formatting reconstruction; Step 4--6; list[" MyCORE_FORMAT_Z "] is NULL", af_idx);
}
#endif
@@ -1570,9 +1589,9 @@ void myhtml_tree_active_formatting_reconstruction(myhtml_tree_t* tree)
while (af_idx < af->length)
{
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(list[af_idx] == NULL) {
- MyHTML_DEBUG("Formatting reconstruction; Next steps; list[%zu] is NULL", af_idx);
+ MyCORE_DEBUG("Formatting reconstruction; Next steps; list[" MyCORE_FORMAT_Z "] is NULL", af_idx);
}
#endif
@@ -1596,9 +1615,9 @@ bool myhtml_tree_adoption_agency_algorithm(myhtml_tree_t* tree, myhtml_token_nod
myhtml_tree_node_t** afe_list = tree->active_formatting->list;
myhtml_tree_node_t* current_node = oel_list[oel_curr_index];
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(current_node == NULL) {
- MyHTML_DEBUG_ERROR("Adoption agency algorithm; Current node is NULL");
+ MyCORE_DEBUG_ERROR("Adoption agency algorithm; Current node is NULL");
}
#endif
@@ -1707,18 +1726,18 @@ bool myhtml_tree_adoption_agency_algorithm(myhtml_tree_t* tree, myhtml_token_nod
/* %EXTERNAL% VALIDATOR:RULES TOKEN STATUS:AAA_BEGIN LEVEL:INFO */
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(oel_format_el_idx == 0) {
- MyHTML_DEBUG_ERROR("Adoption agency algorithm; Step 11; oel_format_el_idx is 0; Bad!");
+ MyCORE_DEBUG_ERROR("Adoption agency algorithm; Step 11; oel_format_el_idx is 0; Bad!");
}
#endif
// step 12
myhtml_tree_node_t* common_ancestor = oel_list[oel_format_el_idx - 1];
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(common_ancestor == NULL) {
- MyHTML_DEBUG_ERROR("Adoption agency algorithm; Step 11; common_ancestor is NULL");
+ MyCORE_DEBUG_ERROR("Adoption agency algorithm; Step 11; common_ancestor is NULL");
}
#endif
@@ -1744,7 +1763,7 @@ bool myhtml_tree_adoption_agency_algorithm(myhtml_tree_t* tree, myhtml_token_nod
if(node_index > 0)
node_index--;
else {
- fprintf(stderr, "ERROR: adoption agency algorithm; decrement node_index, node_index is null");
+ MyCORE_DEBUG_ERROR("Adoption agency algorithm; decrement node_index, node_index is null");
return false;
}
@@ -1752,9 +1771,9 @@ bool myhtml_tree_adoption_agency_algorithm(myhtml_tree_t* tree, myhtml_token_nod
node = oel_list[node_index];
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(node == NULL) {
- MyHTML_DEBUG_ERROR("Adoption agency algorithm; Step 13.3; node is NULL");
+ MyCORE_DEBUG_ERROR("Adoption agency algorithm; Step 13.3; node is NULL");
}
#endif
// step 14.4
@@ -1795,9 +1814,9 @@ bool myhtml_tree_adoption_agency_algorithm(myhtml_tree_t* tree, myhtml_token_nod
if(last == furthest_block) {
bookmark = afe_node_index + 1;
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(bookmark >= tree->active_formatting->length) {
- MyHTML_DEBUG_ERROR("Adoption agency algorithm; Step 13.8; bookmark >= open_elements length");
+ MyCORE_DEBUG_ERROR("Adoption agency algorithm; Step 13.8; bookmark >= open_elements length");
}
#endif
}
@@ -1846,9 +1865,9 @@ bool myhtml_tree_adoption_agency_algorithm(myhtml_tree_t* tree, myhtml_token_nod
if(afe_index < bookmark)
bookmark--;
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(bookmark >= tree->active_formatting->length) {
- MyHTML_DEBUG_ERROR("Adoption agency algorithm; Before Step 18; bookmark (%zu) >= open_elements length", bookmark);
+ MyCORE_DEBUG_ERROR("Adoption agency algorithm; Before Step 18; bookmark (" MyCORE_FORMAT_Z ") >= open_elements length", bookmark);
}
#endif
@@ -1862,7 +1881,7 @@ bool myhtml_tree_adoption_agency_algorithm(myhtml_tree_t* tree, myhtml_token_nod
myhtml_tree_list_insert_by_index(tree->open_elements, new_formatting_element, idx_furthest_block + 1);
}
else {
- MyHTML_DEBUG_ERROR("Adoption agency algorithm; Step 19; can't find furthest_block in open elements");
+ MyCORE_DEBUG_ERROR("Adoption agency algorithm; Step 19; can't find furthest_block in open elements");
}
}
@@ -1881,9 +1900,9 @@ myhtml_tree_node_t * myhtml_tree_appropriate_place_inserting(myhtml_tree_t* tree
myhtml_tree_node_t* adjusted_location;
if(tree->foster_parenting) {
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(target == NULL) {
- MyHTML_DEBUG_ERROR("Appropriate place inserting; Step 2; target is NULL in return value! This IS very bad");
+ MyCORE_DEBUG_ERROR("Appropriate place inserting; Step 2; target is NULL in return value! This IS very bad");
}
#endif
if(target->ns != MyHTML_NAMESPACE_HTML)
@@ -1932,9 +1951,9 @@ myhtml_tree_node_t * myhtml_tree_appropriate_place_inserting(myhtml_tree_t* tree
break;
}
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(idx_table == 0) {
- MyHTML_DEBUG_ERROR("Appropriate place inserting; Step 2.5; idx_table is 0");
+ MyCORE_DEBUG_ERROR("Appropriate place inserting; Step 2.5; idx_table is 0");
}
#endif
@@ -1950,9 +1969,9 @@ myhtml_tree_node_t * myhtml_tree_appropriate_place_inserting(myhtml_tree_t* tree
}
}
else {
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(target == NULL) {
- MyHTML_DEBUG_ERROR("Appropriate place inserting; Step 3-5; target is NULL in return value! This IS very bad");
+ MyCORE_DEBUG_ERROR("Appropriate place inserting; Step 3-5; target is NULL in return value! This IS very bad");
}
#endif
@@ -1972,9 +1991,9 @@ myhtml_tree_node_t * myhtml_tree_appropriate_place_inserting_in_tree(myhtml_tree
myhtml_tree_node_t* adjusted_location;
if(target->tree->foster_parenting) {
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(target == NULL) {
- MyHTML_DEBUG_ERROR("Appropriate place inserting; Step 2; target is NULL in return value! This IS very bad");
+ MyCORE_DEBUG_ERROR("Appropriate place inserting; Step 2; target is NULL in return value! This IS very bad");
}
#endif
@@ -2028,12 +2047,6 @@ myhtml_tree_node_t * myhtml_tree_appropriate_place_inserting_in_tree(myhtml_tree
break;
}
-#ifdef DEBUG_MODE
- if(idx_table == 0) {
- MyHTML_DEBUG_ERROR("Appropriate place inserting; Step 2.5; idx_table is 0");
- }
-#endif
-
// step 2.6-7
adjusted_location = target;
@@ -2047,9 +2060,9 @@ myhtml_tree_node_t * myhtml_tree_appropriate_place_inserting_in_tree(myhtml_tree
}
}
else {
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(target == NULL) {
- MyHTML_DEBUG_ERROR("Appropriate place inserting; Step 3-5; target is NULL in return value! This IS very bad");
+ MyCORE_DEBUG_ERROR("Appropriate place inserting; Step 3-5; target is NULL in return value! This IS very bad");
}
#endif
@@ -2066,11 +2079,11 @@ myhtml_tree_node_t * myhtml_tree_appropriate_place_inserting_in_tree(myhtml_tree
// stack of template insertion modes
myhtml_tree_insertion_list_t * myhtml_tree_template_insertion_init(myhtml_tree_t* tree)
{
- myhtml_tree_insertion_list_t* list = myhtml_malloc(sizeof(myhtml_tree_insertion_list_t));
+ myhtml_tree_insertion_list_t* list = mycore_malloc(sizeof(myhtml_tree_insertion_list_t));
list->length = 0;
list->size = 1024;
- list->list = (enum myhtml_insertion_mode*)myhtml_malloc(sizeof(enum myhtml_insertion_mode) * list->size);
+ list->list = (enum myhtml_insertion_mode*)mycore_malloc(sizeof(enum myhtml_insertion_mode) * list->size);
tree->template_insertion = list;
@@ -2088,10 +2101,10 @@ myhtml_tree_insertion_list_t * myhtml_tree_template_insertion_destroy(myhtml_tre
return NULL;
if(tree->template_insertion->list)
- myhtml_free(tree->template_insertion->list);
+ mycore_free(tree->template_insertion->list);
if(tree->template_insertion)
- myhtml_free(tree->template_insertion);
+ mycore_free(tree->template_insertion);
return NULL;
}
@@ -2103,7 +2116,7 @@ void myhtml_tree_template_insertion_append(myhtml_tree_t* tree, enum myhtml_inse
if(list->length >= list->size) {
list->size <<= 1;
- enum myhtml_insertion_mode* tmp = (enum myhtml_insertion_mode*)myhtml_realloc(list->list,
+ enum myhtml_insertion_mode* tmp = (enum myhtml_insertion_mode*)mycore_realloc(list->list,
sizeof(enum myhtml_insertion_mode) * list->size);
if(tmp)
@@ -2119,9 +2132,9 @@ void myhtml_tree_template_insertion_pop(myhtml_tree_t* tree)
if(tree->template_insertion->length)
tree->template_insertion->length--;
-#ifdef DEBUG_MODE
+#ifdef MyCORE_BUILD_DEBUG
if(tree->template_insertion->length == 0) {
- MyHTML_DEBUG("Pop template insertion; length is 0");
+ MyCORE_DEBUG("Pop template insertion; length is 0");
}
#endif
}
@@ -2131,122 +2144,14 @@ size_t myhtml_tree_template_insertion_length(myhtml_tree_t* tree)
return tree->template_insertion->length;
}
-void myhtml_tree_print_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out)
-{
- if(node == NULL)
- return;
-
- const myhtml_tag_context_t *ctx = myhtml_tag_get_by_id(tree->tags, node->tag_id);
-
- if(node->tag_id == MyHTML_TAG__TEXT ||
- node->tag_id == MyHTML_TAG__COMMENT)
- {
- if(node->token)
- fprintf(out, "<%.*s>: %.*s\n", (int)ctx->name_length, ctx->name,
- (int)node->token->str.length, node->token->str.data);
- else
- fprintf(out, "<%.*s>\n", (int)ctx->name_length, ctx->name);
- }
- else if(node->tag_id == MyHTML_TAG__DOCTYPE)
- {
- fprintf(out, "<!DOCTYPE");
-
- if(tree->doctype.attr_name) {
- fprintf(out, " %s", tree->doctype.attr_name);
- }
-
- if(tree->doctype.attr_public) {
- fprintf(out, " %s", tree->doctype.attr_public);
- }
-
- if(tree->doctype.attr_system) {
- fprintf(out, " %s", tree->doctype.attr_system);
- }
-
- fprintf(out, ">\n");
- }
- else
- {
- if(node->token && node->token->type & MyHTML_TOKEN_TYPE_CLOSE) {
- fprintf(out, "</%.*s", (int)ctx->name_length, ctx->name);
- }
- else {
- fprintf(out, "<%.*s", (int)ctx->name_length, ctx->name);
- }
-
- if(node->ns != MyHTML_NAMESPACE_HTML) {
- switch (node->ns) {
- case MyHTML_NAMESPACE_SVG:
- fprintf(out, ":svg");
- break;
- case MyHTML_NAMESPACE_MATHML:
- fprintf(out, ":math");
- break;
- case MyHTML_NAMESPACE_XLINK:
- fprintf(out, ":xlink");
- break;
- case MyHTML_NAMESPACE_XML:
- fprintf(out, ":xml");
- break;
- case MyHTML_NAMESPACE_XMLNS:
- fprintf(out, ":xmlns");
- break;
- default:
- break;
- }
- }
-
- if(node->token)
- myhtml_token_print_attr(tree, node->token, out);
-
- fprintf(out, ">\n");
- }
-}
-
-void _myhtml_tree_print_node_children(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out, size_t inc)
-{
- if(node == NULL)
- return;
-
- size_t i;
-
- while(node)
- {
- for(i = 0; i < inc; i++)
- fprintf(out, "\t");
-
- myhtml_tree_print_node(tree, node, out);
- _myhtml_tree_print_node_children(tree, node->child, out, (inc + 1));
-
- node = node->next;
- }
-}
-
-void myhtml_tree_print_node_children(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out, size_t inc)
-{
- if(node == NULL)
- return;
-
- _myhtml_tree_print_node_children(tree, node->child, out, inc);
-}
-
-void myhtml_tree_print_by_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out, size_t inc)
-{
- if(node == NULL)
- return;
-
- myhtml_tree_print_node(tree, node, out);
- myhtml_tree_print_node_children(tree, node, out, (inc + 1));
-}
-
// token list
myhtml_tree_token_list_t * myhtml_tree_token_list_init(void)
{
- myhtml_tree_token_list_t* list = myhtml_malloc(sizeof(myhtml_tree_token_list_t));
+ myhtml_tree_token_list_t* list = mycore_malloc(sizeof(myhtml_tree_token_list_t));
list->length = 0;
list->size = 4096;
- list->list = (myhtml_token_node_t**)myhtml_malloc(sizeof(myhtml_token_node_t*) * list->size);
+ list->list = (myhtml_token_node_t**)mycore_malloc(sizeof(myhtml_token_node_t*) * list->size);
return list;
}
@@ -2262,10 +2167,10 @@ myhtml_tree_token_list_t * myhtml_tree_token_list_destroy(myhtml_tree_token_list
return NULL;
if(list->list)
- myhtml_free(list->list);
+ mycore_free(list->list);
if(destroy_self && list) {
- myhtml_free(list);
+ mycore_free(list);
return NULL;
}
@@ -2277,7 +2182,7 @@ void myhtml_tree_token_list_append(myhtml_tree_token_list_t* list, myhtml_token_
if(list->length >= list->size) {
list->size <<= 1;
- myhtml_token_node_t** tmp = (myhtml_token_node_t**)myhtml_realloc(list->list, sizeof(myhtml_token_node_t*) * list->size);
+ myhtml_token_node_t** tmp = (myhtml_token_node_t**)mycore_realloc(list->list, sizeof(myhtml_token_node_t*) * list->size);
if(tmp)
list->list = tmp;
@@ -2292,7 +2197,7 @@ void myhtml_tree_token_list_append_after_index(myhtml_tree_token_list_t* list, m
if(list->length >= list->size) {
list->size <<= 1;
- myhtml_token_node_t** tmp = (myhtml_token_node_t**)myhtml_realloc(list->list, sizeof(myhtml_token_node_t*) * list->size);
+ myhtml_token_node_t** tmp = (myhtml_token_node_t**)mycore_realloc(list->list, sizeof(myhtml_token_node_t*) * list->size);
if(tmp)
list->list = tmp;
@@ -2313,7 +2218,7 @@ void myhtml_tree_token_list_append_after_index(myhtml_tree_token_list_t* list, m
myhtml_token_node_t * myhtml_tree_token_list_current_node(myhtml_tree_token_list_t* list)
{
if(list->length == 0) {
- MyHTML_DEBUG("Token list current node; length is 0");
+ MyCORE_DEBUG("Token list current node; length is 0");
return NULL;
}
@@ -2443,7 +2348,7 @@ bool myhtml_tree_is_html_integration_point(myhtml_tree_t* tree, myhtml_tree_node
node->tag_id == MyHTML_TAG_ANNOTATION_XML && node->token &&
(node->token->type & MyHTML_TOKEN_TYPE_CLOSE) == 0)
{
- myhtml_token_node_wait_for_done(node->token);
+ myhtml_token_node_wait_for_done(tree->token, node->token);
myhtml_token_attr_t* attr = myhtml_token_attr_match_case(tree->token, node->token,
"encoding", 8, "text/html", 9);
@@ -2460,11 +2365,11 @@ bool myhtml_tree_is_html_integration_point(myhtml_tree_t* tree, myhtml_tree_node
}
// temp tag name
-myhtml_status_t myhtml_tree_temp_tag_name_init(myhtml_tree_temp_tag_name_t* temp_tag_name)
+mystatus_t myhtml_tree_temp_tag_name_init(myhtml_tree_temp_tag_name_t* temp_tag_name)
{
temp_tag_name->size = 1024;
temp_tag_name->length = 0;
- temp_tag_name->data = (char *)myhtml_malloc(temp_tag_name->size * sizeof(char));
+ temp_tag_name->data = (char *)mycore_malloc(temp_tag_name->size * sizeof(char));
if(temp_tag_name->data == NULL)
return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
@@ -2483,23 +2388,23 @@ myhtml_tree_temp_tag_name_t * myhtml_tree_temp_tag_name_destroy(myhtml_tree_temp
return NULL;
if(temp_tag_name->data) {
- myhtml_free(temp_tag_name->data);
+ mycore_free(temp_tag_name->data);
temp_tag_name->data = NULL;
}
if(self_destroy) {
- myhtml_free(temp_tag_name);
+ mycore_free(temp_tag_name);
return NULL;
}
return temp_tag_name;
}
-myhtml_status_t myhtml_tree_temp_tag_name_append_one(myhtml_tree_temp_tag_name_t* temp_tag_name, const char name)
+mystatus_t myhtml_tree_temp_tag_name_append_one(myhtml_tree_temp_tag_name_t* temp_tag_name, const char name)
{
if(temp_tag_name->length >= temp_tag_name->size) {
size_t nsize = temp_tag_name->size << 1;
- char *tmp = (char *)myhtml_realloc(temp_tag_name->data, nsize * sizeof(char));
+ char *tmp = (char *)mycore_realloc(temp_tag_name->data, nsize * sizeof(char));
if(tmp) {
temp_tag_name->size = nsize;
@@ -2515,14 +2420,14 @@ myhtml_status_t myhtml_tree_temp_tag_name_append_one(myhtml_tree_temp_tag_name_t
return MyHTML_STATUS_OK;
}
-myhtml_status_t myhtml_tree_temp_tag_name_append(myhtml_tree_temp_tag_name_t* temp_tag_name, const char* name, size_t name_len)
+mystatus_t myhtml_tree_temp_tag_name_append(myhtml_tree_temp_tag_name_t* temp_tag_name, const char* name, size_t name_len)
{
if(temp_tag_name->data == NULL || name_len == 0)
return MyHTML_STATUS_OK;
if((temp_tag_name->length + name_len) >= temp_tag_name->size) {
size_t nsize = (temp_tag_name->size << 1) + name_len;
- char *tmp = (char *)myhtml_realloc(temp_tag_name->data, nsize * sizeof(char));
+ char *tmp = (char *)mycore_realloc(temp_tag_name->data, nsize * sizeof(char));
if(tmp) {
temp_tag_name->size = nsize;
@@ -2540,20 +2445,19 @@ myhtml_status_t myhtml_tree_temp_tag_name_append(myhtml_tree_temp_tag_name_t* te
void myhtml_tree_wait_for_last_done_token(myhtml_tree_t* tree, myhtml_token_node_t* token_for_wait)
{
-#ifndef MyHTML_BUILD_WITHOUT_THREADS
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
- const struct timespec timeout = {0, 0};
- while(tree->token_last_done != token_for_wait) {myhtml_thread_nanosleep(&timeout);}
+ while(tree->token_last_done != token_for_wait) {mythread_nanosleep_sleep(tree->myhtml->thread_stream->timespec);}
#endif
}
/* special tonek list */
-myhtml_status_t myhtml_tree_special_list_init(myhtml_tree_special_token_list_t* special)
+mystatus_t myhtml_tree_special_list_init(myhtml_tree_special_token_list_t* special)
{
special->size = 1024;
special->length = 0;
- special->list = (myhtml_tree_special_token_t *)myhtml_malloc(special->size * sizeof(myhtml_tree_special_token_t));
+ special->list = (myhtml_tree_special_token_t *)mycore_malloc(special->size * sizeof(myhtml_tree_special_token_t));
if(special->list == NULL)
return MyHTML_STATUS_ERROR_MEMORY_ALLOCATION;
@@ -2572,23 +2476,23 @@ myhtml_tree_special_token_list_t * myhtml_tree_special_list_destroy(myhtml_tree_
return NULL;
if(special->list) {
- myhtml_free(special->list);
+ mycore_free(special->list);
special->list = NULL;
}
if(self_destroy) {
- myhtml_free(special);
+ mycore_free(special);
return NULL;
}
return special;
}
-myhtml_status_t myhtml_tree_special_list_append(myhtml_tree_special_token_list_t* special, myhtml_token_node_t *token, myhtml_namespace_t ns)
+mystatus_t myhtml_tree_special_list_append(myhtml_tree_special_token_list_t* special, myhtml_token_node_t *token, myhtml_namespace_t ns)
{
if(special->length >= special->size) {
size_t nsize = special->size << 1;
- myhtml_tree_special_token_t *tmp = (myhtml_tree_special_token_t *)myhtml_realloc(special->list, nsize * sizeof(myhtml_tree_special_token_t));
+ myhtml_tree_special_token_t *tmp = (myhtml_tree_special_token_t *)mycore_realloc(special->list, nsize * sizeof(myhtml_tree_special_token_t));
if(tmp) {
special->size = nsize;
@@ -2628,14 +2532,14 @@ myhtml_tree_special_token_t * myhtml_tree_special_list_get_last(myhtml_tree_spec
}
/* incoming buffer */
-myhtml_incoming_buffer_t * myhtml_tree_incoming_buffer_first(myhtml_tree_t *tree)
+mycore_incoming_buffer_t * myhtml_tree_incoming_buffer_first(myhtml_tree_t *tree)
{
return tree->incoming_buf_first;
}
const char * myhtml_tree_incomming_buffer_make_data(myhtml_tree_t *tree, size_t begin, size_t length)
{
- myhtml_incoming_buffer_t *buffer = myhtml_incoming_buffer_find_by_position(tree->incoming_buf_first, begin);
+ mycore_incoming_buffer_t *buffer = mycore_incoming_buffer_find_by_position(tree->incoming_buf_first, begin);
size_t relative_begin = begin - buffer->offset;
if((relative_begin + length) <= buffer->size) {
diff --git a/source/myhtml/tree.h b/source/myhtml/tree.h
index 1e126f6..c3299de 100644
--- a/source/myhtml/tree.h
+++ b/source/myhtml/tree.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -31,10 +31,11 @@ extern "C" {
#include "myhtml/mystring.h"
#include "myhtml/token.h"
#include "myhtml/stream.h"
-#include "myhtml/utils/mcsync.h"
-#include "myhtml/utils/mchar_async.h"
-#include "myhtml/utils/mcobject.h"
-#include "myhtml/utils/mcobject_async.h"
+#include "mycore/thread_queue.h"
+#include "mycore/utils/mcsync.h"
+#include "mycore/utils/mchar_async.h"
+#include "mycore/utils/mcobject.h"
+#include "mycore/utils/mcobject_async.h"
#define myhtml_tree_get(tree, attr) tree->attr
#define myhtml_tree_set(tree, attr) tree->attr
@@ -164,7 +165,7 @@ struct myhtml_tree_temp_stream {
size_t length;
size_t size;
- myhtml_encoding_result_t res;
+ myencoding_result_t res;
struct myhtml_tree_temp_tag_name* current;
};
@@ -185,6 +186,11 @@ struct myhtml_tree {
size_t mcasync_rules_token_id;
size_t mcasync_rules_attr_id;
size_t mcasync_tree_id;
+ /*
+ * mchar_node_id
+ * for rules, or if single mode,
+ * or for main thread only after parsing
+ */
size_t mchar_node_id;
myhtml_token_attr_t* attr_current;
myhtml_tag_id_t tmp_tag_id;
@@ -192,8 +198,8 @@ struct myhtml_tree {
mythread_queue_node_t* current_qnode;
mcobject_t* mcobject_incoming_buf;
- myhtml_incoming_buffer_t* incoming_buf;
- myhtml_incoming_buffer_t* incoming_buf_first;
+ mycore_incoming_buffer_t* incoming_buf;
+ mycore_incoming_buffer_t* incoming_buf_first;
// ref for nodes
myhtml_tree_node_t* document;
@@ -227,10 +233,10 @@ struct myhtml_tree {
volatile myhtml_tree_parse_flags_t parse_flags;
bool foster_parenting;
size_t global_offset;
- myhtml_status_t tokenizer_status;
+ mystatus_t tokenizer_status;
- myhtml_encoding_t encoding;
- myhtml_encoding_t encoding_usereq;
+ myencoding_t encoding;
+ myencoding_t encoding_usereq;
myhtml_tree_temp_tag_name_t temp_tag_name;
/* callback */
@@ -249,7 +255,7 @@ struct myhtml_tree {
// base
myhtml_tree_t * myhtml_tree_create(void);
-myhtml_status_t myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml);
+mystatus_t myhtml_tree_init(myhtml_tree_t* tree, myhtml_t* myhtml);
void myhtml_tree_clean(myhtml_tree_t* tree);
void myhtml_tree_clean_all(myhtml_tree_t* tree);
myhtml_tree_t * myhtml_tree_destroy(myhtml_tree_t* tree);
@@ -355,10 +361,6 @@ void myhtml_tree_node_clean(myhtml_tree_node_t* tree_node);
void myhtml_tree_node_free(myhtml_tree_node_t* node);
myhtml_tree_node_t * myhtml_tree_node_clone(myhtml_tree_node_t* node);
-void myhtml_tree_print_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out);
-void myhtml_tree_print_node_children(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out, size_t inc);
-void myhtml_tree_print_by_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out, size_t inc);
-
void myhtml_tree_node_add_child(myhtml_tree_node_t* root, myhtml_tree_node_t* node);
void myhtml_tree_node_insert_before(myhtml_tree_node_t* root, myhtml_tree_node_t* node);
void myhtml_tree_node_insert_after(myhtml_tree_node_t* root, myhtml_tree_node_t* node);
@@ -390,21 +392,21 @@ bool myhtml_tree_is_mathml_integration_point(myhtml_tree_t* tree, myhtml_tree_no
bool myhtml_tree_is_html_integration_point(myhtml_tree_t* tree, myhtml_tree_node_t* node);
// temp tag name
-myhtml_status_t myhtml_tree_temp_tag_name_init(myhtml_tree_temp_tag_name_t* temp_tag_name);
+mystatus_t myhtml_tree_temp_tag_name_init(myhtml_tree_temp_tag_name_t* temp_tag_name);
void myhtml_tree_temp_tag_name_clean(myhtml_tree_temp_tag_name_t* temp_tag_name);
myhtml_tree_temp_tag_name_t * myhtml_tree_temp_tag_name_destroy(myhtml_tree_temp_tag_name_t* temp_tag_name, bool self_destroy);
-myhtml_status_t myhtml_tree_temp_tag_name_append(myhtml_tree_temp_tag_name_t* temp_tag_name, const char* name, size_t name_len);
-myhtml_status_t myhtml_tree_temp_tag_name_append_one(myhtml_tree_temp_tag_name_t* temp_tag_name, const char name);
+mystatus_t myhtml_tree_temp_tag_name_append(myhtml_tree_temp_tag_name_t* temp_tag_name, const char* name, size_t name_len);
+mystatus_t myhtml_tree_temp_tag_name_append_one(myhtml_tree_temp_tag_name_t* temp_tag_name, const char name);
/* special tonek list */
-myhtml_status_t myhtml_tree_special_list_init(myhtml_tree_special_token_list_t* special);
-myhtml_status_t myhtml_tree_special_list_append(myhtml_tree_special_token_list_t* special, myhtml_token_node_t *token, myhtml_namespace_t ns);
+mystatus_t myhtml_tree_special_list_init(myhtml_tree_special_token_list_t* special);
+mystatus_t myhtml_tree_special_list_append(myhtml_tree_special_token_list_t* special, myhtml_token_node_t *token, myhtml_namespace_t ns);
size_t myhtml_tree_special_list_length(myhtml_tree_special_token_list_t* special);
myhtml_tree_special_token_t * myhtml_tree_special_list_get_last(myhtml_tree_special_token_list_t* special);
size_t myhtml_tree_special_list_pop(myhtml_tree_special_token_list_t* special);
/* incoming buffer */
-myhtml_incoming_buffer_t * myhtml_tree_incoming_buffer_first(myhtml_tree_t *tree);
+mycore_incoming_buffer_t * myhtml_tree_incoming_buffer_first(myhtml_tree_t *tree);
const char * myhtml_tree_incomming_buffer_make_data(myhtml_tree_t *tree, size_t begin, size_t length);
#ifdef __cplusplus
diff --git a/source/myhtml/utils/avl_tree.h b/source/myhtml/utils/avl_tree.h
deleted file mode 100644
index f2c837e..0000000
--- a/source/myhtml/utils/avl_tree.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- 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 MyHTML_UTILS_AVL_TREE_H
-#define MyHTML_UTILS_AVL_TREE_H
-#pragma once
-
-#include "myhtml/myosi.h"
-#include "myhtml/utils/mcobject.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct myhtml_utils_avl_tree_node myhtml_utils_avl_tree_node_t;
-typedef void (*myhtml_utils_avl_tree_node_callback_f)(myhtml_utils_avl_tree_node_t* avl_tree_node, void* ctx);
-
-struct myhtml_utils_avl_tree_node {
- void *value;
- size_t type;
-
- myhtml_utils_avl_tree_node_t* left;
- myhtml_utils_avl_tree_node_t* right;
- myhtml_utils_avl_tree_node_t* parent;
-
- short height;
-};
-
-struct myhtml_utils_avl_tree {
- mcobject_t* mc_nodes;
-}
-typedef myhtml_utils_avl_tree_t;
-
-myhtml_utils_avl_tree_t * myhtml_utils_avl_tree_create(void);
-myhtml_status_t myhtml_utils_avl_tree_init(myhtml_utils_avl_tree_t* avl_tree);
-void myhtml_utils_avl_tree_clean(myhtml_utils_avl_tree_t* avl_tree);
-myhtml_utils_avl_tree_t * myhtml_utils_avl_tree_destroy(myhtml_utils_avl_tree_t* avl_tree, bool self_destroy);
-
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_node_create_root(myhtml_utils_avl_tree_t* avl_tree, size_t type, void* value);
-
-void myhtml_utils_avl_tree_add(myhtml_utils_avl_tree_t* avl_tree, myhtml_utils_avl_tree_node_t** root, size_t type, void* value);
-void * myhtml_utils_avl_tree_delete(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t** root, size_t type);
-myhtml_utils_avl_tree_node_t * myhtml_utils_avl_tree_search_by_type(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t* node, size_t type);
-
-void myhtml_utils_avl_tree_list_all_nodes(myhtml_utils_avl_tree_t *avl_tree, myhtml_utils_avl_tree_node_t* root, myhtml_utils_avl_tree_node_callback_f callback, void* ctx);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* MyHTML_UTILS_AVL_TREE_H */
diff --git a/source/myhtml/utils/mcsync.c b/source/myhtml/utils/mcsync.c
deleted file mode 100644
index 58b263b..0000000
--- a/source/myhtml/utils/mcsync.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- Copyright (C) 2015-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)
-*/
-
-#include "myhtml/utils/mcsync.h"
-
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && ((defined(__GNUC__) && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) || \
- defined(__ATOMIC_SEQ_CST))
-#define MyHTML_FORCE_SPINLOCK
-#endif
-
-#if defined(MyHTML_FORCE_SPINLOCK)
-static int mcsync_atomic_compare_exchange(int* ptr, int compare, int exchange)
-{
- return __atomic_compare_exchange_n(ptr, &compare, exchange, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
-}
-
-static void mcsync_atomic_store(int* ptr, int value)
-{
- __atomic_store_n(ptr, 0, __ATOMIC_SEQ_CST);
-}
-#endif
-
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && defined(IS_OS_WINDOWS)
-static int pthread_mutex_lock(pthread_mutex_t *mutex)
-{
- EnterCriticalSection(mutex);
- return 0;
-}
-
-static int pthread_mutex_unlock(pthread_mutex_t *mutex)
-{
- LeaveCriticalSection(mutex);
- return 0;
-}
-
-static int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr)
-{
- (void)attr;
- InitializeCriticalSection(mutex);
- return 0;
-}
-
-static int pthread_mutex_destroy(pthread_mutex_t *mutex)
-{
- DeleteCriticalSection(mutex);
- return 0;
-}
-#endif
-
-mcsync_t * mcsync_create(void)
-{
- return calloc(1, sizeof(mcsync_t));
-}
-
-mcsync_status_t mcsync_init(mcsync_t* mcsync)
-{
- mcsync_clean(mcsync);
- return MCSYNC_STATUS_OK;
-}
-
-mcsync_t * mcsync_destroy(mcsync_t* mcsync, int destroy_self)
-{
- if(mcsync == NULL)
- return NULL;
-
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && !defined(MyHTML_FORCE_SPINLOCK)
- if(mcsync->mutex) {
- pthread_mutex_destroy(mcsync->mutex);
- myhtml_free(mcsync->mutex);
- }
-#endif
-
- if(destroy_self)
- myhtml_free(mcsync);
-
- return NULL;
-}
-
-void mcsync_clean(mcsync_t* mcsync)
-{
- mcsync->spinlock = 0;
-}
-
-mcsync_status_t mcsync_lock(mcsync_t* mcsync)
-{
-#if defined(MyHTML_FORCE_SPINLOCK)
- while (!mcsync_atomic_compare_exchange(&mcsync->spinlock, 0, 1)) {}
-#elif !defined(MyHTML_BUILD_WITHOUT_THREADS)
- mcsync_mutex_lock(mcsync);
-#endif
-
- return MCSYNC_STATUS_OK;
-}
-
-mcsync_status_t mcsync_unlock(mcsync_t* mcsync)
-{
-#if defined(MyHTML_FORCE_SPINLOCK)
- mcsync_atomic_store(&mcsync->spinlock, 0);
-#elif !defined(MyHTML_BUILD_WITHOUT_THREADS)
- mcsync_mutex_unlock(mcsync);
-#endif
-
- return MCSYNC_STATUS_OK;
-}
-
-mcsync_status_t mcsync_mutex_lock(mcsync_t* mcsync)
-{
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && !defined(MyHTML_FORCE_SPINLOCK)
- if(mcsync->mutex == NULL) {
- mcsync->mutex = (pthread_mutex_t*)myhtml_malloc(sizeof(pthread_mutex_t));
-
- if(mcsync->mutex == NULL)
- return MCSYNC_STATUS_ERROR_MEM_ALLOCATE;
-
- pthread_mutex_init(mcsync->mutex, NULL);
- }
-
- if(pthread_mutex_lock(mcsync->mutex) == 0)
- return MCSYNC_STATUS_OK;
- else
- return MCSYNC_STATUS_NOT_OK;
-#else
- return MCSYNC_STATUS_NOT_OK;
-#endif
-}
-
-mcsync_status_t mcsync_mutex_unlock(mcsync_t* mcsync)
-{
-#if !defined(MyHTML_BUILD_WITHOUT_THREADS) && !defined(MyHTML_FORCE_SPINLOCK)
- if(pthread_mutex_unlock(mcsync->mutex) == 0)
- return MCSYNC_STATUS_OK;
- else
- return MCSYNC_STATUS_NOT_OK;
-#else
- return MCSYNC_STATUS_NOT_OK;
-#endif
-}
-
diff --git a/source/myhtml/utils/mhash.h b/source/myhtml/utils/mhash.h
deleted file mode 100644
index c3c8aec..0000000
--- a/source/myhtml/utils/mhash.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Copyright (C) 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 avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
-
- Author: lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-#ifndef html_mhash_h
-#define html_mhash_h
-
-#include "myhtml/myosi.h"
-#include "myhtml/utils/mchar_async.h"
-
-typedef struct myhtml_utils_mhash_entry myhtml_utils_mhash_entry_t;
-
-struct myhtml_utils_mhash_entry {
- char* key;
- size_t key_length;
-
- void *value;
-
- myhtml_utils_mhash_entry_t* next;
-};
-
-struct myhtml_utils_mhash {
- mchar_async_t* mchar_obj;
- size_t mchar_node;
-
- myhtml_utils_mhash_entry_t** table;
- size_t table_size;
- size_t table_length;
-
- size_t table_max_depth;
-}
-typedef myhtml_utils_mhash_t;
-
-myhtml_utils_mhash_t * myhtml_utils_mhash_create(void);
-myhtml_status_t myhtml_utils_mhash_init(myhtml_utils_mhash_t* mhash, size_t table_size, size_t depth);
-void myhtml_utils_mhash_clean(myhtml_utils_mhash_t* mhash);
-myhtml_utils_mhash_t * myhtml_utils_mhash_destroy(myhtml_utils_mhash_t* mhash, bool self_destroy);
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_create_entry(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
-
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_search(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size, void* value);
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_add_with_choice(myhtml_utils_mhash_t* mhash, const char* key, size_t key_size);
-
-myhtml_utils_mhash_entry_t * myhtml_utils_mhash_entry_by_id(myhtml_utils_mhash_t* mhash, size_t id);
-size_t myhtml_utils_mhash_get_table_size(myhtml_utils_mhash_t* mhash);
-
-myhtml_utils_mhash_entry_t ** myhtml_utils_mhash_rebuld(myhtml_utils_mhash_t* mhash);
-
-#endif
diff --git a/source/myport/posix/Makefile.mk b/source/myport/posix/Makefile.mk
new file mode 100644
index 0000000..d1ff5f5
--- /dev/null
+++ b/source/myport/posix/Makefile.mk
@@ -0,0 +1,9 @@
+myport_dirs := mycore/. mycore/utils
+myport_objs := $(call MODEST_UTILS_OBJS,$(call MyPORT_SELECTED_PORT),$(myport_dirs))
+
+myport_all: $(myport_objs)
+
+myport_clean:
+ rm -f $(myport_objs)
+
+myport_clone:
diff --git a/source/myport/posix/Rules.mk b/source/myport/posix/Rules.mk
new file mode 100644
index 0000000..7684fb7
--- /dev/null
+++ b/source/myport/posix/Rules.mk
@@ -0,0 +1,27 @@
+#*******************************
+# For unix and linux see POSIX rules in /Makefile.cfg
+#*******************
+#*******************************
+# Darwin, Mac OS X
+#*******************
+ifeq ($(OS),Darwin)
+ MODEST_CLONE_SED_HEADER_COMMAND = find $(INCLUDE_DIR_API) -name "*.h" -exec sed -i '.bak' -E 's/^[ \t]*\#[ \t]*include[ \t]*"([^"]+)"/\#include <\1>/g' {} \;
+
+ MODEST_CFLAGS += -fPIC
+ MODEST_CFLAGS += $(PROJECT_OPTIMIZATION_LEVEL) -Wno-unused-variable -Wno-unused-function -std=c99
+ LIB_NAME_SUFFIX := .dylib
+
+ MODEST_BUILD_SHARED_AFTER += ln -sf $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY) $(MODEST_UTILS_NEW_LINE)
+ MODEST_BUILD_SHARED_AFTER += ln -sf $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY_WITH_VERSION_MAJOR) $(MODEST_UTILS_NEW_LINE)
+ MODEST_BUILD_SHARED_AFTER += ln -sf $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY_WITH_VERSION_MAJOR_MINOR) $(MODEST_UTILS_NEW_LINE)
+
+ MODEST_BUILD_CLEAN_AFTER += rm -f $(call MODEST_LIBRARY) $(MODEST_UTILS_NEW_LINE)
+ MODEST_BUILD_CLEAN_AFTER += rm -f $(call MODEST_LIBRARY_WITH_VERSION_MAJOR) $(MODEST_UTILS_NEW_LINE)
+ MODEST_BUILD_CLEAN_AFTER += rm -f $(call MODEST_LIBRARY_WITH_VERSION_MAJOR_MINOR) $(MODEST_UTILS_NEW_LINE)
+
+ # Need set
+ MODEST_BUILD_OS := $(OS)
+ # this name eq source/myport/<namedir>
+ MODEST_PORT_NAME := posix
+endif
+# end of Darwin, Mac OS X
diff --git a/source/myport/posix/mycore/io.c b/source/myport/posix/mycore/io.c
new file mode 100644
index 0000000..135f101
--- /dev/null
+++ b/source/myport/posix/mycore/io.c
@@ -0,0 +1,69 @@
+/*
+ Copyright (C) 2015-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 "mycore/myosi.h"
+#include <stdarg.h>
+
+/* FILE */
+FILE * mycore_fopen(const char *filename, const char *mode)
+{
+ return fopen(filename, mode);
+}
+
+int mycore_fclose(FILE *stream)
+{
+ return fclose(stream);
+}
+
+size_t mycore_fread(void *buffer, size_t size, size_t count, FILE *stream)
+{
+ return fread(buffer, size, count, stream);
+}
+
+size_t mycore_fwrite(const void *buffer, size_t size, size_t count, FILE *stream)
+{
+ return fwrite(buffer, size, count, stream);
+}
+
+int mycore_fflush(FILE *stream)
+{
+ return fflush(stream);
+}
+
+int mycore_fseek(FILE* stream, long offset, int origin)
+{
+ return fseek(stream, offset, origin);
+}
+
+long mycore_ftell(FILE* stream)
+{
+ return ftell(stream);
+}
+
+int mycore_ferror(FILE *stream)
+{
+ return ferror(stream);
+}
+
+/* setbuf */
+void mycore_setbuf(FILE *stream, char *buffer)
+{
+ setbuf(stream, buffer);
+}
diff --git a/source/myhtml/myosi.c b/source/myport/posix/mycore/memory.c
index cd1e683..4cfd1e0 100644
--- a/source/myhtml/myosi.c
+++ b/source/myport/posix/mycore/memory.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Alexander Borisov
+ Copyright (C) 2015-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
@@ -18,33 +18,25 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include "myhtml/myosi.h"
+#include "mycore/myosi.h"
-void * myhtml_mem_malloc(size_t size)
+void * mycore_malloc(size_t size)
{
return malloc(size);
}
-// see who's call realloc
-void * myhtml_mem_realloc(void* dst, size_t size)
+void * mycore_realloc(void* dst, size_t size)
{
return realloc(dst, size);
}
-void * myhtml_mem_calloc(size_t num, size_t size)
+void * mycore_calloc(size_t num, size_t size)
{
return calloc(num, size);
}
-void myhtml_mem_free(void* dst)
+void * mycore_free(void* dst)
{
free(dst);
-}
-
-void myhtml_print(FILE* out, const char* format, ...)
-{
- va_list argptr;
- va_start(argptr, format);
- vfprintf(out, format, argptr);
- va_end(argptr);
+ return NULL;
}
diff --git a/source/myport/posix/mycore/perf.c b/source/myport/posix/mycore/perf.c
new file mode 100644
index 0000000..eff7a5c
--- /dev/null
+++ b/source/myport/posix/mycore/perf.c
@@ -0,0 +1,136 @@
+/*
+ Copyright (C) 2015-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
+
+ Authors: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#include "mycore/myosi.h"
+#include "mycore/perf.h"
+
+#ifdef MyCORE_WITH_PERF
+
+#if MODEST_BUILD_OS == Darwin || MODEST_BUILD_OS == FreeBSD
+#include <sys/sysctl.h>
+#elif MODEST_BUILD_OS == Linux
+#endif
+
+struct mycore_perf {
+ unsigned long long start;
+ unsigned long long end;
+ unsigned long long freq;
+}
+typedef mycore_perf_t;
+
+void * mycore_perf_create(void)
+{
+ mycore_perf_t *perf = mycore_calloc(1, sizeof(mycore_perf_t));
+ if(perf == NULL)
+ return NULL;
+
+ perf->freq = mycore_perf_frequency();
+
+ return perf;
+}
+
+void mycore_perf_clean(void* perf)
+{
+ memset(perf, 0, sizeof(mycore_perf_t));
+}
+
+void mycore_perf_destroy(void* perf)
+{
+ if(perf)
+ mycore_free(perf);
+}
+
+mycore_status_t myhtml_perf_begin(void* perf)
+{
+ ((mycore_perf_t*)(perf))->start = mycore_perf_clock();
+ return MyCORE_STATUS_OK;
+}
+
+mycore_status_t myhtml_perf_end(void* perf)
+{
+ ((mycore_perf_t*)(perf))->end = mycore_perf_clock();
+ return MyCORE_STATUS_OK;
+}
+
+double myhtml_perf_in_sec(void* perf)
+{
+ mycore_perf_t *obj_perf = (mycore_perf_t*)perf;
+
+ if(obj_perf->freq)
+ return ((double)(obj_perf->end - obj_perf->start) / (double)obj_perf->freq);
+
+ return 0.0f;
+}
+
+unsigned long long mycore_perf_clock(void)
+{
+ unsigned long long x;
+
+ __asm__ volatile (
+ "cpuid\n\t" /* cpuid serializes any out-of-order prefetches before executing rdtsc (clobbers ebx, ecx, edx) */
+ "rdtsc\n\t"
+ "shl $32, %%rdx\n\t"
+ "or %%rdx, %%rax"
+ : "=a" (x)
+ :
+ : "rdx", "ebx", "ecx");
+
+ return x;
+}
+
+unsigned long long mycore_perf_frequency(void)
+{
+ unsigned long long freq = 0;
+
+#if MODEST_BUILD_OS == Darwin && defined(CTL_HW) && defined(HW_CPU_FREQ)
+ /* OSX kernel: sysctl(CTL_HW | HW_CPU_FREQ) */
+ size_t len = sizeof(freq);
+ int mib[2] = {CTL_HW, HW_CPU_FREQ};
+
+ if(sysctl(mib, 2, &freq, &len, NULL, 0))
+ return 0;
+
+ return freq;
+
+#elif MODEST_BUILD_OS == Linux
+ /* Use procfs on linux */
+ FILE* fp = fopen("/proc/cpuinfo", "r");
+ if(fp == NULL)
+ return 0;
+
+ /* Find 'CPU MHz :' */
+ char buf[1024] = {0};
+ double fval = 0.0;
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ if (sscanf(buf, "cpu MHz : %lf\n", &fval) == 1) {
+ freq = (unsigned long long)(fval * 1000000ull);
+ break;
+ }
+ }
+
+ fclose(fp);
+ return freq;
+
+#else
+ return freq;
+#endif /* MODEST_BUILD_OS == Darwin || Linux */
+}
+
+#endif /* MyCORE_WITH_PERF */
diff --git a/source/myport/posix/mycore/thread.c b/source/myport/posix/mycore/thread.c
new file mode 100644
index 0000000..c1bf95f
--- /dev/null
+++ b/source/myport/posix/mycore/thread.c
@@ -0,0 +1,160 @@
+/*
+ Copyright (C) 2015-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 "mycore/mythread.h"
+#include "mycore/utils/mcsync.h"
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+#include <pthread.h>
+
+/***********************************************************************************
+ *
+ * For all unix system. POSIX pthread
+ *
+ ***********************************************************************************/
+void * mythread_thread_create(mythread_t *mythread, mythread_process_f process_func, void* ctx)
+{
+ void *thread = mycore_calloc(1, sizeof(pthread_t));
+
+ if(thread == NULL)
+ return NULL;
+
+ if(pthread_create(&(*((pthread_t*)thread)), mythread->attr, process_func, ctx) == 0)
+ return thread;
+
+ return NULL;
+}
+
+mystatus_t mythread_thread_join(mythread_t *mythread, void* thread)
+{
+ if(pthread_join(*((pthread_t*)thread), NULL) == 0)
+ return MyCORE_STATUS_OK;
+
+ return MyCORE_STATUS_ERROR;
+}
+
+mystatus_t mythread_thread_cancel(mythread_t *mythread, void* thread)
+{
+ if(pthread_cancel(*((pthread_t*)thread)) == 0)
+ return MyCORE_STATUS_OK;
+
+ return MyCORE_STATUS_ERROR;
+}
+
+mystatus_t mythread_thread_destroy(mythread_t *mythread, void* thread)
+{
+ mycore_free(thread);
+ return MyCORE_STATUS_OK;
+}
+
+void * mythread_thread_attr_init(mythread_t *mythread)
+{
+ pthread_attr_t *attr = (pthread_attr_t*)mycore_calloc(1, sizeof(pthread_attr_t));
+
+ if(attr == NULL)
+ return NULL;
+
+ mythread->sys_last_error = pthread_attr_init(attr);
+ if(mythread->sys_last_error) {
+ mycore_free(attr);
+ return NULL;
+ }
+
+ mythread->sys_last_error = pthread_attr_setdetachstate(attr, PTHREAD_CREATE_JOINABLE);
+ if(mythread->sys_last_error) {
+ mycore_free(attr);
+ return NULL;
+ }
+
+ return attr;
+}
+
+void mythread_thread_attr_clean(mythread_t *mythread, void* attr)
+{
+ /* some code */
+}
+
+void mythread_thread_attr_destroy(mythread_t *mythread, void* attr)
+{
+ if(attr == NULL)
+ return;
+
+ mythread->sys_last_error = pthread_attr_destroy(attr);
+ mycore_free(attr);
+}
+
+void * mythread_mutex_create(mythread_t *mythread)
+{
+ void *mutex = mcsync_mutex_create();
+ if(mutex == NULL)
+ return NULL;
+
+ if(mcsync_mutex_init(mutex)) {
+ mycore_free(mutex);
+ return NULL;
+ }
+
+ return mutex;
+}
+
+mystatus_t mythread_mutex_post(mythread_t *mythread, void* mutex)
+{
+ return mcsync_mutex_unlock(mutex);
+}
+
+mystatus_t mythread_mutex_wait(mythread_t *mythread, void* mutex)
+{
+ return mcsync_mutex_lock(mutex);
+}
+
+mystatus_t mythread_mutex_try_wait(mythread_t *mythread, void* mutex)
+{
+ return mcsync_mutex_try_lock(mutex);
+}
+
+void mythread_mutex_close(mythread_t *mythread, void* mutex)
+{
+ mcsync_mutex_destroy(mutex);
+}
+
+void * mythread_nanosleep_create(mythread_t* mythread)
+{
+ return mycore_calloc(1, sizeof(struct timespec));
+}
+
+void mythread_nanosleep_clean(void* timespec)
+{
+ memset(timespec, 0, sizeof(struct timespec));
+}
+
+void mythread_nanosleep_destroy(void* timespec)
+{
+ mycore_free(timespec);
+}
+
+mystatus_t mythread_nanosleep_sleep(void* timespec)
+{
+ if(nanosleep(timespec, NULL) == 0)
+ return MyCORE_STATUS_OK;
+
+ return MyCORE_STATUS_ERROR;
+}
+
+#endif
diff --git a/source/myport/posix/mycore/utils/mcsync.c b/source/myport/posix/mycore/utils/mcsync.c
new file mode 100644
index 0000000..2e66790
--- /dev/null
+++ b/source/myport/posix/mycore/utils/mcsync.c
@@ -0,0 +1,149 @@
+/*
+ Copyright (C) 2015-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 "mycore/utils/mcsync.h"
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+#include <pthread.h>
+
+#if ((defined(__GNUC__) && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) || defined(__ATOMIC_SEQ_CST))
+#define MyCORE_MCSYNC_SPINLOCK_PRESENT
+#endif
+
+#ifdef MyCORE_MCSYNC_SPINLOCK_PRESENT
+static mcsync_status_t mcsync_static_atomic_lock(void* spinlock)
+{
+ int compare = 0;
+ while (!__atomic_compare_exchange_n((int*)spinlock, &compare, 1, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {}
+
+ return MCSYNC_STATUS_OK;
+}
+
+static mcsync_status_t mcsync_static_atomic_unlock(void* spinlock)
+{
+ __atomic_store_n((int*)spinlock, 0, __ATOMIC_SEQ_CST);
+
+ return MCSYNC_STATUS_OK;
+}
+#endif /* MyCORE_MCSYNC_SPINLOCK_PRESENT */
+
+/* spinlock */
+void * mcsync_spin_create(void)
+{
+ return mycore_calloc(1, sizeof(int));
+}
+
+mcsync_status_t mcsync_spin_init(void* spinlock)
+{
+#ifndef MyCORE_MCSYNC_SPINLOCK_PRESENT
+ return mcsync_mutex_init(spinlock);
+#else
+ return MCSYNC_STATUS_OK;
+#endif
+}
+
+void mcsync_spin_clean(void* spinlock)
+{
+#ifdef MyCORE_MCSYNC_SPINLOCK_PRESENT
+ *((int*)spinlock) = 0;
+#endif
+}
+
+void mcsync_spin_destroy(void* spinlock)
+{
+#ifdef MyCORE_MCSYNC_SPINLOCK_PRESENT
+ mycore_free(spinlock);
+#else
+ mcsync_mutex_destroy(spinlock);
+#endif
+}
+
+mcsync_status_t mcsync_spin_lock(void* spinlock)
+{
+#ifdef MyCORE_MCSYNC_SPINLOCK_PRESENT
+ return mcsync_static_atomic_lock(spinlock);
+#else
+ return mcsync_mutex_lock(spinlock);
+#endif
+}
+
+mcsync_status_t mcsync_spin_unlock(void* spinlock)
+{
+#ifdef MyCORE_MCSYNC_SPINLOCK_PRESENT
+ return mcsync_static_atomic_unlock(spinlock);
+#else
+ return mcsync_mutex_unlock(spinlock);
+#endif
+}
+
+/* mutex */
+void * mcsync_mutex_create(void)
+{
+ void *mutex = mycore_calloc(1, sizeof(pthread_mutex_t));
+ if(mutex == NULL)
+ return NULL;
+
+ return mutex;
+}
+
+mcsync_status_t mcsync_mutex_init(void* mutex)
+{
+ if(pthread_mutex_init(mutex, NULL))
+ return MCSYNC_STATUS_NOT_OK;
+
+ return MCSYNC_STATUS_OK;
+}
+
+void mcsync_mutex_clean(void* mutex)
+{
+ /* clean function */
+}
+
+void mcsync_mutex_destroy(void* mutex)
+{
+ pthread_mutex_destroy(mutex);
+ mycore_free(mutex);
+}
+
+mcsync_status_t mcsync_mutex_lock(void* mutex)
+{
+ if(pthread_mutex_lock(mutex) == 0)
+ return MCSYNC_STATUS_OK;
+
+ return MCSYNC_STATUS_NOT_OK;
+}
+
+mcsync_status_t mcsync_mutex_try_lock(void* mutex)
+{
+ if(pthread_mutex_trylock(mutex) == 0)
+ return MCSYNC_STATUS_OK;
+
+ return MCSYNC_STATUS_NOT_OK;
+}
+
+mcsync_status_t mcsync_mutex_unlock(void* mutex)
+{
+ if(pthread_mutex_unlock(mutex) == 0)
+ return MCSYNC_STATUS_OK;
+
+ return MCSYNC_STATUS_NOT_OK;
+}
+
+#endif
diff --git a/source/myport/windows_nt/Makefile.mk b/source/myport/windows_nt/Makefile.mk
new file mode 100644
index 0000000..d1ff5f5
--- /dev/null
+++ b/source/myport/windows_nt/Makefile.mk
@@ -0,0 +1,9 @@
+myport_dirs := mycore/. mycore/utils
+myport_objs := $(call MODEST_UTILS_OBJS,$(call MyPORT_SELECTED_PORT),$(myport_dirs))
+
+myport_all: $(myport_objs)
+
+myport_clean:
+ rm -f $(myport_objs)
+
+myport_clone:
diff --git a/source/myport/windows_nt/Rules.mk b/source/myport/windows_nt/Rules.mk
new file mode 100644
index 0000000..f802892
--- /dev/null
+++ b/source/myport/windows_nt/Rules.mk
@@ -0,0 +1,21 @@
+#*******************************
+# Windows_NT
+#*******************
+ifeq ($(OS),Windows_NT)
+ LIB_NAME_SUFFIX := .dll
+ LIB_NAME_SUFFIX_STATIC := .dll.a
+
+ MODEST_LIBRARY_NAME_WITH_VERSION := lib$(LIB_NAME)-$(PROJECT_VERSION_MAJOR)$(LIB_NAME_SUFFIX)
+
+ MODEST_CFLAGS += -Wno-unused-variable -Wno-unused-function -std=c99
+ MODEST_LDFLAGS += -Wl,--out-implib,$(call MODEST_LIBRARY_STATIC)
+
+ MODEST_BUILD_SHARED_AFTER += cp $(call MODEST_LIBRARY_WITH_VERSION) $(BINARY_DIR_BASE) $(MODEST_UTILS_NEW_LINE)
+ MODEST_BUILD_CLEAN_AFTER += rm -f $(BINARY_DIR_BASE)/$(call MODEST_LIBRARY_NAME_WITH_VERSION) $(MODEST_UTILS_NEW_LINE)
+
+ # Need set
+ MODEST_BUILD_OS := $(OS)
+ # this name eq source/myport/<namedir>
+ MODEST_PORT_NAME := windows_nt
+endif
+# end of Windows_NT
diff --git a/source/myport/windows_nt/mycore/io.c b/source/myport/windows_nt/mycore/io.c
new file mode 100644
index 0000000..b383cd4
--- /dev/null
+++ b/source/myport/windows_nt/mycore/io.c
@@ -0,0 +1,71 @@
+/*
+ Copyright (C) 2015-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 "mycore/myosi.h"
+#include <stdarg.h>
+
+/* FILE */
+FILE * mycore_fopen(const char* filename, const char* mode)
+{
+ return fopen(filename, mode);
+}
+
+int mycore_fclose(FILE *stream)
+{
+ return fclose(stream);
+}
+
+size_t mycore_fread(void *buffer, size_t size, size_t count, FILE* stream)
+{
+ return fread(buffer, size, count, stream);
+}
+
+size_t mycore_fwrite(const void* buffer, size_t size, size_t count, FILE* stream)
+{
+ return fwrite(buffer, size, count, stream);
+}
+
+int mycore_fflush(FILE *stream)
+{
+ return fflush(stream);
+}
+
+int mycore_fseek(FILE* stream, long offset, int origin)
+{
+ return fseek(stream, offset, origin);
+}
+
+long mycore_ftell(FILE* stream)
+{
+ return ftell(stream);
+}
+
+int mycore_ferror(FILE *stream)
+{
+ return ferror(stream);
+}
+
+/* setbuf */
+void mycore_setbuf(FILE* stream, char* buffer)
+{
+ setbuf(stream, buffer);
+}
+
+
diff --git a/source/myport/windows_nt/mycore/memory.c b/source/myport/windows_nt/mycore/memory.c
new file mode 100644
index 0000000..4cfd1e0
--- /dev/null
+++ b/source/myport/windows_nt/mycore/memory.c
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2015-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 "mycore/myosi.h"
+
+void * mycore_malloc(size_t size)
+{
+ return malloc(size);
+}
+
+void * mycore_realloc(void* dst, size_t size)
+{
+ return realloc(dst, size);
+}
+
+void * mycore_calloc(size_t num, size_t size)
+{
+ return calloc(num, size);
+}
+
+void * mycore_free(void* dst)
+{
+ free(dst);
+ return NULL;
+}
diff --git a/source/myport/windows_nt/mycore/perf.c b/source/myport/windows_nt/mycore/perf.c
new file mode 100644
index 0000000..7caafdc
--- /dev/null
+++ b/source/myport/windows_nt/mycore/perf.c
@@ -0,0 +1,92 @@
+/*
+ Copyright (C) 2015-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
+
+ Authors: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#include "mycore/myosi.h"
+#include "mycore/perf.h"
+
+#ifdef MyCORE_WITH_PERF
+#include <windows.h>
+
+struct mycore_perf {
+ LARGE_INTEGER start;
+ LARGE_INTEGER end;
+ LARGE_INTEGER freq;
+}
+typedef mycore_perf_t;
+
+void * mycore_perf_create(void)
+{
+ mycore_perf_t *perf = mycore_calloc(1, sizeof(mycore_perf_t));
+ if(perf == NULL)
+ return NULL;
+
+ QueryPerformanceFrequency(&perf->freq);
+
+ return perf;
+}
+
+void mycore_perf_clean(void* perf)
+{
+ memset(perf, 0, sizeof(mycore_perf_t));
+}
+
+void mycore_perf_destroy(void* perf)
+{
+ if(perf)
+ mycore_free(perf);
+}
+
+mycore_status_t myhtml_perf_begin(void* perf)
+{
+ QueryPerformanceCounter(&((mycore_perf_t*)(perf))->start);
+ return MyCORE_STATUS_OK;
+}
+
+mycore_status_t myhtml_perf_end(void* perf)
+{
+ QueryPerformanceCounter(&((mycore_perf_t*)(perf))->end);
+ return MyCORE_STATUS_OK;
+}
+
+double myhtml_perf_in_sec(void* perf)
+{
+ mycore_perf_t *obj_perf = (mycore_perf_t*)perf;
+
+ if(obj_perf->freq.QuadPart)
+ return ((double)(obj_perf->end.QuadPart - obj_perf->start.QuadPart) / (double)obj_perf->freq.QuadPart);
+
+ return 0.0f;
+}
+
+unsigned long long mycore_perf_clock(void)
+{
+ LARGE_INTEGER x;
+ QueryPerformanceFrequency(&x);
+ return (unsigned long long)x.QuadPart;
+}
+
+unsigned long long mycore_perf_frequency(void)
+{
+ LARGE_INTEGER x;
+ QueryPerformanceFrequency(&x);
+ return (unsigned long long)x.QuadPart;
+}
+
+#endif /* MyCORE_WITH_PERF */
diff --git a/source/myport/windows_nt/mycore/thread.c b/source/myport/windows_nt/mycore/thread.c
new file mode 100644
index 0000000..cf8a874
--- /dev/null
+++ b/source/myport/windows_nt/mycore/thread.c
@@ -0,0 +1,131 @@
+/*
+ Copyright (C) 2015-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 "mycore/mythread.h"
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+#include <windows.h>
+
+/***********************************************************************************
+ *
+ * For Windows
+ *
+ ***********************************************************************************/
+void * mythread_thread_create(mythread_t *mythread, mythread_process_f process_func, void* ctx)
+{
+ return CreateThread(NULL, // default security attributes
+ 0, // use default stack size
+ (LPTHREAD_START_ROUTINE)process_func, // thread function name
+ ctx, // argument to thread function
+ 0, // use default creation flags
+ NULL); // returns the thread identifier
+}
+
+mystatus_t mythread_thread_join(mythread_t *mythread, void* thread)
+{
+ if(WaitForSingleObject(thread, INFINITE) == WAIT_OBJECT_0)
+ return MyCORE_STATUS_OK;
+
+ return MyCORE_STATUS_ERROR;
+}
+
+mystatus_t mythread_thread_cancel(mythread_t *mythread, void* thread)
+{
+ if(TerminateThread(thread, 0))
+ return MyCORE_STATUS_OK;
+
+ return MyCORE_STATUS_ERROR;
+}
+
+mystatus_t mythread_thread_destroy(mythread_t *mythread, void* thread)
+{
+ if(TerminateThread(thread, 0))
+ return MyCORE_STATUS_OK;
+
+ return MyCORE_STATUS_ERROR;
+}
+
+void * mythread_thread_attr_init(mythread_t *mythread)
+{
+ return (void*)0x01;
+}
+
+void mythread_thread_attr_clean(mythread_t *mythread, void* attr)
+{
+}
+
+void mythread_thread_attr_destroy(mythread_t *mythread, void* attr)
+{
+}
+
+void * mythread_mutex_create(mythread_t *mythread)
+{
+ void *mutex = mcsync_mutex_create();
+ if(mutex == NULL)
+ return NULL;
+
+ if(mcsync_mutex_init(mutex)) {
+ mycore_free(mutex);
+ return NULL;
+ }
+
+ return mutex;
+}
+
+mystatus_t mythread_mutex_post(mythread_t *mythread, void* mutex)
+{
+ return mcsync_mutex_unlock(mutex);
+}
+
+mystatus_t mythread_mutex_wait(mythread_t *mythread, void* mutex)
+{
+ return mcsync_mutex_lock(mutex);
+}
+
+mystatus_t mythread_mutex_try_wait(mythread_t *mythread, void* mutex)
+{
+ return mcsync_mutex_try_lock(mutex);
+}
+
+void mythread_mutex_close(mythread_t *mythread, void* mutex)
+{
+ mcsync_mutex_destroy(mutex);
+}
+
+void * mythread_nanosleep_create(mythread_t* mythread)
+{
+ return (void*)0x01;
+}
+
+void mythread_nanosleep_clean(void* timespec)
+{
+}
+
+void mythread_nanosleep_destroy(void* timespec)
+{
+}
+
+mystatus_t mythread_nanosleep_sleep(void* timespec)
+{
+ Sleep(0);
+ return MyCORE_STATUS_OK;
+}
+
+#endif
diff --git a/source/myport/windows_nt/mycore/utils/mcsync.c b/source/myport/windows_nt/mycore/utils/mcsync.c
new file mode 100644
index 0000000..4062c75
--- /dev/null
+++ b/source/myport/windows_nt/mycore/utils/mcsync.c
@@ -0,0 +1,117 @@
+/*
+ Copyright (C) 2015-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 "mycore/utils/mcsync.h"
+
+#ifndef MyCORE_BUILD_WITHOUT_THREADS
+#include <windows.h>
+
+/* spinlock */
+void * mcsync_spin_create(void)
+{
+ CRITICAL_SECTION *spinlock = mycore_calloc(1, sizeof(CRITICAL_SECTION));
+ if(spinlock == NULL)
+ return NULL;
+
+ if(InitializeCriticalSectionAndSpinCount(spinlock, 0x00000400))
+ return spinlock;
+
+ return mycore_free(spinlock);
+}
+
+mcsync_status_t mcsync_spin_init(void* spinlock)
+{
+ if(spinlock)
+ return MCSYNC_STATUS_OK;
+
+ return MCSYNC_STATUS_NOT_OK;
+}
+
+void mcsync_spin_clean(void* spinlock)
+{
+}
+
+void mcsync_spin_destroy(void* spinlock)
+{
+ DeleteCriticalSection(spinlock);
+ mycore_free(spinlock);
+}
+
+mcsync_status_t mcsync_spin_lock(void* spinlock)
+{
+ EnterCriticalSection(spinlock);
+ return MCSYNC_STATUS_OK;
+}
+
+mcsync_status_t mcsync_spin_unlock(void* spinlock)
+{
+ LeaveCriticalSection(spinlock);
+ return MCSYNC_STATUS_OK;
+}
+
+/* mutex */
+void * mcsync_mutex_create(void)
+{
+ return CreateSemaphore(NULL, 1, 1, NULL);
+}
+
+mcsync_status_t mcsync_mutex_init(void* mutex)
+{
+ if(mutex == NULL)
+ return MCSYNC_STATUS_NOT_OK;
+
+ return MCSYNC_STATUS_OK;
+}
+
+void mcsync_mutex_clean(void* mutex)
+{
+ /* clean function */
+}
+
+void mcsync_mutex_destroy(void* mutex)
+{
+ CloseHandle(mutex);
+}
+
+mcsync_status_t mcsync_mutex_lock(void* mutex)
+{
+ if(WaitForSingleObject(mutex, INFINITE) == WAIT_OBJECT_0)
+ return MCSYNC_STATUS_OK;
+
+ return MCSYNC_STATUS_NOT_OK;
+}
+
+mcsync_status_t mcsync_mutex_try_lock(void* mutex)
+{
+ if(WaitForSingleObject(mutex, 0) != WAIT_FAILED)
+ return MCSYNC_STATUS_OK;
+
+ return MCSYNC_STATUS_NOT_OK;
+}
+
+mcsync_status_t mcsync_mutex_unlock(void* mutex)
+{
+ if(ReleaseSemaphore(mutex, 1, NULL))
+ return MCSYNC_STATUS_OK;
+
+ return MCSYNC_STATUS_NOT_OK;
+}
+
+#endif
diff --git a/source/myunicode/Makefile.mk b/source/myunicode/Makefile.mk
new file mode 100644
index 0000000..e219cf0
--- /dev/null
+++ b/source/myunicode/Makefile.mk
@@ -0,0 +1,13 @@
+myunicode_dirs := .
+myunicode_objs := $(call MODEST_UTILS_OBJS,myunicode,$(myunicode_dirs))
+
+myunicode_description := unicode normalization, case work and other
+myunicode_dependencies := mycore myport
+
+myunicode_all: $(myunicode_objs)
+
+myunicode_clean:
+ rm -f $(myunicode_objs)
+
+myunicode_clone:
+ $(call MODEST_UTILS_HDRS_CLONE,myunicode,$(myunicode_dirs))
diff --git a/source/myunicode/myosi.c b/source/myunicode/myosi.c
new file mode 100644
index 0000000..104d2c3
--- /dev/null
+++ b/source/myunicode/myosi.c
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 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 "myunicode/myosi.h"
+
+void * myunicode_callback_malloc(size_t size, void* ctx)
+{
+ return mycore_malloc(size);
+}
+
+void * myunicode_callback_realloc(void* value, size_t size, void* ctx)
+{
+ return mycore_realloc(value, size);
+}
+
+void * myunicode_callback_free(void* value, void* ctx)
+{
+ return mycore_free(value);
+}
diff --git a/source/myunicode/myosi.h b/source/myunicode/myosi.h
new file mode 100644
index 0000000..fd25d26
--- /dev/null
+++ b/source/myunicode/myosi.h
@@ -0,0 +1,35 @@
+/*
+ Copyright (C) 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 MyUNICODE_MYOSI_H
+#define MyUNICODE_MYOSI_H
+#pragma once
+
+#include "myhtml/myosi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyUNICODE_MYOSI_H */
diff --git a/source/myurl/Makefile.mk b/source/myurl/Makefile.mk
new file mode 100644
index 0000000..079aa5e
--- /dev/null
+++ b/source/myurl/Makefile.mk
@@ -0,0 +1,13 @@
+myurl_dirs := .
+myurl_objs := $(call MODEST_UTILS_OBJS,myurl,$(myurl_dirs))
+
+myurl_description := URL parser by https://url.spec.whatwg.org/
+myurl_dependencies := mycore myport
+
+myurl_all: $(myurl_objs)
+
+myurl_clean:
+ rm -f $(myurl_objs)
+
+myurl_clone:
+ $(call MODEST_UTILS_HDRS_CLONE,myurl,$(myurl_dirs))
diff --git a/source/myurl/host.c b/source/myurl/host.c
new file mode 100644
index 0000000..7251187
--- /dev/null
+++ b/source/myurl/host.c
@@ -0,0 +1,631 @@
+/*
+ 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/host.h"
+#include "myurl/url.h"
+#include "myurl/resources.h"
+#include "mycore/utils/resources.h"
+
+myurl_host_t * myurl_host_create(myurl_t* url)
+{
+ myurl_host_t *host = url->callback_malloc(sizeof(myurl_host_t), url->callback_ctx);
+
+ if(host)
+ memset(host, 0, sizeof(myurl_host_t));
+
+ return host;
+}
+
+mystatus_t myurl_host_init(myurl_t* url)
+{
+ return MyURL_STATUS_OK;
+}
+
+void myurl_host_clean(myurl_t* url, myurl_host_t* host)
+{
+ if(host->type == MyURL_HOST_TYPE_DOMAIN)
+ url->callback_free(host->value.domain.value, url->callback_ctx);
+
+ if(host->type == MyURL_HOST_TYPE_OPAQUE)
+ url->callback_free(host->value.opaque.value, url->callback_ctx);
+
+ memset(host, 0, sizeof(myurl_host_t));
+}
+
+myurl_host_t * myurl_host_destroy(myurl_t* url, myurl_host_t* host, bool destroy_self)
+{
+ if(host == NULL)
+ return NULL;
+
+ myurl_host_clean(url, host);
+
+ if(destroy_self) {
+ return url->callback_free(host, url->callback_ctx);
+ }
+
+ return host;
+}
+
+mystatus_t myurl_host_copy(myurl_t* url, myurl_host_t* host_from, myurl_host_t* host_to)
+{
+ host_to->type = host_from->type;
+
+ switch (host_from->type) {
+ case MyURL_HOST_TYPE_DOMAIN:
+ return myurl_utils_data_copy_set(url, host_from->value.domain.value, host_from->value.domain.length,
+ &host_to->value.domain.value, &host_to->value.domain.length);
+
+ default:
+ break;
+ }
+
+ return MyURL_STATUS_OK;
+}
+
+/* Create Values */
+myurl_host_ipv_t * myurl_host_ipv6_entry_create(myurl_t* url)
+{
+ myurl_host_ipv_t *ipv = url->callback_malloc(sizeof(myurl_host_ipv_t), url->callback_ctx);
+
+ if(ipv)
+ memset(ipv, 0, sizeof(myurl_host_ipv_t));
+
+ return ipv;
+}
+
+/* Parsing */
+mystatus_t myurl_host_parser(myurl_t* url, myurl_host_t* host, const char* data, size_t data_size, bool is_special)
+{
+ size_t data_length = 0;
+
+ /* 1 */
+ if(data[data_length] == '[') {
+ if(data[ (data_size - 1) ] != ']') {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+
+ data_length++;
+
+ host->type = MyURL_HOST_TYPE_IPv6;
+ return myurl_host_ipv6_parser(&host->value.ipv, &data[data_length], (data_size - 2));
+ }
+
+ /* 2 */
+ if(is_special == false) {
+ host->type = MyURL_HOST_TYPE_OPAQUE;
+ return myurl_host_opaque_host_parser(url, &host->value.opaque, data, data_size);
+ }
+
+ /* 3 */
+ char *domain = myurl_utils_data_copy(url, data, data_size);
+ size_t domain_size = myurl_utils_percent_decode_bytes_in_data(domain, data_size);
+
+ /* 4 */
+ char* ascii_domain;
+ size_t ascii_domain_size;
+ mystatus_t status = myurl_host_domain_to_ascii(url, &ascii_domain, &ascii_domain_size, domain, domain_size,
+ false, false, MyURL_HOST_IDNA_PROCESSING_OPTION_NONTRANSITIONAL);
+ /* 5 */
+ if(status != MyURL_STATUS_OK) {
+ // parse error
+ return status;
+ }
+
+ /* 6 */
+ const unsigned char *u_ascii_domain = (const unsigned char*)ascii_domain;
+ data_length = 0;
+
+ while(data_length < ascii_domain_size) {
+ if(myurl_resources_static_map_forbidden_host_code_point[ u_ascii_domain[data_length] ] != 0xff) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+
+ data_length++;
+ }
+
+ /* 7 */
+ bool failure;
+ if(myurl_host_ipv4_parser(&host->value.ipv, ascii_domain, ascii_domain_size, &failure) == MyURL_STATUS_OK) {
+ url->callback_free(ascii_domain, url->callback_ctx);
+
+ host->type = MyURL_HOST_TYPE_IPv4;
+ return MyURL_STATUS_OK;
+ }
+
+ if(failure) {
+ // parse error
+ url->callback_free(ascii_domain, url->callback_ctx);
+ return MyURL_STATUS_ERROR;
+ }
+
+ host->type = MyURL_HOST_TYPE_DOMAIN;
+ host->value.domain.value = ascii_domain;
+ host->value.domain.length = ascii_domain_size;
+
+ return MyURL_STATUS_OK;
+}
+
+mystatus_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)
+{
+
+
+
+ *return_domain = domain;
+ *return_domain_size = domain_size;
+
+ return MyURL_STATUS_OK;
+}
+
+mystatus_t myurl_host_opaque_host_parser(myurl_t* url, myurl_host_opaque_t* opaque, const char* data, size_t data_size)
+{
+ // TODO: see this
+ /* 1 */
+ /* If input contains a forbidden host code point excluding "%", validation error, return failure. */
+ size_t length = 0, offset = 0;
+ const unsigned char *u_data = (const unsigned char*)data;
+
+ while(length < data_size) {
+ if(myurl_resources_static_map_forbidden_host_code_point[ u_data[length] ] != 0xff) {
+ offset = length;
+
+ while(offset) {
+ offset--;
+
+ if(data[offset] == '%') {
+ break;
+ }
+ }
+
+ if(offset == 0 && data[offset] != '%') {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+ }
+
+ length++;
+ }
+
+ /* 2 */
+ length = 0;
+ char *in_hex_val = myurl_utils_percent_encode(url, data, data_size, myurl_resources_static_map_C0, &length);
+
+ if(in_hex_val == NULL) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+
+ /* 3 */
+ opaque->value = in_hex_val;
+ opaque->length = length;
+
+ return MyURL_STATUS_OK;
+}
+
+mystatus_t myurl_host_ipv4_number_parser(const char* data, size_t data_size, unsigned int* number, bool* validationErrorFlag)
+{
+ size_t length = 0;
+
+ /* 1 */
+ unsigned int r = 10;
+
+ /* 2 */
+ if(data_size > 1) {
+ if(*data == '0' && (data[1] == 'x' || data[1] == 'X')) {
+ /* 2.1 */
+ *validationErrorFlag = true;
+
+ /* 2.2 */
+ length += 2;
+
+ /* 2.3 */
+ r = 16;
+ }
+ else if(*data == '0') {
+ /* 3.1 */
+ *validationErrorFlag = true;
+
+ /* 3.2 */
+ length++;
+
+ /* 3.3 */
+ r = 8;
+ }
+ }
+
+ *number = 0;
+
+ if(r == 10) {
+ while(length < data_size) {
+ if(mycore_string_chars_num_map[ (unsigned char)data[length] ] == 0xff) {
+ return MyURL_STATUS_ERROR;
+ }
+
+ *number = mycore_string_chars_num_map[ (unsigned char)data[length] ] + *number * r;
+
+ length++;
+ }
+ }
+ else if(r == 16) {
+ while(length < data_size) {
+ if(mycore_string_chars_hex_map[ (unsigned char)data[length] ] == 0xff) {
+ return MyURL_STATUS_ERROR;
+ }
+
+ *number = mycore_string_chars_hex_map[ (unsigned char)data[length] ] + *number * r;
+
+ length++;
+ }
+ }
+ else {
+ while(length < data_size) {
+ if((unsigned char)data[length] < 0x30 || (unsigned char)data[length] > 0x37) {
+ return MyURL_STATUS_ERROR;
+ }
+
+ *number = mycore_string_chars_num_map[ (unsigned char)data[length] ] + *number * r;
+
+ length++;
+ }
+ }
+
+ return MyURL_STATUS_OK;
+}
+
+mystatus_t myurl_host_ipv4_parser(myurl_host_ipv_t* ipv, const char* data, size_t data_size, bool* failure)
+{
+ if(failure)
+ *failure = false;
+
+ size_t data_length = 0;
+ memset(ipv, 0, sizeof(myurl_host_ipv_t));
+
+ /* 1 */
+ bool validationErrorFlag = false;
+
+ /* 2 */
+ size_t part_begin = data_length;
+ size_t part_count = 0;
+
+ while(data_length < data_size)
+ {
+ if(data[data_length] == '.')
+ {
+ /* 4 */
+ if(part_count == 3) {
+ return MyURL_STATUS_ERROR;
+ }
+
+ /* 6.1 */
+ if((data_length - part_begin) == 0) {
+ return MyURL_STATUS_ERROR;
+ }
+
+ if(myurl_host_ipv4_number_parser(&data[part_begin], (data_length - part_begin), &ipv->pieces[part_count], &validationErrorFlag)) {
+ return MyURL_STATUS_ERROR;
+ }
+
+ part_begin = data_length + 1;
+ part_count++;
+ }
+
+ data_length++;
+ }
+
+ if(data_length - part_begin) {
+ if(myurl_host_ipv4_number_parser(&data[part_begin], (data_length - part_begin), &ipv->pieces[part_count], &validationErrorFlag)) {
+ return MyURL_STATUS_ERROR;
+ }
+
+ part_count++;
+ }
+
+ if(part_count == 0) {
+ return MyURL_STATUS_ERROR;
+ }
+
+ /* 7 */
+// if(validationErrorFlag) {
+// // parse error
+// }
+
+ /* 8 */
+ for(size_t i = 0; i < part_count; i++) {
+ if(ipv->pieces[i] > 255) {
+ // parse error
+
+ /* if not last */
+ if(i != (part_count - 1)) {
+ if(failure)
+ *failure = true;
+
+ return MyURL_STATUS_ERROR;
+ }
+ }
+ }
+
+ /* 9 */
+ if(ipv->pieces[(part_count - 1)] >= mycore_power(256, (5 - part_count))) {
+ if(failure)
+ *failure = true;
+
+ return MyURL_STATUS_ERROR;
+ }
+
+ /* 10 */
+ part_count--;
+ unsigned int ipv4 = ipv->pieces[part_count];
+
+ /* calc end char count */
+ for(size_t i = 0; i < part_count; i++) {
+ size_t n = mycore_power(256, (3 - i));
+ ipv4 += ipv->pieces[i] * n;
+ }
+
+ ipv->pieces[0] = ipv4;
+ ipv->type = MyURL_HOST_TYPE_IP_v4;
+
+ return MyURL_STATUS_OK;
+}
+
+mystatus_t myurl_host_ipv6_parser(myurl_host_ipv_t* ipv, const char* data, size_t data_size)
+{
+ size_t data_length = 0;
+ const unsigned char *u_data = (const unsigned char*)data;
+
+ /* 1 */
+ memset(ipv, 0, sizeof(myurl_host_ipv_t));
+ /* 2 */
+ unsigned int *piece = ipv->pieces;
+ unsigned int *piece_pointer = ipv->pieces;
+ /* 3 */
+ unsigned int *compress_pointer = NULL;
+
+ ipv->type = MyURL_HOST_TYPE_IP_v6;
+
+ /* 5 */
+ if(data[data_length] == ':') {
+ data_length++;
+
+ /* 5.1 */
+ if(data_length >= data_size || data[data_length] != ':') {
+ return MyURL_STATUS_ERROR;
+ }
+
+ /* 5.2 */
+ data_length++;
+
+ /* 5.3 */
+ piece_pointer++;
+ piece = piece_pointer;
+
+ compress_pointer = piece_pointer;
+ }
+
+ /* 6 */
+ while(data_length < data_size)
+ {
+ /* 6.1 */
+ if(piece_pointer == &ipv->pieces[8]) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+
+ /* 6.2 */
+ if(data[data_length] == ':') {
+ /* 6.2.1 */
+ if(compress_pointer != NULL) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+
+ /* 6.2.2 */
+ data_length++;
+
+ piece_pointer++;
+ piece = piece_pointer;
+
+ compress_pointer = piece_pointer;
+ continue;
+ }
+
+ /* 6.3 and 6.4 */
+ unsigned int num = 0;
+ size_t i = 0;
+
+ while((i < 4) && (data_length < data_size)) {
+ if(mycore_string_chars_hex_map[ u_data[data_length] ] != 0xff) {
+ num <<= 4;
+ num |= mycore_string_chars_hex_map[ u_data[data_length] ];
+ }
+ else
+ break;
+
+ data_length++;
+ i++;
+ }
+
+ /* 6.5 */
+ if(data_length < data_size)
+ {
+ if(data[data_length] == '.') {
+ /* 6.5.1 */
+ if(i == 0) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+
+ /* 6.5.2 */
+ data_length -= i;
+
+ /* 6.5.3 */
+ if(myurl_host_ipv6_ipv4_parser(ipv, &data[data_length], (data_size - data_length), &piece_pointer)) {
+ return MyURL_STATUS_ERROR;
+ }
+
+ break;
+ }
+ else if(data[data_length] == ':') {
+ /* 6.5.1 */
+ data_length++;
+
+ /* 6.5.2 */
+ if(data_length >= data_size) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+ }
+ else {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+ }
+
+ /* 6.6 */
+ *piece = num;
+ /* 6.7 */
+ piece_pointer++;
+ piece = piece_pointer;
+ }
+
+ /* 11 */
+ /* 11.1 */
+ if(compress_pointer) {
+ unsigned int swaps = (unsigned int)(piece_pointer - compress_pointer);
+ size_t i = 7;
+
+ /* 11.2 and 11.3 */
+ while(i && swaps > 0) {
+ unsigned int *tmp = compress_pointer + (swaps - 1);
+ unsigned int num = *tmp;
+
+ *tmp = ipv->pieces[i];
+ ipv->pieces[i] = num;
+
+ swaps--;
+ i--;
+ }
+
+ return MyURL_STATUS_OK;
+ }
+
+ /* 12 */
+ if(compress_pointer == NULL && piece_pointer != &ipv->pieces[8]) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+
+ return MyURL_STATUS_OK;
+}
+
+mystatus_t myurl_host_ipv6_ipv4_parser(myurl_host_ipv_t* ipv, const char* data, size_t data_size, unsigned int** piece_pointer)
+{
+ size_t data_length = 0;
+ const unsigned char *u_data = (const unsigned char*)data;
+
+ /* 8 */
+ if((*piece_pointer - ipv->pieces) > 6) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+
+ /* 9 */
+ unsigned int numbersSeen = 0;
+
+ /* 10 */
+ while(data_length < data_size)
+ {
+ /* 10.1 */
+ int value = -1;
+
+ /* 10.2 */
+ if(numbersSeen > 0)
+ {
+ if(data[data_length] != '.' || numbersSeen >= 4) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+
+ data_length++;
+
+ if(data_length >= data_size)
+ return MyURL_STATUS_ERROR;
+ }
+
+ /* 10.3 */
+ if(mycore_string_chars_num_map[ u_data[data_length] ] == 0xff) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+
+ /* 10.4 */
+ while(data_length < data_size && mycore_string_chars_num_map[ u_data[data_length] ] != 0xff)
+ {
+ /* 10.4.1 */
+ unsigned int number = mycore_string_chars_num_map[ u_data[data_length] ];
+
+ /* 10.4.2 */
+ if(value == -1) {
+ value = (int)number;
+ }
+ else if(value == 0) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+ else {
+ value = value * 10 + number;
+ }
+
+ /* 10.4.3 */
+ if(value > 255) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+
+ /* 10.4.2 */
+ data_length++;
+ }
+
+ /* 10.5 */
+ **piece_pointer = **piece_pointer * 0x100 + value;
+
+ /* 10.6 */
+ numbersSeen++;
+
+ /* 10.7 */ // maybe: (numbersSeen % 2 == 0) ?
+ if(numbersSeen == 2 || numbersSeen == 4) {
+ (*piece_pointer)++;
+ }
+
+ /* 10.8 */
+ if(data_length >= data_size && numbersSeen != 4) {
+ // parse error
+ return MyURL_STATUS_ERROR;
+ }
+ }
+
+ return MyURL_STATUS_OK;
+}
+
+
diff --git a/source/myurl/host.h b/source/myurl/host.h
new file mode 100644
index 0000000..a648b5b
--- /dev/null
+++ b/source/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;
+ } value;
+
+ myurl_host_type_t type;
+}
+typedef myurl_host_t;
+
+myurl_host_t * myurl_host_create(myurl_t* url);
+mystatus_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);
+mystatus_t myurl_host_copy(myurl_t* url, myurl_host_t* host_from, myurl_host_t* host_to);
+
+mystatus_t myurl_host_parser(myurl_t* url, myurl_host_t* host, const char* data, size_t data_size, bool is_special);
+mystatus_t myurl_host_ipv4_parser(myurl_host_ipv_t* ipv, const char* data, size_t data_size, bool* failure);
+mystatus_t myurl_host_ipv6_parser(myurl_host_ipv_t* ipv, const char* data, size_t data_size);
+mystatus_t myurl_host_ipv6_ipv4_parser(myurl_host_ipv_t* ipv, const char* data, size_t data_size, unsigned int** piece_pointer);
+mystatus_t myurl_host_opaque_host_parser(myurl_t* url, myurl_host_opaque_t* opaque, const char* data, size_t data_size);
+mystatus_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/source/myurl/myosi.c b/source/myurl/myosi.c
new file mode 100644
index 0000000..dc8bfee
--- /dev/null
+++ b/source/myurl/myosi.c
@@ -0,0 +1,38 @@
+/*
+ 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/url.h"
+
+void * myurl_callback_malloc(size_t size, void* ctx)
+{
+ return mycore_malloc(size);
+}
+
+void * myurl_callback_realloc(void* value, size_t size, void* ctx)
+{
+ return mycore_realloc(value, size);
+}
+
+void * myurl_callback_free(void* value, void* ctx)
+{
+ mycore_free(value);
+ return NULL;
+}
diff --git a/source/myurl/myosi.h b/source/myurl/myosi.h
new file mode 100644
index 0000000..ae51ee5
--- /dev/null
+++ b/source/myurl/myosi.h
@@ -0,0 +1,83 @@
+/*
+ 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"
+
+#define MyURL_VERSION_MAJOR 0
+#define MyURL_VERSION_MINOR 1
+#define MyURL_VERSION_PATCH 0
+
+#define MyURL_VERSION_STRING MyCORE_STR(MyURL_VERSION_MAJOR) MyCORE_STR(.) MyCORE_STR(MyURL_VERSION_MINOR) MyCORE_STR(.) MyCORE_STR(MyURL_VERSION_PATCH)
+
+#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, mycore_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/source/myurl/parser.c b/source/myurl/parser.c
new file mode 100644
index 0000000..1ef80fc
--- /dev/null
+++ b/source/myurl/parser.c
@@ -0,0 +1,1164 @@
+/*
+ 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/url.h"
+#include "myurl/parser.h"
+#include "myurl/resources.h"
+#include "mycore/utils/resources.h"
+
+static size_t myurl_parser_skip_control_and_space_leading(const char* url, size_t url_size)
+{
+ size_t i;
+ const unsigned char *u_url = (const unsigned char*)url;
+
+ for(i = 0; i < url_size; i++) {
+ /* control */
+ if(u_url[i] > 0x1F &&
+ /* space */
+ u_url[i] != 0x20 &&
+ /* tab */
+ u_url[i] != 0x09 &&
+ /* new line */
+ u_url[i] != 0x0A && u_url[i] != 0x0D)
+ {
+ break;
+ }
+ }
+
+ return i;
+}
+
+static size_t myurl_parser_skip_control_and_space_trailing(const char* url, size_t url_size)
+{
+ size_t origin_size = url_size;
+ const unsigned char *u_url = (const unsigned char*)url;
+
+ while(url_size) {
+ url_size--;
+
+ if(u_url[url_size] > 0x1F && u_url[url_size] != 0x20) {
+ url_size++;
+ break;
+ }
+ }
+
+ return (origin_size - url_size);
+}
+
+static size_t myurl_parser_skip_newline_and_tab_set(unsigned char* u_data, size_t data_size)
+{
+ size_t offset = 0;
+ for(size_t i = 0; i < data_size; i++)
+ {
+ if(u_data[i] == 0x09 || u_data[i] == 0x0A)
+ {
+ u_data[(i - offset)] = u_data[ (i + 1) ];
+ offset++;
+ }
+ else
+ u_data[(i - offset)] = u_data[i];
+ }
+
+ u_data[ (data_size - offset) ] = '\0';
+ return (data_size - offset);
+}
+
+static size_t myurl_parser_skip_newline_and_tab(myurl_t* url, const char* data, size_t data_size)
+{
+ const unsigned char *u_data = (const unsigned char*)data;
+
+ for(size_t i = 0; i < data_size; i++) {
+ if(u_data[i] == 0x09 || u_data[i] == 0x0A)
+ {
+ url->copy = myurl_utils_data_copy(url, data, data_size);
+
+ if(url->copy)
+ return (i + myurl_parser_skip_newline_and_tab_set((unsigned char*)(&url->copy[i]), (data_size - i)));
+
+ return 0;
+ }
+ }
+
+ return data_size;
+}
+
+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)
+{
+ // add check syntax violation
+ size_t data_length = myurl_parser_skip_control_and_space_leading(data, data_size);
+ data_size -= myurl_parser_skip_control_and_space_trailing(data, data_size);
+
+ data_size = myurl_parser_skip_newline_and_tab(url, &data[data_length], data_size);
+
+ url->state = myurl_parser_state_scheme_start;
+
+ if(url->copy) {
+ data = url->copy;
+ data_length = 0;
+ }
+
+ if(data_size == 0) {
+ if(data_length)
+ data_length = 0;
+
+ /* parse end */
+ myurl_state_f prev_state = myurl_parser_state_undef;
+
+ while(data_length == data_size && url->state != prev_state)
+ {
+ prev_state = url->state;
+ data_length = url->state(url, url_entry, url_base, data, data_length, data_size);
+ }
+
+ if(url->copy) {
+ url->callback_free(url->copy, url->callback_ctx);
+ }
+
+ return data_length;
+ }
+
+ while(data_length < data_size)
+ {
+ while(data_length < data_size) {
+ data_length = url->state(url, url_entry, url_base, data, data_length, data_size);
+ }
+
+ /* parse end */
+ myurl_state_f prev_state = myurl_parser_state_undef;
+
+ while(data_length == data_size && url->state != prev_state)
+ {
+ prev_state = url->state;
+ data_length = url->state(url, url_entry, url_base, data, data_length, data_size);
+ }
+
+ if(data_length >= data_size)
+ break;
+ }
+
+ if(url->copy) {
+ url->callback_free(url->copy, url->callback_ctx);
+ }
+
+ return data_length;
+}
+
+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)
+{
+ return data_length;
+}
+
+/*
+ * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ * ~s~cheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ */
+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)
+{
+ if(data_length < data_size && myurl_parser_alpha(data[data_length])) {
+ url->state = myurl_parser_state_scheme;
+ url->begin = data_length;
+
+ data_length++;
+ }
+ else if(url->state_override == NULL) {
+ url->state = myurl_parser_state_no_scheme;
+ }
+ else {
+ // syntax violation, stop parsing
+ url_entry->status = MyURL_STATUS_FAILURE_SCHEME_START;
+ return (data_size + 1);
+ }
+
+ return data_length;
+}
+
+/*
+ * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ * ~scheme~:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ */
+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)
+{
+ /* END OF FILE */
+ if(data_length >= data_size) {
+ /* 3 */
+ if(url->state_override == NULL) {
+ url->begin = 0;
+ url->state = myurl_parser_state_no_scheme;
+
+ return myurl_parser_skip_control_and_space_leading(data, data_size);
+ }
+
+ return myurl_parser_state_undef(url, url_entry, url_base, data, data_length, data_size);
+ }
+
+ while(data_length < data_size)
+ {
+ /* 1 and 4 */
+ if(myurl_parser_alphanumeric(data[data_length]) == false &&
+ data[data_length] != '+' && data[data_length] != '-' && data[data_length] != '.')
+ {
+ /* 2 */
+ if(data[data_length] == ':')
+ {
+ const myurl_scheme_entry_t *scheme = myurl_scheme_find_entry(&data[url->begin], (data_length - url->begin));
+ myurl_scheme_t *url_entry_scheme = &url_entry->scheme;
+
+ /* 2.1 */
+ if(url->state_override)
+ {
+ if(scheme == NULL) {
+ if(url_entry_scheme->type & MyURL_SCHEME_TYPE_SPECIAL)
+ {
+ url->state = url->state_override;
+ return (data_length + 1); // skip ':'
+ }
+ }
+ else if((url_entry_scheme->type & MyURL_SCHEME_TYPE_SPECIAL) !=
+ (scheme->type & MyURL_SCHEME_TYPE_SPECIAL))
+ {
+ url->state = url->state_override;
+ return (data_length + 1); // skip ':'
+ }
+ }
+
+ memset(url_entry_scheme, 0, sizeof(myurl_scheme_t));
+
+ /* 2.2 */
+ if(scheme == NULL) {
+ if(url_entry_scheme->name)
+ url->callback_free(url_entry_scheme->name, url->callback_ctx);
+
+ url_entry_scheme->length = (data_length - url->begin);
+ url_entry_scheme->name = myurl_utils_data_copy(url, &data[url->begin], url_entry_scheme->length);
+
+ if(url_entry_scheme->name == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+ }
+ else {
+ url_entry_scheme->name = myurl_utils_data_copy(url, scheme->name, scheme->name_length);
+ if(url_entry_scheme->name == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ url_entry_scheme->length = scheme->name_length;
+ url_entry_scheme->port = scheme->port;
+ url_entry_scheme->sid = scheme->m_id;
+ url_entry_scheme->type = scheme->type;
+ }
+
+ /* 2.3 */
+ url->begin = 0;
+
+ data_length++; // skip ':'
+
+ /* 2.4 */
+ if(url->state_override) {
+ url->state = url->state_override;
+ return data_length;
+ }
+
+ /* 2.5 */
+ if(url_entry_scheme->sid == MyURL_SCHEME_ID_FILE)
+ {
+ /* 2.5.1 */
+ if(((data_length + 1) < data_size) &&
+ mycore_strncmp((const char*)(&data[data_length]), "//", 2))
+ {
+ // parse error
+ }
+
+ /* 2.5.2 */
+ url->state = myurl_parser_state_file;
+ }
+ /* 2.6 */
+ else if((url_entry_scheme->type & MyURL_SCHEME_TYPE_SPECIAL) &&
+ url_base != NULL && url_base->scheme.sid == url_entry_scheme->sid && url_base->scheme.type == url_entry_scheme->type)
+ {
+ url->state = myurl_parser_state_special_relative_or_authority;
+ }
+ /* 2.7 */
+ else if(url_entry_scheme->type & MyURL_SCHEME_TYPE_SPECIAL) {
+ url->state = myurl_parser_state_special_authority_slashes;
+ }
+ /* 2.8 */
+ else if(data_length < data_size && data[data_length] == '/') {
+ url->state = myurl_parser_state_path_or_authority;
+ data_length++;
+ }
+ /* 2.9 */
+ else {
+ url_entry->flags |= MyURL_FLAGS_CANNOT_BE_BASE_URL;
+ url->state = myurl_parser_state_cannot_be_a_base_URL_path;
+ }
+
+ return data_length;
+ }
+ /* 3 */
+ else if(url->state_override == NULL) {
+ url->begin = 0;
+ url->state = myurl_parser_state_no_scheme;
+
+ return myurl_parser_skip_control_and_space_leading(data, data_size);
+ }
+
+ /* 4 */
+ // syntax violation, return failure
+ url_entry->status = MyURL_STATUS_FAILURE_SCHEME_STATE;
+ return (data_size + 1);
+ }
+
+ data_length++;
+ }
+
+ if(url->state_override == NULL) {
+ url->begin = 0;
+ url->state = myurl_parser_state_no_scheme;
+
+ return myurl_parser_skip_control_and_space_leading(data, data_size);
+ }
+
+ /* 4 */
+ // syntax violation, return failure
+ url_entry->status = MyURL_STATUS_FAILURE_SCHEME_STATE;
+ return (data_size + 1);
+}
+
+/*
+ * //[user:password@]host[:port][/]path[?query][#fragment]
+ * ~/~/[user:password@]host[:port][/]path[?query][#fragment]
+ */
+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)
+{
+ /* 1 */
+ if(url_base == NULL || ((url_base->flags & MyURL_FLAGS_CANNOT_BE_BASE_URL) &&
+ (data_length >= data_size || data[data_length] != '#')))
+ {
+ // syntax violation, return failure
+ url_entry->status = MyURL_STATUS_FAILURE_NO_SCHEME_BASE_NULL_OR_NOT_HASH;
+ return (data_size + 1);
+ }
+
+ /* 2 */
+ if((url_base->flags & MyURL_FLAGS_CANNOT_BE_BASE_URL) && data_length < data_size && data[data_length] == '#')
+ {
+ if(myurl_scheme_copy(url, &url_base->scheme, &url_entry->scheme) != MyURL_STATUS_OK ||
+ myurl_path_copy(url, &url_base->path, &url_entry->path) != MyURL_STATUS_OK ||
+ myurl_parser_copy_attr(url, url_base, url_entry, query) != MyURL_STATUS_OK)
+ {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ url_entry->query_length = url_base->query_length;
+ url_entry->flags |= MyURL_FLAGS_CANNOT_BE_BASE_URL;
+
+ if(url_entry->fragment)
+ url_entry->fragment = url->callback_free(url_entry->fragment, url->callback_ctx);
+
+ url->state = myurl_parser_state_fragment;
+
+ return (data_length + 1); // skip '#'
+ }
+
+ /* 3 */
+ if(url_base->scheme.sid != MyURL_SCHEME_ID_FILE)
+ url->state = myurl_parser_state_relative;
+ else
+ url->state = myurl_parser_state_file;
+
+ return data_length;
+}
+
+/*
+ * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ * scheme:[~//~[user:password@]host[:port]][/]path[?query][#fragment]
+ */
+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)
+{
+ if((data_length + 1) < data_size && data[data_length] == '/' && data[(data_length + 1)] == '/')
+ {
+ url->state = myurl_parser_state_special_authority_ignore_slashes;
+ data_length += 2;
+ }
+ else {
+ // parse error
+ url->state = myurl_parser_state_relative;
+ }
+
+ return data_length;
+}
+
+/*
+ * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ * scheme:[~//~[user:password@]host[:port]][/]path[?query][#fragment]
+ */
+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)
+{
+ if(data_length < data_size && data[data_length] == '/') {
+ url->state = myurl_parser_state_authority;
+ data_length++;
+ }
+ else {
+ url->state = myurl_parser_state_path;
+ }
+
+ return data_length;
+}
+
+/*
+ * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ * scheme:[//[user:password@]host[:port]][/]path~~[?query][#fragment]
+ */
+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)
+{
+ if(myurl_scheme_copy(url, &url_base->scheme, &url_entry->scheme) != MyURL_STATUS_OK) {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ /* END OF FILE */
+ if(data_length >= data_size)
+ return myurl_parser_state_relative_end(url, url_entry, url_base, data, data_length, data_size);
+
+ switch (data[data_length]) {
+ case '/':
+ url->state = myurl_parser_state_relative_slash;
+ break;
+
+ case '?':
+ if(myurl_parser_copy_attr(url, url_base, url_entry, username) != MyURL_STATUS_OK ||
+ myurl_parser_copy_attr(url, url_base, url_entry, password) != MyURL_STATUS_OK ||
+ myurl_host_copy(url, &url_base->host, &url_entry->host) != MyURL_STATUS_OK ||
+ myurl_path_copy(url, &url_base->path, &url_entry->path) != MyURL_STATUS_OK)
+ {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ url_entry->port = url_base->port;
+ url_entry->port_is_set = url_base->port_is_set;
+
+ myurl_utils_data_set_empty(url, &url_entry->query, &url_entry->query_length);
+
+ url->state = myurl_parser_state_query;
+ break;
+
+ case '#':
+ if(myurl_parser_copy_attr(url, url_base, url_entry, username) != MyURL_STATUS_OK ||
+ myurl_parser_copy_attr(url, url_base, url_entry, password) != MyURL_STATUS_OK ||
+ myurl_parser_copy_attr(url, url_base, url_entry, query) != MyURL_STATUS_OK ||
+ myurl_host_copy(url, &url_base->host, &url_entry->host) != MyURL_STATUS_OK ||
+ myurl_path_copy(url, &url_base->path, &url_entry->path) != MyURL_STATUS_OK)
+ {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ url_entry->port = url_base->port;
+ url_entry->port_is_set = url_base->port_is_set;
+
+ myurl_utils_data_set_empty(url, &url_entry->fragment, &url_entry->fragment_length);
+
+ url->state = myurl_parser_state_fragment;
+ break;
+
+ default:
+ if((url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL) && data[data_length] == '\\')
+ {
+ // parse error
+ url->state = myurl_parser_state_relative_slash;
+ break;
+ }
+
+ if(myurl_parser_copy_attr(url, url_base, url_entry, username) != MyURL_STATUS_OK ||
+ myurl_parser_copy_attr(url, url_base, url_entry, password) != MyURL_STATUS_OK ||
+ myurl_host_copy(url, &url_base->host, &url_entry->host) != MyURL_STATUS_OK ||
+ myurl_path_copy(url, &url_base->path, &url_entry->path) != MyURL_STATUS_OK)
+ {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ myurl_path_pop(&url_entry->path);
+
+ url_entry->port = url_base->port;
+ url_entry->port_is_set = url_base->port_is_set;
+
+ url->state = myurl_parser_state_path;
+ return data_length;
+ }
+
+ return (data_length + 1);
+}
+
+/*
+ * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ */
+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)
+{
+ if(data_length < data_size)
+ {
+ if((url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL) && (data[data_length] == '/' || data[data_length] == '\\'))
+ {
+ if(data[data_length] == '\\') {
+ // parse error
+ }
+
+ url->state = myurl_parser_state_special_authority_ignore_slashes;
+ return (data_length + 1);
+ }
+ else if(data[data_length] == '/') {
+ url->state = myurl_parser_state_authority;
+ return (data_length + 1);
+ }
+ }
+
+ if(myurl_parser_copy_attr(url, url_base, url_entry, username) != MyURL_STATUS_OK ||
+ myurl_parser_copy_attr(url, url_base, url_entry, password) != MyURL_STATUS_OK ||
+ myurl_host_copy(url, &url_base->host, &url_entry->host) != MyURL_STATUS_OK)
+ {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ url_entry->port = url_base->port;
+ url->state = myurl_parser_state_path;
+
+ return data_length;
+}
+
+/*
+ * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ */
+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)
+{
+ if((data_length + 1) < data_size && data[data_length] == '/' && data[(data_length + 1)] == '/') {
+ data_length += 2;
+ }
+ else {
+ // parse error
+ }
+
+ url->state = myurl_parser_state_special_authority_ignore_slashes;
+ return data_length;
+}
+
+/*
+ * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ * scheme:[//~~[user:password@]host[:port]][/]path[?query][#fragment]
+ */
+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)
+{
+ /* END OF FILE */
+ if(data_length >= data_size) {
+ url->begin = 0;
+ url->state = myurl_parser_state_authority;
+ return data_length;
+ }
+
+ while(data_length < data_size) {
+ if(data[data_length] != '/' && data[data_length] != '\\')
+ {
+ url->state = myurl_parser_state_authority;
+ break;
+ }
+ else {
+ // parse error
+ }
+
+ data_length++;
+ }
+
+ return data_length;
+}
+
+/*
+ * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ * scheme:[//[~u~ser:password@]host[:port]][/]path[?query][#fragment]
+ */
+static char * myurl_parser_state_authority_copy_value(myurl_t* url, myurl_entry_t* url_entry, const char* data, size_t data_length, bool is_password)
+{
+ size_t length;
+ char *in_hex_val = myurl_utils_percent_encode(url, data, data_length, myurl_resources_static_map_userinfo, &length);
+
+ if(in_hex_val == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return NULL;
+ }
+
+ if(is_password) {
+ if(myurl_parser_append_buffer(url, in_hex_val, 0, length, url_entry->password)) {
+ url->callback_free(in_hex_val, url->callback_ctx);
+
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return NULL;
+ }
+ }
+ else {
+ if(myurl_parser_append_buffer(url, in_hex_val, 0, length, url_entry->username)) {
+ url->callback_free(in_hex_val, url->callback_ctx);
+
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return NULL;
+ }
+ }
+
+ url->callback_free(in_hex_val, url->callback_ctx);
+
+ return url_entry->username;
+}
+
+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)
+{
+ if(url->begin == 0)
+ url->begin = data_length;
+
+ bool passwordTokenSeenFlag = false;
+
+ while(data_length < data_size) {
+ /* 1 */
+ if(data[data_length] == '@')
+ {
+ /* find last at '@' */
+ size_t i = data_length;
+ while(i < data_size)
+ {
+ if(data[i] == '@')
+ data_length = i;
+
+ i++;
+ }
+
+ /* 1.1 */
+ // parse error
+
+ /* 1.2, 1.3 */
+ url_entry->flags |= MyURL_FLAGS_AT;
+
+ /* 1.4 */
+ i = url->begin;
+ while(i < data_length)
+ {
+ if(data[i] == ':') {
+ passwordTokenSeenFlag = true;
+
+ if(myurl_parser_state_authority_copy_value(url, url_entry, &data[ url->begin ], (i - url->begin), false) == NULL)
+ return (data_size + 1);
+
+ url->begin = i = i + 1;
+ break;
+ }
+
+ i++;
+ }
+
+ if(passwordTokenSeenFlag) {
+ if(myurl_parser_state_authority_copy_value(url, url_entry, &data[ url->begin ], (data_length - url->begin), true) == NULL)
+ return (data_size + 1);
+ }
+ else {
+ if(myurl_parser_state_authority_copy_value(url, url_entry, &data[ url->begin ], (data_length - url->begin), false) == NULL)
+ return (data_size + 1);
+ }
+
+ url->begin = (data_length + 1);
+ }
+ else if((data[data_length] == '/' || data[data_length] == '?' || data[data_length] == '#') ||
+ ((url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL) && data[data_length] == '\\'))
+ {
+ return myurl_parser_state_authority_end(url, url_entry, url_base, data, data_length, data_size);
+ }
+
+ data_length++;
+ }
+
+ /* END OF FILE */
+ return myurl_parser_state_authority_end(url, url_entry, url_base, data, data_length, data_size);
+}
+
+/*
+ * scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
+ * scheme:[//[user:password@]~host~[:port]][/]path[?query][#fragment]
+ */
+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)
+{
+ if(url->begin == 0)
+ url->begin = data_length;
+
+ while(data_length < data_size)
+ {
+ /* 1 */
+ if(url->state_override && url_entry->scheme.sid == MyURL_SCHEME_ID_FILE) {
+ url->state = myurl_parser_state_file_host;
+ return data_length;
+ }
+
+ /* 2 */
+ if(data[data_length] == ':' && (url_entry->flags & MyURL_FLAGS_BRACKET) == 0) {
+ /* 2.1 */
+ if((data_length - url->begin) == 0) {
+ // parse error
+ url_entry->status = MyURL_STATUS_FAILURE_UNEXPECTED_ENDING;
+ return (data_size + 1);
+ }
+
+ /* 1.2 and 1.3 */
+ if(myurl_host_parser(url, &url_entry->host, &data[url->begin], (data_length - url->begin),
+ (url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL)))
+ {
+ url_entry->status = MyURL_STATUS_FAILURE_BAD_HOSTNAME;
+ return (data_size + 1);
+ }
+
+ /* 1.4 */
+ data_length++;
+ url->begin = 0;
+
+ /* 1.5 */
+ if(url->state_override == myurl_parser_state_host_hostname) {
+ return data_size;
+ }
+
+ url->state = myurl_parser_state_port;
+
+ return data_length;
+ }
+
+ /* 3 */
+ else if((data[data_length] == '/' || data[data_length] == '?' || data[data_length] == '#') ||
+ ((url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL) && data[data_length] == '\\'))
+ {
+ return myurl_parser_state_host_hostname_end(url, url_entry, url_base, data, data_length, data_size);
+ }
+ else if(data[data_length] == '[') {
+ url_entry->flags |= MyURL_FLAGS_BRACKET;
+ }
+ else if(data[data_length] == ']') {
+ url_entry->flags ^= (url_entry->flags & MyURL_FLAGS_BRACKET);
+ }
+
+ data_length++;
+ }
+
+ /* END OF FILE */
+ return myurl_parser_state_host_hostname_end(url, url_entry, url_base, data, data_length, 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)
+{
+ if(url->begin == 0)
+ url->begin = data_length;
+
+ while(data_length < data_size)
+ {
+ /* 1 */
+ if(myurl_parser_digit(data[data_length]) == 0)
+ {
+ /* 2 */
+ if((data[data_length] == '/' || data[data_length] == '?' || data[data_length] == '#') ||
+ ((url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL) && data[data_length] == '\\') ||
+ url->state_override)
+ {
+ return myurl_parser_state_port_end(url, url_entry, url_base, data, data_length, data_size);
+ }
+
+ url_entry->status = MyURL_STATUS_FAILURE_BAD_PORT;
+ return (data_size + 1);
+ }
+
+ data_length++;
+ }
+
+ // EOF code point
+ return myurl_parser_state_port_end(url, url_entry, url_base, data, data_length, 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)
+{
+ /* 1 */
+ if(url_entry->scheme.sid != MyURL_SCHEME_ID_FILE)
+ {
+ const myurl_scheme_entry_t *scheme = myurl_scheme_find_entry("file", 4);
+ if(scheme) {
+ url_entry->scheme.name = myurl_utils_data_copy(url, scheme->name, scheme->name_length);
+ if(url_entry->scheme.name == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ url_entry->scheme.length = scheme->name_length;
+ url_entry->scheme.port = scheme->port;
+ url_entry->scheme.sid = scheme->m_id;
+ url_entry->scheme.type = scheme->type;
+ }
+ else {
+ url_entry->status = MyURL_STATUS_FAILURE_SCHEME_STATE;
+ return (data_size + 1);
+ }
+ }
+
+ /* 2 */
+ if(data_length < data_size && (data[data_length] == '/' || data[data_length] == '\\')) {
+ //if(data[data_length] == '\\') {
+ // // parse error
+ //}
+
+ url->state = myurl_parser_state_file_slash;
+ return (data_length + 1);
+ }
+
+
+ /* 3 */
+ if(url_base && url_base->scheme.sid == MyURL_SCHEME_ID_FILE) {
+ /* END OF FILE */
+ if(data_length >= data_size)
+ return myurl_parser_state_file_end(url, url_entry, url_base, data, data_length, data_size);
+
+ if(data[data_length] == '?') {
+ if(myurl_host_copy(url, &url_base->host, &url_entry->host) != MyURL_STATUS_OK ||
+ myurl_path_copy(url, &url_base->path, &url_entry->path) != MyURL_STATUS_OK ||
+ myurl_parser_copy_attr(url, url_base, url_entry, query) != MyURL_STATUS_OK)
+ {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ myurl_utils_data_set_empty(url, &url_entry->query, &url_entry->query_length);
+
+ url->state = myurl_parser_state_query;
+ return (data_length + 1);
+ }
+
+ if(data[data_length] == '#') {
+ if(myurl_host_copy(url, &url_base->host, &url_entry->host) != MyURL_STATUS_OK ||
+ myurl_path_copy(url, &url_base->path, &url_entry->path) != MyURL_STATUS_OK ||
+ myurl_parser_copy_attr(url, url_base, url_entry, query) != MyURL_STATUS_OK)
+ {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ myurl_utils_data_set_empty(url, &url_entry->fragment, &url_entry->fragment_length);
+
+ url->state = myurl_parser_state_fragment;
+ return (data_length + 1);
+ }
+
+ /* 3.1 */
+ size_t sec_rem = data_length + 2;
+ if(
+ /* c and the first code point of remaining are not a Windows drive letter */
+ (myurl_utils_is_windows_drive_letter(data, data_length, data_size)) ||
+
+ /* remaining consists of one code point */
+ (sec_rem == data_size) ||
+
+ /* remaining’s second code point is not "/", "\", "?", or "#" */
+ (
+ sec_rem < data_size &&
+ (data[sec_rem] != '/' && data[sec_rem] != '/' && data[sec_rem] != '?' && data[sec_rem] != '#')
+ ))
+ {
+ if(myurl_host_copy(url, &url_base->host, &url_entry->host) != MyURL_STATUS_OK ||
+ myurl_path_copy(url, &url_base->path, &url_entry->path) != MyURL_STATUS_OK)
+ {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ myurl_path_shorten(&url_entry->path, url_entry->scheme.sid);
+ }
+ //else {
+ // // parse error
+ //}
+ }
+
+ /* 4 */
+ url->state = myurl_parser_state_path;
+ return data_length;
+}
+
+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)
+{
+ /* 1 */
+ if(data_length < data_size && (data[data_length] == '/' || data[data_length] == '\\')) {
+ //if(data[data_length] == '\\') {
+ // // parse error
+ //}
+
+ url->state = myurl_parser_state_file_host;
+ return (data_length + 1);
+ }
+
+ /* 2 */
+ if(url_base && url_base->scheme.sid == MyURL_SCHEME_ID_FILE && url_base->path.list &&
+ myurl_utils_is_windows_drive_letter(url_base->path.list->data, 0, url_base->path.list->length))
+ {
+ /* 2.1 */
+ if(myurl_path_append(url, &url_entry->path, url_base->path.list->data, url_base->path.list->length) == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+ }
+
+ /* 2.2 */
+ url->state = myurl_parser_state_path;
+
+ return data_length;
+}
+
+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)
+{
+ if(url->begin == 0)
+ url->begin = data_length;
+
+ while(data_length < data_size)
+ {
+ /* 1 */
+ if((data[data_length] == '/' || data[data_length] == '\\' || data[data_length] == '?' || data[data_length] == '#')) {
+ return myurl_parser_state_file_host_end(url, url_entry, url_base, data, data_length, data_size);
+ }
+
+ data_length++;
+ }
+
+ // EOF code point
+ return myurl_parser_state_file_host_end(url, url_entry, url_base, data, data_length, 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)
+{
+ /* 1 */
+ if(url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL) {
+ /* 1.1 */
+// if(data[data_length] == '\\') {
+// // parse error
+//
+// }
+
+ /* 1.2 */
+ url->state = myurl_parser_state_path;
+ url->begin = 0;
+
+ /* 1.2 */
+ if(data_length >= data_size || (data[data_length] != '/' && data[data_length] != '\\')) {
+ return data_length;
+ }
+
+ return data_length + 1;
+ }
+
+ /* 4 */
+ if(data_length >= data_size)
+ return data_length;
+
+ /* 2, 3 */
+ if(url->state_override == NULL)
+ {
+ if(data[data_length] == '?') {
+ myurl_utils_data_set_empty(url, &url_entry->query, &url_entry->query_length);
+
+ url->state = myurl_parser_state_query;
+ return (data_length + 1);
+ }
+ else if(data[data_length] == '#') {
+ myurl_utils_data_set_empty(url, &url_entry->fragment, &url_entry->fragment_length);
+
+ url->state = myurl_parser_state_fragment;
+ return (data_length + 1);
+ }
+ }
+
+ /* 4 */
+ url->state = myurl_parser_state_path;
+
+ if(data[data_length] != '/')
+ return data_length;
+
+ return (data_length + 1);
+}
+
+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)
+{
+ if(url->begin == 0)
+ url->begin = data_length;
+
+ while(data_length < data_size)
+ {
+ /* 1 */
+ if(
+ (data[data_length] == '/') ||
+ (url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL && data[data_length] == '\\') ||
+ (url->state_override == NULL && (data[data_length] == '?' || data[data_length] == '#'))
+ )
+ {
+ data_length = myurl_parser_state_path_end(url, url_entry, url_base, data, data_length, data_size);
+
+ if(url->state != myurl_parser_state_path)
+ return data_length;
+
+ url->begin = data_length;
+ }
+ else
+ data_length++;
+
+ /* 2 */
+ /* 2.1 */
+ // If c is not a URL code point and not "%", validation error.
+ //if(data[data_length] == '%') {
+ // // parse error
+ //}
+
+ /* 2.2 */
+ //if((data_length + 2) < data_size && data[data_length] == '%' &&
+ // (mycore_string_chars_hex_map[ (unsigned char)data[(data_length + 1)] ] == 0xff ||
+ // mycore_string_chars_hex_map[ (unsigned char)data[(data_length + 2)] ] == 0xff))
+ //{
+ // // parse error
+ //}
+ }
+
+ return myurl_parser_state_path_end(url, url_entry, url_base, data, data_length, 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)
+{
+ if(url->begin == 0)
+ url->begin = data_length;
+
+ while(data_length < data_size)
+ {
+ /* 1 */
+ if(data[data_length] == '?')
+ {
+ /* 3.3 */
+ if(url->begin < data_length) {
+ myurl_parser_state_cannot_be_a_base_URL_path_end(url, url_entry, url_base, data, data_length, data_size);
+
+ if(url_entry->status)
+ return (data_size + 1);
+ }
+
+ myurl_utils_data_set_empty(url, &url_entry->query, &url_entry->query_length);
+
+ url->state = myurl_parser_state_query;
+ url->begin = 0;
+
+ return (data_length + 1);
+ }
+
+ /* 2 */
+ if(data[data_length] == '#')
+ {
+ /* 3.3 */
+ if(url->begin < data_length) {
+ myurl_parser_state_cannot_be_a_base_URL_path_end(url, url_entry, url_base, data, data_length, data_size);
+
+ if(url_entry->status)
+ return (data_size + 1);
+ }
+
+ myurl_utils_data_set_empty(url, &url_entry->fragment, &url_entry->fragment_length);
+
+ url->state = myurl_parser_state_fragment;
+ url->begin = 0;
+
+ return (data_length + 1);
+ }
+
+ /* 3 */
+ /* 3.1 */
+ // TODO: If c is not EOF code point, not a URL code point, and not "%", validation error.
+ //if(data[data_length] == '%') {
+ // // parse error
+ //}
+
+ /* 3.2 */
+ //if((data_length + 2) < data_size && data[data_length] == '%' &&
+ // (mycore_string_chars_hex_map[ (unsigned char)data[(data_length + 1)] ] == 0xff ||
+ // mycore_string_chars_hex_map[ (unsigned char)data[(data_length + 2)] ] == 0xff))
+ //{
+ // // parse error
+ //}
+
+ data_length++;
+ }
+
+ return myurl_parser_state_cannot_be_a_base_URL_path_end(url, url_entry, url_base, data, data_length, 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)
+{
+ if(url->begin == 0)
+ url->begin = data_length;
+
+ while(data_length < data_size)
+ {
+ /* 1 */
+ if(url->state_override == NULL && data[data_length] == '#')
+ {
+ return myurl_parser_state_query_end(url, url_entry, url_base, data, data_length, data_size);
+ }
+
+ /* 2 */
+ // TODO: If c is not a URL code point and not "%", validation error.
+ //if(data[data_length] == '%') {
+ // // parse error
+ //}
+
+ /* 2.2 */
+ //if((data_length + 2) < data_size && data[data_length] == '%' &&
+ // (mycore_string_chars_hex_map[ (unsigned char)data[(data_length + 1)] ] == 0xff ||
+ // mycore_string_chars_hex_map[ (unsigned char)data[(data_length + 2)] ] == 0xff))
+ //{
+ // // parse error
+ //}
+
+ data_length++;
+ }
+
+ // EOF code point
+ return myurl_parser_state_query_end(url, url_entry, url_base, data, data_length, 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)
+{
+ /* 1.2, 1.3 */
+ size_t buffer_length;
+ char *buffer = myurl_utils_percent_encode(url, &data[ data_length ], (data_size - data_length),
+ myurl_resources_static_map_C0, &buffer_length);
+
+ if(buffer == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ url_entry->fragment = buffer;
+ url_entry->fragment_length = buffer_length;
+
+ return (data_size + 1);
+}
+
+
diff --git a/source/myurl/parser.h b/source/myurl/parser.h
new file mode 100644
index 0000000..62cf69c
--- /dev/null
+++ b/source/myurl/parser.h
@@ -0,0 +1,103 @@
+/*
+ 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_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/source/myurl/parser_end.c b/source/myurl/parser_end.c
new file mode 100644
index 0000000..517a35b
--- /dev/null
+++ b/source/myurl/parser_end.c
@@ -0,0 +1,347 @@
+/*
+ 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/url.h"
+#include "myurl/parser.h"
+#include "myurl/resources.h"
+#include "mycore/utils/resources.h"
+
+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)
+{
+ if(myurl_parser_copy_attr(url, url_base, url_entry, username) != MyURL_STATUS_OK ||
+ myurl_parser_copy_attr(url, url_base, url_entry, password) != MyURL_STATUS_OK ||
+ myurl_parser_copy_attr(url, url_base, url_entry, query) != MyURL_STATUS_OK ||
+ myurl_host_copy(url, &url_base->host, &url_entry->host) != MyURL_STATUS_OK ||
+ myurl_path_copy(url, &url_base->path, &url_entry->path) != MyURL_STATUS_OK)
+ {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ url_entry->port = url_base->port;
+ url_entry->port_is_set = url_base->port_is_set;
+
+ return 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)
+{
+ if((url_entry->flags & MyURL_FLAGS_AT) && (data_length - url->begin) == 0) {
+ // parse error
+ url_entry->status = MyURL_STATUS_FAILURE_AUTHORITY_HOST_AFTER_AUTH;
+ return (data_size + 1);
+ }
+
+ data_length -= (data_length - url->begin);
+
+ url->state = myurl_parser_state_host_hostname;
+ url->begin = 0;
+
+ return data_length;
+}
+
+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)
+{
+ /* 3.1 */
+ if((url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL) && (data_length - url->begin) == 0) {
+ // parse error
+ url_entry->status = MyURL_STATUS_FAILURE_UNEXPECTED_ENDING;
+ return (data_size + 1);
+ }
+
+ /* 3.2 */
+ if(url->state_override && (data_length - url->begin) == 0 &&
+ (myurl_parser_is_includes_credentials(url_entry) || url_entry->port_is_set))
+ {
+ // parse error
+ return (data_size + 1);
+ }
+
+ /* 3.3 and 3.4 */
+ if(myurl_host_parser(url, &url_entry->host, &data[url->begin], (data_length - url->begin),
+ (url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL)))
+ {
+ url_entry->status = MyURL_STATUS_FAILURE_BAD_HOSTNAME;
+ return (data_size + 1);
+ }
+
+ /* 3.6 */
+ if(url->state_override)
+ return (data_size + 1);
+
+ /* 3.5 */
+ url->state = myurl_parser_state_port;
+ url->begin = 0;
+
+ return data_length;
+}
+
+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)
+{
+ /* 2.1 */
+ if((data_length - url->begin))
+ {
+ size_t len = url->begin;
+ unsigned int port = 0;
+
+ /* 2.1.1 */
+ while(len < data_length)
+ {
+ if(port > 65535) {
+ url_entry->status = MyURL_STATUS_FAILURE_BAD_PORT;
+ return (data_size + 1);
+ }
+
+ port = mycore_string_chars_num_map[ (unsigned char)data[len] ] + port * 10;
+ len++;
+ }
+
+ /* 2.1.3 */
+ if(url_entry->scheme.port != port) {
+ url_entry->port = port;
+ url_entry->port_is_set = true;
+ }
+ }
+
+ /* for all 2.1.4 */
+ url->begin = 0;
+
+ /* 2.2 */
+ if(url->state_override)
+ return (data_size + 1);
+
+ /* 2.3 */
+ url->state = myurl_parser_state_path_start;
+
+ return data_length;
+}
+
+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)
+{
+ if(myurl_host_copy(url, &url_base->host, &url_entry->host) != MyURL_STATUS_OK ||
+ myurl_path_copy(url, &url_base->path, &url_entry->path) != MyURL_STATUS_OK ||
+ myurl_parser_copy_attr(url, url_base, url_entry, query) != MyURL_STATUS_OK)
+ {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ return 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)
+{
+ /* 1.1 */
+ if(url->state_override == NULL && myurl_utils_is_windows_drive_letter(data, url->begin, data_size)) {
+ url->state = myurl_parser_state_path;
+ return data_length;
+ }
+
+ /* 1.2 */
+ if((data_length <= url->begin)) {
+ /* 1.2.1 */
+ myurl_host_clean(url, &url_entry->host);
+
+ /* 1.2.2 */
+ if(url->state_override)
+ return (data_size + 1);
+
+ /* 1.2.3 */
+ url->state = myurl_parser_state_path_start;
+ return data_length;
+ }
+
+ /* 1.3 */
+ if(myurl_host_parser(url, &url_entry->host, &data[url->begin], (data_length - url->begin), (url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL))) {
+ url_entry->status = MyURL_STATUS_FAILURE_BAD_HOSTNAME;
+ return (data_size + 1);
+ }
+
+ /* 1.3.3 */
+ if(url_entry->host.type == MyURL_HOST_TYPE_DOMAIN &&
+ url_entry->host.value.domain.length == 9 &&
+ mycore_strncasecmp("localhost", url_entry->host.value.domain.value, url_entry->host.value.domain.length) == 0)
+ {
+ myurl_host_clean(url, &url_entry->host);
+ }
+
+ /* 1.3.5 */
+ if(url->state_override)
+ return (data_size + 1);
+
+ /* 2.1.6 */
+ url->begin = 0;
+ url->state = myurl_parser_state_path_start;
+
+ return data_length;
+}
+
+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)
+{
+ return 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)
+{
+ /* 1.1 */
+ //if(url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL && data[data_length] == '\\') {
+ // // parse error
+ //}
+
+ /* 1.2 */
+ if(myurl_utils_is_double_dot_path_segment(&data[ url->begin ], (data_length - url->begin)))
+ {
+ myurl_path_shorten(&url_entry->path, url_entry->scheme.sid);
+
+ if(data_length >= data_size || (data[data_length] != '/' &&
+ (url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL && data[data_length] == '\\') == 0))
+ {
+ if(myurl_path_push(url, &url_entry->path, NULL, 0) == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR;
+ return (data_size + 1);
+ }
+ }
+ }
+
+ /* 1.3 */
+ else if(myurl_utils_is_single_dot_path_segment(&data[ url->begin ], (data_length - url->begin)))
+ {
+ if(data_length >= data_size || (data[data_length] != '/' &&
+ (url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL && data[data_length] == '\\') == 0))
+ {
+ if(myurl_path_push(url, &url_entry->path, NULL, 0) == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR;
+ return (data_size + 1);
+ }
+ }
+ }
+
+ /* 1.4 */
+ else {
+ bool second_replace = false;
+ /* 1.4.1 */
+ if(url_entry->scheme.sid == MyURL_SCHEME_ID_FILE && url_entry->path.length == 0 &&
+ myurl_utils_is_windows_drive_letter(data, url->begin, data_length))
+ {
+ /* 1.4.1.1 */
+ //if(url_entry->host.type != MyURL_HOST_TYPE_UNDEF) {
+ // // parse error
+ //}
+
+ /* 1.4.1.2 */
+ myurl_host_clean(url, &url_entry->host);
+ second_replace = true;
+ }
+
+ /* 1.4.2 */
+ size_t buffer_length;
+ char *buffer = myurl_utils_percent_encode(url, &data[ url->begin ], (data_length - url->begin),
+ myurl_resources_static_map_path, &buffer_length);
+
+ if(buffer == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ if(myurl_path_push(url, &url_entry->path, buffer, buffer_length) == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ /* 1.4.1.2 */
+ if(second_replace && buffer_length > 1) {
+ buffer[1] = ':';
+ }
+ }
+
+ /* 1.5 */
+ url->begin = 0;
+
+ if(data_length < data_size) {
+ /* 1.6 */
+ if(data[data_length] == '?') {
+ myurl_utils_data_set_null(url, &url_entry->query, &url_entry->query_length);
+ url->state = myurl_parser_state_query;
+ }
+ /* 1.7 */
+ if(data[data_length] == '#') {
+ myurl_utils_data_set_null(url, &url_entry->fragment, &url_entry->fragment_length);
+ url->state = myurl_parser_state_fragment;
+ }
+ }
+
+ return (data_length + 1);
+}
+
+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)
+{
+ if(url->begin < data_length) {
+ size_t buffer_length;
+ char *buffer = myurl_utils_percent_encode(url, &data[ url->begin ], (data_length - url->begin),
+ myurl_resources_static_map_C0, &buffer_length);
+
+ if(buffer == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ if(myurl_path_push(url, &url_entry->path, buffer, buffer_length) == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+ }
+
+ return (data_size + 1);
+}
+
+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)
+{
+ /* 1.1 */
+ if((url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL) == 0 ||
+ url_entry->scheme.sid == MyURL_SCHEME_ID_WS ||
+ url_entry->scheme.sid == MyURL_SCHEME_ID_WSS)
+ {
+ url->encoding = MyENCODING_UTF_8;
+ }
+
+ /* 1.2, 1.3 */
+ size_t buffer_length;
+ char *buffer = myurl_utils_percent_encode(url, &data[ url->begin ], (data_length - url->begin),
+ myurl_resources_static_map_query_charset, &buffer_length);
+
+ if(buffer == NULL) {
+ url_entry->status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ return (data_size + 1);
+ }
+
+ url_entry->query = buffer;
+ url_entry->query_length = buffer_length;
+
+ /* 1.4 */
+ url->begin = 0;
+
+ /* 1.5 */
+ myurl_utils_data_set_null(url, &url_entry->fragment, &url_entry->fragment_length);
+ url->state = myurl_parser_state_fragment;
+
+ return (data_length + 1);
+}
+
+
diff --git a/source/myurl/path.c b/source/myurl/path.c
new file mode 100644
index 0000000..568e6c4
--- /dev/null
+++ b/source/myurl/path.c
@@ -0,0 +1,286 @@
+/*
+ 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/path.h"
+#include "myurl/url.h"
+
+myurl_path_t * myurl_path_create(myurl_t* url)
+{
+ myurl_path_t *path = url->callback_malloc(sizeof(myurl_path_t), url->callback_ctx);
+
+ if(path)
+ memset(path, 0, sizeof(myurl_path_t));
+
+ return path;
+}
+
+mystatus_t myurl_path_init(myurl_t* url, myurl_path_t* path, size_t begin_size)
+{
+ if(begin_size == 0)
+ return MyURL_STATUS_ERROR;
+
+ path->length = 0;
+ path->size = begin_size;
+ path->list = url->callback_malloc(sizeof(myurl_path_entry_t) * path->size, url->callback_ctx);
+
+ if(path->list == NULL)
+ return MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ memset(path->list, 0, sizeof(myurl_path_entry_t) * path->size);
+
+ return MyURL_STATUS_OK;
+}
+
+void myurl_path_clean(myurl_t* url, myurl_path_t* path)
+{
+ for(size_t i = 0; i < path->length; i++) {
+ if(path->list[i].data) {
+ url->callback_free(path->list[i].data, url->callback_ctx);
+ }
+ }
+
+ path->length = 0;
+}
+
+myurl_path_entry_t * myurl_path_entry_destroy(myurl_t* url, myurl_path_entry_t* path, bool destroy_self)
+{
+ if(path == NULL)
+ return NULL;
+
+ if(path->data)
+ url->callback_free(path->data, url->callback_ctx);
+
+ if(destroy_self) {
+ url->callback_free(path, url->callback_ctx);
+ return NULL;
+ }
+
+ return path;
+}
+
+myurl_path_t * myurl_path_destroy(myurl_t* url, myurl_path_t* path, bool destroy_self)
+{
+ if(path == NULL)
+ return NULL;
+
+ if(path->list) {
+ myurl_path_clean(url, path);
+ url->callback_free(path->list, url->callback_ctx);
+ }
+
+ if(destroy_self && path) {
+ return url->callback_free(path, url->callback_ctx);
+ }
+
+ return path;
+}
+
+myurl_path_entry_t * myurl_path_append(myurl_t* url, myurl_path_t* path, const char* data, size_t length)
+{
+ if(path->length >= path->size) {
+ size_t new_size = path->length + 1024;
+
+ myurl_path_entry_t *tmp = url->callback_realloc(path->list, sizeof(myurl_path_entry_t) * new_size, url->callback_ctx);
+
+ if(tmp) {
+ memset(&tmp[path->length], 0, sizeof(myurl_path_entry_t) * (new_size - path->length));
+
+ path->list = tmp;
+ path->size = new_size;
+ }
+ else
+ return NULL;
+ }
+
+ myurl_path_entry_t *entry = &path->list[ path->length ];
+ path->length++;
+
+ if(length) {
+ entry->data = url->callback_malloc(sizeof(char) * length, url->callback_ctx);
+
+ if(entry->data == NULL)
+ return NULL;
+
+ memcpy(entry->data, data, sizeof(char) * length);
+ }
+ else
+ entry->data = NULL;
+
+ entry->length = length;
+ return entry;
+}
+
+myurl_path_entry_t * myurl_path_push(myurl_t* url, myurl_path_t* path, char* data, size_t length)
+{
+ if(path->length >= path->size) {
+ size_t new_size = path->length + 32;
+
+ myurl_path_entry_t *tmp = url->callback_realloc(path->list, sizeof(myurl_path_entry_t) * new_size, url->callback_ctx);
+
+ if(tmp) {
+ memset(&tmp[path->length], 0, sizeof(myurl_path_entry_t) * (new_size - path->length));
+
+ path->list = tmp;
+ path->size = new_size;
+ }
+ else
+ return NULL;
+ }
+
+ myurl_path_entry_t *entry = &path->list[ path->length ];
+ path->length++;
+
+ entry->data = data;
+ entry->length = length;
+
+ return entry;
+}
+
+myurl_path_entry_t * myurl_path_push_to_index(myurl_t* url, myurl_path_t* path, size_t index, char* data, size_t length)
+{
+ if(index >= path->size) {
+ myurl_path_entry_t *tmp = url->callback_realloc(path->list, sizeof(myurl_path_entry_t) * index, url->callback_ctx);
+
+ if(tmp) {
+ memset(&tmp[path->length], 0, sizeof(myurl_path_entry_t) * (index - path->length));
+
+ path->list = tmp;
+ path->size = index;
+ }
+ else
+ return NULL;
+ }
+
+ if(index > path->length)
+ path->length = index;
+
+ if(path->list[ index ].data)
+ url->callback_free(path->list[ index ].data, url->callback_ctx);
+
+ path->list[ index ].data = data;
+ path->list[ index ].length = length;
+
+ return &path->list[ index ];
+}
+
+myurl_path_entry_t * myurl_path_current(myurl_path_t* path)
+{
+ if(path->length == 0)
+ return NULL;
+
+ return &path->list[ (path->length - 1) ];
+}
+
+myurl_path_entry_t * myurl_path_pop(myurl_path_t* path)
+{
+ if(path->length == 0)
+ return NULL;
+
+ path->length--;
+
+ return &path->list[path->length];
+}
+
+void myurl_path_remove_by_index(myurl_t* url, myurl_path_t* path, size_t index)
+{
+ if(path->length == 0 || index >= path->length || path->list == NULL)
+ return;
+
+ myurl_path_entry_destroy(url, &path->list[index], false);
+
+ if((path->length - 1) > index) {
+ memmove(&path->list[index], &path->list[index + 1], sizeof(myurl_path_entry_t) * (path->length - (path->length - index)));
+ }
+
+ path->length--;
+}
+
+mystatus_t myurl_path_copy(myurl_t* url, myurl_path_t* path_from, myurl_path_t* path_to)
+{
+ if(path_from->length >= path_to->size) {
+ size_t new_size = path_from->length + 2;
+
+ myurl_path_entry_t* tmp = url->callback_realloc(path_to->list, sizeof(myurl_path_entry_t) * new_size, url->callback_ctx);
+
+ if(tmp) {
+ memset(&tmp[path_to->length], 0, sizeof(myurl_path_entry_t) * (new_size - path_to->length));
+
+ path_to->list = tmp;
+ path_to->size = new_size;
+ }
+ else
+ return MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
+ myurl_path_entry_t *list_to = path_to->list;
+ myurl_path_entry_t *list_from = path_from->list;
+
+ if(path_to->length > path_from->length)
+ {
+ while(path_to->length > path_from->length) {
+ path_to->length--;
+
+ if(list_to[path_to->length].data)
+ url->callback_free( list_to[path_to->length].data, url->callback_ctx );
+ }
+ }
+
+ path_to->length = path_from->length;
+
+ for(size_t i = 0; i < path_from->length; i++)
+ {
+ if(list_to[i].data)
+ {
+ if(list_to[i].length < list_from[i].length)
+ list_to[i].data = url->callback_realloc(list_to[i].data, (list_from[i].length + 1), url->callback_ctx);
+ }
+ else {
+ list_to[i].data = url->callback_malloc((list_from[i].length + 1), url->callback_ctx);
+ }
+
+ if(list_to[i].data == NULL)
+ return MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ list_to[i].length = list_from[i].length;
+ list_to[i].data[ list_to[i].length ] = '\0';
+
+ if(list_from[i].length) {
+ memcpy(list_to[i].data, list_from[i].data, sizeof(char) * list_from[i].length);
+ }
+ }
+
+ return MyURL_STATUS_OK;
+}
+
+void myurl_path_shorten(myurl_path_t* path, myurl_scheme_id_t scheme_id)
+{
+ if(path->length == 0)
+ return;
+
+ if(scheme_id == MyURL_SCHEME_ID_FILE) {
+ if(path->length == 1 && myurl_utils_is_windows_drive_letter(path->list[0].data, 0, path->list[0].length))
+ return;
+ }
+
+ myurl_path_pop(path);
+}
+
+
+
diff --git a/source/myurl/path.h b/source/myurl/path.h
new file mode 100644
index 0000000..4d8f0c3
--- /dev/null
+++ b/source/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);
+mystatus_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);
+mystatus_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/source/myurl/punycode.c b/source/myurl/punycode.c
new file mode 100644
index 0000000..5ebfa68
--- /dev/null
+++ b/source/myurl/punycode.c
@@ -0,0 +1,395 @@
+/*
+ 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 avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#include "myurl/punycode.h"
+
+mystatus_t myurl_punycode_encode_with_callback(const unsigned char* data, size_t data_size, mycore_string_raw_t* str_raw)
+{
+ size_t i = 0;
+ size_t cp_count = 0;
+
+ while(i < data_size) {
+ size_t n = myencoding_ascii_utf_8_length(data[i]);
+
+ if(n == 1) {
+ str_raw->data[ str_raw->length++ ] = data[i];
+ }
+ else if(n == 0)
+ return MyURL_STATUS_ERROR;
+
+ cp_count++;
+ i += n;
+ }
+
+ if(str_raw->length) {
+ str_raw->data[ str_raw->length++ ] = MyURL_PUNYCODE_CONST_DELIMITER;
+ }
+
+ while(i < data_size) {
+
+ }
+
+ return MyURL_STATUS_OK;
+}
+
+
+///*
+// punycode.c from RFC 3492
+// http://www.nicemice.net/idn/
+// Adam M. Costello
+// http://www.nicemice.net/amc/
+//
+// This is ANSI C code (C89) implementing Punycode (RFC 3492).
+//
+// */
+//
+//
+///************************************************************/
+///* Public interface (would normally go in its own .h file): */
+//
+//#include <limits.h>
+//
+//enum punycode_status {
+// punycode_success,
+// punycode_bad_input, /* Input is invalid. */
+// punycode_big_output, /* Output would exceed the space provided. */
+// punycode_overflow /* Input needs wider integers to process. */
+//};
+//
+//#if UINT_MAX >= (1 << 26) - 1
+//typedef unsigned int punycode_uint;
+//#else
+//typedef unsigned long punycode_uint;
+//#endif
+//
+//enum punycode_status punycode_encode(punycode_uint input_length,
+// const punycode_uint input[],
+// const unsigned char case_flags[],
+// punycode_uint *output_length,
+// char output[] );
+//
+///* punycode_encode() converts Unicode to Punycode. The input */
+///* is represented as an array of Unicode code points (not code */
+///* units; surrogate pairs are not allowed), and the output */
+///* will be represented as an array of ASCII code points. The */
+///* output string is *not* null-terminated; it will contain */
+///* zeros if and only if the input contains zeros. (Of course */
+///* the caller can leave room for a terminator and add one if */
+///* needed.) The input_length is the number of code points in */
+///* the input. The output_length is an in/out argument: the */
+///* caller passes in the maximum number of code points that it */
+///* can receive, and on successful return it will contain the */
+///* number of code points actually output. The case_flags array */
+///* holds input_length boolean values, where nonzero suggests that */
+///* the corresponding Unicode character be forced to uppercase */
+///* after being decoded (if possible), and zero suggests that */
+///* it be forced to lowercase (if possible). ASCII code points */
+///* are encoded literally, except that ASCII letters are forced */
+///* to uppercase or lowercase according to the corresponding */
+///* uppercase flags. If case_flags is a null pointer then ASCII */
+///* letters are left as they are, and other code points are */
+///* treated as if their uppercase flags were zero. The return */
+///* value can be any of the punycode_status values defined above */
+///* except punycode_bad_input; if not punycode_success, then */
+///* output_size and output might contain garbage. */
+//
+//enum punycode_status punycode_decode(punycode_uint input_length,
+// const char input[],
+// punycode_uint *output_length,
+// punycode_uint output[],
+// unsigned char case_flags[] );
+//
+///* punycode_decode() converts Punycode to Unicode. The input is */
+///* represented as an array of ASCII code points, and the output */
+///* will be represented as an array of Unicode code points. The */
+///* input_length is the number of code points in the input. The */
+///* output_length is an in/out argument: the caller passes in */
+///* the maximum number of code points that it can receive, and */
+///* on successful return it will contain the actual number of */
+///* code points output. The case_flags array needs room for at */
+///* least output_length values, or it can be a null pointer if the */
+///* case information is not needed. A nonzero flag suggests that */
+///* the corresponding Unicode character be forced to uppercase */
+///* by the caller (if possible), while zero suggests that it be */
+///* forced to lowercase (if possible). ASCII code points are */
+///* output already in the proper case, but their flags will be set */
+///* appropriately so that applying the flags would be harmless. */
+///* The return value can be any of the punycode_status values */
+///* defined above; if not punycode_success, then output_length, */
+///* output, and case_flags might contain garbage. On success, the */
+///* decoder will never need to write an output_length greater than */
+///* input_length, because of how the encoding is defined. */
+//
+///**********************************************************/
+///* Implementation (would normally go in its own .c file): */
+//
+//#include <string.h>
+//
+///*** Bootstring parameters for Punycode ***/
+//
+//enum { base = 36, tmin = 1, tmax = 26, skew = 38, damp = 700,
+// initial_bias = 72, initial_n = 0x80, delimiter = 0x2D };
+//
+///* basic(cp) tests whether cp is a basic code point: */
+//#define basic(cp) ((punycode_uint)(cp) < 0x80)
+//
+///* delim(cp) tests whether cp is a delimiter: */
+//#define delim(cp) ((cp) == delimiter)
+//
+///* decode_digit(cp) returns the numeric value of a basic code */
+///* point (for use in representing integers) in the range 0 to */
+///* base-1, or base if cp is does not represent a value. */
+//
+//static punycode_uint decode_digit(punycode_uint cp)
+//{
+// return cp - 48 < 10 ? cp - 22 : cp - 65 < 26 ? cp - 65 :
+// cp - 97 < 26 ? cp - 97 : base;
+//}
+//
+///* encode_digit(d,flag) returns the basic code point whose value */
+///* (when used for representing integers) is d, which needs to be in */
+///* the range 0 to base-1. The lowercase form is used unless flag is */
+///* nonzero, in which case the uppercase form is used. The behavior */
+///* is undefined if flag is nonzero and digit d has no uppercase form. */
+//
+//static char encode_digit(punycode_uint d, int flag)
+//{
+// return d + 22 + 75 * (d < 26) - ((flag != 0) << 5);
+// /* 0..25 map to ASCII a..z or A..Z */
+// /* 26..35 map to ASCII 0..9 */
+//}
+//
+///* flagged(bcp) tests whether a basic code point is flagged */
+///* (uppercase). The behavior is undefined if bcp is not a */
+///* basic code point. */
+//
+//#define flagged(bcp) ((punycode_uint)(bcp) - 65 < 26)
+//
+///* encode_basic(bcp,flag) forces a basic code point to lowercase */
+///* if flag is zero, uppercase if flag is nonzero, and returns */
+///* the resulting code point. The code point is unchanged if it */
+///* is caseless. The behavior is undefined if bcp is not a basic */
+///* code point. */
+//
+//static char encode_basic(punycode_uint bcp, int flag)
+//{
+// bcp -= (bcp - 97 < 26) << 5;
+// return bcp + ((!flag && (bcp - 65 < 26)) << 5);
+//}
+//
+///*** Platform-specific constants ***/
+//
+///* maxint is the maximum value of a punycode_uint variable: */
+//static const punycode_uint maxint = -1;
+///* Because maxint is unsigned, -1 becomes the maximum value. */
+//
+///*** Bias adaptation function ***/
+//
+//static punycode_uint adapt(punycode_uint delta, punycode_uint numpoints, int firsttime)
+//{
+// punycode_uint k;
+//
+// delta = firsttime ? delta / damp : delta >> 1;
+// /* delta >> 1 is a faster way of doing delta / 2 */
+// delta += delta / numpoints;
+//
+// for (k = 0; delta > ((base - tmin) * tmax) / 2; k += base) {
+// delta /= base - tmin;
+// }
+//
+// return k + (base - tmin + 1) * delta / (delta + skew);
+//}
+//
+///*** Main encode function ***/
+//
+//enum punycode_status punycode_encode(punycode_uint input_length,
+// const punycode_uint input[],
+// const unsigned char case_flags[],
+// punycode_uint *output_length,
+// char output[] )
+//{
+// punycode_uint n, delta, h, b, out, max_out, bias, j, m, q, k, t;
+//
+// /* Initialize the state: */
+//
+// n = initial_n;
+// delta = out = 0;
+// max_out = *output_length;
+// bias = initial_bias;
+//
+// /* Handle the basic code points: */
+// for (j = 0; j < input_length; ++j) {
+// if (basic(input[j])) {
+// if (max_out - out < 2) return punycode_big_output;
+// output[out++] =
+// case_flags ? encode_basic(input[j], case_flags[j]) : input[j];
+// }
+// /* else if (input[j] < n) return punycode_bad_input; */
+// /* (not needed for Punycode with unsigned code points) */
+// }
+//
+// h = b = out;
+//
+// /* h is the number of code points that have been handled, b is the */
+// /* number of basic code points, and out is the number of characters */
+// /* that have been output. */
+//
+// if (b > 0) output[out++] = delimiter;
+//
+// /* Main encoding loop: */
+//
+// while (h < input_length) {
+// /* All non-basic code points < n have been */
+// /* handled already. Find the next larger one: */
+//
+// for (m = maxint, j = 0; j < input_length; ++j) {
+// /* if (basic(input[j])) continue; */
+// /* (not needed for Punycode) */
+// if (input[j] >= n && input[j] < m) m = input[j];
+// }
+//
+// /* Increase delta enough to advance the decoder's */
+// /* <n,i> state to <m,0>, but guard against overflow: */
+//
+// if (m - n > (maxint - delta) / (h + 1)) return punycode_overflow;
+// delta += (m - n) * (h + 1);
+// n = m;
+//
+// for (j = 0; j < input_length; ++j) {
+// /* Punycode does not need to check whether input[j] is basic: */
+// if (input[j] < n /* || basic(input[j]) */ ) {
+// if (++delta == 0) return punycode_overflow;
+// }
+//
+// if (input[j] == n) {
+// /* Represent delta as a generalized variable-length integer: */
+//
+// for (q = delta, k = base; ; k += base) {
+// if (out >= max_out) return punycode_big_output;
+//
+// t = k <= bias /* + tmin */ ? tmin : /* +tmin not needed */
+// k >= bias + tmax ? tmax : k - bias;
+// if (q < t) break;
+// output[out++] = encode_digit(t + (q - t) % (base - t), 0);
+// q = (q - t) / (base - t);
+// }
+//
+// output[out++] = encode_digit(q, case_flags && case_flags[j]);
+// bias = adapt(delta, h + 1, h == b);
+// delta = 0;
+// ++h;
+// }
+// }
+//
+// ++delta, ++n;
+// }
+//
+// *output_length = out;
+// return punycode_success;
+//}
+//
+///*** Main decode function ***/
+//
+//enum punycode_status punycode_decode(punycode_uint input_length,
+// const char input[],
+// punycode_uint *output_length,
+// punycode_uint output[],
+// unsigned char case_flags[] )
+//{
+// punycode_uint n, out, i, max_out, bias,
+// b, j, in, oldi, w, k, digit, t;
+//
+// /* Initialize the state: */
+//
+// n = initial_n;
+// out = i = 0;
+// max_out = *output_length;
+// bias = initial_bias;
+//
+// /* Handle the basic code points: Let b be the number of input code */
+// /* points before the last delimiter, or 0 if there is none, then */
+// /* copy the first b code points to the output. */
+//
+// for (b = j = 0; j < input_length; ++j) if (delim(input[j])) b = j;
+// if (b > max_out) return punycode_big_output;
+//
+// for (j = 0; j < b; ++j) {
+// if (case_flags) case_flags[out] = flagged(input[j]);
+// if (!basic(input[j])) return punycode_bad_input;
+// output[out++] = input[j];
+// }
+//
+// /* Main decoding loop: Start just after the last delimiter if any */
+// /* basic code points were copied; start at the beginning otherwise. */
+//
+// for (in = b > 0 ? b + 1 : 0; in < input_length; ++out) {
+//
+// /* in is the index of the next character to be consumed, and */
+// /* out is the number of code points in the output array. */
+//
+// /* Decode a generalized variable-length integer into delta, */
+// /* which gets added to i. The overflow checking is easier */
+// /* if we increase i as we go, then subtract off its starting */
+// /* value at the end to obtain delta. */
+//
+// for (oldi = i, w = 1, k = base; ; k += base) {
+// if (in >= input_length) return punycode_bad_input;
+// digit = decode_digit(input[in++]);
+// if (digit >= base) return punycode_bad_input;
+// if (digit > (maxint - i) / w) return punycode_overflow;
+// i += digit * w;
+// t = k <= bias /* + tmin */ ? tmin : /* +tmin not needed */
+// k >= bias + tmax ? tmax : k - bias;
+// if (digit < t) break;
+// if (w > maxint / (base - t)) return punycode_overflow;
+// w *= (base - t);
+// }
+//
+// bias = adapt(i - oldi, out + 1, oldi == 0);
+//
+// /* i was supposed to wrap around from out+1 to 0, */
+// /* incrementing n each time, so we'll fix that now: */
+//
+// if (i / (out + 1) > maxint - n) return punycode_overflow;
+// n += i / (out + 1);
+// i %= (out + 1);
+//
+// /* Insert n at position i of the output: */
+//
+// /* not needed for Punycode: */
+// /* if (decode_digit(n) <= base) return punycode_invalid_input; */
+// if (out >= max_out) return punycode_big_output;
+//
+// if (case_flags) {
+// memmove(case_flags + i + 1, case_flags + i, out - i);
+//
+// /* Case of last character determines uppercase flag: */
+// case_flags[i] = flagged(input[in - 1]);
+// }
+//
+// memmove(output + i + 1, output + i, (out - i) * sizeof *output);
+// output[i++] = n;
+// }
+//
+// *output_length = out;
+// return punycode_success;
+//}
+//
+//
diff --git a/source/myurl/punycode.h b/source/myurl/punycode.h
new file mode 100644
index 0000000..dad8c73
--- /dev/null
+++ b/source/myurl/punycode.h
@@ -0,0 +1,48 @@
+/*
+ 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 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 "myencoding/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/source/myurl/resources.h b/source/myurl/resources.h
new file mode 100644
index 0000000..ea71527
--- /dev/null
+++ b/source/myurl/resources.h
@@ -0,0 +1,180 @@
+/*
+ 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_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/source/myurl/scheme.c b/source/myurl/scheme.c
new file mode 100644
index 0000000..a5142c9
--- /dev/null
+++ b/source/myurl/scheme.c
@@ -0,0 +1,104 @@
+/*
+ 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/url.h"
+#include "myurl/scheme.h"
+#include "myurl/scheme_resources.h"
+#include "mycore/utils/resources.h"
+
+void myurl_scheme_clean(myurl_t* url, myurl_scheme_t* scheme)
+{
+ if(scheme->name)
+ url->callback_free(scheme->name, url->callback_ctx);
+
+ memset(scheme, 0, sizeof(myurl_scheme_t));
+}
+
+myurl_scheme_t * myurl_scheme_destroy(myurl_t* url, myurl_scheme_t* scheme, bool self_destroy)
+{
+ if(scheme == NULL)
+ return NULL;
+
+ if(scheme->name)
+ url->callback_free(scheme->name, url->callback_ctx);
+
+ if(self_destroy) {
+ url->callback_free(scheme, url->callback_ctx);
+ return NULL;
+ }
+
+ return scheme;
+}
+
+const myurl_scheme_entry_t * myurl_scheme_find_entry(const char* name, size_t length)
+{
+ size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] *
+ mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] *
+ length)
+ % MyURL_SCHEME_STATIC_INDEX_LENGTH) + 1;
+
+ while (myurl_scheme_entry_static_index[idx].name)
+ {
+ if(myurl_scheme_entry_static_index[idx].name_length == length) {
+ if(mycore_strncasecmp(myurl_scheme_entry_static_index[idx].name, name, length) == 0)
+ return &myurl_scheme_entry_static_index[idx];
+
+ if(myurl_scheme_entry_static_index[idx].next)
+ idx = myurl_scheme_entry_static_index[idx].next;
+ else
+ return NULL;
+ }
+ else if(myurl_scheme_entry_static_index[idx].name_length > length) {
+ return NULL;
+ }
+ else {
+ idx = myurl_scheme_entry_static_index[idx].next;
+ }
+ }
+
+ return NULL;
+}
+
+myurl_scheme_id_t myurl_scheme_id_by_name(const char *name, size_t length)
+{
+ const myurl_scheme_entry_t *entry = myurl_scheme_find_entry(name, length);
+
+ if(entry)
+ return entry->m_id;
+
+ return MyURL_SCHEME_ID_UNDEF;
+}
+
+mystatus_t myurl_scheme_copy(myurl_t* url, myurl_scheme_t* from, myurl_scheme_t* to)
+{
+ memcpy(to, from, sizeof(myurl_scheme_t));
+
+ if(from->name) {
+ to->name = myurl_utils_data_copy(url, from->name, from->length);
+
+ if(to->name == NULL) {
+ return MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+ }
+
+ return MyURL_STATUS_OK;
+}
+
+
diff --git a/source/myurl/scheme.h b/source/myurl/scheme.h
new file mode 100644
index 0000000..08bd520
--- /dev/null
+++ b/source/myurl/scheme.h
@@ -0,0 +1,78 @@
+/*
+ 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_SCHEME_H
+#define MyURL_SCHEME_H
+#pragma once
+
+#include "myurl/myosi.h"
+#include "myurl/scheme_const.h"
+#include "mycore/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);
+
+mystatus_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/source/myurl/scheme_const.h b/source/myurl/scheme_const.h
new file mode 100644
index 0000000..508c1a5
--- /dev/null
+++ b/source/myurl/scheme_const.h
@@ -0,0 +1,43 @@
+/*
+ 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_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/source/myurl/scheme_resources.h b/source/myurl/scheme_resources.h
new file mode 100644
index 0000000..d408479
--- /dev/null
+++ b/source/myurl/scheme_resources.h
@@ -0,0 +1,64 @@
+/*
+ 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_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/source/myurl/serialization.c b/source/myurl/serialization.c
new file mode 100644
index 0000000..b092f33
--- /dev/null
+++ b/source/myurl/serialization.c
@@ -0,0 +1,221 @@
+/*
+ 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/url.h"
+#include "myhtml/serialization.h"
+
+void myurl_serialization_host(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx)
+{
+ switch (url_entry->host.type) {
+ case MyURL_HOST_TYPE_DOMAIN:
+ callback(url_entry->host.value.domain.value, url_entry->host.value.domain.length, ctx);
+ break;
+
+ case MyURL_HOST_TYPE_IPv4: {
+ char digit_buffer[6];
+ char buffer[17] = {0};
+
+ size_t ipv4_length = 12 + 4;
+ size_t digit_size = 0;
+
+ unsigned int n = url_entry->host.value.ipv.pieces[0];
+
+ for(size_t i = 0; i < 4; i++)
+ {
+ digit_size = myurl_convert_integer_to_data_without_check_buffer(n % 256, digit_buffer);
+
+ if(digit_size <= ipv4_length) {
+ ipv4_length -= digit_size;
+
+ memcpy(&buffer[ipv4_length], digit_buffer, sizeof(char) * digit_size);
+ }
+
+ if(ipv4_length && i != 3) {
+ ipv4_length--;
+ buffer[ipv4_length] = '.';
+ }
+
+ n = (unsigned int)floor((double)n / 256.0f);
+ }
+
+ callback(&buffer[ipv4_length], (16 - ipv4_length), ctx);
+ break;
+ }
+
+ case MyURL_HOST_TYPE_IPv6: {
+ callback("[", 1, ctx);
+
+ /* 1 */
+ unsigned int *pieces = url_entry->host.value.ipv.pieces;
+ unsigned int *compress_pointer = NULL;
+
+ char buffer[128] = {0};
+
+ /* 2, 3 */
+ for(size_t i = 0; i < 7; i++) {
+ if(pieces[i] == 0 && pieces[(i + 1)] == 0) {
+ compress_pointer = &pieces[i];
+ break;
+ }
+ }
+
+ /* 4 */
+ for(size_t i = 0; i < 8; i++) {
+ /* 4.1 */
+ if(compress_pointer == &pieces[i]) {
+
+
+ if(i == 0)
+ callback("::", 2, ctx);
+ else
+ callback(":", 1, ctx);
+
+ i++;
+ while(i < 8) {
+ if(pieces[i] != 0) {
+ i--;
+ break;
+ }
+
+ i++;
+ }
+ }
+ else {
+ /* 4.2 */
+ size_t len = myurl_convert_integer_to_hex_data_without_check_buffer((long)pieces[i], buffer);
+ callback(buffer, len, ctx);
+
+ /* 4.3 */
+ if(i != 7)
+ callback(":", 1, ctx);
+ }
+ }
+
+ callback("]", 1, ctx);
+
+ break;
+ }
+
+ case MyURL_HOST_TYPE_OPAQUE:
+ callback(url_entry->host.value.opaque.value, url_entry->host.value.opaque.length, ctx);
+ break;
+
+ default:
+ break;
+ }
+}
+
+void myurl_serialization_authority(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx)
+{
+ if(url_entry->username_length || url_entry->password_length) {
+ callback(url_entry->username, url_entry->username_length, ctx);
+
+ if(url_entry->password_length) {
+ callback(":", 1, ctx);
+ callback(url_entry->password, url_entry->password_length, ctx);
+ }
+ }
+}
+
+void myurl_serialization_auth_host_port(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx)
+{
+ callback("//", 2, ctx);
+
+ if(url_entry->username_length || url_entry->password_length) {
+ myurl_serialization_authority(url_entry, callback, ctx);
+ callback("@", 1, ctx);
+ }
+
+ myurl_serialization_host(url_entry, callback, ctx);
+
+ if(url_entry->port_is_set) {
+ callback(":", 1, ctx);
+
+ char return_str[128] = {0};
+ size_t length = myurl_convert_integer_to_data_without_check_buffer((long)url_entry->port, return_str);
+
+ callback(return_str, length, ctx);
+ }
+}
+
+void myurl_serialization_path(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx)
+{
+ if(url_entry->flags & MyURL_FLAGS_CANNOT_BE_BASE_URL) {
+ callback(url_entry->path.list[0].data, url_entry->path.list[0].length, ctx);
+ }
+ else {
+ for(size_t i = 0; i < url_entry->path.length; i++) {
+ callback("/", 1, ctx);
+ callback(url_entry->path.list[i].data, url_entry->path.list[i].length, ctx);
+ }
+ }
+}
+
+void myurl_serialization_fragment(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx)
+{
+ if(url_entry->fragment && url_entry->fragment_length)
+ callback(url_entry->fragment, url_entry->fragment_length, ctx);
+}
+
+void myurl_serialization_without_fragment(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx)
+{
+ if(url_entry->scheme.name)
+ callback(url_entry->scheme.name, url_entry->scheme.length, ctx);
+
+ callback(":", 1, ctx);
+
+ if(url_entry->host.type) {
+ myurl_serialization_auth_host_port(url_entry, callback, ctx);
+ }
+ else if(url_entry->scheme.sid == MyURL_SCHEME_ID_FILE) {
+ callback("//", 2, ctx);
+ }
+
+ myurl_serialization_path(url_entry, callback, ctx);
+
+ if(url_entry->query != NULL) {
+ callback("?", 1, ctx);
+
+ if(url_entry->query_length)
+ callback(url_entry->query, url_entry->query_length, ctx);
+ }
+}
+
+void myurl_serialization_with_fragment(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx)
+{
+ myurl_serialization_without_fragment(url_entry, callback, ctx);
+
+ if(url_entry->fragment != NULL) {
+ callback("#", 1, ctx);
+
+ if(url_entry->fragment_length)
+ callback(url_entry->fragment, url_entry->fragment_length, ctx);
+ }
+}
+
+void myurl_serialization(myurl_entry_t* url_entry, bool exclude_fragment_flag, mycore_callback_serialize_f callback, void* ctx)
+{
+ if(exclude_fragment_flag)
+ myurl_serialization_without_fragment(url_entry, callback, ctx);
+ else
+ myurl_serialization_with_fragment(url_entry, callback, ctx);
+}
+
+
diff --git a/source/myurl/serialization.h b/source/myurl/serialization.h
new file mode 100644
index 0000000..ea25906
--- /dev/null
+++ b/source/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, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization_host(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization_auth_host_port(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization_path(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization_fragment(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization_with_fragment(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization_without_fragment(myurl_entry_t* url_entry, mycore_callback_serialize_f callback, void* ctx);
+void myurl_serialization(myurl_entry_t* url_entry, bool exclude_fragment_flag, mycore_callback_serialize_f callback, void* ctx);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* MyURL_SERIALIZATION_H */
diff --git a/source/myurl/url.c b/source/myurl/url.c
new file mode 100644
index 0000000..871eafa
--- /dev/null
+++ b/source/myurl/url.c
@@ -0,0 +1,649 @@
+/*
+ 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/url.h"
+#include "myurl/resources.h"
+
+myurl_t * myurl_create(void)
+{
+ return mycore_calloc(1, sizeof(myurl_t));
+}
+
+mystatus_t myurl_init(myurl_t* url)
+{
+ url->callback_malloc = myurl_callback_malloc;
+ url->callback_free = myurl_callback_free;
+ url->callback_realloc = myurl_callback_realloc;
+ url->callback_ctx = url;
+
+ return MyURL_STATUS_OK;
+}
+
+void myurl_clean(myurl_t* url)
+{
+ memset(url, 0, sizeof(myurl_t));
+}
+
+myurl_t * myurl_destroy(myurl_t* url, bool self_destroy)
+{
+ if(url == NULL)
+ return NULL;
+
+ if(self_destroy) {
+ mycore_free(url);
+ return NULL;
+ }
+
+ return url;
+}
+
+/*
+ * Entry
+ */
+myurl_entry_t * myurl_entry_create_and_init(myurl_t* url)
+{
+ myurl_entry_t *entry = url->callback_malloc(sizeof(myurl_entry_t), url->callback_ctx);
+ if(entry == NULL)
+ return NULL;
+
+ memset(entry, 0, sizeof(myurl_entry_t));
+
+ if(myurl_path_init(url, &entry->path, 56) != MyURL_STATUS_OK) {
+ return url->callback_free(entry, url->callback_ctx);
+ }
+
+ entry->url_ref = url;
+
+ return entry;
+}
+
+void myurl_entry_clean(myurl_entry_t* url_entry)
+{
+ myurl_t* url = url_entry->url_ref;
+
+ if(url_entry->username)
+ url->callback_free(url_entry->username, url->callback_ctx);
+
+ if(url_entry->password)
+ url->callback_free(url_entry->password, url->callback_ctx);
+
+ if(url_entry->query)
+ url->callback_free(url_entry->query, url->callback_ctx);
+
+ if(url_entry->fragment)
+ url->callback_free(url_entry->fragment, url->callback_ctx);
+
+ myurl_host_destroy(url, &url_entry->host, false);
+ myurl_path_destroy(url, &url_entry->path, false);
+ myurl_scheme_destroy(url, &url_entry->scheme, false);
+
+ memset(url_entry, 0, sizeof(myurl_entry_t));
+
+ url_entry->url_ref = url;
+}
+
+myurl_entry_t * myurl_entry_destroy(myurl_entry_t* url_entry, bool self_destroy)
+{
+ if(url_entry == NULL)
+ return NULL;
+
+ myurl_entry_clean(url_entry);
+
+ if(self_destroy) {
+ return url_entry->url_ref->callback_free(url_entry, url_entry->url_ref->callback_ctx);
+ }
+
+ return url_entry;
+}
+
+/*
+ * The CODE
+ */
+myurl_entry_t * myurl_parse(myurl_t* url, const char* data_url, size_t data_url_size, myurl_entry_t* base_url, mystatus_t* status)
+{
+ myurl_entry_t* entry = myurl_entry_create_and_init(url);
+
+ if(entry == NULL) {
+ if(status)
+ *status = MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ return NULL;
+ }
+
+ myurl_parser_begin(url, entry, base_url, data_url, data_url_size);
+
+ if(status)
+ *status = entry->status;
+
+ if(entry->status)
+ return myurl_entry_destroy(entry, true);
+
+ return entry;
+}
+
+/* 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)
+{
+ if(callback_malloc)
+ url->callback_malloc = callback_malloc;
+ else
+ url->callback_malloc = myurl_callback_malloc;
+
+ if(callback_realloc)
+ url->callback_realloc = callback_realloc;
+ else
+ url->callback_realloc = myurl_callback_realloc;
+
+ if(callback_free)
+ url->callback_free = callback_free;
+ else
+ url->callback_free = myurl_callback_free;
+
+ if(ctx)
+ url->callback_ctx = ctx;
+ else
+ url->callback_ctx = url;
+}
+
+void * myurl_callback_memory_context(myurl_t* url)
+{
+ return url->callback_ctx;
+}
+
+/* api entry */
+/* callback for as_string */
+static mystatus_t myurl_entry_host_callback_for_as_string(const char* data, size_t len, void* ctx)
+{
+ myurl_utils_serialization_ctx_t *obj_ctx = ctx;
+
+ if(obj_ctx->error)
+ return MyCORE_STATUS_ERROR;
+
+ if((obj_ctx->length + len + 1) >= obj_ctx->size) {
+ size_t new_size = obj_ctx->length + len + 128;
+
+ char *tmp = obj_ctx->url->callback_realloc(obj_ctx->data, sizeof(char) * new_size,
+ obj_ctx->url->callback_ctx);
+
+ if(tmp) {
+ obj_ctx->size = new_size;
+ obj_ctx->data = tmp;
+ }
+ else
+ obj_ctx->error = true;
+ }
+
+ memcpy(&obj_ctx->data[ obj_ctx->length ], data, sizeof(char) * len);
+ obj_ctx->length += len;
+
+ return MyCORE_STATUS_OK;
+}
+
+static char * myurl_as_string(myurl_entry_t* url_entry, size_t *length, myurl_callback_serialization_func_f func)
+{
+ if(length)
+ *length = 0;
+
+ if(url_entry->url_ref == NULL)
+ return NULL;
+
+ myurl_t* url = url_entry->url_ref;
+ myurl_utils_serialization_ctx_t ctx = {0};
+
+ ctx.size = 128;
+ ctx.data = url->callback_malloc(sizeof(char) * ctx.size, url->callback_ctx);
+ ctx.url = url;
+
+ if(ctx.data == NULL)
+ return NULL;
+
+ func(url_entry, myurl_entry_host_callback_for_as_string, &ctx);
+
+ if(ctx.error) {
+ if(ctx.data)
+ return url->callback_free(ctx.data, url->callback_ctx);
+
+ return NULL;
+ }
+
+ if(length)
+ *length = ctx.length;
+
+ ctx.data[ ctx.length ] = '\0';
+
+ return ctx.data;
+}
+
+mystatus_t myurl_entry_status(myurl_entry_t* url_entry)
+{
+ return url_entry->status;
+}
+
+myurl_flags_t myurl_entry_flags(myurl_entry_t* url_entry)
+{
+ return url_entry->flags;
+}
+
+myurl_t * myurl_entry_url(myurl_entry_t* url_entry)
+{
+ return url_entry->url_ref;
+}
+
+char * myurl_entry_as_string(myurl_entry_t* url_entry, size_t *length)
+{
+ return myurl_as_string(url_entry, length, myurl_serialization_with_fragment);
+}
+
+/* scheme */
+myurl_scheme_t * myurl_entry_scheme(myurl_entry_t* url_entry)
+{
+ return &url_entry->scheme;
+}
+
+const char * myurl_entry_scheme_name(myurl_entry_t* url_entry, size_t* length)
+{
+ if(length)
+ *length = url_entry->scheme.length;
+
+ return url_entry->scheme.name;
+}
+
+unsigned int myurl_entry_scheme_port(myurl_entry_t* url_entry)
+{
+ return (unsigned int)url_entry->scheme.port;
+}
+
+myurl_scheme_id_t myurl_entry_scheme_id(myurl_entry_t* url_entry)
+{
+ return url_entry->scheme.sid;
+}
+
+myurl_scheme_type_t myurl_entry_scheme_type(myurl_entry_t* url_entry)
+{
+ return url_entry->scheme.type;
+}
+
+/* authority */
+char * myurl_entry_authority_as_string(myurl_entry_t* url_entry, size_t* length)
+{
+ return myurl_as_string(url_entry, length, myurl_serialization_authority);
+}
+
+const char * myurl_entry_username(myurl_entry_t* url_entry, size_t *length)
+{
+ if(length)
+ *length = url_entry->username_length;
+
+ return url_entry->username;
+}
+
+const char * myurl_entry_password(myurl_entry_t* url_entry, size_t *length)
+{
+ if(length)
+ *length = url_entry->password_length;
+
+ return url_entry->password;
+}
+
+/* host */
+myurl_host_t * myurl_entry_host(myurl_entry_t* url_entry)
+{
+ return &url_entry->host;
+}
+
+char * myurl_entry_host_as_string(myurl_entry_t* url_entry, size_t *length)
+{
+ return myurl_as_string(url_entry, length, myurl_serialization_host);
+}
+
+myurl_host_type_t myurl_entry_host_type(myurl_entry_t* url_entry)
+{
+ return url_entry->host.type;
+}
+
+const char * myurl_entry_host_domain(myurl_entry_t* url_entry, size_t *length)
+{
+ if(url_entry->host.type != MyURL_HOST_TYPE_DOMAIN) {
+ if(length)
+ *length = 0;
+
+ return NULL;
+ }
+
+ if(length)
+ *length = url_entry->host.value.domain.length;
+
+ return url_entry->host.value.domain.value;
+}
+
+const char * myurl_entry_host_opaque(myurl_entry_t* url_entry, size_t *length)
+{
+ if(url_entry->host.type != MyURL_HOST_TYPE_OPAQUE) {
+ if(length)
+ *length = 0;
+
+ return NULL;
+ }
+
+ if(length)
+ *length = url_entry->host.value.opaque.length;
+
+ return url_entry->host.value.opaque.value;
+}
+
+unsigned int myurl_entry_host_ipv4(myurl_entry_t* url_entry)
+{
+ if(url_entry->host.type != MyURL_HOST_TYPE_IPv4)
+ return 0;
+
+ return url_entry->host.value.ipv.pieces[0];
+}
+
+unsigned int * myurl_entry_host_ipv6(myurl_entry_t* url_entry)
+{
+ if(url_entry->host.type != MyURL_HOST_TYPE_IPv6)
+ return NULL;
+
+ return url_entry->host.value.ipv.pieces;
+}
+
+/* port */
+bool myurl_entry_port_is_defined(myurl_entry_t* url_entry)
+{
+ return url_entry->port_is_set;
+}
+
+unsigned int myurl_entry_port(myurl_entry_t* url_entry)
+{
+ return url_entry->port;
+}
+
+/* path */
+myurl_path_t * myurl_entry_path(myurl_entry_t* url_entry)
+{
+ return &url_entry->path;
+}
+
+char * myurl_entry_path_as_string(myurl_entry_t* url_entry, size_t* length)
+{
+ return myurl_as_string(url_entry, length, myurl_serialization_path);
+}
+
+size_t myurl_entry_path_length(myurl_entry_t* url_entry)
+{
+ return url_entry->path.length;
+}
+
+const char * myurl_entry_path_entry(myurl_entry_t* url_entry, size_t index, size_t *length)
+{
+ if(url_entry->path.length < index) {
+ if(length)
+ *length = 0;
+
+ return NULL;
+ }
+
+ if(length)
+ *length = url_entry->path.list[index].length;
+
+ return url_entry->path.list[index].data;
+}
+
+/* query */
+const char * myurl_entry_query(myurl_entry_t* url_entry, size_t *length)
+{
+ if(length)
+ *length = url_entry->query_length;
+
+ return url_entry->query;
+}
+
+/* fragment */
+const char * myurl_entry_fragment(myurl_entry_t* url_entry, size_t *length)
+{
+ if(length)
+ *length = url_entry->fragment_length;
+
+ return url_entry->fragment;
+}
+
+/*
+ For changes
+*/
+/* scheme */
+const char * myurl_entry_scheme_name_set(myurl_entry_t* url_entry, const char* name, size_t length)
+{
+ if(url_entry->url_ref == NULL)
+ return NULL;
+
+ myurl_t* url = url_entry->url_ref;
+
+ if(myurl_utils_data_copy_set(url, name, length, &url_entry->scheme.name, &url_entry->scheme.length))
+ return NULL;
+
+ return url_entry->scheme.name;
+}
+
+void myurl_entry_scheme_port_set(myurl_entry_t* url_entry, unsigned int port)
+{
+ url_entry->scheme.port = port;
+}
+
+void myurl_entry_scheme_id_set(myurl_entry_t* url_entry, myurl_scheme_id_t sid)
+{
+ url_entry->scheme.sid = sid;
+}
+
+void myurl_entry_scheme_type_set(myurl_entry_t* url_entry, myurl_scheme_type_t type)
+{
+ url_entry->scheme.type = type;
+}
+
+void myurl_entry_scheme_clean(myurl_entry_t* url_entry)
+{
+ if(url_entry->url_ref)
+ myurl_scheme_clean(url_entry->url_ref, &url_entry->scheme);
+}
+
+/* authority */
+const char * myurl_entry_username_set(myurl_entry_t* url_entry, const char* username, size_t length)
+{
+ if(url_entry->url_ref == NULL)
+ return NULL;
+
+ myurl_t* url = url_entry->url_ref;
+
+ if(myurl_utils_data_copy_set(url, username, length, &url_entry->username, &url_entry->username_length))
+ return NULL;
+
+ return url_entry->username;
+}
+
+const char * myurl_entry_password_set(myurl_entry_t* url_entry, const char* password, size_t length)
+{
+ if(url_entry->url_ref == NULL)
+ return NULL;
+
+ myurl_t* url = url_entry->url_ref;
+
+ if(myurl_utils_data_copy_set(url, password, length, &url_entry->password, &url_entry->password_length))
+ return NULL;
+
+ return url_entry->password;
+}
+
+/* host */
+mystatus_t myurl_entry_host_set(myurl_entry_t* url_entry, const char* host, size_t length)
+{
+ if(url_entry->url_ref == NULL)
+ return MyURL_STATUS_ERROR;
+
+ myurl_host_t new_host;
+ memset(&new_host, 0, sizeof(myurl_host_t));
+
+ mystatus_t status = myurl_host_parser(url_entry->url_ref, &new_host, host, length, (url_entry->scheme.type & MyURL_SCHEME_TYPE_SPECIAL));
+
+ if(status)
+ return status;
+
+ myurl_host_clean(url_entry->url_ref, &url_entry->host);
+ url_entry->host = new_host;
+
+ return status;
+}
+
+/* port */
+void myurl_entry_port_set(myurl_entry_t* url_entry, unsigned int port)
+{
+ url_entry->port = port;
+ url_entry->port_is_set = true;
+}
+
+/* path */
+mystatus_t myurl_entry_path_set(myurl_entry_t* url_entry, const char* path, size_t length)
+{
+ if(url_entry->url_ref == NULL || path == NULL)
+ return MyURL_STATUS_ERROR;
+
+ mystatus_t status;
+ myurl_entry_t *new_entry = myurl_parse(url_entry->url_ref, path, length, url_entry, &status);
+
+ if(new_entry) {
+ status = myurl_path_copy(url_entry->url_ref, &new_entry->path, &url_entry->path);
+
+ myurl_entry_destroy(new_entry, true);
+ }
+
+ return status;
+}
+
+mystatus_t myurl_entry_path_append_entry(myurl_entry_t* url_entry, const char* entry, size_t length)
+{
+ if(url_entry->url_ref == NULL || entry == NULL)
+ return MyURL_STATUS_ERROR;
+
+ size_t buffer_length;
+ char *buffer = myurl_utils_percent_encode(url_entry->url_ref, entry, length, myurl_resources_static_map_path, &buffer_length);
+
+ if(buffer == NULL)
+ return MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if(myurl_path_push(url_entry->url_ref, &url_entry->path, buffer, buffer_length) == NULL)
+ return MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ return MyURL_STATUS_OK;
+}
+
+void myurl_entry_path_pop_entry(myurl_entry_t* url_entry)
+{
+ myurl_path_pop(&url_entry->path);
+}
+
+mystatus_t myurl_entry_path_replace_entry(myurl_entry_t* url_entry, size_t index, const char* entry, size_t length)
+{
+ if(url_entry->url_ref == NULL || entry == NULL)
+ return MyURL_STATUS_ERROR;
+
+ size_t buffer_length;
+ char *buffer = myurl_utils_percent_encode(url_entry->url_ref, entry, length, myurl_resources_static_map_path, &buffer_length);
+
+ if(buffer == NULL)
+ return MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if(myurl_path_push_to_index(url_entry->url_ref, &url_entry->path, index, buffer, buffer_length) == NULL)
+ return MyURL_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ return MyURL_STATUS_OK;
+}
+
+void myurl_entry_path_remove_entry(myurl_entry_t* url_entry, size_t index)
+{
+ if(url_entry->url_ref == NULL)
+ return;
+
+ myurl_path_remove_by_index(url_entry->url_ref, &url_entry->path, index);
+}
+
+void myurl_entry_path_clean(myurl_entry_t* url_entry)
+{
+ if(url_entry->url_ref == NULL)
+ return;
+
+ myurl_path_clean(url_entry->url_ref, &url_entry->path);
+}
+
+/* query */
+const char * myurl_entry_query_set(myurl_entry_t* url_entry, const char* query, size_t length)
+{
+ if(url_entry->url_ref == NULL)
+ return NULL;
+
+ myurl_t* url = url_entry->url_ref;
+
+ size_t buffer_length;
+ char *buffer = myurl_utils_percent_encode(url, query, length, myurl_resources_static_map_query_charset, &buffer_length);
+
+ if(buffer == NULL)
+ return NULL;
+
+ if(url_entry->query)
+ url->callback_free(url_entry->query, url->callback_ctx);
+
+ url_entry->query = buffer;
+ url_entry->query_length = buffer_length;
+
+ return url_entry->query;
+}
+
+/* fragment */
+const char * myurl_entry_fragment_set(myurl_entry_t* url_entry, const char* fragment, size_t length)
+{
+ if(url_entry->url_ref == NULL)
+ return NULL;
+
+ myurl_t* url = url_entry->url_ref;
+
+ size_t buffer_length;
+ char *buffer = myurl_utils_percent_encode(url, fragment, length, myurl_resources_static_map_C0, &buffer_length);
+
+ if(buffer == NULL)
+ return NULL;
+
+ if(url_entry->fragment)
+ url->callback_free(url_entry->fragment, url->callback_ctx);
+
+ url_entry->fragment = buffer;
+ url_entry->fragment_length = buffer_length;
+
+ return url_entry->fragment;
+}
+
+/* for free char* */
+void myurl_entry_free_string(myurl_entry_t* url_entry, char* string)
+{
+ if(url_entry->url_ref == NULL)
+ return;
+
+ if(string)
+ url_entry->url_ref->callback_free(string, url_entry->url_ref->callback_ctx);
+}
+
+
diff --git a/source/myurl/url.h b/source/myurl/url.h
new file mode 100644
index 0000000..9877299
--- /dev/null
+++ b/source/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;
+ mystatus_t status;
+
+ myurl_t* url_ref;
+};
+
+struct myhtml_url {
+ /* parser */
+ myurl_state_f state;
+ myurl_state_f state_override;
+ myencoding_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);
+mystatus_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, mystatus_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 */
+mystatus_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 */
+mystatus_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 */
+mystatus_t myurl_entry_path_set(myurl_entry_t* url_entry, const char* path, size_t length);
+mystatus_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);
+mystatus_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/source/myurl/utils.c b/source/myurl/utils.c
new file mode 100644
index 0000000..6c951b9
--- /dev/null
+++ b/source/myurl/utils.c
@@ -0,0 +1,461 @@
+/*
+ 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 avl_treet, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Author: lex.borisov@gmail.com (Alexander Borisov)
+*/
+
+#include "myurl/url.h"
+#include "myurl/utils.h"
+#include "myurl/resources.h"
+#include "mycore/utils/resources.h"
+
+/* data */
+char * myurl_utils_data_copy(myurl_t* url, const char* data, size_t size)
+{
+ char *copy = url->callback_malloc(((sizeof(char) * size) + 1), url->callback_ctx);
+
+ if(copy) {
+ memcpy(copy, data, sizeof(char) * size);
+ copy[size] = '\0';
+ }
+
+ return copy;
+}
+
+mystatus_t myurl_utils_data_copy_set(myurl_t* url, const char* data, size_t size, char** to, size_t* to_length)
+{
+ if(data == NULL) {
+ *to = NULL;
+ *to_length = 0;
+
+ return MyURL_STATUS_OK;
+ }
+
+ char *copy;
+
+ /* mem */
+ if(*to) {
+ if((*to_length + 1) < size)
+ copy = url->callback_realloc(*to, (sizeof(char) * (size + 1)), url->callback_ctx);
+ else
+ copy = *to;
+ }
+ else
+ copy = url->callback_malloc(((sizeof(char) * size) + 1), url->callback_ctx);
+
+ /* process */
+ if(copy) {
+ *to = copy;
+ *to_length = size;
+
+ memcpy(copy, data, sizeof(char) * size);
+
+ copy[size] = '\0';
+ }
+ else {
+ *to_length = 0;
+ return MyURL_STATUS_ERROR;
+ }
+
+ return MyURL_STATUS_OK;
+}
+
+mystatus_t myurl_utils_data_copy_append(myurl_t* url, const char* data, size_t size, char** to, size_t* to_length)
+{
+ if(data == NULL) {
+ if(*to)
+ *to = url->callback_free(*to, url->callback_ctx);
+
+ *to = NULL;
+ *to_length = 0;
+
+ return MyURL_STATUS_OK;
+ }
+
+ char *copy;
+
+ /* mem */
+ if(*to) {
+ if((*to_length + 1) < size)
+ copy = url->callback_realloc(*to, (sizeof(char) * (size + *to_length)) + 1, url->callback_ctx);
+ else
+ copy = *to;
+ }
+ else
+ copy = url->callback_malloc(((sizeof(char) * size) + 1), url->callback_ctx);
+
+ /* process */
+ if(copy) {
+ *to = copy;
+
+ memcpy(&copy[ *to_length ], data, sizeof(char) * size);
+ (*to_length) += size;
+
+ copy[size] = '\0';
+ }
+ else {
+ *to_length = 0;
+ return MyURL_STATUS_ERROR;
+ }
+
+ return MyURL_STATUS_OK;
+}
+
+void myurl_utils_data_set_null(myurl_t* url, char** to, size_t* length)
+{
+ if(*to)
+ *to = url->callback_free(*to, url->callback_ctx);
+
+ if(length)
+ *length = 0;
+}
+
+void myurl_utils_data_set_empty(myurl_t* url, char** to, size_t* length)
+{
+ if(*to == NULL)
+ *to = url->callback_malloc(sizeof(char), url->callback_ctx);
+
+ if(length)
+ *length = 0;
+
+ *to[0] = '\0';
+}
+
+/* converter */
+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 new_size = size;
+ const unsigned char *u_data = (const unsigned char*)data;
+
+ size_t len;
+ for(len = 0; len < size; len++) {
+ if(encode_set[ u_data[len] ] == 0x00)
+ new_size += 2;
+ }
+
+ char *out = url->callback_malloc((sizeof(char) * new_size) + 1, url->callback_ctx);
+ if(out == NULL) {
+ if(return_length)
+ *return_length = 0;
+
+ return NULL;
+ }
+
+ char *out_link = out;
+
+ len = 0;
+ while(len < size)
+ {
+ if(encode_set[ u_data[len] ] == 0x00) {
+ const char *two_hex = mycore_string_char_to_two_hex_value[ u_data[len] ];
+
+ *out = '%'; out++;
+ *out = (char)mycore_string_chars_uppercase_map[ (unsigned char)two_hex[0] ]; out++;
+ *out = (char)mycore_string_chars_uppercase_map[ (unsigned char)two_hex[1] ]; out++;
+ *out = '\0';
+ }
+ else {
+ *out = data[len];
+ out++;
+ }
+
+ len++;
+ }
+
+ *out = '\0';
+
+ if(return_length)
+ *return_length = new_size;
+
+ return out_link;
+}
+
+/* converter */
+size_t myurl_utils_percent_decode_bytes_in_data(char* data, size_t size)
+{
+ unsigned char *u_data = (unsigned char*)data;
+ unsigned char tmp = '\0';
+
+ size_t len = 0, offset = 0;
+ while(len < size)
+ {
+ if(u_data[len] == '%' && (len + 2) < size) {
+ size_t pos = len;
+ len++;
+
+ if(mycore_string_chars_hex_map[ u_data[len] ] != 0xFF &&
+ mycore_string_chars_hex_map[ u_data[(len + 1)] ] != 0xFF)
+ {
+ tmp = mycore_string_chars_hex_map[ u_data[len] ];
+ tmp = (tmp << 4) | mycore_string_chars_hex_map[ u_data[(len + 1)] ];
+
+ u_data[(pos - offset)] = tmp;
+
+ offset += 2;
+ len++;
+ }
+ else {
+ len--;
+
+ if(offset)
+ u_data[(len - offset)] = data[len];
+ }
+
+ len++;
+ }
+ else {
+ if(offset)
+ u_data[(len - offset)] = data[len];
+
+ len++;
+ }
+ }
+
+ if(offset) {
+ size_t new_size = (len - offset);
+ data[new_size] = '\0';
+
+ return new_size;
+ }
+
+ return size;
+}
+
+bool myurl_utils_is_windows_drive_letter(const char* data, size_t length, size_t size)
+{
+ if(data == NULL)
+ return false;
+
+ length++;
+
+ if(length >= size)
+ return false;
+
+ return mycore_string_alpha_character[ (unsigned char)data[(length - 1)] ] != 0xff &&
+ (data[length] == ':' || data[length] == '|');
+}
+
+bool myurl_utils_is_double_dot_path_segment(const char* data, size_t length)
+{
+ if(length < 2)
+ return false;
+
+ if(*data == '.' && data[1] == '.') {
+ if(length == 2)
+ return true;
+
+ return false;
+ }
+
+ if(length < 4)
+ return false;
+
+ if(*data == '.' && data[1] == '%' && data[2] == '2' && data[3] == 'e') {
+ if(length == 4)
+ return true;
+
+ return false;
+ }
+
+ if(*data == '%' && data[1] == '2' && data[2] == 'e' && data[3] == '.') {
+ if(length == 4)
+ return true;
+
+ return false;
+ }
+
+ if(length != 6)
+ return false;
+
+ if(*data == '%' && data[1] == '2' && data[2] == 'e' && data[3] == '%' && data[4] == '2' && data[5] == 'e') {
+ return true;
+ }
+
+ return false;
+}
+
+bool myurl_utils_is_single_dot_path_segment(const char* data, size_t length)
+{
+ if(length < 1)
+ return false;
+
+ if(*data == '.') {
+ if(length == 1)
+ return true;
+
+ return false;
+ }
+
+ if(length != 3)
+ return false;
+
+ if(*data == '%' && data[1] == '2' && data[2] == 'e') {
+ return true;
+ }
+
+ return false;
+}
+
+size_t myurl_convert_integer_to_data_without_check_buffer(long digit, char* return_str)
+{
+ size_t length = 0;
+
+ if(digit != 0) {
+ if(digit < 0) {
+ length++;
+ digit -= digit;
+
+ return_str[0] = '-';
+ }
+
+ /* calc end char count */
+ length += (size_t)floor(log10( labs(digit) )) + 1;
+ }
+ else {
+ return_str[0] = '0';
+ return_str[1] = '\0';
+
+ return 1;
+ }
+
+ for(size_t i = 0; i < length; i++) {
+ return_str[ ((length - i) - 1) ] = (char)myurl_resources_static_map_digits[ digit % 10 ];
+ digit /= 10;
+ }
+
+ return_str[length] = '\0';
+ return length;
+}
+
+size_t myurl_convert_integer_to_hex_data_without_check_buffer(long digit, char* return_str)
+{
+ size_t length = 0;
+
+ if(digit != 0) {
+ if(digit < 0) {
+ length++;
+ digit -= digit;
+
+ return_str[0] = '-';
+ }
+
+ /* calc end char count */
+ long tmp_digit = digit;
+ while(tmp_digit) {length++; tmp_digit /= 16;}
+ }
+ else {
+ return_str[0] = '0';
+ return_str[1] = '\0';
+
+ return 1;
+ }
+
+ size_t tmp_length = length;
+
+ while(digit) {
+ unsigned long temp = digit % 16;
+
+ tmp_length--;
+ if(temp < 10)
+ return_str[tmp_length] = (char)(temp + 48);
+ else
+ return_str[tmp_length] = (char)(temp + 87);
+
+ digit /= 16;
+ }
+
+ return_str[length] = '\0';
+ return length;
+}
+
+//void myurl_utils_data_set(myurl_parser_t* parser, myurl_parser_data_t* parse_data, const unsigned char* data, size_t length)
+//{
+// if(parse_data->data == NULL) {
+// parse_data->size = (length + 1);
+// parse_data->length = length;
+//
+// parse_data->data = (unsigned char*)mchar_async_malloc(parser->mchar, parser->node_idx, parse_data->size);
+// }
+// else if(length >= parse_data->size) {
+// parse_data->size = (length + 1);
+// parse_data->length = length;
+//
+// parse_data->data = (unsigned char*)mchar_async_realloc(parser->mchar, parser->node_idx,
+// (char*)parse_data->data, 0, parse_data->size);
+// }
+//
+// if(data && length) {
+// memcpy(parse_data->data, data, sizeof(unsigned char) * length);
+// }
+//
+// parse_data->data[length] = '\0';
+//}
+//
+//void myurl_utils_data_append(myurl_parser_t* parser, myurl_parser_data_t* parse_data, const unsigned char* data, size_t length)
+//{
+// if(parse_data->data == NULL) {
+// parse_data->size = (length + 1);
+// parse_data->data = (unsigned char*)mchar_async_malloc(parser->mchar, parser->node_idx, parse_data->size);
+// }
+// else if((parse_data->length + length) >= parse_data->size) {
+// parse_data->size = (parse_data->length + length + 1);
+// parse_data->data = (unsigned char*)mchar_async_realloc(parser->mchar, parser->node_idx,
+// (char*)parse_data->data, 0, parse_data->size);
+// }
+//
+// if(data && length) {
+// memcpy(&parse_data->data[parse_data->length], data, sizeof(unsigned char) * length);
+// }
+//
+// parse_data->length = parse_data->length + length;
+// parse_data->data[parse_data->length] = '\0';
+//}
+//
+//void myurl_utils_data_copy(myurl_parser_t* parser, myurl_parser_data_t* to, const myurl_parser_data_t* from)
+//{
+// if(to->data == NULL) {
+// to->size = (from->length + 1);
+// to->length = from->length;
+//
+// to->data = (unsigned char*)mchar_async_malloc(parser->mchar, parser->node_idx, to->size);
+// }
+// else if(from->length >= to->size) {
+// to->size = (from->length + 1);
+// to->length = from->length;
+//
+// to->data = (unsigned char*)mchar_async_realloc(parser->mchar, parser->node_idx,
+// (char*)to->data, 0, to->size);
+// }
+//
+// if(from->data && to->length) {
+// memcpy(to->data, from->data, sizeof(unsigned char) * to->length);
+// }
+//
+// to->data[to->length] = '\0';
+//}
+//
+//void myurl_utils_data_destroy(myurl_parser_t* parser, myurl_parser_data_t* parse_data, bool self_destroy)
+//{
+// mchar_async_free(parser->mchar, parser->node_idx, (char*)parse_data->data);
+//
+// if(self_destroy) {
+// mycore_free(parse_data);
+// }
+//}
+
+
+
diff --git a/source/myurl/utils.h b/source/myurl/utils.h
new file mode 100644
index 0000000..ab67010
--- /dev/null
+++ b/source/myurl/utils.h
@@ -0,0 +1,73 @@
+/*
+ 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 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);
+mystatus_t myurl_utils_data_copy_set(myurl_t* url, const char* data, size_t size, char** to, size_t* to_length);
+mystatus_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/test/Makefile b/test/Makefile
index b7dc66d..e1a8bf1 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,50 +1,90 @@
TARGET := test
-SRCDIR := test
+SRCDIR := .
CC ?= gcc
-LIBS := ../lib/libmodest_static.a
-LDLIBS := $(LIBS)
-INCLUDE_TMP := include
+# ARGS
+#
+# BINARY_OPTIMIZATION_LEVEL, default -O2
+# MODEST_BUILD_WITHOUT_THREADS, YES or (NO or undefined), default undefined
+#
-MODEST_OPTIMIZATION_LEVEL ?= -O2
+.DEFAULT_GOAL := all
-CFLAGS ?= -Wall -Werror
-CFLAGS += $(MODEST_OPTIMIZATION_LEVEL) -Wno-unused-variable -fPIC --std=c99 -I../include
+#********************
+# other Makefile
+#***************
+BINARY_PATH_RELATIVE := ..
+MODEST_SOURCE := $(BINARY_PATH_RELATIVE)/source
+include $(BINARY_PATH_RELATIVE)/Makefile.bin.cfg
-MODEST_BUILD_WITHOUT_THREADS ?= NO
-ifeq ($(MODEST_BUILD_WITHOUT_THREADS),YES)
- $(info Build Tests without POSIX Threads)
-else
- $(info Build Examples with POSIX Threads)
- CFLAGS += -pthread
-endif
+BINARY_TO_DIR := $(BINARY_PATH_RELATIVE)/$(TEST_DIR_BASE)
+TEST_DIR_RELATIVE := $(BINARY_PATH_RELATIVE)/$(TEST_DIR)
-ifeq ($(OS),Windows_NT)
-else
- UNAM := $(shell uname -s)
- ifeq ($(UNAM),Darwin)
- else
- CFLAGS += -D_POSIX_C_SOURCE=199309L
- endif
-endif
+#********************
+# Build
+#***************
+BINARY_BUILD_MODULES ?= $(dir $(wildcard $(SRCDIR)/*/))
+BINARY_BUILD_MODULES_LIST := $(strip $(foreach dir,$(BINARY_BUILD_MODULES),$(word 2, $(subst $(MODEST_DIR_SEPARATOR), , $(dir))) ))
+BINARY_BUILD_MODULES_MAKEFILES_LIST := $(foreach dir,$(BINARY_BUILD_MODULES_LIST),$(dir)/Makefile.mk)
-find_files_h = $(wildcard $(dir)/*.h)
-find_files_c = $(wildcard $(dir)/*.c)
+#********************
+# Targets
+#***************
+BINARY_BUILD_MODULES_TARGET := $(BINARY_BUILD_MODULES_LIST)
+BINARY_BUILD_MODULES_TARGET_ALL := $(foreach dir,$(BINARY_BUILD_MODULES_TARGET),$(dir)_all)
+BINARY_BUILD_MODULES_TARGET_CLEAN := $(foreach dir,$(BINARY_BUILD_MODULES_TARGET),$(dir)_clean)
-SUBDIRS := mycss myhtml myhtml/utils
-HDRS += $(foreach dir,$(SUBDIRS),$(find_files_h))
-SRCS += $(foreach dir,$(SUBDIRS),$(find_files_c))
-#SRCS_FN += $(foreach dir,$(SUBDIRS),$(notdir $(find_files_c)))
+#********************
+# Utils
+#***************
+define BYNARY_UTILS_NEW_LINE
-OBJS := $(patsubst %.c,%,$(SRCS))
-#OBJS_RM := $(patsubst %.c,%,$(SRCS_FN))
-all: $(TARGET)
+endef
+BINARY_UTILS_OBJS = $(patsubst %.c,%,$(foreach dir,$2,$(wildcard $(SRCDIR)/$1/$(dir)/*.c)))
+BINARY_UTILS_CREATE_DIR = mkdir -p $(BINARY_TO_DIR)/$(subst /.,,$1) $(BYNARY_UTILS_NEW_LINE)
+BINARY_UTILS_CREATE_DIRS = $(foreach dir,$(BINARY_BUILD_MODULES_LIST),$(foreach path,$($(dir)_dirs),$(call BINARY_UTILS_CREATE_DIR,$(dir)/$(path))))
-$(TARGET): $(OBJS)
+#********************
+# Include all modules Makefile.mk
+#***************
+include $(BINARY_BUILD_MODULES_MAKEFILES_LIST)
-clean:
- rm -f $(OBJS)
+#********************
+# Set ARGS for flags
+#***************
+override CFLAGS += $(BINARY_CFLAGS)
+override LDFLAGS += $(BINARY_LDFLAGS)
+override LDLIBS += $(BINARY_LIBRARIES)
-.PHONY: all \ No newline at end of file
+#********************
+# Objects
+#***************
+BINARY_BUILD_EXECUTE ?= $(foreach dir,$(BINARY_BUILD_MODULES_TARGET),$($(dir)_objs))
+BINARY_BUILD_EXECUTE_CLEAN := $(foreach path,$(BINARY_BUILD_EXECUTE),$(subst ./,,$(path)))
+BINARY_BUILD_EXECUTE_TO_CLEAN := $(foreach path,$(BINARY_BUILD_EXECUTE_CLEAN),rm -f $(BINARY_TO_DIR)/$(path) $(BYNARY_UTILS_NEW_LINE))
+BINARY_BUILD_DIRS_TO_CLEAN := $(foreach path,$(BINARY_BUILD_MODULES_LIST),rm -rf $(BINARY_TO_DIR)/$(path) $(BYNARY_UTILS_NEW_LINE))
+BINARY_BUILD_EXECUTE_COPY := $(foreach path,$(BINARY_BUILD_EXECUTE_CLEAN),cp $(path) $(BINARY_TO_DIR)/$(dir $(path)) $(BYNARY_UTILS_NEW_LINE))
+BINARY_BUILD_EXECUTE_COPY_ALL := $(BINARY_UTILS_CREATE_DIRS) $(BINARY_BUILD_EXECUTE_COPY)
+BINARY_BUILD_RUN_ALL_TEST := $(foreach dir,$(BINARY_BUILD_EXECUTE_CLEAN),$(dir) $($(word 1,$(subst /, ,$(dir)))_$(notdir $(dir))) $(BYNARY_UTILS_NEW_LINE))
+
+#********************
+# Target options
+#***************
+all: build
+ $(BINARY_BUILD_EXECUTE_COPY_ALL)
+
+build: $(BINARY_BUILD_EXECUTE_CLEAN)
+
+clean: $(BINARY_BUILD_MODULES_TARGET_CLEAN)
+ $(BINARY_BUILD_EXECUTE_TO_CLEAN)
+ $(BINARY_BUILD_DIRS_TO_CLEAN)
+
+copy:
+ $(BINARY_BUILD_EXECUTE_COPY_ALL)
+
+run: all
+ $(BINARY_BUILD_RUN_ALL_TEST)
+
+.PHONY: all copy clean $(BINARY_BUILD_MODULES_TARGET_ALL)
diff --git a/test/mycore/Makefile.mk b/test/mycore/Makefile.mk
new file mode 100644
index 0000000..8c586ab
--- /dev/null
+++ b/test/mycore/Makefile.mk
@@ -0,0 +1,7 @@
+mycore_dirs := utils
+mycore_objs := $(call BINARY_UTILS_OBJS,mycore,$(mycore_dirs))
+
+mycore_all: $(mycore_objs)
+
+mycore_clean:
+ rm -f $(mycore_objs)
diff --git a/test/myhtml/data/encoding/detect_meta.html b/test/mycore/data/encoding/detect_meta.html
index e868f3f..e868f3f 100644
--- a/test/myhtml/data/encoding/detect_meta.html
+++ b/test/mycore/data/encoding/detect_meta.html
diff --git a/test/myhtml/encoding_detect_meta.c b/test/mycore/encoding_detect_meta.c
index 69d694b..f4712fc 100644
--- a/test/myhtml/encoding_detect_meta.c
+++ b/test/mycore/encoding_detect_meta.c
@@ -19,7 +19,7 @@
*/
#include <myhtml/myhtml.h>
-#include <myhtml/encoding.h>
+#include <myencoding/encoding.h>
struct test_res {
char* data;
@@ -60,7 +60,7 @@ test_res_t test_load_file(const char* filename)
size_t nread = fread(file_data, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "Could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "Could not read %ld bytes (" MyCORE_FMT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -116,7 +116,7 @@ void test_entries(const char* filename)
size_t code_begin = 0, code_length = 0;
size_t body_begin = 0;
- myhtml_encoding_t encoding;
+ myencoding_t encoding;
const unsigned char *udata = (const unsigned char*)test_data.data;
printf("Test, get encoding from <meta ...> element:\n");
@@ -135,9 +135,9 @@ void test_entries(const char* filename)
code_length = length - code_begin;
if(strncmp("not-determined", &test_data.data[code_begin], strlen("not-determined")) == 0) {
- encoding = MyHTML_ENCODING_NOT_DETERMINED;
+ encoding = MyENCODING_NOT_DETERMINED;
}
- else if(myhtml_encoding_by_name(&test_data.data[code_begin], code_length, &encoding) == false) {
+ else if(myencoding_by_name(&test_data.data[code_begin], code_length, &encoding) == false) {
fprintf(stderr, "Can't get encoding from test header: %.*s\n", (int)code_length, &test_data.data[code_begin]);
exit(EXIT_FAILURE);
}
@@ -149,7 +149,7 @@ void test_entries(const char* filename)
/* get end of body */
length = test_find_body_end(udata, length, test_data.size);
- myhtml_encoding_t find_encoding = myhtml_encoding_prescan_stream_to_determine_encoding(&test_data.data[body_begin], (length - body_begin));
+ myencoding_t find_encoding = myencoding_prescan_stream_to_determine_encoding(&test_data.data[body_begin], (length - body_begin));
if(find_encoding != encoding) {
fprintf(stderr, "ERROR! WRONG! ACHTUNG! Header Encoding not equally Encoding after parsing body\n");
diff --git a/test/myhtml/utils/avl_tree.c b/test/mycore/utils/avl_tree.c
index fee0aff..a01dc29 100644
--- a/test/myhtml/utils/avl_tree.c
+++ b/test/mycore/utils/avl_tree.c
@@ -18,19 +18,19 @@
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
-#include <myhtml/utils/avl_tree.h>
+#include <mycore/utils/avl_tree.h>
#define test_exit fprintf(stderr, "ERROR! Wrong tree construction!\n"); exit(EXIT_FAILURE);
-myhtml_utils_avl_tree_t * avl_tree_create(void)
+mycore_utils_avl_tree_t * avl_tree_create(void)
{
- myhtml_utils_avl_tree_t *avl_tree = myhtml_utils_avl_tree_create();
+ mycore_utils_avl_tree_t *avl_tree = mycore_utils_avl_tree_create();
if(avl_tree == NULL) {
fprintf(stderr, "Can't allocate memory for AVL-Tree object\n");
exit(EXIT_FAILURE);
}
- if(myhtml_utils_avl_tree_init(avl_tree)) {
+ if(mycore_utils_avl_tree_init(avl_tree)) {
fprintf(stderr, "Can't init AVL-Tree object\n");
exit(EXIT_FAILURE);
}
@@ -38,7 +38,7 @@ myhtml_utils_avl_tree_t * avl_tree_create(void)
return avl_tree;
}
-void test_for_three(myhtml_utils_avl_tree_node_t *find_node)
+void test_for_three(mycore_utils_avl_tree_node_t *find_node)
{
/* 1 */
if(find_node->type != 1) {test_exit}
@@ -65,111 +65,111 @@ void test_for_three(myhtml_utils_avl_tree_node_t *find_node)
void avl_tree_test_3_0(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
if(root_node == NULL || root_node->type != 2) {test_exit}
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
test_for_three(find_node);
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_3_1(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
if(root_node == NULL || root_node->type != 2) {test_exit}
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
test_for_three(find_node);
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_3_2(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
if(root_node == NULL || root_node->type != 2) {test_exit}
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
test_for_three(find_node);
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_3_3(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
if(root_node == NULL || root_node->type != 2) {test_exit}
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
test_for_three(find_node);
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_3_4(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
if(root_node == NULL || root_node->type != 2) {test_exit}
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
test_for_three(find_node);
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_3_5(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
if(root_node == NULL || root_node->type != 2) {test_exit}
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
test_for_three(find_node);
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_4(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
/* 1 */
if(find_node->type != 1) {test_exit}
@@ -201,21 +201,21 @@ void avl_tree_test_4(void)
if(find_node->right != NULL) {test_exit}
if(find_node->parent == NULL || find_node->parent->type != 3) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_5(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
/* 1 */
if(find_node->type != 1) {test_exit}
@@ -255,24 +255,24 @@ void avl_tree_test_5(void)
if(find_node->right != NULL) {test_exit}
if(find_node->parent == NULL || find_node->parent->type != 4) {test_exit}
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 4);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 4);
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_delete_1L(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 1);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 1);
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 2);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 2);
/* 2 */
if(find_node->type != 2) {test_exit}
@@ -296,22 +296,22 @@ void avl_tree_test_delete_1L(void)
if(find_node->right != NULL) {test_exit}
if(find_node->parent == NULL || find_node->parent->type != 3) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_delete_1R(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 4);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 4);
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
/* 1 */
if(find_node->type != 1) {test_exit}
@@ -335,22 +335,22 @@ void avl_tree_test_delete_1R(void)
if(find_node->right != NULL) {test_exit}
if(find_node->parent == NULL || find_node->parent->type != 2) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_delete_2L(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 1);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 1);
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 2);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 2);
/* 2 */
if(find_node->type != 2) {test_exit}
@@ -374,22 +374,22 @@ void avl_tree_test_delete_2L(void)
if(find_node->right != NULL) {test_exit}
if(find_node->parent == NULL || find_node->parent->type != 3) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_delete_2R(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 4);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 4);
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
/* 1 */
if(find_node->type != 1) {test_exit}
@@ -413,25 +413,25 @@ void avl_tree_test_delete_2R(void)
if(find_node->right != NULL) {test_exit}
if(find_node->parent == NULL || find_node->parent->type != 2) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_delete_sub_1L(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 1);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 1);
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 2);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 2);
/* 2 */
if(find_node->type != 2) {test_exit}
@@ -479,25 +479,25 @@ void avl_tree_test_delete_sub_1L(void)
if(find_node->right != NULL) {test_exit}
if(find_node->parent == NULL || find_node->parent->type != 6) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_delete_sub_1R(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 7);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 7);
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 1);
/* 1 */
if(find_node->type != 1) {test_exit}
@@ -545,28 +545,28 @@ void avl_tree_test_delete_sub_1R(void)
if(find_node->right != NULL) {test_exit}
if(find_node->parent == NULL || find_node->parent->type != 5) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_delete_10_0(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 8, (void*)(8));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 9, (void*)(9));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 10, (void*)(10));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 8, (void*)(8));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 9, (void*)(9));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 10, (void*)(10));
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 8);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 8);
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 4);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 4);
if(find_node->type != 4) {test_exit}
if(find_node->parent != NULL) {test_exit}
@@ -581,29 +581,29 @@ void avl_tree_test_delete_10_0(void)
if(find_node->right->left->left->type != 5) {test_exit}
if(find_node->right->right->right->type != 10) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_delete_10_1(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 8, (void*)(8));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 9, (void*)(9));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 10, (void*)(10));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 8, (void*)(8));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 9, (void*)(9));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 10, (void*)(10));
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 8);
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 5);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 8);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 5);
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 4);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 4);
if(find_node->type != 4) {test_exit}
if(find_node->parent != NULL) {test_exit}
@@ -617,29 +617,29 @@ void avl_tree_test_delete_10_1(void)
if(find_node->right->right->type != 9) {test_exit}
if(find_node->right->right->right->type != 10) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_delete_10_2(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 8, (void*)(8));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 9, (void*)(9));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 10, (void*)(10));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 8, (void*)(8));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 9, (void*)(9));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 10, (void*)(10));
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 8);
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 6);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 8);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 6);
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 4);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 4);
if(find_node->type != 4) {test_exit}
if(find_node->parent != NULL) {test_exit}
@@ -653,28 +653,28 @@ void avl_tree_test_delete_10_2(void)
if(find_node->right->right->type != 9) {test_exit}
if(find_node->right->right->right->type != 10) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_delete_10_3(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 8, (void*)(8));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 9, (void*)(9));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 10, (void*)(10));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 8, (void*)(8));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 9, (void*)(9));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 10, (void*)(10));
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 9);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 9);
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 4);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 4);
if(find_node->type != 4) {test_exit}
if(find_node->parent != NULL) {test_exit}
@@ -689,28 +689,28 @@ void avl_tree_test_delete_10_3(void)
if(find_node->right->left->left->type != 5) {test_exit}
if(find_node->right->left->right->type != 7) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_delete_10_4(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 8, (void*)(8));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 9, (void*)(9));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 10, (void*)(10));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 8, (void*)(8));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 9, (void*)(9));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 10, (void*)(10));
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 4);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 4);
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 3);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 3);
if(find_node->type != 3) {test_exit}
if(find_node->parent != NULL) {test_exit}
@@ -725,28 +725,28 @@ void avl_tree_test_delete_10_4(void)
if(find_node->right->left->right->type != 7) {test_exit}
if(find_node->right->right->right->type != 10) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
void avl_tree_test_delete_10_5(void)
{
- myhtml_utils_avl_tree_t *avl_tree = avl_tree_create();
- myhtml_utils_avl_tree_node_t *root_node = NULL;
+ mycore_utils_avl_tree_t *avl_tree = avl_tree_create();
+ mycore_utils_avl_tree_node_t *root_node = NULL;
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 8, (void*)(8));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 9, (void*)(9));
- myhtml_utils_avl_tree_add(avl_tree, &root_node, 10, (void*)(10));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 1, (void*)(1));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 2, (void*)(2));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 3, (void*)(3));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 4, (void*)(4));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 5, (void*)(5));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 6, (void*)(6));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 7, (void*)(7));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 8, (void*)(8));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 9, (void*)(9));
+ mycore_utils_avl_tree_add(avl_tree, &root_node, 10, (void*)(10));
- myhtml_utils_avl_tree_delete(avl_tree, &root_node, 6);
+ mycore_utils_avl_tree_delete(avl_tree, &root_node, 6);
- myhtml_utils_avl_tree_node_t *find_node = myhtml_utils_avl_tree_search_by_type(avl_tree, root_node, 4);
+ mycore_utils_avl_tree_node_t *find_node = mycore_utils_avl_tree_search_by_type(avl_tree, root_node, 4);
if(find_node->type != 4) {test_exit}
if(find_node->parent != NULL) {test_exit}
@@ -761,12 +761,12 @@ void avl_tree_test_delete_10_5(void)
if(find_node->right->left->right->type != 7) {test_exit}
if(find_node->right->right->right->type != 10) {test_exit}
- avl_tree = myhtml_utils_avl_tree_destroy(avl_tree, true);
+ avl_tree = mycore_utils_avl_tree_destroy(avl_tree, true);
}
int main(int argc, const char * argv[])
{
- myhtml_utils_avl_tree_t *avl_tree = myhtml_utils_avl_tree_create();
+ mycore_utils_avl_tree_t *avl_tree = mycore_utils_avl_tree_create();
avl_tree_test_3_0();
avl_tree_test_3_1();
diff --git a/test/mycss/Makefile.mk b/test/mycss/Makefile.mk
new file mode 100644
index 0000000..86ccb10
--- /dev/null
+++ b/test/mycss/Makefile.mk
@@ -0,0 +1,9 @@
+mycss_dirs := .
+mycss_objs := $(call BINARY_UTILS_OBJS,mycss,$(mycss_dirs))
+
+mycss_all: $(mycss_objs)
+
+mycss_clean:
+ rm -f $(mycss_objs)
+
+mycss_declaration := $(TEST_DIR_RELATIVE)/mycss/data/declaration
diff --git a/test/mycss/declaration.c b/test/mycss/declaration.c
index dfc46a3..13f74b1 100644
--- a/test/mycss/declaration.c
+++ b/test/mycss/declaration.c
@@ -90,7 +90,7 @@ test_res_t test_load_file(const char* filename)
size_t nread = fread(file_data, 1, size, fh);
if (nread != size) {
- fprintf(stderr, "Could not read %ld bytes (%zu bytes done)\n", size, nread);
+ fprintf(stderr, "Could not read %ld bytes (" MyCORE_FORMAT_Z " bytes done)\n", size, nread);
exit(EXIT_FAILURE);
}
@@ -99,29 +99,29 @@ test_res_t test_load_file(const char* filename)
return (test_res_t){file_data, (size_t)size};
}
-void test_init_str_raw(myhtml_string_raw_t* str, size_t size)
+void test_init_str_raw(mycore_string_raw_t* str, size_t size)
{
str->size = size;
str->length = 0;
- str->data = (char*)myhtml_malloc(str->size * sizeof(char));
+ str->data = (char*)mycore_malloc(str->size * sizeof(char));
if(str->data == NULL) {
- fprintf(stderr, "Can't allocation resources for myhtml_string_raw_t object\n");
+ fprintf(stderr, "Can't allocation resources for mycore_string_raw_t object\n");
exit(EXIT_FAILURE);
}
}
-void test_reallocate_str(myhtml_string_raw_t *str, size_t size)
+void test_reallocate_str(mycore_string_raw_t *str, size_t size)
{
- str->data = (char*)myhtml_realloc(str->data, size * sizeof(char));
+ str->data = (char*)mycore_realloc(str->data, size * sizeof(char));
if(str->data == NULL) {
- fprintf(stderr, "Can't reallocation resources for myhtml_string_raw_t object\n");
+ fprintf(stderr, "Can't reallocation resources for mycore_string_raw_t object\n");
exit(EXIT_FAILURE);
}
}
-void test_str_set_term(myhtml_string_raw_t *str)
+void test_str_set_term(mycore_string_raw_t *str)
{
if((str->length + 1) >= str->size)
test_reallocate_str(str, 64);
@@ -129,11 +129,11 @@ void test_str_set_term(myhtml_string_raw_t *str)
str->data[ str->length ] = '\0';
}
-myhtml_string_raw_t test_combine_to_style(const char* one, size_t one_len, const char* two, size_t two_len)
+mycore_string_raw_t test_combine_to_style(const char* one, size_t one_len, const char* two, size_t two_len)
{
size_t new_size = one_len + two_len;
- myhtml_string_raw_t str = {0};
+ mycore_string_raw_t str = {0};
test_init_str_raw(&str, (new_size + 2));
memcpy(str.data, one, sizeof(char) * one_len);
@@ -239,7 +239,7 @@ test_stat_t test_read_dir(const char* dir_path, test_read_dir_callback_f callbac
continue;
result_stat.total++;
- printf("%zu) %s: ", result_stat.total, ent->d_name);
+ printf(MyCORE_FORMAT_Z ") %s: ", result_stat.total, ent->d_name);
if(callback(path, (strlen(ent->d_name) + path_len + 1), context)) {
result_stat.good++;
@@ -254,9 +254,9 @@ test_stat_t test_read_dir(const char* dir_path, test_read_dir_callback_f callbac
/* test */
bool test_process_elements(test_data_t *test_data, myhtml_collection_t *collection, test_stat_t* result_stat);
-myhtml_string_raw_t test_process_result_from_node(test_data_t *test_data, myhtml_tree_node_t *node);
-myhtml_string_raw_t test_process_serialize_stype(test_data_t *test_data, const char* style, size_t style_size);
-void test_process_serialize_callback(const char* buffer, size_t size, void* ctx);
+mycore_string_raw_t test_process_result_from_node(test_data_t *test_data, myhtml_tree_node_t *node);
+mycore_string_raw_t test_process_serialize_stype(test_data_t *test_data, const char* style, size_t style_size);
+mystatus_t test_process_serialize_callback(const char* buffer, size_t size, void* ctx);
bool test_process_callback(const char* filename, size_t filename_len, void* context)
{
@@ -265,7 +265,7 @@ bool test_process_callback(const char* filename, size_t filename_len, void* cont
test_stat_t result_stat = {0};
/* parse html */
- myhtml_status_t status = myhtml_parse(test_data->tree, MyHTML_ENCODING_UTF_8, html_data.data, html_data.size);
+ myhtml_status_t status = myhtml_parse(test_data->tree, MyENCODING_UTF_8, html_data.data, html_data.size);
if(status) {
fprintf(stderr, "Could parse HTML from file %s error code %d\n", filename, status);
exit(EXIT_FAILURE);
@@ -283,12 +283,12 @@ bool test_process_callback(const char* filename, size_t filename_len, void* cont
printf("\tResult: ");
}
- printf("count(%zu) good(%zu) bad(%zu)\n", result_stat.total, result_stat.good, (result_stat.total - result_stat.good));
+ printf("count(" MyCORE_FORMAT_Z ") good(" MyCORE_FORMAT_Z ") bad(" MyCORE_FORMAT_Z ")\n", result_stat.total, result_stat.good, (result_stat.total - result_stat.good));
test_data->stat.good += result_stat.good;
test_data->stat.total += result_stat.total;
- myhtml_free(html_data.data);
+ mycore_free(html_data.data);
return true;
}
@@ -306,10 +306,10 @@ bool test_process_elements(test_data_t *test_data, myhtml_collection_t *collecti
const char* name = myhtml_attribute_value(attr_name, &name_length);
const char* value = myhtml_attribute_value(attr_value, &value_length);
- myhtml_string_raw_t style = test_combine_to_style(name, name_length, value, value_length);
+ mycore_string_raw_t style = test_combine_to_style(name, name_length, value, value_length);
- myhtml_string_raw_t correct_result = test_process_result_from_node(test_data, node);
- myhtml_string_raw_t parse_result = test_process_serialize_stype(test_data, style.data, style.length);
+ mycore_string_raw_t correct_result = test_process_result_from_node(test_data, node);
+ mycore_string_raw_t parse_result = test_process_serialize_stype(test_data, style.data, style.length);
result_stat->total++;
@@ -326,9 +326,9 @@ bool test_process_elements(test_data_t *test_data, myhtml_collection_t *collecti
printf("\tBad: name=\"%s\" value=\"%s\" need=\"%s\" result=\"%s\"\n", name, value, correct_result.data, parse_result.data);
}
- myhtml_string_raw_destroy(&style, false);
- myhtml_string_raw_destroy(&correct_result, false);
- myhtml_string_raw_destroy(&parse_result, false);
+ mycore_string_raw_destroy(&style, false);
+ mycore_string_raw_destroy(&correct_result, false);
+ mycore_string_raw_destroy(&parse_result, false);
mycss_entry_clean_all(test_data->entry);
}
@@ -336,11 +336,11 @@ bool test_process_elements(test_data_t *test_data, myhtml_collection_t *collecti
return true;
}
-myhtml_string_raw_t test_process_result_from_node(test_data_t *test_data, myhtml_tree_node_t *node)
+mycore_string_raw_t test_process_result_from_node(test_data_t *test_data, myhtml_tree_node_t *node)
{
- myhtml_string_raw_t str = {0};
+ mycore_string_raw_t str = {0};
- if(myhtml_serialization_node_buffer(node->child, &str) == false) {
+ if(myhtml_serialization_node_buffer(node->child, &str)) {
fprintf(stderr, "Could serialization HTML node\n");
exit(EXIT_FAILURE);
}
@@ -348,13 +348,13 @@ myhtml_string_raw_t test_process_result_from_node(test_data_t *test_data, myhtml
return str;
}
-myhtml_string_raw_t test_process_serialize_stype(test_data_t *test_data, const char* style, size_t style_size)
+mycore_string_raw_t test_process_serialize_stype(test_data_t *test_data, const char* style, size_t style_size)
{
- myhtml_string_raw_t str;
+ mycore_string_raw_t str;
test_init_str_raw(&str, 4096);
mycss_status_t status;
- mycss_declaration_entry_t *declaration = mycss_declaration_parse(test_data->entry->declaration, MyHTML_ENCODING_UTF_8, style, style_size, &status);
+ mycss_declaration_entry_t *declaration = mycss_declaration_parse(test_data->entry->declaration, MyENCODING_UTF_8, style, style_size, &status);
if(status) {
fprintf(stderr, "Could parse CSS Style (%d): %s\n", status, style);
@@ -367,15 +367,17 @@ myhtml_string_raw_t test_process_serialize_stype(test_data_t *test_data, const c
return str;
}
-void test_process_serialize_callback(const char* buffer, size_t size, void* ctx)
+mystatus_t test_process_serialize_callback(const char* buffer, size_t size, void* ctx)
{
- myhtml_string_raw_t *str = (myhtml_string_raw_t*)ctx;
+ mycore_string_raw_t *str = (mycore_string_raw_t*)ctx;
if((str->length + size) >= str->size)
test_reallocate_str(str, 4096);
memcpy(&str->data[ str->length ], buffer, sizeof(char) * size);
str->length += size;
+
+ return MyCORE_STATUS_OK;
}
int main(int argc, const char * argv[])
@@ -398,7 +400,7 @@ int main(int argc, const char * argv[])
test_read_dir(argv[1], test_process_callback, &test_data);
size_t bad_count = (test_data.stat.total - test_data.stat.good);
- printf("\nTotal: %zu; Good: %zu; Bad: %zu\n", test_data.stat.total, test_data.stat.good, bad_count);
+ printf("\nTotal: " MyCORE_FORMAT_Z "; Good: " MyCORE_FORMAT_Z "; Bad: " MyCORE_FORMAT_Z "\n", test_data.stat.total, test_data.stat.good, bad_count);
test_declaration_destroy_myhtml(test_data.tree);
test_declaration_destroy_mycss(test_data.entry);
diff --git a/test/myencoding/Makefile.mk b/test/myencoding/Makefile.mk
new file mode 100644
index 0000000..fa4ab02
--- /dev/null
+++ b/test/myencoding/Makefile.mk
@@ -0,0 +1,9 @@
+myencoding_dirs := .
+myencoding_objs := $(call BINARY_UTILS_OBJS,myencoding,$(myencoding_dirs))
+
+myencoding_all: $(myencoding_objs)
+
+myencoding_clean:
+ rm -f $(myencoding_objs)
+
+myencoding_encoding_detect_meta := $(TEST_DIR_RELATIVE)/myencoding/data/encoding/detect_meta.html
diff --git a/test/myencoding/data/encoding/detect_meta.html b/test/myencoding/data/encoding/detect_meta.html
new file mode 100644
index 0000000..e868f3f
--- /dev/null
+++ b/test/myencoding/data/encoding/detect_meta.html
@@ -0,0 +1,736 @@
+koi8-r
+<meta http-equiv="content-type" Content="text/html; charset=koi8-r">
+
+koi8-r
+<meta http-equiv="CONTENT-TyPe" Content="text/html; charset=koi8-r">
+
+koi8-r
+<meta http-equiv=CONTENT-TyPe Content="text/html; charset=koi8-r">
+
+utf-8
+<meta http-equiv=CONTENT-TyPe Content=charset=utf8>
+
+utf-8
+<meta http-equiv=CONTENT-TyPe Content=lalalatextbeforecharcharset=utf8>
+
+windows-1251
+<meta key=value ns="bm" key-f='value some as value' / ddd = fff ddd = f = ff
+http-equiv="content-Type" Content="text/html; charset=Windows-1251">
+
+windows-1251
+<meta http-equiv="content-Type" Content="text/html; charset=Windows-1251">
+
+utf-8
+<meta http-equiv="content-Type" Content="text/html; charset=utf-8">
+
+utf-8
+<meta http-equiv="content-Type" Content="text/html; charset=utf8">
+
+WINDOWS-1252
+<meta http-equiv="content-Type" Content="text/html; charset=X-USER-DEFINED">
+
+utf-8
+<meta http-equiv="content-Type" Content="text/html; charset=utf-16LE">
+
+utf-8
+<meta http-equiv="content-Type" Content="text/html; charset=UtF-8">
+
+utf-8
+<meta http-equiv="content-Type" Content="text/htmlcharset=UtF-8">
+
+utf-8
+<meta http-equiv="content-Type" Content="charset=UtF-8">
+
+not-determined
+<meta http-equiv="content-Type" Content="charset UtF-8">
+
+not-determined
+<meta http-equiv="content-Type" Content="charset=UtF">
+
+not-determined
+<meta http-equiv="content-Type" Content="utf-8">
+
+ibm866
+<meta http-equiv="content-Type" Content="charset = ibm866">
+
+ibm866
+<meta http-equiv="content-Type" Content=" charset = ibm866">
+
+ibm866
+<meta http-equiv="content-Type" Content=" charset =ibm866">
+
+ibm866
+<meta http-equiv="content-Type" Content=" charset= ibm866">
+
+ISO-2022-JP
+<meta http-equiv="content-Type" Content="
+charset
+=
+IsO-2022-JP">
+
+ISO-2022-JP
+<meta http-equiv="content-Type" Content="text/html;
+charset
+=
+IsO-2022-JP">
+
+EUC-JP
+<meta http-equiv="content-Type" Content="text/html; charset=EUC-JP">
+
+not-determined
+<meta http-equiv="content-Type blah" Content="text/html; charset=EUC-JP">
+
+EUC-KR
+<meta http-equiv="content-Type" Content="blah blah blah/mu mu mu;
+charset
+=
+EUC-KR">
+
+EUC-KR
+<meta http-equiv="content-Type" Content="text/html;
+charset
+=
+EUC-KR;">
+
+SHIFT_JIS
+<meta http-equiv="content-Type" Content="text/html">
+<meta http-equiv="content-Type" Content="charset=SHIFT-JIS">
+
+windows-874
+<meta http-equiv="Content-Type" Content="text/html; charset=tis-620">
+
+iso-8859-2
+<meta http-equiv="Content-Type" Content="text/html; charset=iso88592">
+
+iso-8859-3
+<meta http-equiv="Content-Type" Content="text/html; charset=iso88593">
+
+iso-8859-4
+<meta http-equiv="Content-Type" Content="text/html; charset=iso88594">
+
+shift_jis
+<meta http-equiv="Content-Type" Content="text/html; charset=sjis">
+
+iso-8859-5
+<meta http-equiv="Content-Type" Content="text/html; charset=iso88595">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=iso88596">
+
+iso-8859-10
+<meta http-equiv="Content-Type" Content="text/html; charset=iso885910">
+
+iso-8859-3
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-3">
+
+iso-8859-13
+<meta http-equiv="Content-Type" Content="text/html; charset=iso885913">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=l1">
+
+windows-1254
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-9:1989">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=csisolatinarabic">
+
+iso-8859-7
+<meta http-equiv="Content-Type" Content="text/html; charset=iso88597">
+
+macintosh
+<meta http-equiv="Content-Type" Content="text/html; charset=mac">
+
+iso-8859-8
+<meta http-equiv="Content-Type" Content="text/html; charset=iso88598">
+
+windows-1251
+<meta http-equiv="Content-Type" Content="text/html; charset=x-cp1251">
+
+koi8-u
+<meta http-equiv="Content-Type" Content="text/html; charset=koi8-u">
+
+windows-1254
+<meta http-equiv="Content-Type" Content="text/html; charset=iso88599">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=ecma-114">
+
+iso-8859-4
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-4">
+
+iso-8859-14
+<meta http-equiv="Content-Type" Content="text/html; charset=iso885914">
+
+iso-8859-4
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-ir-110">
+
+iso-8859-10
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-10">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-ir-100">
+
+iso-8859-3
+<meta http-equiv="Content-Type" Content="text/html; charset=l3">
+
+iso-8859-2
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-2">
+
+iso-8859-2
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-2">
+
+iso-8859-8
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-8">
+
+macintosh
+<meta http-equiv="Content-Type" Content="text/html; charset=csmacintosh">
+
+windows-1253
+<meta http-equiv="Content-Type" Content="text/html; charset=cp1253">
+
+gbk
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-ir-58">
+
+windows-1258
+<meta http-equiv="Content-Type" Content="text/html; charset=x-cp1258">
+
+iso-8859-4
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-4">
+
+iso-8859-4
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-4">
+
+iso-8859-5
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-ir-144">
+
+iso-8859-14
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-14">
+
+iso-8859-10
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-10">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-6">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-6">
+
+iso-8859-7
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-ir-126">
+
+windows-1254
+<meta http-equiv="Content-Type" Content="text/html; charset=l5">
+
+iso-8859-2
+<meta http-equiv="Content-Type" Content="text/html; charset=latin2">
+
+iso-8859-8
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-8">
+
+iso-8859-8
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-ir-138">
+
+iso-8859-8
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-8">
+
+windows-1254
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-ir-148">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=cp819">
+
+iso-8859-14
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-14">
+
+iso-8859-10
+<meta http-equiv="Content-Type" Content="text/html; charset=csisolatin6">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=csisolatin1">
+
+shift_jis
+<meta http-equiv="Content-Type" Content="text/html; charset=ms932">
+
+iso-8859-15
+<meta http-equiv="Content-Type" Content="text/html; charset=l9">
+
+windows-1258
+<meta http-equiv="Content-Type" Content="text/html; charset=cp1258">
+
+windows-1256
+<meta http-equiv="Content-Type" Content="text/html; charset=windows-1256">
+
+gbk
+<meta http-equiv="Content-Type" Content="text/html; charset=gb_2312">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=windows-1252">
+
+iso-8859-7
+<meta http-equiv="Content-Type" Content="text/html; charset=sun_eu_greek">
+
+euc-jp
+<meta http-equiv="Content-Type" Content="text/html; charset=cseucpkdfmtjapanese">
+
+iso-8859-4
+<meta http-equiv="Content-Type" Content="text/html; charset=latin4">
+
+big5
+<meta http-equiv="Content-Type" Content="text/html; charset=x-x-big5">
+
+windows-1255
+<meta http-equiv="Content-Type" Content="text/html; charset=x-cp1255">
+
+koi8-r
+<meta http-equiv="Content-Type" Content="text/html; charset=koi">
+
+windows-1257
+<meta http-equiv="Content-Type" Content="text/html; charset=windows-1257">
+
+windows-874
+<meta http-equiv="Content-Type" Content="text/html; charset=windows-874">
+
+windows-1251
+<meta http-equiv="Content-Type" Content="text/html; charset=cp1251">
+
+utf-8
+<meta http-equiv="Content-Type" Content="text/html; charset=utf-16">
+
+iso-8859-5
+<meta http-equiv="Content-Type" Content="text/html; charset=csisolatincyrillic">
+
+iso-8859-7
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-7">
+
+iso-8859-8
+<meta http-equiv="Content-Type" Content="text/html; charset=visual">
+
+macintosh
+<meta http-equiv="Content-Type" Content="text/html; charset=macintosh">
+
+windows-1250
+<meta http-equiv="Content-Type" Content="text/html; charset=cp1250">
+
+gbk
+<meta http-equiv="Content-Type" Content="text/html; charset=chinese">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=ansi_x3.4-1968">
+
+iso-8859-3
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-3:1988">
+
+iso-8859-4
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-4:1988">
+
+iso-8859-5
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-5:1988">
+
+iso-8859-8
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-8:1988">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=csiso88596e">
+
+iso-8859-8
+<meta http-equiv="Content-Type" Content="text/html; charset=csiso88598e">
+
+gbk
+<meta http-equiv="Content-Type" Content="text/html; charset=csgb2312">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=arabic">
+
+iso-8859-10
+<meta http-equiv="Content-Type" Content="text/html; charset=latin6">
+
+windows-874
+<meta http-equiv="Content-Type" Content="text/html; charset=iso885911">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-1">
+
+iso-8859-7
+<meta http-equiv="Content-Type" Content="text/html; charset=greek">
+
+shift_jis
+<meta http-equiv="Content-Type" Content="text/html; charset=ms_kanji">
+
+iso-8859-5
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-5">
+
+iso-8859-15
+<meta http-equiv="Content-Type" Content="text/html; charset=iso885915">
+
+macintosh
+<meta http-equiv="Content-Type" Content="text/html; charset=x-mac-roman">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=ascii">
+
+euc-kr
+<meta http-equiv="Content-Type" Content="text/html; charset=korean">
+
+euc-kr
+<meta http-equiv="Content-Type" Content="text/html; charset=cseuckr">
+
+utf-8
+<meta http-equiv="Content-Type" Content="text/html; charset=utf8">
+
+koi8-r
+<meta http-equiv="Content-Type" Content="text/html; charset=cskoi8r">
+
+iso-8859-3
+<meta http-equiv="Content-Type" Content="text/html; charset=csisolatin3">
+
+windows-1256
+<meta http-equiv="Content-Type" Content="text/html; charset=cp1256">
+
+x-mac-cyrillic
+<meta http-equiv="Content-Type" Content="text/html; charset=x-mac-ukrainian">
+
+windows-1254
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-9">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=us-ascii">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=x-cp1252">
+
+iso-8859-13
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-13">
+
+big5
+<meta http-equiv="Content-Type" Content="text/html; charset=big5">
+
+windows-1250
+<meta http-equiv="Content-Type" Content="text/html; charset=windows-1250">
+
+euc-kr
+<meta http-equiv="Content-Type" Content="text/html; charset=ksc5601">
+
+iso-8859-7
+<meta http-equiv="Content-Type" Content="text/html; charset=greek8">
+
+gb18030
+<meta http-equiv="Content-Type" Content="text/html; charset=gb18030">
+
+euc-jp
+<meta http-equiv="Content-Type" Content="text/html; charset=x-euc-jp">
+
+shift_jis
+<meta http-equiv="Content-Type" Content="text/html; charset=x-sjis">
+
+utf-8
+<meta http-equiv="Content-Type" Content="text/html; charset=utf-16be">
+
+utf-8
+<meta http-equiv="Content-Type" Content="text/html; charset=utf-16le">
+
+windows-1255
+<meta http-equiv="Content-Type" Content="text/html; charset=windows-1255">
+
+euc-kr
+<meta http-equiv="Content-Type" Content="text/html; charset=ks_c_5601-1987">
+
+ibm866
+<meta http-equiv="Content-Type" Content="text/html; charset=866">
+
+big5
+<meta http-equiv="Content-Type" Content="text/html; charset=cn-big5">
+
+koi8-r
+<meta http-equiv="Content-Type" Content="text/html; charset=koi8_r">
+
+koi8-r
+<meta http-equiv="Content-Type" Content="text/html; charset=koi8-r">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=ibm819">
+
+shift_jis
+<meta http-equiv="Content-Type" Content="text/html; charset=shift_jis">
+
+shift_jis
+<meta http-equiv="Content-Type" Content="text/html; charset=shift-jis">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=asmo-708">
+
+shift_jis
+<meta http-equiv="Content-Type" Content="text/html; charset=csshiftjis">
+
+windows-1254
+<meta http-equiv="Content-Type" Content="text/html; charset=cp1254">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-6-e">
+
+iso-8859-8
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-8-e">
+
+windows-1256
+<meta http-equiv="Content-Type" Content="text/html; charset=x-cp1256">
+
+iso-2022-jp
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-2022-jp">
+
+ibm866
+<meta http-equiv="Content-Type" Content="text/html; charset=csibm866">
+
+windows-874
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-11">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-6:1987">
+
+iso-8859-2
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-2:1987">
+
+iso-8859-7
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-7:1987">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-1:1987">
+
+gbk
+<meta http-equiv="Content-Type" Content="text/html; charset=gb2312">
+
+windows-1254
+<meta http-equiv="Content-Type" Content="text/html; charset=csisolatin5">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-6-i">
+
+iso-8859-8-i
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-8-i">
+
+euc-kr
+<meta http-equiv="Content-Type" Content="text/html; charset=windows-949">
+
+iso-8859-2
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-2">
+
+iso-8859-2
+<meta http-equiv="Content-Type" Content="text/html; charset=l2">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=latin1">
+
+euc-kr
+<meta http-equiv="Content-Type" Content="text/html; charset=ks_c_5601-1989">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-6">
+
+iso-8859-2
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-ir-101">
+
+windows-874
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-11">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-1">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-1">
+
+ibm866
+<meta http-equiv="Content-Type" Content="text/html; charset=cp866">
+
+iso-8859-3
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-3">
+
+iso-8859-3
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-3">
+
+iso-8859-13
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-13">
+
+iso-8859-4
+<meta http-equiv="Content-Type" Content="text/html; charset=l4">
+
+windows-1253
+<meta http-equiv="Content-Type" Content="text/html; charset=windows-1253">
+
+iso-8859-5
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-5">
+
+iso-8859-5
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-5">
+
+iso-8859-15
+<meta http-equiv="Content-Type" Content="text/html; charset=iso8859-15">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-ir-127">
+
+iso-8859-7
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-7">
+
+iso-8859-7
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-7">
+
+iso-8859-10
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-ir-157">
+
+utf-8
+<meta http-equiv="Content-Type" Content="text/html; charset=unicode-1-1-utf-8">
+
+iso-8859-10
+<meta http-equiv="Content-Type" Content="text/html; charset=l6">
+
+euc-kr
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-ir-149">
+
+iso-8859-3
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-ir-109">
+
+windows-1254
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-9">
+
+windows-1254
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-9">
+
+windows-1253
+<meta http-equiv="Content-Type" Content="text/html; charset=x-cp1253">
+
+iso-8859-16
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-16">
+
+windows-1258
+<meta http-equiv="Content-Type" Content="text/html; charset=windows-1258">
+
+iso-8859-8-i
+<meta http-equiv="Content-Type" Content="text/html; charset=logical">
+
+iso-8859-8
+<meta http-equiv="Content-Type" Content="text/html; charset=csisolatinhebrew">
+
+iso-8859-3
+<meta http-equiv="Content-Type" Content="text/html; charset=latin3">
+
+windows-874
+<meta http-equiv="Content-Type" Content="text/html; charset=dos-874">
+
+euc-kr
+<meta http-equiv="Content-Type" Content="text/html; charset=euc-kr">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=cp1252">
+
+iso-8859-6
+<meta http-equiv="Content-Type" Content="text/html; charset=csiso88596i">
+
+iso-8859-8-i
+<meta http-equiv="Content-Type" Content="text/html; charset=csiso88598i">
+
+gbk
+<meta http-equiv="Content-Type" Content="text/html; charset=gbk">
+
+euc-kr
+<meta http-equiv="Content-Type" Content="text/html; charset=csksc56011987">
+
+x-mac-cyrillic
+<meta http-equiv="Content-Type" Content="text/html; charset=x-mac-cyrillic">
+
+iso-2022-jp
+<meta http-equiv="Content-Type" Content="text/html; charset=csiso2022jp">
+
+iso-8859-2
+<meta http-equiv="Content-Type" Content="text/html; charset=csisolatin2">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=x-user-defined">
+
+windows-1254
+<meta http-equiv="Content-Type" Content="text/html; charset=latin5">
+
+windows-1257
+<meta http-equiv="Content-Type" Content="text/html; charset=cp1257">
+
+big5
+<meta http-equiv="Content-Type" Content="text/html; charset=big5-hkscs">
+
+windows-1250
+<meta http-equiv="Content-Type" Content="text/html; charset=x-cp1250">
+
+euc-jp
+<meta http-equiv="Content-Type" Content="text/html; charset=euc-jp">
+
+iso-8859-7
+<meta http-equiv="Content-Type" Content="text/html; charset=elot_928">
+
+iso-8859-7
+<meta http-equiv="Content-Type" Content="text/html; charset=ecma-118">
+
+gbk
+<meta http-equiv="Content-Type" Content="text/html; charset=gb_2312-80">
+
+windows-1251
+<meta http-equiv="Content-Type" Content="text/html; charset=windows-1251">
+
+iso-8859-15
+<meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-15">
+
+iso-8859-15
+<meta http-equiv="Content-Type" Content="text/html; charset=iso_8859-15">
+
+euc-kr
+<meta http-equiv="Content-Type" Content="text/html; charset=ksc_5601">
+
+gbk
+<meta http-equiv="Content-Type" Content="text/html; charset=csiso58gb231280">
+
+iso-8859-5
+<meta http-equiv="Content-Type" Content="text/html; charset=cyrillic">
+
+big5
+<meta http-equiv="Content-Type" Content="text/html; charset=csbig5">
+
+windows-1255
+<meta http-equiv="Content-Type" Content="text/html; charset=cp1255">
+
+windows-1254
+<meta http-equiv="Content-Type" Content="text/html; charset=x-cp1254">
+
+iso-8859-15
+<meta http-equiv="Content-Type" Content="text/html; charset=csisolatin9">
+
+koi8-u
+<meta http-equiv="Content-Type" Content="text/html; charset=koi8-ru">
+
+iso-8859-4
+<meta http-equiv="Content-Type" Content="text/html; charset=csisolatin4">
+
+shift_jis
+<meta http-equiv="Content-Type" Content="text/html; charset=windows-31j">
+
+windows-1257
+<meta http-equiv="Content-Type" Content="text/html; charset=x-cp1257">
+
+utf-8
+<meta http-equiv="Content-Type" Content="text/html; charset=utf-8">
+
+ibm866
+<meta http-equiv="Content-Type" Content="text/html; charset=ibm866">
+
+koi8-r
+<meta http-equiv="Content-Type" Content="text/html; charset=koi8">
+
+iso-8859-8
+<meta http-equiv="Content-Type" Content="text/html; charset=hebrew">
+
+windows-1254
+<meta http-equiv="Content-Type" Content="text/html; charset=windows-1254">
+
+gbk
+<meta http-equiv="Content-Type" Content="text/html; charset=x-gbk">
+
+iso-8859-7
+<meta http-equiv="Content-Type" Content="text/html; charset=csisolatingreek">
+
+windows-1252
+<meta http-equiv="Content-Type" Content="text/html; charset=iso88591">
diff --git a/test/myencoding/encoding_detect_meta.c b/test/myencoding/encoding_detect_meta.c
new file mode 100644
index 0000000..24a8b68
--- /dev/null
+++ b/test/myencoding/encoding_detect_meta.c
@@ -0,0 +1,178 @@
+/*
+ Copyright (C) 2015-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 <myhtml/myhtml.h>
+#include <myencoding/encoding.h>
+
+struct test_res {
+ char* data;
+ size_t size;
+}
+typedef test_res_t;
+
+test_res_t test_load_file(const char* filename)
+{
+ FILE *fh = fopen(filename, "rb");
+ if(fh == NULL) {
+ fprintf(stderr, "Can't open file: %s\n", filename);
+ exit(EXIT_FAILURE);
+ }
+
+ if(fseek(fh, 0L, SEEK_END) != 0) {
+ fprintf(stderr, "Can't set position (fseek) in file: %s\n", filename);
+ exit(EXIT_FAILURE);
+ }
+
+ long size = ftell(fh);
+
+ if(fseek(fh, 0L, SEEK_SET) != 0) {
+ fprintf(stderr, "Can't set position (fseek) in file: %s\n", filename);
+ exit(EXIT_FAILURE);
+ }
+
+ if(size <= 0) {
+ fprintf(stderr, "Can't get file size or file is empty: %s\n", filename);
+ exit(EXIT_FAILURE);
+ }
+
+ char *file_data = (char*)malloc(size + 1);
+ if(file_data == NULL) {
+ fprintf(stderr, "Can't allocate mem for file: %s\n", filename);
+ exit(EXIT_FAILURE);
+ }
+
+ size_t nread = fread(file_data, 1, size, fh);
+ if (nread != size) {
+ fprintf(stderr, "Could not read %ld bytes (" MyCORE_FORMAT_Z " bytes done)\n", size, nread);
+ exit(EXIT_FAILURE);
+ }
+
+ fclose(fh);
+
+ return (test_res_t){file_data, (size_t)size};
+}
+
+size_t test_skip_whitespace(const unsigned char *udata, size_t length, size_t data_size)
+{
+ while(length < data_size) {
+ if(udata[length] != 0x09 && udata[length] != 0x0A && udata[length] != 0x0C && udata[length] != 0x0D && udata[length] != 0x20) {
+ return length;
+ }
+
+ length++;
+ }
+
+ return length;
+}
+
+size_t test_skip_not_whitespace(const unsigned char *udata, size_t length, size_t data_size)
+{
+ while(length < data_size) {
+ if(udata[length] == 0x09 || udata[length] == 0x0A || udata[length] == 0x0C || udata[length] == 0x0D || udata[length] == 0x20) {
+ return length;
+ }
+
+ length++;
+ }
+
+ return length;
+}
+
+size_t test_find_body_end(const unsigned char *udata, size_t length, size_t data_size)
+{
+ while((length + 1) < data_size) {
+ if(udata[length] == 0x0A && udata[(length + 1)] == 0x0A) {
+ return (length + 1);
+ }
+
+ length++;
+ }
+
+ return data_size;
+}
+
+void test_entries(const char* filename)
+{
+ size_t length = 0;
+ test_res_t test_data = test_load_file(filename);
+
+ size_t code_begin = 0, code_length = 0;
+ size_t body_begin = 0;
+
+ myencoding_t encoding;
+ const unsigned char *udata = (const unsigned char*)test_data.data;
+
+ printf("Test, get encoding from <meta ...> element:\n");
+
+ while(length < test_data.size)
+ {
+ /* Find Encoding in Test Header */
+ /* skip ws */
+ length = code_begin = test_skip_whitespace(udata, length, test_data.size);
+
+ if(length >= test_data.size)
+ return;
+
+ /* find ws */
+ length = test_skip_not_whitespace(udata, length, test_data.size);
+ code_length = length - code_begin;
+
+ if(strncmp("not-determined", &test_data.data[code_begin], strlen("not-determined")) == 0) {
+ encoding = MyENCODING_NOT_DETERMINED;
+ }
+ else if(myencoding_by_name(&test_data.data[code_begin], code_length, &encoding) == false) {
+ fprintf(stderr, "Can't get encoding from test header: %.*s\n", (int)code_length, &test_data.data[code_begin]);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Find Test Data */
+ /* get begin of body */
+ length = body_begin = test_skip_whitespace(udata, length, test_data.size);
+
+ /* get end of body */
+ length = test_find_body_end(udata, length, test_data.size);
+
+ myencoding_t find_encoding = myencoding_prescan_stream_to_determine_encoding(&test_data.data[body_begin], (length - body_begin));
+
+ if(find_encoding != encoding) {
+ fprintf(stderr, "ERROR! WRONG! ACHTUNG! Header Encoding not equally Encoding after parsing body\n");
+ fprintf(stderr, "Header: %.*s\n", (int)code_length, &test_data.data[code_begin]);
+ fprintf(stderr, "Body: %.*s\n", (int)(length - body_begin), &test_data.data[body_begin]);
+
+ exit(EXIT_FAILURE);
+ }
+
+ printf("\t%.*s: Ok\n", (int)code_length, &test_data.data[code_begin]);
+ }
+}
+
+int main(int argc, const char * argv[])
+{
+ if (argc < 2) {
+ printf("Bad ARGV!\nUse: encoding_detect_meta <test_file_path>\n");
+ exit(EXIT_FAILURE);
+ }
+
+ test_entries(argv[1]);
+
+ //test_entries("/new/C-git/Modest/test/myhtml/data/encoding/detect_meta.html");
+
+ return EXIT_SUCCESS;
+}
diff --git a/test/myhtml/Makefile.mk b/test/myhtml/Makefile.mk
new file mode 100644
index 0000000..f6fc0c7
--- /dev/null
+++ b/test/myhtml/Makefile.mk
@@ -0,0 +1,7 @@
+myhtml_dirs := .
+myhtml_objs := $(call BINARY_UTILS_OBJS,myhtml,$(myhtml_dirs))
+
+myhtml_all: $(myhtml_objs)
+
+myhtml_clean:
+ rm -f $(myhtml_objs)
diff --git a/test/myhtml/commoncrawl.c b/test/myhtml/commoncrawl.c
new file mode 100644
index 0000000..bbba386
--- /dev/null
+++ b/test/myhtml/commoncrawl.c
@@ -0,0 +1,294 @@
+/*
+ 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)
+ For HTML Pages from: http://commoncrawl.org/
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+//#include <dirent.h>
+//#include <string.h>
+//#include <unistd.h>
+//
+//#include <myhtml/api.h>
+//
+//#define DIE(msg, ...) do { fprintf(stderr, msg, ##__VA_ARGS__); exit(EXIT_FAILURE); } while(0)
+//
+//static myhtml_tree_t* global_tree;
+//
+//#define total_count_size 20
+//static size_t total_count[total_count_size];
+//
+//typedef void (*process_state_f)(const char* data, size_t filename_size);
+//typedef void (*parser_state_f)(const char* data, size_t filename_size, size_t count);
+//
+//void print_total_count(void)
+//{
+// size_t total = 0;
+// for(size_t i = 0; i < 7; i++)
+// total += total_count[i];
+//
+// printf("Total: %zu\n" ,total);
+//
+// printf("\t0-100: %zu\n", total_count[0]);
+// printf("\t100-1000: %zu\n", total_count[1]);
+// printf("\t1000-5000: %zu\n", total_count[2]);
+// printf("\t5000-10000: %zu\n", total_count[3]);
+// printf("\t10000-50000: %zu\n", total_count[4]);
+// printf("\t50000-100000: %zu\n", total_count[5]);
+// printf("\t100000 and up: %zu\n", total_count[6]);
+//}
+//
+//void listdir(const char *name, process_state_f callback)
+//{
+// memset(total_count, 0, sizeof(size_t) * total_count_size);
+//
+// DIR *dir;
+// struct dirent *entry;
+//
+// if(!(dir = opendir(name)))
+// return;
+// if(!(entry = readdir(dir)))
+// return;
+//
+// do {
+// if(entry->d_type == DT_DIR) {
+// char path[2048];
+//
+// int len = snprintf(path, sizeof(path)-1, "%s/%s", name, entry->d_name);
+// path[len] = '\0';
+//
+// if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
+// continue;
+//
+// listdir(path, callback);
+// }
+// else {
+// char path[2048];
+//
+// int len = snprintf(path, sizeof(path)-1, "%s/%s", name, entry->d_name);
+// path[len] = '\0';
+//
+// if(path[ (len - 3) ] == '.' && path[ (len - 2) ] == 'g' && path[ (len - 1) ] == 'z') {
+// callback(path, len);
+// }
+// }
+// }
+// while ((entry = readdir(dir)));
+//
+// closedir(dir);
+//}
+//
+//void read_loaded(const char *filename, const char *db_dir, process_state_f callback)
+//{
+// memset(total_count, 0, sizeof(size_t) * total_count_size);
+//
+// FILE *fh = fopen(filename, "rb");
+// if(fh == NULL) {
+// fprintf(stderr, "Can't open html file: %s\n", filename);
+// exit(EXIT_FAILURE);
+// }
+//
+// fseek(fh, 0L, SEEK_END);
+// long size = ftell(fh);
+// fseek(fh, 0L, SEEK_SET);
+//
+// char *data = (char*)malloc(size + 1);
+// if(data == NULL) {
+// fprintf(stderr, "Can't allocate mem for html file: %s\n", filename);
+// exit(EXIT_FAILURE);
+// }
+//
+// size_t nread = fread(data, 1, size, fh);
+// if (nread != size) {
+// fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", size, nread);
+// exit(EXIT_FAILURE);
+// }
+//
+// fclose(fh);
+//
+// if(size < 0)
+// size = 0;
+//
+// size_t from = 0;
+// char path[2048];
+//
+// for(size_t i = 0; i < size; i++) {
+// if(data[i] == '\n') {
+// int len = snprintf(path, sizeof(path)-1, "%s/%.*s", db_dir, (int)(i - from), &data[from]);
+// path[len] = '\0';
+//
+// callback(path, len);
+//
+// from = i + 1;
+// }
+// }
+//
+// free(data);
+//}
+//
+//void process(const char* filename, size_t filename_size, parser_state_f parser)
+//{
+// FILE *fh = fopen(filename, "rb");
+// if(fh == NULL) {
+// fprintf(stderr, "Can't open html file: %s\n", filename);
+// exit(EXIT_FAILURE);
+// }
+//
+// fseek(fh, 0L, SEEK_SET);
+//
+// const char *ct = "Content-Length:";
+// size_t ct_size = strlen(ct);
+//
+// char * line = NULL;
+// long get_size = 0;
+// ssize_t read = 0;
+//
+// size_t count = 0, read_len = 0;
+//
+// while ((read = getline(&line, &read_len, fh)) != -1) {
+//
+// if(strncmp(ct, line, ct_size) == 0) {
+// size_t i;
+//
+// for(i = ct_size; i < read_len; i++)
+// if(line[i] != '\n' && line[i] != '\r' && line[i] != ' ')
+// break;
+//
+// get_size = strtol(&line[i], NULL, 0);
+// }
+// else if(get_size && line[0] == '\r' && line[1] == '\n') {
+// long head_begin = ftell(fh) + 2;
+// long end = head_begin + get_size;
+//
+// while ((read = getline(&line, &read_len, fh)) != -1) {
+// //printf("%.*s", (int)read_len, line);
+//
+// if(line[0] == '\r' && line[1] == '\n')
+// break;
+// }
+//
+// long head_end = ftell(fh);
+//
+// size_t html_length = (end - head_end);
+// char *html = malloc(html_length + 1);
+//
+// size_t nread = fread(html, 1, html_length, fh);
+// if (nread != html_length) {
+// fprintf(stderr, "could not read %ld bytes (%zu bytes done)\n", html_length, nread);
+// exit(EXIT_FAILURE);
+// }
+//
+// count++;
+// parser(html, html_length, count);
+//
+// get_size = 0;
+// free(html);
+// }
+// }
+//
+// fclose(fh);
+//}
+//
+//void html_parser(const char* html, size_t html_length, size_t count)
+//{
+// if((count % 1000) == 0) {
+// printf("\t%zu\n", count);
+// }
+//
+// myencoding_t encoding = 0;
+// //myhtml_encoding_detect(html, html_length, &encoding);
+//
+// // parse html
+// myhtml_status_t status = myhtml_parse(global_tree, encoding, html, html_length);
+// if(status != MyHTML_STATUS_OK) {
+// fprintf(stderr, "Can't parse:\n%.*s\n", (int)html_length, html);
+// exit(EXIT_FAILURE);
+// }
+//
+// if(html_length < 100)
+// total_count[0]++;
+// else if(html_length >= 100 && html_length < 1000)
+// total_count[1]++;
+// else if(html_length >= 1000 && html_length < 5000)
+// total_count[2]++;
+// else if(html_length >= 5000 && html_length < 10000)
+// total_count[3]++;
+// else if(html_length >= 10000 && html_length < 50000)
+// total_count[4]++;
+// else if(html_length >= 50000 && html_length < 100000)
+// total_count[5]++;
+// else if(html_length >= 100000)
+// total_count[6]++;
+//
+// //myhtml_tree_print_node_children(global_tree, global_tree->document, stdout, 0);
+//}
+//
+//void process_unpack(const char* filename, size_t filename_size)
+//{
+// char command[2048];
+// snprintf(command, sizeof(command)-1, "gzip -k -d %s", filename);
+//
+// printf("Unzip %s\n", filename);
+//
+// system(command);
+//
+// char new_path[2048];
+// size_t new_path_size = (filename_size - 3);
+//
+// snprintf(new_path, sizeof(new_path)-1, "%.*s", (int)new_path_size, filename);
+//
+// printf("Process %s:\n", new_path);
+// process(new_path, new_path_size, html_parser);
+// printf("\n");
+//
+// unlink(new_path);
+//}
+//
+//static void usage(void)
+//{
+// fprintf(stderr, "commoncrawl <dir with *.warc.gz>\n");
+//}
+//
+int main(int argc, const char * argv[])
+{
+// if (argc != 2) {
+// usage();
+// return 0;
+// }
+//
+// // basic init
+// myhtml_t* myhtml = myhtml_create();
+// myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);
+//
+// // first tree init
+// global_tree = myhtml_tree_create();
+// myhtml_tree_init(global_tree, myhtml);
+//
+// listdir(argv[1], process_unpack);
+//
+// // release resources
+// myhtml_tree_destroy(global_tree);
+// myhtml_destroy(myhtml);
+//
+// print_total_count();
+
+ return 0;
+}
+
+
diff --git a/test/myurl/Makefile.mk b/test/myurl/Makefile.mk
new file mode 100644
index 0000000..d2ca170
--- /dev/null
+++ b/test/myurl/Makefile.mk
@@ -0,0 +1,9 @@
+myurl_dirs := .
+myurl_objs := $(call BINARY_UTILS_OBJS,myurl,$(myurl_dirs))
+
+myurl_all: $(myurl_objs)
+
+myurl_clean:
+ rm -f $(myurl_objs)
+
+myurl_url := $(TEST_DIR_RELATIVE)/myurl/data
diff --git a/test/myurl/data/fragment.test b/test/myurl/data/fragment.test
new file mode 100644
index 0000000..aa2b563
--- /dev/null
+++ b/test/myurl/data/fragment.test
@@ -0,0 +1,25 @@
+type 1
+
+%URL:http://example.com#hash
+%EXPECT:http://example.com/#hash
+
+%URL:http://example.com/#hash
+%EXPECT:http://example.com/#hash
+
+%URL:http://example.com/path#hash
+%EXPECT:http://example.com/path#hash
+
+%URL:http://example.com/path/#hash
+%EXPECT:http://example.com/path/#hash
+
+%URL:http://example.com/path/#hash万
+%EXPECT:http://example.com/path/#hash%E4%B8%87
+
+%URL:http://example.com/path/#ha万sh
+%EXPECT:http://example.com/path/#ha%E4%B8%87sh
+
+%URL:http://example.com/?abc#hash
+%EXPECT:http://example.com/?abc#hash
+
+%URL:http://example.com/?abc#hash-link
+%EXPECT:http://example.com/?abc#hash-link
diff --git a/test/myurl/data/hostname.test b/test/myurl/data/hostname.test
new file mode 100644
index 0000000..b03f849
--- /dev/null
+++ b/test/myurl/data/hostname.test
@@ -0,0 +1,19 @@
+type 1
+
+%URL:http://example.com/
+%EXPECT:http://example.com/
+
+%URL:http://example.com./
+%EXPECT:http://example.com./
+
+%URL:http://.
+%EXPECT:http://./
+
+%URL:http://./
+%EXPECT:http://./
+
+%URL:https://a.
+%EXPECT:https://a./
+
+%URL:http://+-****/
+%EXPECT:http://+-****/
diff --git a/test/myurl/data/ipv4.test b/test/myurl/data/ipv4.test
new file mode 100644
index 0000000..a08640d
--- /dev/null
+++ b/test/myurl/data/ipv4.test
@@ -0,0 +1,161 @@
+type 2
+
+%URL:http://./
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://./
+
+%URL:http://.
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://./
+
+%URL:http://192.168.0.1/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://192.168.0.1/
+
+%URL:http://192.168.0.1
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://192.168.0.1/
+
+%URL:http://0xC0.0Xa8.0x0.0x1/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://192.168.0.1/
+
+%URL:http://0xC0.0Xa8.0x0.0x1
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://192.168.0.1/
+
+%URL:http://192.168.9.com/
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://192.168.9.com/
+
+%URL:http://19a.168.0.1/
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://19a.168.0.1/
+
+%URL:http://0308.0250.00.01/
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://0308.0250.00.01/
+
+%URL:http://0xCG.0xA8.0x0.0x1/
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://0xCG.0xA8.0x0.0x1/
+
+%URL:http://0300.0250.00.01/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://192.168.0.1/
+
+%URL:http://192.168.0.1./
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://192.168.0.1./
+
+%URL:http://192.168.0.1. text/
+%EXPECT:
+
+%URL:http://192.168.0.1.text/
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://192.168.0.1.text/
+
+%URL:http://192.168.0.1../
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://192.168.0.1../
+
+%URL:http://example.com../
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://example.com../
+
+%URL:http://0x100.0.0.0/
+%EXPECT:
+
+%URL:http://192.168..1/
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://192.168..1/
+
+%URL:http://0x100.0/
+%EXPECT:
+
+%URL:http://0x100.0.0/
+%EXPECT:
+
+%URL:http://0x100.0.0.0/
+%EXPECT:
+
+%URL:http://0.0x100.0.0/
+%EXPECT:
+
+%URL:http://0.0.0x100.0/
+%EXPECT:
+
+%URL:http://0.0.0.0x100/
+%EXPECT:
+
+%URL:http://0.0.0x10000/
+%EXPECT:
+
+%URL:http://0.0x1000000/
+%EXPECT:
+
+%URL:http://0xFF.0/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://255.0.0.0/
+
+%URL:http://0xFF.0.0.0/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://255.0.0.0/
+
+%URL:http://0.0xFF.0.0/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://0.255.0.0/
+
+%URL:http://0.0.0xFF.0/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://0.0.255.0/
+
+%URL:http://0.0.0.0xFF/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://0.0.0.255/
+
+%URL:http://0.0.0xFFFF/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://0.0.255.255/
+
+%URL:http://0xFFFFFFFF/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://255.255.255.255/
+
+%URL:http://276.256.0xf1a2.077777/
+%EXPECT:
+
+%URL:http://192.168.0.257/
+%EXPECT:
+
+%URL:http://192.168.0.256/
+%EXPECT:
+
+%URL:http://192.015052000001/
+%EXPECT:
+
+%URL:http://0X12C0a80001/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://192.168.0.1/
+
+%URL:http://276.1.2/
+%EXPECT:
+
+%URL:http://0000000000000300.0x00000000000000fF.00000000000000001/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://192.255.0.1/
+
+%URL:http://0000000000000300.0xffffffffFFFFFFFF.3022415481470977/
+%EXPECT:
+
+%URL:http://00000000000000000001/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://0.0.0.1/
+
+%URL:http://0.0.0.000000000000000000z/
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://0.0.0.000000000000000000z/
+
+%URL:http://0.00.0x.0x0/
+%DOMAIN_TYPE:IPv4
+%EXPECT:http://0.0.0.0/
diff --git a/test/myurl/data/ipv6.test b/test/myurl/data/ipv6.test
new file mode 100644
index 0000000..7cfc85d
--- /dev/null
+++ b/test/myurl/data/ipv6.test
@@ -0,0 +1,176 @@
+type 2
+
+%URL:http://[/
+%EXPECT:
+
+%URL:http://[:/
+%EXPECT:
+
+%URL:http://]/
+%DOMAIN_TYPE:DOMAIN
+%EXPECT:http://]/
+
+%URL:http://[:]/
+%EXPECT:
+
+%URL:http://2001:db8::1/
+%EXPECT:
+
+%URL:http://[2001:db8::1/
+%EXPECT:
+
+%URL:http://2001:db8::1]/
+%EXPECT:
+
+%URL:http://[::]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[::]/
+
+%URL:http://[::1]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[::1]/
+
+%URL:http://[1::.]/
+%EXPECT:
+
+%URL:http://[::1.]/
+%EXPECT:
+
+%URL:http://[::192.168.0.1.]/
+%EXPECT:
+
+%URL:http://[::ffff:192.168.0.1]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[::ffff:c0a8:1]/
+
+%URL:http://[000:01:02:003:004:5:6:007.]/
+%EXPECT:
+
+%URL:http://[000:01:02:003:004:5:6:007]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[0:1:2:3:4:5:6:7]/
+
+%URL:http://[A:b:c:DE:fF:0:1:aC.]/
+%EXPECT:
+
+%URL:http://[A:b:c:DE:fF:0:1:aC]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[a:b:c:de:ff:0:1:ac]/
+
+%URL:http://[A:b:c:DE:fF:0:1::]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[a:b:c:de:ff:0:1:0]/
+
+%URL:http://[1:0:0:2::3:0]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[1::2:0:0:3:0]/
+
+%URL:http://[1::2:0:0:3:0]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[1::2:0:0:3:0]/
+
+%URL:http://[::eeee:192.168.0.1]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[::eeee:c0a8:1]/
+
+%URL:http://[::eeee:192.168.0.1.]/
+%EXPECT:
+
+%URL:http://[2001::192.168.0.1]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[2001::c0a8:1]/
+
+%URL:http://[1:2:192.168.0.1:5:6]/
+%EXPECT:
+
+%URL:http://[::ffff:192.1.2]/
+%EXPECT:
+
+%URL:http://[::ffff:0xC0.0Xa8.0x0.0x1]/
+%EXPECT:
+
+%URL:http://[0:0::0:0:8]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[::8]/
+
+%URL:http://[2001:db8::1]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[2001:db8::1]/
+
+%URL:http://[2001:db8::1]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[2001:db8::1]/
+
+%URL:http://[2001::db8::1]/
+%EXPECT:
+
+%URL:http://[2001:db8:::1]/
+%EXPECT:
+
+%URL:http://[:::]/
+%EXPECT:
+
+%URL:http://[2001::.com]/
+%EXPECT:
+
+%URL:http://[::192.168.0.0.1]/
+%EXPECT:
+
+%URL:http://[::ffff:192.168.0.0.1]/
+%EXPECT:
+
+%URL:http://[1:2:3:4:5:6:7:8:9]/
+%EXPECT:
+
+%URL:http://[0:0:0:0:0:0:0:192.168.0.1]/
+%EXPECT:
+
+%URL:http://[1:2:3:4:5:6::192.168.0.1]/
+%EXPECT:
+
+%URL:http://[1:2:3:4:5:6::8]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[1:2:3:4:5:6:0:8]/
+
+%URL:http://[1:2:3:4:5:6:7:8:]/
+%EXPECT:
+
+%URL:http://[1:2:3:4:5:6:192.168.0.1:]/
+%EXPECT:
+
+%URL:http://[-1:2:3:4:5:6:7:8]/
+%EXPECT:
+
+%URL:http://[1::%1]/
+%EXPECT:
+
+%URL:http://[1::%eth0]/
+%EXPECT:
+
+%URL:http://[1::%]/
+%EXPECT:
+
+%URL:http://[%]/
+%EXPECT:
+
+%URL:http://[::%:]/
+%EXPECT:
+
+%URL:http://[:0:0::0:0:8]/
+%EXPECT:
+
+%URL:http://[0:0::0:0:8:]/
+%EXPECT:
+
+%URL:http://[:0:0::0:0:8:]/
+%EXPECT:
+
+%URL:http://[::192.168..1]/
+%EXPECT:
+
+%URL:http://[::1 hello]/
+%EXPECT:
+
+%URL:http://[2001:db8::]/
+%DOMAIN_TYPE:IPv6
+%EXPECT:http://[2001:db8::]/
diff --git a/test/myurl/data/mailto.test b/test/myurl/data/mailto.test
new file mode 100644
index 0000000..ed7c0ab
--- /dev/null
+++ b/test/myurl/data/mailto.test
@@ -0,0 +1,28 @@
+type 1
+
+%URL:mailto:addr1
+%EXPECT:mailto:addr1
+
+%URL:mailto:addr1@foo.com
+%EXPECT:mailto:addr1@foo.com
+
+%URL:mailto:addr1
+%EXPECT:mailto:addr1
+
+%URL:mailto:addr1?to=jon
+%EXPECT:mailto:addr1?to=jon
+
+%URL:mailto:addr1,addr2
+%EXPECT:mailto:addr1,addr2
+
+%URL:mailto:addr1, addr2
+%EXPECT:mailto:addr1, addr2
+
+%URL:mailto:addr1%2caddr2
+%EXPECT:mailto:addr1%2caddr2
+
+%URL:mailto:������
+%EXPECT:mailto:%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD
+
+%URL:mailto:addr1?
+%EXPECT:mailto:addr1?
diff --git a/test/myurl/data/miscellaneous.test b/test/myurl/data/miscellaneous.test
new file mode 100644
index 0000000..089571c
--- /dev/null
+++ b/test/myurl/data/miscellaneous.test
@@ -0,0 +1,43 @@
+type 1
+
+%URL:http://user%40example.com/
+%EXPECT:http://user@example.com/
+
+%URL:http://user%3Ainfo%40/
+%EXPECT:http://user:info@/
+
+%URL:http://user@/
+%EXPECT:
+
+%URL:$:foo/bar
+%EXPECT:
+
+%URL:mailto::foo@bar.com
+%EXPECT:mailto::foo@bar.com
+
+%URL:html://lastmac@12345:example.com
+%EXPECT:
+
+%URL:html://lastmac:12345@example.com
+%EXPECT:html://lastmac:12345@example.com
+
+%URL:html://lastmac:1@2345@example.com
+%EXPECT:html://lastmac:1%402345@example.com
+
+%URL:html://lastmac:1@2345@@example.com
+%EXPECT:html://lastmac:1%402345%40@example.com
+
+%URL:html://lastmac:@1@2345@@example.com
+%EXPECT:html://lastmac:%401%402345%40@example.com
+
+%URL:html://:@1@2345@@example.com
+%EXPECT:html://:%401%402345%40@example.com
+
+%URL:html://:@example.com
+%EXPECT:html://example.com
+
+%URL:html://lastmac:@example.com
+%EXPECT:html://lastmac@example.com
+
+%URL:html://lastmac:::::123@example.com
+%EXPECT:html://lastmac:%3A%3A%3A%3A123@example.com
diff --git a/test/myurl/data/path.test b/test/myurl/data/path.test
new file mode 100644
index 0000000..4a8b3ca
--- /dev/null
+++ b/test/myurl/data/path.test
@@ -0,0 +1,183 @@
+type 1
+
+%URL:http://example.com
+%EXPECT:http://example.com/
+
+%URL:http://example.com/
+%EXPECT:http://example.com/
+
+%URL:http://example.com/a
+%EXPECT:http://example.com/a
+
+%URL:http://example.com/a/
+%EXPECT:http://example.com/a/
+
+%URL:http://example.com/a/b/c
+%EXPECT:http://example.com/a/b/c
+
+%URL:http://example.com/a/b/c/
+%EXPECT:http://example.com/a/b/c/
+
+%URL:http://example.com/././c
+%EXPECT:http://example.com/c
+
+%URL:http://example.com/././.c
+%EXPECT:http://example.com/.c
+
+%URL:http://www.example.com/a/.
+%EXPECT:http://www.example.com/a/
+
+%URL:http://www.example.com/a/./
+%EXPECT:http://www.example.com/a/
+
+%URL:http://www.example.com/a/b/..
+%EXPECT:http://www.example.com/a/
+
+%URL:http://www.example.com/foo/bar/../
+%EXPECT:http://www.example.com/foo/
+
+%URL:http://www.example.com/a/..bar
+%EXPECT:http://www.example.com/a/..bar
+
+%URL:http://www.example.com/a/b/../ton
+%EXPECT:http://www.example.com/a/ton
+
+%URL:http://www.example.com/a/b/../d/../../g
+%EXPECT:http://www.example.com/g
+
+%URL:http://www.example.com/a/../../..
+%EXPECT:http://www.example.com/
+
+%URL:http://www.example.com/a/../../../e
+%EXPECT:http://www.example.com/e
+
+%URL:http://www.example.com/a/%2e
+%EXPECT:http://www.example.com/a/
+
+%URL:http://www.example.com////../..
+%EXPECT:http://www.example.com//
+
+%URL:http://www.example.com/a/b//../..
+%EXPECT:http://www.example.com/a/
+
+%URL:http://www.example.com/a/b//..
+%EXPECT:http://www.example.com/a/b/
+
+%URL:http://www.example.com/a/b/..
+%EXPECT:http://www.example.com/a/
+
+%URL:http://www.example.com/(%28:%3A%29)
+%EXPECT:http://www.example.com/(%28:%3A%29)
+
+%URL:http://www.example.com/%3A%3a%3C%3c
+%EXPECT:http://www.example.com/%3A%3a%3C%3c
+
+%URL:http://www.example.com/万abc
+%EXPECT:http://www.example.com/%E4%B8%87abc
+
+%URL:http://example.com/a/万
+%EXPECT:http://example.com/a/%E4%B8%87
+
+%URL:http://example.com/a/万/
+%EXPECT:http://example.com/a/%E4%B8%87/
+
+%URL:http://example.com/a/万/c/
+%EXPECT:http://example.com/a/%E4%B8%87/c/
+
+%URL:http://example.com/ a / b / c /
+%EXPECT:http://example.com/%20a%20%20/%20%20b%20/%20%20c%20/
+
+%URL:http://example.com/a
+/
+b/c/
+
+%EXPECT:http://example.com/a/b/c/
+
+%URL:http://example.com/
+a
+/
+b/c
+/
+
+%EXPECT:http://example.com/a/b/c/
+
+%URL:http://example.com/a/b\c/d\e/f
+%EXPECT:http://example.com/a/b/c/d/e/f
+
+%URL:http://example.com\a\b\c\
+%EXPECT:http://example.com/a/b/c/
+
+%URL:http://example.com\a\b\c
+%EXPECT:http://example.com/a/b/c
+
+%URL:http://example.com\a
+%EXPECT:http://example.com/a
+
+%URL:http://example.com\a/
+%EXPECT:http://example.com/a/
+
+%URL:http://example.com\
+%EXPECT:http://example.com/
+
+%URL:file:C:\example\
+%EXPECT:file:///C:/example/
+
+%URL:file:///C:\example\
+%EXPECT:file:///C:/example/
+
+%URL:file:///C:\example\\\\\\\\
+%EXPECT:file:///C:/example////////
+
+%URL:file:///C:\\\\\\\\example\\\\\\\\
+%EXPECT:file:///C:////////example////////
+
+%URL:file:///C|\\\\\\\\example\\\\\\\\
+%EXPECT:file:///C:////////example////////
+
+%URL:file://C|\\\\\\\\example\\\\\\\\
+%EXPECT:file:///C:////////example////////
+
+%URL:file://C:\example\
+%EXPECT:file:///C:/example/
+
+%URL:file://C:\example\\\\\\\\
+%EXPECT:file:///C:/example////////
+
+%URL:file://C:\\\\\\\\example\\\\\\\\
+%EXPECT:file:///C:////////example////////
+
+%URL:file:///user/data/
+%EXPECT:file:///user/data/
+
+%URL:file://user/data/
+%EXPECT:file://user/data/
+
+%URL:file://user/data
+%EXPECT:file://user/data
+
+%URL:file:/user/data
+%EXPECT:file:///user/data
+
+%URL:file:/user
+%EXPECT:file:///user
+
+%URL:file:/
+%EXPECT:file:///
+
+%URL:file:
+%EXPECT:file:///
+
+%URL:file
+%EXPECT:
+
+%URL:file://localhost/C:/foo
+%EXPECT:file:///C:/foo
+
+%URL:file://localhost/foo
+%EXPECT:file:///foo
+
+%URL:\\\\another\\path
+%EXPECT:
+
+%URL:file:///C:/foo
+%EXPECT:file:///C:/foo
diff --git a/test/myurl/data/port.test b/test/myurl/data/port.test
new file mode 100644
index 0000000..7f857af
--- /dev/null
+++ b/test/myurl/data/port.test
@@ -0,0 +1,34 @@
+type 1
+
+%URL:http://www.example.com:hahaha/
+%EXPECT:
+
+%URL:http://www.example.com: hah aha/
+%EXPECT:
+
+%URL:http://www.example.com:-1/
+%EXPECT:
+
+%URL:http://www.example.com:-1/
+%EXPECT:
+
+%URL:http://www.example.com:123/
+%EXPECT:http://www.example.com:123/
+
+%URL:http://www.example.com:80/
+%EXPECT:http://www.example.com/
+
+%URL:http://www.example.com:/
+%EXPECT:http://www.example.com/
+
+%URL:http://www.example.com:/
+%EXPECT:http://www.example.com/
+
+%URL:http://www.example.com:15615156165165165/
+%EXPECT:
+
+%URL:https://www.example.com:443/
+%EXPECT:https://www.example.com/
+
+%URL:https://www.example.com:442/
+%EXPECT:https://www.example.com:442/
diff --git a/test/myurl/data/query.test b/test/myurl/data/query.test
new file mode 100644
index 0000000..2b8959d
--- /dev/null
+++ b/test/myurl/data/query.test
@@ -0,0 +1,26 @@
+type 1
+
+%URL:http://example.com?abc
+%EXPECT:http://example.com/?abc
+
+%URL:http://example.com/?abc
+%EXPECT:http://example.com/?abc
+
+%URL:http://example.com/?key=value
+%EXPECT:http://example.com/?key=value
+
+%URL:http://example.com/?key=value&hohoho=hahaha
+%EXPECT:http://example.com/?key=value&hohoho=hahaha
+
+%URL:http://example.com/?key=val ue
+%EXPECT:http://example.com/?key=val%20ue
+
+%URL:http://example.com/?key=val万ue
+%EXPECT:http://example.com/?key=val%E4%B8%87ue
+
+%URL:http://example.com/?key=v
+al万u e
+%EXPECT:http://example.com/?key=val%E4%B8%87ue
+
+%URL:http://example.com/?abc#hash
+%EXPECT:http://example.com/?abc#hash
diff --git a/test/myurl/data/relative.test b/test/myurl/data/relative.test
new file mode 100644
index 0000000..99dc39e
--- /dev/null
+++ b/test/myurl/data/relative.test
@@ -0,0 +1,208 @@
+type 3
+
+%URL:/path
+%BASE:http://example.com/
+%EXPECT:http://example.com/path
+
+%URL:/path/
+%BASE:http://example.com/
+%EXPECT:http://example.com/path/
+
+%URL:../path/
+%BASE:http://example.com/
+%EXPECT:http://example.com/path/
+
+%URL:/../path/
+%BASE:http://example.com/
+%EXPECT:http://example.com/path/
+
+%URL:../../path/
+%BASE:http://example.com/
+%EXPECT:http://example.com/path/
+
+%URL:/../../path/
+%BASE:http://example.com/
+%EXPECT:http://example.com/path/
+
+%URL:/../../../../../../../../../../../../path/
+%BASE:http://example.com/
+%EXPECT:http://example.com/path/
+
+%URL:a/b/c/../../path/
+%BASE:http://example.com/
+%EXPECT:http://example.com/a/path/
+
+%URL:a/b/c/../../path/
+%BASE:http://example.com/
+%EXPECT:http://example.com/a/path/
+
+%URL:a/b/c/./../path/
+%BASE:http://example.com/
+%EXPECT:http://example.com/a/b/path/
+
+%URL:a/b/c/././path/
+%BASE:http://example.com/
+%EXPECT:http://example.com/a/b/c/path/
+
+%URL:a/b/../c/././././././././path/
+%BASE:http://example.com/
+%EXPECT:http://example.com/a/c/path/
+
+%URL:a/b/../c/././././././././
+%BASE:http://example.com/
+%EXPECT:http://example.com/a/c/
+
+%URL:a/b/../c/./././././././.
+%BASE:http://example.com/
+%EXPECT:http://example.com/a/c/
+
+%URL:a/b/../c/./././././././.
+%BASE:http://example.com/
+%EXPECT:http://example.com/a/c/
+
+%URL:a/b/../c
+%BASE:http://example.com/../../
+%EXPECT:http://example.com/a/c
+
+%URL:/path/
+%BASE:http://example.com/?key=value&a=1
+%EXPECT:http://example.com/path/
+
+%URL:/path/
+%BASE:http://example.com/?key=value&a=1
+%EXPECT:http://example.com/path/
+
+%URL:/path/?b=2
+%BASE:http://example.com/?key=value&a=1
+%EXPECT:http://example.com/path/?b=2
+
+%URL:/path/
+%BASE:http://example.com/#hash
+%EXPECT:http://example.com/path/
+
+%URL:/path/#myhash
+%BASE:http://example.com/#hash
+%EXPECT:http://example.com/path/#myhash
+
+%URL: /path/
+%BASE:http://example.com
+%EXPECT:http://example.com/path/
+
+%URL: .
+%BASE:http://example.com/path
+%EXPECT:http://example.com/
+
+%URL:
+
+
+
+%BASE:http://example.com/
+%EXPECT:http://example.com/
+
+%URL:http:/path
+%BASE:http://host/a
+%EXPECT:http://host/path
+
+%URL:HTTP:/path
+%BASE:http://host/a
+%EXPECT:http://host/path
+
+%URL:HTTP:path
+%BASE:http://host/a
+%EXPECT:http://host/path
+
+%URL:HTTP:path
+%BASE:http://host/a/
+%EXPECT:http://host/a/path
+
+%URL:HTTP:path/
+%BASE:http://host/a/
+%EXPECT:http://host/a/path/
+
+%URL:httg:/myhost
+%BASE:http://host/a
+%EXPECT:httg:/myhost
+
+%URL:https:/myhost
+%BASE:http://host/a
+%EXPECT:https://myhost/
+
+%URL:/b/../c
+%BASE:http://host/a?b#c
+%EXPECT:http://host/c
+
+%URL:bc/de?query#ref
+%BASE:http://host/a/
+%EXPECT:http://host/a/bc/de?query#ref
+
+%URL:..
+%BASE:http://host/a/
+%EXPECT:http://host/
+
+%URL:./..
+%BASE:http://host/a/
+%EXPECT:http://host/
+
+%URL:../.
+%BASE:http://host/a/
+%EXPECT:http://host/
+
+%URL:../../../foo
+%BASE:http://host/a?query#ref
+%EXPECT:http://host/foo
+
+%URL:?
+%BASE:http://host/a?x=y#z
+%EXPECT:http://host/a?
+
+%URL:?foo=bar#com
+%BASE:http://host/a?x=y#z
+%EXPECT:http://host/a?foo=bar#com
+
+%URL:#ref
+%BASE:http://host/a
+%EXPECT:http://host/a#ref
+
+%URL:#
+%BASE:http://host/a#b
+%EXPECT:http://host/a#
+
+%URL:#bye
+%BASE:http://host/a?foo=bar#hello
+%EXPECT:http://host/a?foo=bar#bye
+
+%URL:baz.html
+%BASE:data:foobar
+%EXPECT:
+
+%URL:data:baz
+%BASE:data:foobar
+%EXPECT:data:baz
+
+%URL:data:/base
+%BASE:data:foobar
+%EXPECT:data:/base
+
+%URL:./asd:fgh
+%BASE:http://foo/bar
+%EXPECT:http://foo/asd:fgh
+
+%URL: hello world
+%BASE:http://foo/bar
+%EXPECT:http://foo/hello%20world
+
+%URL:///another/path
+%BASE:http://host/a
+%EXPECT:http://another/path
+
+%URL://
+%BASE:http://host/a
+%EXPECT:
+
+%URL:\\/another/path
+%BASE:http://host/a
+%EXPECT:http://another/path
+
+%URL:/\\Another\\path
+%BASE:http://host/a
+%EXPECT:http://Another//path
diff --git a/test/myurl/data/relative_win.test b/test/myurl/data/relative_win.test
new file mode 100644
index 0000000..f1297c4
--- /dev/null
+++ b/test/myurl/data/relative_win.test
@@ -0,0 +1,77 @@
+type 3
+
+%URL:http://host/
+%BASE:file:///C:/foo
+%EXPECT:http://host/
+
+%URL:bar
+%BASE:file:///C:/foo
+%EXPECT:file:///C:/bar
+
+%URL:../../../bar.html
+%BASE:file:///C:/foo
+%EXPECT:file:///bar.html
+
+%URL:/../bar.html
+%BASE:file:///C:/foo
+%EXPECT:file:///C:/bar.html
+
+%URL:\\\\another\\path
+%BASE:http://host/a
+%EXPECT:http://another//path
+
+%URL://c:/foo
+%BASE:file:///C:/something
+%EXPECT:file:///c:/foo
+
+%URL://localhost/c:/foo
+%BASE:file:///C:/something
+%EXPECT:file:///c:/foo
+
+%URL:c:
+%BASE:file:///C:/foo
+%EXPECT:c:
+
+%URL:c:/foo
+%BASE:file:///C:/foo
+%EXPECT:c:/foo
+
+%URL:c:\\foo
+%BASE:http://host/a
+%EXPECT:c:\\foo
+
+%URL:/z:/bar
+%BASE:file:///C:/foo
+%EXPECT:file:///C:/z:/bar
+
+%URL:/bar
+%BASE:file:///C:/foo
+%EXPECT:file:///C:/bar
+
+%URL:/bar
+%BASE:file://localhost/C:/foo
+%EXPECT:file:///C:/bar
+
+%URL:/bar
+%BASE:file:///localhost/C:/foo
+%EXPECT:file:///bar
+
+%URL:/bar
+%BASE:file:///localhost/C:/foo
+%EXPECT:file:///bar
+
+%URL:bar
+%BASE:file:///localhost/C:/foo
+%EXPECT:file:///localhost/C:/bar
+
+%URL:/bar
+%BASE:file:///C:/foo/com/
+%EXPECT:file:///C:/bar
+
+%URL://somehost/path
+%BASE:file:///C:/something
+%EXPECT:file://somehost/path
+
+%URL:/\\//somehost/path
+%BASE:file:///C:/something
+%EXPECT:file://///somehost/path
diff --git a/test/myurl/data/scheme.test b/test/myurl/data/scheme.test
new file mode 100644
index 0000000..4385b8c
--- /dev/null
+++ b/test/myurl/data/scheme.test
@@ -0,0 +1,100 @@
+type 1
+
+%URL:http://example.com/
+%EXPECT:http://example.com/
+
+%URL:HTTP://example.com/
+%EXPECT:http://example.com/
+
+%URL:hTtP://example.com/
+%EXPECT:http://example.com/
+
+%URL:https://example.com/
+%EXPECT:https://example.com/
+
+%URL:blob:d3958f5c-0777-0845-9dcf-2cb28783acaf
+%EXPECT:blob:d3958f5c-0777-0845-9dcf-2cb28783acaf
+
+%URL:wss://example.com/
+%EXPECT:wss://example.com/
+
+%URL:ws://example.com/
+%EXPECT:ws://example.com/
+
+%URL:filesystem:/new/god/of/war
+%EXPECT:filesystem:/new/god/of/war
+
+%URL:ftp://example.com/
+%EXPECT:ftp://example.com/
+
+%URL:data:image/gif;base64,R01
+%EXPECT:data:image/gif;base64,R01
+
+%URL:gopher://example.com/
+%EXPECT:gopher://example.com/
+
+%URL:about:blank
+%EXPECT:about:blank
+
+%URL:about:blanksdfsdfsfd/dsfsfsf/564ytry/
+%EXPECT:about:blanksdfsdfsfd/dsfsfsf/564ytry/
+
+%URL:about:blanksdfsdfsfd/dsfsfsf/564ytry
+%EXPECT:about:blanksdfsdfsfd/dsfsfsf/564ytry
+
+%URL:http:///////example.com/
+%EXPECT:http://example.com/
+
+%URL:http:/fdf/example.com/
+%EXPECT:http://fdf/example.com/
+
+%URL:http:fdf/example.com/
+%EXPECT:http://fdf/example.com/
+
+%URL:httpss://example.com/
+%EXPECT:httpss://example.com/
+
+%URL:://example.com/
+%EXPECT:
+
+%URL:/example.com/
+%EXPECT:
+
+%URL://example.com/
+%EXPECT:
+
+%URL:http//example.com/
+%EXPECT:
+
+%URL:MySCHEMA://example.com/
+%EXPECT:MySCHEMA://example.com/
+
+%URL:http://example.com
+%EXPECT:http://example.com/
+
+%URL:http
+%EXPECT:
+
+%URL:http:
+%EXPECT:
+
+%URL:http://
+%EXPECT:
+
+%URL:http://.
+%EXPECT:http://./
+
+%URL:http://..
+%EXPECT:http://../
+
+%URL:http://a.
+%EXPECT:http://a./
+
+%URL:万://a.
+%EXPECT:
+
+%URL:htt万://a.
+%EXPECT:
+
+%URL:-://a.
+%EXPECT:
diff --git a/test/myurl/url.c b/test/myurl/url.c
new file mode 100644
index 0000000..96369e2
--- /dev/null
+++ b/test/myurl/url.c
@@ -0,0 +1,514 @@
+/*
+ Copyright (C) 2015-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/url.h>
+#include <myurl/serialization.h>
+#include <myhtml/mystring.h>
+#include <mycore/utils/mchar_async.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+
+struct test_res {
+ char* data;
+ size_t size;
+}
+typedef test_res_t;
+
+struct test_pos {
+ size_t begin;
+ size_t length;
+}
+typedef test_pos_t;
+
+enum test_type {
+ TEST_TYPE_UNDEF = 0x00,
+ TEST_TYPE_FIRST = '1',
+ TEST_TYPE_SECOND = '2',
+ TEST_TYPE_THIRD = '3',
+ TEST_TYPE_FOURTH = '4'
+};
+
+static mchar_async_t* MCharOBJ = NULL;
+static size_t MCharOBJNode = 0;
+
+test_pos_t test_get_value(const char *data, size_t* length, size_t data_size, const char* some);
+
+test_res_t test_load_file(const char* filename)
+{
+ FILE *fh = fopen(filename, "rb");
+ if(fh == NULL) {
+ fprintf(stderr, "Can't open file: %s\n", filename);
+ exit(EXIT_FAILURE);
+ }
+
+ if(fseek(fh, 0L, SEEK_END) != 0) {
+ fprintf(stderr, "Can't set position (fseek) in file: %s\n", filename);
+ exit(EXIT_FAILURE);
+ }
+
+ long size = ftell(fh);
+
+ if(fseek(fh, 0L, SEEK_SET) != 0) {
+ fprintf(stderr, "Can't set position (fseek) in file: %s\n", filename);
+ exit(EXIT_FAILURE);
+ }
+
+ if(size <= 0) {
+ fprintf(stderr, "Can't get file size or file is empty: %s\n", filename);
+ exit(EXIT_FAILURE);
+ }
+
+ char *file_data = (char*)malloc(size + 1);
+ if(file_data == NULL) {
+ fprintf(stderr, "Can't allocate mem for file: %s\n", filename);
+ exit(EXIT_FAILURE);
+ }
+
+ size_t nread = fread(file_data, 1, size, fh);
+ if (nread != size) {
+ fprintf(stderr, "Could not read %ld bytes (%zu bytes done)\n", size, nread);
+ exit(EXIT_FAILURE);
+ }
+
+ fclose(fh);
+
+ return (test_res_t){file_data, (size_t)size};
+}
+
+mystatus_t test_serialization_callback(const char* data, size_t len, void* ctx)
+{
+ mycore_string_t *str = ctx;
+ mycore_string_append(str, data, len);
+
+ return MyCORE_STATUS_OK;
+}
+
+myurl_entry_t * test_parse_url(const char *data, size_t length, myurl_entry_t* base_url)
+{
+ myurl_t *url = myurl_create();
+ if(url == NULL) {
+ fprintf(stderr, "Could create url object\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(myurl_init(url)) {
+ fprintf(stderr, "Could init url object\n");
+ exit(EXIT_FAILURE);
+ }
+
+ myurl_entry_t *url_entry = myurl_parse(url, data, length, base_url, NULL);
+
+ if(url_entry == NULL) {
+ myurl_destroy(url, true);
+ return NULL;
+ }
+
+ return url_entry;
+}
+
+void test_destroy_url(myurl_entry_t* entry_url)
+{
+ if(entry_url) {
+ myurl_t *url = entry_url->url_ref;
+ myurl_entry_destroy(entry_url, true);
+ myurl_destroy(url, true);
+ }
+}
+
+myurl_host_type_t test_host_type_from_data(const char *data, size_t length)
+{
+ if(strncmp("IPv4", data, length) == 0) {
+ return MyURL_HOST_TYPE_IPv4;
+ }
+ else if(strncmp("IPv6", data, length) == 0) {
+ return MyURL_HOST_TYPE_IPv6;
+ }
+ else if(strncmp("DOMAIN", data, length) == 0) {
+ return MyURL_HOST_TYPE_DOMAIN;
+ }
+ else if(strncmp("OPAQUE", data, length) == 0) {
+ return MyURL_HOST_TYPE_OPAQUE;
+ }
+
+ return MyURL_HOST_TYPE_UNDEF;
+}
+
+myurl_host_type_t test_get_domain_type(const char *data, size_t* length, size_t data_size)
+{
+ test_pos_t domain_type = test_get_value(data, length, data_size, "%DOMAIN_TYPE:");
+ myurl_host_type_t domain_type_int = test_host_type_from_data(&data[domain_type.begin], domain_type.length);
+
+ return domain_type_int;
+}
+
+test_pos_t test_get_value(const char *data, size_t* length, size_t data_size, const char* some)
+{
+ test_pos_t pos = {0};
+ size_t some_len = strlen(some);
+
+ size_t len = *length + some_len;
+
+ if(len >= data_size)
+ return pos;
+
+ if(strncmp(some, &data[ *length ], some_len))
+ return pos;
+
+ pos.begin = len;
+
+ while(len < data_size) {
+ if(data[len] == '%')
+ {
+ size_t bpos = len;
+ bpos++;
+
+ while(bpos < data_size) {
+ if((bpos - 1) > len && (data[bpos] < 'A' || data[bpos] > 'Z') && data[bpos] != '_') {
+ if(data[bpos] == ':') {
+ if(strncmp("%URL", &data[len], 4) == 0)
+ pos.length = ((len - pos.begin) - 2);
+ else
+ pos.length = ((len - pos.begin) - 1);
+
+ *length = len;
+ return pos;
+ }
+
+ break;
+ }
+
+ bpos++;
+ }
+ }
+
+ len++;
+ }
+
+ *length = len;
+ pos.length = ((len - pos.begin) - 1);
+
+ return pos;
+}
+
+/* FIRST */
+bool test_for_type_first_entry(const char *data, size_t* length, size_t data_size)
+{
+ test_pos_t url = test_get_value(data, length, data_size, "%URL:");
+ if(url.length == 0)
+ return true;
+
+ //printf("%.*s\n", (int)url.length, &data[ url.begin ]);
+
+ myurl_entry_t *url_entry = test_parse_url(&data[ url.begin ], url.length, NULL);
+
+ /* get expected */
+ test_pos_t expect = test_get_value(data, length, data_size, "%EXPECT:");
+ if(expect.length == 0) {
+ if(url_entry == NULL)
+ return true;
+ }
+
+ if(url_entry == NULL) {
+ fprintf(stderr, "Test FAILURE!\n");
+ fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+ fprintf(stderr, "\tResult:\n");
+ fprintf(stderr, "\tExpect: %.*s\n\n", (int)expect.length, &data[expect.begin]);
+
+ test_destroy_url(url_entry);
+ return true;
+ }
+
+ mycore_string_t cmp_str = {0};
+ mycore_string_init(MCharOBJ, MCharOBJNode, &cmp_str, 1024);
+
+ myurl_serialization(url_entry, false, test_serialization_callback, &cmp_str);
+
+ /* compare */
+ if(cmp_str.length != expect.length || strncmp(cmp_str.data, &data[expect.begin], cmp_str.length))
+ {
+ fprintf(stderr, "Test FAILURE!\n");
+ fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+ fprintf(stderr, "\tResult: %.*s\n", (int)cmp_str.length, cmp_str.data);
+ fprintf(stderr, "\tExpect: %.*s\n\n", (int)expect.length, &data[expect.begin]);
+
+ mycore_string_destroy(&cmp_str, false);
+ test_destroy_url(url_entry);
+ return true;
+ }
+
+ mycore_string_destroy(&cmp_str, false);
+ test_destroy_url(url_entry);
+
+ return true;
+}
+
+bool test_for_type_first(const char *data, size_t length, size_t data_size)
+{
+ while(length < data_size) {
+ if(test_for_type_first_entry(data, &length, data_size) == false)
+ return false;
+ }
+
+ return true;
+}
+
+/* SECOND */
+bool test_for_type_second_entry(const char *data, size_t* length, size_t data_size)
+{
+ test_pos_t url = test_get_value(data, length, data_size, "%URL:");
+ if(url.length == 0)
+ return true;
+
+ /* get domain_type */
+ myurl_host_type_t domain_type = test_get_domain_type(data, length, data_size);
+
+ //printf("%.*s\n", (int)url.length, &data[ url.begin ]);
+
+ myurl_entry_t *url_entry = test_parse_url(&data[ url.begin ], url.length, NULL);
+
+ /* get expected */
+ test_pos_t expect = test_get_value(data, length, data_size, "%EXPECT:");
+ if(expect.length == 0) {
+ if(url_entry == NULL)
+ return true;
+ }
+
+ if(url_entry == NULL) {
+ fprintf(stderr, "Test FAILURE!\n");
+ fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+ fprintf(stderr, "\tResult:\n");
+ fprintf(stderr, "\tExpect: %.*s\n\n", (int)expect.length, &data[expect.begin]);
+
+ test_destroy_url(url_entry);
+ return true;
+ }
+
+ if(url_entry->host.type != domain_type) {
+ fprintf(stderr, "Test FAILURE!\n");
+ fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+ fprintf(stderr, "\tDomain Type: %d\n", url_entry->host.type);
+ fprintf(stderr, "\tDomain Ip Version Type: %d\n", url_entry->host.value.ipv.type);
+ fprintf(stderr, "\tExpect Domain Type: %d\n\n", domain_type);
+
+ test_destroy_url(url_entry);
+ return true;
+ }
+
+ mycore_string_t cmp_str = {0};
+ mycore_string_init(MCharOBJ, MCharOBJNode, &cmp_str, 1024);
+
+ myurl_serialization(url_entry, false, test_serialization_callback, &cmp_str);
+
+ /* compare */
+ if(cmp_str.length != expect.length || strncmp(cmp_str.data, &data[expect.begin], cmp_str.length))
+ {
+ fprintf(stderr, "Test FAILURE!\n");
+ fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+ fprintf(stderr, "\tResult: %.*s\n", (int)cmp_str.length, cmp_str.data);
+ fprintf(stderr, "\tExpect: %.*s\n\n", (int)expect.length, &data[expect.begin]);
+
+ mycore_string_destroy(&cmp_str, false);
+ test_destroy_url(url_entry);
+ return true;
+ }
+
+ mycore_string_destroy(&cmp_str, false);
+ test_destroy_url(url_entry);
+
+ return true;
+}
+
+bool test_for_type_second(const char *data, size_t length, size_t data_size)
+{
+ while(length < data_size) {
+ if(test_for_type_second_entry(data, &length, data_size) == false)
+ return false;
+ }
+
+ return true;
+}
+
+/* THIRD */
+bool test_for_type_third_entry(const char *data, size_t* length, size_t data_size)
+{
+ test_pos_t url = test_get_value(data, length, data_size, "%URL:");
+ if(url.length == 0)
+ return true;
+
+ /* get base */
+ test_pos_t base = test_get_value(data, length, data_size, "%BASE:");
+ if(base.length == 0)
+ return true;
+
+ myurl_entry_t *base_entry = test_parse_url(&data[ base.begin ], base.length, NULL);
+ myurl_entry_t *url_entry = test_parse_url(&data[ url.begin ], url.length, base_entry);
+
+ /* get expected */
+ test_pos_t expect = test_get_value(data, length, data_size, "%EXPECT:");
+ if(expect.length == 0) {
+ if(url_entry == NULL)
+ return true;
+ }
+
+ if(url_entry == NULL) {
+ fprintf(stderr, "Test FAILURE!\n");
+ fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+ fprintf(stderr, "\tBASE: %.*s\n", (int)base.length, &data[ base.begin ]);
+ fprintf(stderr, "\tResult:\n");
+ fprintf(stderr, "\tExpect: %.*s\n\n", (int)expect.length, &data[expect.begin]);
+
+ test_destroy_url(url_entry);
+ return true;
+ }
+
+ mycore_string_t cmp_str = {0};
+ mycore_string_init(MCharOBJ, MCharOBJNode, &cmp_str, 1024);
+
+ myurl_serialization(url_entry, false, test_serialization_callback, &cmp_str);
+
+ /* compare */
+ if(cmp_str.length != expect.length || strncmp(cmp_str.data, &data[expect.begin], cmp_str.length))
+ {
+ fprintf(stderr, "Test FAILURE!\n");
+ fprintf(stderr, "\tURL: %.*s\n", (int)url.length, &data[ url.begin ]);
+ fprintf(stderr, "\tBASE: %.*s\n", (int)base.length, &data[ base.begin ]);
+ fprintf(stderr, "\tResult: %.*s\n", (int)cmp_str.length, cmp_str.data);
+ fprintf(stderr, "\tExpect: %.*s\n\n", (int)expect.length, &data[expect.begin]);
+
+ mycore_string_destroy(&cmp_str, false);
+ test_destroy_url(url_entry);
+ return true;
+ }
+
+ mycore_string_destroy(&cmp_str, false);
+ test_destroy_url(url_entry);
+
+ return true;
+}
+
+bool test_for_type_third(const char *data, size_t length, size_t data_size)
+{
+ while(length < data_size) {
+ if(test_for_type_third_entry(data, &length, data_size) == false)
+ return false;
+ }
+
+ return true;
+}
+
+void test_by_type(const char *data, size_t data_size, const char* filename)
+{
+ printf("Test file: %s\n", filename);
+
+ size_t length = 8;
+
+ if(data_size <= length || strncmp("type ", data, 5)) {
+ fprintf(stderr, "Could not read type form %s\n", filename);
+ exit(EXIT_FAILURE);
+ }
+
+ switch ((unsigned char)data[5]) {
+ case TEST_TYPE_FIRST:
+ test_for_type_first(&data[8], 0, (data_size - 8));
+ break;
+
+ case TEST_TYPE_SECOND:
+ test_for_type_second(&data[8], 0, (data_size - 8));
+ break;
+
+ case TEST_TYPE_THIRD:
+ test_for_type_third(&data[8], 0, (data_size - 8));
+ break;
+
+ default:
+ break;
+ }
+}
+
+void test(const char* filename)
+{
+ test_res_t test_data = test_load_file(filename);
+ test_by_type(test_data.data, test_data.size, filename);
+
+ if(test_data.data)
+ free(test_data.data);
+}
+
+void test_read_dir(const char* dir_path)
+{
+ char path[(4096 * 4)];
+ sprintf(path, "%s", dir_path);
+
+ printf("Tests in directory: %s\n", path);
+
+ size_t path_len = strlen(dir_path);
+
+ DIR *dir;
+ struct dirent *ent;
+ struct stat path_stat;
+
+ if((dir = opendir(dir_path)) != NULL)
+ {
+ while((ent = readdir(dir)) != NULL)
+ {
+ sprintf(&path[path_len], "/%s", ent->d_name);
+
+ if(stat(path, &path_stat) != 0) {
+ fprintf(stderr, "Can't get status for file: %s\n", path);
+ exit(EXIT_FAILURE);
+ }
+
+ if(ent->d_name[0] == '.' || S_ISDIR(path_stat.st_mode))
+ continue;
+
+ test(path);
+ }
+
+ closedir (dir);
+ }
+}
+
+int main(int argc, const char * argv[])
+{
+ setbuf(stdout, NULL);
+
+ if (argc < 2) {
+ printf("Bad ARGV!\nUse: url <test_file_path>\n");
+ exit(EXIT_FAILURE);
+ }
+
+ MCharOBJ = mchar_async_create();
+ if(MCharOBJ == NULL)
+ return EXIT_FAILURE;
+
+ if(mchar_async_init(MCharOBJ, 4, 4096))
+ return EXIT_FAILURE;
+
+ MCharOBJNode = mchar_async_node_add(MCharOBJ, NULL);
+
+ test_read_dir(argv[1]);
+ //test_read_dir("/new/C-git/Modest/test/myurl/data");
+
+ mchar_async_destroy(MCharOBJ, true);
+
+ return EXIT_SUCCESS;
+}
diff --git a/utils/MyHTML/encoding_name.pl b/utils/MyHTML/encoding_name.pl
index d67b107..d2b8641 100755
--- a/utils/MyHTML/encoding_name.pl
+++ b/utils/MyHTML/encoding_name.pl
@@ -168,13 +168,13 @@ sub print_enum {
print "enum myhtml_encoding_list {\n\t";
my @vals;
- push @vals, ["MyHTML_ENCODING_DEFAULT", "0x00"];
- push @vals, ["MyHTML_ENCODING_AUTO", "0x01"];
- push @vals, ["MyHTML_ENCODING_NOT_DETERMINED", "0x02"];
- push @vals, ["MyHTML_ENCODING_UTF_8", "0x00"];
- push @vals, ["MyHTML_ENCODING_UTF_16LE", "0x04"];
- push @vals, ["MyHTML_ENCODING_UTF_16BE", "0x05"];
- push @vals, ["MyHTML_ENCODING_X_USER_DEFINED", "0x06"];
+ push @vals, ["MyHTML_ENCODING_DEFAULT", "0x00", "utf_8"];
+ push @vals, ["MyHTML_ENCODING_AUTO", "0x01", "NULL"];
+ push @vals, ["MyHTML_ENCODING_NOT_DETERMINED", "0x02", "NULL"];
+ push @vals, ["MyHTML_ENCODING_UTF_8", "0x00", "utf_8"];
+ push @vals, ["MyHTML_ENCODING_UTF_16LE", "0x04", "utf_16le"];
+ push @vals, ["MyHTML_ENCODING_UTF_16BE", "0x05", , "utf_16be"];
+ push @vals, ["MyHTML_ENCODING_X_USER_DEFINED", "0x06", "x_user_defined"];
my $i = 7;
foreach my $id (sort {$a cmp $b} keys %$index) {
@@ -184,18 +184,27 @@ sub print_enum {
next if $id =~ /UTF_16BE$/i;
next if $id =~ /X_USER_DEFINED$/i;
- push @vals, ["MyHTML_ENCODING_". uc($id), sprintf("0x%02x", $i)];
+ push @vals, ["MyHTML_ENCODING_". uc($id), sprintf("0x%02x", $i), lc($id)];
$i++;
}
- push @vals, ["MyHTML_ENCODING_LAST_ENTRY", sprintf("0x%02x", $i)];
+ push @vals, ["MyHTML_ENCODING_LAST_ENTRY", sprintf("0x%02x", $i), "NULL"];
print join(",\n\t", @{MyHTML::Base->format_list_text(\@vals, "= ")}), "\n";
print "}\ntypedef myhtml_encoding_t;\n\n";
- shift @vals;
+ print "static const myhtml_encoding_custom_f myhtml_encoding_function_index[] = \n{\n";
+ foreach my $entry (@vals) {
+ if($entry->[2] eq "NULL") {
+ print "\t", $entry->[2], ",\n";
+ } else {
+ print "\t", "myhtml_encoding_decode_", $entry->[2], ",\t// ", $entry->[0], "\n";
+ }
+ }
+
+ print "};\n";
print "static const myhtml_encoding_entry_name_index_t myhtml_encoding_entry_name_index_static_list_index[(MyHTML_ENCODING_LAST_ENTRY + 1)] =\n{\n";
diff --git a/utils/MyHTML/url_resources.pl b/utils/MyHTML/url_resources.pl
index a52cdf0..2562fef 100644
--- a/utils/MyHTML/url_resources.pl
+++ b/utils/MyHTML/url_resources.pl
@@ -39,18 +39,78 @@ my $userinfo_encode = {
"|" => ''
};
-my $utils = MyHTML::Base->new(dirs => {source => "../../Modest/source/myhtml/url", template => "tmpl"});
+my $forbidden_host_code_point = {
+ "\x00" => '',
+ "\x09" => '',
+ "\x0A" => '',
+ "\x0D" => '',
+ "\x20" => '',
+ "#" => '',
+ "\%" => '',
+ "/" => '',
+ ":" => '',
+ "?" => '',
+ "\@" => '',
+ "[" => '',
+ "\\" => '',
+ "]" => ''
+};
+
+my $utils = MyHTML::Base->new(dirs => {source => "../../source/myhtml/url", template => "tmpl"});
my $utils_data = $utils->read_tmpl("url_resources.h");
$utils->save_src("resources.h", $utils_data,
{
BODY =>
- get_text_data(creare_for_default(), "myhtml_url_resources_static_map_default") .
- get_text_data(creare_for_simple(), "myhtml_url_resources_static_map_simple") .
+ get_text_data(creare_for_query(), "myhtml_url_resources_static_map_query_charset") .
+ get_text_data(creare_for_forbidden_host_code_point(), "myhtml_url_resources_static_map_forbidden_host_code_point") .
+ "/* 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. */\n".
+ get_text_data(creare_for_simple(), "myhtml_url_resources_static_map_C0") .
+ '/* The path percent-encode set is the myhtml_url_resources_static_map_path and code points U+0020, \'"\', "#", "<", ">", "?", "`", "{", and "}". */'."\n".
+ get_text_data(creare_for_default(), "myhtml_url_resources_static_map_path") .
+ '/* The userinfo percent-encode set is the myhtml_url_resources_static_map_path and code points "/", ":", ";", "=", "@", "[", "\", "]", "^", and "|". */'."\n".
get_text_data(creare_for_userinfo(), "myhtml_url_resources_static_map_userinfo")
}
);
+sub creare_for_query {
+ my @data;
+
+ for my $codepoint (0..255) {
+ my $char = chr($codepoint);
+
+ # less than 0x21, greater than 0x7E, or is 0x22, 0x23, 0x3C, or 0x3E
+ if ($codepoint < 33 || $codepoint > 126 || $codepoint == 0x22 ||
+ $codepoint == 0x23 || $codepoint == 0x3C || $codepoint == 0x3E)
+ {
+ push @data, "0x00";
+ }
+ else {
+ push @data, sprintf("0x%02x", $codepoint);
+ }
+ }
+
+ return \@data;
+}
+
+sub creare_for_forbidden_host_code_point {
+ my @data;
+
+ for my $codepoint (0..255) {
+ my $char = chr($codepoint);
+
+ if (exists $default_encode->{$char} || $char eq chr(0))
+ {
+ push @data, sprintf("0x%02x", $codepoint);
+ }
+ else {
+ push @data, "0xff";
+ }
+ }
+
+ return \@data;
+}
+
sub creare_for_default {
my @data;