* Fixed ["aux" folder issue with Windows. #198](https://github.com/clicon/clixon/issues/198)

* Updated config scripts
* removed unused expand_dir util cli function
* Fixed again [making cli_show_options's output more human readable #199](https://github.com/clicon/clixon/issues/199)
This commit is contained in:
Olof hagsand 2021-04-07 09:41:49 +02:00
parent 7412bb7b3d
commit 692dc12c03
8 changed files with 19 additions and 134 deletions

View file

@ -85,6 +85,7 @@ Developers may need to change their code
### Corrected Bugs ### Corrected Bugs
* Fixed ["aux" folder issue with Windows. #198](https://github.com/clicon/clixon/issues/198)
* Fixed [changing interface name not support with openconfig module #195](https://github.com/clicon/clixon/issues/195) * Fixed [changing interface name not support with openconfig module #195](https://github.com/clicon/clixon/issues/195)
* Fixed [making cli_show_options's output more human readable #199](https://github.com/clicon/clixon/issues/199) * Fixed [making cli_show_options's output more human readable #199](https://github.com/clicon/clixon/issues/199)
* Fixed Yang parsing of comments in (extension) unknown statements, to allow multiple white space * Fixed Yang parsing of comments in (extension) unknown statements, to allow multiple white space

View file

@ -359,125 +359,6 @@ expand_dbvar(void *h,
return retval; return retval;
} }
/*! List files in a directory
*/
int
expand_dir(char *dir,
int *nr,
char ***commands,
mode_t flags,
int detail)
{
DIR *dirp;
struct dirent *dp;
struct stat st;
char *str;
char *cmd;
int len;
int retval = -1;
struct passwd *pw;
char filename[MAXPATHLEN];
if ((dirp = opendir(dir)) == 0){
fprintf(stderr, "expand_dir: opendir(%s) %s\n",
dir, strerror(errno));
return -1;
}
*nr = 0;
while ((dp = readdir(dirp)) != NULL) {
if (
#if 0
strcmp(dp->d_name, ".") != 0 &&
strcmp(dp->d_name, "..") != 0
#else
dp->d_name[0] != '.'
#endif
) {
snprintf(filename, MAXPATHLEN-1, "%s/%s", dir, dp->d_name);
if (lstat(filename, &st) == 0){
if ((st.st_mode & flags) == 0)
continue;
#if EXPAND_RECURSIVE
if (S_ISDIR(st.st_mode)) {
int nrsav = *nr;
if(expand_dir(filename, nr, commands, detail) < 0)
goto quit;
while(nrsav < *nr) {
len = strlen(dp->d_name) + strlen((*commands)[nrsav]) + 2;
if((str = malloc(len)) == NULL) {
fprintf(stderr, "expand_dir: malloc: %s\n",
strerror(errno));
goto quit;
}
snprintf(str, len-1, "%s/%s",
dp->d_name, (*commands)[nrsav]);
free((*commands)[nrsav]);
(*commands)[nrsav] = str;
nrsav++;
}
continue;
}
#endif
if ((cmd = strdup(dp->d_name)) == NULL) {
fprintf(stderr, "expand_dir: strdup: %s\n",
strerror(errno));
goto quit;
}
#ifndef __APPLE__
if (0 &&detail){
if ((pw = getpwuid(st.st_uid)) == NULL){
fprintf(stderr, "expand_dir: getpwuid(%d): %s\n",
st.st_uid, strerror(errno));
goto quit;
}
len = strlen(cmd) +
strlen(pw->pw_name) +
#ifdef __FreeBSD__
strlen(ctime(&st.st_mtimespec.tv_sec)) +
#else
strlen(ctime(&st.st_mtim.tv_sec)) +
#endif
strlen("{ by }") + 1 /* \0 */;
if ((str=realloc(cmd, strlen(cmd)+len)) == NULL) {
fprintf(stderr, "expand_dir: malloc: %s\n",
strerror(errno));
goto quit;
}
snprintf(str + strlen(dp->d_name),
len - strlen(dp->d_name),
"{%s by %s}",
#ifdef __FreeBSD__
ctime(&st.st_mtimespec.tv_sec),
#else
ctime(&st.st_mtim.tv_sec),
#endif
pw->pw_name
);
cmd = str;
}
#endif /* __APPLE__ */
if (((*commands) =
realloc(*commands, ((*nr)+1)*sizeof(char**))) == NULL){
perror("expand_dir: realloc");
goto quit;
}
(*commands)[(*nr)] = cmd;
(*nr)++;
if (*nr >= 128) /* Limit number of options */
break;
}
}
}
retval = 0;
quit:
closedir(dirp);
return retval;
}
/*! CLI callback show yang spec. If arg given matches yang argument string */ /*! CLI callback show yang spec. If arg given matches yang argument string */
int int
show_yang(clicon_handle h, show_yang(clicon_handle h,
@ -974,7 +855,7 @@ cli_show_options(clicon_handle h,
while ((x = xml_child_each(clicon_conf_xml(h), x, CX_ELMNT)) != NULL) { while ((x = xml_child_each(clicon_conf_xml(h), x, CX_ELMNT)) != NULL) {
if (strcmp(xml_name(x), "CLICON_YANG_DIR") != 0) if (strcmp(xml_name(x), "CLICON_YANG_DIR") != 0)
continue; continue;
fprintf(stdout, "%s: \"%s\"", xml_name(x), xml_body(x)); fprintf(stdout, "%s: \"%s\"\n", xml_name(x), xml_body(x));
} }
x = NULL; x = NULL;
while ((x = xml_child_each(clicon_conf_xml(h), x, CX_ELMNT)) != NULL) { while ((x = xml_child_each(clicon_conf_xml(h), x, CX_ELMNT)) != NULL) {

View file

@ -114,7 +114,6 @@ int cli_copy_config(clicon_handle h, cvec *cvv, cvec *argv);
int cli_help(clicon_handle h, cvec *vars, cvec *argv); int cli_help(clicon_handle h, cvec *vars, cvec *argv);
/* In cli_show.c */ /* In cli_show.c */
int expand_dir(char *dir, int *nr, char ***commands, mode_t flags, int detail);
int expand_dbvar(void *h, char *name, cvec *cvv, cvec *argv, int expand_dbvar(void *h, char *name, cvec *cvv, cvec *argv,
cvec *commands, cvec *helptexts); cvec *commands, cvec *helptexts);

View file

@ -2,7 +2,7 @@
# Attempt to guess a canonical system name. # Attempt to guess a canonical system name.
# Copyright 1992-2021 Free Software Foundation, Inc. # Copyright 1992-2021 Free Software Foundation, Inc.
timestamp='2021-01-01' timestamp='2021-01-25'
# This file is free software; you can redistribute it and/or modify it # This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by # under the terms of the GNU General Public License as published by
@ -188,10 +188,9 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# #
# Note: NetBSD doesn't particularly care about the vendor # Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown". # portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=$( (uname -p 2>/dev/null || \ UNAME_MACHINE_ARCH=$( (uname -p 2>/dev/null || \
"/sbin/$sysctl" 2>/dev/null || \ /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
"/usr/sbin/$sysctl" 2>/dev/null || \ /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
echo unknown)) echo unknown))
case "$UNAME_MACHINE_ARCH" in case "$UNAME_MACHINE_ARCH" in
aarch64eb) machine=aarch64_be-unknown ;; aarch64eb) machine=aarch64_be-unknown ;;
@ -1483,8 +1482,8 @@ EOF
i*86:rdos:*:*) i*86:rdos:*:*)
echo "$UNAME_MACHINE"-pc-rdos echo "$UNAME_MACHINE"-pc-rdos
exit ;; exit ;;
i*86:AROS:*:*) *:AROS:*:*)
echo "$UNAME_MACHINE"-pc-aros echo "$UNAME_MACHINE"-unknown-aros
exit ;; exit ;;
x86_64:VMkernel:*:*) x86_64:VMkernel:*:*)
echo "$UNAME_MACHINE"-unknown-esx echo "$UNAME_MACHINE"-unknown-esx

View file

@ -2,7 +2,7 @@
# Configuration validation subroutine script. # Configuration validation subroutine script.
# Copyright 1992-2021 Free Software Foundation, Inc. # Copyright 1992-2021 Free Software Foundation, Inc.
timestamp='2021-01-07' timestamp='2021-03-10'
# This file is free software; you can redistribute it and/or modify it # This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by # under the terms of the GNU General Public License as published by
@ -1683,12 +1683,15 @@ fi
# Now, validate our (potentially fixed-up) OS. # Now, validate our (potentially fixed-up) OS.
case $os in case $os in
# Sometimes we do "kernel-abi", so those need to count as OSes. # Sometimes we do "kernel-libc", so those need to count as OSes.
musl* | newlib* | uclibc*) musl* | newlib* | uclibc*)
;; ;;
# Likewise for "kernel-libc" # Likewise for "kernel-abi"
eabi* | gnueabi*) eabi* | gnueabi*)
;; ;;
# VxWorks passes extra cpu info in the 4th filed.
simlinux | simwindows | spe)
;;
# Now accept the basic system types. # Now accept the basic system types.
# The portable systems comes first. # The portable systems comes first.
# Each alternative MUST end in a * to match a version number. # Each alternative MUST end in a * to match a version number.
@ -1709,7 +1712,7 @@ case $os in
| bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
| ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
| udi* | lites* | ieee* | go32* | aux* | hcos* \ | udi* | lites* | ieee* | go32* | aux* | hcos* \
| chorusrdb* | cegcc* | glidix* \ | chorusrdb* | cegcc* | glidix* | serenity* \
| cygwin* | msys* | pe* | moss* | proelf* | rtems* \ | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
| midipix* | mingw32* | mingw64* | mint* \ | midipix* | mingw32* | mingw64* | mint* \
| uxpv* | beos* | mpeix* | udk* | moxiebox* \ | uxpv* | beos* | mpeix* | udk* | moxiebox* \
@ -1751,6 +1754,8 @@ case $kernel-$os in
;; ;;
kfreebsd*-gnu* | kopensolaris*-gnu*) kfreebsd*-gnu* | kopensolaris*-gnu*)
;; ;;
vxworks-simlinux | vxworks-simwindows | vxworks-spe)
;;
nto-qnx*) nto-qnx*)
;; ;;
os2-emx) os2-emx)

