Removed curl dependency
This commit is contained in:
parent
f6b3e95100
commit
af334bb746
9 changed files with 121 additions and 89 deletions
|
|
@ -29,8 +29,10 @@
|
||||||
#
|
#
|
||||||
# ***** END LICENSE BLOCK *****
|
# ***** END LICENSE BLOCK *****
|
||||||
|
|
||||||
- Moved qdbm, chunk and xmldb to datastore keyvalue directories
|
- Removed curl dependency
|
||||||
Created xmldb plugin api
|
|
||||||
|
- Created xmldb plugin api
|
||||||
|
Moved qdbm, chunk and xmldb to datastore keyvalue directories
|
||||||
Removed all other clixon dependency on chunk code
|
Removed all other clixon dependency on chunk code
|
||||||
|
|
||||||
- cli_copy_config added as generic cli command
|
- cli_copy_config added as generic cli command
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <curl/curl.h>
|
|
||||||
|
|
||||||
/* cligen */
|
/* cligen */
|
||||||
#include <cligen/cligen.h>
|
#include <cligen/cligen.h>
|
||||||
|
|
@ -163,10 +162,8 @@ str2cvec(char *string,
|
||||||
*(snext++) = '\0';
|
*(snext++) = '\0';
|
||||||
if ((val = index(s, delim2)) != NULL){
|
if ((val = index(s, delim2)) != NULL){
|
||||||
*(val++) = '\0';
|
*(val++) = '\0';
|
||||||
if ((valu = curl_easy_unescape(NULL, val, 0, NULL)) == NULL){
|
if (percent_decode(val, &valu) < 0)
|
||||||
clicon_debug(1, "curl_easy_unescape %s", strerror(errno));
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
if ((cv = cvec_add(cvv, CGV_STRING)) == NULL){
|
if ((cv = cvec_add(cvv, CGV_STRING)) == NULL){
|
||||||
clicon_debug(1, "error cvec_add %s", strerror(errno));
|
clicon_debug(1, "error cvec_add %s", strerror(errno));
|
||||||
goto err;
|
goto err;
|
||||||
|
|
@ -175,7 +172,7 @@ str2cvec(char *string,
|
||||||
s++;
|
s++;
|
||||||
cv_name_set(cv, s);
|
cv_name_set(cv, s);
|
||||||
cv_string_set(cv, valu);
|
cv_string_set(cv, valu);
|
||||||
curl_free(valu);
|
free(valu); valu = NULL;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if (strlen(s)){
|
if (strlen(s)){
|
||||||
|
|
|
||||||
49
configure
vendored
49
configure
vendored
|
|
@ -4172,55 +4172,6 @@ _ACEOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# restconf uses libcurl (I think?)
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for curl_global_init in -lcurl" >&5
|
|
||||||
$as_echo_n "checking for curl_global_init in -lcurl... " >&6; }
|
|
||||||
if ${ac_cv_lib_curl_curl_global_init+:} false; then :
|
|
||||||
$as_echo_n "(cached) " >&6
|
|
||||||
else
|
|
||||||
ac_check_lib_save_LIBS=$LIBS
|
|
||||||
LIBS="-lcurl $LIBS"
|
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
||||||
/* end confdefs.h. */
|
|
||||||
|
|
||||||
/* Override any GCC internal prototype to avoid an error.
|
|
||||||
Use char because int might match the return type of a GCC
|
|
||||||
builtin and then its argument prototype would still apply. */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
#endif
|
|
||||||
char curl_global_init ();
|
|
||||||
int
|
|
||||||
main ()
|
|
||||||
{
|
|
||||||
return curl_global_init ();
|
|
||||||
;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_ACEOF
|
|
||||||
if ac_fn_c_try_link "$LINENO"; then :
|
|
||||||
ac_cv_lib_curl_curl_global_init=yes
|
|
||||||
else
|
|
||||||
ac_cv_lib_curl_curl_global_init=no
|
|
||||||
fi
|
|
||||||
rm -f core conftest.err conftest.$ac_objext \
|
|
||||||
conftest$ac_exeext conftest.$ac_ext
|
|
||||||
LIBS=$ac_check_lib_save_LIBS
|
|
||||||
fi
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curl_curl_global_init" >&5
|
|
||||||
$as_echo "$ac_cv_lib_curl_curl_global_init" >&6; }
|
|
||||||
if test "x$ac_cv_lib_curl_curl_global_init" = xyes; then :
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
|
||||||
#define HAVE_LIBCURL 1
|
|
||||||
_ACEOF
|
|
||||||
|
|
||||||
LIBS="-lcurl $LIBS"
|
|
||||||
|
|
||||||
else
|
|
||||||
as_fn_error $? "libcurl missing" "$LINENO" 5
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
for ac_func in inet_aton sigaction sigvec strlcpy strsep strndup alphasort versionsort strverscmp
|
for ac_func in inet_aton sigaction sigvec strlcpy strsep strndup alphasort versionsort strverscmp
|
||||||
do :
|
do :
|
||||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||||
|
|
|
||||||
|
|
@ -151,9 +151,6 @@ AC_CHECK_LIB(socket, socket)
|
||||||
AC_CHECK_LIB(nsl, xdr_char)
|
AC_CHECK_LIB(nsl, xdr_char)
|
||||||
AC_CHECK_LIB(dl, dlopen)
|
AC_CHECK_LIB(dl, dlopen)
|
||||||
|
|
||||||
# restconf uses libcurl (I think?)
|
|
||||||
AC_CHECK_LIB(curl, curl_global_init,, AC_MSG_ERROR([libcurl missing]))
|
|
||||||
|
|
||||||
AC_CHECK_FUNCS(inet_aton sigaction sigvec strlcpy strsep strndup alphasort versionsort strverscmp)
|
AC_CHECK_FUNCS(inet_aton sigaction sigvec strlcpy strsep strndup alphasort versionsort strverscmp)
|
||||||
|
|
||||||
# Lives in libfcgi-dev
|
# Lives in libfcgi-dev
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,6 @@
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <curl/curl.h>
|
|
||||||
|
|
||||||
/* cligen */
|
/* cligen */
|
||||||
#include <cligen/cligen.h>
|
#include <cligen/cligen.h>
|
||||||
|
|
@ -108,6 +107,7 @@
|
||||||
/* clicon */
|
/* clicon */
|
||||||
#include <clixon/clixon.h>
|
#include <clixon/clixon.h>
|
||||||
|
|
||||||
|
#include "clixon_chunk.h"
|
||||||
#include "clixon_qdb.h"
|
#include "clixon_qdb.h"
|
||||||
#include "clixon_keyvalue.h"
|
#include "clixon_keyvalue.h"
|
||||||
|
|
||||||
|
|
@ -200,16 +200,15 @@ append_listkeys(cbuf *ckey,
|
||||||
xml_name(xt), keyname);
|
xml_name(xt), keyname);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((bodyenc = curl_easy_escape(NULL, xml_body(xkey), 0)) == NULL){
|
if (percent_encode(xml_body(xkey), &bodyenc) < 0)
|
||||||
clicon_err(OE_UNIX, errno, "curl_easy_escape");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
if (i++)
|
if (i++)
|
||||||
cprintf(ckey, ",");
|
cprintf(ckey, ",");
|
||||||
else
|
else
|
||||||
cprintf(ckey, "=");
|
cprintf(ckey, "=");
|
||||||
cprintf(ckey, "%s", bodyenc);
|
cprintf(ckey, "%s", bodyenc);
|
||||||
curl_free(bodyenc); bodyenc = NULL;
|
free(bodyenc);
|
||||||
|
bodyenc = NULL;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
|
@ -362,17 +361,15 @@ get(char *dbname,
|
||||||
* If xml element is a leaf-list, then the next element is expected to
|
* If xml element is a leaf-list, then the next element is expected to
|
||||||
* be a value
|
* be a value
|
||||||
*/
|
*/
|
||||||
if ((argdec = curl_easy_unescape(NULL, restval, 0, NULL)) == NULL){
|
if (percent_decode(restval, &argdec) < 0)
|
||||||
clicon_err(OE_UNIX, errno, "curl_easy_escape");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
if ((xc = xml_find(x, name))==NULL ||
|
if ((xc = xml_find(x, name))==NULL ||
|
||||||
(xb = xml_find(xc, argdec))==NULL){
|
(xb = xml_find(xc, argdec))==NULL){
|
||||||
if ((xc = xml_new_spec(name, x, y)) == NULL)
|
if ((xc = xml_new_spec(name, x, y)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
/* Assume body is created at end of function */
|
/* Assume body is created at end of function */
|
||||||
}
|
}
|
||||||
curl_free(argdec);
|
free(argdec);
|
||||||
argdec = NULL;
|
argdec = NULL;
|
||||||
break;
|
break;
|
||||||
case Y_LIST:
|
case Y_LIST:
|
||||||
|
|
@ -409,12 +406,10 @@ get(char *dbname,
|
||||||
if (j>=nvalvec)
|
if (j>=nvalvec)
|
||||||
break;
|
break;
|
||||||
arg = valvec[j++];
|
arg = valvec[j++];
|
||||||
if ((argdec = curl_easy_unescape(NULL, arg, 0, NULL)) == NULL){
|
if (percent_decode(arg, &argdec) < 0)
|
||||||
clicon_err(OE_UNIX, errno, "curl_easy_escape");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
cprintf(cb, "[%s=%s]", cv_string_get(cvi), argdec);
|
cprintf(cb, "[%s=%s]", cv_string_get(cvi), argdec);
|
||||||
curl_free(argdec);
|
free(argdec);
|
||||||
argdec=NULL;
|
argdec=NULL;
|
||||||
}
|
}
|
||||||
if ((xc = xpath_first(x, cbuf_get(cb))) == NULL){
|
if ((xc = xpath_first(x, cbuf_get(cb))) == NULL){
|
||||||
|
|
@ -429,16 +424,15 @@ get(char *dbname,
|
||||||
break;
|
break;
|
||||||
arg = valvec[j++];
|
arg = valvec[j++];
|
||||||
keyname = cv_string_get(cvi);
|
keyname = cv_string_get(cvi);
|
||||||
if ((argdec = curl_easy_unescape(NULL, arg, 0, NULL)) == NULL){
|
if (percent_decode(arg, &argdec) < 0)
|
||||||
clicon_err(OE_UNIX, errno, "curl_easy_escape");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
if (create_keyvalues(xc,
|
if (create_keyvalues(xc,
|
||||||
ykey,
|
ykey,
|
||||||
argdec,
|
argdec,
|
||||||
keyname) < 0)
|
keyname) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
curl_free(argdec); argdec = NULL;
|
free(argdec);
|
||||||
|
argdec = NULL;
|
||||||
} /* while */
|
} /* while */
|
||||||
}
|
}
|
||||||
if (cb){
|
if (cb){
|
||||||
|
|
@ -768,10 +762,8 @@ put(char *dbname,
|
||||||
goto done;
|
goto done;
|
||||||
break;
|
break;
|
||||||
case Y_LEAF_LIST:
|
case Y_LEAF_LIST:
|
||||||
if ((bodyenc = curl_easy_escape(NULL, body, 0)) == NULL){
|
if (percent_encode(body, &bodyenc) < 0)
|
||||||
clicon_err(OE_UNIX, errno, "curl_easy_escape");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
cprintf(cbxk, "=%s", bodyenc);
|
cprintf(cbxk, "=%s", bodyenc);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -821,7 +813,7 @@ put(char *dbname,
|
||||||
if (cbxk)
|
if (cbxk)
|
||||||
cbuf_free(cbxk);
|
cbuf_free(cbxk);
|
||||||
if (bodyenc)
|
if (bodyenc)
|
||||||
curl_free(bodyenc);
|
free(bodyenc);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,6 @@
|
||||||
/* Define to 1 if you have the `crypt' library (-lcrypt). */
|
/* Define to 1 if you have the `crypt' library (-lcrypt). */
|
||||||
#undef HAVE_LIBCRYPT
|
#undef HAVE_LIBCRYPT
|
||||||
|
|
||||||
/* Define to 1 if you have the `curl' library (-lcurl). */
|
|
||||||
#undef HAVE_LIBCURL
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `dl' library (-ldl). */
|
/* Define to 1 if you have the `dl' library (-ldl). */
|
||||||
#undef HAVE_LIBDL
|
#undef HAVE_LIBDL
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,5 +59,7 @@ char *clicon_strjoin (int argc, char **argv, char *delim);
|
||||||
#ifndef HAVE_STRNDUP
|
#ifndef HAVE_STRNDUP
|
||||||
char *clicon_strndup (const char *, size_t);
|
char *clicon_strndup (const char *, size_t);
|
||||||
#endif /* ! HAVE_STRNDUP */
|
#endif /* ! HAVE_STRNDUP */
|
||||||
|
int percent_encode(char *str, char **escp);
|
||||||
|
int percent_decode(char *esc, char **str);
|
||||||
|
|
||||||
#endif /* _CLIXON_STRING_H_ */
|
#endif /* _CLIXON_STRING_H_ */
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,102 @@ clicon_strjoin(int argc,
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
unreserved(unsigned char in)
|
||||||
|
{
|
||||||
|
switch(in) {
|
||||||
|
case '0': case '1': case '2': case '3': case '4':
|
||||||
|
case '5': case '6': case '7': case '8': case '9':
|
||||||
|
case 'a': case 'b': case 'c': case 'd': case 'e':
|
||||||
|
case 'f': case 'g': case 'h': case 'i': case 'j':
|
||||||
|
case 'k': case 'l': case 'm': case 'n': case 'o':
|
||||||
|
case 'p': case 'q': case 'r': case 's': case 't':
|
||||||
|
case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
|
||||||
|
case 'A': case 'B': case 'C': case 'D': case 'E':
|
||||||
|
case 'F': case 'G': case 'H': case 'I': case 'J':
|
||||||
|
case 'K': case 'L': case 'M': case 'N': case 'O':
|
||||||
|
case 'P': case 'Q': case 'R': case 'S': case 'T':
|
||||||
|
case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
|
||||||
|
case '-': case '.': case '_': case '~':
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Percent encoding according to RFC 3896
|
||||||
|
* @param[out] esc Deallocate with free()
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
percent_encode(char *str,
|
||||||
|
char **escp)
|
||||||
|
{
|
||||||
|
int retval = -1;
|
||||||
|
char *esc = NULL;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
/* This is max */
|
||||||
|
if ((esc = malloc(strlen(str)*3+1)) == NULL){
|
||||||
|
clicon_err(OE_UNIX, errno, "malloc");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
j = 0;
|
||||||
|
for (i=0; i<strlen(str); i++){
|
||||||
|
if (unreserved(str[i]))
|
||||||
|
esc[j++] = str[i];
|
||||||
|
else{
|
||||||
|
snprintf(&esc[j], 4, "%%%02X", str[i]&0xff);
|
||||||
|
j += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*escp = esc;
|
||||||
|
retval = 0;
|
||||||
|
done:
|
||||||
|
if (retval < 0 && esc)
|
||||||
|
free(esc);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Percent decoding according to RFC 3896
|
||||||
|
* @param[out] str Deallocate with free()
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
percent_decode(char *esc,
|
||||||
|
char **strp)
|
||||||
|
{
|
||||||
|
int retval = -1;
|
||||||
|
char *str = NULL;
|
||||||
|
int i, j;
|
||||||
|
char hstr[3];
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
|
/* This is max */
|
||||||
|
if ((str = malloc(strlen(esc)+1)) == NULL){
|
||||||
|
clicon_err(OE_UNIX, errno, "malloc");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
j = 0;
|
||||||
|
for (i=0; i<strlen(esc); i++){
|
||||||
|
if (esc[i] == '%' && strlen(esc)-i > 2 &&
|
||||||
|
isxdigit(esc[i+1]) && isxdigit(esc[i+2])){
|
||||||
|
hstr[0] = esc[i+1];
|
||||||
|
hstr[1] = esc[i+2];
|
||||||
|
hstr[2] = 0;
|
||||||
|
str[j] = strtoul(hstr, &ptr, 16);
|
||||||
|
i += 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
str[j] = esc[i];
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
*strp = str;
|
||||||
|
retval = 0;
|
||||||
|
done:
|
||||||
|
if (retval < 0 && str)
|
||||||
|
free(str);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
/*! strndup() for systems without it, such as xBSD
|
/*! strndup() for systems without it, such as xBSD
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <curl/curl.h>
|
|
||||||
|
|
||||||
/* cligen */
|
/* cligen */
|
||||||
#include <cligen/cligen.h>
|
#include <cligen/cligen.h>
|
||||||
|
|
@ -77,6 +76,7 @@
|
||||||
#include "clixon_queue.h"
|
#include "clixon_queue.h"
|
||||||
#include "clixon_hash.h"
|
#include "clixon_hash.h"
|
||||||
#include "clixon_handle.h"
|
#include "clixon_handle.h"
|
||||||
|
#include "clixon_string.h"
|
||||||
#include "clixon_yang.h"
|
#include "clixon_yang.h"
|
||||||
#include "clixon_yang_type.h"
|
#include "clixon_yang_type.h"
|
||||||
#include "clixon_options.h"
|
#include "clixon_options.h"
|
||||||
|
|
@ -957,13 +957,11 @@ xmlkeyfmt2key(char *xkfmt,
|
||||||
clicon_err(OE_UNIX, errno, "strdup");
|
clicon_err(OE_UNIX, errno, "strdup");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((strenc = curl_easy_escape(NULL, str, 0)) == NULL){
|
if (percent_encode(str, &strenc) < 0)
|
||||||
clicon_err(OE_UNIX, errno, "curl_easy_escape");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
cprintf(cb, "%s", strenc);
|
cprintf(cb, "%s", strenc);
|
||||||
curl_free(strenc);
|
free(strenc); strenc = NULL;
|
||||||
free(str);
|
free(str); str = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (c == '%')
|
if (c == '%')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue