[asterisk-commits] seanbright: branch group/asterisk-cpp r168423 - /team/group/asterisk-cpp/main/

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


Author: seanbright
Date: Sat Jan 10 21:00:40 2009
New Revision: 168423

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

Modified:
    team/group/asterisk-cpp/main/config.c

Modified: team/group/asterisk-cpp/main/config.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/config.c?view=diff&rev=168423&r1=168422&r2=168423
==============================================================================
--- team/group/asterisk-cpp/main/config.c (original)
+++ team/group/asterisk-cpp/main/config.c Sat Jan 10 21:00:40 2009
@@ -54,7 +54,7 @@
 #define COMMENT_META ';'
 #define COMMENT_TAG '-'
 
-static char *extconfig_conf = "extconfig.conf";
+static const char *extconfig_conf = "extconfig.conf";
 
 
 /*! \brief Structure to keep comments for rewriting configuration files */
@@ -82,7 +82,7 @@
 
 static int init_appendbuf(void *data)
 {
-	struct ast_str **str = data;
+	struct ast_str **str = (struct ast_str **) data;
 	*str = ast_str_create(16);
 	return *str ? 0 : -1;
 }
@@ -99,7 +99,7 @@
 
 static void  CB_ADD_LEN(struct ast_str **cb, const char *str, int len)
 {
-	char *s = alloca(len + 1);
+	char *s = (char *) alloca(len + 1);
 	ast_copy_string(s, str, len);
 	ast_str_append(cb, 0, "%s", str);
 }
@@ -120,7 +120,7 @@
 	if (!buffer || !ast_str_strlen(buffer)) {
 		return NULL;
 	}
-	if ((x = ast_calloc(1, sizeof(*x) + ast_str_strlen(buffer) + 1))) {
+	if ((x = (struct ast_comment *) ast_calloc(1, sizeof(*x) + ast_str_strlen(buffer) + 1))) {
 		strcpy(x->cmt, ast_str_buffer(buffer)); /* SAFE */
 	}
 	return x;
@@ -156,7 +156,9 @@
 
 static int hashtab_compare_strings(void *a, void *b, int flags)
 {
-	const struct inclfile *ae = a, *be = b;
+	const struct inclfile
+        *ae = (struct inclfile *) a,
+        *be = (struct inclfile *) b;
 	return !strcmp(ae->fname, be->fname) ? CMP_MATCH | CMP_STOP : 0;
 }
 
@@ -229,9 +231,9 @@
 	int fn_len = strlen(filename) + 1;	
 
 #ifdef MALLOC_DEBUG
-	if ((variable = __ast_calloc(1, name_len + val_len + fn_len + sizeof(*variable), file, lineno, func))) {
+	if ((variable = (struct ast_variable *) __ast_calloc(1, name_len + val_len + fn_len + sizeof(*variable), file, lineno, func))) {
 #else
-	if ((variable = ast_calloc(1, name_len + val_len + fn_len + sizeof(*variable)))) {
+    if ((variable = (struct ast_variable *) ast_calloc(1, name_len + val_len + fn_len + sizeof(*variable)))) {
 #endif
 		char *dst = variable->stuff;	/* writable space starts here */
 		variable->name = strcpy(dst, name);
@@ -262,7 +264,7 @@
 	} else
 		*real_included_file_name = 0;
 	
-	inc = ast_calloc(1,sizeof(struct ast_config_include));
+	inc = (struct ast_config_include *) ast_calloc(1,sizeof(struct ast_config_include));
 	inc->include_location_file = ast_strdup(from_file);
 	inc->include_location_lineno = from_lineno;
 	if (!ast_strlen_zero(real_included_file_name))
@@ -444,32 +446,32 @@
 
 static struct ast_variable *variable_clone(const struct ast_variable *old)
 {
-	struct ast_variable *new = ast_variable_new(old->name, old->value, old->file);
-
-	if (new) {
-		new->lineno = old->lineno;
-		new->object = old->object;
-		new->blanklines = old->blanklines;
+	struct ast_variable *var = ast_variable_new(old->name, old->value, old->file);
+
+	if (var) {
+		var->lineno = old->lineno;
+		var->object = old->object;
+		var->blanklines = old->blanklines;
 		/* TODO: clone comments? */
 	}
 
-	return new;
+	return var;
 }
  
-static void move_variables(struct ast_category *old, struct ast_category *new)
-{
-	struct ast_variable *var = old->root;
-
-	old->root = NULL;
+static void move_variables(struct ast_category *oldcat, struct ast_category *newcat)
+{
+	struct ast_variable *var = oldcat->root;
+
+	oldcat->root = NULL;
 	/* we can just move the entire list in a single op */
-	ast_variable_append(new, var);
+	ast_variable_append(newcat, var);
 }
 
 struct ast_category *ast_category_new(const char *name, const char *in_file, int lineno) 
 {
 	struct ast_category *category;
 
-	if ((category = ast_calloc(1, sizeof(*category))))
+	if ((category = (struct ast_category *) ast_calloc(1, sizeof(*category))))
 		ast_copy_string(category->name, name, sizeof(category->name));
 	category->file = strdup(in_file);
 	category->lineno = lineno; /* if you don't know the lineno, set it to 999999 or something real big */
@@ -662,23 +664,24 @@
 	ast_copy_string(cat->name, name, sizeof(cat->name));
 }
 
-static void inherit_category(struct ast_category *new, const struct ast_category *base)
+static void inherit_category(struct ast_category *newcat, const struct ast_category *base)
 {
 	struct ast_variable *var;
-	struct ast_category_template_instance *x = ast_calloc(1,sizeof(struct ast_category_template_instance));
+	struct ast_category_template_instance *x =
+        (struct ast_category_template_instance *) ast_calloc(1,sizeof(struct ast_category_template_instance));
 
 	strcpy(x->name, base->name);
 	x->inst = base;
-	AST_LIST_INSERT_TAIL(&new->template_instances, x, next);
+	AST_LIST_INSERT_TAIL(&newcat->template_instances, x, next);
 	for (var = base->root; var; var = var->next)
-		ast_variable_append(new, variable_clone(var));
+		ast_variable_append(newcat, variable_clone(var));
 }
 
 struct ast_config *ast_config_new(void) 
 {
 	struct ast_config *config;
 
-	if ((config = ast_calloc(1, sizeof(*config))))
+	if ((config = (struct ast_config *) ast_calloc(1, sizeof(*config))))
 		config->max_include_level = MAX_INCLUDE_LEVEL;
 	return config;
 }
@@ -875,7 +878,7 @@
 			break;
 	}
 	if (!cfmtime) {
-		cfmtime = ast_calloc(1, sizeof(*cfmtime) + strlen(configfile) + 1 + strlen(who_asked) + 1);
+		cfmtime = (struct cache_file_mtime *) ast_calloc(1, sizeof(*cfmtime) + strlen(configfile) + 1 + strlen(who_asked) + 1);
 		if (!cfmtime) {
 			AST_LIST_UNLOCK(&cfmtime_head);
 			return;
@@ -901,7 +904,7 @@
 				return;
 			}
 		}
-		cfinclude = ast_calloc(1, sizeof(*cfinclude) + strlen(filename) + 1);
+		cfinclude = (struct cache_file_include *) ast_calloc(1, sizeof(*cfinclude) + strlen(filename) + 1);
 		if (!cfinclude) {
 			AST_LIST_UNLOCK(&cfmtime_head);
 			return;
@@ -1106,7 +1109,7 @@
 
 		if (c && c > cur && (*(c - 1) == '+')) {
 			struct ast_variable *var, *replace = NULL;
-			struct ast_str **str = ast_threadstorage_get(&appendbuf, sizeof(*str));
+			struct ast_str **str = (struct ast_str **) ast_threadstorage_get(&appendbuf, sizeof(*str));
 
 			if (!str || !*str) {
 				return -1;
@@ -1224,8 +1227,7 @@
 				"Glob Expansion of pattern '%s' failed: Read error\n", fn);
 		else  {
 			/* loop over expanded files */
-			int i;
-			for (i=0; i<globbuf.gl_pathc; i++) {
+			for (size_t i = 0; i < globbuf.gl_pathc; i++) {
 				ast_copy_string(fn, globbuf.gl_pathv[i], sizeof(fn));
 #endif
 	/*
@@ -1250,7 +1252,7 @@
 					break;
 			}
 			if (!cfmtime) {
-				cfmtime = ast_calloc(1, sizeof(*cfmtime) + strlen(fn) + 1 + strlen(who_asked) + 1);
+				cfmtime = (struct cache_file_mtime *) ast_calloc(1, sizeof(*cfmtime) + strlen(fn) + 1 + strlen(who_asked) + 1);
 				if (!cfmtime)
 					continue;
 				AST_LIST_HEAD_INIT(&cfmtime->includes);
@@ -1271,15 +1273,14 @@
 				char fn2[256];
 #ifdef AST_INCLUDE_GLOB
 				int glob_return;
-				glob_t glob_buf = { .gl_offs = 0 };
+				glob_t glob_buf = { 0, NULL, 0 };
 				glob_return = glob(cfinclude->include, MY_GLOB_FLAGS, NULL, &glob_buf);
 				/* On error, we reparse */
 				if (glob_return == GLOB_NOSPACE || glob_return  == GLOB_ABORTED)
 					unchanged = 0;
 				else  {
 					/* loop over expanded files */
-					int j;
-					for (j = 0; j < glob_buf.gl_pathc; j++) {
+					for (size_t j = 0; j < glob_buf.gl_pathc; j++) {
 						ast_copy_string(fn2, glob_buf.gl_pathv[j], sizeof(fn2));
 #else
 						ast_copy_string(fn2, cfinclude->include);
@@ -1298,7 +1299,7 @@
 
 			if (unchanged) {
 				AST_LIST_UNLOCK(&cfmtime_head);
-				return CONFIG_STATUS_FILEUNCHANGED;
+				return (struct ast_config *) CONFIG_STATUS_FILEUNCHANGED;
 			}
 		}
 		if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE))
@@ -1400,7 +1401,7 @@
 					char *buffer = ast_strip(process_buf);
 					if (!ast_strlen_zero(buffer)) {
 						if (process_text_line(cfg, &cat, buffer, lineno, fn, flags, comment_buffer, lline_buffer, suggested_include_file, &last_cat, &last_var, who_asked)) {
-							cfg = CONFIG_STATUS_FILEINVALID;
+							cfg = (struct ast_config *) CONFIG_STATUS_FILEINVALID;
 							break;
 						}
 					}
@@ -1502,9 +1503,9 @@
 	fprintf(f1, ";!\n");
 }
 
-static void   inclfile_destroy(void *obj)
-{
-	const struct inclfile *o = obj;
+static void inclfile_destroy(void *obj)
+{
+	const struct inclfile *o = (struct inclfile *) obj;
 
 	if (o->fname)
 		free(o->fname);
@@ -1525,10 +1526,10 @@
 	else
 		snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, file);
 	lookup.fname = fn;
-	*fi = ao2_find(fileset, &lookup, OBJ_POINTER);
+	*fi = (struct inclfile *) ao2_find(fileset, &lookup, OBJ_POINTER);
 	if (!(*fi)) {
 		/* set up a file scratch pad */
-		struct inclfile *fx = ao2_alloc(sizeof(struct inclfile), inclfile_destroy);
+		struct inclfile *fx = (struct inclfile *) ao2_alloc(sizeof(struct inclfile), inclfile_destroy);
 		fx->fname = ast_strdup(fn);
 		fx->lineno = 1;
 		*fi = fx;
@@ -1849,7 +1850,7 @@
 	if (table)
 		length += strlen(table) + 1;
 
-	if (!(map = ast_calloc(1, length)))
+	if (!(map = (struct ast_config_map *) ast_calloc(1, length)))
 		return -1;
 
 	map->name = map->stuff;
@@ -1941,21 +1942,21 @@
 	return 0;
 }
 
-int ast_config_engine_register(struct ast_config_engine *new) 
+int ast_config_engine_register(struct ast_config_engine *engine)
 {
 	struct ast_config_engine *ptr;
 
 	ast_mutex_lock(&config_lock);
 
 	if (!config_engine_list) {
-		config_engine_list = new;
+		config_engine_list = engine;
 	} else {
 		for (ptr = config_engine_list; ptr->next; ptr=ptr->next);
-		ptr->next = new;
+		ptr->next = engine;
 	}
 
 	ast_mutex_unlock(&config_lock);
-	ast_log(LOG_NOTICE,"Registered Config Engine %s\n", new->name);
+	ast_log(LOG_NOTICE, "Registered Config Engine %s\n", engine->name);
 
 	return 1;
 }
@@ -2018,8 +2019,8 @@
 }
 
 static struct ast_config_engine text_file_engine = {
-	.name = "text",
-	.load_func = config_text_file_load,
+	"text",
+	config_text_file_load
 };
 
 struct ast_config *ast_config_internal_load(const char *filename, struct ast_config *cfg, struct ast_flags flags, const char *suggested_include_file, const char *who_asked)
@@ -2280,7 +2281,7 @@
 	switch (flags & PARSE_TYPE) {
 	case PARSE_INT32:
 	    {
-		int32_t *result = p_result;
+        int32_t *result = (int32_t *) p_result;
 		int32_t x, def = result ? *result : 0,
 			high = (int32_t)0x7fffffff,
 			low  = (int32_t)0x80000000;
@@ -2307,7 +2308,7 @@
 
 	case PARSE_UINT32:
 	    {
-		uint32_t *result = p_result;
+        uint32_t *result = (uint32_t *) p_result;
 		uint32_t x, def = result ? *result : 0,
 			low = 0, high = (uint32_t)~0;
 		/* optional argument: first default value, then range */
@@ -2333,7 +2334,7 @@
 
 	case PARSE_DOUBLE:
 	    {
-		double *result = p_result;
+            double *result = (double *) p_result;
 		double x, def = result ? *result : 0,
 			low = -HUGE_VAL, high = HUGE_VAL;
 
@@ -2378,7 +2379,7 @@
 		 * honor the ports flag setting, assign default value
 		 * in case of errors or field unset.
 		 */
-		flags &= PARSE_PORT_MASK; /* the only flags left to process */
+		flags = (ast_parse_flags) (flags & PARSE_PORT_MASK); /* the only flags left to process */
 		if (port) {
 			if (flags == PARSE_PORT_FORBID) {
 				error = 1;	/* port was forbidden */
@@ -2453,7 +2454,8 @@
 static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct cache_file_mtime *cfmtime;
-	char *prev = "", *completion_value = NULL;
+	const char *prev = "";
+    char *completion_value = NULL;
 	int wordlen, which = 0;
 
 	switch (cmd) {
@@ -2502,7 +2504,7 @@
 	AST_LIST_LOCK(&cfmtime_head);
 	AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
 		if (!strcmp(cfmtime->filename, a->argv[2])) {
-			char *buf = alloca(strlen("module reload ") + strlen(cfmtime->who_asked) + 1);
+			char *buf = (char *) alloca(strlen("module reload ") + strlen(cfmtime->who_asked) + 1);
 			sprintf(buf, "module reload %s", cfmtime->who_asked);
 			ast_cli_command(a->fd, buf);
 		}




More information about the asterisk-commits mailing list