4
configure vendored
View file

@ -2229,7 +2229,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# where autotool scripts are: install-sh, config.sub, config.guess # where autotool scripts are: install-sh, config.sub, config.guess
ac_aux_dir= ac_aux_dir=
for ac_dir in aux "$srcdir"/aux; do for ac_dir in config-aux "$srcdir"/config-aux; do
if test -f "$ac_dir/install-sh"; then if test -f "$ac_dir/install-sh"; then
ac_aux_dir=$ac_dir ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/install-sh -c" ac_install_sh="$ac_aux_dir/install-sh -c"
@ -2245,7 +2245,7 @@ for ac_dir in aux "$srcdir"/aux; do
fi fi
done done
if test -z "$ac_aux_dir"; then if test -z "$ac_aux_dir"; then
as_fn_error $? "cannot find install-sh, install.sh, or shtool in aux \"$srcdir\"/aux" "$LINENO" 5 as_fn_error $? "cannot find install-sh, install.sh, or shtool in config-aux \"$srcdir\"/config-aux" "$LINENO" 5
fi fi
# These three variables are undocumented and unsupported, # These three variables are undocumented and unsupported,

View file

@ -46,7 +46,7 @@ AC_INIT(lib/clixon/clixon.h.in)
: ${LINKAGE=dynamic} : ${LINKAGE=dynamic}
# where autotool scripts are: install-sh, config.sub, config.guess # where autotool scripts are: install-sh, config.sub, config.guess
AC_CONFIG_AUX_DIR(aux) AC_CONFIG_AUX_DIR(config-aux)
CLIXON_VERSION_MAJOR="5" CLIXON_VERSION_MAJOR="5"
CLIXON_VERSION_MINOR="1" CLIXON_VERSION_MINOR="1"