mirror of
https://github.com/lexborisov/Modest
synced 2024-11-22 05:41:32 +03:00
Fix for makefiles
This commit is contained in:
parent
3a9d974e9c
commit
3cfea886cb
131
include/myhtml/utils/mchar_async.h
Normal file
131
include/myhtml/utils/mchar_async.h
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
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_UTILS_MCHAR_ASYNC_H
|
||||
#define MyHTML_UTILS_MCHAR_ASYNC_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <myhtml/myosi.h>
|
||||
#include <myhtml/utils/mcsync.h>
|
||||
|
||||
#define mchar_async_cache_has_nodes(cache) cache.count
|
||||
|
||||
typedef struct mchar_async_node mchar_async_node_t;
|
||||
|
||||
struct mchar_async_cache_node {
|
||||
void *value;
|
||||
size_t size;
|
||||
|
||||
size_t left;
|
||||
size_t right;
|
||||
size_t parent;
|
||||
}
|
||||
typedef mchar_async_cache_node_t;
|
||||
|
||||
struct mchar_async_chunk {
|
||||
char *begin;
|
||||
size_t length;
|
||||
size_t size;
|
||||
|
||||
struct mchar_async_chunk *next;
|
||||
struct mchar_async_chunk *prev;
|
||||
}
|
||||
typedef mchar_async_chunk_t;
|
||||
|
||||
struct mchar_async_cache {
|
||||
mchar_async_cache_node_t *nodes;
|
||||
size_t nodes_size;
|
||||
size_t nodes_length;
|
||||
size_t nodes_root;
|
||||
|
||||
size_t count;
|
||||
|
||||
size_t *index;
|
||||
size_t index_length;
|
||||
size_t index_size;
|
||||
}
|
||||
typedef mchar_async_cache_t;
|
||||
|
||||
struct mchar_async_node {
|
||||
mchar_async_chunk_t *chunk;
|
||||
mchar_async_cache_t cache;
|
||||
};
|
||||
|
||||
struct mchar_async {
|
||||
size_t origin_size;
|
||||
|
||||
mchar_async_chunk_t **chunks;
|
||||
size_t chunks_pos_size;
|
||||
size_t chunks_pos_length;
|
||||
size_t chunks_size;
|
||||
size_t chunks_length;
|
||||
|
||||
mchar_async_cache_t chunk_cache;
|
||||
|
||||
mchar_async_node_t *nodes;
|
||||
size_t nodes_length;
|
||||
size_t nodes_size;
|
||||
|
||||
size_t *nodes_cache;
|
||||
size_t nodes_cache_length;
|
||||
size_t nodes_cache_size;
|
||||
|
||||
mcsync_t *mcsync;
|
||||
}
|
||||
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_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);
|
||||
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);
|
||||
|
||||
mchar_async_chunk_t * mchar_async_chunk_malloc(mchar_async_t *mchar_async, mchar_async_node_t *node, size_t length);
|
||||
char * mchar_async_crop_first_chars(mchar_async_t *mchar_async, size_t node_idx, char *data, size_t crop_len);
|
||||
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);
|
||||
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);
|
||||
|
||||
void mchar_async_cache_add(mchar_async_cache_t *cache, void* value, size_t size);
|
||||
size_t mchar_async_cache_delete(mchar_async_cache_t *cache, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* mchar_async_h */
|
||||
|
70
include/myhtml/utils/mcobject.h
Normal file
70
include/myhtml/utils/mcobject.h
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
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_UTILS_MCOBJECT_H
|
||||
#define MyHTML_UTILS_MCOBJECT_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <myhtml/myosi.h>
|
||||
|
||||
struct mcobject_chunk {
|
||||
unsigned char *begin;
|
||||
size_t length;
|
||||
size_t size;
|
||||
|
||||
struct mcobject_chunk *next;
|
||||
struct mcobject_chunk *prev;
|
||||
}
|
||||
typedef mcobject_chunk_t;
|
||||
|
||||
struct mcobject {
|
||||
mcobject_chunk_t *chunk;
|
||||
|
||||
void **cache;
|
||||
size_t cache_size;
|
||||
size_t cache_length;
|
||||
|
||||
size_t struct_size;
|
||||
size_t chunk_size;
|
||||
}
|
||||
typedef mcobject_t;
|
||||
|
||||
|
||||
mcobject_t * mcobject_create(void);
|
||||
myhtml_status_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_malloc(mcobject_t *mcobject, myhtml_status_t* status);
|
||||
myhtml_status_t mcobject_free(mcobject_t *mcobject, void *entry);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* MyHTML_UTILS_MCOBJECT_H */
|
||||
|
114
include/myhtml/utils/mcobject_async.h
Normal file
114
include/myhtml/utils/mcobject_async.h
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
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_UTILS_MCOBJECT_ASYNC_H
|
||||
#define MyHTML_UTILS_MCOBJECT_ASYNC_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <myhtml/myosi.h>
|
||||
#include <myhtml/utils/mcsync.h>
|
||||
|
||||
enum mcobject_async_status {
|
||||
MCOBJECT_ASYNC_STATUS_OK = 0,
|
||||
MCOBJECT_ASYNC_STATUS_ERROR_MEMORY_ALLOCATION = 1,
|
||||
MCOBJECT_ASYNC_STATUS_CHUNK_ERROR_MEMORY_ALLOCATION = 2,
|
||||
MCOBJECT_ASYNC_STATUS_CHUNK_CACHE_ERROR_MEMORY_ALLOCATION = 3,
|
||||
MCOBJECT_ASYNC_STATUS_NODES_ERROR_MEMORY_ALLOCATION = 4,
|
||||
MCOBJECT_ASYNC_STATUS_NODES_ERROR_BAD_NODE_ID = 5,
|
||||
MCOBJECT_ASYNC_STATUS_CACHE_ERROR_MEMORY_REALLOC = 6
|
||||
}
|
||||
typedef mcobject_async_status_t;
|
||||
|
||||
struct mcobject_async_chunk {
|
||||
unsigned char *begin;
|
||||
size_t length;
|
||||
size_t size;
|
||||
|
||||
struct mcobject_async_chunk *next;
|
||||
struct mcobject_async_chunk *prev;
|
||||
}
|
||||
typedef mcobject_async_chunk_t;
|
||||
|
||||
struct mcobject_async_node {
|
||||
mcobject_async_chunk_t *chunk;
|
||||
|
||||
void **cache;
|
||||
size_t cache_size;
|
||||
size_t cache_length;
|
||||
}
|
||||
typedef mcobject_async_node_t;
|
||||
|
||||
struct mcobject_async {
|
||||
size_t origin_size;
|
||||
size_t struct_size;
|
||||
size_t struct_size_sn;
|
||||
|
||||
mcobject_async_chunk_t **chunk_cache;
|
||||
size_t chunk_cache_size;
|
||||
size_t chunk_cache_length;
|
||||
|
||||
mcobject_async_chunk_t **chunks;
|
||||
size_t chunks_pos_size;
|
||||
size_t chunks_pos_length;
|
||||
size_t chunks_size;
|
||||
size_t chunks_length;
|
||||
|
||||
mcobject_async_node_t *nodes;
|
||||
size_t nodes_length;
|
||||
size_t nodes_size;
|
||||
|
||||
size_t *nodes_cache;
|
||||
size_t nodes_cache_length;
|
||||
size_t nodes_cache_size;
|
||||
|
||||
mcsync_t *mcsync;
|
||||
}
|
||||
typedef mcobject_async_t;
|
||||
|
||||
mcobject_async_t * mcobject_async_create(void);
|
||||
mcobject_async_status_t mcobject_async_init(mcobject_async_t *mcobj_async, size_t chunk_len, size_t obj_size_by_one_chunk, size_t struct_size);
|
||||
|
||||
void mcobject_async_clean(mcobject_async_t *mcobj_async);
|
||||
mcobject_async_t * mcobject_async_destroy(mcobject_async_t *mcobj_async, int destroy_self);
|
||||
|
||||
size_t mcobject_async_node_add(mcobject_async_t *mcobj_async, mcobject_async_status_t *status);
|
||||
void mcobject_async_node_clean(mcobject_async_t *mcobj_async, size_t node_idx);
|
||||
void mcobject_async_node_all_clean(mcobject_async_t *mcobj_async);
|
||||
void mcobject_async_node_delete(mcobject_async_t *mcobj_async, size_t node_idx);
|
||||
|
||||
void * mcobject_async_malloc(mcobject_async_t *mcobj_async, size_t node_idx, mcobject_async_status_t *status);
|
||||
mcobject_async_status_t mcobject_async_free(mcobject_async_t *mcobj_async, void *entry);
|
||||
|
||||
mcobject_async_chunk_t * mcobject_async_chunk_malloc(mcobject_async_t *mcobj_async, size_t length, mcobject_async_status_t *status);
|
||||
mcobject_async_chunk_t * mcobject_async_chunk_malloc_without_lock(mcobject_async_t *mcobj_async, size_t length, mcobject_async_status_t *status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* mcobject_async_h */
|
||||
|
||||
|
||||
|
||||
|
61
include/myhtml/utils/mcsimple.h
Normal file
61
include/myhtml/utils/mcsimple.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
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_UTILS_MCSIMPLE_H
|
||||
#define MyHTML_UTILS_MCSIMPLE_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <myhtml/myosi.h>
|
||||
|
||||
struct mcsimple {
|
||||
size_t struct_size;
|
||||
|
||||
uint8_t **list;
|
||||
|
||||
size_t list_pos_size;
|
||||
size_t list_pos_length;
|
||||
size_t list_pos_length_used;
|
||||
size_t list_size;
|
||||
size_t list_length;
|
||||
}
|
||||
typedef mcsimple_t;
|
||||
|
||||
|
||||
mcsimple_t * mcsimple_create(void);
|
||||
void mcsimple_init(mcsimple_t *mcsimple, size_t pos_size, size_t list_size, size_t struct_size);
|
||||
void mcsimple_clean(mcsimple_t *mcsimple);
|
||||
mcsimple_t * mcsimple_destroy(mcsimple_t *mcsimple, bool destroy_self);
|
||||
|
||||
uint8_t * mcsimple_init_list_entries(mcsimple_t *mcsimple, size_t pos);
|
||||
|
||||
void * mcsimple_malloc(mcsimple_t *mcsimple);
|
||||
void * mcsimple_get_by_absolute_position(mcsimple_t *mcsimple, size_t pos);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* MyHTML_UTILS_MCSIMPLE_H */
|
||||
|
81
include/myhtml/utils/mcsync.h
Normal file
81
include/myhtml/utils/mcsync.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
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_UTILS_MCSYNC_H
|
||||
#define MyHTML_UTILS_MCSYNC_H
|
||||
#pragma once
|
||||
|
||||
#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
|
||||
}
|
||||
typedef mcsync_status_t;
|
||||
|
||||
struct mcsync {
|
||||
int spinlock;
|
||||
#if !defined(MyHTML_BUILD_WITHOUT_THREADS)
|
||||
pthread_mutex_t *mutex;
|
||||
#endif
|
||||
}
|
||||
typedef mcsync_t;
|
||||
|
||||
mcsync_t * mcsync_create(void);
|
||||
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_mutex_lock(mcsync_t* mclock);
|
||||
mcsync_status_t mcsync_mutex_unlock(mcsync_t* mclock);
|
||||
|
||||
#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);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* mcsync_h */
|
97
include/myhtml/utils/mctree.h
Normal file
97
include/myhtml/utils/mctree.h
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
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_UTILS_MCTREE_H
|
||||
#define MyHTML_UTILS_MCTREE_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <myhtml/myosi.h>
|
||||
#include <myhtml/utils.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
#define mctree_node_get_free_id(mctree) mctree->nodes_length
|
||||
|
||||
#define mctree_node_clean(mctree, idx) \
|
||||
mctree->nodes[idx].str = NULL; \
|
||||
mctree->nodes[idx].value = NULL; \
|
||||
mctree->nodes[idx].child_count = 0; \
|
||||
mctree->nodes[idx].prev = 0; \
|
||||
mctree->nodes[idx].next = 0; \
|
||||
mctree->nodes[idx].child = 0
|
||||
|
||||
#define mctree_node_add(mctree) \
|
||||
mctree->nodes_length++; \
|
||||
if(mctree->nodes_length == mctree->nodes_size) { \
|
||||
mctree->nodes_size += 4096; \
|
||||
mctree->nodes = (mctree_node_t*)myhtml_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
|
||||
|
||||
|
||||
typedef size_t mctree_index_t;
|
||||
|
||||
struct mctree_node {
|
||||
const char* str;
|
||||
size_t str_size;
|
||||
void* value;
|
||||
|
||||
size_t child_count;
|
||||
mctree_index_t prev;
|
||||
mctree_index_t next;
|
||||
mctree_index_t child;
|
||||
}
|
||||
typedef mctree_node_t;
|
||||
|
||||
struct mctree_tree {
|
||||
mctree_node_t* nodes;
|
||||
size_t nodes_length;
|
||||
size_t nodes_size;
|
||||
|
||||
size_t start_size;
|
||||
}
|
||||
typedef mctree_t;
|
||||
|
||||
typedef void (*mctree_before_insert_f)(const char* key, size_t key_size, void **value);
|
||||
|
||||
|
||||
mctree_t * mctree_create(size_t start_size);
|
||||
void mctree_clean(mctree_t* mctree);
|
||||
mctree_t * mctree_destroy(mctree_t* mctree);
|
||||
|
||||
mctree_index_t mctree_insert(mctree_t* mctree, const char* key, size_t key_size, void* value, mctree_before_insert_f b_insert);
|
||||
mctree_index_t mctree_search(mctree_t* mctree, const char* key, size_t key_size);
|
||||
mctree_index_t mctree_search_lowercase(mctree_t* mctree, const char* key, size_t key_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* defined(__mhtml__mtree__) */
|
213
include/myhtml/utils/resources.h
Normal file
213
include/myhtml/utils/resources.h
Normal file
@ -0,0 +1,213 @@
|
||||
/*
|
||||
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_UTILS_RESOURCES_H
|
||||
#define MyHTML_UTILS_RESOURCES_H
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
static const unsigned char myhtml_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,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
|
||||
0x06, 0x07, 0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 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 myhtml_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,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
|
||||
0x06, 0x07, 0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0xff,
|
||||
0xff, 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, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 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 myhtml_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,
|
||||
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
|
||||
};
|
||||
|
||||
static const size_t replacement_character[] = {
|
||||
65533, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
18, 19, 20, 21, 22, 23, 24, 25, 26,
|
||||
27, 28, 29, 30, 31, 32, 33, 34, 35,
|
||||
36, 37, 38, 39, 40, 41, 42, 43, 44,
|
||||
45, 46, 47, 48, 49, 50, 51, 52, 53,
|
||||
54, 55, 56, 57, 58, 59, 60, 61, 62,
|
||||
63, 64, 65, 66, 67, 68, 69, 70, 71,
|
||||
72, 73, 74, 75, 76, 77, 78, 79, 80,
|
||||
81, 82, 83, 84, 85, 86, 87, 88, 89,
|
||||
90, 91, 92, 93, 94, 95, 96, 97, 98,
|
||||
99, 100, 101, 102, 103, 104, 105, 106, 107,
|
||||
108, 109, 110, 111, 112, 113, 114, 115, 116,
|
||||
117, 118, 119, 120, 121, 122, 123, 124, 125,
|
||||
126, 127, 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, 382, 376
|
||||
};
|
||||
|
||||
static const size_t myhtml_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,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
|
||||
0x06, 0x07, 0x08, 0x09, 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 myhtml_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,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 myhtml_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 */
|
@ -6,8 +6,6 @@ HDRS += $(foreach dir,$(SUBDIRS),$(find_files_h))
|
||||
SRCS += $(foreach dir,$(SUBDIRS),$(find_files_c))
|
||||
|
||||
mycss_clone: MyCSS_DIR_$(SUBDIRS)
|
||||
mkdir -p $(INCLUDE_TMP)/mycss
|
||||
cp $(SRCDIR)/mycss/*.h $(INCLUDE_TMP)/mycss
|
||||
|
||||
MyCSS_DIR_$(SUBDIRS):
|
||||
mkdir -p $(INCLUDE_TMP)/mycss/$(patsubst MyCSS_DIR_%,%,$@)
|
||||
|
@ -1,13 +1,11 @@
|
||||
find_files_h = $(wildcard $(SRCDIR)/myhtml/$(dir)/*.h)
|
||||
find_files_c = $(wildcard $(SRCDIR)/myhtml/$(dir)/*.c)
|
||||
|
||||
SUBDIRS := . utils
|
||||
SUBDIRS := . "utils"
|
||||
HDRS += $(foreach dir,$(SUBDIRS),$(find_files_h))
|
||||
SRCS += $(foreach dir,$(SUBDIRS),$(find_files_c))
|
||||
|
||||
myhtml_clone: MyHTML_DIR_$(SUBDIRS)
|
||||
mkdir -p $(INCLUDE_TMP)/myhtml
|
||||
cp $(SRCDIR)/myhtml/*.h $(INCLUDE_TMP)/myhtml
|
||||
|
||||
MyHTML_DIR_$(SUBDIRS):
|
||||
mkdir -p $(INCLUDE_TMP)/myhtml/$(patsubst MyHTML_DIR_%,%,$@)
|
||||
|
Loading…
Reference in New Issue
Block a user