Restructured error,debug anf log API
Renamed functions clicon->clixon, replaced global variables w access functions Unified clicon_netconf_error with clixon_err()
This commit is contained in:
parent
261469be16
commit
24a4991ec8
199 changed files with 4668 additions and 4158 deletions
|
|
@ -78,10 +78,10 @@
|
|||
* @param[in] str Pointer to string containing HTTP/1
|
||||
* @param[in] filename Debug string identifying file or connection
|
||||
* @retval 0 Parse OK
|
||||
* @retval -1 Error with clicon_err called.
|
||||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
_http1_parse(clicon_handle h,
|
||||
_http1_parse(clixon_handle h,
|
||||
restconf_conn *rc,
|
||||
char *str,
|
||||
const char *filename)
|
||||
|
|
@ -109,11 +109,11 @@ _http1_parse(clicon_handle h,
|
|||
http1_scan_exit(&hy);
|
||||
if (ret != 0){
|
||||
if (filename)
|
||||
clicon_log(LOG_NOTICE, "HTTP1 error: on line %d in %s", hy.hy_linenum, filename);
|
||||
clixon_log(h, LOG_NOTICE, "HTTP1 error: on line %d in %s", hy.hy_linenum, filename);
|
||||
else
|
||||
clicon_log(LOG_NOTICE, "HTTP1 error: on line %d", hy.hy_linenum);
|
||||
if (clicon_errno == 0)
|
||||
clicon_err(OE_RESTCONF, 0, "HTTP1 parser error with no error code (should not happen)");
|
||||
clixon_log(h, LOG_NOTICE, "HTTP1 error: on line %d", hy.hy_linenum);
|
||||
if (clixon_err_category() == 0)
|
||||
clixon_err(OE_RESTCONF, 0, "HTTP1 parser error with no error code (should not happen)");
|
||||
goto done;
|
||||
}
|
||||
ok:
|
||||
|
|
@ -130,10 +130,10 @@ _http1_parse(clicon_handle h,
|
|||
* @param[in] f A file descriptor containing HTTP/1 (as ASCII characters)
|
||||
* @param[in] filename Debug string identifying file or connection
|
||||
* @retval 0 Parse OK
|
||||
* @retval -1 Error with clicon_err called.
|
||||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
clixon_http1_parse_file(clicon_handle h,
|
||||
clixon_http1_parse_file(clixon_handle h,
|
||||
restconf_conn *rc,
|
||||
FILE *f,
|
||||
const char *filename)
|
||||
|
|
@ -149,18 +149,18 @@ clixon_http1_parse_file(clicon_handle h,
|
|||
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s %s", __FUNCTION__, filename);
|
||||
if (f == NULL){
|
||||
clicon_err(OE_RESTCONF, EINVAL, "f is NULL");
|
||||
clixon_err(OE_RESTCONF, EINVAL, "f is NULL");
|
||||
goto done;
|
||||
}
|
||||
if ((buf = malloc(buflen)) == NULL){
|
||||
clicon_err(OE_XML, errno, "malloc");
|
||||
clixon_err(OE_XML, errno, "malloc");
|
||||
goto done;
|
||||
}
|
||||
memset(buf, 0, buflen);
|
||||
ptr = buf;
|
||||
while (1){
|
||||
if ((ret = fread(&ch, 1, 1, f)) < 0){
|
||||
clicon_err(OE_XML, errno, "read");
|
||||
clixon_err(OE_XML, errno, "read");
|
||||
break;
|
||||
}
|
||||
if (ret != 0){
|
||||
|
|
@ -175,7 +175,7 @@ clixon_http1_parse_file(clicon_handle h,
|
|||
oldbuflen = buflen;
|
||||
buflen *= 2;
|
||||
if ((buf = realloc(buf, buflen)) == NULL){
|
||||
clicon_err(OE_XML, errno, "realloc");
|
||||
clixon_err(OE_XML, errno, "realloc");
|
||||
goto done;
|
||||
}
|
||||
memset(buf+oldbuflen, 0, buflen-oldbuflen);
|
||||
|
|
@ -195,10 +195,10 @@ clixon_http1_parse_file(clicon_handle h,
|
|||
* @param[in] rc Restconf connection
|
||||
* @param[in] str HTTP/1 string
|
||||
* @retval 0 Parse OK
|
||||
* @retval -1 Error with clicon_err called.
|
||||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
clixon_http1_parse_string(clicon_handle h,
|
||||
clixon_http1_parse_string(clixon_handle h,
|
||||
restconf_conn *rc,
|
||||
char *str)
|
||||
{
|
||||
|
|
@ -213,12 +213,12 @@ clixon_http1_parse_string(clicon_handle h,
|
|||
* @param[in] buf HTTP/1 buffer
|
||||
* @param[in] n Length of buffer
|
||||
* @retval 0 Parse OK
|
||||
* @retval -1 Error with clicon_err called.
|
||||
* @retval -1 Error
|
||||
* @note Had preferred to do this without copying, OR
|
||||
* input flex with a non-null terminated string
|
||||
*/
|
||||
int
|
||||
clixon_http1_parse_buf(clicon_handle h,
|
||||
clixon_http1_parse_buf(clixon_handle h,
|
||||
restconf_conn *rc,
|
||||
char *buf,
|
||||
size_t n)
|
||||
|
|
@ -227,7 +227,7 @@ clixon_http1_parse_buf(clicon_handle h,
|
|||
int ret;
|
||||
|
||||
if ((str = malloc(n+1)) == NULL){
|
||||
clicon_err(OE_RESTCONF, errno, "malloc");
|
||||
clixon_err(OE_RESTCONF, errno, "malloc");
|
||||
return -1;
|
||||
}
|
||||
memcpy(str, buf, n);
|
||||
|
|
@ -250,7 +250,7 @@ clixon_http1_parse_buf(clicon_handle h,
|
|||
* runtime config option
|
||||
*/
|
||||
static int
|
||||
http1_upgrade_http2(clicon_handle h,
|
||||
http1_upgrade_http2(clixon_handle h,
|
||||
restconf_stream_data *sd)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -280,7 +280,7 @@ http1_upgrade_http2(clicon_handle h,
|
|||
sd->sd_upgrade2 = 1;
|
||||
if ((settings = restconf_param_get(h, "HTTP_HTTP2_Settings")) != NULL &&
|
||||
(sd->sd_settings2 = (uint8_t*)strdup(settings)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "strdup");
|
||||
clixon_err(OE_UNIX, errno, "strdup");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -332,7 +332,7 @@ restconf_http1_reply(restconf_conn *rc,
|
|||
/* Write a body */
|
||||
if (sd->sd_body){
|
||||
if (cbuf_append_buf(sd->sd_outp_buf, cbuf_get(sd->sd_body), cbuf_len(sd->sd_body)) < 0){
|
||||
clicon_err(OE_RESTCONF, errno, "cbuf_append_buf");
|
||||
clixon_err(OE_RESTCONF, errno, "cbuf_append_buf");
|
||||
goto done;
|
||||
}
|
||||
cbuf_free(sd->sd_body);
|
||||
|
|
@ -351,7 +351,7 @@ restconf_http1_reply(restconf_conn *rc,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
restconf_http1_path_root(clicon_handle h,
|
||||
restconf_http1_path_root(clixon_handle h,
|
||||
restconf_conn *rc)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -368,7 +368,7 @@ restconf_http1_path_root(clicon_handle h,
|
|||
clixon_debug(CLIXON_DBG_DEFAULT, "------------");
|
||||
pretty = restconf_pretty_get(h);
|
||||
if ((sd = restconf_stream_find(rc, 0)) == NULL){
|
||||
clicon_err(OE_RESTCONF, EINVAL, "No stream_data");
|
||||
clixon_err(OE_RESTCONF, EINVAL, "No stream_data");
|
||||
goto done;
|
||||
}
|
||||
/* Sanity check */
|
||||
|
|
@ -484,7 +484,7 @@ restconf_http1_path_root(clicon_handle h,
|
|||
* @see rfc7231 Sec 5.1.1
|
||||
*/
|
||||
int
|
||||
http1_check_expect(clicon_handle h,
|
||||
http1_check_expect(clixon_handle h,
|
||||
restconf_conn *rc,
|
||||
restconf_stream_data *sd)
|
||||
{
|
||||
|
|
@ -518,7 +518,7 @@ http1_check_expect(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
http1_check_content_length(clicon_handle h,
|
||||
http1_check_content_length(clixon_handle h,
|
||||
restconf_stream_data *sd,
|
||||
int *status)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue