aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita <nikita.hldm@gmail.com>2019-04-12 18:58:29 +0300
committerGriffin Downs <35574547+grdowns@users.noreply.github.com>2019-04-12 08:58:29 -0700
commitb41ddf807200ab7ef10000f605e29d254f6955ed (patch)
tree7202a4f24fedcc6e99e989fe553005231cf732cf
parente1ae8f62b9ee5de63ae148e08df85fb90965af1d (diff)
downloadvcpkg-b41ddf807200ab7ef10000f605e29d254f6955ed.tar.gz
vcpkg-b41ddf807200ab7ef10000f605e29d254f6955ed.zip
[binn] new port (#5637)
* Add binn library * Fix binn.h include * Fix UWP. Replace to safe functions * Fix uwp patch * [binn] update uwp patch
-rw-r--r--ports/binn/0001_fix_uwp.patch93
-rw-r--r--ports/binn/CMakeLists.txt23
-rw-r--r--ports/binn/CONTROL3
-rw-r--r--ports/binn/portfile.cmake26
4 files changed, 145 insertions, 0 deletions
diff --git a/ports/binn/0001_fix_uwp.patch b/ports/binn/0001_fix_uwp.patch
new file mode 100644
index 000000000..c4f0b6658
--- /dev/null
+++ b/ports/binn/0001_fix_uwp.patch
@@ -0,0 +1,93 @@
+diff --git a/src/binn.c b/src/binn.c
+index ef32f35..d12d473 100644
+--- a/src/binn.c
++++ b/src/binn.c
+@@ -142,8 +142,8 @@ BINN_PRIVATE void copy_be64(u64 *pdest, u64 *psource) {
+ /***************************************************************************/
+
+ #ifndef WIN32
+-#define stricmp strcasecmp
+-#define strnicmp strncasecmp
++#define _stricmp strcasecmp
++#define _strnicmp strncasecmp
+ #endif
+
+ BINN_PRIVATE BOOL IsValidBinnHeader(void *pbuf, int *ptype, int *pcount, int *psize, int *pheadersize);
+@@ -614,7 +614,7 @@ BINN_PRIVATE unsigned char * SearchForKey(unsigned char *p, int header_size, int
+ if (p > plimit) break;
+ // Compare if the strings are equal.
+ if (len > 0) {
+- if (strnicmp((char*)p, key, len) == 0) { // note that there is no null terminator here
++ if (_strnicmp((char*)p, key, len) == 0) { // note that there is no null terminator here
+ if (keylen == len) {
+ p += len;
+ return p;
+@@ -1582,6 +1582,7 @@ BINN_PRIVATE BOOL binn_read_pair(int expected_type, void *ptr, int pos, int *pid
+ base = p;
+ plimit = p + size - 1;
+ p += header_size;
++ key = 0;
+
+ for (i = 0; i < count; i++) {
+ switch (type) {
+@@ -3147,15 +3148,15 @@ BINN_PRIVATE BOOL is_bool_str(char *str, BOOL *pbool) {
+
+ if (str == NULL || pbool == NULL) return FALSE;
+
+- if (stricmp(str, "true") == 0) goto loc_true;
+- if (stricmp(str, "yes") == 0) goto loc_true;
+- if (stricmp(str, "on") == 0) goto loc_true;
+- //if (stricmp(str, "1") == 0) goto loc_true;
++ if (_stricmp(str, "true") == 0) goto loc_true;
++ if (_stricmp(str, "yes") == 0) goto loc_true;
++ if (_stricmp(str, "on") == 0) goto loc_true;
++ //if (_stricmp(str, "1") == 0) goto loc_true;
+
+- if (stricmp(str, "false") == 0) goto loc_false;
+- if (stricmp(str, "no") == 0) goto loc_false;
+- if (stricmp(str, "off") == 0) goto loc_false;
+- //if (stricmp(str, "0") == 0) goto loc_false;
++ if (_stricmp(str, "false") == 0) goto loc_false;
++ if (_stricmp(str, "no") == 0) goto loc_false;
++ if (_stricmp(str, "off") == 0) goto loc_false;
++ //if (_stricmp(str, "0") == 0) goto loc_false;
+
+ if (is_integer(str)) {
+ vint = atoi64(str);
+@@ -3333,7 +3334,7 @@ char * APIENTRY binn_get_str(binn *value) {
+
+ if (type_family(value->type) == BINN_FAMILY_INT) {
+ if (copy_int_value(value->ptr, &vint, value->type, BINN_INT64) == FALSE) return NULL;
+- sprintf(buf, "%" INT64_FORMAT, vint);
++ sprintf_s(buf, "%" INT64_FORMAT, vint);
+ goto loc_convert_value;
+ }
+
+@@ -3341,15 +3342,15 @@ char * APIENTRY binn_get_str(binn *value) {
+ case BINN_FLOAT:
+ value->vdouble = value->vfloat;
+ case BINN_DOUBLE:
+- sprintf(buf, "%g", value->vdouble);
++ sprintf_s(buf, sizeof buf, "%g", value->vdouble);
+ goto loc_convert_value;
+ case BINN_STRING:
+ return (char*) value->ptr;
+ case BINN_BOOL:
+ if (value->vbool)
+- strcpy(buf, "true");
++ strcpy_s(buf, sizeof buf, "true");
+ else
+- strcpy(buf, "false");
++ strcpy_s(buf, sizeof buf, "false");
+ goto loc_convert_value;
+ }
+
+@@ -3358,7 +3359,7 @@ char * APIENTRY binn_get_str(binn *value) {
+ loc_convert_value:
+
+ //value->vint64 = 0;
+- value->ptr = strdup(buf);
++ value->ptr = _strdup(buf);
+ if (value->ptr == NULL) return NULL;
+ value->freefn = free;
+ value->type = BINN_STRING;
diff --git a/ports/binn/CMakeLists.txt b/ports/binn/CMakeLists.txt
new file mode 100644
index 000000000..0c3995685
--- /dev/null
+++ b/ports/binn/CMakeLists.txt
@@ -0,0 +1,23 @@
+cmake_minimum_required(VERSION 3.8)
+
+project(binn
+ VERSION 1.0
+ DESCRIPTION "Binn is a binary data serialization format designed to be compact, fast and easy to use."
+ HOMEPAGE_URL "https://github.com/liteserver/binn"
+)
+
+set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
+
+add_library (binn src/binn.h src/binn.c)
+
+target_include_directories(binn
+ PUBLIC
+ ${PROJECT_SOURCE_DIR}/src
+)
+
+install(
+ TARGETS binn
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
diff --git a/ports/binn/CONTROL b/ports/binn/CONTROL
new file mode 100644
index 000000000..f98abe1ec
--- /dev/null
+++ b/ports/binn/CONTROL
@@ -0,0 +1,3 @@
+Source: binn
+Version: 1.0
+Description: Binn is a binary data serialization format designed to be compact, fast and easy to use. \ No newline at end of file
diff --git a/ports/binn/portfile.cmake b/ports/binn/portfile.cmake
new file mode 100644
index 000000000..5115aacda
--- /dev/null
+++ b/ports/binn/portfile.cmake
@@ -0,0 +1,26 @@
+include(vcpkg_common_functions)
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO liteserver/binn
+ REF 38019c11e582e5078436b8257887e79a33db8b28
+ SHA512 82c7ef211154303ebb4cb991e620da520231edd224de674d4dabc42760fd7b8b6dd7be167d6c0b6c04146ea7e077b0bcff14312be909cb4ebb1ec786863d3fb4
+ HEAD_REF master
+ PATCHES
+ 0001_fix_uwp.patch
+)
+
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
+
+file(INSTALL ${SOURCE_PATH}/src/binn.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/binn)
+
+vcpkg_configure_cmake(
+ SOURCE_PATH ${SOURCE_PATH}
+ PREFER_NINJA
+)
+
+vcpkg_install_cmake()
+
+# Handle copyright
+file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/binn)
+file(RENAME ${CURRENT_PACKAGES_DIR}/share/binn/LICENSE ${CURRENT_PACKAGES_DIR}/share/binn/copyright) \ No newline at end of file