[asterisk-commits] russell: branch group/asterisk-cpp r168462 - in /team/group/asterisk-cpp: inc...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jan 11 20:11:28 CST 2009


Author: russell
Date: Sun Jan 11 20:11:28 2009
New Revision: 168462

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168462
Log:
fix a bunch of stuff in pbx.c ... still a lot to go

Modified:
    team/group/asterisk-cpp/include/asterisk/app.h
    team/group/asterisk-cpp/include/asterisk/extconf.h
    team/group/asterisk-cpp/include/asterisk/pbx.h
    team/group/asterisk-cpp/main/pbx.c

Modified: team/group/asterisk-cpp/include/asterisk/app.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/app.h?view=diff&rev=168462&r1=168461&r2=168462
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/app.h (original)
+++ team/group/asterisk-cpp/include/asterisk/app.h Sun Jan 11 20:11:28 2009
@@ -463,7 +463,7 @@
   \return zero for success, non-zero if an error occurs
   \sa AST_APP_OPTIONS
  */
-int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr);
+int ast_app_parse_options(const struct ast_app_option *options, size_t num_options, struct ast_flags *flags, char **args, char *optstr);
 
 	/*!
   \brief Parses a string containing application options and sets flags/arguments.
@@ -474,7 +474,7 @@
   \return zero for success, non-zero if an error occurs
   \sa AST_APP_OPTIONS
  */
-int ast_app_parse_options64(const struct ast_app_option *options, struct ast_flags64 *flags, char **args, char *optstr);
+int ast_app_parse_options64(const struct ast_app_option *options, size_t num_options, struct ast_flags64 *flags, char **args, char *optstr);
 
 /*! \brief Given a list of options array, return an option string based on passed flags
 	\param options The array of possible options declared with AST_APP_OPTIONS

Modified: team/group/asterisk-cpp/include/asterisk/extconf.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/extconf.h?view=diff&rev=168462&r1=168461&r2=168462
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/extconf.h (original)
+++ team/group/asterisk-cpp/include/asterisk/extconf.h Sun Jan 11 20:11:28 2009
@@ -71,7 +71,7 @@
 
 /*! \brief A registered application */
 struct ast_app {
-	int (*execute)(struct ast_channel *chan, void *data);
+	int (*execute)(struct ast_channel *chan, const char *data);
 	AST_DECLARE_STRING_FIELDS(
 		AST_STRING_FIELD(synopsis);     /*!< Synopsis text for 'show applications' */
 		AST_STRING_FIELD(description);  /*!< Description (help text) for 'show application &lt;name&gt;' */
@@ -107,7 +107,7 @@
 	char stuff[0];
 };
 /* from pbx.h */
-typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data);
+typedef int (*ast_state_cb_type)(const char *context, const char* id, enum ast_extension_states state, void *data);
 struct ast_timing {
 	int hastime;				/*!< If time construct exists */
 	unsigned int monthmask;			/*!< Mask for month */

Modified: team/group/asterisk-cpp/include/asterisk/pbx.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/pbx.h?view=diff&rev=168462&r1=168461&r2=168462
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/pbx.h (original)
+++ team/group/asterisk-cpp/include/asterisk/pbx.h Sun Jan 11 20:11:28 2009
@@ -75,6 +75,11 @@
 
 /*! \brief Data structure associated with a custom dialplan function */
 struct ast_custom_function {
+	typedef int (*read_fn)(struct ast_channel *, const char *, char *, char *, size_t);
+	typedef int (*write_fn)(struct ast_channel *, const char *, char *, const char *);
+	ast_custom_function(const char *n, read_fn r = NULL, write_fn w = NULL) :
+		name(n), synopsis(NULL), desc(NULL), syntax(NULL), arguments(NULL), 
+		seealso(NULL), read(r), write(w) {}
 	const char *name;			/*!< Name */
 	AST_DECLARE_STRING_FIELDS(
 		AST_STRING_FIELD(synopsis);     /*!< Synopsis text for 'show functions' */
@@ -857,7 +862,7 @@
 const char *ast_get_extension_cidmatch(struct ast_exten *e);
 const char *ast_get_extension_app(struct ast_exten *e);
 const char *ast_get_extension_label(struct ast_exten *e);
-void *ast_get_extension_app_data(struct ast_exten *e);
+const char *ast_get_extension_app_data(struct ast_exten *e);
 /*! @} */
 
 /*! @name Registrar info functions ... */
@@ -924,10 +929,10 @@
 /*!
  * \note Will lock the channel.
  */
-int pbx_builtin_setvar(struct ast_channel *chan, void *data);
-int pbx_builtin_setvar_multiple(struct ast_channel *chan, void *data);
-
-int pbx_builtin_raise_exception(struct ast_channel *chan, void *data);
+int pbx_builtin_setvar(struct ast_channel *chan, const char *data);
+int pbx_builtin_setvar_multiple(struct ast_channel *chan, const char *data);
+
+int pbx_builtin_raise_exception(struct ast_channel *chan, const char *data);
 
 void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
 void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count);

Modified: team/group/asterisk-cpp/main/pbx.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/pbx.c?view=diff&rev=168462&r1=168461&r2=168462
==============================================================================
--- team/group/asterisk-cpp/main/pbx.c (original)
+++ team/group/asterisk-cpp/main/pbx.c Sun Jan 11 20:11:28 2009
@@ -771,7 +771,7 @@
 	struct ast_context *parent;	/*!< The context this extension belongs to  */
 	const char *app; 		/*!< Application to execute */
 	struct ast_app *cached_app;     /*!< Cached location of application */
-	void *data;			/*!< Data to use (arguments) */
+	const char *data;			/*!< Data to use (arguments) */
 	void (*datad)(void *);		/*!< Data destructor */
 	struct ast_exten *peer;		/*!< Next higher priority with our extension */
 	struct ast_hashtab *peer_table;    /*!< Priorities list in hashtab form -- only on the head of the peer list */
@@ -850,7 +850,7 @@
 
 /*! \brief ast_app: A registered application */
 struct ast_app {
-	int (*execute)(struct ast_channel *chan, void *data);
+	int (*execute)(struct ast_channel *chan, const char *data);
 	AST_DECLARE_STRING_FIELDS(
 		AST_STRING_FIELD(synopsis);     /*!< Synopsis text for 'show applications' */
 		AST_STRING_FIELD(description);  /*!< Description (help text) for 'show application &lt;name&gt;' */
@@ -867,7 +867,7 @@
 /*! \brief ast_state_cb: An extension state notify register item */
 struct ast_state_cb {
 	int id;
-	void *data;
+	const void *data;
 	ast_state_cb_type callback;
 	AST_LIST_ENTRY(ast_state_cb) entry;
 };
@@ -914,33 +914,33 @@
 	int priority;				/*!< Priority associated with this exception */
 };
 
-static int pbx_builtin_answer(struct ast_channel *, void *);
-static int pbx_builtin_goto(struct ast_channel *, void *);
-static int pbx_builtin_hangup(struct ast_channel *, void *);
-static int pbx_builtin_background(struct ast_channel *, void *);
-static int pbx_builtin_wait(struct ast_channel *, void *);
-static int pbx_builtin_waitexten(struct ast_channel *, void *);
-static int pbx_builtin_incomplete(struct ast_channel *, void *);
-static int pbx_builtin_resetcdr(struct ast_channel *, void *);
-static int pbx_builtin_setamaflags(struct ast_channel *, void *);
-static int pbx_builtin_ringing(struct ast_channel *, void *);
-static int pbx_builtin_proceeding(struct ast_channel *, void *);
-static int pbx_builtin_progress(struct ast_channel *, void *);
-static int pbx_builtin_congestion(struct ast_channel *, void *);
-static int pbx_builtin_busy(struct ast_channel *, void *);
-static int pbx_builtin_noop(struct ast_channel *, void *);
-static int pbx_builtin_gotoif(struct ast_channel *, void *);
-static int pbx_builtin_gotoiftime(struct ast_channel *, void *);
-static int pbx_builtin_execiftime(struct ast_channel *, void *);
-static int pbx_builtin_saynumber(struct ast_channel *, void *);
-static int pbx_builtin_saydigits(struct ast_channel *, void *);
-static int pbx_builtin_saycharacters(struct ast_channel *, void *);
-static int pbx_builtin_sayphonetic(struct ast_channel *, void *);
+static int pbx_builtin_answer(struct ast_channel *, const char *);
+static int pbx_builtin_goto(struct ast_channel *, const char *);
+static int pbx_builtin_hangup(struct ast_channel *, const char *);
+static int pbx_builtin_background(struct ast_channel *, const char *);
+static int pbx_builtin_wait(struct ast_channel *, const char *);
+static int pbx_builtin_waitexten(struct ast_channel *, const char *);
+static int pbx_builtin_incomplete(struct ast_channel *, const char *);
+static int pbx_builtin_resetcdr(struct ast_channel *, const char *);
+static int pbx_builtin_setamaflags(struct ast_channel *, const char *);
+static int pbx_builtin_ringing(struct ast_channel *, const char *);
+static int pbx_builtin_proceeding(struct ast_channel *, const char *);
+static int pbx_builtin_progress(struct ast_channel *, const char *);
+static int pbx_builtin_congestion(struct ast_channel *, const char *);
+static int pbx_builtin_busy(struct ast_channel *, const char *);
+static int pbx_builtin_noop(struct ast_channel *, const char *);
+static int pbx_builtin_gotoif(struct ast_channel *, const char *);
+static int pbx_builtin_gotoiftime(struct ast_channel *, const char *);
+static int pbx_builtin_execiftime(struct ast_channel *, const char *);
+static int pbx_builtin_saynumber(struct ast_channel *, const char *);
+static int pbx_builtin_saydigits(struct ast_channel *, const char *);
+static int pbx_builtin_saycharacters(struct ast_channel *, const char *);
+static int pbx_builtin_sayphonetic(struct ast_channel *, const char *);
 static int matchcid(const char *cidpattern, const char *callerid);
-int pbx_builtin_setvar(struct ast_channel *, void *);
+int pbx_builtin_setvar(struct ast_channel *, const char *);
 void log_match_char_tree(struct match_char *node, char *prefix); /* for use anywhere */
-int pbx_builtin_setvar_multiple(struct ast_channel *, void *);
-static int pbx_builtin_importvar(struct ast_channel *, void *);
+int pbx_builtin_setvar_multiple(struct ast_channel *, const char *);
+static int pbx_builtin_importvar(struct ast_channel *, const char *);
 static void set_ext_pri(struct ast_channel *c, const char *exten, int pri); 
 static void new_find_extension(const char *str, struct scoreboard *score, 
 		struct match_char *tree, int length, int spec, const char *callerid, 
@@ -1069,7 +1069,7 @@
 /*! \brief Declaration of builtin applications */
 static struct pbx_builtin {
 	char name[AST_MAX_APP];
-	int (*execute)(struct ast_channel *chan, void *data);
+	int (*execute)(struct ast_channel *chan, const char *data);
 } builtins[] =
 {
 	/* These applications are built into the PBX core and do not
@@ -1313,6 +1313,8 @@
 	struct ast_module_user *u = NULL;
 	const char *saved_c_appl;
 	const char *saved_c_data;
+	char *args = (char *) data;
+	char empty_str[] = "";
 
 	if (c->cdr && !ast_check_hangup(c))
 		ast_cdr_setapp(c->cdr, app->name, (const char *) data);
@@ -1322,10 +1324,10 @@
 	saved_c_data= c->data;
 
 	c->appl = app->name;
-	c->data = (const char *) data;
+	c->data = args;
 	if (app->module)
 		u = __ast_module_user_add(app->module, c);
-	res = app->execute(c, S_OR(data, ""));
+	res = app->execute(c, S_OR(args, empty_str));
 	if (app->module && u)
 		__ast_module_user_remove(app->module, u);
 	/* restore channel values */
@@ -1604,7 +1606,8 @@
 static void new_find_extension(const char *str, struct scoreboard *score, struct match_char *tree, int length, int spec, const char *label, const char *callerid, enum ext_match_t action)
 {
 	struct match_char *p; /* note minimal stack storage requirements */
-	struct ast_exten pattern = { .label = label };
+	struct ast_exten pattern = { NULL, };
+	pattern.label = label;
 #ifdef DEBUG_THIS
 	if (tree)
 		ast_log(LOG_NOTICE,"new_find_extension called with %s on (sub)tree %s action=%s\n", str, tree->x, action2str(action));
@@ -1805,7 +1808,7 @@
 {
 	struct match_char *m;
 	
-	if (!(m = ast_calloc(1, sizeof(*m))))
+	if (!(m = (struct match_char *) ast_calloc(1, sizeof(*m))))
 		return NULL;
 
 	if (!(m->x = ast_strdup(pattern))) {
@@ -1851,7 +1854,7 @@
 	char buf[256];
 	char extenbuf[512];
 	char *s1 = extenbuf;
-	int l1 = strlen(e1->exten) + strlen(e1->cidmatch) + 2;
+	unsigned int l1 = strlen(e1->exten) + strlen(e1->cidmatch) + 2;
 	
 
 	strncpy(extenbuf,e1->exten,sizeof(extenbuf));
@@ -1976,7 +1979,7 @@
 			numobjs, numbucks, biggest_bucket, resizes);
 #endif
 	t1 = ast_hashtab_start_traversal(con->root_table);
-	while( (e1 = ast_hashtab_next(t1)) ) {
+	while ((e1 = (struct ast_exten *) ast_hashtab_next(t1))) {
 		if (e1->exten)
 			add_exten_to_pattern_tree(con, e1, 0);
 		else
@@ -2171,7 +2174,7 @@
  * \retval 2 on early match.
  */
 
-static int _extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
+static int _extension_match_core(const char *pattern, const char *data, int mode)
 {
 	mode &= E_MATCH_MASK;	/* only consider the relevant bits */
 	
@@ -2335,7 +2338,7 @@
  * Wrapper around _extension_match_core() to do performance measurement
  * using the profiling code.
  */
-static int extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
+static int extension_match_core(const char *pattern, const char *data, int mode)
 {
 	int i;
 	static int prof_id = -2;	/* marker for 'unallocated' id */
@@ -2382,7 +2385,7 @@
 	strncpy(item.name,name,256);
 	ast_rdlock_contexts();
 	if( contexts_table ) {
-		tmp = ast_hashtab_lookup(contexts_table,&item);
+		tmp = (struct ast_context *) ast_hashtab_lookup(contexts_table,&item);
 	} else {
 		while ( (tmp = ast_walk_contexts(tmp)) ) {
 			if (!name || !strcasecmp(name, tmp->name))
@@ -2452,7 +2455,7 @@
 	else {	/* look in contexts */
 		struct fake_context item;
 		strncpy(item.name,context,256);
-		tmp = ast_hashtab_lookup(contexts_table,&item);
+		tmp = (struct ast_context *) ast_hashtab_lookup(contexts_table,&item);
 #ifdef NOTNOW
 		tmp = NULL;
 		while ((tmp = ast_walk_contexts(tmp)) ) {
@@ -2603,9 +2606,9 @@
 			if (action == E_FINDLABEL && label ) {
 				if (q->status < STATUS_NO_LABEL)
 					q->status = STATUS_NO_LABEL;
-				e = ast_hashtab_lookup(eroot->peer_label_table, &pattern);
+				e = (struct ast_exten *) ast_hashtab_lookup(eroot->peer_label_table, &pattern);
 			} else {
-				e = ast_hashtab_lookup(eroot->peer_table, &pattern);
+				e = (struct ast_exten *) ast_hashtab_lookup(eroot->peer_table, &pattern);
 			}
 			if (e) {	/* found a valid match */
 				q->status = STATUS_SUCCESS;
@@ -2639,9 +2642,9 @@
 			if (action == E_FINDLABEL && label ) {
 				if (q->status < STATUS_NO_LABEL)
 					q->status = STATUS_NO_LABEL;
-				e = ast_hashtab_lookup(eroot->peer_label_table, &pattern);
+				e = (struct ast_exten *) ast_hashtab_lookup(eroot->peer_label_table, &pattern);
 			} else {
-				e = ast_hashtab_lookup(eroot->peer_table, &pattern);
+				e = (struct ast_exten *) ast_hashtab_lookup(eroot->peer_table, &pattern);
 			}
 #ifdef NOTNOW
 			while ( (e = ast_walk_extension_priorities(eroot, e)) ) {
@@ -2894,7 +2897,7 @@
 		}
 	}
 	/* if not found, look into chanvars or global vars */
-	for (i = 0; s == &not_found && i < ARRAY_LEN(places); i++) {
+	for (i = 0; s == &not_found && i < (int) ARRAY_LEN(places); i++) {
 		struct ast_var_t *variables;
 		if (!places[i])
 			continue;
@@ -2925,19 +2928,16 @@
 
 static void exception_store_free(void *data)
 {
-	struct pbx_exception *exception = data;
+	struct pbx_exception *exception = (struct pbx_exception *) data;
 	ast_string_field_free_memory(exception);
 	ast_free(exception);
 }
 
-static struct ast_datastore_info exception_store_info = {
-	.type = "EXCEPTION",
-	.destroy = exception_store_free,
-};
-
-int pbx_builtin_raise_exception(struct ast_channel *chan, void *vreason)
-{
-	const char *reason = vreason;
+static struct ast_datastore_info exception_store_info("EXCEPTION", exception_store_free);
+
+int pbx_builtin_raise_exception(struct ast_channel *chan, const char *vreason)
+{
+	const char *reason = (const char *) vreason;
 	struct ast_datastore *ds = ast_channel_datastore_find(chan, &exception_store_info, NULL);
 	struct pbx_exception *exception = NULL;
 
@@ -2945,7 +2945,7 @@
 		ds = ast_datastore_alloc(&exception_store_info, NULL);
 		if (!ds)
 			return -1;
-		exception = ast_calloc(1, sizeof(struct pbx_exception));
+		exception = (struct pbx_exception *) ast_calloc(1, sizeof(struct pbx_exception));
 		if (!exception) {
 			ast_datastore_free(ds);
 			return -1;
@@ -2958,7 +2958,7 @@
 		ds->data = exception;
 		ast_channel_datastore_add(chan, ds);
 	} else
-		exception = ds->data;
+		exception = (struct pbx_exception *) ds->data;
 
 	ast_string_field_set(exception, reason, reason);
 	ast_string_field_set(exception, context, chan->context);
@@ -2974,7 +2974,7 @@
 	struct pbx_exception *exception = NULL;
 	if (!ds || !ds->data)
 		return -1;
-	exception = ds->data;
+	exception = (struct pbx_exception *) ds->data;
 	if (!strcasecmp(data, "REASON"))
 		ast_copy_string(buf, exception->reason, buflen);
 	else if (!strcasecmp(data, "CONTEXT"))
@@ -2988,10 +2988,7 @@
 	return 0;
 }
 
-static struct ast_custom_function exception_function = {
-	.name = "EXCEPTION",
-	.read = acf_exception_read,
-};
+static struct ast_custom_function exception_function("EXCEPTION", acf_exception_read);
 
 static char *handle_show_functions(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
@@ -3076,7 +3073,7 @@
 	}
 
 	syntax_size = strlen(S_OR(acf->syntax, "Not Available")) + AST_TERM_MAX_ESCAPE_CHARS;
-	if (!(syntax = ast_malloc(syntax_size))) {
+	if (!(syntax = (char *) ast_malloc(syntax_size))) {
 		ast_cli(a->fd, "Memory allocation failure!\n");
 		return CLI_FAILURE;
 	}
@@ -3099,16 +3096,16 @@
 #endif
 	{
 		synopsis_size = strlen(S_OR(acf->synopsis, "Not Available")) + AST_TERM_MAX_ESCAPE_CHARS;
-		synopsis = ast_malloc(synopsis_size);
+		synopsis = (char *) ast_malloc(synopsis_size);
 
 		description_size = strlen(S_OR(acf->desc, "Not Available")) + AST_TERM_MAX_ESCAPE_CHARS;
-		description = ast_malloc(description_size);
+		description = (char *) ast_malloc(description_size);
 
 		arguments_size = strlen(S_OR(acf->arguments, "Not Available")) + AST_TERM_MAX_ESCAPE_CHARS;
-		arguments = ast_malloc(arguments_size);
+		arguments = (char *) ast_malloc(arguments_size);
 
 		seealso_size = strlen(S_OR(acf->seealso, "Not Available")) + AST_TERM_MAX_ESCAPE_CHARS;
-		seealso = ast_malloc(seealso_size);
+		seealso = (char *) ast_malloc(seealso_size);
 
 		/* check allocated memory. */
 		if (!synopsis || !description || !arguments || !seealso) {
@@ -3415,7 +3412,7 @@
 			whereweare += (len + 3);
 
 			if (!var)
-				var = alloca(VAR_BUF_SIZE);
+				var = (char *) alloca(VAR_BUF_SIZE);
 
 			/* Store variable name (and truncate) */
 			ast_copy_string(var, vars, len + 1);
@@ -3424,7 +3421,7 @@
 			if (needsub) {
 				size_t used;
 				if (!ltmp)
-					ltmp = alloca(VAR_BUF_SIZE);
+					ltmp = (char *) alloca(VAR_BUF_SIZE);
 
 				pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1, &used);
 				vars = ltmp;
@@ -3433,7 +3430,7 @@
 			}
 
 			if (!workspace)
-				workspace = alloca(VAR_BUF_SIZE);
+				workspace = (char *) alloca(VAR_BUF_SIZE);
 
 			workspace[0] = '\0';
 
@@ -3503,7 +3500,7 @@
 			whereweare += (len + 3);
 
 			if (!var)
-				var = alloca(VAR_BUF_SIZE);
+				var = (char *) alloca(VAR_BUF_SIZE);
 
 			/* Store variable name (and truncate) */
 			ast_copy_string(var, vars, len + 1);
@@ -3512,7 +3509,7 @@
 			if (needsub) {
 				size_t used;
 				if (!ltmp)
-					ltmp = alloca(VAR_BUF_SIZE);
+					ltmp = (char *) alloca(VAR_BUF_SIZE);
 
 				pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1, &used);
 				vars = ltmp;
@@ -3554,12 +3551,12 @@
 		return;
 
 	/* No variables or expressions in e->data, so why scan it? */
-	if ((!(tmp = strchr(e->data, '$'))) || (!strstr(tmp, "${") && !strstr(tmp, "$["))) {
-		ast_copy_string(passdata, e->data, datalen);
+	if ((!(tmp = strchr((const char *) e->data, '$'))) || (!strstr(tmp, "${") && !strstr(tmp, "$["))) {
+		ast_copy_string(passdata, (const char *) e->data, datalen);
 		return;
 	}
 
-	pbx_substitute_variables_helper(c, e->data, passdata, datalen - 1);
+	pbx_substitute_variables_helper(c, (const char *) e->data, passdata, datalen - 1);
 }
 
 /*! 
@@ -3587,7 +3584,7 @@
 	struct ast_exten *e;
 	struct ast_app *app;
 	int res;
-	struct pbx_find_info q = { .stacklen = 0 }; /* the rest is reset in pbx_find_extension */
+	struct pbx_find_info q = { { NULL, },  }; /* the rest is reset in pbx_find_extension */
 	char passdata[EXT_DATA_SIZE];
 
 	int matching_action = (action == E_MATCH || action == E_CANMATCH || action == E_MATCHMORE);
@@ -3689,7 +3686,7 @@
 /*! \brief Find hint for given extension in context */
 static struct ast_exten *ast_hint_extension_nolock(struct ast_channel *c, const char *context, const char *exten)
 {
-	struct pbx_find_info q = { .stacklen = 0 }; /* the rest is set in pbx_find_context */
+	struct pbx_find_info q = { { NULL, },  }; /* the rest is set in pbx_find_context */
 	return pbx_find_extension(c, NULL, &q, context, exten, PRIORITY_HINT, NULL, "", E_MATCH);
 }
 
@@ -3749,9 +3746,7 @@
 /*! \brief Return extension_state as string */
 const char *ast_extension_state2str(int extension_state)
 {
-	int i;
-
-	for (i = 0; (i < ARRAY_LEN(extension_states)); i++) {
+	for (unsigned int i = 0; (i < ARRAY_LEN(extension_states)); i++) {
 		if (extension_states[i].extension_state == extension_state)
 			return extension_states[i].text;
 	}
@@ -3773,7 +3768,7 @@
 static int handle_statechange(void *datap)
 {
 	struct ast_hint *hint;
-	struct statechange *sc = datap;
+	struct statechange *sc = (struct statechange *) datap;
 	AST_RWLIST_RDLOCK(&hints);
 
 	AST_RWLIST_TRAVERSE(&hints, hint, list) {
@@ -3801,12 +3796,12 @@
 
 		/* For general callbacks */
 		AST_LIST_TRAVERSE(&statecbs, cblist, entry) {
-			cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data);
+			cblist->callback(hint->exten->parent->name, hint->exten->exten, (ast_extension_states) state, (void *) cblist->data);
 		}
 
 		/* For extension callbacks */
 		AST_LIST_TRAVERSE(&hint->callbacks, cblist, entry) {
-			cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data);
+			cblist->callback(hint->exten->parent->name, hint->exten->exten, (ast_extension_states) state, (void *) cblist->data);
 		}
 
 		hint->laststate = state;	/* record we saw the change */
@@ -3837,7 +3832,7 @@
 		}
 
 		/* Now insert the callback */
-		if (!(cblist = ast_calloc(1, sizeof(*cblist)))) {
+		if (!(cblist = (struct ast_state_cb *) ast_calloc(1, sizeof(*cblist)))) {
 			AST_RWLIST_UNLOCK(&hints);
 			return -1;
 		}
@@ -3867,7 +3862,7 @@
 	 */
 	if (e->exten[0] == '_') {
 		ast_add_extension(e->parent->name, 0, exten, e->priority, e->label,
-			e->cidmatch, e->app, ast_strdup(e->data), ast_free_ptr,
+			e->cidmatch, e->app, ast_strdup((const char *) e->data), ast_free_ptr,
 			e->registrar);
 		e = ast_hint_extension(NULL, context, exten);
 		if (!e || e->exten[0] == '_') {
@@ -3890,7 +3885,7 @@
 	}
 
 	/* Now insert the callback in the callback list  */
-	if (!(cblist = ast_calloc(1, sizeof(*cblist)))) {
+	if (!(cblist = (struct ast_state_cb *) ast_calloc(1, sizeof(*cblist)))) {
 		AST_RWLIST_UNLOCK(&hints);
 		return -1;
 	}
@@ -3971,7 +3966,7 @@
 
 	ast_debug(2, "HINTS: Adding hint %s: %s\n", ast_get_extension_name(e), ast_get_extension_app(e));
 
-	if (!(hint = ast_calloc(1, sizeof(*hint)))) {
+	if (!(hint = (struct ast_hint *) ast_calloc(1, sizeof(*hint)))) {
 		AST_RWLIST_UNLOCK(&hints);
 		return -1;
 	}
@@ -4021,7 +4016,7 @@
 		while ((cblist = AST_LIST_REMOVE_HEAD(&hint->callbacks, entry))) {
 			/* Notify with -1 and remove all callbacks */
 			cblist->callback(hint->exten->parent->name, hint->exten->exten, 
-				AST_EXTENSION_DEACTIVATED, cblist->data);
+				AST_EXTENSION_DEACTIVATED, (void *) cblist->data);
 			ast_free(cblist);
 		}
 
@@ -4141,8 +4136,8 @@
 		/* XXX and now what ? */
 		ast_free(c->pbx);
 	}
-	if (!(c->pbx = ast_calloc(1, sizeof(*c->pbx))))
-		return -1;
+	if (!(c->pbx = (struct ast_pbx *) ast_calloc(1, sizeof(*c->pbx))))
+		return AST_PBX_FAILED;
 	/* Set reasonable defaults */
 	c->pbx->rtimeoutms = 10000;
 	c->pbx->dtimeoutms = 5000;
@@ -4368,7 +4363,7 @@
 		ast_hangup(c);
 	}
 
-	return 0;
+	return AST_PBX_SUCCESS;
 }
 
 /*! 
@@ -4441,7 +4436,7 @@
 	if (e->peer_label_table)
 		ast_hashtab_destroy(e->peer_label_table, 0);
 	if (e->datad)
-		e->datad(e->data);
+		e->datad((void *) e->data);
 	ast_free(e);
 }
 
@@ -4455,7 +4450,7 @@
 	   before invoking the function; it will be decremented when the
 	   PBX has finished running on the channel
 	 */
-	struct ast_channel *c = data;
+	struct ast_channel *c = (struct ast_channel *) data;
 
 	__ast_pbx_run(c, NULL);
 	decrease_call_count();
@@ -4556,7 +4551,7 @@
 	ast_copy_string(item.name, context, sizeof(item.name));
 
 	ast_rdlock_contexts();
-	c = ast_hashtab_lookup(contexts_table,&item);
+	c = (struct ast_context *) ast_hashtab_lookup(contexts_table,&item);
 
 #ifdef NOTNOW
 
@@ -4746,10 +4741,10 @@
 	ex.matchcid = matchcallerid && !ast_strlen_zero(callerid); /* don't say match if there's no callerid */
 	ex.cidmatch = callerid;
 	ast_copy_string(dummy_name, extension, sizeof(dummy_name));
-	exten = ast_hashtab_lookup(con->root_table, &ex);
+	exten = (struct ast_exten *) ast_hashtab_lookup(con->root_table, &ex);
 	if (exten) {
 		if (priority == 0) {
-			exten2 = ast_hashtab_remove_this_object(con->root_table, exten);
+			exten2 = (struct ast_exten *) ast_hashtab_remove_this_object(con->root_table, exten);
 			if (!exten2)
 				ast_log(LOG_ERROR,"Trying to delete the exten %s from context %s, but could not remove from the root_table\n", extension, con->name);
 			if (con->pattern_tree) {
@@ -4765,26 +4760,26 @@
 			}
 		} else {
 			ex.priority = priority;
-			exten2 = ast_hashtab_lookup(exten->peer_table, &ex);
+			exten2 = (struct ast_exten *) ast_hashtab_lookup(exten->peer_table, &ex);
 			if (exten2) {
 				
 				if (exten2->label) { /* if this exten has a label, remove that, too */
-					exten3 = ast_hashtab_remove_this_object(exten->peer_label_table,exten2);
+					exten3 = (struct ast_exten *) ast_hashtab_remove_this_object(exten->peer_label_table,exten2);
 					if (!exten3)
 						ast_log(LOG_ERROR,"Did not remove this priority label (%d/%s) from the peer_label_table of context %s, extension %s!\n", priority, exten2->label, con->name, exten2->exten);
 				}
 			
-				exten3 = ast_hashtab_remove_this_object(exten->peer_table, exten2);
+				exten3 = (struct ast_exten *) ast_hashtab_remove_this_object(exten->peer_table, exten2);
 				if (!exten3)
 					ast_log(LOG_ERROR,"Did not remove this priority (%d) from the peer_table of context %s, extension %s!\n", priority, con->name, exten2->exten);
 				if (exten2 == exten && exten2->peer) {
-					exten2 = ast_hashtab_remove_this_object(con->root_table, exten);
+					exten2 = (struct ast_exten *) ast_hashtab_remove_this_object(con->root_table, exten);
 					ast_hashtab_insert_immediate(con->root_table, exten2->peer);
 				}
 				if (ast_hashtab_size(exten->peer_table) == 0) {
 					/* well, if the last priority of an exten is to be removed,
 					   then, the extension is removed, too! */
-					exten3 = ast_hashtab_remove_this_object(con->root_table, exten);
+					exten3 = (struct ast_exten *) ast_hashtab_remove_this_object(con->root_table, exten);
 					if (!exten3)
 						ast_log(LOG_ERROR,"Did not remove this exten (%s) from the context root_table (%s) (priority %d)\n", exten->exten, con->name, priority);
 					if (con->pattern_tree) {
@@ -4888,7 +4883,7 @@
 	ast_rdlock_contexts();
 
 	strncpy(item.name,context,256);
-	c = ast_hashtab_lookup(contexts_table,&item);
+	c = (struct ast_context *) ast_hashtab_lookup(contexts_table,&item);
 	if (c)
 		ret = 0;
 
@@ -4926,7 +4921,7 @@
 	ast_rdlock_contexts();
 
 	strncpy(item.name, context, 256);
-	c = ast_hashtab_lookup(contexts_table,&item);
+	c = (struct ast_context *) ast_hashtab_lookup(contexts_table,&item);
 	if (c)
 		ret = 0;
 #ifdef NOTNOW
@@ -4949,7 +4944,7 @@
 }
 
 /*! \brief Dynamically register a new dial plan application */
-int ast_register_application2(const char *app, int (*execute)(struct ast_channel *, void *), const char *synopsis, const char *description, void *mod)
+int ast_register_application2(const char *app, int (*execute)(struct ast_channel *, const char *), const char *synopsis, const char *description, void *mod)
 {
 	struct ast_app *tmp, *cur = NULL;
 	char tmps[80];
@@ -4970,7 +4965,7 @@
 
 	length = sizeof(*tmp) + strlen(app) + 1;
 
-	if (!(tmp = ast_calloc(1, length))) {
+	if (!(tmp = (struct ast_app *) ast_calloc(1, length))) {
 		AST_RWLIST_UNLOCK(&apps);
 		return -1;
 	}
@@ -5019,7 +5014,7 @@
 
 	strcpy(tmp->name, app);
 	tmp->execute = execute;
-	tmp->module = mod;
+	tmp->module = (struct ast_module *) mod;
 
 	/* Store in alphabetical order */
 	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&apps, cur, list) {
@@ -5104,16 +5099,16 @@
 #endif
 	{
 		synopsis_size = strlen(S_OR(aa->synopsis, "Not Available")) + AST_TERM_MAX_ESCAPE_CHARS;
-		synopsis = ast_malloc(synopsis_size);
+		synopsis = (char *) ast_malloc(synopsis_size);
 
 		description_size = strlen(S_OR(aa->description, "Not Available")) + AST_TERM_MAX_ESCAPE_CHARS;
-		description = ast_malloc(description_size);
+		description = (char *) ast_malloc(description_size);
 
 		arguments_size = strlen(S_OR(aa->arguments, "Not Available")) + AST_TERM_MAX_ESCAPE_CHARS;
-		arguments = ast_malloc(arguments_size);
+		arguments = (char *) ast_malloc(arguments_size);
 
 		seealso_size = strlen(S_OR(aa->seealso, "Not Available")) + AST_TERM_MAX_ESCAPE_CHARS;
-		seealso = ast_malloc(seealso_size);
+		seealso = (char *) ast_malloc(seealso_size);
 
 		if (!synopsis || !description || !arguments || !seealso) {
 			goto return_cleanup;
@@ -5127,7 +5122,7 @@
 
 	/* Handle the syntax the same for both XML and raw docs */
 	syntax_size = strlen(S_OR(aa->syntax, "Not Available")) + AST_TERM_MAX_ESCAPE_CHARS;
-	if (!(syntax = ast_malloc(syntax_size))) {
+	if (!(syntax = (char *) ast_malloc(syntax_size))) {
 		goto return_cleanup;
 	}
 	term_color(syntax, S_OR(aa->syntax, "Not available"), COLOR_CYAN, 0, syntax_size);
@@ -5373,7 +5368,7 @@
 	int like = 0, describing = 0;
 	int total_match = 0; 	/* Number of matches in like clause */
 	int total_apps = 0; 	/* Number of apps registered */
-	static char* choices[] = { "like", "describing", NULL };
+	static char const* choices[] = { "like", "describing", NULL };
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -5502,7 +5497,7 @@
 	} else {
 		snprintf(buf, buflen, "%d. %s(%s)",
 			prio, ast_get_extension_app(e),
-			(!ast_strlen_zero(ast_get_extension_app_data(e)) ? (char *)ast_get_extension_app_data(e) : ""));
+			(!ast_strlen_zero(ast_get_extension_app_data(e)) ? ast_get_extension_app_data(e) : ""));
 	}
 }
 
@@ -5919,7 +5914,7 @@
 				if (prio == PRIORITY_HINT) {
 					astman_append(s, "Priority: hint\r\nApplication: %s\r\n", ast_get_extension_app(p));
 				} else {
-					astman_append(s, "Priority: %d\r\nApplication: %s\r\nAppData: %s\r\n", prio, ast_get_extension_app(p), (char *) ast_get_extension_app_data(p));
+					astman_append(s, "Priority: %d\r\nApplication: %s\r\nAppData: %s\r\n", prio, ast_get_extension_app(p), ast_get_extension_app_data(p));
 				}
 				astman_append(s, "Registrar: %s\r\n\r\n", ast_get_extension_registrar(e));
 			}
@@ -8243,7 +8238,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_proceeding(struct ast_channel *chan, void *data)
+static int pbx_builtin_proceeding(struct ast_channel *chan, const char *data)
 {
 	ast_indicate(chan, AST_CONTROL_PROCEEDING);
 	return 0;
@@ -8252,7 +8247,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_progress(struct ast_channel *chan, void *data)
+static int pbx_builtin_progress(struct ast_channel *chan, const char *data)
 {
 	ast_indicate(chan, AST_CONTROL_PROGRESS);
 	return 0;
@@ -8261,7 +8256,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_ringing(struct ast_channel *chan, void *data)
+static int pbx_builtin_ringing(struct ast_channel *chan, const char *data)
 {
 	ast_indicate(chan, AST_CONTROL_RINGING);
 	return 0;
@@ -8270,7 +8265,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_busy(struct ast_channel *chan, void *data)
+static int pbx_builtin_busy(struct ast_channel *chan, const char *data)
 {
 	ast_indicate(chan, AST_CONTROL_BUSY);
 	/* Don't change state of an UP channel, just indicate
@@ -8284,7 +8279,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_congestion(struct ast_channel *chan, void *data)
+static int pbx_builtin_congestion(struct ast_channel *chan, const char *data)
 {
 	ast_indicate(chan, AST_CONTROL_CONGESTION);
 	/* Don't change state of an UP channel, just indicate
@@ -8298,7 +8293,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_answer(struct ast_channel *chan, void *data)
+static int pbx_builtin_answer(struct ast_channel *chan, const char *data)
 {
 	int delay = 0;
 
@@ -8312,7 +8307,7 @@
 	return __ast_answer(chan, delay);
 }
 
-static int pbx_builtin_incomplete(struct ast_channel *chan, void *data)
+static int pbx_builtin_incomplete(struct ast_channel *chan, const char *data)
 {
 	char *options = data;
 	int answer = 1;
@@ -8342,7 +8337,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_resetcdr(struct ast_channel *chan, void *data)
+static int pbx_builtin_resetcdr(struct ast_channel *chan, const char *data)
 {
 	char *args;
 	struct ast_flags flags = { 0 };
@@ -8360,7 +8355,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_setamaflags(struct ast_channel *chan, void *data)
+static int pbx_builtin_setamaflags(struct ast_channel *chan, const char *data)
 {
 	/* Copy the AMA Flags as specified */
 	ast_cdr_setamaflags(chan, data ? data : "");
@@ -8370,7 +8365,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_hangup(struct ast_channel *chan, void *data)
+static int pbx_builtin_hangup(struct ast_channel *chan, const char *data)
 {
 	if (!ast_strlen_zero(data)) {
 		int cause;
@@ -8400,7 +8395,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_gotoiftime(struct ast_channel *chan, void *data)
+static int pbx_builtin_gotoiftime(struct ast_channel *chan, const char *data)
 {
 	char *s, *ts, *branch1, *branch2, *branch;
 	struct ast_timing timing;
@@ -8435,7 +8430,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_execiftime(struct ast_channel *chan, void *data)
+static int pbx_builtin_execiftime(struct ast_channel *chan, const char *data)
 {
 	char *s, *appname;
 	struct ast_timing timing;
@@ -8489,7 +8484,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_wait(struct ast_channel *chan, void *data)
+static int pbx_builtin_wait(struct ast_channel *chan, const char *data)
 {
 	double s;
 	int ms;
@@ -8505,7 +8500,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_waitexten(struct ast_channel *chan, void *data)
+static int pbx_builtin_waitexten(struct ast_channel *chan, const char *data)
 {
 	int ms, res;
 	double s;
@@ -8572,7 +8567,7 @@
 /*!
  * \ingroup applications
  */
-static int pbx_builtin_background(struct ast_channel *chan, void *data)
+static int pbx_builtin_background(struct ast_channel *chan, const char *data)
 {
 	int res = 0;
 	int mres = 0;
@@ -8655,7 +8650,7 @@
 /*! Goto
  * \ingroup applications
  */
-static int pbx_builtin_goto(struct ast_channel *chan, void *data)
+static int pbx_builtin_goto(struct ast_channel *chan, const char *data)
 {
 	int res = ast_parseable_goto(chan, data);
 	if (!res)
@@ -8824,7 +8819,7 @@
 		ast_rwlock_unlock(&globalslock);
 }
 
-int pbx_builtin_setvar(struct ast_channel *chan, void *data)
+int pbx_builtin_setvar(struct ast_channel *chan, const char *data)
 {
 	char *name, *value, *mydata;
 
@@ -8847,7 +8842,7 @@
 	return(0);
 }
 
-int pbx_builtin_setvar_multiple(struct ast_channel *chan, void *vdata)
+int pbx_builtin_setvar_multiple(struct ast_channel *chan, const char *vdata)
 {
 	char *data;
 	int x;
@@ -8883,7 +8878,7 @@
 	return 0;
 }
 
-int pbx_builtin_importvar(struct ast_channel *chan, void *data)
+int pbx_builtin_importvar(struct ast_channel *chan, const char *data)
 {
 	char *name;
 	char *value;
@@ -8920,7 +8915,7 @@
 	return(0);
 }
 
-static int pbx_builtin_noop(struct ast_channel *chan, void *data)
+static int pbx_builtin_noop(struct ast_channel *chan, const char *data)
 {
 	return 0;
 }
@@ -8947,7 +8942,7 @@
 	}
 }
 
-static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
+static int pbx_builtin_gotoif(struct ast_channel *chan, const char *data)
 {
 	char *condition, *branch1, *branch2, *branch;
 	char *stringp;
@@ -8971,7 +8966,7 @@
 	return pbx_builtin_goto(chan, branch);
 }
 
-static int pbx_builtin_saynumber(struct ast_channel *chan, void *data)
+static int pbx_builtin_saynumber(struct ast_channel *chan, const char *data)
 {
 	char tmp[256];
 	char *number = tmp;
@@ -8999,7 +8994,7 @@
 	return 0;
 }
 
-static int pbx_builtin_saydigits(struct ast_channel *chan, void *data)
+static int pbx_builtin_saydigits(struct ast_channel *chan, const char *data)
 {
 	int res = 0;
 
@@ -9008,7 +9003,7 @@
 	return res;
 }
 
-static int pbx_builtin_saycharacters(struct ast_channel *chan, void *data)
+static int pbx_builtin_saycharacters(struct ast_channel *chan, const char *data)
 {
 	int res = 0;
 
@@ -9017,7 +9012,7 @@
 	return res;
 }
 
-static int pbx_builtin_sayphonetic(struct ast_channel *chan, void *data)
+static int pbx_builtin_sayphonetic(struct ast_channel *chan, const char *data)
 {
 	int res = 0;
 
@@ -9200,7 +9195,7 @@
 	return e ? e->app : NULL;
 }
 
-void *ast_get_extension_app_data(struct ast_exten *e)
+const char *ast_get_extension_app_data(struct ast_exten *e)
 {
 	return e ? e->data : NULL;
 }




More information about the asterisk-commits mailing list