@ohos-ports/bare-buffer 3.7.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +26 -0
  3. package/binding.c +1077 -0
  4. package/binding.gyp +32 -0
  5. package/binding.js +1 -0
  6. package/build/Release/bare_buffer.node +0 -0
  7. package/deps/libbase64/.clang-format +10 -0
  8. package/deps/libbase64/.gitattributes +1 -0
  9. package/deps/libbase64/.github/workflows/integrate.yml +45 -0
  10. package/deps/libbase64/.github/workflows/nightly.yml +28 -0
  11. package/deps/libbase64/.prettierrc +1 -0
  12. package/deps/libbase64/CMakeLists.txt +71 -0
  13. package/deps/libbase64/LICENSE +201 -0
  14. package/deps/libbase64/NOTICE +13 -0
  15. package/deps/libbase64/README.md +11 -0
  16. package/deps/libbase64/include/base64.h +323 -0
  17. package/deps/libbase64/package.json +25 -0
  18. package/deps/libbase64/src/base64.c +22 -0
  19. package/deps/libbase64/test/CMakeLists.txt +31 -0
  20. package/deps/libbase64/test/decode-invalid.c +35 -0
  21. package/deps/libbase64/test/decode-length.c +23 -0
  22. package/deps/libbase64/test/decode.c +36 -0
  23. package/deps/libbase64/test/encode-length.c +22 -0
  24. package/deps/libbase64/test/encode.c +42 -0
  25. package/deps/libbase64/test/fuzz/CMakeLists.txt +18 -0
  26. package/deps/libbase64/test/fuzz/decode/utf16le.c +53 -0
  27. package/deps/libbase64/test/fuzz/decode/utf8.c +47 -0
  28. package/deps/libbase64/test/fuzz/encode/utf16le.c +56 -0
  29. package/deps/libbase64/test/fuzz/encode/utf8.c +56 -0
  30. package/deps/libhex/.clang-format +10 -0
  31. package/deps/libhex/.gitattributes +1 -0
  32. package/deps/libhex/.github/workflows/integrate.yml +45 -0
  33. package/deps/libhex/.github/workflows/nightly.yml +28 -0
  34. package/deps/libhex/.prettierrc +1 -0
  35. package/deps/libhex/CMakeLists.txt +72 -0
  36. package/deps/libhex/LICENSE +201 -0
  37. package/deps/libhex/NOTICE +13 -0
  38. package/deps/libhex/README.md +11 -0
  39. package/deps/libhex/include/hex.h +163 -0
  40. package/deps/libhex/package.json +25 -0
  41. package/deps/libhex/src/hex.c +16 -0
  42. package/deps/libhex/test/CMakeLists.txt +31 -0
  43. package/deps/libhex/test/decode-invalid.c +37 -0
  44. package/deps/libhex/test/decode-length.c +23 -0
  45. package/deps/libhex/test/decode.c +25 -0
  46. package/deps/libhex/test/encode-length.c +22 -0
  47. package/deps/libhex/test/encode.c +25 -0
  48. package/deps/libhex/test/fuzz/CMakeLists.txt +18 -0
  49. package/deps/libhex/test/fuzz/decode/utf16le.c +53 -0
  50. package/deps/libhex/test/fuzz/decode/utf8.c +47 -0
  51. package/deps/libhex/test/fuzz/encode/utf16le.c +36 -0
  52. package/deps/libhex/test/fuzz/encode/utf8.c +36 -0
  53. package/deps/libutf/.clang-format +10 -0
  54. package/deps/libutf/.gitattributes +1 -0
  55. package/deps/libutf/.github/workflows/integrate.yml +45 -0
  56. package/deps/libutf/.github/workflows/nightly.yml +28 -0
  57. package/deps/libutf/.prettierrc +1 -0
  58. package/deps/libutf/CMakeLists.txt +105 -0
  59. package/deps/libutf/LICENSE +201 -0
  60. package/deps/libutf/NOTICE +13 -0
  61. package/deps/libutf/README.md +11 -0
  62. package/deps/libutf/include/utf/string.h +1655 -0
  63. package/deps/libutf/include/utf.h +132 -0
  64. package/deps/libutf/package.json +24 -0
  65. package/deps/libutf/src/ascii/validate.c +47 -0
  66. package/deps/libutf/src/endianness.c +19 -0
  67. package/deps/libutf/src/endianness.h +54 -0
  68. package/deps/libutf/src/latin1/convert-to-utf16.c +37 -0
  69. package/deps/libutf/src/latin1/convert-to-utf32.c +34 -0
  70. package/deps/libutf/src/latin1/convert-to-utf8.c +58 -0
  71. package/deps/libutf/src/latin1/length-from-utf16.c +26 -0
  72. package/deps/libutf/src/latin1/length-from-utf32.c +26 -0
  73. package/deps/libutf/src/latin1/length-from-utf8.c +34 -0
  74. package/deps/libutf/src/utf16/convert-to-latin1.c +41 -0
  75. package/deps/libutf/src/utf16/convert-to-utf32.c +56 -0
  76. package/deps/libutf/src/utf16/convert-to-utf8.c +80 -0
  77. package/deps/libutf/src/utf16/length-from-latin1.c +26 -0
  78. package/deps/libutf/src/utf16/length-from-utf32.c +33 -0
  79. package/deps/libutf/src/utf16/length-from-utf8.c +38 -0
  80. package/deps/libutf/src/utf16/validate.c +53 -0
  81. package/deps/libutf/src/utf32/convert-to-latin1.c +40 -0
  82. package/deps/libutf/src/utf32/convert-to-utf16.c +56 -0
  83. package/deps/libutf/src/utf32/convert-to-utf8.c +71 -0
  84. package/deps/libutf/src/utf32/length-from-latin1.c +26 -0
  85. package/deps/libutf/src/utf32/length-from-utf16.c +35 -0
  86. package/deps/libutf/src/utf32/length-from-utf8.c +35 -0
  87. package/deps/libutf/src/utf32/string.c +149 -0
  88. package/deps/libutf/src/utf32/validate.c +39 -0
  89. package/deps/libutf/src/utf8/convert-to-latin1.c +70 -0
  90. package/deps/libutf/src/utf8/convert-to-utf16.c +95 -0
  91. package/deps/libutf/src/utf8/convert-to-utf32.c +110 -0
  92. package/deps/libutf/src/utf8/length-from-latin1.c +32 -0
  93. package/deps/libutf/src/utf8/length-from-utf16.c +48 -0
  94. package/deps/libutf/src/utf8/length-from-utf32.c +35 -0
  95. package/deps/libutf/src/utf8/string.c +149 -0
  96. package/deps/libutf/src/utf8/validate.c +107 -0
  97. package/deps/libutf/test/CMakeLists.txt +56 -0
  98. package/deps/libutf/test/fuzz/CMakeLists.txt +26 -0
  99. package/deps/libutf/test/fuzz/corpus/.gitignore +2 -0
  100. package/deps/libutf/test/fuzz/crashes/.gitignore +2 -0
  101. package/deps/libutf/test/fuzz/latin1/convert-to-utf16.c +32 -0
  102. package/deps/libutf/test/fuzz/latin1/convert-to-utf32.c +32 -0
  103. package/deps/libutf/test/fuzz/latin1/convert-to-utf8.c +33 -0
  104. package/deps/libutf/test/fuzz/utf16/convert-to-latin1.c +36 -0
  105. package/deps/libutf/test/fuzz/utf16/convert-to-utf32.c +38 -0
  106. package/deps/libutf/test/fuzz/utf16/convert-to-utf8.c +38 -0
  107. package/deps/libutf/test/fuzz/utf32/convert-to-latin1.c +36 -0
  108. package/deps/libutf/test/fuzz/utf32/convert-to-utf16.c +38 -0
  109. package/deps/libutf/test/fuzz/utf32/convert-to-utf8.c +38 -0
  110. package/deps/libutf/test/fuzz/utf8/convert-to-latin1.c +33 -0
  111. package/deps/libutf/test/fuzz/utf8/convert-to-utf16.c +35 -0
  112. package/deps/libutf/test/fuzz/utf8/convert-to-utf32.c +35 -0
  113. package/deps/libutf/test/utf16/utf8-convert.c +45 -0
  114. package/deps/libutf/test/utf16/utf8-length.c +41 -0
  115. package/deps/libutf/test/utf16/validate-invalid.c +50 -0
  116. package/deps/libutf/test/utf16/validate.c +32 -0
  117. package/deps/libutf/test/utf32/string-append.c +74 -0
  118. package/deps/libutf/test/utf32/string-compare.c +108 -0
  119. package/deps/libutf/test/utf32/string-erase.c +79 -0
  120. package/deps/libutf/test/utf32/string-index.c +102 -0
  121. package/deps/libutf/test/utf32/string-insert.c +92 -0
  122. package/deps/libutf/test/utf32/string-last-index.c +71 -0
  123. package/deps/libutf/test/utf32/string-prepend.c +51 -0
  124. package/deps/libutf/test/utf32/string-replace.c +88 -0
  125. package/deps/libutf/test/utf32/string-reserve.c +99 -0
  126. package/deps/libutf/test/utf32/string-substring.c +93 -0
  127. package/deps/libutf/test/utf8/latin1-convert.c +23 -0
  128. package/deps/libutf/test/utf8/string-append.c +23 -0
  129. package/deps/libutf/test/utf8/string-compare.c +67 -0
  130. package/deps/libutf/test/utf8/string-erase.c +75 -0
  131. package/deps/libutf/test/utf8/string-index.c +99 -0
  132. package/deps/libutf/test/utf8/string-last-index.c +68 -0
  133. package/deps/libutf/test/utf8/string-prepend.c +23 -0
  134. package/deps/libutf/test/utf8/string-replace.c +74 -0
  135. package/deps/libutf/test/utf8/string-reserve.c +51 -0
  136. package/deps/libutf/test/utf8/string-substring.c +68 -0
  137. package/deps/libutf/test/utf8/utf16-convert.c +32 -0
  138. package/deps/libutf/test/utf8/utf16-length.c +29 -0
  139. package/deps/libutf/test/utf8/validate-invalid.c +26 -0
  140. package/deps/libutf/test/utf8/validate.c +21 -0
  141. package/global.d.ts +21 -0
  142. package/global.js +6 -0
  143. package/index.d.ts +769 -0
  144. package/index.js +1339 -0
  145. package/lib/ascii.js +36 -0
  146. package/lib/base64.js +25 -0
  147. package/lib/base64url.js +25 -0
  148. package/lib/checked.js +23 -0
  149. package/lib/constants.d.ts +7 -0
  150. package/lib/constants.js +3 -0
  151. package/lib/hex.js +20 -0
  152. package/lib/latin1.js +14 -0
  153. package/lib/utf16le.js +20 -0
  154. package/lib/utf8.js +18 -0
  155. package/package.json +64 -0
