Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
mringwal committed Oct 8, 2018
2 parents 6a765b5 + b402b8b commit 2f98d3c60ab84a4e7ec4a33c528cd323900cd4a3
Showing with 9,624 additions and 1,449 deletions.
  1. +291 −0 3rd-party/md5/md5.c
  2. +45 −0 3rd-party/md5/md5.h
  3. +12 −9 3rd-party/tinydir/tinydir.h
  4. +20 −0 3rd-party/yxml/COPYING
  5. +1,063 −0 3rd-party/yxml/yxml.c
  6. +162 −0 3rd-party/yxml/yxml.h
  7. +34 −0 CHANGELOG.md
  8. +35 −33 README.md
  9. +5 −0 chipset/README.md
  10. +27 −6 chipset/cc256x/Makefile.inc
  11. +1 −1 chipset/cc256x/convert_bts_init_scripts.py
  12. +2 −0 chipset/intel/.gitignore
  13. +28 −0 chipset/intel/Makefile.inc
  14. +430 −0 chipset/intel/btstack_chipset_intel_firmware.c
  15. +71 −0 chipset/intel/btstack_chipset_intel_firmware.h
  16. +1 −1 doc/manual/docs/how_to.md
  17. +2 −2 doc/manual/docs/profiles.md
  18. +11 −4 example/Makefile.inc
  19. +4 −4 example/a2dp_sink_demo.c
  20. +44 −19 example/a2dp_source_demo.c
  21. +11 −5 example/ancs_client_demo.c
  22. +10 −11 example/ant_test.c
  23. +0 −10 example/att_delayed_read_response.gatt
  24. +55 −16 example/{att_delayed_read_response.c → att_delayed_response.c}
  25. +10 −0 example/att_delayed_response.gatt
  26. +10 −8 example/avrcp_browsing_client.c
  27. +3 −3 example/dut_mode_classic.c
  28. +3 −3 example/gap_inquiry.c
  29. +3 −2 example/gap_le_advertisements.c
  30. +4 −4 example/gatt_battery_query.c
  31. +7 −7 example/gatt_browser.c
  32. +3 −4 example/gatt_heart_rate_client.c
  33. +8 −7 example/hfp_ag_demo.c
  34. +9 −8 example/hfp_hf_demo.c
  35. +7 −5 example/hid_host_demo.c
  36. +9 −8 example/hid_keyboard_demo.c
  37. +9 −7 example/hid_mouse_demo.c
  38. +13 −7 example/hog_keyboard_demo.c
  39. +9 −6 example/hog_mouse_demo.c
  40. +3 −0 example/hsp_ag_demo.c
  41. +8 −5 example/hsp_hs_demo.c
  42. +7 −5 example/le_counter.c
  43. +3 −3 example/le_data_channel_client.c
  44. +6 −5 example/le_data_channel_server.c
  45. +65 −24 example/le_streamer.c
  46. +6 −6 example/le_streamer_client.c
  47. +6 −6 example/panu_demo.c
  48. +59 −11 example/pbap_client_demo.c
  49. +3 −5 example/sdp_bnep_query.c
  50. +2 −3 example/sdp_general_query.c
  51. +3 −6 example/sdp_rfcomm_query.c
  52. +10 −7 example/sm_pairing_central.c
  53. +26 −11 example/sm_pairing_peripheral.c
  54. +11 −10 example/spp_and_le_counter.c
  55. +6 −5 example/spp_and_le_streamer.c
  56. +11 −2 example/spp_flowcontrol.c
  57. +4 −4 example/spp_streamer.c
  58. +4 −4 example/spp_streamer_client.c
  59. +3 −0 platform/corefoundation/btstack_device_name_db_corefoundation.m
  60. +3 −0 platform/corefoundation/btstack_link_key_db_corefoundation.m
  61. +2 −0 platform/corefoundation/btstack_run_loop_corefoundation.m
  62. +1 −1 platform/daemon/binding/java/build.xml
  63. +193 −0 platform/daemon/binding/java/example/com/bluekitchen/LEStreamerClient.java
  64. +0 −42 platform/daemon/example/Makefile.in
  65. +10 −1 platform/daemon/example/inquiry.c
  66. +10 −1 platform/daemon/example/l2cap_server.c
  67. +10 −1 platform/daemon/example/l2cap_throughput.c
  68. +9 −0 platform/daemon/example/le_scan.c
  69. +10 −1 platform/daemon/example/rfcomm_cat.c
  70. +10 −1 platform/daemon/example/rfcomm_echo.c
  71. +10 −1 platform/daemon/example/rfcomm_test.c
  72. +10 −1 platform/daemon/example/test.c
  73. +12 −0 platform/daemon/src/btstack.c
  74. +70 −0 platform/daemon/src/btstack_server.h
  75. +315 −236 platform/daemon/src/daemon.c
  76. +49 −0 platform/daemon/src/daemon_cmds.c
  77. +6 −0 platform/daemon/src/daemon_cmds.h
  78. +183 −61 platform/daemon/src/socket_connection.c
  79. +10 −0 platform/libusb/hci_transport_h2_libusb.c
  80. +1 −0 platform/posix/btstack_tlv_posix.c
  81. +1 −1 platform/windows/btstack_run_loop_windows.c
  82. +38 −8 platform/windows/hci_transport_h2_winusb.c
  83. +119 −92 port/daemon/configure.ac
  84. +1 −0 port/daemon/example/Makefile.in
  85. +2 −0 port/daemon/src/.gitignore
  86. +57 −43 port/daemon/src/Makefile.in
  87. +3 −0 port/esp32/components/btstack/component.mk
  88. +2 −0 port/esp32/integrate_btstack.py
  89. +44 −4 port/esp32/template/sdkconfig
  90. +1 −1 port/ios/src/hci_transport_h4_iphone.c
  91. +72 −0 port/libusb-intel/.gitignore
  92. +53 −0 port/libusb-intel/Makefile
  93. +86 −0 port/libusb-intel/README.md
  94. +36 −0 port/libusb-intel/btstack_config.h
  95. +204 −0 port/libusb-intel/main.c
  96. +15 −3 port/libusb/.gitignore
  97. +1 −1 port/libusb/btstack_config.h
  98. +5 −1 port/max32630-fthr/example/template/Makefile
  99. +1 −1 port/msp-exp430f5438-cc2564b/example/hid_demo.c
  100. +7 −2 port/mtk/Makefile
  101. +3 −1 port/mtk/btstack_config.h
  102. +1 −1 port/posix-h4-da14581/.gitignore
  103. +7 −8 port/posix-h4-da14585/.gitignore
  104. +10 −0 port/posix-h4/.gitignore
  105. +1 −1 port/posix-h4/btstack_config.h
  106. +27 −3 port/posix-h5/.gitignore
  107. +1 −0 port/stm32-f4discovery-cc256x/cubemx-f4discovery-cc256x/.gitignore
  108. +17 −11 port/stm32-f4discovery-cc256x/cubemx-f4discovery-cc256x/Makefile
  109. +1 −0 port/stm32-f4discovery-cc256x/eclipse-template/.cproject
  110. +1 −0 port/stm32-l053r8-em9304/cubemx-l053r8-em9304/Makefile
  111. +2 −2 port/wiced-h4/wiced-h4.mk
  112. +2 −2 port/wiced-h5/wiced-h5.mk
  113. +39 −0 port/windows-winusb-intel/.gitignore
  114. +39 −0 port/windows-winusb-intel/Makefile
  115. +43 −0 port/windows-winusb-intel/README.md
  116. +33 −0 port/windows-winusb-intel/btstack_config.h
  117. +193 −0 port/windows-winusb-intel/main.c
  118. +4 −1 port/windows-winusb/Makefile
  119. +34 −13 port/windows-winusb/main.c
  120. +28 −11 src/ble/att_db.c
  121. +5 −1 src/ble/att_db.h
  122. +14 −11 src/ble/att_server.c
  123. +4 −3 src/ble/att_server.h
  124. +11 −1 src/ble/gatt-service/hids.gatt
  125. +260 −62 src/ble/gatt-service/hids_device.c
  126. +26 −4 src/ble/gatt-service/hids_device.h
  127. +46 −1 src/ble/gatt_client.c
  128. +245 −16 src/ble/gatt_client.h
  129. +17 −9 src/ble/sm.c
  130. +2 −1 src/bluetooth.h
  131. +19 −6 src/btstack_crypto.c
  132. +92 −1 src/btstack_defines.h
  133. +211 −3 src/btstack_event.h
  134. +2 −2 src/btstack_slip.c
  135. +5 −2 src/btstack_util.c
  136. +64 −1 src/classic/a2dp_source.c
  137. +8 −1 src/classic/a2dp_source.h
  138. +20 −33 src/classic/avdtp.c
  139. +14 −3 src/classic/avdtp.h
  140. +8 −0 src/classic/avdtp_initiator.c
  141. +2 −4 src/classic/avrcp.c
  142. +5 −0 src/classic/avrcp_controller.c
  143. +281 −67 src/classic/goep_client.c
  144. +31 −3 src/classic/goep_client.h
  145. +66 −33 src/classic/hfp.c
  146. +5 −4 src/classic/hfp.h
  147. +15 −25 src/classic/hfp_ag.c
  148. +32 −3 src/classic/hfp_hf.c
  149. +353 −49 src/classic/hid_device.c
  150. +88 −2 src/classic/hid_device.h
  151. +75 −18 src/classic/obex.h
  152. +8 −7 src/classic/obex_iterator.c
  153. +1 −1 src/classic/pan.c
  154. +1 −1 src/classic/pan.h
  155. +473 −68 src/classic/pbap_client.c
  156. +31 −1 src/classic/pbap_client.h
  157. +61 −36 src/classic/rfcomm.c
  158. +43 −1 src/classic/sdp_server.c
  159. +97 −41 src/hci.c
  160. +8 −3 src/hci.h
  161. +11 −0 src/hci_cmd.c
  162. +2 −1 src/hci_cmd.h
  163. +3 −0 src/hci_dump.c
  164. +53 −19 src/l2cap.c
  165. +1 −1 test/hfp/hfp_ag_client_test.c
  166. +5 −0 test/pts/.gitignore
  167. +15 −7 test/pts/Makefile
  168. +10 −3 test/pts/ble_central_test.c
  169. +5 −3 test/pts/bnep_test.c
  170. +1 −1 test/pts/classic_test.c
  171. +7 −2 test/pts/gatt_profiles.c
  172. +554 −0 test/pts/hid_device_test.c
  173. +497 −0 test/pts/hid_host_test.c
  174. +567 −0 test/pts/hog_demo_test.c
  175. +14 −0 test/pts/hog_demo_test.gatt
  176. +235 −0 test/pts/hog_demo_test.h
  177. +5 −0 test/pts/hsp_ag_test.c
  178. +5 −1 test/pts/hsp_hs_test.c
  179. +6 −1 test/pts/sco_loopback.c
  180. 0 test/{security_manager → rijndael}/rijndael.c
  181. 0 test/{security_manager → rijndael}/rijndael.h
  182. +2 −0 test/security_manager/Makefile
  183. +2 −2 tool/get_version.sh
View
@@ -0,0 +1,291 @@
/*
* This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
* MD5 Message-Digest Algorithm (RFC 1321).
*
* Homepage:
* http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
*
* Author:
* Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
*
* This software was written by Alexander Peslyak in 2001. No copyright is
* claimed, and the software is hereby placed in the public domain.
* In case this attempt to disclaim copyright and place the software in the
* public domain is deemed null and void, then the software is
* Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
* general public under the following terms:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted.
*
* There's ABSOLUTELY NO WARRANTY, express or implied.
*
* (This is a heavily cut-down "BSD license".)
*
* This differs from Colin Plumb's older public domain implementation in that
* no exactly 32-bit integer data type is required (any 32-bit or wider
* unsigned integer data type will do), there's no compile-time endianness
* configuration, and the function prototypes match OpenSSL's. No code from
* Colin Plumb's implementation has been reused; this comment merely compares
* the properties of the two independent implementations.
*
* The primary goals of this implementation are portability and ease of use.
* It is meant to be fast, but not as fast as possible. Some known
* optimizations are not included to reduce source code size and avoid
* compile-time configuration.
*/
#ifndef HAVE_OPENSSL
#include <string.h>
#include "md5.h"
/*
* The basic MD5 functions.
*
* F and G are optimized compared to their RFC 1321 definitions for
* architectures that lack an AND-NOT instruction, just like in Colin Plumb's
* implementation.
*/
#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y))))
#define H(x, y, z) (((x) ^ (y)) ^ (z))
#define H2(x, y, z) ((x) ^ ((y) ^ (z)))
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
/*
* The MD5 transformation for all four rounds.
*/
#define STEP(f, a, b, c, d, x, t, s) \
(a) += f((b), (c), (d)) + (x) + (t); \
(a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
(a) += (b);
/*
* SET reads 4 input bytes in little-endian byte order and stores them in a
* properly aligned word in host byte order.
*
* The check for little-endian architectures that tolerate unaligned memory
* accesses is just an optimization. Nothing will break if it fails to detect
* a suitable architecture.
*
* Unfortunately, this optimization may be a C strict aliasing rules violation
* if the caller's data buffer has effective type that cannot be aliased by
* MD5_u32plus. In practice, this problem may occur if these MD5 routines are
* inlined into a calling function, or with future and dangerously advanced
* link-time optimizations. For the time being, keeping these MD5 routines in
* their own translation unit avoids the problem.
*/
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
#define SET(n) \
(*(MD5_u32plus *)&ptr[(n) * 4])
#define GET(n) \
SET(n)
#else
#define SET(n) \
(ctx->block[(n)] = \
(MD5_u32plus)ptr[(n) * 4] | \
((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
#define GET(n) \
(ctx->block[(n)])
#endif
/*
* This processes one or more 64-byte data blocks, but does NOT update the bit
* counters. There are no alignment requirements.
*/
static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
{
const unsigned char *ptr;
MD5_u32plus a, b, c, d;
MD5_u32plus saved_a, saved_b, saved_c, saved_d;
ptr = (const unsigned char *)data;
a = ctx->a;
b = ctx->b;
c = ctx->c;
d = ctx->d;
do {
saved_a = a;
saved_b = b;
saved_c = c;
saved_d = d;
/* Round 1 */
STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7)
STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12)
STEP(F, c, d, a, b, SET(2), 0x242070db, 17)
STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22)
STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7)
STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12)
STEP(F, c, d, a, b, SET(6), 0xa8304613, 17)
STEP(F, b, c, d, a, SET(7), 0xfd469501, 22)
STEP(F, a, b, c, d, SET(8), 0x698098d8, 7)
STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12)
STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17)
STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22)
STEP(F, a, b, c, d, SET(12), 0x6b901122, 7)
STEP(F, d, a, b, c, SET(13), 0xfd987193, 12)
STEP(F, c, d, a, b, SET(14), 0xa679438e, 17)
STEP(F, b, c, d, a, SET(15), 0x49b40821, 22)
/* Round 2 */
STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5)
STEP(G, d, a, b, c, GET(6), 0xc040b340, 9)
STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14)
STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20)
STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5)
STEP(G, d, a, b, c, GET(10), 0x02441453, 9)
STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14)
STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20)
STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5)
STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9)
STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14)
STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20)
STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5)
STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9)
STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14)
STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20)
/* Round 3 */
STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)
STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11)
STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16)
STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23)
STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4)
STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11)
STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16)
STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23)
STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4)
STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11)
STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16)
STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23)
STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4)
STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11)
STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16)
STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23)
/* Round 4 */
STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)
STEP(I, d, a, b, c, GET(7), 0x432aff97, 10)
STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15)
STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21)
STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6)
STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10)
STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15)
STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21)
STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6)
STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10)
STEP(I, c, d, a, b, GET(6), 0xa3014314, 15)
STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21)
STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6)
STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10)
STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15)
STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21)
a += saved_a;
b += saved_b;
c += saved_c;
d += saved_d;
ptr += 64;
} while (size -= 64);
ctx->a = a;
ctx->b = b;
ctx->c = c;
ctx->d = d;
return ptr;
}
void MD5_Init(MD5_CTX *ctx)
{
ctx->a = 0x67452301;
ctx->b = 0xefcdab89;
ctx->c = 0x98badcfe;
ctx->d = 0x10325476;
ctx->lo = 0;
ctx->hi = 0;
}
void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
{
MD5_u32plus saved_lo;
unsigned long used, available;
saved_lo = ctx->lo;
if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
ctx->hi++;
ctx->hi += size >> 29;
used = saved_lo & 0x3f;
if (used) {
available = 64 - used;
if (size < available) {
memcpy(&ctx->buffer[used], data, size);
return;
}
memcpy(&ctx->buffer[used], data, available);
data = (const unsigned char *)data + available;
size -= available;
body(ctx, ctx->buffer, 64);
}
if (size >= 64) {
data = body(ctx, data, size & ~(unsigned long)0x3f);
size &= 0x3f;
}
memcpy(ctx->buffer, data, size);
}
#define OUT(dst, src) \
(dst)[0] = (unsigned char)(src); \
(dst)[1] = (unsigned char)((src) >> 8); \
(dst)[2] = (unsigned char)((src) >> 16); \
(dst)[3] = (unsigned char)((src) >> 24);
void MD5_Final(unsigned char *result, MD5_CTX *ctx)
{
unsigned long used, available;
used = ctx->lo & 0x3f;
ctx->buffer[used++] = 0x80;
available = 64 - used;
if (available < 8) {
memset(&ctx->buffer[used], 0, available);
body(ctx, ctx->buffer, 64);
used = 0;
available = 64;
}
memset(&ctx->buffer[used], 0, available - 8);
ctx->lo <<= 3;
OUT(&ctx->buffer[56], ctx->lo)
OUT(&ctx->buffer[60], ctx->hi)
body(ctx, ctx->buffer, 64);
OUT(&result[0], ctx->a)
OUT(&result[4], ctx->b)
OUT(&result[8], ctx->c)
OUT(&result[12], ctx->d)
memset(ctx, 0, sizeof(*ctx));
}
#endif
View
@@ -0,0 +1,45 @@
/*
* This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
* MD5 Message-Digest Algorithm (RFC 1321).
*
* Homepage:
* http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
*
* Author:
* Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
*
* This software was written by Alexander Peslyak in 2001. No copyright is
* claimed, and the software is hereby placed in the public domain.
* In case this attempt to disclaim copyright and place the software in the
* public domain is deemed null and void, then the software is
* Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
* general public under the following terms:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted.
*
* There's ABSOLUTELY NO WARRANTY, express or implied.
*
* See md5.c for more information.
*/
#ifdef HAVE_OPENSSL
#include <openssl/md5.h>
#elif !defined(_MD5_H)
#define _MD5_H
/* Any 32-bit or wider unsigned integer data type will do */
typedef unsigned int MD5_u32plus;
typedef struct {
MD5_u32plus lo, hi;
MD5_u32plus a, b, c, d;
unsigned char buffer[64];
MD5_u32plus block[16];
} MD5_CTX;
extern void MD5_Init(MD5_CTX *ctx);
extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
extern void MD5_Final(unsigned char *result, MD5_CTX *ctx);
#endif
@@ -1,5 +1,5 @@
/*
Copyright (c) 2013-2017, tinydir authors:
Copyright (c) 2013-2018, tinydir authors:
- Cong Xu
- Lautis Sun
- Baudouin Feildel
@@ -89,7 +89,10 @@ extern "C" {
# define _TINYDIR_PATH_MAX MAX_PATH
#elif defined __linux__
# include <limits.h>
# define _TINYDIR_PATH_MAX PATH_MAX
/* BK - only use PATH_MAX if defined */
# if defined(PATH_MAX)
# define _TINYDIR_PATH_MAX PATH_MAX
# endif
#elif defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
# include <sys/param.h>
# if defined(BSD)
@@ -365,7 +368,7 @@ int tinydir_open_sorted(tinydir_dir *dir, const _tinydir_char_t *path)
}
tinydir_close(dir);
if (tinydir_open(dir, path) == -1)
if (n_files == 0 || tinydir_open(dir, path) == -1)
{
return -1;
}
@@ -658,7 +661,7 @@ int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path)
/* Get the parent path */
#if (defined _MSC_VER || defined __MINGW32__)
#if ((defined _MSC_VER) && (_MSC_VER >= 1400))
_tsplitpath_s(
errno = _tsplitpath_s(
path,
drive_buf, _TINYDIR_DRIVE_MAX,
dir_name_buf, _TINYDIR_FILENAME_MAX,
@@ -673,6 +676,11 @@ int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path)
ext_buf);
#endif
if (errno)
{
return -1;
}
/* _splitpath_s not work fine with only filename and widechar support */
#ifdef _UNICODE
if (drive_buf[0] == L'\xFEFE')
@@ -681,11 +689,6 @@ int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path)
dir_name_buf[0] = '\0';
#endif
if (errno)
{
errno = EINVAL;
return -1;
}
/* Emulate the behavior of dirname by returning "." for dir name if it's
empty */
if (drive_buf[0] == '\0' && dir_name_buf[0] == '\0')
Oops, something went wrong.

0 comments on commit 2f98d3c

Please sign in to comment.