C-style update: Unified comment, retvals in order, remove trailing spaces
Changed function name for `clicon_debug` functions
This commit is contained in:
parent
6e314dd96f
commit
62348fc9c7
204 changed files with 6047 additions and 4904 deletions
|
|
@ -69,6 +69,7 @@
|
|||
|
||||
|
||||
/*! HTTP headers done, if there is a message body coming next
|
||||
*
|
||||
* @param[in] req Fastcgi request handle
|
||||
* @retval body Handle for body handling (in fcgi same as req)
|
||||
*
|
||||
|
|
@ -86,9 +87,12 @@ restconf_reply_body_start(void *req0)
|
|||
}
|
||||
|
||||
/*! Add HTTP header field name and value to reply, fcgi specific
|
||||
*
|
||||
* @param[in] req Fastcgi request handle
|
||||
* @param[in] name HTTP header field name
|
||||
* @param[in] vfmt HTTP header field value format string w variable parameter
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @see eg RFC 7230
|
||||
*/
|
||||
int
|
||||
|
|
@ -102,7 +106,7 @@ restconf_reply_header(void *req0,
|
|||
size_t vlen;
|
||||
char *value = NULL;
|
||||
va_list ap;
|
||||
|
||||
|
||||
if (req == NULL || name == NULL || vfmt == NULL){
|
||||
clicon_err(OE_CFG, EINVAL, "req, name or value is NULL");
|
||||
return -1;
|
||||
|
|
@ -116,14 +120,14 @@ restconf_reply_header(void *req0,
|
|||
goto done;
|
||||
}
|
||||
/* second round: compute actual value */
|
||||
va_start(ap, vfmt);
|
||||
va_start(ap, vfmt);
|
||||
if (vsnprintf(value, vlen+1, vfmt, ap) < 0){
|
||||
clicon_err(OE_UNIX, errno, "vsnprintf");
|
||||
va_end(ap);
|
||||
goto done;
|
||||
}
|
||||
va_end(ap);
|
||||
FCGX_FPrintF(req->out, "%s: %s\r\n", name, value);
|
||||
FCGX_FPrintF(req->out, "%s: %s\r\n", name, value);
|
||||
retval = 0;
|
||||
done:
|
||||
if (value)
|
||||
|
|
@ -132,9 +136,12 @@ restconf_reply_header(void *req0,
|
|||
}
|
||||
|
||||
/*! Add HTTP message body to reply, fcgi specific
|
||||
*
|
||||
* @param[in] req Fastcgi request handle
|
||||
* @param[in,out] content_len This is for Content-Length header
|
||||
* @param[in] bfmt HTTP message body format string w variable parameter
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @see eg RFC 7230
|
||||
*/
|
||||
int
|
||||
|
|
@ -163,14 +170,14 @@ restconf_reply_body_add(void *req0,
|
|||
goto done;
|
||||
}
|
||||
/* second round: compute actual body */
|
||||
va_start(ap, bfmt);
|
||||
va_start(ap, bfmt);
|
||||
if (vsnprintf(body, blen+1, bfmt, ap) < 0){
|
||||
clicon_err(OE_UNIX, errno, "vsnprintf");
|
||||
va_end(ap);
|
||||
goto done;
|
||||
}
|
||||
va_end(ap);
|
||||
FCGX_FPrintF(req->out, "%s", body);
|
||||
FCGX_FPrintF(req->out, "%s", body);
|
||||
/* Increment in/out Content-Length parameter */
|
||||
if (content_len){
|
||||
sz = strlen(body);
|
||||
|
|
@ -184,12 +191,14 @@ restconf_reply_body_add(void *req0,
|
|||
}
|
||||
|
||||
/*! Send HTTP reply with potential message body
|
||||
* @param[in] req Fastcgi request handle
|
||||
* @param[in] code Status code
|
||||
* @param[in] cb Body as a cbuf if non-NULL. Note is consumed
|
||||
* @param[in] head Only send headers, dont send body.
|
||||
*
|
||||
*
|
||||
* Prerequisites: status code set, headers given, body if wanted set
|
||||
* @param[in] req Fastcgi request handle
|
||||
* @param[in] code Status code
|
||||
* @param[in] cb Body as a cbuf if non-NULL. Note is consumed
|
||||
* @param[in] head Only send headers, dont send body.
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
restconf_reply_send(void *req0,
|
||||
|
|
@ -222,6 +231,7 @@ restconf_reply_send(void *req0,
|
|||
}
|
||||
|
||||
/*! Get input data from http request, eg such as curl -X PUT http://... <indata>
|
||||
*
|
||||
* @param[in] req Fastcgi request handle
|
||||
* @retval indata
|
||||
* @retval NULL Error
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue