[asterisk-commits] rizzo: trunk r45351 - /trunk/main/manager.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Oct 17 11:08:51 MST 2006
Author: rizzo
Date: Tue Oct 17 13:08:51 2006
New Revision: 45351
URL: http://svn.digium.com/view/asterisk?rev=45351&view=rev
Log:
simplify authority_to_str() using ast_build_string()
Modified:
trunk/main/manager.c
Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?rev=45351&r1=45350&r2=45351&view=diff
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Tue Oct 17 13:08:51 2006
@@ -199,24 +199,21 @@
static struct manager_action *first_action = NULL;
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)
{
- int running_total = 0, i;
-
- memset(res, 0, reslen);
+ int i, len = reslen;
+ char *dst = res, *sep = "";
+
+ res[0] = '\0';
for (i = 0; i < (sizeof(perms) / sizeof(perms[0])) - 1; i++) {
if (authority & perms[i].num) {
- if (*res) {
- strncat(res, ",", (reslen > running_total) ? reslen - running_total : 0);
- 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))
+ ast_build_string(&dst, &len, "%s%s", sep, perms[i].label);
+ sep = ",";
+ }
+ }
+
+ if (ast_strlen_zero(res)) /* replace empty string with something sensible */
ast_copy_string(res, "<none>", reslen);
return res;
@@ -554,8 +551,7 @@
}
-/*! \brief CLI command
- Should change to "manager show commands" */
+/*! \brief CLI command manager list commands */
static int handle_showmancmds(int fd, int argc, char *argv[])
{
struct manager_action *cur;
@@ -573,8 +569,7 @@
return RESULT_SUCCESS;
}
-/*! \brief CLI command show manager connected */
-/* Should change to "manager show connected" */
+/*! \brief CLI command manager list connected */
static int handle_showmanconn(int fd, int argc, char *argv[])
{
struct mansession *s;
More information about the asterisk-commits
mailing list