mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 20:56:39 +00:00
simplify authority_to_str() using ast_build_string()
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45351 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -199,24 +199,21 @@ static AST_LIST_HEAD_STATIC(users, ast_manager_user);
|
|||||||
static struct manager_action *first_action = NULL;
|
static struct manager_action *first_action = NULL;
|
||||||
AST_MUTEX_DEFINE_STATIC(actionlock);
|
AST_MUTEX_DEFINE_STATIC(actionlock);
|
||||||
|
|
||||||
/*! \brief Convert authority code to string with serveral options */
|
/*! \brief Convert authority code to a list of options */
|
||||||
static char *authority_to_str(int authority, char *res, int reslen)
|
static char *authority_to_str(int authority, char *res, int reslen)
|
||||||
{
|
{
|
||||||
int running_total = 0, i;
|
int i, len = reslen;
|
||||||
|
char *dst = res, *sep = "";
|
||||||
|
|
||||||
memset(res, 0, reslen);
|
res[0] = '\0';
|
||||||
for (i = 0; i < (sizeof(perms) / sizeof(perms[0])) - 1; i++) {
|
for (i = 0; i < (sizeof(perms) / sizeof(perms[0])) - 1; i++) {
|
||||||
if (authority & perms[i].num) {
|
if (authority & perms[i].num) {
|
||||||
if (*res) {
|
ast_build_string(&dst, &len, "%s%s", sep, perms[i].label);
|
||||||
strncat(res, ",", (reslen > running_total) ? reslen - running_total : 0);
|
sep = ",";
|
||||||
running_total++;
|
|
||||||
}
|
|
||||||
strncat(res, perms[i].label, (reslen > running_total) ? reslen - running_total : 0);
|
|
||||||
running_total += strlen(perms[i].label);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ast_strlen_zero(res))
|
if (ast_strlen_zero(res)) /* replace empty string with something sensible */
|
||||||
ast_copy_string(res, "<none>", reslen);
|
ast_copy_string(res, "<none>", reslen);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -554,8 +551,7 @@ static int handle_showmanagers(int fd, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief CLI command
|
/*! \brief CLI command manager list commands */
|
||||||
Should change to "manager show commands" */
|
|
||||||
static int handle_showmancmds(int fd, int argc, char *argv[])
|
static int handle_showmancmds(int fd, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct manager_action *cur;
|
struct manager_action *cur;
|
||||||
@@ -573,8 +569,7 @@ static int handle_showmancmds(int fd, int argc, char *argv[])
|
|||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief CLI command show manager connected */
|
/*! \brief CLI command manager list connected */
|
||||||
/* Should change to "manager show connected" */
|
|
||||||
static int handle_showmanconn(int fd, int argc, char *argv[])
|
static int handle_showmanconn(int fd, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct mansession *s;
|
struct mansession *s;
|
||||||
|
Reference in New Issue
Block a user