Updated cli_kill_session
This commit is contained in:
parent
407b4703b3
commit
87e49ca37a
1 changed files with 13 additions and 20 deletions
|
|
@ -638,7 +638,7 @@ cli_del(clixon_handle h,
|
||||||
/*! Set debug level on CLI client (not backend daemon)
|
/*! Set debug level on CLI client (not backend daemon)
|
||||||
*
|
*
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] cvv If variable "level" exists, its integer value is used
|
* @param[in] cvv If variable "level" exists, its integer value is used
|
||||||
* @param[in] arg Else use the integer value of argument
|
* @param[in] arg Else use the integer value of argument
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
|
|
@ -647,8 +647,8 @@ cli_del(clixon_handle h,
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
cli_debug_cli(clixon_handle h,
|
cli_debug_cli(clixon_handle h,
|
||||||
cvec *cvv,
|
cvec *cvv,
|
||||||
cvec *argv)
|
cvec *argv)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cg_var *cv;
|
cg_var *cv;
|
||||||
|
|
@ -1574,11 +1574,11 @@ cli_unlock(clixon_handle h,
|
||||||
*
|
*
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] cvv Not used
|
* @param[in] cvv Not used
|
||||||
* @param[in] arg <session-id>
|
* @param[in] arg variabel w session nr
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
* @code
|
* @code
|
||||||
* lock("comment"), cli_kill_session(54);
|
* <sessid:uint32> lock("comment"), cli_kill_session("sessid");
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
|
|
@ -1587,29 +1587,22 @@ cli_kill_session(clixon_handle h,
|
||||||
cvec *argv)
|
cvec *argv)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
char *str;
|
char *var;
|
||||||
uint32_t session_id;
|
uint32_t session_id;
|
||||||
int ret;
|
cg_var *cv;
|
||||||
char *reason = NULL;
|
|
||||||
|
|
||||||
if (cvec_len(argv) != 1){
|
if (cvec_len(argv) != 1){
|
||||||
clixon_err(OE_PLUGIN, EINVAL, "Requires arguments: <session-id>");
|
clixon_err(OE_PLUGIN, EINVAL, "Requires arguments: varname");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((str = cv_string_get(cvec_i(argv, 0))) != NULL){
|
if ((var = cv_string_get(cvec_i(argv, 0))) != NULL){
|
||||||
if ((ret = parse_uint32(str, &session_id, &reason)) < 0)
|
if ((cv = cvec_find_var(cvv, var)) != NULL)
|
||||||
goto done;
|
if ((session_id = cv_uint32_get(cv)) != 0)
|
||||||
if (ret == 0){
|
if (clicon_rpc_kill_session(h, session_id) < 0)
|
||||||
cligen_output(stderr, "%s\n", reason);
|
goto done;
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
else if ((ret = clicon_rpc_kill_session(h, session_id)) < 0)
|
|
||||||
goto done;
|
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
if (reason)
|
|
||||||
free(reason);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue