[asterisk-commits] mmichelson: branch group/asterisk-cpp r168448 - in /team/group/asterisk-cpp: ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jan 11 18:05:32 CST 2009


Author: mmichelson
Date: Sun Jan 11 18:05:31 2009
New Revision: 168448

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168448
Log:
manager.c almost compiles. There's a weird error
on line 992 that I don't know how to resolve


Modified:
    team/group/asterisk-cpp/include/asterisk/http.h
    team/group/asterisk-cpp/include/asterisk/manager.h
    team/group/asterisk-cpp/include/asterisk/tcptls.h
    team/group/asterisk-cpp/main/manager.c

Modified: team/group/asterisk-cpp/include/asterisk/http.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/http.h?view=diff&rev=168448&r1=168447&r2=168448
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/http.h (original)
+++ team/group/asterisk-cpp/include/asterisk/http.h Sun Jan 11 18:05:31 2009
@@ -76,6 +76,9 @@
 
 /*! \brief Definition of a URI handler */
 struct ast_http_uri {
+	ast_http_uri(const char *description, const char *uri, ast_http_callback callback, unsigned int supports_get,
+			void *data, const char *key) :
+		description(description), uri(uri), callback(callback), supports_get(supports_get), data(data), key(key) {}
 	AST_LIST_ENTRY(ast_http_uri) entry;
 	const char *description;
 	const char *uri;

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=168448&r1=168447&r2=168448
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/manager.h (original)
+++ team/group/asterisk-cpp/include/asterisk/manager.h Sun Jan 11 18:05:31 2009
@@ -195,13 +195,13 @@
 void astman_send_error(struct mansession *s, const struct message *m, const char *error);
 
 /*! \brief Send response in manager transaction */
-void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg);
+void astman_send_response(struct mansession *s, const struct message *m, const char *resp, const char *msg);
 
 /*! \brief Send ack in manager transaction */
 void astman_send_ack(struct mansession *s, const struct message *m, const char *msg);
 
 /*! \brief Send ack in manager list transaction */
-void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag);
+void astman_send_listack(struct mansession *s, const struct message *m, const char *msg, const char *listflag);
 
 void __attribute__((format(printf, 2, 3))) astman_append(struct mansession *s, const char *fmt, ...);
 

Modified: team/group/asterisk-cpp/include/asterisk/tcptls.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/tcptls.h?view=diff&rev=168448&r1=168447&r2=168448
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/tcptls.h (original)
+++ team/group/asterisk-cpp/include/asterisk/tcptls.h Sun Jan 11 18:05:31 2009
@@ -113,6 +113,11 @@
  * arguments for the accepting thread
  */
 struct ast_tcptls_session_args {
+	ast_tcptls_session_args(const char *name_arg, void *(*accept_fn_arg)(void *), void *(*worker_fn_arg)(void *),
+			int accept_fd_arg = -1, pthread_t master_arg = AST_PTHREADT_NULL, int poll_timeout_arg = -1,
+			void (*periodic_fn_arg)(void *) = NULL, struct ast_tls_config *tls_cfg_arg = NULL) :
+		tls_cfg(tls_cfg_arg), accept_fd(accept_fd_arg), poll_timeout(poll_timeout_arg), master(master_arg),
+		accept_fn(accept_fn_arg), periodic_fn(periodic_fn_arg), worker_fn(worker_fn_arg), name(name_arg) {}
 	struct sockaddr_in local_address;
 	struct sockaddr_in old_local_address;
 	struct sockaddr_in remote_address;

Modified: team/group/asterisk-cpp/main/manager.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/manager.c?view=diff&rev=168448&r1=168447&r2=168448
==============================================================================
--- team/group/asterisk-cpp/main/manager.c (original)
+++ team/group/asterisk-cpp/main/manager.c Sun Jan 11 18:05:31 2009
@@ -142,7 +142,7 @@
  */
 #define MAX_BLACKLIST_CMD_LEN 2
 static struct {
-	char *words[AST_MAX_CMD_LEN];
+	const char *words[AST_MAX_CMD_LEN];
 } command_blacklist[] = {
 	{{ "module", "load", NULL }},
 	{{ "module", "unload", NULL }},
@@ -322,7 +322,7 @@
  */
 static struct permalias {
 	int num;
-	char *label;
+	const char *label;
 } perms[] = {
 	{ EVENT_FLAG_SYSTEM, "system" },
 	{ EVENT_FLAG_CALL, "call" },
@@ -345,8 +345,8 @@
 /*! \brief Convert authority code to a list of options */
 static char *authority_to_str(int authority, struct ast_str **res)
 {
-	int i;
-	char *sep = "";
+	size_t i;
+	const char *sep = "";
 
 	ast_str_reset(*res);
 	for (i = 0; i < ARRAY_LEN(perms) - 1; i++) {
@@ -386,7 +386,8 @@
 
 static int get_perm(const char *instr)
 {
-	int x = 0, ret = 0;
+	size_t x = 0;
+	int ret = 0;
 
 	if (!instr)
 		return 0;
@@ -418,7 +419,8 @@
 	if (ast_false(string))
 		return 0;
 	if (ast_true(string)) {	/* all permissions */
-		int x, ret = 0;
+		size_t x;
+		int ret = 0;
 		for (x = 0; x < ARRAY_LEN(perms); x++)
 			ret |= perms[x].num;
 		return ret;
@@ -823,9 +825,9 @@
 #define	GET_HEADER_FIRST_MATCH	0
 #define	GET_HEADER_LAST_MATCH	1
 #define	GET_HEADER_SKIP_EMPTY	2
-static const char *__astman_get_header(const struct message *m, char *var, int mode)
-{
-	int x, l = strlen(var);
+static const char *__astman_get_header(const struct message *m, const char *var, int mode)
+{
+	size_t x, l = strlen(var);
 	const char *result = "";
 
 	for (x = 0; x < m->hdrcount; x++) {
@@ -850,7 +852,7 @@
  * This is the legacy function and is implemented in therms of
  * __astman_get_header().
  */
-const char *astman_get_header(const struct message *m, char *var)
+const char *astman_get_header(const struct message *m, const char *var)
 {
 	return __astman_get_header(m, var, GET_HEADER_FIRST_MATCH);
 }
@@ -858,7 +860,8 @@
 
 struct ast_variable *astman_get_variables(const struct message *m)
 {
-	int varlen, x, y;
+	int varlen;
+	unsigned int x, y;
 	struct ast_variable *head = NULL, *cur;
 
 	AST_DECLARE_APP_ARGS(args,
@@ -951,8 +954,8 @@
  * Use the explicit constant MSG_MOREDATA to remove the empty line.
  * XXX MSG_MOREDATA should go to a header file.
  */
-#define MSG_MOREDATA	((char *)astman_send_response)
-static void astman_send_response_full(struct mansession *s, const struct message *m, char *resp, char *msg, char *listflag)
+#define MSG_MOREDATA	((const char *) astman_send_response)
+static void astman_send_response_full(struct mansession *s, const struct message *m, const char *resp, const char *msg, const char *listflag)
 {
 	const char *id = astman_get_header(m, "ActionID");
 
@@ -969,27 +972,27 @@
 		astman_append(s, "\r\n");
 }
 
-void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg)
+void astman_send_response(struct mansession *s, const struct message *m, const char *resp, char *msg)
 {
 	astman_send_response_full(s, m, resp, msg, NULL);
 }
 
-void astman_send_error(struct mansession *s, const struct message *m, char *error)
+void astman_send_error(struct mansession *s, const struct message *m, const char *error)
 {
 	astman_send_response_full(s, m, "Error", error, NULL);
 }
 
-void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
+void astman_send_ack(struct mansession *s, const struct message *m, const char *msg)
 {
 	astman_send_response_full(s, m, "Success", msg, NULL);
 }
 
 static void astman_start_ack(struct mansession *s, const struct message *m)
 {
-	astman_send_response_full(s, m, "Success", MSG_MOREDATA, NULL);
-}
-
-void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
+	astman_send_response_full(s, m, "Success", (const char *) MSG_MOREDATA, NULL);
+}
+
+void astman_send_listack(struct mansession *s, const struct message *m, const char *msg, const char *listflag)
 {
 	astman_send_response_full(s, m, "Success", msg, listflag);
 }
@@ -1220,7 +1223,7 @@
 	}
 
 	buf_len = 512;
-	buf = alloca(buf_len);
+	buf = (char *) alloca(buf_len);
 
 	astman_start_ack(s, m);
 	astman_append(s, "JSON: {");
@@ -1228,7 +1231,7 @@
 		int comma2 = 0;
 		if (buf_len < 2 * strlen(category) + 1) {
 			buf_len *= 2;
-			buf = alloca(buf_len);
+			buf = (char *) alloca(buf_len);
 		}
 		json_escape(buf, category);
 		astman_append(s, "%s\"%s\":[", comma1 ? "," : "", buf);
@@ -1239,13 +1242,13 @@
 				astman_append(s, ",");
 			if (buf_len < 2 * strlen(v->name) + 1) {
 				buf_len *= 2;
-				buf = alloca(buf_len);
+				buf = (char *) alloca(buf_len);
 			}
 			json_escape(buf, v->name);
 			astman_append(s, "\"%s", buf);
 			if (buf_len < 2 * strlen(v->value) + 1) {
 				buf_len *= 2;
-				buf = alloca(buf_len);
+				buf = (char *) alloca(buf_len);
 			}
 			json_escape(buf, v->value);
 			astman_append(s, "%s\"", buf);
@@ -1270,7 +1273,7 @@
 	struct ast_category *category;
 	struct ast_variable *v;
 	struct ast_str *str1 = ast_str_create(16), *str2 = ast_str_create(16);
-	enum error_type result = 0;
+	enum error_type result = (enum error_type) 0;
 
 	for (x = 0; x < 100000; x++) {	/* 100000 = the max number of allowed updates + 1 */
 		unsigned int object = 0;
@@ -1798,7 +1801,7 @@
 
 	if (varname[strlen(varname) - 1] == ')') {
 		if (!c) {
-			c = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/manager");
+			c = (struct ast_channel *) ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/manager");
 			if (c) {
 				ast_func_read(c, (char *) varname, workspace, sizeof(workspace));
 				ast_channel_free(c);
@@ -1872,7 +1875,7 @@
 	/* if we look by name, we break after the first iteration */
 	while (c) {
 		if (!ast_strlen_zero(cvariables)) {
-			int i;
+			unsigned int i;
 			ast_str_reset(str);
 			for (i = 0; i < vars.argc; i++) {
 				char valbuf[512], *ret = NULL;
@@ -2135,7 +2138,7 @@
 {
 	char *cmd_copy, *cur_cmd;
 	char *cmd_words[MAX_BLACKLIST_CMD_LEN] = { NULL, };
-	int i;
+	size_t i;
 
 	cmd_copy = ast_strdupa(cmd);
 	for (i = 0; i < MAX_BLACKLIST_CMD_LEN && (cur_cmd = strsep(&cmd_copy, " ")); i++) {
@@ -2178,8 +2181,8 @@
 	const char *cmd = astman_get_header(m, "Command");
 	const char *id = astman_get_header(m, "ActionID");
 	char *buf, *final_buf;
-	char template[] = "/tmp/ast-ami-XXXXXX";	/* template for temporary file */
-	int fd = mkstemp(template);
+	char file_template[] = "/tmp/ast-ami-XXXXXX";	/* template for temporary file */
+	int fd = mkstemp(file_template);
 	off_t l;
 
 	if (ast_strlen_zero(cmd)) {
@@ -2200,8 +2203,8 @@
 	l = lseek(fd, 0, SEEK_END);	/* how many chars available */
 
 	/* This has a potential to overflow the stack.  Hence, use the heap. */
-	buf = ast_calloc(1, l + 1);
-	final_buf = ast_calloc(1, l + 1);
+	buf = (char *) ast_calloc(1, l + 1);
+	final_buf = (char *) ast_calloc(1, l + 1);
 	if (buf) {
 		lseek(fd, 0, SEEK_SET);
 		if (read(fd, buf, l) < 0) {
@@ -2216,7 +2219,7 @@
 		ast_free(buf);
 	}
 	close(fd);
-	unlink(template);
+	unlink(file_template);
 	astman_append(s, "--END COMMAND--\r\n\r\n");
 	if (final_buf)
 		ast_free(final_buf);
@@ -2244,7 +2247,7 @@
 
 static void *fast_originate(void *data)
 {
-	struct fast_originate_helper *in = data;
+	struct fast_originate_helper *in = (struct fast_originate_helper *) data;
 	int res;
 	int reason = 0;
 	struct ast_channel *chan = NULL;
@@ -2368,7 +2371,7 @@
 		ast_parse_allow_disallow(NULL, &format, codecs, 1);
 	}
 	if (ast_true(async)) {
-		struct fast_originate_helper *fast = ast_calloc(1, sizeof(*fast));
+		struct fast_originate_helper *fast = (struct fast_originate_helper *) ast_calloc(1, sizeof(*fast));
 		if (!fast) {
 			res = -1;
 		} else {
@@ -2600,7 +2603,7 @@
 {
 	const char *event = astman_get_header(m, "UserEvent");
 	char body[2048] = "";
-	int x, bodylen = 0;
+	unsigned int x, bodylen = 0;
 	for (x = 0; x < m->hdrcount; x++) {
 		if (strncasecmp("UserEvent:", m->headers[x], strlen("UserEvent:"))) {
 			ast_copy_string(body + bodylen, m->headers[x], sizeof(body) - bodylen - 3);
@@ -3081,8 +3084,8 @@
  */
 static void *session_do(void *data)
 {
-	struct ast_tcptls_session_instance *ser = data;
-	struct mansession *s = ast_calloc(1, sizeof(*s));
+	struct ast_tcptls_session_instance *ser = (struct ast_tcptls_session_instance *) data;
+	struct mansession *s = (struct mansession *) ast_calloc(1, sizeof(*s));
 	int flags;
 	int res;
 
@@ -3183,7 +3186,7 @@
  */
 static int append_event(const char *str, int category)
 {
-	struct eventqent *tmp = ast_malloc(sizeof(*tmp) + strlen(str));
+	struct eventqent *tmp = (struct eventqent *) ast_malloc(sizeof(*tmp) + strlen(str));
 	static int seq;	/* sequence number */
 
 	if (!tmp)
@@ -3302,7 +3305,7 @@
 	return 0;
 }
 
-static int manager_state_cb(char *context, char *exten, int state, void *data)
+static int manager_state_cb(char *context, char *exten, enum ast_extension_states state, void *data)
 {
 	/* Notify managers of change */
 	char hint[512];
@@ -3348,7 +3351,7 @@
 {
 	struct manager_action *cur = NULL;
 
-	if (!(cur = ast_calloc(1, sizeof(*cur))))
+	if (!(cur = (struct manager_action *) ast_calloc(1, sizeof(*cur))))
 		return -1;
 
 	cur->action = action;
@@ -3382,10 +3385,10 @@
 	FORMAT_XML,
 };
 
-static char *contenttype[] = {
-	[FORMAT_RAW] = "plain",
-	[FORMAT_HTML] = "html",
-	[FORMAT_XML] =  "xml",
+static const char *contenttype[] = {
+	"plain",
+	"html",
+	"xml",
 };
 
 /*!
@@ -3548,7 +3551,7 @@
 
 static int variable_count_hash_fn(const void *vvc, const int flags)
 {
-	const struct variable_count *vc = vvc;
+	const struct variable_count *vc = (const struct variable_count *) vvc;
 	int res = 0, i;
 	for (i = 0; i < 5; i++) {
 		if (vc->varname[i] == '\0')
@@ -3564,8 +3567,8 @@
 	 * if you pass in objects or strings, the same operation applies. This is
 	 * due to the fact that the hash occurs on the first element, which means
 	 * the address of both the struct and the string are exactly the same. */
-	struct variable_count *vc = obj;
-	char *str = vstr;
+	struct variable_count *vc = (struct variable_count *) obj;
+	char *str = (char *) vstr;
 	return !strcmp(vc->varname, str) ? CMP_MATCH | CMP_STOP : 0;
 }
 
@@ -3652,7 +3655,7 @@
 				ast_trim_blanks(var);
 			} else {		/* field name not found, move to opaque mode */
 				val = var;
-				var = "Opaque-data";
+				var = (char *) "Opaque-data";
 			}
 		}
 
@@ -3667,11 +3670,11 @@
 
 		if (!in_data) {	/* build appropriate line start */
 			ast_str_append(out, 0, xml ? " " : "<tr><td>");
-			if ((vc = ao2_find(vco, var, 0)))
+			if ((vc = (struct variable_count *) ao2_find(vco, var, (enum search_flags) 0)))
 				vc->count++;
 			else {
 				/* Create a new entry for this one */
-				vc = ao2_alloc(sizeof(*vc), NULL);
+				vc = (struct variable_count *) ao2_alloc(sizeof(*vc), NULL);
 				vc->varname = var;
 				vc->count = 1;
 				ao2_link(vco, vc);
@@ -3706,7 +3709,7 @@
 	uint32_t ident = 0;
 	int blastaway = 0;
 	struct ast_variable *v;
-	char template[] = "/tmp/ast-http-XXXXXX";	/* template for temporary file */
+	char file_template[] = "/tmp/ast-http-XXXXXX";	/* template for temporary file */
 	struct ast_str *out = NULL;
 	struct message m = { 0 };
 	unsigned int x;
@@ -3723,7 +3726,7 @@
 		/* Create new session.
 		 * While it is not in the list we don't need any locking
 		 */
-		if (!(s = ast_calloc(1, sizeof(*s)))) {
+		if (!(s = (struct mansession *) ast_calloc(1, sizeof(*s)))) {
 			*status = 500;
 			goto generic_callback_out;
 		}
@@ -3755,13 +3758,13 @@
 		goto generic_callback_out;
 	}
 
-	s->fd = mkstemp(template);	/* create a temporary file for command output */
-	unlink(template);
+	s->fd = mkstemp(file_template);	/* create a temporary file for command output */
+	unlink(file_template);
 	s->f = fdopen(s->fd, "w+");
 
 	for (x = 0, v = params; v && (x < AST_MAX_MANHEADERS); x++, v = v->next) {
 		hdrlen = strlen(v->name) + strlen(v->value) + 3;
-		m.headers[m.hdrcount] = alloca(hdrlen);
+		m.headers[m.hdrcount] = (char *) alloca(hdrlen);
 		snprintf((char *) m.headers[m.hdrcount], hdrlen, "%s: %s", v->name, v->value);
 		ast_verb(4, "HTTP Manager add header %s\n", m.headers[m.hdrcount]);
 		m.hdrcount = x + 1;
@@ -3826,7 +3829,7 @@
 		size_t l = ftell(s->f);
 		
 		if (l) {
-			if ((buf = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_SHARED, s->fd, 0))) {
+			if ((buf = (char *) mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_SHARED, s->fd, 0))) {
 				if (format == FORMAT_XML || format == FORMAT_HTML)
 					xml_translate(&out, buf, params, format);
 				else
@@ -3834,7 +3837,7 @@
 				munmap(buf, l);
 			}
 		} else if (format == FORMAT_XML || format == FORMAT_HTML) {
-			xml_translate(&out, "", params, format);
+			xml_translate(&out, (char *) "", params, format);
 		}
 		fclose(s->f);
 		s->f = NULL;
@@ -3887,32 +3890,32 @@
 	return generic_http_callback(FORMAT_RAW, &ser->remote_address, uri, method, params, status, title, contentlength);
 }
 
-struct ast_http_uri rawmanuri = {
-	.description = "Raw HTTP Manager Event Interface",
-	.uri = "rawman",
-	.callback = rawman_http_callback,
-	.supports_get = 1,
-	.data = NULL,
-	.key = __FILE__,
-};
-
-struct ast_http_uri manageruri = {
-	.description = "HTML Manager Event Interface",
-	.uri = "manager",
-	.callback = manager_http_callback,
-	.supports_get = 1,
-	.data = NULL,
-	.key = __FILE__,
-};
-
-struct ast_http_uri managerxmluri = {
-	.description = "XML Manager Event Interface",
-	.uri = "mxml",
-	.callback = mxml_http_callback,
-	.supports_get = 1,
-	.data = NULL,
-	.key = __FILE__,
-};
+struct ast_http_uri rawmanuri(
+	"Raw HTTP Manager Event Interface",
+	"rawman",
+	rawman_http_callback,
+	1,
+	NULL,
+	__FILE__
+);
+
+struct ast_http_uri manageruri(
+	"HTML Manager Event Interface",
+	"manager",
+	manager_http_callback,
+	1,
+	NULL,
+	__FILE__
+);
+
+struct ast_http_uri managerxmluri(
+	"XML Manager Event Interface",
+	"mxml",
+	mxml_http_callback,
+	1,
+	NULL,
+	__FILE__
+);
 
 static int registered = 0;
 static int webregged = 0;
@@ -3927,26 +3930,11 @@
 }
 
 struct ast_tls_config ami_tls_cfg;
-static struct ast_tcptls_session_args ami_desc = {
-	.accept_fd = -1,
-	.master = AST_PTHREADT_NULL,
-	.tls_cfg = NULL, 
-	.poll_timeout = 5000,	/* wake up every 5 seconds */
-	.periodic_fn = purge_old_stuff,
-	.name = "AMI server",
-	.accept_fn = ast_tcptls_server_root,	/* thread doing the accept() */
-	.worker_fn = session_do,	/* thread handling the session */
-};
-
-static struct ast_tcptls_session_args amis_desc = {
-	.accept_fd = -1,
-	.master = AST_PTHREADT_NULL,
-	.tls_cfg = &ami_tls_cfg, 
-	.poll_timeout = -1,	/* the other does the periodic cleanup */
-	.name = "AMI TLS server",
-	.accept_fn = ast_tcptls_server_root,	/* thread doing the accept() */
-	.worker_fn = session_do,	/* thread handling the session */
-};
+static struct ast_tcptls_session_args ami_desc("AMI server", ast_tcptls_server_root, 
+		session_do, -1, AST_PTHREADT_NULL, 5000, purge_old_stuff);
+
+static struct ast_tcptls_session_args amis_desc("AMI TLS server", ast_tcptls_server_root, 
+		session_do, -1, AST_PTHREADT_NULL, -1, NULL, &ami_tls_cfg);
 
 static int __init_manager(int reload)
 {
@@ -4107,7 +4095,7 @@
 				 * if none found - create one and add it to the list
 				 */
 				if (!(user = get_manager_by_name_locked(cat))) {
-					if (!(user = ast_calloc(1, sizeof(*user))))
+					if (!(user = (struct ast_manager_user *) ast_calloc(1, sizeof(*user))))
 						break;
 
 					/* Copy name over */
@@ -4169,7 +4157,7 @@
 
 		/* Look for an existing entry, if none found - create one and add it to the list */
 		if (!(user = get_manager_by_name_locked(cat))) {
-			if (!(user = ast_calloc(1, sizeof(*user))))
+			if (!(user = (struct ast_manager_user *) ast_calloc(1, sizeof(*user))))
 				break;
 			/* Copy name over */
 			ast_copy_string(user->username, cat, sizeof(user->username));




More information about the asterisk-commits mailing list