diff options
author | Jakub Jelen <jjelen@redhat.com> | 2017-12-11 15:37:02 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2017-12-21 11:43:19 +0100 |
commit | b8e301ade328fdfbef37e967241fc5da67111975 (patch) | |
tree | 9b24d8c0d25c5d775fed05047235d12bd9192578 | |
parent | 99c5160cb5a1a169f86d334017efde4cef23ead8 (diff) | |
download | libssh-b8e301ade328fdfbef37e967241fc5da67111975.tar.gz libssh-b8e301ade328fdfbef37e967241fc5da67111975.tar.xz libssh-b8e301ade328fdfbef37e967241fc5da67111975.zip |
config: Add CMake check for glob()
-rw-r--r-- | ConfigureChecks.cmake | 5 | ||||
-rw-r--r-- | config.h.cmake | 6 | ||||
-rw-r--r-- | src/config.c | 10 | ||||
-rw-r--r-- | tests/unittests/torture_config.c | 6 |
4 files changed, 25 insertions, 2 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 3e497dcb..2e1083b4 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -63,6 +63,7 @@ check_include_file(sys/utime.h HAVE_SYS_UTIME_H) check_include_file(sys/param.h HAVE_SYS_PARAM_H) check_include_file(arpa/inet.h HAVE_ARPA_INET_H) check_include_file(byteswap.h HAVE_BYTESWAP_H) +check_include_file(glob.h HAVE_GLOB_H) if (WIN32) check_include_file(io.h HAVE_IO_H) @@ -140,6 +141,10 @@ check_function_exists(isblank HAVE_ISBLANK) check_function_exists(strncpy HAVE_STRNCPY) check_function_exists(strtoull HAVE_STRTOULL) +if (HAVE_GLOB_H) + check_function_exists(glob HAVE_GLOB) +endif (HAVE_GLOB_H) + if (NOT WIN32) check_function_exists(vsnprintf HAVE_VSNPRINTF) check_function_exists(snprintf HAVE_SNPRINTF) diff --git a/config.h.cmake b/config.h.cmake index f8869df7..e0460c57 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -20,6 +20,9 @@ /* Define to 1 if you have the <aprpa/inet.h> header file. */ #cmakedefine HAVE_ARPA_INET_H 1 +/* Define to 1 if you have the <glob.h> header file. */ +#cmakedefine HAVE_GLOB_H 1 + /* Define to 1 if you have the <pty.h> header file. */ #cmakedefine HAVE_PTY_H 1 @@ -151,6 +154,9 @@ /* Define to 1 if you have the `_strtoui64' function. */ #cmakedefine HAVE__STRTOUI64 1 +/* Define to 1 if you have the `glob' function. */ +#cmakedefine HAVE_GLOB 1 + /*************************** LIBRARIES ***************************/ /* Define to 1 if you have the `crypto' library (-lcrypto). */ diff --git a/src/config.c b/src/config.c index cedf34e4..a95e0b63 100644 --- a/src/config.c +++ b/src/config.c @@ -27,7 +27,9 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> -#include <glob.h> +#ifdef HAVE_GLOB_H +# include <glob.h> +#endif #include "libssh/priv.h" #include "libssh/session.h" @@ -317,6 +319,7 @@ static void local_parse_file(ssh_session session, const char *filename, int *par return; } +#ifdef HAVE_GLOB static void local_parse_glob(ssh_session session, const char *fileglob, int *parsing, @@ -343,6 +346,7 @@ static void local_parse_glob(ssh_session session, globfree(&globbuf); } +#endif /* HAVE_GLOB */ static int ssh_config_parse_line(ssh_session session, const char *line, unsigned int count, int *parsing, int seen[]) { @@ -389,7 +393,11 @@ static int ssh_config_parse_line(ssh_session session, const char *line, p = ssh_config_get_str_tok(&s, NULL); if (p && *parsing) { +#ifdef HAVE_GLOB local_parse_glob(session, p, parsing, seen); +#else + local_parse_file(session, p, parsing, seen); +#endif /* HAVE_GLOB */ } break; case SOC_HOST: { diff --git a/tests/unittests/torture_config.c b/tests/unittests/torture_config.c index 8ca097c7..1694fbde 100644 --- a/tests/unittests/torture_config.c +++ b/tests/unittests/torture_config.c @@ -122,13 +122,16 @@ static void torture_config_double_ports(void **state) { static void torture_config_glob(void **state) { ssh_session session = *state; int ret; +#ifdef HAVE_GLOB char *v; +#endif ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG5); - assert_true(ret == 0); + assert_true(ret == 0); /* non-existing files should not error */ /* Test the variable presence */ +#ifdef HAVE_GLOB ret = ssh_options_get(session, SSH_OPTIONS_PROXYCOMMAND, &v); assert_true(ret == 0); @@ -140,6 +143,7 @@ static void torture_config_glob(void **state) { assert_string_equal(v, ID_FILE); ssh_string_free_char(v); +#endif /* HAVE_GLOB */ } int torture_run_tests(void) { |