summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-06-28 15:42:54 -0400
committermidipix <writeonce@midipix.org>2016-06-28 19:46:41 -0400
commita2ea1bdf70166f887457b5462332d2df4f6f54c5 (patch)
tree4ab3559d0e526fc7df2d59edcaec53ccf277430c
parent964eed7331c807e553ec42637151fda21b5495d9 (diff)
downloadntapi-a2ea1bdf70166f887457b5462332d2df4f6f54c5.tar.bz2
ntapi-a2ea1bdf70166f887457b5462332d2df4f6f54c5.tar.xz
string functions: added __ntapi_tt_strncmp_utf16().
-rw-r--r--include/ntapi/nt_string.h5
-rw-r--r--include/ntapi/ntapi.h1
-rw-r--r--project/common.mk1
-rw-r--r--src/internal/ntapi.c1
-rw-r--r--src/internal/ntapi_fnapi.h1
-rw-r--r--src/string/ntapi_tt_strncmp_utf16.c22
6 files changed, 31 insertions, 0 deletions
diff --git a/include/ntapi/nt_string.h b/include/ntapi/nt_string.h
index d5ad05d..fd9b312 100644
--- a/include/ntapi/nt_string.h
+++ b/include/ntapi/nt_string.h
@@ -56,6 +56,11 @@ typedef int __cdecl ntapi_tt_strncmp_multibyte(
__in const char * b,
__in size_t n);
+typedef int __cdecl ntapi_tt_strncmp_utf16(
+ __in const wchar16_t * a,
+ __in const wchar16_t * b,
+ __in size_t n);
+
typedef void __cdecl ntapi_tt_init_unicode_string_from_utf16(
__out nt_unicode_string * str_dest,
__in wchar16_t * str_src);
diff --git a/include/ntapi/ntapi.h b/include/ntapi/ntapi.h
index 770b9d6..a413e4e 100644
--- a/include/ntapi/ntapi.h
+++ b/include/ntapi/ntapi.h
@@ -403,6 +403,7 @@ typedef struct _ntapi_vtbl {
ntapi_tt_strcmp_multibyte * tt_strcmp_multibyte;
ntapi_tt_strcmp_utf16 * tt_strcmp_utf16;
ntapi_tt_strncmp_multibyte * tt_strncmp_multibyte;
+ ntapi_tt_strncmp_utf16 * tt_strncmp_utf16;
ntapi_tt_aligned_block_memset * tt_aligned_block_memset;
ntapi_tt_aligned_block_memcpy * tt_aligned_block_memcpy;
ntapi_tt_aligned_memcpy_utf16 * tt_aligned_memcpy_utf16;
diff --git a/project/common.mk b/project/common.mk
index bbeb2fc..8dd2dfc 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -77,6 +77,7 @@ COMMON_SRCS = \
src/string/ntapi_tt_strcmp_utf16.c \
src/string/ntapi_tt_string_null_offset.c \
src/string/ntapi_tt_strncmp_multibyte.c \
+ src/string/ntapi_tt_strncmp_utf16.c \
src/string/ntapi_tt_uintptr_to_hex_utf16.c \
src/string/ntapi_tt_uintptr_to_hex_utf8.c \
src/sync/ntapi_tt_create_event.c \
diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c
index c71aeb5..b77cdd5 100644
--- a/src/internal/ntapi.c
+++ b/src/internal/ntapi.c
@@ -170,6 +170,7 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
__ntapi->tt_strcmp_multibyte = __ntapi_tt_strcmp_multibyte;
__ntapi->tt_strcmp_utf16 = __ntapi_tt_strcmp_utf16;
__ntapi->tt_strncmp_multibyte = __ntapi_tt_strncmp_multibyte;
+ __ntapi->tt_strncmp_utf16 = __ntapi_tt_strncmp_utf16;
__ntapi->strlen = __ntapi_tt_string_null_offset_multibyte;
__ntapi->wcslen = __ntapi_wcslen;
__ntapi->tt_aligned_block_memset = __ntapi_tt_aligned_block_memset;
diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h
index 684f12a..9ded75a 100644
--- a/src/internal/ntapi_fnapi.h
+++ b/src/internal/ntapi_fnapi.h
@@ -56,6 +56,7 @@ ntapi_tt_string_null_offset_ptrsize __ntapi_tt_string_null_offset_ptrsize;
ntapi_tt_strcmp_multibyte __ntapi_tt_strcmp_multibyte;
ntapi_tt_strcmp_utf16 __ntapi_tt_strcmp_utf16;
ntapi_tt_strncmp_multibyte __ntapi_tt_strncmp_multibyte;
+ntapi_tt_strncmp_utf16 __ntapi_tt_strncmp_utf16;
ntapi_wcslen __ntapi_wcslen;
ntapi_tt_aligned_block_memset __ntapi_tt_aligned_block_memset;
ntapi_tt_aligned_block_memcpy __ntapi_tt_aligned_block_memcpy;
diff --git a/src/string/ntapi_tt_strncmp_utf16.c b/src/string/ntapi_tt_strncmp_utf16.c
new file mode 100644
index 0000000..ddac803
--- /dev/null
+++ b/src/string/ntapi_tt_strncmp_utf16.c
@@ -0,0 +1,22 @@
+/********************************************************/
+/* ntapi: Native API core library */
+/* Copyright (C) 2013--2016 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
+/********************************************************/
+
+#include <psxtypes/psxtypes.h>
+#include <ntapi/nt_string.h>
+
+int __cdecl __ntapi_tt_strncmp_utf16(
+ __in const wchar16_t * a,
+ __in const wchar16_t * b,
+ __in size_t n)
+{
+ if ((n /= sizeof(wchar16_t)) == 0)
+ return 0;
+
+ for (--n; n && (*a == *b) && *a; a++, b++)
+ n--;
+
+ return (int)*a - (int)*b;
+}