[asterisk-commits] seanbright: branch group/asterisk-cpp r168428 - in /team/group/asterisk-cpp: ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jan 10 21:54:49 CST 2009


Author: seanbright
Date: Sat Jan 10 21:54:49 2009
New Revision: 168428

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168428
Log:
cli.c compiles

Modified:
    team/group/asterisk-cpp/include/asterisk/cli.h
    team/group/asterisk-cpp/main/cli.c

Modified: team/group/asterisk-cpp/include/asterisk/cli.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/cli.h?view=diff&rev=168428&r1=168427&r2=168428
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/cli.h (original)
+++ team/group/asterisk-cpp/include/asterisk/cli.h Sat Jan 10 21:54:49 2009
@@ -30,7 +30,7 @@
 
 /* dont check permissions while passing this option as a 'uid'
  * to the cli_has_permissions() function. */
-#define CLI_NO_PERMS		-1
+#define CLI_NO_PERMS		((uid_t) -1)
 
 #define RESULT_SUCCESS		0
 #define RESULT_SHOWUSAGE	1
@@ -132,6 +132,15 @@
 
 /* argument for new-style CLI handler */
 struct ast_cli_args {
+    ast_cli_args() :
+        fd(0),
+        argc(0),
+        argv(NULL),
+        line(NULL),
+        word(NULL),
+        pos(0),
+        n(0) {}
+    ast_cli_args(int fd, int argc, char **argv) : fd(fd), argc(argc), argv(argv) {}
 	int fd;
 	int argc;
 	char **argv;

Modified: team/group/asterisk-cpp/main/cli.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/cli.c?view=diff&rev=168428&r1=168427&r2=168428
==============================================================================
--- team/group/asterisk-cpp/main/cli.c (original)
+++ team/group/asterisk-cpp/main/cli.c Sat Jan 10 21:54:49 2009
@@ -60,8 +60,8 @@
 
 /*! \brief list of users to apply restrictions. */
 struct usergroup_cli_perm {
-	int uid;				/*!< User ID (-1 disabled) */
-	int gid;				/*!< Group ID (-1 disabled) */
+	uid_t uid;				/*!< User ID (-1 disabled) */
+	gid_t gid;				/*!< Group ID (-1 disabled) */
 	struct cli_perm_head *perms;		/*!< List of permissions. */
 	AST_LIST_ENTRY(usergroup_cli_perm) list;/*!< List mechanics */
 };
@@ -80,7 +80,7 @@
  * \brief map a debug or verbose value to a filename
  */
 struct ast_debug_file {
-	unsigned int level;
+	int level;
 	AST_RWLIST_ENTRY(ast_debug_file) entry;
 	char filename[0];
 };
@@ -162,7 +162,7 @@
  *  \retval 1 if has permission
  *  \retval 0 if it is not allowed.
  */
-static int cli_has_permissions(int uid, int gid, const char *command)
+static int cli_has_permissions(uid_t uid, gid_t gid, const char *command)
 {
 	struct usergroup_cli_perm *user_perm;
 	struct cli_perm *perm;
@@ -366,9 +366,9 @@
 	int fd = a->fd;
 	int argc = a->argc;
 	char **argv = a->argv;
-	char *argv3 = a->argv ? S_OR(a->argv[3], "") : "";
+	const char *argv3 = a->argv ? S_OR(a->argv[3], "") : "";
 	int *dst;
-	char *what;
+	const char *what;
 	struct debug_file_list *dfl;
 	struct ast_debug_file *adf;
 	char *fn;
@@ -387,7 +387,7 @@
 
 	case CLI_GENERATE:
 		if (a->pos == 3 || (a->pos == 4 && !strcasecmp(a->argv[3], "atleast"))) {
-			char *pos = a->pos == 3 ? argv3 : S_OR(a->argv[4], "");
+			const char *pos = a->pos == 3 ? argv3 : S_OR(a->argv[4], "");
 			int numbermatch = (ast_strlen_zero(pos) || strchr("123456789", pos[0])) ? 0 : 21;
 			if (a->n < 21 && numbermatch == 0) {
 				return complete_number(pos, 0, 0x7fffffff, a->n);
@@ -470,7 +470,7 @@
 				AST_RWLIST_UNLOCK(dfl);
 				return CLI_SUCCESS;
 			}
-		} else if (!(adf = ast_calloc(1, sizeof(*adf) + strlen(fn) + 1))) {
+		} else if (!(adf = (struct ast_debug_file *) ast_calloc(1, sizeof(*adf) + strlen(fn) + 1))) {
 			AST_RWLIST_UNLOCK(dfl);
 			return CLI_FAILURE;
 		}
@@ -533,7 +533,7 @@
 {
 	/* "module unload mod_1 [mod_2 .. mod_N]" */
 	int x;
-	int force = AST_FORCE_SOFT;
+	ast_module_unload_mode force = AST_FORCE_SOFT;
 	char *s;
 
 	switch (cmd) {
@@ -685,7 +685,7 @@
 
 static char *handle_modlist(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	char *like;
+	const char *like;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -995,7 +995,8 @@
 {
 	struct passwd *pw = NULL;
 	struct group *gr;
-	int gid = -1, uid = -1;
+    uid_t uid = -1;
+	gid_t gid = -1;
 	char command[AST_MAX_ARGS] = "";
 	struct ast_cli_entry *ce = NULL;
 	int found = 0;
@@ -1090,7 +1091,7 @@
 
 	if (a->argc != 4)
 		return CLI_SHOWUSAGE;
-	if (!(buf = ast_malloc(buflen)))
+	if (!(buf = (char *) ast_malloc(buflen)))
 		return CLI_FAILURE;
 	buf[len] = '\0';
 	matches = ast_cli_completion_matches(a->argv[2], a->argv[3]);
@@ -1100,7 +1101,7 @@
 			if (len + matchlen >= buflen) {
 				buflen += matchlen * 3;
 				obuf = buf;
-				if (!(buf = ast_realloc(obuf, buflen))) 
+				if (!(buf = (char *) ast_realloc(obuf, buflen))) 
 					/* Memory allocation failure...  Just free old buffer and be done */
 					ast_free(obuf);
 			}
@@ -1246,7 +1247,7 @@
 		/* pretend we have an extra "off" at the end. We can do this as the array
 		 * is NULL terminated so we overwrite that entry.
 		 */
-		a->argv[e->args+1] = "off";
+		a->argv[e->args+1] = (char *) "off";
 		a->argc++;
 	}
 	res = handle_core_set_debug_channel(e, cmd, a);
@@ -1613,13 +1614,13 @@
 
 		if (!user_group) {
 			/* alloc space for the new user config. */
-			user_group = ast_calloc(1, sizeof(*user_group));
+			user_group = (struct usergroup_cli_perm *) ast_calloc(1, sizeof(*user_group));
 			if (!user_group) {
 				continue;
 			}
 			user_group->uid = (pw ? pw->pw_uid : -1);
 			user_group->gid = (gr ? gr->gr_gid : -1);
-			user_group->perms = ast_calloc(1, sizeof(*user_group->perms));
+			user_group->perms = (struct cli_perm_head *) ast_calloc(1, sizeof(*user_group->perms));
 			if (!user_group->perms) {
 				ast_free(user_group);
 				continue;
@@ -1632,13 +1633,13 @@
 				continue;
 			}
 			if (!strcasecmp(v->name, "permit")) {
-				perm = ast_calloc(1, sizeof(*perm));
+				perm = (struct cli_perm *) ast_calloc(1, sizeof(*perm));
 				if (perm) {
 					perm->permit = 1;
 					perm->command = ast_strdup(v->value);
 				}
 			} else if (!strcasecmp(v->name, "deny")) {
-				perm = ast_calloc(1, sizeof(*perm));
+				perm = (struct cli_perm *) ast_calloc(1, sizeof(*perm));
 				if (perm) {
 					perm->permit = 0;
 					perm->command = ast_strdup(v->value);
@@ -1713,7 +1714,7 @@
 static char *is_prefix(const char *word, const char *token,
 	int pos, int *actual)
 {
-	int lw;
+	size_t lw;
 	char *s, *t1;
 
 	*actual = 0;
@@ -1837,7 +1838,7 @@
 			/* this is a new-style entry. Reset fields and free memory. */
 			char *cmda = (char *) e->cmda;
 			memset(cmda, '\0', sizeof(e->cmda));
-			ast_free(e->command);
+			ast_free((char *) e->command);
 			e->command = NULL;
 			e->usage = NULL;
 		}
@@ -1858,7 +1859,8 @@
 	e->handler(e, CLI_INIT, &a);
 	/* XXX check that usage and command are filled up */
 	s = ast_skip_blanks(e->command);
-	s = e->command = ast_strdup(s);
+	e->command = (const char *) ast_strdup(s);
+    s = (char *) e->command;
 	for (i=0; !ast_strlen_zero(s) && i < AST_MAX_CMD_LEN-1; i++) {
 		*dst++ = s;	/* store string */
 		s = ast_skip_nonblanks(s);
@@ -2101,14 +2103,14 @@
 {
 	char **match_list = NULL, *retstr, *prevstr;
 	size_t match_list_len, max_equal, which, i;
-	int matches = 0;
+	size_t matches = 0;
 
 	/* leave entry 0 free for the longest common substring */
 	match_list_len = 1;
 	while ((retstr = ast_cli_generator(text, word, matches)) != NULL) {
 		if (matches + 1 >= match_list_len) {
 			match_list_len <<= 1;
-			if (!(match_list = ast_realloc(match_list, match_list_len * sizeof(*match_list))))
+			if (!(match_list = (char **) ast_realloc(match_list, match_list_len * sizeof(*match_list))))
 				return NULL;
 		}
 		match_list[++matches] = retstr;
@@ -2128,7 +2130,7 @@
 		max_equal = i;
 	}
 
-	if (!(retstr = ast_malloc(max_equal + 1)))
+	if (!(retstr = (char *) ast_malloc(max_equal + 1)))
 		return NULL;
 	
 	ast_copy_string(retstr, match_list[1], max_equal + 1);
@@ -2136,7 +2138,7 @@
 
 	/* ensure that the array is NULL terminated */
 	if (matches + 1 >= match_list_len) {
-		if (!(match_list = ast_realloc(match_list, (match_list_len + 1) * sizeof(*match_list))))
+		if (!(match_list = (char **) ast_realloc(match_list, (match_list_len + 1) * sizeof(*match_list))))
 			return NULL;
 	}
 	match_list[matches + 1] = NULL;
@@ -2223,12 +2225,15 @@
 			 * Run the generator if one is available. In any case we are done.
 			 */
 			if (e->handler) {	/* new style command */
-				struct ast_cli_args a = {
-					.line = matchstr, .word = word,
-					.pos = argindex,
-					.n = state - matchnum,
-					.argv = argv,
-					.argc = x};
+				struct ast_cli_args a;
+
+                a.line = matchstr;
+                a.word = word;
+                a.pos = argindex;
+                a.n = state - matchnum;
+                a.argv = argv;
+                a.argc = x;
+
 				ret = e->handler(e, CLI_GENERATE, &a);
 			}
 			if (ret)
@@ -2254,8 +2259,11 @@
 	char *duplicate = parse_args(s, &x, args + 1, AST_MAX_ARGS, NULL);
 	char tmp[AST_MAX_ARGS + 1];
 	char *retval = NULL;
-	struct ast_cli_args a = {
-		.fd = fd, .argc = x, .argv = args+1 };
+	struct ast_cli_args a;
+
+    a.fd = fd;
+    a.argc = x;
+    a.argv = args + 1;
 
 	if (duplicate == NULL)
 		return -1;
@@ -2304,9 +2312,9 @@
 int ast_cli_command_multiple_full(int uid, int gid, int fd, size_t size, const char *s)
 {
 	char cmd[512];
-	int x, y = 0, count = 0;
-
-	for (x = 0; x < size; x++) {
+	int y = 0, count = 0;
+
+	for (size_t x = 0; x < size; x++) {
 		cmd[y] = s[x];
 		y++;
 		if (s[x] == '\0') {




More information about the asterisk-commits mailing list