moved detect_endtag to clixon_proto
This commit is contained in:
parent
7880b5d498
commit
05edace630
5 changed files with 67 additions and 43 deletions
|
|
@ -147,30 +147,6 @@ add_error_postamble(cbuf *xf)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*! Look for a text pattern in an input string, one char at a time
|
||||
* @param[in] tag What to look for
|
||||
* @param[in] ch New input character
|
||||
* @param[in,out] state A state integer holding how far we have parsed.
|
||||
* @retval 0 No, we havent detected end tag
|
||||
* @retval 1 Yes, we have detected end tag!
|
||||
* XXX: move to clicon_xml?
|
||||
*/
|
||||
int
|
||||
detect_endtag(char *tag, char ch, int *state)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (tag[*state] == ch){
|
||||
(*state)++;
|
||||
if (*state == strlen(tag)){
|
||||
*state = 0;
|
||||
retval = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
*state = 0;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*! Get "target" attribute, return actual database given candidate or running
|
||||
* Caller must do error handling
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ extern int cc_closed;
|
|||
int add_preamble(cbuf *xf);
|
||||
int add_postamble(cbuf *xf);
|
||||
int add_error_preamble(cbuf *xf, char *reason);
|
||||
int detect_endtag(char *tag, char ch, int *state);
|
||||
char *netconf_get_target(cxobj *xn, char *path);
|
||||
int add_error_postamble(cbuf *xf);
|
||||
int netconf_output(int s, cbuf *xf, char *msg);
|
||||
|
|
|
|||
|
|
@ -175,20 +175,18 @@ static int
|
|||
netconf_input_cb(int s,
|
||||
void *arg)
|
||||
{
|
||||
int retval = -1;
|
||||
clicon_handle h = arg;
|
||||
unsigned char buf[BUFSIZ];
|
||||
int i;
|
||||
int len;
|
||||
// static cbuf *cb; /* XXX: should use ce state? */
|
||||
cbuf *cb=NULL; /* XXX: should use ce state? */
|
||||
cbuf *cb=NULL;
|
||||
int xml_state = 0;
|
||||
int retval = -1;
|
||||
|
||||
if (cb == NULL)
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "%s: cbuf_new", __FUNCTION__);
|
||||
return retval;
|
||||
}
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "%s: cbuf_new", __FUNCTION__);
|
||||
return retval;
|
||||
}
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if ((len = read(s, buf, sizeof(buf))) < 0){
|
||||
if (errno == ECONNRESET)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue