Browse code

strn - adding configuration option to force use of internal strn functions for use when crosscompiling binaries against older libraries

Mickey Sola authored on 2017/08/31 04:24:23
Showing 4 changed files
... ...
@@ -139,6 +139,8 @@ m4_include([m4/reorganization/substitutions.m4])
139 139
 
140 140
 m4_include([m4/reorganization/libmspack.m4])
141 141
 
142
+m4_include([m4/reorganization/strni.m4])
143
+
142 144
 if test "x$use_internal_mspack" = "xyes"; then
143 145
     mspack_msg="Internal"
144 146
     AC_CONFIG_SUBDIRS([libclamav/libmspack-0.5alpha])
... ...
@@ -460,7 +460,7 @@ const char* cli_strcasestr(const char* a, const char *b)
460 460
 }
461 461
 #endif
462 462
 
463
-#ifndef HAVE_STRNLEN
463
+#if !defined(HAVE_STRNLEN) || defined(HAVE_STRNI)
464 464
 size_t cli_strnlen(const char *s, size_t n)
465 465
 {
466 466
     size_t i = 0;
... ...
@@ -469,7 +469,7 @@ size_t cli_strnlen(const char *s, size_t n)
469 469
 }
470 470
 #endif
471 471
 
472
-#ifndef HAVE_STRNDUP
472
+#if !defined(HAVE_STRNDUP) || defined(HAVE_STRNI)
473 473
 char *cli_strndup(const char *s, size_t n)
474 474
 {
475 475
     char *alloc;
... ...
@@ -33,13 +33,13 @@
33 33
 const char *cli_strcasestr(const char *haystack, const char *needle);
34 34
 #endif
35 35
 
36
-#ifdef HAVE_STRNDUP
36
+#if defined(HAVE_STRNDUP) && !defined(HAVE_STRNI)
37 37
 #define cli_strndup strndup
38 38
 #else
39 39
 char *cli_strndup(const char *s, size_t n);
40 40
 #endif
41 41
 
42
-#ifdef HAVE_STRNLEN
42
+#if defined(HAVE_STRNLEN) && !defined(HAVE_STRNI)
43 43
 #define cli_strnlen strnlen
44 44
 #else
45 45
 size_t cli_strnlen(const char *s, size_t n);
46 46
new file mode 100644
... ...
@@ -0,0 +1,12 @@
0
+
1
+AC_ARG_ENABLE([strni],
2
+[AS_HELP_STRING([--enable-strni],
3
+[enables explicit use of internal strn functions to support cross-compilation against older libs])],
4
+enable_strni=$enableval, enable_strni="no")
5
+
6
+if test "$enable_strni" = "yes"; then
7
+    AC_DEFINE([HAVE_STRNI],1,[using internal strn functions])
8
+    AC_SUBST([HAVE_STRNI])
9
+fi
10
+
11
+