@@ -0,0 +1,16 @@
1
+ #include <stdint.h>
2
+ #include <utf.h>
3
+
4
+ #include "../include/hex.h"
5
+
6
+ extern int
7
+ hex_encode_utf8(const uint8_t *buffer, size_t buffer_len, utf8_t *string, size_t *string_len);
8
+
9
+ extern int
10
+ hex_decode_utf8(const utf8_t *string, size_t string_len, uint8_t *buffer, size_t *buffer_len);
11
+
12
+ extern int
13
+ hex_encode_utf16le(const uint8_t *buffer, size_t buffer_len, utf16_t *string, size_t *string_len);
14
+
15
+ extern int
16
+ hex_decode_utf16le(const utf16_t *string, size_t string_len, uint8_t *buffer, size_t *buffer_len);
@@ -0,0 +1,31 @@
1
+ list(APPEND tests
2
+ decode
3
+ decode-invalid
4
+ decode-length
5
+ encode
6
+ encode-length
7
+ )
8
+
9
+ foreach(test IN LISTS tests)
10
+ add_executable(${test} ${test}.c)
11
+
12
+ target_link_libraries(
13
+ ${test}
14
+ PRIVATE
15
+ hex_static
16
+ )
17
+
18
+ add_test(
19
+ NAME ${test}
20
+ COMMAND ${test}
21
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
22
+ )
23
+
24
+ set_tests_properties(
25
+ ${test}
26
+ PROPERTIES
27
+ TIMEOUT 30
28
+ )
29
+ endforeach()
30
+
31
+ add_subdirectory(fuzz)
@@ -0,0 +1,37 @@
1
+ #include <assert.h>
2
+ #include <string.h>
3
+ #include <utf.h>
4
+
5
+ #include "../include/hex.h"
6
+
7
+ #define test_decode_invalid_utf8(string) \
8
+ { \
9
+ size_t string_len = strlen(string); \
10
+ size_t buffer_len = string_len; \
11
+ uint8_t buffer[buffer_len]; \
12
+ int err = hex_decode_utf8((utf8_t *) string, string_len, buffer, &buffer_len); \
13
+ assert(err != 0); \
14
+ };
15
+
16
+ #define test_decode_invalid_utf16le(units, n) \
17
+ { \
18
+ size_t buffer_len = n; \
19
+ uint8_t buffer[buffer_len]; \
20
+ int err = hex_decode_utf16le(units, n, buffer, &buffer_len); \
21
+ assert(err != 0); \
22
+ };
23
+
24
+ int
25
+ main() {
26
+ test_decode_invalid_utf8("v");
27
+
28
+ // Odd-length input must be rejected
29
+ test_decode_invalid_utf8("abc");
30
+
31
+ utf16_t odd[3] = {'a', 'b', 'c'};
32
+ test_decode_invalid_utf16le(odd, 3);
33
+
34
+ // UTF-16 code units > 0xff must be rejected
35
+ utf16_t high[2] = {'6', 0x20ac};
36
+ test_decode_invalid_utf16le(high, 2);
37
+ }
@@ -0,0 +1,23 @@
1
+ #include <assert.h>
2
+ #include <string.h>
3
+ #include <utf.h>
4
+
5
+ #include "../include/hex.h"
6
+
7
+ #define test_decode_length(string, expected) \
8
+ { \
9
+ size_t string_len = strlen(string); \
10
+ size_t buffer_len = 0; \
11
+ int err = hex_decode_utf8((utf8_t *) string, string_len, NULL, &buffer_len); \
12
+ assert(err == 0); \
13
+ assert(buffer_len == expected); \
14
+ };
15
+
16
+ int
17
+ main() {
18
+ test_decode_length("61", 1);
19
+ test_decode_length("6162", 2);
20
+ test_decode_length("616263", 3);
21
+ test_decode_length("61626364", 4);
22
+ test_decode_length("6162636465", 5);
23
+ }
@@ -0,0 +1,25 @@
1
+ #include <assert.h>
2
+ #include <string.h>
3
+ #include <utf.h>
4
+
5
+ #include "../include/hex.h"
6
+
7
+ #define test_decode(string, expected) \
8
+ { \
9
+ size_t string_len = strlen(string); \
10
+ size_t buffer_len = string_len; \
11
+ uint8_t buffer[buffer_len]; \
12
+ int err = hex_decode_utf8((utf8_t *) string, string_len, buffer, &buffer_len); \
13
+ assert(err == 0); \
14
+ assert(buffer_len == strlen(expected)); \
15
+ assert(strncmp((char *) buffer, expected, buffer_len) == 0); \
16
+ };
17
+
18
+ int
19
+ main() {
20
+ test_decode("61", "a");
21
+ test_decode("6162", "ab");
22
+ test_decode("616263", "abc");
23
+ test_decode("61626364", "abcd");
24
+ test_decode("6162636465", "abcde");
25
+ }
@@ -0,0 +1,22 @@
1
+ #include <assert.h>
2
+ #include <string.h>
3
+
4
+ #include "../include/hex.h"
5
+
6
+ #define test_encode_length(buffer, expected) \
7
+ { \
8
+ size_t buffer_len = strlen(buffer); \
9
+ size_t string_len = 0; \
10
+ int err = hex_encode_utf8((uint8_t *) buffer, buffer_len, NULL, &string_len); \
11
+ assert(err == 0); \
12
+ assert(string_len == expected); \
13
+ };
14
+
15
+ int
16
+ main() {
17
+ test_encode_length("a", 2);
18
+ test_encode_length("ab", 4);
19
+ test_encode_length("abc", 6);
20
+ test_encode_length("abcd", 8);
21
+ test_encode_length("abcde", 10);
22
+ }
@@ -0,0 +1,25 @@
1
+ #include <assert.h>
2
+ #include <string.h>
3
+ #include <utf.h>
4
+
5
+ #include "../include/hex.h"
6
+
7
+ #define test_encode(buffer, expected) \
8
+ { \
9
+ size_t buffer_len = strlen(buffer); \
10
+ size_t string_len = buffer_len * 2 + 1; \
11
+ char string[string_len]; \
12
+ int err = hex_encode_utf8((uint8_t *) buffer, buffer_len, (utf8_t *) string, &string_len); \
13
+ assert(err == 0); \
14
+ assert(string_len == strlen(expected)); \
15
+ assert(strncmp(string, expected, string_len) == 0); \
16
+ };
17
+
18
+ int
19
+ main() {
20
+ test_encode("a", "61");
21
+ test_encode("ab", "6162");
22
+ test_encode("abc", "616263");
23
+ test_encode("abcd", "61626364");
24
+ test_encode("abcde", "6162636465");
25
+ }
@@ -0,0 +1,18 @@
1
+ list(APPEND fuzzers
2
+ encode/utf8
3
+ encode/utf16le
4
+ decode/utf8
5
+ decode/utf16le
6
+ )
7
+
8
+ foreach(fuzzer IN LISTS fuzzers)
9
+ string(REPLACE "/" "_" name ${fuzzer})
10
+
11
+ add_fuzzer(fuzz_${name} ${fuzzer}.c)
12
+
13
+ target_link_libraries(
14
+ fuzz_${name}
15
+ PRIVATE
16
+ hex_static
17
+ )
18
+ endforeach()
@@ -0,0 +1,53 @@
1
+ #include <assert.h>
2
+ #include <stddef.h>
3
+ #include <stdint.h>
4
+ #include <stdlib.h>
5
+ #include <string.h>
6
+
7
+ #include "../../../include/hex.h"
8
+
9
+ int
10
+ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
11
+ // Reinterpret the raw bytes as a sequence of UTF-16 code units.
12
+ size_t units = size / sizeof(utf16_t);
13
+ utf16_t *string = units > 0 ? malloc(units * sizeof(utf16_t)) : NULL;
14
+
15
+ if (string != NULL) memcpy(string, data, units * sizeof(utf16_t));
16
+
17
+ size_t buffer_len = units / 2;
18
+ uint8_t *buffer = buffer_len > 0 ? malloc(buffer_len) : NULL;
19
+
20
+ int err = hex_decode_utf16le(string, units, buffer, &buffer_len);
21
+
22
+ if (err == 0) {
23
+ assert(buffer_len == units / 2);
24
+
25
+ if (buffer_len > 0) {
26
+ // Re-encode the decoded bytes; the result must decode back identically.
27
+ size_t reencoded_len = buffer_len * 2;
28
+ utf16_t *reencoded = malloc(reencoded_len * sizeof(utf16_t));
29
+
30
+ err = hex_encode_utf16le(buffer, buffer_len, reencoded, &reencoded_len);
31
+
32
+ assert(err == 0);
33
+ assert(reencoded_len == buffer_len * 2);
34
+
35
+ size_t roundtrip_len = buffer_len;
36
+ uint8_t *roundtrip = malloc(roundtrip_len);
37
+
38
+ err = hex_decode_utf16le(reencoded, reencoded_len, roundtrip, &roundtrip_len);
39
+
40
+ assert(err == 0);
41
+ assert(roundtrip_len == buffer_len);
42
+ assert(memcmp(roundtrip, buffer, buffer_len) == 0);
43
+
44
+ free(roundtrip);
45
+ free(reencoded);
46
+ }
47
+ }
48
+
49
+ free(buffer);
50
+ free(string);
51
+
52
+ return 0;
53
+ }
@@ -0,0 +1,47 @@
1
+ #include <assert.h>
2
+ #include <stddef.h>
3
+ #include <stdint.h>
4
+ #include <stdlib.h>
5
+ #include <string.h>
6
+
7
+ #include "../../../include/hex.h"
8
+
9
+ int
10
+ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
11
+ // Decoded output is at most half the input length.
12
+ size_t buffer_len = size / 2;
13
+ uint8_t *buffer = buffer_len > 0 ? malloc(buffer_len) : NULL;
14
+
15
+ int err = hex_decode_utf8((const utf8_t *) data, size, buffer, &buffer_len);
16
+
17
+ if (err == 0) {
18
+ assert(buffer_len == size / 2);
19
+
20
+ if (buffer_len > 0) {
21
+ // Re-encode the decoded bytes; the result must decode back identically.
22
+ size_t string_len = buffer_len * 2;
23
+ utf8_t *string = malloc(string_len);
24
+
25
+ err = hex_encode_utf8(buffer, buffer_len, string, &string_len);
26
+
27
+ assert(err == 0);
28
+ assert(string_len == buffer_len * 2);
29
+
30
+ size_t roundtrip_len = buffer_len;
31
+ uint8_t *roundtrip = malloc(roundtrip_len);
32
+
33
+ err = hex_decode_utf8(string, string_len, roundtrip, &roundtrip_len);
34
+
35
+ assert(err == 0);
36
+ assert(roundtrip_len == buffer_len);
37
+ assert(memcmp(roundtrip, buffer, buffer_len) == 0);
38
+
39
+ free(roundtrip);
40
+ free(string);
41
+ }
42
+ }
43
+
44
+ free(buffer);
45
+
46
+ return 0;
47
+ }
@@ -0,0 +1,36 @@
1
+ #include <assert.h>
2
+ #include <stddef.h>
3
+ #include <stdint.h>
4
+ #include <stdlib.h>
5
+ #include <string.h>
6
+
7
+ #include "../../../include/hex.h"
8
+
9
+ int
10
+ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
11
+ // Each input byte expands to exactly 2 hex code units.
12
+ size_t string_len = size * 2;
13
+ utf16_t *string = string_len > 0 ? malloc(string_len * sizeof(utf16_t)) : NULL;
14
+
15
+ int err = hex_encode_utf16le(data, size, string, &string_len);
16
+
17
+ assert(err == 0);
18
+ assert(string_len == size * 2);
19
+
20
+ if (size > 0) {
21
+ size_t buffer_len = size;
22
+ uint8_t *buffer = malloc(buffer_len);
23
+
24
+ err = hex_decode_utf16le(string, string_len, buffer, &buffer_len);
25
+
26
+ assert(err == 0);
27
+ assert(buffer_len == size);
28
+ assert(memcmp(buffer, data, size) == 0);
29
+
30
+ free(buffer);
31
+ }
32
+
33
+ free(string);
34
+
35
+ return 0;
36
+ }
@@ -0,0 +1,36 @@
1
+ #include <assert.h>
2
+ #include <stddef.h>
3
+ #include <stdint.h>
4
+ #include <stdlib.h>
5
+ #include <string.h>
6
+
7
+ #include "../../../include/hex.h"
8
+
9
+ int
10
+ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
11
+ // Each input byte expands to exactly 2 hex characters.
12
+ size_t string_len = size * 2;
13
+ utf8_t *string = string_len > 0 ? malloc(string_len) : NULL;
14
+
15
+ int err = hex_encode_utf8(data, size, string, &string_len);
16
+
17
+ assert(err == 0);
18
+ assert(string_len == size * 2);
19
+
20
+ if (size > 0) {
21
+ size_t buffer_len = size;
22
+ uint8_t *buffer = malloc(buffer_len);
23
+
24
+ err = hex_decode_utf8(string, string_len, buffer, &buffer_len);
25
+
26
+ assert(err == 0);
27
+ assert(buffer_len == size);
28
+ assert(memcmp(buffer, data, size) == 0);
29
+
30
+ free(buffer);
31
+ }
32
+
33
+ free(string);
34
+
35
+ return 0;
36
+ }
@@ -0,0 +1,10 @@
1
+ AlignAfterOpenBracket: BlockIndent
2
+ AlignConsecutiveMacros: Consecutive
3
+ AlignEscapedNewlines: DontAlign
4
+ AllowShortIfStatementsOnASingleLine: AllIfsAndElse
5
+ AlwaysBreakAfterReturnType: TopLevel
6
+ BinPackArguments: false
7
+ BinPackParameters: false
8
+ ContinuationIndentWidth: 2
9
+ ColumnLimit: 0
10
+ SpaceAfterCStyleCast: true
@@ -0,0 +1 @@
1
+ * text=auto eol=lf
@@ -0,0 +1,45 @@
1
+ name: Integrate
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request:
7
+ branches:
8
+ - main
9
+ permissions:
10
+ contents: read
11
+ jobs:
12
+ security:
13
+ runs-on: ubuntu-latest
14
+ name: Security
15
+ steps:
16
+ - uses: holepunchto/actions/security-base@v1
17
+ lint:
18
+ runs-on: ubuntu-latest
19
+ name: Lint
20
+ steps:
21
+ - uses: holepunchto/actions/node-base@v1
22
+ - run: npm run lint
23
+ test:
24
+ strategy:
25
+ matrix:
26
+ include:
27
+ - os: ubuntu-latest
28
+ platform: linux
29
+ arch: x64
30
+ - os: macos-latest
31
+ platform: darwin
32
+ arch: arm64
33
+ - os: windows-latest
34
+ platform: win32
35
+ arch: x64
36
+ runs-on: ${{ matrix.os }}
37
+ name: Test / ${{ matrix.platform }}-${{ matrix.arch }}
38
+ steps:
39
+ - uses: holepunchto/actions/bare-base@v1
40
+ - uses: holepunchto/actions/compile-prebuilds@v1
41
+ with:
42
+ platform: ${{ matrix.platform }}
43
+ arch: ${{ matrix.arch }}
44
+ flags: --debug
45
+ - run: bare-make test
@@ -0,0 +1,28 @@
1
+ name: Nightly
2
+ on:
3
+ schedule:
4
+ - cron: '0 4 * * *'
5
+ workflow_dispatch:
6
+ permissions:
7
+ contents: read
8
+ jobs:
9
+ fuzz:
10
+ strategy:
11
+ matrix:
12
+ include:
13
+ - os: ubuntu-latest
14
+ platform: linux
15
+ arch: x64
16
+ runs-on: ${{ matrix.os }}
17
+ name: Fuzz / ${{ matrix.platform }}-${{ matrix.arch }}
18
+ steps:
19
+ - uses: holepunchto/actions/bare-base@v1
20
+ - uses: holepunchto/actions/restore-fuzz-corpus@v1
21
+ - uses: holepunchto/actions/compile-prebuilds@v1
22
+ with:
23
+ platform: ${{ matrix.platform }}
24
+ arch: ${{ matrix.arch }}
25
+ flags: --debug --sanitize address --fuzz
26
+ - run: bare-make test
27
+ - uses: holepunchto/actions/save-fuzz-corpus@v1
28
+ if: always()
@@ -0,0 +1 @@
1
+ "prettier-config-holepunch"
@@ -0,0 +1,105 @@
1
+ cmake_minimum_required(VERSION 3.31)
2
+
3
+ find_package(cmake-harden REQUIRED PATHS node_modules/cmake-harden)
4
+ find_package(cmake-fuzz REQUIRED PATHS node_modules/cmake-fuzz)
5
+
6
+ project(utf C)
7
+
8
+ add_library(utf OBJECT)
9
+
10
+ harden(utf)
11
+
12
+ set_target_properties(
13
+ utf
14
+ PROPERTIES
15
+ C_STANDARD 99
16
+ POSITION_INDEPENDENT_CODE ON
17
+ )
18
+
19
+ target_sources(
20
+ utf
21
+ INTERFACE
22
+ include/utf.h
23
+ include/utf/string.h
24
+ PRIVATE
25
+ src/endianness.c
26
+ src/endianness.h
27
+ src/ascii/validate.c
28
+ src/latin1/convert-to-utf8.c
29
+ src/latin1/convert-to-utf16.c
30
+ src/latin1/convert-to-utf32.c
31
+ src/latin1/length-from-utf8.c
32
+ src/latin1/length-from-utf16.c
33
+ src/latin1/length-from-utf32.c
34
+ src/utf8/convert-to-latin1.c
35
+ src/utf8/convert-to-utf16.c
36
+ src/utf8/convert-to-utf32.c
37
+ src/utf8/length-from-latin1.c
38
+ src/utf8/length-from-utf16.c
39
+ src/utf8/length-from-utf32.c
40
+ src/utf8/string.c
41
+ src/utf8/validate.c
42
+ src/utf16/convert-to-latin1.c
43
+ src/utf16/convert-to-utf8.c
44
+ src/utf16/convert-to-utf32.c
45
+ src/utf16/length-from-latin1.c
46
+ src/utf16/length-from-utf8.c
47
+ src/utf16/length-from-utf32.c
48
+ src/utf16/validate.c
49
+ src/utf32/convert-to-latin1.c
50
+ src/utf32/convert-to-utf8.c
51
+ src/utf32/convert-to-utf16.c
52
+ src/utf32/length-from-latin1.c
53
+ src/utf32/length-from-utf8.c
54
+ src/utf32/length-from-utf16.c
55
+ src/utf32/string.c
56
+ src/utf32/validate.c
57
+ )
58
+
59
+ target_include_directories(
60
+ utf
61
+ PUBLIC
62
+ include
63
+ )
64
+
65
+ add_library(utf_shared SHARED)
66
+
67
+ set_target_properties(
68
+ utf_shared
69
+ PROPERTIES
70
+ OUTPUT_NAME utf
71
+ WINDOWS_EXPORT_ALL_SYMBOLS ON
72
+ )
73
+
74
+ target_link_libraries(
75
+ utf_shared
76
+ PUBLIC
77
+ utf
78
+ )
79
+
80
+ add_library(utf_static STATIC)
81
+
82
+ set_target_properties(
83
+ utf_static
84
+ PROPERTIES
85
+ OUTPUT_NAME utf
86
+ PREFIX lib
87
+ )
88
+
89
+ target_link_libraries(
90
+ utf_static
91
+ PUBLIC
92
+ utf
93
+ )
94
+
95
+ install(TARGETS utf_shared utf_static)
96
+
97
+ install(FILES include/utf.h DESTINATION include)
98
+
99
+ install(DIRECTORY include/utf DESTINATION include)
100
+
101
+ if(PROJECT_IS_TOP_LEVEL)
102
+ enable_testing()
103
+
104
+ add_subdirectory(test)
105
+ endif()