mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
config: Add CMake check for glob()
This commit is contained in:
committed by
Andreas Schneider
parent
99c5160cb5
commit
b8e301ade3
@@ -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)
|
||||
|
||||
@@ -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). */
|
||||
|
||||
10
src/config.c
10
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: {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user