Created xmldb plugin api

This commit is contained in:
Olof hagsand 2017-04-09 22:53:48 +02:00
parent 4169bd8d30
commit f6b3e95100
39 changed files with 492 additions and 504 deletions

View file

@ -66,7 +66,6 @@
#include "clixon_file.h"
#include "clixon_yang.h"
#include "clixon_hash.h"
#include "clixon_chunk.h"
#include "clixon_options.h"
#include "clixon_yang_type.h"
#include "clixon_yang_parse.h"
@ -1382,20 +1381,21 @@ yang_parse_file(clicon_handle h,
* @retval 1 Match founbd, Most recent entry returned in fbuf
* @retval 0 No matching entry found
* @retval -1 Error
*/static int
*/
static int
yang_parse_find_match(clicon_handle h,
const char *yang_dir,
const char *module,
cbuf *fbuf)
{
int retval = -1;
struct dirent *dp;
struct dirent *dp = NULL;
int ndp;
cbuf *regex = NULL;
char *regexstr;
if ((regex = cbuf_new()) == NULL){
clicon_err(OE_YANG, errno, "%s: cbuf_new", __FUNCTION__);
clicon_err(OE_YANG, errno, "cbuf_new");
goto done;
}
cprintf(regex, "^%s.*(.yang)$", module);
@ -1403,8 +1403,7 @@ yang_parse_find_match(clicon_handle h,
if ((ndp = clicon_file_dirent(yang_dir,
&dp,
regexstr,
S_IFREG,
__FUNCTION__)) < 0)
S_IFREG)) < 0)
goto done;
/* Entries are sorted, last entry should be most recent date */
if (ndp != 0){
@ -1416,7 +1415,8 @@ yang_parse_find_match(clicon_handle h,
done:
if (regex)
cbuf_free(regex);
unchunk_group(__FUNCTION__);
if (dp)
free(dp);
return retval;
}