[asterisk-commits] mmichelson: branch mmichelson/queue-reset r166860 - /team/mmichelson/queue-re...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 29 11:44:15 CST 2008


Author: mmichelson
Date: Mon Dec 29 11:44:14 2008
New Revision: 166860

URL: http://svn.digium.com/view/asterisk?view=rev&rev=166860
Log:
A few fixups to the code, but no functional changes

* Fix coding guidelines items such as spaces after if
  and braces on single-line ifs

* Change all uses of bitwise logic to use the ast_flags
  API.


Modified:
    team/mmichelson/queue-reset/apps/app_queue.c

Modified: team/mmichelson/queue-reset/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/apps/app_queue.c?view=diff&rev=166860&r1=166859&r2=166860
==============================================================================
--- team/mmichelson/queue-reset/apps/app_queue.c (original)
+++ team/mmichelson/queue-reset/apps/app_queue.c Mon Dec 29 11:44:14 2008
@@ -5546,7 +5546,7 @@
 /* Once we have isolated a queue within reload_queues, we call this. This will either
  * reload information for the queue or if we're just reloading member information, we'll just
  * reload that without touching other settings within the queue */
-static void reload_single_queue(struct ast_config *cfg, enum queue_reload_mask mask, const char *queuename)
+static void reload_single_queue(struct ast_config *cfg, struct ast_flags *mask, const char *queuename)
 {
 	int new;
 	struct call_queue *q = NULL;
@@ -5556,8 +5556,8 @@
 	};
 	const char *tmpvar;
 	struct ao2_iterator mem_iter;
-	const int queue_reload = mask & QUEUE_RELOAD;
-	const int member_reload = mask & QUEUE_RELOAD_MEMBER;
+	const int queue_reload = ast_test_flag(mask, QUEUE_RELOAD);
+	const int member_reload = ast_test_flag(mask, QUEUE_RELOAD_MEMBER);
 	int prev_weight = 0;
 	struct member *cur;
 	struct ast_variable *var;
@@ -5658,14 +5658,14 @@
 }
 
 
-static int reload_queues(int reload, enum queue_reload_mask mask, const char *queuename)
+static int reload_queues(int reload, struct ast_flags *mask, const char *queuename)
 {
 	struct call_queue *q;
 	struct ast_config *cfg;
 	char *cat;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 	struct ao2_iterator queue_iter;
-	const int queue_reload = mask & QUEUE_RELOAD;
+	const int queue_reload = ast_test_flag(mask, QUEUE_RELOAD);
 
 	if (!(cfg = ast_config_load("queues.conf", config_flags))) {
 		ast_log(LOG_NOTICE, "No call queueing config file (queues.conf), so no call queues\n");
@@ -5730,14 +5730,17 @@
 	}
 }
 
-static int reload_handler(int reload, enum queue_reload_mask mask, const char *queuename)
-{
-	if (mask & QUEUE_RELOAD_RULES)
+static int reload_handler(int reload, struct ast_flags *mask, const char *queuename)
+{
+	if (ast_test_flag(mask, QUEUE_RELOAD_RULES)) {
 		reload_queue_rules(reload);
-	if (mask & QUEUE_RESET_STATS)
+	}
+	if (ast_test_flag(mask, QUEUE_RESET_STATS)) {
 		clear_stats(queuename);
-	if (mask & (QUEUE_RELOAD | QUEUE_RELOAD_MEMBER))
+	}
+	if (ast_test_flag(mask, (QUEUE_RELOAD | QUEUE_RELOAD_MEMBER))) {
 		reload_queues(reload, mask, queuename);
+	}
 	return 1;
 }
 
@@ -6262,36 +6265,44 @@
 
 static int manager_queue_reload(struct mansession *s, const struct message *m)
 {
-	enum queue_reload_mask mask = QUEUE_RELOAD_ALL;
+	struct ast_flags mask;
 	const char *queuename = NULL;
+
+	ast_set_flag(&mask, AST_FLAGS_ALL);
 	
 	queuename = astman_get_header(m, "Queue");
 	if (!strcasecmp(S_OR(astman_get_header(m, "Reset"), ""), "no"))
-		mask &= ~QUEUE_RESET_STATS;
+		ast_clear_flag(&mask, QUEUE_RESET_STATS);
 	if (!strcasecmp(S_OR(astman_get_header(m, "Members"), ""), "no"))
-		mask &= ~QUEUE_RELOAD_MEMBER;
+		ast_clear_flag(&mask, QUEUE_RELOAD_MEMBER);
 	if (!strcasecmp(S_OR(astman_get_header(m, "Rules"), ""), "no"))
-		mask &= ~QUEUE_RELOAD_RULES;
-
-	reload_handler(1, mask, queuename);
+		ast_clear_flag(&mask, QUEUE_RELOAD_RULES);
+
+	reload_handler(1, &mask, queuename);
 	return 0;
 }
 
 static int manager_queue_reset(struct mansession *s, const struct message *m)
 {
 	const char *queuename = NULL;
+	struct ast_flags mask = {0,};
+	
 	queuename = astman_get_header(m, "Queue");
-
-	reload_handler(1, QUEUE_RESET_STATS, queuename);
+	ast_set_flag(&mask, QUEUE_RESET_STATS);
+
+	reload_handler(1, &mask, queuename);
 	return 0;
 }
 
 static int manager_queue_member_reload(struct mansession *s, const struct message *m)
 {
 	const char *queuename = NULL;
+	struct ast_flags mask = {0,};
+
 	queuename = astman_get_header(m, "Queue");
-
-	reload_handler(1, QUEUE_RELOAD_MEMBER, queuename);
+	ast_set_flag(&mask, QUEUE_RELOAD_MEMBER);
+
+	reload_handler(1, &mask, queuename);
 	return 0;
 }
 
@@ -6703,6 +6714,8 @@
 
 static char *handle_queue_rule_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
+	struct ast_flags mask = {0,};
+
 	switch (cmd) {
 		case CLI_INIT:
 			e->command = "queue rules reload";
@@ -6713,13 +6726,16 @@
 		case CLI_GENERATE:
 			return NULL;
 	}
-	reload_handler(1, QUEUE_RELOAD_RULES, NULL);
+
+	ast_set_flag(&mask, QUEUE_RELOAD_RULES);
+	reload_handler(1, &mask, NULL);
 	return CLI_SUCCESS;
 }
 
 static char *handle_queue_reset(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	char *queuename = NULL;
+	struct ast_flags mask = {0,};
 	switch(cmd) {
 		case CLI_INIT:
 			e->command = "queue reset stats";
@@ -6741,13 +6757,15 @@
 	if (a->argc == 4) /*queue specified*/
 		queuename = a->argv[3];
 
-	reload_handler(1, QUEUE_RESET_STATS, queuename);
+	ast_set_flag(&mask, QUEUE_RESET_STATS);
+	reload_handler(1, &mask, queuename);
 	return CLI_SUCCESS;
 }
 
 static char *handle_queue_member_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	char *queuename = NULL;
+	struct ast_flags mask = {0,};
 	switch(cmd) {
 		case CLI_INIT:
 			e->command = "queue member reload\n";
@@ -6769,13 +6787,14 @@
 	if (a->argc == 4) /*queue specified*/
 		queuename = a->argv[3];
 
-	reload_handler(1, QUEUE_RELOAD_MEMBER, queuename);
+	ast_set_flag(&mask, QUEUE_RELOAD_MEMBER);
+	reload_handler(1, &mask, queuename);
 	return CLI_SUCCESS;
 }
 
 static char *handle_queue_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	enum queue_reload_mask mask = QUEUE_RELOAD_ALL;
+	struct ast_flags mask;
 	int i;
 	char *queuename = NULL;
 	switch (cmd) {
@@ -6795,19 +6814,21 @@
 	if (a->argc < 2 || a->argc > 6)
 		return CLI_SHOWUSAGE;
 
+	ast_set_flag(&mask, AST_FLAGS_ALL);
+
 	if (a->argc == 2) {
 		/*Reload everything*/
-		reload_handler(1, mask, NULL);
+		reload_handler(1, &mask, NULL);
 		return CLI_SUCCESS;
 	}
 
 	for (i = 2; i < a->argc; i++) {
-		if(!strcasecmp(a->argv[i], "nomembers"))
-			mask &= ~QUEUE_RELOAD_MEMBER;
-		else if(!strcasecmp(a->argv[i], "norules"))
-			mask &= ~QUEUE_RELOAD_RULES;
-		else if(!strcasecmp(a->argv[i], "noreset")) {
-			mask &= ~QUEUE_RESET_STATS;
+		if (!strcasecmp(a->argv[i], "nomembers")) {
+			ast_clear_flag(&mask, QUEUE_RELOAD_MEMBER);
+		} else if (!strcasecmp(a->argv[i], "norules")) {
+			ast_clear_flag(&mask, QUEUE_RELOAD_RULES);
+		} else if (!strcasecmp(a->argv[i], "noreset")) {
+			ast_clear_flag(&mask, QUEUE_RESET_STATS);
 		} else {
 			/*They must have specified a queue*/
 			if (queuename)
@@ -6818,7 +6839,7 @@
 		}
 	}
 
-	reload_handler(1, mask, queuename);
+	reload_handler(1, &mask, queuename);
 
 	return CLI_SUCCESS;
 }
@@ -6898,12 +6919,14 @@
 {
 	int res;
 	struct ast_context *con;
+	struct ast_flags mask = {0,};
 
 	queues = ao2_container_alloc(MAX_QUEUE_BUCKETS, queue_hash_cb, queue_cmp_cb);
 
 	use_weight = 0;
 
-	if (!reload_handler(0, QUEUE_RELOAD_ALL, NULL))
+	ast_set_flag(&mask, AST_FLAGS_ALL);
+	if (!reload_handler(0, &mask, NULL))
 		return AST_MODULE_LOAD_DECLINE;
 
 	con = ast_context_find_or_create(NULL, NULL, "app_queue_gosub_virtual_context", "app_queue");
@@ -6956,8 +6979,10 @@
 
 static int reload(void)
 {
+	struct ast_flags mask = {0,};
 	ast_unload_realtime("queue_members");
-	reload_handler(1, QUEUE_RELOAD_ALL, NULL);
+	ast_set_flag(&mask, AST_FLAGS_ALL);
+	reload_handler(1, &mask, NULL);
 	return 0;
 }
 




More information about the asterisk-commits mailing list