diff --git a/.gitmodules b/.gitmodules index 6928c834f..7f5120d97 100644 --- a/.gitmodules +++ b/.gitmodules @@ -30,3 +30,7 @@ path = depends/uri-encode url = https://github.com/ShadowsocksR-Live/uri-encode-c.git branch = master +[submodule "depends/cstl"] + path = depends/cstl + url = https://github.com/ShadowsocksR-Live/cstl.git + branch = master diff --git a/CMakeLists.txt b/CMakeLists.txt index fc7c5a182..94c929b62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- # ---------------------------------------------------------------------- # Copyright © 2011-2015, RedJack, LLC. # All rights reserved. @@ -35,6 +35,7 @@ add_subdirectory(depends/libuv) add_subdirectory(depends/json-c) add_subdirectory(depends/uv-mbed/win32) add_subdirectory(depends/uri-encode) +add_subdirectory(depends/cstl) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/depends/cstl b/depends/cstl new file mode 160000 index 000000000..eeeea142e --- /dev/null +++ b/depends/cstl @@ -0,0 +1 @@ +Subproject commit eeeea142ef17617c1d8d484496fb87239e655718 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d25ee2618..c2dfe487a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,7 +35,6 @@ set(SOURCE_FILES_OBFS obfs/auth_chain.c obfs/base64.c obfs/crc32.c - obfs/cstl_lib.c obfs/http_simple.c obfs/obfs.c obfs/obfsutil.c @@ -144,6 +143,7 @@ include_directories(${libsodium_include_dirs}) include_directories(${LIB_JSON_C_BIN_DIR}/..) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../depends/http-parser) include_directories(${URI_ENCODE_DIR}) +include_directories(${CSTL_ROOT_DIR}/inc) if(USE_CRYPTO_MBEDTLS) include_directories(${MBEDTLS_ROOT_DIR}/include) @@ -189,6 +189,7 @@ set_target_properties(ssr-server PROPERTIES COMPILE_DEFINITIONS MODULE_REMOTE) set (ss_lib_common json-c uv_a + cstl ) if (MSVC) diff --git a/src/client/client.c b/src/client/client.c index cf34aaae9..7a93a2409 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -1,6 +1,6 @@ #include "base64.h" #include "common.h" -#include "cstl_lib.h" +#include #include "defs.h" #include "dump_info.h" #include "encrypt.h" diff --git a/src/ip_addr_cache.c b/src/ip_addr_cache.c index 067754745..87aaa2aea 100644 --- a/src/ip_addr_cache.c +++ b/src/ip_addr_cache.c @@ -3,7 +3,7 @@ #include #include "ip_addr_cache.h" -#include "cstl_lib.h" +#include #include "sockaddr_universal.h" struct ip_addr_cache { diff --git a/src/obfs/cstl_lib.c b/src/obfs/cstl_lib.c deleted file mode 100644 index 486ebab53..000000000 --- a/src/obfs/cstl_lib.c +++ /dev/null @@ -1,1659 +0,0 @@ -/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** - * This file is part of cstl library - * Copyright (C) 2011 Avinash Dongre ( dongre.avinash@gmail.com ) - * Copyright (C) 2018 ssrlive ( ssrlivebox@gmail.com ) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ - -#include "cstl_lib.h" -#include -#include - -// c_algorithms.c -#include - -void -cstl_for_each(struct cstl_iterator *pIterator, void(*fn)(const void *value, const void *key, void *p), void *p) { - const void *pElement; - if (pIterator==NULL || fn==NULL) { - return; - } - while ((pElement = pIterator->next(pIterator)) != NULL) { - const void *value = pIterator->current_value(pIterator); - const void *key = pIterator->current_key ? pIterator->current_key(pIterator) : NULL; - fn(value, key, p); - } -} - - -// c_array.c -#include -#include - -struct cstl_array { - size_t capacity; /* Number of maximum elements array can hold without reallocation */ - size_t count; /* Number of current elements in the array */ - struct cstl_object** pElements; /* actual storage area */ - cstl_compare compare_fn; /* Compare function pointer*/ - cstl_destroy destruct_fn; /* Destructor function pointer*/ -}; - -static struct cstl_array* -cstl_array_check_and_grow(struct cstl_array* pArray) { - if (pArray->count >= pArray->capacity) { - size_t size; - pArray->capacity = 2 * pArray->capacity; - size = pArray->capacity * sizeof(struct cstl_object*); - pArray->pElements = (struct cstl_object**) realloc(pArray->pElements, size); - } - return pArray; -} - -struct cstl_array* -cstl_array_new(size_t array_size, cstl_compare fn_c, cstl_destroy fn_d) { - struct cstl_array* pArray = (struct cstl_array*)calloc(1, sizeof(struct cstl_array)); - if (!pArray) { - return (struct cstl_array*)0; - } - pArray->capacity = array_size < 8 ? 8 : array_size; - pArray->pElements = (struct cstl_object**) calloc(pArray->capacity, sizeof(struct cstl_object*)); - if (!pArray->pElements) { - free(pArray); - return (struct cstl_array*)0; - } - pArray->compare_fn = fn_c; - pArray->destruct_fn = fn_d; - pArray->count = 0; - - return pArray; -} - -static cstl_error -cstl_array_insert(struct cstl_array* pArray, size_t index, void* elem, size_t elem_size) { - cstl_error rc = CSTL_ERROR_SUCCESS; - struct cstl_object* pObject = cstl_object_new(elem, elem_size); - if (!pObject) { - return CSTL_ARRAY_INSERT_FAILED; - } - pArray->pElements[index] = pObject; - pArray->count++; - return rc; -} - -cstl_error -cstl_array_push_back(struct cstl_array* pArray, void* elem, size_t elem_size) { - cstl_error rc = CSTL_ERROR_SUCCESS; - - if (!pArray) { - return CSTL_ARRAY_NOT_INITIALIZED; - } - cstl_array_check_and_grow(pArray); - - rc = cstl_array_insert(pArray, pArray->count, elem, elem_size); - - return rc; -} - -const void * -cstl_array_element_at(struct cstl_array* pArray, size_t index) { - if (!pArray) { - return NULL; - } - if (index >= pArray->count) { - return NULL; - } - return cstl_object_get_data(pArray->pElements[index]); -} - -size_t -cstl_array_size(struct cstl_array* pArray) { - if (pArray == (struct cstl_array*)0) { - return 0; - } - return pArray->count; -} - -size_t -cstl_array_capacity(struct cstl_array* pArray) { - if (pArray == (struct cstl_array*)0) { - return 0; - } - return pArray->capacity; -} - -cstl_bool -cstl_array_empty(struct cstl_array* pArray) { - if (pArray == (struct cstl_array*)0) { - return 0; - } - return pArray->count == 0 ? cstl_true : cstl_false; -} - -cstl_error -cstl_array_reserve(struct cstl_array* pArray, size_t new_size) { - if (pArray == (struct cstl_array*)0) { - return CSTL_ARRAY_NOT_INITIALIZED; - } - if (new_size <= pArray->capacity) { - return CSTL_ERROR_SUCCESS; - } - cstl_array_check_and_grow(pArray); - return CSTL_ERROR_SUCCESS; -} - -const void * -cstl_array_front(struct cstl_array* pArray) { - return cstl_array_element_at(pArray, 0); -} - -const void * -cstl_array_back(struct cstl_array* pArray) { - return cstl_array_element_at(pArray, pArray->count - 1); -} - -cstl_error -cstl_array_insert_at(struct cstl_array* pArray, size_t index, void* elem, size_t elem_size) { - cstl_error rc = CSTL_ERROR_SUCCESS; - if (!pArray) { - return CSTL_ARRAY_NOT_INITIALIZED; - } - if (index > pArray->capacity) { - return CSTL_ARRAY_INDEX_OUT_OF_BOUND; - } - cstl_array_check_and_grow(pArray); - - memmove(&(pArray->pElements[index + 1]), - &pArray->pElements[index], - (pArray->count - index) * sizeof(struct cstl_object*)); - - rc = cstl_array_insert(pArray, index, elem, elem_size); - - return rc; -} - -cstl_error -cstl_array_remove_from(struct cstl_array* pArray, size_t index) { - cstl_error rc = CSTL_ERROR_SUCCESS; - - if (!pArray) { - return rc; - } - if (index >= pArray->count) { - return CSTL_ARRAY_INDEX_OUT_OF_BOUND; - } - if (pArray->destruct_fn) { - void *elem = (void *) cstl_array_element_at(pArray, index); - if (elem) { - pArray->destruct_fn(elem); - } - } - cstl_object_delete(pArray->pElements[index]); - - memmove(&(pArray->pElements[index]), - &pArray->pElements[index + 1], - (pArray->count - index) * sizeof(struct cstl_object*)); - pArray->count--; - - return rc; -} - -cstl_error -cstl_array_delete(struct cstl_array* pArray) { - cstl_error rc = CSTL_ERROR_SUCCESS; - size_t i = 0; - - if (pArray == (struct cstl_array*)0) { - return CSTL_ARRAY_NOT_INITIALIZED; - } - if (pArray->destruct_fn) { - for (i = 0; i < pArray->count; i++) { - void *elem = (void *) cstl_array_element_at(pArray, i); - if ( elem ) { - pArray->destruct_fn(elem); - } - } - } - - for (i = 0; i < pArray->count; i++) { - cstl_object_delete(pArray->pElements[i]); - } - free(pArray->pElements); - free(pArray); - return rc; -} - -static const void * -cstl_array_get_next(struct cstl_iterator* pIterator) { - struct cstl_array *pArray = (struct cstl_array*)pIterator->pContainer; - if (pIterator->current_index >= cstl_array_size(pArray)) { - return (const void *)0; - } - pIterator->current_element = pArray->pElements[pIterator->current_index++]; - return pIterator->current_element; -} - -static const void* -cstl_array_get_value(struct cstl_iterator *pIterator) { - struct cstl_object *element = (struct cstl_object *)pIterator->current_element; - return cstl_object_get_data(element); -} - -static void -cstl_array_replace_value(struct cstl_iterator *pIterator, void* elem, size_t elem_size) { - struct cstl_array* pArray = (struct cstl_array*)pIterator->pContainer; - struct cstl_object *currentElement = (struct cstl_object *)pIterator->current_element; - if (pArray->destruct_fn) { - void *old_element = (void *) cstl_object_get_data(currentElement); - if (old_element) { - pArray->destruct_fn(old_element); - } - } - cstl_object_replace_raw(currentElement, elem, elem_size); -} - -struct cstl_iterator* -cstl_array_new_iterator(struct cstl_array* pArray) { - struct cstl_iterator *itr = (struct cstl_iterator*) calloc(1, sizeof(struct cstl_iterator)); - itr->next = cstl_array_get_next; - itr->current_value = cstl_array_get_value; - itr->replace_current_value = cstl_array_replace_value; - itr->pContainer = pArray; - itr->current_index = 0; - return itr; -} - -void -cstl_array_delete_iterator(struct cstl_iterator* pItr) { - free(pItr); -} - - -// c_deque.c -#include - -struct cstl_deque { - struct cstl_object**pElements; - size_t capacity; - size_t count; - size_t head; - size_t tail; - cstl_compare compare_fn; - cstl_destroy destruct_fn; -}; - -#define cstl_deque_INDEX(x) ((char *)(pDeq)->pElements + (sizeof(struct cstl_object) * (x))) - -static cstl_error -cstl_deque_insert(struct cstl_deque* pDeq, size_t index, void* elem, size_t elem_size) { - cstl_error rc = CSTL_ERROR_SUCCESS; - struct cstl_object* pObject = cstl_object_new(elem, elem_size); - if (!pObject) { - return CSTL_ARRAY_INSERT_FAILED; - } - pDeq->pElements[index] = pObject; - pDeq->count++; - return rc; -} - -static struct cstl_deque* -cstl_deque_grow(struct cstl_deque* pDeq) { - size_t size; - pDeq->capacity = pDeq->capacity * 2; - size = pDeq->capacity * sizeof(struct cstl_object*); - pDeq->pElements = (struct cstl_object**) realloc(pDeq->pElements, size); - return pDeq; -} - -struct cstl_deque* -cstl_deque_new(size_t deq_size, cstl_compare fn_c, cstl_destroy fn_d) { - struct cstl_deque* pDeq = (struct cstl_deque*)calloc(1, sizeof(struct cstl_deque)); - if (pDeq == (struct cstl_deque*)0) { - return (struct cstl_deque*)0; - } - pDeq->capacity = deq_size < 8 ? 8 : deq_size; - pDeq->pElements = (struct cstl_object**) calloc(pDeq->capacity, sizeof(struct cstl_object*)); - - if (pDeq == (struct cstl_deque*)0) { - return (struct cstl_deque*)0; - } - pDeq->compare_fn = fn_c; - pDeq->destruct_fn = fn_d; - pDeq->head = pDeq->capacity / 2; - pDeq->tail = pDeq->head + 1; - pDeq->count = 0; - - return pDeq; -} - -size_t cstl_deque_count(struct cstl_deque *deque) { - return deque->count; -} - -cstl_error -cstl_deque_push_back(struct cstl_deque* pDeq, void* elem, size_t elem_size) { - if (pDeq == (struct cstl_deque*)0) { - return CSTL_DEQUE_NOT_INITIALIZED; - } - if (pDeq->tail == pDeq->capacity) { - pDeq = cstl_deque_grow(pDeq); - } - cstl_deque_insert(pDeq, pDeq->tail, elem, elem_size); - pDeq->tail++; - - return CSTL_ERROR_SUCCESS; -} - -cstl_error -cstl_deque_push_front(struct cstl_deque* pDeq, void* elem, size_t elem_size) { - cstl_error rc = CSTL_ERROR_SUCCESS; - size_t to = 0; - size_t from = 0; - size_t count = 0; - - if (pDeq->head == 0) { - pDeq = cstl_deque_grow(pDeq); - to = (pDeq->capacity - pDeq->count) / 2; - from = pDeq->head + 1; - count = pDeq->tail - from; - memmove(&(pDeq->pElements[to]), &(pDeq->pElements[from]), count * sizeof(struct cstl_object*)); - pDeq->head = to - 1; - pDeq->tail = pDeq->head + count + 1; - } - cstl_deque_insert(pDeq, pDeq->head, elem, elem_size); - pDeq->head--; - return rc; -} - -const void * cstl_deque_front(struct cstl_deque* pDeq) { - if (pDeq) { - return cstl_deque_element_at(pDeq, 0); - } - return (struct cstl_deque*)0; -} - -const void * cstl_deque_back(struct cstl_deque* pDeq) { - if (pDeq) { - return cstl_deque_element_at(pDeq, pDeq->count - 1); - } - return (struct cstl_deque*)0; -} - -cstl_error -cstl_deque_pop_back(struct cstl_deque* pDeq) { - if (pDeq == (struct cstl_deque*)0) { - return CSTL_DEQUE_NOT_INITIALIZED; - } - if (pDeq->destruct_fn) { - void *elem = (void *) cstl_deque_element_at(pDeq, pDeq->count - 1); - if ( elem ) { - pDeq->destruct_fn(elem); - } - } - cstl_object_delete(pDeq->pElements[pDeq->tail - 1]); - pDeq->tail--; - pDeq->count--; - - return CSTL_ERROR_SUCCESS; -} - -cstl_error -cstl_deque_pop_front(struct cstl_deque* pDeq) { - if (pDeq == (struct cstl_deque*)0) { - return CSTL_DEQUE_NOT_INITIALIZED; - } - if (pDeq->destruct_fn) { - void *elem = (void *) cstl_deque_element_at(pDeq, 0); - if ( elem ) { - pDeq->destruct_fn(elem); - } - } - cstl_object_delete(pDeq->pElements[pDeq->head + 1]); - - pDeq->head++; - pDeq->count--; - - return CSTL_ERROR_SUCCESS; -} - -cstl_bool -cstl_deque_empty(struct cstl_deque* pDeq) { - if (pDeq == (struct cstl_deque*)0) { - return cstl_true; - } - return pDeq->count == 0 ? cstl_true : cstl_false; -} - -size_t -cstl_deque_size(struct cstl_deque* pDeq) { - if (pDeq == (struct cstl_deque*)0) { - return cstl_true; - } - return pDeq->count; -} - -const void * -cstl_deque_element_at(struct cstl_deque* pDeq, size_t index) { - if ((pDeq==NULL) || (index >= pDeq->count)) { - return NULL; - } - return cstl_object_get_data(pDeq->pElements[(pDeq->head + 1) + index]); -} - -cstl_error -cstl_deque_delete(struct cstl_deque* pDeq) { - size_t i = 0; - - if (pDeq == (struct cstl_deque*)0) { - return CSTL_ERROR_SUCCESS; - } - if (pDeq->destruct_fn) { - for (i = 0; i < pDeq->count; ++i) { - void *elem = (void *) cstl_deque_element_at(pDeq, i); - if ( elem ) { - pDeq->destruct_fn(elem); - } - } - } - for (i = pDeq->head + 1; i < pDeq->tail; i++) { - cstl_object_delete(pDeq->pElements[i]); - } - free(pDeq->pElements); - free(pDeq); - - return CSTL_ERROR_SUCCESS; -} - -static const void * -cstl_deque_get_next(struct cstl_iterator* pIterator) { - struct cstl_deque *pDeq = (struct cstl_deque*)pIterator->pContainer; - size_t index = pIterator->current_index; - - if (index <= pDeq->head || index >= pDeq->tail) { - return (const void *)0; - } - pIterator->current_element = pDeq->pElements[pIterator->current_index++]; - return pIterator->current_element; -} - -static const void* -cstl_deque_get_value(struct cstl_iterator *pIterator) { - struct cstl_object *element = (struct cstl_object *)pIterator->current_element; - return cstl_object_get_data(element); -} - -static void -cstl_deque_replace_value(struct cstl_iterator *pIterator, void* elem, size_t elem_size) { - struct cstl_deque* pDeq = (struct cstl_deque*)pIterator->pContainer; - struct cstl_object *currentElement = (struct cstl_object *)pIterator->current_element; - if (pDeq->destruct_fn) { - void *old_element = (void *) cstl_object_get_data(currentElement); - if (old_element) { - pDeq->destruct_fn(old_element); - } - } - cstl_object_replace_raw(currentElement, elem, elem_size); -} - -struct cstl_iterator* -cstl_deque_new_iterator(struct cstl_deque* pDeq) { - struct cstl_iterator *itr = (struct cstl_iterator*) calloc(1, sizeof(struct cstl_iterator)); - itr->next = cstl_deque_get_next; - itr->current_value = cstl_deque_get_value; - itr->replace_current_value = cstl_deque_replace_value; - itr->current_index = pDeq->head + 1; - itr->pContainer = pDeq; - return itr; -} - -void -cstl_deque_delete_iterator(struct cstl_iterator* pItr) { - free(pItr); -} - - -// c_map.c -#include - -struct cstl_map { - struct cstl_rb* root; - cstl_bool map_changed; -}; - -struct cstl_map* -cstl_map_new(cstl_compare fn_c_k, cstl_destroy fn_k_d, cstl_destroy fn_v_d) { - struct cstl_map* pMap = (struct cstl_map*)calloc(1, sizeof(struct cstl_map)); - if (pMap == (struct cstl_map*)0) { - return (struct cstl_map*)0; - } - pMap->root = cstl_rb_new(fn_c_k, fn_k_d, fn_v_d); - if (pMap->root == (struct cstl_rb*)0) { - return (struct cstl_map*)0; - } - return pMap; -} - -cstl_error -cstl_map_insert(struct cstl_map* pMap, const void* key, size_t key_size, const void* value, size_t value_size) { - cstl_error rc = CSTL_ERROR_SUCCESS; - if (pMap == (struct cstl_map*)0) { - return CSTL_MAP_NOT_INITIALIZED; - } - rc = cstl_rb_insert(pMap->root, key, key_size, value, value_size); - if (rc == CSTL_ERROR_SUCCESS) { - pMap->map_changed = cstl_true; - } - return rc; -} - -cstl_bool -cstl_map_exists(struct cstl_map* pMap, const void* key) { - cstl_bool found = cstl_false; - struct cstl_rb_node* node; - - if (pMap == (struct cstl_map*)0) { - return cstl_false; - } - node = cstl_rb_find(pMap->root, key); - if (node != (struct cstl_rb_node*)0) { - return cstl_true; - } - return found; -} - -cstl_error -cstl_map_replace(struct cstl_map* pMap, const void* key, const void* value, size_t value_size) { - struct cstl_rb_node* node; - if (pMap == (struct cstl_map*)0) { - return CSTL_MAP_NOT_INITIALIZED; - } - node = cstl_rb_find(pMap->root, key); - if (node == (struct cstl_rb_node*)0) { - return CSTL_RBTREE_KEY_NOT_FOUND; - } - - if (pMap->root->destruct_v_fn) { - void* old_element = (void *)cstl_object_get_data(node->value); - if (old_element) { - pMap->root->destruct_v_fn(old_element); - } - } - cstl_object_replace_raw(node->value, value, value_size); - return CSTL_ERROR_SUCCESS; -} - - -cstl_error -cstl_map_remove(struct cstl_map* pMap, const void* key) { - cstl_error rc = CSTL_ERROR_SUCCESS; - struct cstl_rb_node* node; - if (pMap == (struct cstl_map*)0) { - return CSTL_MAP_NOT_INITIALIZED; - } - node = cstl_rb_remove(pMap->root, key); - if (node != (struct cstl_rb_node*)0) { - void* removed_node = (void *)0; - if (pMap->root->destruct_k_fn) { - removed_node = (void *) cstl_object_get_data(node->key); - if (removed_node) { - pMap->root->destruct_k_fn(removed_node); - } - } - cstl_object_delete(node->key); - - if (pMap->root->destruct_v_fn) { - removed_node = (void *) cstl_object_get_data(node->value); - if (removed_node) { - pMap->root->destruct_v_fn(removed_node); - } - } - cstl_object_delete(node->value); - - free(node); - pMap->map_changed = cstl_true; - } - return rc; -} - -const void * -cstl_map_find(struct cstl_map* pMap, const void* key) { - struct cstl_rb_node* node; - - if (pMap == (struct cstl_map*)0) { - return (void *)0; - } - node = cstl_rb_find(pMap->root, (void *) key); - if (node == (struct cstl_rb_node*)0) { - return (void *)0; - } - return cstl_object_get_data(node->value); -} - -cstl_error -cstl_map_delete(struct cstl_map* x) { - cstl_error rc = CSTL_ERROR_SUCCESS; - if (x != (struct cstl_map*)0) { - rc = cstl_rb_delete(x->root); - free(x); - } - return rc; -} - -static struct cstl_rb_node * -cstl_map_minimum(struct cstl_map *x) { - return cstl_rb_minimum(x->root, x->root->root); -} - -static const void * -cstl_map_iter_get_next(struct cstl_iterator* pIterator) { - struct cstl_map *x = (struct cstl_map*)pIterator->pContainer; - struct cstl_rb_node *ptr = NULL; - if (!pIterator->current_element) { - pIterator->current_element = cstl_map_minimum(x); - } else { - pIterator->current_element = cstl_rb_tree_successor(x->root, (struct cstl_rb_node*)pIterator->current_element); - } - ptr = (struct cstl_rb_node*)pIterator->current_element; - if (ptr==NULL || ptr->key==NULL) { - return NULL; - } - return ptr; -} - -static const void* -cstl_map_iter_get_key(struct cstl_iterator *pIterator) { - struct cstl_rb_node *current = (struct cstl_rb_node*)pIterator->current_element; - return cstl_object_get_data(current->key); -} - -static const void* -cstl_map_iter_get_value(struct cstl_iterator *pIterator) { - struct cstl_rb_node* current = (struct cstl_rb_node*)pIterator->current_element; - return cstl_object_get_data(current->value); -} - -static void -cstl_map_iter_replace_value(struct cstl_iterator *pIterator, void* elem, size_t elem_size) { - struct cstl_map *pMap = (struct cstl_map*)pIterator->pContainer; - struct cstl_rb_node* node = (struct cstl_rb_node*)pIterator->current_element; - - if (pMap->root->destruct_v_fn) { - void *old_element = (void *) cstl_object_get_data(node->value); - if (old_element) { - pMap->root->destruct_v_fn(old_element); - } - } - cstl_object_replace_raw(node->value, elem, elem_size); -} - -struct cstl_iterator* -cstl_map_new_iterator(struct cstl_map* pMap) { - struct cstl_iterator *itr = (struct cstl_iterator*)calloc(1, sizeof(struct cstl_iterator)); - itr->next = cstl_map_iter_get_next; - itr->current_key = cstl_map_iter_get_key; - itr->current_value = cstl_map_iter_get_value; - itr->replace_current_value = cstl_map_iter_replace_value; - itr->pContainer = pMap; - itr->current_index = 0; - itr->current_element = (void*)0; - pMap->map_changed = cstl_false; - return itr; -} - -void -cstl_map_delete_iterator(struct cstl_iterator* pItr) { - free(pItr); -} - -void cstl_map_traverse(struct cstl_map *map, map_iter_callback cb, void *p) { - struct cstl_iterator *iterator; - const void *element; - cstl_bool stop = cstl_false; - if (map==NULL || cb==NULL) { - return; - } - iterator = cstl_map_new_iterator(map); - while( (element = iterator->next(iterator)) ) { - const void *key = iterator->current_key(iterator); - const void *value = iterator->current_value(iterator); - cb(map, key, value, &stop, p); - if (stop != cstl_false) { break; } - if (map->map_changed) { - cstl_map_delete_iterator(iterator); - iterator = cstl_map_new_iterator(map); - } - } - cstl_map_delete_iterator(iterator); -} - - -// c_rb.c -#include -#include -#include - -#define rb_sentinel(pTree) &(pTree)->sentinel - -static void debug_verify_properties(struct cstl_rb*); -static void debug_verify_property_1(struct cstl_rb*, struct cstl_rb_node*); -static void debug_verify_property_2(struct cstl_rb*, struct cstl_rb_node*); -static int debug_node_color(struct cstl_rb*, struct cstl_rb_node* n); -static void debug_verify_property_4(struct cstl_rb*, struct cstl_rb_node*); -static void debug_verify_property_5(struct cstl_rb*, struct cstl_rb_node*); -static void debug_verify_property_5_helper(struct cstl_rb*, struct cstl_rb_node*, int, int*); - -static void -__left_rotate(struct cstl_rb* pTree, struct cstl_rb_node* x) { - struct cstl_rb_node* y; - y = x->right; - x->right = y->left; - if (y->left != rb_sentinel(pTree)) { - y->left->parent = x; - } - if (y != rb_sentinel(pTree)) { - y->parent = x->parent; - } - if (x->parent) { - if (x == x->parent->left) { - x->parent->left = y; - } else { - x->parent->right = y; - } - } else { - pTree->root = y; - } - y->left = x; - if (x != rb_sentinel(pTree)) { - x->parent = y; - } -} - -static void -__right_rotate(struct cstl_rb* pTree, struct cstl_rb_node* x) { - struct cstl_rb_node* y = x->left; - x->left = y->right; - if (y->right != rb_sentinel(pTree)) { - y->right->parent = x; - } - if (y != rb_sentinel(pTree)) { - y->parent = x->parent; - } - if (x->parent) { - if (x == x->parent->right) { - x->parent->right = y; - } else { - x->parent->left = y; - } - } else { - pTree->root = y; - } - y->right = x; - if (x != rb_sentinel(pTree)) { - x->parent = y; - } -} - -struct cstl_rb* -cstl_rb_new(cstl_compare fn_c, cstl_destroy fn_ed, cstl_destroy fn_vd) { - struct cstl_rb* pTree = (struct cstl_rb*)calloc(1, sizeof(struct cstl_rb)); - if (pTree == (struct cstl_rb*)0) { - return (struct cstl_rb*)0; - } - pTree->compare_fn = fn_c; - pTree->destruct_k_fn = fn_ed; - pTree->destruct_v_fn = fn_vd; - pTree->root = rb_sentinel(pTree); - pTree->sentinel.left = rb_sentinel(pTree); - pTree->sentinel.right = rb_sentinel(pTree); - pTree->sentinel.parent = (struct cstl_rb_node*)0; - pTree->sentinel.color = cstl_black; - - return pTree; -} - -static void -__rb_insert_fixup(struct cstl_rb* pTree, struct cstl_rb_node* x) { - while (x != pTree->root && x->parent->color == cstl_red) { - if (x->parent == x->parent->parent->left) { - struct cstl_rb_node* y = x->parent->parent->right; - if (y->color == cstl_red) { - x->parent->color = cstl_black; - y->color = cstl_black; - x->parent->parent->color = cstl_red; - x = x->parent->parent; - } else { - if (x == x->parent->right) { - x = x->parent; - __left_rotate(pTree, x); - } - x->parent->color = cstl_black; - x->parent->parent->color = cstl_red; - __right_rotate(pTree, x->parent->parent); - } - } else { - struct cstl_rb_node* y = x->parent->parent->left; - if (y->color == cstl_red) { - x->parent->color = cstl_black; - y->color = cstl_black; - x->parent->parent->color = cstl_red; - x = x->parent->parent; - } else { - if (x == x->parent->left) { - x = x->parent; - __right_rotate(pTree, x); - } - x->parent->color = cstl_black; - x->parent->parent->color = cstl_red; - __left_rotate(pTree, x->parent->parent); - } - } - } - pTree->root->color = cstl_black; -} - -struct cstl_rb_node* -cstl_rb_find(struct cstl_rb* pTree, const void* key) { - struct cstl_rb_node* x = pTree->root; - - while (x != rb_sentinel(pTree)) { - const void *cur_key = cstl_object_get_data(x->key); - int c = pTree->compare_fn(key, cur_key); - if (c == 0) { - break; - } else { - x = c < 0 ? x->left : x->right; - } - } - if (x == rb_sentinel(pTree)) { - return (struct cstl_rb_node*)0; - } - return x; -} - -cstl_error -cstl_rb_insert(struct cstl_rb* pTree, const void* k, size_t key_size, const void* v, size_t value_size) { - cstl_error rc = CSTL_ERROR_SUCCESS; - struct cstl_rb_node* x; - struct cstl_rb_node* y; - struct cstl_rb_node* z; - - x = (struct cstl_rb_node*)calloc(1, sizeof(struct cstl_rb_node)); - if (x == (struct cstl_rb_node*)0) { - return CSTL_ERROR_MEMORY; - } - x->left = rb_sentinel(pTree); - x->right = rb_sentinel(pTree); - x->color = cstl_red; - - x->key = cstl_object_new(k, key_size); - if (v) { - x->value = cstl_object_new(v, value_size); - } else { - x->value = (struct cstl_object*)0; - } - - y = pTree->root; - z = (struct cstl_rb_node*)0; - - while (y != rb_sentinel(pTree)) { - const void *cur_key = cstl_object_get_data(y->key); - const void *new_key = cstl_object_get_data(x->key); - int c = pTree->compare_fn(new_key, cur_key); - if (c == 0) { - cstl_object_delete(x->key); - cstl_object_delete(x->value); - free(x); - return CSTL_RBTREE_KEY_DUPLICATE; - } - z = y; - if (c < 0) { - y = y->left; - } else { - y = y->right; - } - } - x->parent = z; - if (z) { - const void *cur_key = cstl_object_get_data(z->key); - const void *new_key = cstl_object_get_data(x->key); - int c = pTree->compare_fn(new_key, cur_key); - if (c < 0) { - z->left = x; - } else { - z->right = x; - } - } else { - pTree->root = x; - } - __rb_insert_fixup(pTree, x); - - debug_verify_properties(pTree); - return rc; -} - -static void -__rb_remove_fixup(struct cstl_rb* pTree, struct cstl_rb_node* x) { - while (x != pTree->root && x->color == cstl_black) { - if (x == x->parent->left) { - struct cstl_rb_node* w = x->parent->right; - if (w->color == cstl_red) { - w->color = cstl_black; - x->parent->color = cstl_red; - __left_rotate(pTree, x->parent); - w = x->parent->right; - } - if (w->left->color == cstl_black && w->right->color == cstl_black) { - w->color = cstl_red; - x = x->parent; - } else { - if (w->right->color == cstl_black) { - w->left->color = cstl_black; - w->color = cstl_red; - __right_rotate(pTree, w); - w = x->parent->right; - } - w->color = x->parent->color; - x->parent->color = cstl_black; - w->right->color = cstl_black; - __left_rotate(pTree, x->parent); - x = pTree->root; - } - } else { - struct cstl_rb_node* w = x->parent->left; - if (w->color == cstl_red) { - w->color = cstl_black; - x->parent->color = cstl_red; - __right_rotate(pTree, x->parent); - w = x->parent->left; - } - if (w->right->color == cstl_black && w->left->color == cstl_black) { - w->color = cstl_red; - x = x->parent; - } else { - if (w->left->color == cstl_black) { - w->right->color = cstl_black; - w->color = cstl_red; - __left_rotate(pTree, w); - w = x->parent->left; - } - w->color = x->parent->color; - x->parent->color = cstl_black; - w->left->color = cstl_black; - __right_rotate(pTree, x->parent); - x = pTree->root; - } - } - } - x->color = cstl_black; -} - -static struct cstl_rb_node* -__remove_c_rb(struct cstl_rb* pTree, struct cstl_rb_node* z) { - struct cstl_rb_node* x = (struct cstl_rb_node*)0; - struct cstl_rb_node* y = (struct cstl_rb_node*)0; - - if (z->left == rb_sentinel(pTree) || z->right == rb_sentinel(pTree)) { - y = z; - } else { - y = z->right; - while (y->left != rb_sentinel(pTree)) { - y = y->left; - } - } - if (y->left != rb_sentinel(pTree)) { - x = y->left; - } else { - x = y->right; - } - x->parent = y->parent; - if (y->parent) { - if (y == y->parent->left) { - y->parent->left = x; - } else { - y->parent->right = x; - } - } else { - pTree->root = x; - } - if (y != z) { - struct cstl_object* tmp; - tmp = z->key; - z->key = y->key; - y->key = tmp; - - tmp = z->value; - z->value = y->value; - y->value = tmp; - } - if (y->color == cstl_black) { - __rb_remove_fixup(pTree, x); - } - debug_verify_properties(pTree); - return y; -} - -struct cstl_rb_node* -cstl_rb_remove(struct cstl_rb* pTree, const void* key) { - struct cstl_rb_node* z = (struct cstl_rb_node*)0; - - z = pTree->root; - while (z != rb_sentinel(pTree)) { - const void *cur_key = cstl_object_get_data(z->key); - int c = pTree->compare_fn(key, cur_key); - if (c == 0) { - break; - } else { - z = (c < 0) ? z->left : z->right; - } - } - if (z == rb_sentinel(pTree)) { - return (struct cstl_rb_node*)0; - } - return __remove_c_rb(pTree, z); -} - -static void -__delete_c_rb_node(struct cstl_rb* pTree, struct cstl_rb_node* x) { - - if (pTree->destruct_k_fn) { - void *key = (void *) cstl_object_get_data(x->key); - pTree->destruct_k_fn(key); - } - cstl_object_delete(x->key); - - if (x->value) { - if (pTree->destruct_v_fn) { - void *value = (void *) cstl_object_get_data(x->value); - pTree->destruct_v_fn(value); - } - cstl_object_delete(x->value); - } -} - -cstl_error -cstl_rb_delete(struct cstl_rb* pTree) { - cstl_error rc = CSTL_ERROR_SUCCESS; - struct cstl_rb_node* z = pTree->root; - - while (z != rb_sentinel(pTree)) { - if (z->left != rb_sentinel(pTree)) { - z = z->left; - } else if (z->right != rb_sentinel(pTree)) { - z = z->right; - } else { - __delete_c_rb_node(pTree, z); - if (z->parent) { - z = z->parent; - if (z->left != rb_sentinel(pTree)) { - free(z->left); - z->left = rb_sentinel(pTree); - } else if (z->right != rb_sentinel(pTree)) { - free(z->right); - z->right = rb_sentinel(pTree); - } - } else { - free(z); - z = rb_sentinel(pTree); - } - } - } - free(pTree); - return rc; -} - -struct cstl_rb_node * -cstl_rb_minimum(struct cstl_rb* pTree, struct cstl_rb_node* x) { - while (x->left != rb_sentinel(pTree)) { - x = x->left; - } - return x; -} - -struct cstl_rb_node * -cstl_rb_maximum(struct cstl_rb* pTree, struct cstl_rb_node* x) { - while (x->right != rb_sentinel(pTree)) { - x = x->right; - } - return x; -} - -cstl_bool -cstl_rb_empty(struct cstl_rb* pTree) { - if (pTree->root != rb_sentinel(pTree)) { - return cstl_true; - } - return cstl_false; -} - -struct cstl_rb_node* -cstl_rb_tree_successor(struct cstl_rb* pTree, struct cstl_rb_node* x) { - struct cstl_rb_node *y = (struct cstl_rb_node*)0; - if (x->right != rb_sentinel(pTree)) { - return cstl_rb_minimum(pTree, x->right); - } - if (x == cstl_rb_maximum(pTree, pTree->root)) { - return (struct cstl_rb_node*)0; - } - y = x->parent; - while (y != rb_sentinel(pTree) && x == y->right) { - x = y; - y = y->parent; - } - return y; -} - -/* -struct cstl_rb_node * -cstl_rb_get_next(struct cstl_rb* pTree, struct cstl_rb_node**current, struct cstl_rb_node**pre) { - struct cstl_rb_node* prev_current; - while ((*current) != rb_sentinel(pTree)) { - if ((*current)->left == rb_sentinel(pTree)) { - prev_current = (*current); - (*current) = (*current)->right; - return prev_current; - } else { - (*pre) = (*current)->left; - while ((*pre)->right != rb_sentinel(pTree) && (*pre)->right != (*current)) - (*pre) = (*pre)->right; - if ((*pre)->right == rb_sentinel(pTree)) { - (*pre)->right = (*current); - (*current) = (*current)->left; - } else { - (*pre)->right = rb_sentinel(pTree); - prev_current = (*current); - (*current) = (*current)->right; - return prev_current; - } - } - } - return (struct cstl_rb_node*)0; -} */ - -void debug_verify_properties(struct cstl_rb* t) { - debug_verify_property_1(t, t->root); - debug_verify_property_2(t, t->root); - debug_verify_property_4(t, t->root); - debug_verify_property_5(t, t->root); -} - -void debug_verify_property_1(struct cstl_rb* pTree, struct cstl_rb_node* n) { - assert(debug_node_color(pTree, n) == cstl_red || debug_node_color(pTree, n) == cstl_black); - if (n == rb_sentinel(pTree)) { return; } - debug_verify_property_1(pTree, n->left); - debug_verify_property_1(pTree, n->right); -} - -void debug_verify_property_2(struct cstl_rb* pTree, struct cstl_rb_node* root) { - (void)pTree; (void)root; - assert(debug_node_color(pTree, root) == cstl_black); -} - -int debug_node_color(struct cstl_rb* pTree, struct cstl_rb_node* n) { - return n == rb_sentinel(pTree) ? cstl_black : n->color; -} - -void debug_verify_property_4(struct cstl_rb* pTree, struct cstl_rb_node* n) { - if (debug_node_color(pTree, n) == cstl_red) { - assert(debug_node_color(pTree, n->left) == cstl_black); - assert(debug_node_color(pTree, n->right) == cstl_black); - assert(debug_node_color(pTree, n->parent) == cstl_black); - } - if (n == rb_sentinel(pTree)) { return; } - debug_verify_property_4(pTree, n->left); - debug_verify_property_4(pTree, n->right); -} - -void debug_verify_property_5(struct cstl_rb* pTree, struct cstl_rb_node* root) { - int black_count_path = -1; - debug_verify_property_5_helper(pTree, root, 0, &black_count_path); -} - -void debug_verify_property_5_helper(struct cstl_rb* pTree, struct cstl_rb_node* n, int black_count, int* path_black_count) { - if (debug_node_color(pTree, n) == cstl_black) { - black_count++; - } - if (n == rb_sentinel(pTree)) { - if (*path_black_count == -1) { - *path_black_count = black_count; - } else { - assert(black_count == *path_black_count); - } - return; - } - debug_verify_property_5_helper(pTree, n->left, black_count, path_black_count); - debug_verify_property_5_helper(pTree, n->right, black_count, path_black_count); -} - - -// c_set.c -#include - -struct cstl_set { - struct cstl_rb* root; -}; - -struct cstl_set* -cstl_set_new(cstl_compare fn_c, cstl_destroy fn_d) { - struct cstl_set* pSet = (struct cstl_set*)calloc(1, sizeof(struct cstl_set)); - if (pSet == (struct cstl_set*)0) { - return (struct cstl_set*)0; - } - pSet->root = cstl_rb_new(fn_c, fn_d, (void*)0); - if (pSet->root == (struct cstl_rb*)0) { - return (struct cstl_set*)0; - } - return pSet; -} - -cstl_error -cstl_set_insert(struct cstl_set* pSet, void* key, size_t key_size) { - if (pSet == (struct cstl_set*)0) { - return CSTL_SET_NOT_INITIALIZED; - } - return cstl_rb_insert(pSet->root, key, key_size, (void*)0, 0); -} - -cstl_bool -cstl_set_exists(struct cstl_set* pSet, void* key) { - cstl_bool found = cstl_false; - struct cstl_rb_node* node; - - if (pSet == (struct cstl_set*)0) { - return cstl_false; - } - node = cstl_rb_find(pSet->root, key); - if (node != (struct cstl_rb_node*)0) { - return cstl_true; - } - return found; -} - -cstl_error -cstl_set_remove(struct cstl_set* pSet, void* key) { - cstl_error rc = CSTL_ERROR_SUCCESS; - struct cstl_rb_node* node; - if (pSet == (struct cstl_set*)0) { - return CSTL_SET_NOT_INITIALIZED; - } - node = cstl_rb_remove(pSet->root, key); - if (node != (struct cstl_rb_node*)0) { - if (pSet->root->destruct_k_fn) { - void *key = (void *) cstl_object_get_data(node->key); - if (key) { - pSet->root->destruct_k_fn(key); - } - } - cstl_object_delete(node->key); - - free(node); - } - return rc; -} - -const void * cstl_set_find(struct cstl_set* pSet, const void* key) { - struct cstl_rb_node* node; - - if (pSet == (struct cstl_set*)0) { - return NULL; - } - node = cstl_rb_find(pSet->root, key); - if (node == (struct cstl_rb_node*)0) { - return NULL; - } - return cstl_object_get_data(node->key); -} - -cstl_error -cstl_set_delete(struct cstl_set* x) { - cstl_error rc = CSTL_ERROR_SUCCESS; - if (x != (struct cstl_set*)0) { - rc = cstl_rb_delete(x->root); - free(x); - } - return rc; -} - -static struct cstl_rb_node * -cstl_set_minimum(struct cstl_set *x) { - return cstl_rb_minimum(x->root, x->root->root); -} - -static const void * -cstl_set_get_next(struct cstl_iterator* pIterator) { - struct cstl_set *x = (struct cstl_set*)pIterator->pContainer; - struct cstl_rb_node *ptr = NULL; - if (!pIterator->current_element) { - pIterator->current_element = cstl_set_minimum(x); - } else { - pIterator->current_element = cstl_rb_tree_successor(x->root, (struct cstl_rb_node*)pIterator->current_element); - } - ptr = (struct cstl_rb_node*)pIterator->current_element; - if (ptr==NULL || ptr->key==NULL) { - return NULL; - } - return ptr; -} - -static const void* -cstl_set_get_key(struct cstl_iterator* pIterator) { - struct cstl_rb_node *current = (struct cstl_rb_node*)pIterator->current_element; - return cstl_object_get_data(current->key); -} - -static const void* -cstl_set_get_value(struct cstl_iterator *pIterator) { - return cstl_set_get_key(pIterator); -} - -struct cstl_iterator* -cstl_set_new_iterator(struct cstl_set* pSet) { - struct cstl_iterator *itr = (struct cstl_iterator*) calloc(1, sizeof(struct cstl_iterator)); - itr->next = cstl_set_get_next; - itr->current_key = cstl_set_get_key; - itr->current_value = cstl_set_get_value; - itr->pContainer = pSet; - itr->current_index = 0; - itr->current_element = (void*)0; - return itr; -} - -void -cstl_set_delete_iterator(struct cstl_iterator* pItr) { - free(pItr); -} - - -// c_list.c - -struct cstl_list_node { - struct cstl_object* elem; - struct cstl_list_node *next; -}; - -struct cstl_list { - struct cstl_list_node* head; - cstl_destroy destruct_fn; - cstl_compare compare_key_fn; - size_t size; -}; - -struct cstl_list* -cstl_list_new(cstl_destroy fn_d, cstl_compare fn_c) { - struct cstl_list* pList = (struct cstl_list*)calloc(1, sizeof(struct cstl_list)); - pList->head = (struct cstl_list_node*)0; - pList->destruct_fn = fn_d; - pList->compare_key_fn = fn_c; - pList->size = 0; - return pList; -} - -size_t cstl_list_count(struct cstl_list* pList) { - return pList->size; -} - -void -cstl_list_destroy(struct cstl_list* pList) { - cstl_list_clear(pList); - free(pList); -} - -void cstl_list_clear(struct cstl_list* pList) { - while (pList->size != 0) { - cstl_list_remove(pList, 0); - } -} - -cstl_error -cstl_list_push_back(struct cstl_list* pList, void* elem, size_t elem_size) { - return cstl_list_insert(pList, pList->size, elem, elem_size); -} - -static void -__cstl_slist_remove(struct cstl_list* pList, struct cstl_list_node* pSlistNode) { - if (pList->destruct_fn) { - void *elem = (void *)cstl_object_get_data(pSlistNode->elem); - if (elem) { - pList->destruct_fn(elem); - } - } - cstl_object_delete(pSlistNode->elem); - - free(pSlistNode); -} - -void -cstl_list_remove(struct cstl_list* pList, size_t pos) { - size_t i = 0; - - struct cstl_list_node* current = pList->head; - struct cstl_list_node* previous = (struct cstl_list_node*)0; - - if (pos >= pList->size) { return; } - - if (pos == 0) { - pList->head = current->next; - __cstl_slist_remove(pList, current); - pList->size--; - return; - } - for (i = 0; i < pos; ++i) { - previous = current; - current = current->next; - } - previous->next = current->next; - __cstl_slist_remove(pList, current); - - pList->size--; -} - -cstl_error -cstl_list_insert(struct cstl_list* pList, size_t pos, void* elem, size_t elem_size) { - size_t i = 0; - struct cstl_list_node* current = pList->head; - struct cstl_list_node* new_node = (struct cstl_list_node*)0; - struct cstl_list_node* previous = (struct cstl_list_node*)0; - - if (pos > pList->size) { - pos = pList->size; - } - - new_node = (struct cstl_list_node*)calloc(1, sizeof(struct cstl_list_node)); - new_node->next = (struct cstl_list_node*)0; - new_node->elem = cstl_object_new(elem, elem_size); - if (!new_node->elem) { - free(new_node); - return CSTL_SLIST_INSERT_FAILED; - } - - if (pos == 0) { - new_node->next = pList->head; - pList->head = new_node; - pList->size++; - return CSTL_ERROR_SUCCESS; - } - - for (i = 0; i < pos; ++i) { - previous = current; - current = current->next; - } - - previous->next = new_node; - new_node->next = current; - pList->size++; - - return CSTL_ERROR_SUCCESS; -} - -void -cstl_list_for_each(struct cstl_list* pList, void(*fn)(const void *elem, void *p), void *p) { - struct cstl_list_node* current = pList->head; - if (fn == NULL) { - return; - } - while (current != (struct cstl_list_node*)0) { - fn(cstl_object_get_data(current->elem), p); - current = current->next; - } -} - -const void * -cstl_list_find(struct cstl_list* pList, void* find_value) { - struct cstl_list_node* current = pList->head; - while (current != (struct cstl_list_node*)0) { - const void *tmp = cstl_object_get_data(current->elem); - if (pList->compare_key_fn(find_value, tmp) == 0) { - return tmp; - } - current = current->next; - } - return NULL; -} - -const void * cstl_list_element_at(struct cstl_list* pList, size_t pos) { - struct cstl_list_node* current = NULL; - size_t index = 0; - if (pList==NULL || pList->size==0) { - return NULL; - } - if (pos >= pList->size) { - pos = (pList->size - 1); - } - current = pList->head; - for (index=0; indexnext; - } - return current ? cstl_object_get_data(current->elem) : NULL; -} - -size_t cstl_list_size(struct cstl_list* pList) { - return pList ? pList->size : 0; -} - -static const void * -cstl_list_get_next(struct cstl_iterator* pIterator) { - struct cstl_list *pList = (struct cstl_list*)pIterator->pContainer; - if (!pIterator->current_element) { - pIterator->current_element = (struct cstl_list_node*)pList->head; - } else { - pIterator->current_element = ((struct cstl_list_node*)pIterator->current_element)->next; - } - return pIterator->current_element; -} - -static const void* -cstl_list_get_value(struct cstl_iterator *pIterator) { - struct cstl_object *pObj = ((struct cstl_list_node*)pIterator->current_element)->elem; - return cstl_object_get_data(pObj); -} - -static void -cstl_list_replace_value(struct cstl_iterator *pIterator, void* elem, size_t elem_size) { - struct cstl_list* pList = (struct cstl_list*)pIterator->pContainer; - struct cstl_object *pObj = ((struct cstl_list_node*)pIterator->current_element)->elem; - - if (pList->destruct_fn) { - void *old_element = (void *) cstl_object_get_data(pObj); - if (old_element) { - pList->destruct_fn(old_element); - } - } - cstl_object_replace_raw(pObj, elem, elem_size); -} - -struct cstl_iterator* -cstl_list_new_iterator(struct cstl_list* pList) { - struct cstl_iterator *itr = (struct cstl_iterator*) calloc(1, sizeof(struct cstl_iterator)); - itr->next = cstl_list_get_next; - itr->current_value = cstl_list_get_value; - itr->replace_current_value = cstl_list_replace_value; - itr->pContainer = pList; - itr->current_element = (void*)0; - itr->current_index = 0; - return itr; -} - -void -cstl_list_delete_iterator(struct cstl_iterator* pItr) { - free(pItr); -} - - -// c_util.c -#include -#include - -void -cstl_copy(void* destination, void* source, size_t size) { - memcpy((char*)destination, source, size); -} - -void -cstl_get(void* destination, void* source, size_t size) { - memcpy(destination, (char*)source, size); -} - -char * cstl_strdup(const char *ptr) { -#ifdef WIN32 - return _strdup(ptr); -#else - return strdup(ptr); -#endif -} - -struct cstl_object { - void* raw_data; - size_t size; -}; - -struct cstl_object* -cstl_object_new(const void* inObject, size_t obj_size) { - struct cstl_object* tmp = (struct cstl_object*)calloc(1, sizeof(struct cstl_object)); - void *raw_data = (void *)0; - if (!tmp) { - return (struct cstl_object*)0; - } - tmp->size = obj_size; - raw_data = (void*)calloc(obj_size, sizeof(char)); - if (!raw_data) { - free(tmp); - return (struct cstl_object*)0; - } - memcpy(raw_data, inObject, obj_size); - tmp->raw_data = raw_data; - return tmp; -} - -const void * cstl_object_get_data(struct cstl_object *inObject) { - return inObject->raw_data; -} - -void -cstl_object_replace_raw(struct cstl_object* current_object, const void* elem, size_t elem_size) { - free(current_object->raw_data); - current_object->raw_data = (void*)calloc(elem_size, sizeof(char)); - memcpy(current_object->raw_data, elem, elem_size); -} - -void -cstl_object_delete(struct cstl_object* inObject) { - if (inObject) { - free(inObject->raw_data); - free(inObject); - } -} diff --git a/src/obfs/cstl_lib.h b/src/obfs/cstl_lib.h deleted file mode 100644 index dcfa35596..000000000 --- a/src/obfs/cstl_lib.h +++ /dev/null @@ -1,236 +0,0 @@ -/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** - * This file is part of cstl library - * Copyright (C) 2011 Avinash Dongre ( dongre.avinash@gmail.com ) - * Copyright (C) 2018 ssrlive ( ssrlivebox@gmail.com ) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ - -#ifndef __CSTL_LIB_H__ -#define __CSTL_LIB_H__ - -#include - -//#include "c_errors.h" -/* ------------------------------------------------------------------------*/ -/* C O M M O N E R R O R C O D E */ -/* ------------------------------------------------------------------------*/ -#define CSTL_ERROR_SUCCESS 0 -#define CSTL_ERROR_ERROR 1 -#define CSTL_ERROR_MEMORY 2 -#define CSTL_ELEMENT_RETURN_ERROR 3 -/* ------------------------------------------------------------------------*/ -/* D Y N A M I C A R R A Y E R R O R C O D E S */ -/* ------------------------------------------------------------------------*/ -#define CSTL_ARRAY_NOT_INITIALIZED 101 -#define CSTL_ARRAY_INDEX_OUT_OF_BOUND 102 -#define CSTL_ARRAY_INSERT_FAILED 103 - -#define CSTL_DEQUE_NOT_INITIALIZED 201 -#define CSTL_DEQUE_INDEX_OUT_OF_BOUND 202 - -#define CSTL_RBTREE_NOT_INITIALIZED 401 -#define CSTL_RBTREE_KEY_DUPLICATE 402 -#define CSTL_RBTREE_KEY_NOT_FOUND 403 - -#define CSTL_SET_NOT_INITIALIZED 501 -#define CSTL_SET_INVALID_INPUT 502 - -#define CSTL_MAP_NOT_INITIALIZED 501 -#define CSTL_MAP_INVALID_INPUT 502 - -#define CSTL_SLIST_INSERT_FAILED 601 - - -/* ------------------------------------------------------------------------*/ -/* C O M M O N D E F I N I T O N S */ -/* ------------------------------------------------------------------------*/ - -typedef void (*cstl_destroy)(void*); -typedef int (*cstl_compare)(const void*, const void*); -typedef void (*cstl_traversal)( void*); - -typedef int cstl_error; -typedef int cstl_bool; - -#define cstl_black 0 -#define cstl_red 1 -#define cstl_true 1 -#define cstl_false 0 - -/* ------------------------------------------------------------------------*/ -/* P A I R */ -/* ------------------------------------------------------------------------*/ - -struct cstl_iterator { - const void * (*next)(struct cstl_iterator *pIterator); - void (*replace_current_value)(struct cstl_iterator *pIterator, void *new_value, size_t size); - const void* (*current_key)(struct cstl_iterator *pIterator); - const void* (*current_value)(struct cstl_iterator *pIterator); - void* pContainer; - size_t current_index; - void* current_element; -}; - - -// #include "c_array.h" -struct cstl_array; - -extern struct cstl_array* cstl_array_new ( size_t init_size, cstl_compare fn_c, cstl_destroy fn_d); -extern cstl_error cstl_array_push_back ( struct cstl_array* pArray, void* elem, size_t elem_size); -extern const void * cstl_array_element_at(struct cstl_array* pArray, size_t index); -extern cstl_error cstl_array_insert_at ( struct cstl_array* pArray, size_t index, void* elem, size_t elem_size); -extern size_t cstl_array_size( struct cstl_array* pArray); -extern size_t cstl_array_capacity( struct cstl_array* pArray ); -extern cstl_bool cstl_array_empty( struct cstl_array* pArray); -extern cstl_error cstl_array_reserve( struct cstl_array* pArray, size_t pos); -extern const void * cstl_array_front(struct cstl_array* pArray); -extern const void * cstl_array_back(struct cstl_array* pArray); -extern cstl_error cstl_array_remove_from ( struct cstl_array*, size_t pos); -extern cstl_error cstl_array_delete( struct cstl_array* pArray); - -extern struct cstl_iterator* cstl_array_new_iterator(struct cstl_array* pArray); -extern void cstl_array_delete_iterator ( struct cstl_iterator* pItr); - - -// #include "c_deque.h" -struct cstl_deque; - -extern struct cstl_deque* cstl_deque_new( size_t deq_size , cstl_compare fn_c, cstl_destroy fn_d); -extern size_t cstl_deque_count(struct cstl_deque *deque); -extern cstl_error cstl_deque_push_back (struct cstl_deque* pDeq, void* elem, size_t elem_size); -extern cstl_error cstl_deque_push_front(struct cstl_deque* pDeq, void* elem, size_t elem_size); - -extern const void * cstl_deque_front(struct cstl_deque* pDeq); -extern const void * cstl_deque_back(struct cstl_deque* pDeq); -extern cstl_error cstl_deque_pop_back (struct cstl_deque* pDeq); -extern cstl_error cstl_deque_pop_front (struct cstl_deque* pDeq); -extern cstl_bool cstl_deque_empty (struct cstl_deque* pDeq); -extern size_t cstl_deque_size ( struct cstl_deque* pDeq); -extern cstl_error cstl_deque_delete ( struct cstl_deque* pDeq); -extern const void * cstl_deque_element_at(struct cstl_deque* pDeq, size_t index); - -extern struct cstl_iterator* cstl_deque_new_iterator(struct cstl_deque* pDeq); -extern void cstl_deque_delete_iterator ( struct cstl_iterator* pItr); - - -//#include "c_rb.h" - -struct cstl_object; - -struct cstl_rb_node { - struct cstl_rb_node *left; - struct cstl_rb_node *right; - struct cstl_rb_node *parent; - int color; - struct cstl_object* key; - struct cstl_object* value; -}; - -struct cstl_rb { - struct cstl_rb_node* root; - struct cstl_rb_node sentinel; - cstl_destroy destruct_k_fn; - cstl_destroy destruct_v_fn; - cstl_compare compare_fn; -}; - -extern struct cstl_rb* cstl_rb_new(cstl_compare fn_c,cstl_destroy fn_ed, cstl_destroy fn_vd ); -extern cstl_error cstl_rb_insert(struct cstl_rb* pTree, const void* key, size_t key_size, const void* value, size_t value_size); -extern struct cstl_rb_node* cstl_rb_find (struct cstl_rb* pTree, const void* key); -extern struct cstl_rb_node* cstl_rb_remove (struct cstl_rb* pTree, const void* key); -extern cstl_error cstl_rb_delete (struct cstl_rb* pTree); -extern cstl_bool cstl_rb_empty (struct cstl_rb* pTree); - -extern struct cstl_rb_node *cstl_rb_minimum( struct cstl_rb* pTree, struct cstl_rb_node* x ); -extern struct cstl_rb_node* cstl_rb_tree_successor(struct cstl_rb* pTree, struct cstl_rb_node* x); - - -// #include "c_set.h" -struct cstl_set; - -extern struct cstl_set* cstl_set_new( cstl_compare fn_c, cstl_destroy fn_d); -extern cstl_error cstl_set_insert ( struct cstl_set* pSet, void* key, size_t key_size); -extern cstl_bool cstl_set_exists ( struct cstl_set* pSet, void* key); -extern cstl_error cstl_set_remove ( struct cstl_set* pSet, void* key); -extern const void * cstl_set_find ( struct cstl_set* pSet, const void* key); -extern cstl_error cstl_set_delete ( struct cstl_set* pSet); - -extern struct cstl_iterator* cstl_set_new_iterator(struct cstl_set* pSet); -extern void cstl_set_delete_iterator ( struct cstl_iterator* pItr); - - -//#include "c_map.h" -struct cstl_map; - -extern struct cstl_map* cstl_map_new( cstl_compare fn_c_k, cstl_destroy fn_k_d, cstl_destroy fn_v_d); -extern cstl_error cstl_map_insert ( struct cstl_map* pMap, const void* key, size_t key_size, const void* value, size_t value_size); -extern cstl_bool cstl_map_exists ( struct cstl_map* pMap, const void* key); -extern cstl_error cstl_map_replace(struct cstl_map* pMap, const void* key, const void* value, size_t value_size); -extern cstl_error cstl_map_remove ( struct cstl_map* pMap, const void* key); -extern const void * cstl_map_find(struct cstl_map* pMap, const void* key); -extern cstl_error cstl_map_delete ( struct cstl_map* pMap); - -extern struct cstl_iterator* cstl_map_new_iterator(struct cstl_map* pMap); -extern void cstl_map_delete_iterator ( struct cstl_iterator* pItr); - -typedef void(*map_iter_callback)(struct cstl_map *map, const void *key, const void *value, cstl_bool *stop, void *p); -extern void cstl_map_traverse(struct cstl_map *map, map_iter_callback cb, void *p); - - -//#include "c_list.h" -struct cstl_list; - -extern struct cstl_list * cstl_list_new (cstl_destroy fn_d, cstl_compare fn_c); -extern size_t cstl_list_count(struct cstl_list* pList); -extern void cstl_list_destroy(struct cstl_list* pList); -extern void cstl_list_clear(struct cstl_list* pList); -extern cstl_error cstl_list_insert (struct cstl_list* pList, size_t pos, void* elem, size_t elem_size); -extern cstl_error cstl_list_push_back(struct cstl_list* pList, void* elem, size_t elem_size); -extern void cstl_list_remove (struct cstl_list* pList, size_t pos); -extern void cstl_list_for_each(struct cstl_list* pList, void(*fn)(const void *elem, void *p), void *p); -extern const void * cstl_list_find(struct cstl_list* pList, void* find_value); -extern const void * cstl_list_element_at(struct cstl_list* pList, size_t pos); -extern size_t cstl_list_size(struct cstl_list* pList); - -extern struct cstl_iterator* cstl_list_new_iterator(struct cstl_list* pSlit); -extern void cstl_list_delete_iterator ( struct cstl_iterator* pItr); - - -// #include "c_algorithms.h" -extern void cstl_for_each(struct cstl_iterator* pIterator, void (*fn)(const void *value, const void *key, void*p), void *p); - - -/* ------------------------------------------------------------------------*/ -/* H E L P E R F U N C T I O N S */ -/* ------------------------------------------------------------------------*/ - -extern void cstl_copy ( void* destination, void* source, size_t size ); -extern void cstl_get ( void* destination, void* source, size_t size); -extern char* cstl_strdup (const char *ptr); - -struct cstl_object; - -extern struct cstl_object* cstl_object_new (const void* inObject, size_t obj_size); -extern const void * cstl_object_get_data(struct cstl_object *inObject); -extern void cstl_object_delete (struct cstl_object* inObject ); -extern void cstl_object_replace_raw(struct cstl_object* current_object,const void* elem, size_t elem_size); - - -#endif // __CSTL_LIB_H__ diff --git a/src/server/server.c b/src/server/server.c index 82eddb24e..e575a2bb3 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -23,7 +23,7 @@ #include "ip_addr_cache.h" #include "s5.h" #include "base64.h" -#include "cstl_lib.h" +#include #ifndef SSR_MAX_CONN #define SSR_MAX_CONN 1024 diff --git a/src/ssr_executive.c b/src/ssr_executive.c index c457c4c28..44e51761c 100644 --- a/src/ssr_executive.c +++ b/src/ssr_executive.c @@ -40,7 +40,7 @@ #include "ssrbuffer.h" #include "obfs.h" #include "crc32.h" -#include "cstl_lib.h" +#include #include "strtrim.h" const char * ssr_strerror(enum ssr_error err) { diff --git a/win32/ssr-client/ssr-client-lib.vcxproj b/win32/ssr-client/ssr-client-lib.vcxproj index e49de97d8..1a352498c 100644 --- a/win32/ssr-client/ssr-client-lib.vcxproj +++ b/win32/ssr-client/ssr-client-lib.vcxproj @@ -43,7 +43,6 @@ - @@ -87,7 +86,6 @@ - @@ -173,14 +171,14 @@ Level3 Disabled _WIN32;WIN32;_DEBUG;_CONSOLE;__MINGW32__;__MINGW64_VERSION_MAJOR;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;USE_CRYPTO_MBEDTLS;_WINSOCK_DEPRECATED_NO_WARNINGS;VERSION="3.0.1";HAVE_PCRE_H;MODULE_LOCAL;UDP_RELAY_ENABLE;__PRINT_INFO__;BUILDING_SSR_NATIVE_SHARED;%(PreprocessorDefinitions) - $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/uri-encode/src;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;%(AdditionalIncludeDirectories) + $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/uri-encode/src;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../../depends/cstl/inc;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;%(AdditionalIncludeDirectories) 4819;4996;%(DisableSpecificWarnings) Console true $(OutDir) - ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;uri-encode.lib;%(AdditionalDependencies) + ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;uri-encode.lib;cstl.lib;%(AdditionalDependencies) ssr-client-lib.def @@ -191,14 +189,14 @@ Level3 Disabled _WIN32;_DEBUG;_CONSOLE;__MINGW32__;__MINGW64_VERSION_MAJOR;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;USE_CRYPTO_MBEDTLS;_WINSOCK_DEPRECATED_NO_WARNINGS;VERSION="3.0.1";HAVE_PCRE_H;MODULE_LOCAL;UDP_RELAY_ENABLE;_CRTDBG_MAP_ALLOC;__MEM_CHECK__=1;__PRINT_INFO__;BUILDING_SSR_NATIVE_SHARED;%(PreprocessorDefinitions) - $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/uri-encode/src;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;%(AdditionalIncludeDirectories) + $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/uri-encode/src;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../../depends/cstl/inc;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;%(AdditionalIncludeDirectories) 4819;4996;%(DisableSpecificWarnings) Console true $(OutDir) - ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;uv-mbed.lib;bloom.lib;uri-encode.lib;%(AdditionalDependencies) + ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;uri-encode.lib;cstl.lib;%(AdditionalDependencies) ssr-client-lib.def @@ -211,7 +209,7 @@ true true _WIN32;WIN32;NDEBUG;_CONSOLE;__MINGW32__;__MINGW64_VERSION_MAJOR;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;USE_CRYPTO_MBEDTLS;_WINSOCK_DEPRECATED_NO_WARNINGS;VERSION="3.0.1";HAVE_PCRE_H;MODULE_LOCAL;UDP_RELAY_ENABLE;__PRINT_INFO__;BUILDING_SSR_NATIVE_SHARED;%(PreprocessorDefinitions) - $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/uri-encode/src;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;%(AdditionalIncludeDirectories) + $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/uri-encode/src;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../../depends/cstl/inc;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;%(AdditionalIncludeDirectories) 4819;4996;%(DisableSpecificWarnings) @@ -220,7 +218,7 @@ true true $(OutDir) - ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;uv-mbed.lib;bloom.lib;uri-encode.lib;%(AdditionalDependencies) + ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;uri-encode.lib;cstl.lib;%(AdditionalDependencies) ssr-client-lib.def @@ -233,7 +231,7 @@ true true _WIN32;NDEBUG;_CONSOLE;__MINGW32__;__MINGW64_VERSION_MAJOR;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;USE_CRYPTO_MBEDTLS;_WINSOCK_DEPRECATED_NO_WARNINGS;VERSION="3.0.1";HAVE_PCRE_H;MODULE_LOCAL;UDP_RELAY_ENABLE;__PRINT_INFO__;BUILDING_SSR_NATIVE_SHARED;%(PreprocessorDefinitions) - $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/uri-encode/src;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;%(AdditionalIncludeDirectories) + $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/uri-encode/src;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../../depends/cstl/inc;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;%(AdditionalIncludeDirectories) 4819;4996;%(DisableSpecificWarnings) @@ -242,7 +240,7 @@ true true $(OutDir) - ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;uv-mbed.lib;bloom.lib;uri-encode.lib;%(AdditionalDependencies) + ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;uri-encode.lib;cstl.lib;%(AdditionalDependencies) ssr-client-lib.def diff --git a/win32/ssr-client/ssr-client-lib.vcxproj.filters b/win32/ssr-client/ssr-client-lib.vcxproj.filters index 25e8e5fef..531fbc983 100644 --- a/win32/ssr-client/ssr-client-lib.vcxproj.filters +++ b/win32/ssr-client/ssr-client-lib.vcxproj.filters @@ -84,9 +84,6 @@ Source Files - - obfs - Source Files @@ -203,9 +200,6 @@ Header Files - - obfs - Source Files diff --git a/win32/ssr-client/ssr-client.vcxproj b/win32/ssr-client/ssr-client.vcxproj index 6b04051a3..92c447687 100644 --- a/win32/ssr-client/ssr-client.vcxproj +++ b/win32/ssr-client/ssr-client.vcxproj @@ -44,7 +44,6 @@ - @@ -86,7 +85,6 @@ - @@ -169,14 +167,14 @@ Level3 Disabled _WIN32;WIN32;_DEBUG;_CONSOLE;__MINGW32__;__MINGW64_VERSION_MAJOR;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;USE_CRYPTO_MBEDTLS;_WINSOCK_DEPRECATED_NO_WARNINGS;VERSION="3.0.1";HAVE_PCRE_H;MODULE_LOCAL;UDP_RELAY_ENABLE;__PRINT_INFO__;%(PreprocessorDefinitions) - $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../libcork/include;$(ProjectDir)../../libipset/include;$(ProjectDir)../../libudns;$(ProjectDir)../../depends/pcre4w/pcre;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;%(AdditionalIncludeDirectories) + $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/cstl/inc;%(AdditionalIncludeDirectories) 4819;4996;4068;%(DisableSpecificWarnings) Console true $(OutDir) - ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;%(AdditionalDependencies) + ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;cstl.lib;%(AdditionalDependencies) @@ -186,14 +184,14 @@ Level3 Disabled _WIN32;_DEBUG;_CONSOLE;__MINGW32__;__MINGW64_VERSION_MAJOR;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;USE_CRYPTO_MBEDTLS;_WINSOCK_DEPRECATED_NO_WARNINGS;VERSION="3.0.1";HAVE_PCRE_H;MODULE_LOCAL;UDP_RELAY_ENABLE;_CRTDBG_MAP_ALLOC;__MEM_CHECK__=1;__PRINT_INFO__;%(PreprocessorDefinitions) - $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;%(AdditionalIncludeDirectories) + $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/cstl/inc;%(AdditionalIncludeDirectories) 4819;4996;4068;%(DisableSpecificWarnings) Console true $(OutDir) - ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;%(AdditionalDependencies) + ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;cstl.lib;%(AdditionalDependencies) @@ -205,7 +203,7 @@ true true _WIN32;WIN32;NDEBUG;_CONSOLE;__MINGW32__;__MINGW64_VERSION_MAJOR;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;USE_CRYPTO_MBEDTLS;_WINSOCK_DEPRECATED_NO_WARNINGS;VERSION="3.0.1";HAVE_PCRE_H;MODULE_LOCAL;UDP_RELAY_ENABLE;__PRINT_INFO__;%(PreprocessorDefinitions) - $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;%(AdditionalIncludeDirectories) + $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/cstl/inc;%(AdditionalIncludeDirectories) 4819;4996;4068;%(DisableSpecificWarnings) @@ -214,7 +212,7 @@ true true $(OutDir) - ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;%(AdditionalDependencies) + ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;cstl.lib;%(AdditionalDependencies) @@ -226,7 +224,7 @@ true true _WIN32;NDEBUG;_CONSOLE;__MINGW32__;__MINGW64_VERSION_MAJOR;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;USE_CRYPTO_MBEDTLS;_WINSOCK_DEPRECATED_NO_WARNINGS;VERSION="3.0.1";HAVE_PCRE_H;MODULE_LOCAL;UDP_RELAY_ENABLE;__PRINT_INFO__;%(PreprocessorDefinitions) - $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;%(AdditionalIncludeDirectories) + $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/uv-mbed/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/cstl/inc;%(AdditionalIncludeDirectories) 4819;4996;4068;%(DisableSpecificWarnings) @@ -235,7 +233,7 @@ true true $(OutDir) - ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;%(AdditionalDependencies) + ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;uv-mbed.lib;bloom.lib;cstl.lib;%(AdditionalDependencies) diff --git a/win32/ssr-client/ssr-client.vcxproj.filters b/win32/ssr-client/ssr-client.vcxproj.filters index b35427e80..b90fcf40b 100644 --- a/win32/ssr-client/ssr-client.vcxproj.filters +++ b/win32/ssr-client/ssr-client.vcxproj.filters @@ -87,9 +87,6 @@ Source Files - - obfs - Source Files @@ -206,9 +203,6 @@ Header Files - - obfs - Source Files diff --git a/win32/ssr-native-lib.sln b/win32/ssr-native-lib.sln index 12715eb67..5061647d7 100644 --- a/win32/ssr-native-lib.sln +++ b/win32/ssr-native-lib.sln @@ -27,6 +27,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bloom", "..\depends\libbloo EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uri-encode", "..\depends\uri-encode\msvc\uri-encode.vcxproj", "{14BB53E2-B04A-AA3D-6191-62DA3932F09E}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cstl", "..\depends\cstl\msvc\cstl.vcxproj", "{475DE074-DA8E-3E95-929A-5D73E659170A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -91,6 +93,14 @@ Global {14BB53E2-B04A-AA3D-6191-62DA3932F09E}.Release|Win32.Build.0 = Release|Win32 {14BB53E2-B04A-AA3D-6191-62DA3932F09E}.Release|x64.ActiveCfg = Release|x64 {14BB53E2-B04A-AA3D-6191-62DA3932F09E}.Release|x64.Build.0 = Release|x64 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Debug|Win32.ActiveCfg = Debug|Win32 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Debug|Win32.Build.0 = Debug|Win32 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Debug|x64.ActiveCfg = Debug|x64 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Debug|x64.Build.0 = Debug|x64 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Release|Win32.ActiveCfg = Release|Win32 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Release|Win32.Build.0 = Release|Win32 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Release|x64.ActiveCfg = Release|x64 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/win32/ssr-native.sln b/win32/ssr-native.sln index 9be58cd9b..3da5103da 100644 --- a/win32/ssr-native.sln +++ b/win32/ssr-native.sln @@ -7,6 +7,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssr-client", "ssr-client\ss {44EA013F-AD0F-4D53-8E06-0B4EF26F4B65} = {44EA013F-AD0F-4D53-8E06-0B4EF26F4B65} {A185B162-6CB6-4502-B03F-B56F7699A8D9} = {A185B162-6CB6-4502-B03F-B56F7699A8D9} {F1F4BA6A-0368-4F34-95BB-C29A2244A772} = {F1F4BA6A-0368-4F34-95BB-C29A2244A772} + {475DE074-DA8E-3E95-929A-5D73E659170A} = {475DE074-DA8E-3E95-929A-5D73E659170A} {FCBB48D0-3186-4EC7-A2D9-C54A2BCF0B85} = {FCBB48D0-3186-4EC7-A2D9-C54A2BCF0B85} {E683C8F1-3C3F-4B5D-B60E-87D792D21002} = {E683C8F1-3C3F-4B5D-B60E-87D792D21002} EndProjectSection @@ -25,6 +26,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssr-server", "ssr-server\ss {44EA013F-AD0F-4D53-8E06-0B4EF26F4B65} = {44EA013F-AD0F-4D53-8E06-0B4EF26F4B65} {A185B162-6CB6-4502-B03F-B56F7699A8D9} = {A185B162-6CB6-4502-B03F-B56F7699A8D9} {F1F4BA6A-0368-4F34-95BB-C29A2244A772} = {F1F4BA6A-0368-4F34-95BB-C29A2244A772} + {475DE074-DA8E-3E95-929A-5D73E659170A} = {475DE074-DA8E-3E95-929A-5D73E659170A} {FCBB48D0-3186-4EC7-A2D9-C54A2BCF0B85} = {FCBB48D0-3186-4EC7-A2D9-C54A2BCF0B85} EndProjectSection EndProject @@ -36,6 +38,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uv-mbed", "..\depends\uv-mb EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bloom", "..\depends\libbloom\win32\bloom.vcxproj", "{FCBB48D0-3186-4EC7-A2D9-C54A2BCF0B85}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cstl", "..\depends\cstl\msvc\cstl.vcxproj", "{475DE074-DA8E-3E95-929A-5D73E659170A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -108,6 +112,14 @@ Global {FCBB48D0-3186-4EC7-A2D9-C54A2BCF0B85}.Release|Win32.Build.0 = Release|Win32 {FCBB48D0-3186-4EC7-A2D9-C54A2BCF0B85}.Release|x64.ActiveCfg = Release|x64 {FCBB48D0-3186-4EC7-A2D9-C54A2BCF0B85}.Release|x64.Build.0 = Release|x64 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Debug|Win32.ActiveCfg = Debug|Win32 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Debug|Win32.Build.0 = Debug|Win32 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Debug|x64.ActiveCfg = Debug|x64 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Debug|x64.Build.0 = Debug|x64 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Release|Win32.ActiveCfg = Release|Win32 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Release|Win32.Build.0 = Release|Win32 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Release|x64.ActiveCfg = Release|x64 + {475DE074-DA8E-3E95-929A-5D73E659170A}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/win32/ssr-server/ssr-server.vcxproj b/win32/ssr-server/ssr-server.vcxproj index 3e51f15bd..cdb33fcb8 100644 --- a/win32/ssr-server/ssr-server.vcxproj +++ b/win32/ssr-server/ssr-server.vcxproj @@ -41,7 +41,6 @@ - @@ -82,7 +81,6 @@ - @@ -165,14 +163,14 @@ Level3 Disabled _WIN32;WIN32;_DEBUG;__MEM_CHECK__;_CONSOLE;__MINGW32__;__MINGW64_VERSION_MAJOR;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;USE_CRYPTO_MBEDTLS;_WINSOCK_DEPRECATED_NO_WARNINGS;VERSION="3.0.1";HAVE_PCRE_H;MODULE_REMOTE;UDP_RELAY_ENABLE;__PRINT_INFO__;%(PreprocessorDefinitions) - $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../libcork/include;$(ProjectDir)../../libipset/include;$(ProjectDir)../../libudns;$(ProjectDir)../../depends/pcre4w/pcre;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;%(AdditionalIncludeDirectories) + $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/cstl/inc;%(AdditionalIncludeDirectories) 4819;4996;4068;%(DisableSpecificWarnings) Console true $(OutDir) - ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;bloom.lib;%(AdditionalDependencies) + ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;bloom.lib;cstl.lib;%(AdditionalDependencies) @@ -182,14 +180,14 @@ Level3 Disabled _WIN32;WIN32;_DEBUG;__MEM_CHECK__;_CONSOLE;__MINGW32__;__MINGW64_VERSION_MAJOR;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;USE_CRYPTO_MBEDTLS;_WINSOCK_DEPRECATED_NO_WARNINGS;VERSION="3.0.1";HAVE_PCRE_H;MODULE_REMOTE;UDP_RELAY_ENABLE;__PRINT_INFO__;%(PreprocessorDefinitions) - $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;%(AdditionalIncludeDirectories) + $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/cstl/inc;%(AdditionalIncludeDirectories) 4819;4996;4068;%(DisableSpecificWarnings) Console true $(OutDir) - ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;bloom.lib;%(AdditionalDependencies) + ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;bloom.lib;cstl.lib;%(AdditionalDependencies) @@ -201,7 +199,7 @@ true true _WIN32;WIN32;NDEBUG;_CONSOLE;__MINGW32__;__MINGW64_VERSION_MAJOR;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;USE_CRYPTO_MBEDTLS;_WINSOCK_DEPRECATED_NO_WARNINGS;VERSION="3.0.1";HAVE_PCRE_H;MODULE_REMOTE;UDP_RELAY_ENABLE;__PRINT_INFO__;%(PreprocessorDefinitions) - $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;%(AdditionalIncludeDirectories) + $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/cstl/inc;%(AdditionalIncludeDirectories) 4819;4996;4068;%(DisableSpecificWarnings) @@ -210,7 +208,7 @@ true true $(OutDir) - ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;bloom.lib;%(AdditionalDependencies) + ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;bloom.lib;cstl.lib;%(AdditionalDependencies) @@ -222,7 +220,7 @@ true true _WIN32;NDEBUG;_CONSOLE;__MINGW32__;__MINGW64_VERSION_MAJOR;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;USE_CRYPTO_MBEDTLS;_WINSOCK_DEPRECATED_NO_WARNINGS;VERSION="3.0.1";HAVE_PCRE_H;MODULE_REMOTE;UDP_RELAY_ENABLE;__PRINT_INFO__;%(PreprocessorDefinitions) - $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;%(AdditionalIncludeDirectories) + $(ProjectDir)../../depends;$(ProjectDir)../../depends/json-c/win32;$(ProjectDir)../../depends/json-c;$(ProjectDir)../../depends/mbedtls/include;$(ProjectDir)../../depends/libsodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include/sodium;$(ProjectDir)../../depends/libsodium/src/libsodium/include;$(ProjectDir)../../depends/libsodium/ssrbuild/include;$(ProjectDir)../../depends/libuv/include;$(ProjectDir)../../depends/http-parser;$(ProjectDir)../include;$(ProjectDir)../../src;$(ProjectDir)../../src/obfs;$(ProjectDir)../../src/client;$(ProjectDir)../../depends/libbloom;$(ProjectDir)../../depends/cstl/inc;%(AdditionalIncludeDirectories) 4819;4996;4068;%(DisableSpecificWarnings) @@ -231,7 +229,7 @@ true true $(OutDir) - ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;bloom.lib;%(AdditionalDependencies) + ws2_32.lib;mbedTLS.lib;libuv.lib;libsodium.lib;json-c.lib;bloom.lib;cstl.lib;%(AdditionalDependencies) diff --git a/win32/ssr-server/ssr-server.vcxproj.filters b/win32/ssr-server/ssr-server.vcxproj.filters index a3baf26ff..b53954542 100644 --- a/win32/ssr-server/ssr-server.vcxproj.filters +++ b/win32/ssr-server/ssr-server.vcxproj.filters @@ -81,9 +81,6 @@ Source Files - - obfs - server @@ -197,9 +194,6 @@ Header Files - - obfs - server