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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 12 17:33:30 CST 2009


Author: seanbright
Date: Mon Jan 12 17:33:30 2009
New Revision: 168525

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168525
Log:
res_agi.c compiles now

Modified:
    team/group/asterisk-cpp/include/asterisk/agi.h
    team/group/asterisk-cpp/include/asterisk/logger.h
    team/group/asterisk-cpp/include/asterisk/manager.h
    team/group/asterisk-cpp/include/asterisk/strings.h
    team/group/asterisk-cpp/res/res_agi.c

Modified: team/group/asterisk-cpp/include/asterisk/agi.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/agi.h?view=diff&rev=168525&r1=168524&r2=168525
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/agi.h (original)
+++ team/group/asterisk-cpp/include/asterisk/agi.h Mon Jan 12 17:33:30 2009
@@ -35,20 +35,20 @@
 } AGI;
 
 typedef struct agi_command {
-	char *cmda[AST_MAX_CMD_LEN];		/*!< Null terminated list of the words of the command */
+	const char * const cmda[AST_MAX_CMD_LEN];		/*!< Null terminated list of the words of the command */
 	/*! Handler for the command (channel, AGI state, # of arguments, argument list). 
 	    Returns RESULT_SHOWUSAGE for improper arguments */
 	int (*handler)(struct ast_channel *chan, AGI *agi, int argc, char *argv[]);
 	/*! Summary of the command (< 60 characters) */
-	char *summary;
+	const char *summary;
 	/*! Detailed usage information */
-	char *usage;
+	const char *usage;
 	/*! Does this application run dead */
 	int dead;
 	/*! AGI command syntax description */
-	char *syntax;
+	const char *syntax;
 	/*! See also content */
-	char *seealso;
+	const char *seealso;
 	/*! Where the documentation come from. */
 	enum ast_doc_src docsrc;
 	/*! Pointer to module that registered the agi command */
@@ -129,7 +129,7 @@
  * \return 0 for success, -1 for failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded
  *
  */
-AST_OPTIONAL_API_ATTR(int, format(printf, 3, 4), ast_agi_send, (int fd, struct ast_channel *chan, char *fmt, ...),
+AST_OPTIONAL_API_ATTR(int, format(printf, 3, 4), ast_agi_send, (int fd, struct ast_channel *chan, const char *fmt, ...),
 		      { return AST_OPTIONAL_API_UNAVAILABLE; });
 
 #endif /* _ASTERISK_AGI_H */

Modified: team/group/asterisk-cpp/include/asterisk/logger.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/logger.h?view=diff&rev=168525&r1=168524&r2=168525
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/logger.h (original)
+++ team/group/asterisk-cpp/include/asterisk/logger.h Mon Jan 12 17:33:30 2009
@@ -202,7 +202,7 @@
 		ast_log(AST_LOG_DEBUG, __VA_ARGS__); \
 } while (0)
 
-#define VERBOSITY_ATLEAST(level) (option_verbose >= (level) || (ast_opt_verb_file && ast_verbose_get_by_file(__FILE__) >= (level)))
+#define VERBOSITY_ATLEAST(level) (option_verbose >= (level) || (ast_opt_verb_file && (int) ast_verbose_get_by_file(__FILE__) >= (level)))
 
 #define ast_verb(level, ...) do { \
 	if (VERBOSITY_ATLEAST((level)) ) { \

Modified: team/group/asterisk-cpp/include/asterisk/manager.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/manager.h?view=diff&rev=168525&r1=168524&r2=168525
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/manager.h (original)
+++ team/group/asterisk-cpp/include/asterisk/manager.h Mon Jan 12 17:33:30 2009
@@ -150,7 +150,7 @@
 /*! \brief Unregister a registred manager command 
 	\param action Name of registred Action:
 */
-int ast_manager_unregister( char *action );
+int ast_manager_unregister(const char *action);
 
 /*! 
  * \brief Verify a session's read permissions against a permission mask.  

Modified: team/group/asterisk-cpp/include/asterisk/strings.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/strings.h?view=diff&rev=168525&r1=168524&r2=168525
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/strings.h (original)
+++ team/group/asterisk-cpp/include/asterisk/strings.h Mon Jan 12 17:33:30 2009
@@ -281,7 +281,7 @@
  * string.  It will also place a space in the result buffer in between each
  * string from 'w'.
 */
-void ast_join(char *s, size_t len, char * const w[]);
+void ast_join(char *s, size_t len, const char * const w[]);
 
 /*
   \brief Parse a time (integer) string.

Modified: team/group/asterisk-cpp/res/res_agi.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/res/res_agi.c?view=diff&rev=168525&r1=168524&r2=168525
==============================================================================
--- team/group/asterisk-cpp/res/res_agi.c (original)
+++ team/group/asterisk-cpp/res/res_agi.c Mon Jan 12 17:33:30 2009
@@ -304,17 +304,17 @@
 #define AGI_NANDFS_RETRY 3
 #define AGI_BUF_LEN 2048
 
-static char *app = "AGI";
-
-static char *eapp = "EAGI";
-
-static char *deadapp = "DeadAGI";
-
-static char *synopsis = "Executes an AGI compliant application";
-static char *esynopsis = "Executes an EAGI compliant application";
-static char *deadsynopsis = "Executes AGI on a hungup channel";
-
-static char *descrip =
+static const char *app = "AGI";
+
+static const char *eapp = "EAGI";
+
+static const char *deadapp = "DeadAGI";
+
+static const char *synopsis = "Executes an AGI compliant application";
+static const char *esynopsis = "Executes an EAGI compliant application";
+static const char *deadsynopsis = "Executes AGI on a hungup channel";
+
+static const char *descrip =
 "  [E|Dead]AGI(command,args): Executes an Asterisk Gateway Interface compliant\n"
 "program on a channel. AGI allows Asterisk to launch external programs written\n"
 "in any language to control a telephony channel, play audio, read DTMF digits,\n"
@@ -352,12 +352,12 @@
 	AGI_RESULT_HANGUP,
 };
 
-static agi_command *find_command(char *cmds[], int exact);
+static agi_command *find_command(const char * const cmds[], int exact);
 
 AST_THREADSTORAGE(agi_buf);
 #define AGI_BUF_INITSIZE 256
 
-int ast_agi_send(int fd, struct ast_channel *chan, char *fmt, ...)
+int ast_agi_send(int fd, struct ast_channel *chan, const char *fmt, ...)
 {
 	int res = 0;
 	va_list ap;
@@ -400,11 +400,13 @@
 	ast_free(cmd);
 }
 
+AST_LIST_HEAD(agi_cmd_list, agi_cmd);
+
 /* AGI datastore destructor */
 static void agi_destroy_commands_cb(void *data)
 {
 	struct agi_cmd *cmd;
-	AST_LIST_HEAD(, agi_cmd) *chan_cmds = data;
+	struct agi_cmd_list *chan_cmds = (struct agi_cmd_list *) data;
 	AST_LIST_LOCK(chan_cmds);
 	while ( (cmd = AST_LIST_REMOVE_HEAD(chan_cmds, entry)) ) {
 		free_agi_cmd(cmd);
@@ -415,10 +417,7 @@
 }
 
 /* channel datastore to keep the queue of AGI commands in the channel */
-static const struct ast_datastore_info agi_commands_datastore_info = {
-	.type = "AsyncAGI",
-	.destroy = agi_destroy_commands_cb
-};
+static const struct ast_datastore_info agi_commands_datastore_info("AsyncAGI", agi_destroy_commands_cb);
 
 static const char mandescr_asyncagi[] =
 "Description: Add an AGI command to the execute queue of the channel in Async AGI\n"
@@ -432,7 +431,7 @@
 {
 	struct ast_datastore *store;
 	struct agi_cmd *cmd;
-	AST_LIST_HEAD(, agi_cmd) *agi_commands;
+	struct agi_cmd_list *agi_commands;
 
 	ast_channel_lock(chan);
 	store = ast_channel_datastore_find(chan, &agi_commands_datastore_info, NULL);
@@ -441,7 +440,7 @@
 		ast_log(LOG_ERROR, "Hu? datastore disappeared at Async AGI on Channel %s!\n", chan->name);
 		return NULL;
 	}
-	agi_commands = store->data;
+	agi_commands = (struct agi_cmd_list *) store->data;
 	AST_LIST_LOCK(agi_commands);
 	cmd = AST_LIST_REMOVE_HEAD(agi_commands, entry);
 	AST_LIST_UNLOCK(agi_commands);
@@ -453,15 +452,15 @@
 {
 	struct ast_datastore *store;
 	struct agi_cmd *cmd;
-	AST_LIST_HEAD(, agi_cmd) *agi_commands;
+	struct agi_cmd_list *agi_commands;
 
 	store = ast_channel_datastore_find(chan, &agi_commands_datastore_info, NULL);
 	if (!store) {
 		ast_log(LOG_WARNING, "Channel %s is not at Async AGI.\n", chan->name);
 		return -1;
 	}
-	agi_commands = store->data;
-	cmd = ast_calloc(1, sizeof(*cmd));
+	agi_commands = (struct agi_cmd_list *) store->data;
+	cmd = (struct agi_cmd *) ast_calloc(1, sizeof(*cmd));
 	if (!cmd) {
 		return -1;
 	}
@@ -485,7 +484,7 @@
 static int add_to_agi(struct ast_channel *chan)
 {
 	struct ast_datastore *datastore;
-	AST_LIST_HEAD(, agi_cmd) *agi_cmds_list;
+	struct agi_cmd_list *agi_cmds_list;
 
 	/* check if already on AGI */
 	ast_channel_lock(chan);
@@ -503,7 +502,7 @@
 	if (!datastore) {
 		return -1;
 	}
-	agi_cmds_list = ast_calloc(1, sizeof(*agi_cmds_list));
+	agi_cmds_list = (struct agi_cmd_list *) ast_calloc(1, sizeof(*agi_cmds_list));
 	if (!agi_cmds_list) {
 		ast_log(LOG_ERROR, "Unable to allocate Async AGI commands list.\n");
 		ast_datastore_free(datastore);
@@ -598,7 +597,7 @@
 }
 
 static int agi_handle_command(struct ast_channel *chan, AGI *agi, char *buf, int dead);
-static void setup_env(struct ast_channel *chan, char *request, int fd, int enhanced, int argc, char *argv[]);
+static void setup_env(struct ast_channel *chan, const char *request, int fd, int enhanced, int argc, char *argv[]);
 static enum agi_result launch_asyncagi(struct ast_channel *chan, char *argv[], int *efd)
 {
 /* This buffer sizes might cause truncation if the AGI command writes more data
@@ -760,7 +759,7 @@
 {
 	int s, flags, res, port = AGI_PORT;
 	struct pollfd pfds[1];
-	char *host, *c, *script = "";
+	char *host, *c, *script = NULL;
 	struct sockaddr_in addr_in;
 	struct hostent *hp;
 	struct ast_hostent ahp;
@@ -780,25 +779,25 @@
 	}
 	if (efd) {
 		ast_log(LOG_WARNING, "AGI URI's don't support Enhanced AGI yet\n");
-		return -1;
+		return AGI_RESULT_FAILURE;
 	}
 	if (!(hp = ast_gethostbyname(host, &ahp))) {
 		ast_log(LOG_WARNING, "Unable to locate host '%s'\n", host);
-		return -1;
+		return AGI_RESULT_FAILURE;
 	}
 	if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
 		ast_log(LOG_WARNING, "Unable to create socket: %s\n", strerror(errno));
-		return -1;
+		return AGI_RESULT_FAILURE;
 	}
 	if ((flags = fcntl(s, F_GETFL)) < 0) {
 		ast_log(LOG_WARNING, "Fcntl(F_GETFL) failed: %s\n", strerror(errno));
 		close(s);
-		return -1;
+		return AGI_RESULT_FAILURE;
 	}
 	if (fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0) {
 		ast_log(LOG_WARNING, "Fnctl(F_SETFL) failed: %s\n", strerror(errno));
 		close(s);
-		return -1;
+		return AGI_RESULT_FAILURE;
 	}
 	memset(&addr_in, 0, sizeof(addr_in));
 	addr_in.sin_family = AF_INET;
@@ -958,7 +957,7 @@
 	return AGI_RESULT_SUCCESS;
 }
 
-static void setup_env(struct ast_channel *chan, char *request, int fd, int enhanced, int argc, char *argv[])
+static void setup_env(struct ast_channel *chan, const char *request, int fd, int enhanced, int argc, char *argv[])
 {
 	int count;
 
@@ -1127,7 +1126,7 @@
 static int handle_controlstreamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
 {
 	int res = 0, skipms = 3000;
-	char *fwd = "#", *rev = "*", *suspend = NULL, *stop = NULL;	/* Default values */
+	const char *fwd = "#", *rev = "*", *suspend = NULL, *stop = NULL;	/* Default values */
 
 	if (argc < 5 || argc > 9) {
 		return RESULT_SHOWUSAGE;
@@ -1165,7 +1164,7 @@
 	int res, vres;
 	struct ast_filestream *fs, *vfs;
 	long sample_offset = 0, max_length;
-	char *edigits = "";
+	char *edigits = NULL;
 
 	if (argc < 4 || argc > 5)
 		return RESULT_SHOWUSAGE;
@@ -1216,7 +1215,7 @@
 	struct ast_filestream *fs, *vfs;
 	long sample_offset = 0, max_length;
 	int timeout = 0;
-	char *edigits = "";
+	char *edigits = NULL;
 
 	if ( argc < 4 || argc > 5 )
 		return RESULT_SHOWUSAGE;
@@ -1358,7 +1357,7 @@
 {
 	int res = 0;
 	time_t unixtime;
-	char *format, *zone = NULL;
+	const char *format, *zone = NULL;
 
 	if (argc < 4)
 		return RESULT_SHOWUSAGE;
@@ -1704,7 +1703,7 @@
 			ast_masq_park_call(chan, NULL, 0, NULL);
 		}
 		if (ast_compat_res_agi && !ast_strlen_zero(argv[2])) {
-			char *compat = alloca(strlen(argv[2]) * 2 + 1), *cptr, *vptr;
+			char *compat = (char *) alloca(strlen(argv[2]) * 2 + 1), *cptr, *vptr;
 			for (cptr = compat, vptr = argv[2]; *vptr; vptr++) {
 				if (*vptr == ',') {
 					*cptr++ = '\\';
@@ -1733,7 +1732,8 @@
 static int handle_setcallerid(struct ast_channel *chan, AGI *agi, int argc, char **argv)
 {
 	char tmp[256]="";
-	char *l = NULL, *n = NULL;
+	char *l = NULL;
+	char *n = NULL;
 
 	if (argv[2]) {
 		ast_copy_string(tmp, argv[2], sizeof(tmp));
@@ -1741,9 +1741,9 @@
 		if (l)
 			ast_shrink_phone_number(l);
 		else
-			l = "";
+			l = (char *) "";
 		if (!n)
-			n = "";
+			n = (char *) "";
 		ast_set_callerid(chan, l, n, NULL);
 	}
 
@@ -2564,10 +2564,11 @@
 				ast_module_unref(ast_module_info->self);
 #ifdef AST_XML_DOCS
 			if (e->docsrc == AST_XML_DOC) {
-				ast_free(e->summary);
-				ast_free(e->usage);
-				ast_free(e->syntax);
-				ast_free(e->seealso);
+				/* We cast away the const'ness, but it's safe here */
+				ast_free((char *) e->summary);
+				ast_free((char *) e->usage);
+				ast_free((char *) e->syntax);
+				ast_free((char *) e->seealso);
 				e->summary = NULL, e->usage = NULL;
 				e->syntax = NULL, e->seealso = NULL;
 			}
@@ -2631,7 +2632,7 @@
 	return res;
 }
 
-static agi_command *find_command(char *cmds[], int exact)
+static agi_command *find_command(const char * const cmds[], int exact)
 {
 	int y, match;
 	struct agi_command *e;
@@ -2887,7 +2888,7 @@
 			if (!buf[0]) {
 				/* Program terminated */
 				if (returnstatus) {
-					returnstatus = -1;
+					returnstatus = AGI_RESULT_FAILURE;
 				}
 				ast_verb(3, "<%s>AGI Script %s completed, returning %d\n", chan->name, request, returnstatus);
 				if (pid > 0)
@@ -2908,7 +2909,7 @@
 				buf[strlen(buf) - 1] = 0;
 			if (agidebug)
 				ast_verbose("<%s>AGI Rx << %s\n", chan->name, buf);
-			returnstatus |= agi_handle_command(chan, agi, buf, dead);
+			returnstatus = (enum agi_result) (returnstatus | agi_handle_command(chan, agi, buf, dead));
 			/* If the handle_command returns -1, we need to stop */
 			if (returnstatus < 0) {
 				needhup = 1;
@@ -2995,13 +2996,13 @@
 #endif
 			{
 				synlen = strlen(S_OR(command->summary, "Not available")) + AST_TERM_MAX_ESCAPE_CHARS;
-				synopsis = ast_malloc(synlen);
+				synopsis = (char *) ast_malloc(synlen);
 
 				desclen = strlen(S_OR(command->usage, "Not available")) + AST_TERM_MAX_ESCAPE_CHARS;
-				description = ast_malloc(desclen);
+				description = (char *) ast_malloc(desclen);
 
 				seealsolen = strlen(S_OR(command->seealso, "Not available")) + AST_TERM_MAX_ESCAPE_CHARS;
-				seealso = ast_malloc(seealsolen);
+				seealso = (char *) ast_malloc(seealsolen);
 
 				if (!synopsis || !description || !seealso) {
 					error = 1;
@@ -3013,7 +3014,7 @@
 			}
 
 			stxlen = strlen(S_OR(command->syntax, "Not available")) + AST_TERM_MAX_ESCAPE_CHARS;
-			syntax = ast_malloc(stxlen);
+			syntax = (char *) ast_malloc(stxlen);
 			if (!syntax) {
 				error = 1;
 				goto return_cleanup;
@@ -3164,14 +3165,15 @@
 		AST_APP_ARG(arg)[MAX_ARGS];
 	);
 	AGI agi;
-
-	if (ast_strlen_zero(data)) {
+	char *datastr = (char *) data;
+
+	if (ast_strlen_zero(datastr)) {
 		ast_log(LOG_WARNING, "AGI requires an argument (script)\n");
 		return -1;
 	}
 	if (dead)
 		ast_debug(3, "Hungup channel detected, running agi in dead mode.\n");
-	ast_copy_string(buf, data, sizeof(buf));
+	ast_copy_string(buf, datastr, sizeof(buf));
 	memset(&agi, 0, sizeof(agi));
 	AST_STANDARD_APP_ARGS(args, tmp);
 	args.argv[args.argc] = NULL;
@@ -3278,7 +3280,7 @@
 	return ast_unregister_application(app);
 }
 
-static int load_module(void)
+static enum ast_module_load_result load_module(void)
 {
 	ast_cli_register_multiple(cli_agi, ARRAY_LEN(cli_agi));
 	/* we can safely ignore the result of ast_agi_register_multiple() here, since it cannot fail, as
@@ -3288,10 +3290,11 @@
 	ast_register_application(deadapp, deadagi_exec, deadsynopsis, descrip);
 	ast_register_application(eapp, eagi_exec, esynopsis, descrip);
 	ast_manager_register2("AGI", EVENT_FLAG_AGI, action_add_agi_cmd, "Add an AGI command to execute by Async AGI", mandescr_asyncagi);
-	return ast_register_application(app, agi_exec, synopsis, descrip);
+	return (enum ast_module_load_result) ast_register_application(app, agi_exec, synopsis, descrip);
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Asterisk Gateway Interface (AGI)",
-		.load = load_module,
-		.unload = unload_module,
+				load_module,
+				unload_module,
+				NULL
 		);




More information about the asterisk-commits mailing list