[asterisk-commits] branch group/new_loader_completion r34601 - in /team/group/new_loader_complet...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Jun 18 06:37:42 MST 2006


Author: kpfleming
Date: Sun Jun 18 08:37:41 2006
New Revision: 34601

URL: http://svn.digium.com/view/asterisk?rev=34601&view=rev
Log:
update to trunk, plus various other changes
restore ability to extract application descriptions for menuselect usage

Added:
    team/group/new_loader_completion/build_tools/get_makeopts
      - copied unchanged from r34577, trunk/build_tools/get_makeopts
    team/group/new_loader_completion/build_tools/get_moduleinfo
      - copied unchanged from r34577, trunk/build_tools/get_moduleinfo
Removed:
    team/group/new_loader_completion/build_tools/get_moduledeps
Modified:
    team/group/new_loader_completion/   (props changed)
    team/group/new_loader_completion/CREDITS
    team/group/new_loader_completion/Makefile
    team/group/new_loader_completion/abstract_jb.c
    team/group/new_loader_completion/agi/Makefile
    team/group/new_loader_completion/apps/Makefile
    team/group/new_loader_completion/apps/app_amd.c
    team/group/new_loader_completion/apps/app_chanspy.c
    team/group/new_loader_completion/apps/app_dial.c
    team/group/new_loader_completion/apps/app_dumpchan.c
    team/group/new_loader_completion/apps/app_ivrdemo.c
    team/group/new_loader_completion/apps/app_queue.c
    team/group/new_loader_completion/apps/app_rpt.c
    team/group/new_loader_completion/apps/app_skel.c
    team/group/new_loader_completion/apps/app_voicemail.c
    team/group/new_loader_completion/build_tools/Makefile
    team/group/new_loader_completion/build_tools/cflags.xml
    team/group/new_loader_completion/build_tools/menuselect.c
    team/group/new_loader_completion/build_tools/menuselect.h
    team/group/new_loader_completion/build_tools/menuselect_curses.c
    team/group/new_loader_completion/build_tools/prep_moduledeps
    team/group/new_loader_completion/cdr/Makefile
    team/group/new_loader_completion/channels/Makefile
    team/group/new_loader_completion/channels/chan_agent.c
    team/group/new_loader_completion/channels/chan_iax2.c
    team/group/new_loader_completion/channels/chan_local.c
    team/group/new_loader_completion/channels/chan_misdn.c
    team/group/new_loader_completion/channels/chan_sip.c
    team/group/new_loader_completion/channels/chan_zap.c
    team/group/new_loader_completion/channels/misdn/isdn_lib.c
    team/group/new_loader_completion/channels/misdn/isdn_lib.h
    team/group/new_loader_completion/codecs/Makefile
    team/group/new_loader_completion/configs/indications.conf.sample
    team/group/new_loader_completion/configure
    team/group/new_loader_completion/configure.ac
    team/group/new_loader_completion/doc/radius.txt
    team/group/new_loader_completion/file.c
    team/group/new_loader_completion/fixedjitterbuf.c
    team/group/new_loader_completion/formats/Makefile
    team/group/new_loader_completion/funcs/Makefile
    team/group/new_loader_completion/include/asterisk/abstract_jb.h
    team/group/new_loader_completion/include/asterisk/plc.h
    team/group/new_loader_completion/include/asterisk/udptl.h
    team/group/new_loader_completion/jitterbuf.c
    team/group/new_loader_completion/pbx.c
    team/group/new_loader_completion/pbx/Makefile
    team/group/new_loader_completion/plc.c
    team/group/new_loader_completion/res/Makefile
    team/group/new_loader_completion/res/res_odbc.c
    team/group/new_loader_completion/res/res_osp.c
    team/group/new_loader_completion/res/res_smdi.c
    team/group/new_loader_completion/res/res_snmp.c
    team/group/new_loader_completion/udptl.c
    team/group/new_loader_completion/utils/Makefile

Propchange: team/group/new_loader_completion/
------------------------------------------------------------------------------
    automerge = yeah

Propchange: team/group/new_loader_completion/
------------------------------------------------------------------------------
Binary property 'branch-1.2-blocked' - no diff available.

Propchange: team/group/new_loader_completion/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/group/new_loader_completion/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Jun 18 08:37:41 2006
@@ -1,1 +1,1 @@
-/trunk:1-33954
+/trunk:1-34577

Modified: team/group/new_loader_completion/CREDITS
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/CREDITS?rev=34601&r1=34600&r2=34601&view=diff
==============================================================================
--- team/group/new_loader_completion/CREDITS (original)
+++ team/group/new_loader_completion/CREDITS Sun Jun 18 08:37:41 2006
@@ -27,8 +27,11 @@
 * Thanks to QuickNet Technologies for their donation of an Internet
 PhoneJack and Linejack card to the project.  (http://www.quicknet.net)
 
-* Thanks to VoipSupply for their donation of Sipuras to the project for
-	t38 testing. (http://www.voipsupply.com)
+* Thanks to VoipSupply for their donation of Sipura ATAs to the project for
+T.38 testing. (http://www.voipsupply.com)
+
+* Thanks to Grandstream for their donation of ATAs to the project for
+T.38 testing. (http://www.grandstream.com)
 
 === MISCELLANEOUS PATCHES ===
 Jim Dixon - Zapata Telephony and app_rpt

Modified: team/group/new_loader_completion/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/Makefile?rev=34601&r1=34600&r2=34601&view=diff
==============================================================================
--- team/group/new_loader_completion/Makefile (original)
+++ team/group/new_loader_completion/Makefile Sun Jun 18 08:37:41 2006
@@ -145,13 +145,13 @@
 OPTIMIZE+=-O6
   else
     # Stack backtraces, while useful for debugging, are incompatible with optimizations
-    ifeq (${OSARCH},Linux)
+    ifeq ($(OSARCH),Linux)
       CFLAGS+=-DSTACK_BACKTRACES
     endif
   endif
 else
   # Stack backtraces, while useful for debugging, are incompatible with optimizations
-  ifeq (${OSARCH},Linux)
+  ifeq ($(OSARCH),Linux)
     CFLAGS+=-DSTACK_BACKTRACES
   endif
 endif
@@ -668,7 +668,7 @@
 adsi:
 	mkdir -p $(DESTDIR)$(ASTETCDIR)
 	for x in configs/*.adsi; do \
-		if [ ! -f $(DESTDIR)$(ASTETCDIRX)/$$x ]; then \
+		if [ ! -f $(DESTDIR)$(ASTETCDIR)/$$x ]; then \
 			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x` ; \
 		fi ; \
 	done

Modified: team/group/new_loader_completion/abstract_jb.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/abstract_jb.c?rev=34601&r1=34600&r2=34601&view=diff
==============================================================================
--- team/group/new_loader_completion/abstract_jb.c (original)
+++ team/group/new_loader_completion/abstract_jb.c Sun Jun 18 08:37:41 2006
@@ -5,8 +5,6 @@
  *
  * Contributors:
  * Slav Klenov <slav at securax.org>
- *
- * Copyright on this file is disclaimed to Digium for inclusion in Asterisk
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -17,6 +15,9 @@
  * This program is free software, distributed under the terms of
  * the GNU General Public License Version 2. See the LICENSE file
  * at the top of the source tree.
+ *
+ * A license has been granted to Digium (via disclaimer) for the use of
+ * this code.
  */
 
 /*! \file

Modified: team/group/new_loader_completion/agi/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/agi/Makefile?rev=34601&r1=34600&r2=34601&view=diff
==============================================================================
--- team/group/new_loader_completion/agi/Makefile (original)
+++ team/group/new_loader_completion/agi/Makefile Sun Jun 18 08:37:41 2006
@@ -18,7 +18,7 @@
   LIBS=-lsocket -lnsl ../strcompat.o
 endif
 
-all: depend $(AGIS)
+all: $(AGIS)
 
 install: all
 	mkdir -p $(DESTDIR)$(AGI_DIR)

Modified: team/group/new_loader_completion/apps/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/apps/Makefile?rev=34601&r1=34600&r2=34601&view=diff
==============================================================================
--- team/group/new_loader_completion/apps/Makefile (original)
+++ team/group/new_loader_completion/apps/Makefile Sun Jun 18 08:37:41 2006
@@ -15,20 +15,13 @@
 
 SELECTED_MODS:=$(filter-out $(MENUSELECT_APPS),$(patsubst %.c,%,$(wildcard app_*.c)))
 
-# If you have UnixODBC you can use ODBC voicemail
-# storage
-#
-# Uncomment to use ODBC storage
-#CFLAGS+=-DUSE_ODBC_STORAGE
-# Uncomment for extended ODBC voicemail storage
-#CFLAGS+=-DEXTENDED_ODBC_STORAGE
-# See doc/README.odbcstorage for more information
-
 MODS:=$(patsubst %,%.so,$(SELECTED_MODS))
 
 $(foreach mod,$(patsubst %.so,%,$(MODS)),$(mod).o): CFLAGS+=-DAST_MODULE=\"$(patsubst %.o,%,$@)\"
 
-all: depend $(MODS)
+app_voicemail.o: CFLAGS+=$(patsubst %,-D%,$(MENUSELECT_app_voicemail))
+
+all: $(MODS)
 
 clean-depend:
 	rm -f .depend
@@ -47,9 +40,6 @@
 
 install: all
 	for x in $(MODS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
-	rm -f $(DESTDIR)$(MODULES_DIR)/app_cut.so
-	rm -f $(DESTDIR)$(MODULES_DIR)/app_datetime.so
-	rm -f $(DESTDIR)$(MODULES_DIR)/app_qcall.so
 
 uninstall:
 

Modified: team/group/new_loader_completion/apps/app_amd.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/apps/app_amd.c?rev=34601&r1=34600&r2=34601&view=diff
==============================================================================
--- team/group/new_loader_completion/apps/app_amd.c (original)
+++ team/group/new_loader_completion/apps/app_amd.c Sun Jun 18 08:37:41 2006
@@ -4,8 +4,6 @@
  * Copyright (C) 2003 - 2006, Aheeva Technology.
  *
  * Claude Klimos (claude.klimos at aheeva.com)
- *
- * Disclaimed to Digium
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -16,6 +14,9 @@
  * This program is free software, distributed under the terms of
  * the GNU General Public License Version 2. See the LICENSE file
  * at the top of the source tree.
+ *
+ * A license has been granted to Digium (via disclaimer) for the use of
+ * this code.
  */
 
 #include "asterisk.h"

Modified: team/group/new_loader_completion/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/apps/app_chanspy.c?rev=34601&r1=34600&r2=34601&view=diff
==============================================================================
--- team/group/new_loader_completion/apps/app_chanspy.c (original)
+++ team/group/new_loader_completion/apps/app_chanspy.c Sun Jun 18 08:37:41 2006
@@ -4,7 +4,8 @@
  * Copyright (C) 2005 Anthony Minessale II (anthmct at yahoo.com)
  * Copyright (C) 2005 - 2006, Digium, Inc.
  *
- * Disclaimed to Digium
+ * A license has been granted to Digium (via disclaimer) for the use of
+ * this code.
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact

Modified: team/group/new_loader_completion/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/apps/app_dial.c?rev=34601&r1=34600&r2=34601&view=diff
==============================================================================
--- team/group/new_loader_completion/apps/app_dial.c (original)
+++ team/group/new_loader_completion/apps/app_dial.c Sun Jun 18 08:37:41 2006
@@ -480,8 +480,6 @@
 				if (o->forwards < AST_MAX_FORWARDS) {
 					if (option_verbose > 2)
 						ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, c->name);
-					/* Setup parameters */
-					c = o->chan = ast_request(tech, in->nativeformats, stuff, &cause);
 					/* If we have been told to ignore forwards, just set this channel to null and continue processing extensions normally */
 					if (ast_test_flag(peerflags, OPT_IGNORE_FORWARDING)) {
 						if (option_verbose > 2)

Modified: team/group/new_loader_completion/apps/app_dumpchan.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/apps/app_dumpchan.c?rev=34601&r1=34600&r2=34601&view=diff
==============================================================================
--- team/group/new_loader_completion/apps/app_dumpchan.c (original)
+++ team/group/new_loader_completion/apps/app_dumpchan.c Sun Jun 18 08:37:41 2006
@@ -5,7 +5,8 @@
  *
  * Anthony Minessale <anthmct at yahoo.com>
  *
- * disclaimed to Digium
+ * A license has been granted to Digium (via disclaimer) for the use of
+ * this code.
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact

Modified: team/group/new_loader_completion/apps/app_ivrdemo.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/apps/app_ivrdemo.c?rev=34601&r1=34600&r2=34601&view=diff
==============================================================================
--- team/group/new_loader_completion/apps/app_ivrdemo.c (original)
+++ team/group/new_loader_completion/apps/app_ivrdemo.c Sun Jun 18 08:37:41 2006
@@ -139,5 +139,4 @@
 	return ASTERISK_GPL_KEY;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, XXX);
-
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "IVR Demo Application");

Modified: team/group/new_loader_completion/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/apps/app_queue.c?rev=34601&r1=34600&r2=34601&view=diff
==============================================================================
--- team/group/new_loader_completion/apps/app_queue.c (original)
+++ team/group/new_loader_completion/apps/app_queue.c Sun Jun 18 08:37:41 2006
@@ -282,7 +282,7 @@
 
 
 struct queue_ent {
-	struct ast_call_queue *parent;	/*!< What queue is our parent */
+	struct call_queue *parent;	/*!< What queue is our parent */
 	char moh[80];			/*!< Name of musiconhold to be used */
 	char announce[80];		/*!< Announcement to play for member when call is answered */
 	char context[AST_MAX_CONTEXT];	/*!< Context when user exits queue */
@@ -315,20 +315,20 @@
 	struct member *next;		/*!< Next member */
 };
 
-struct ast_member_interfaces {
+struct member_interface {
 	char interface[80];
-	AST_LIST_ENTRY(ast_member_interfaces) list;    /*!< Next call queue */
+	AST_LIST_ENTRY(member_interface) list;    /*!< Next call queue */
 };
 
-static AST_LIST_HEAD_STATIC(interfaces, ast_member_interfaces);
-
-/* values used in multi-bit flags in ast_call_queue */
+static AST_LIST_HEAD_STATIC(interfaces, member_interface);
+
+/* values used in multi-bit flags in call_queue */
 #define QUEUE_EMPTY_NORMAL 1
 #define QUEUE_EMPTY_STRICT 2
 #define ANNOUNCEHOLDTIME_ALWAYS 1
 #define ANNOUNCEHOLDTIME_ONCE 2
 
-struct ast_call_queue {
+struct call_queue {
 	ast_mutex_t lock;	
 	char name[80];			/*!< Name */
 	char moh[80];			/*!< Music On Hold class to be used */
@@ -385,10 +385,10 @@
 	
 	struct member *members;		/*!< Head of the list of members */
 	struct queue_ent *head;		/*!< Head of the list of callers */
-	AST_LIST_ENTRY(ast_call_queue) list;	/*!< Next call queue */
+	AST_LIST_ENTRY(call_queue) list;	/*!< Next call queue */
 };
 
-static AST_LIST_HEAD_STATIC(queues, ast_call_queue);
+static AST_LIST_HEAD_STATIC(queues, call_queue);
 
 static int set_member_paused(char *queuename, char *interface, int paused);
 
@@ -417,25 +417,29 @@
 static char *int2strat(int strategy)
 {
 	int x;
-	for (x=0;x<sizeof(strategies) / sizeof(strategies[0]);x++) {
+
+	for (x = 0; x < sizeof(strategies) / sizeof(strategies[0]); x++) {
 		if (strategy == strategies[x].strategy)
 			return strategies[x].name;
 	}
+
 	return "<unknown>";
 }
 
 static int strat2int(const char *strategy)
 {
 	int x;
-	for (x=0;x<sizeof(strategies) / sizeof(strategies[0]);x++) {
+
+	for (x = 0; x < sizeof(strategies) / sizeof(strategies[0]); x++) {
 		if (!strcasecmp(strategy, strategies[x].name))
 			return strategies[x].strategy;
 	}
+
 	return -1;
 }
 
 /*! \brief Insert the 'new' entry after the 'prev' entry of queue 'q' */
-static inline void insert_entry(struct ast_call_queue *q, struct queue_ent *prev, struct queue_ent *new, int *pos)
+static inline void insert_entry(struct call_queue *q, struct queue_ent *prev, struct queue_ent *new, int *pos)
 {
 	struct queue_ent *cur;
 
@@ -460,7 +464,7 @@
 	QUEUE_NORMAL
 };
 
-static enum queue_member_status get_member_status(const struct ast_call_queue *q, int max_penalty)
+static enum queue_member_status get_member_status(const struct call_queue *q, int max_penalty)
 {
 	struct member *member;
 	enum queue_member_status result = QUEUE_NO_MEMBERS;
@@ -493,18 +497,17 @@
 
 static void *changethread(void *data)
 {
-	struct ast_call_queue *q;
+	struct call_queue *q;
 	struct statechange *sc = data;
 	struct member *cur;
-	struct ast_member_interfaces *curint;
+	struct member_interface *curint;
 	char *loc;
 	char *technology;
 
 	technology = ast_strdupa(sc->dev);
 	loc = strchr(technology, '/');
 	if (loc) {
-		*loc = '\0';
-		loc++;
+		*loc++ = '\0';
 	} else {
 		free(sc);
 		return NULL;
@@ -517,43 +520,44 @@
 	}
 	AST_LIST_UNLOCK(&interfaces);
 
-	if (curint) {
-
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
-		AST_LIST_LOCK(&queues);
-		AST_LIST_TRAVERSE(&queues, q, list) {
-			ast_mutex_lock(&q->lock);
-			cur = q->members;
-			while(cur) {
-				if (!strcasecmp(sc->dev, cur->interface)) {
-					if (cur->status != sc->state) {
-						cur->status = sc->state;
-						if (!q->maskmemberstatus) {
-							manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus",
-								"Queue: %s\r\n"
-								"Location: %s\r\n"
-								"Membership: %s\r\n"
-								"Penalty: %d\r\n"
-								"CallsTaken: %d\r\n"
-								"LastCall: %d\r\n"
-								"Status: %d\r\n"
-								"Paused: %d\r\n",
-							q->name, cur->interface, cur->dynamic ? "dynamic" : "static",
-							cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
-						}
-					}
-				}
-				cur = cur->next;
-			}
-			ast_mutex_unlock(&q->lock);
-		}
-		AST_LIST_UNLOCK(&queues);
-	} else {
+	if (!curint) {
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
-	}
-	free(sc);
+		free(sc);
+		return NULL;
+        }
+
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
+	AST_LIST_LOCK(&queues);
+	AST_LIST_TRAVERSE(&queues, q, list) {
+		ast_mutex_lock(&q->lock);
+		for (cur = q->members; cur; cur = cur->next) {
+			if (strcasecmp(sc->dev, cur->interface))
+				continue;
+
+			if (cur->status != sc->state) {
+				cur->status = sc->state;
+				if (q->maskmemberstatus)
+					continue;
+
+				manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus",
+					      "Queue: %s\r\n"
+					      "Location: %s\r\n"
+					      "Membership: %s\r\n"
+					      "Penalty: %d\r\n"
+					      "CallsTaken: %d\r\n"
+					      "LastCall: %d\r\n"
+					      "Status: %d\r\n"
+					      "Paused: %d\r\n",
+					      q->name, cur->interface, cur->dynamic ? "dynamic" : "static",
+					      cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
+			}
+		}
+		ast_mutex_unlock(&q->lock);
+	}
+	AST_LIST_UNLOCK(&queues);
+
 	return NULL;
 }
 
@@ -564,17 +568,19 @@
 	struct statechange *sc;
 	pthread_t t;
 	pthread_attr_t attr;
-	
-	if ((sc = ast_calloc(1, sizeof(*sc) + strlen(dev) + 1))) {
-		sc->state = state;
-		strcpy(sc->dev, dev);
-		pthread_attr_init(&attr);
-		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-		if (ast_pthread_create(&t, &attr, changethread, sc)) {
-			ast_log(LOG_WARNING, "Failed to create update thread!\n");
-			free(sc);
-		}
-	}
+
+	if (!(sc = ast_calloc(1, sizeof(*sc) + strlen(dev) + 1)))
+		return 0;
+
+	sc->state = state;
+	strcpy(sc->dev, dev);
+	pthread_attr_init(&attr);
+	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+	if (ast_pthread_create(&t, &attr, changethread, sc)) {
+		ast_log(LOG_WARNING, "Failed to create update thread!\n");
+		free(sc);
+	}
+
 	return 0;
 }
 
@@ -582,8 +588,6 @@
 {
 	struct member *cur;
 	
-	/* Add a new member */
-
 	if ((cur = ast_calloc(1, sizeof(*cur)))) {
 		cur->penalty = penalty;
 		cur->paused = paused;
@@ -596,9 +600,9 @@
 	return cur;
 }
 
-static struct ast_call_queue *alloc_queue(const char *queuename)
-{
-	struct ast_call_queue *q;
+static struct call_queue *alloc_queue(const char *queuename)
+{
+	struct call_queue *q;
 
 	if ((q = ast_calloc(1, sizeof(*q)))) {
 		ast_mutex_init(&q->lock);
@@ -607,9 +611,10 @@
 	return q;
 }
 
-static void init_queue(struct ast_call_queue *q)
+static void init_queue(struct call_queue *q)
 {
 	int i;
+
 	q->dead = 0;
 	q->retry = DEFAULT_RETRY;
 	q->timeout = -1;
@@ -637,12 +642,12 @@
 	ast_copy_string(q->sound_lessthan, "queue-less-than", sizeof(q->sound_lessthan));
 	ast_copy_string(q->sound_reporthold, "queue-reporthold", sizeof(q->sound_reporthold));
 	ast_copy_string(q->sound_periodicannounce[0], "queue-periodic-announce", sizeof(q->sound_periodicannounce[0]));
-	for (i=1;i<MAX_PERIODIC_ANNOUNCEMENTS;i++) {
+	for (i = 1; i < MAX_PERIODIC_ANNOUNCEMENTS; i++) {
 		q->sound_periodicannounce[i][0]='\0';
 	}
 }
 
-static void clear_queue(struct ast_call_queue *q)
+static void clear_queue(struct call_queue *q)
 {
 	q->holdtime = 0;
 	q->callscompleted = 0;
@@ -653,7 +658,7 @@
 
 static int add_to_interfaces(char *interface) 
 {
-	struct ast_member_interfaces *curint, *newint;
+	struct member_interface *curint;
 
 	AST_LIST_LOCK(&interfaces);
 	AST_LIST_TRAVERSE(&interfaces, curint, list) {
@@ -661,54 +666,59 @@
 			break; 
 	}
 
-	if (!curint) {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Adding %s to the list of interfaces that make up all of our queue members.\n", interface);
-
-	        if ((newint = ast_calloc(1, sizeof(*newint)))) {
-			ast_copy_string(newint->interface, interface, sizeof(newint->interface));
-			AST_LIST_INSERT_HEAD(&interfaces, newint, list);
-		}
+	if (curint) {
+		AST_LIST_UNLOCK(&interfaces);
+		return 0;
+	}
+
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Adding %s to the list of interfaces that make up all of our queue members.\n", interface);
+	
+	if ((curint = ast_calloc(1, sizeof(*curint)))) {
+		ast_copy_string(curint->interface, interface, sizeof(curint->interface));
+		AST_LIST_INSERT_HEAD(&interfaces, curint, list);
 	}
 	AST_LIST_UNLOCK(&interfaces);
 
- return 0;
+	return 0;
 }
 
 static int interface_exists_global(char *interface)
 {
-	struct ast_call_queue *q;
+	struct call_queue *q;
 	struct member *mem;
 	int ret = 0;
 
 	AST_LIST_LOCK(&queues);
 	AST_LIST_TRAVERSE(&queues, q, list) {
 		ast_mutex_lock(&q->lock);
-		for (mem = q->members; mem; mem = mem->next)
-			if (!strcasecmp(interface, mem->interface)) {
-				ast_mutex_unlock(&q->lock);
+		for (mem = q->members; mem && !ret; mem = mem->next) {
+			if (!strcasecmp(interface, mem->interface))
 				ret = 1;
-				break;
-			}
+		}
 		ast_mutex_unlock(&q->lock);
+		if (ret)
+			break;
 	}
 	AST_LIST_UNLOCK(&queues);
 
 	return ret;
 }
 
-
 static int remove_from_interfaces(char *interface)
 {
-	struct ast_member_interfaces *curint;
+	struct member_interface *curint;
 
 	AST_LIST_LOCK(&interfaces);
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&interfaces, curint, list) {
-		if (!strcasecmp(curint->interface, interface) && !interface_exists_global(interface)) {
-			if (option_debug)
-				ast_log(LOG_DEBUG, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
-			AST_LIST_REMOVE_CURRENT(&interfaces, list);
-			free(curint);
+		if (!strcasecmp(curint->interface, interface)) {
+			if (!interface_exists_global(interface)) {
+				if (option_debug)
+					ast_log(LOG_DEBUG, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
+				AST_LIST_REMOVE_CURRENT(&interfaces, list);
+				free(curint);
+			}
+			break;
 		}
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
@@ -719,17 +729,12 @@
 
 static void clear_and_free_interfaces(void)
 {
-	struct ast_member_interfaces *curint;
+	struct member_interface *curint;
 
 	AST_LIST_LOCK(&interfaces);
-	AST_LIST_TRAVERSE_SAFE_BEGIN(&interfaces, curint, list) {
-		AST_LIST_REMOVE_CURRENT(&interfaces, list);
+	while ((curint = AST_LIST_REMOVE_HEAD(&interfaces, list)))
 		free(curint);
-	}
-	AST_LIST_TRAVERSE_SAFE_END;
 	AST_LIST_UNLOCK(&interfaces);
-
- 	return;
 }
 
 /*! \brief Configure a queue parameter.
@@ -739,11 +744,12 @@
    The failunknown flag is set for config files (and static realtime) to show
    errors for unknown parameters. It is cleared for dynamic realtime to allow
    extra fields in the tables. */
-static void queue_set_param(struct ast_call_queue *q, const char *param, const char *val, int linenum, int failunknown)
+static void queue_set_param(struct call_queue *q, const char *param, const char *val, int linenum, int failunknown)
 {
 	int i = 0;
 	char *c, *lastc;
 	char buff[80];
+
 	if (!strcasecmp(param, "music") || !strcasecmp(param, "musiconhold")) {
 		ast_copy_string(q->moh, val, sizeof(q->moh));
 	} else if (!strcasecmp(param, "announce")) {
@@ -888,29 +894,25 @@
 	}
 }
 
-static void rt_handle_member_record(struct ast_call_queue *q, char *interface, const char *penalty_str)
+static void rt_handle_member_record(struct call_queue *q, char *interface, const char *penalty_str)
 {
 	struct member *m, *prev_m;
 	int penalty = 0;
 
-	if(penalty_str) {
+	if (penalty_str) {
 		penalty = atoi(penalty_str);
-		if(penalty < 0)
+		if (penalty < 0)
 			penalty = 0;
 	}
 
 	/* Find the member, or the place to put a new one. */
-	prev_m = NULL;
-	m = q->members;
-	while (m && strcmp(m->interface, interface)) {
-		prev_m = m;
-		m = m->next;
-	}
+	for (m = q->members, prev_m = NULL;
+	     m && strcmp(m->interface, interface);
+	     prev_m = m, m = m->next);
 
 	/* Create a new one if not found, else update penalty */
 	if (!m) {
-		m = create_queue_member(interface, penalty, 0);
-		if (m) {
+		if ((m = create_queue_member(interface, penalty, 0))) {
 			m->dead = 0;
 			add_to_interfaces(interface);
 			if (prev_m) {
@@ -925,7 +927,7 @@
 	}
 }
 
-static void free_members(struct ast_call_queue *q, int all)
+static void free_members(struct call_queue *q, int all)
 {
 	/* Free non-dynamic members */
 	struct member *curm, *next, *prev = NULL;
@@ -944,7 +946,7 @@
 	}
 }
 
-static void destroy_queue(struct ast_call_queue *q)
+static void destroy_queue(struct call_queue *q)
 {
 	free_members(q, 1);
 	ast_mutex_destroy(&q->lock);
@@ -954,10 +956,10 @@
 /*!\brief Reload a single queue via realtime.
    \return Return the queue, or NULL if it doesn't exist.
    \note Should be called with the global qlock locked. */
-static struct ast_call_queue *find_queue_by_name_rt(const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config)
+static struct call_queue *find_queue_by_name_rt(const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config)
 {
 	struct ast_variable *v;
-	struct ast_call_queue *q;
+	struct call_queue *q;
 	struct member *m, *prev_m, *next_m;
 	char *interface;
 	char *tmp, *tmp_name;
@@ -965,9 +967,8 @@
 
 	/* Find the queue in the in-core list (we will create a new one if not found). */
 	AST_LIST_TRAVERSE(&queues, q, list) {
-		if (!strcasecmp(q->name, queuename)) {
+		if (!strcasecmp(q->name, queuename))
 			break;
-		}
 	}
 
 	/* Static queues override realtime. */
@@ -1019,38 +1020,32 @@
 	}
 	init_queue(q);		/* Ensure defaults for all parameters not set explicitly. */
 
-	v = queue_vars;
 	memset(tmpbuf, 0, sizeof(tmpbuf));
-	while(v) {
+	for (v = queue_vars; v; v = v->next) {
 		/* Convert to dashes `-' from underscores `_' as the latter are more SQL friendly. */
-		if((tmp = strchr(v->name, '_')) != NULL) {
+		if ((tmp = strchr(v->name, '_'))) {
 			ast_copy_string(tmpbuf, v->name, sizeof(tmpbuf));
 			tmp_name = tmpbuf;
 			tmp = tmp_name;
-			while((tmp = strchr(tmp, '_')) != NULL)
+			while ((tmp = strchr(tmp, '_')))
 				*tmp++ = '-';
 		} else
 			tmp_name = v->name;
 		queue_set_param(q, tmp_name, v->value, -1, 0);
-		v = v->next;
 	}
 
 	if (q->strategy == QUEUE_STRATEGY_ROUNDROBIN)
 		rr_dep_warning();
 
 	/* Temporarily set non-dynamic members dead so we can detect deleted ones. */
-	m = q->members;
-	while (m) {
+	for (m = q->members; m; m = m->next) {
 		if (!m->dynamic)
 			m->dead = 1;
-		m = m->next;
-	}
-
-	interface = ast_category_browse(member_config, NULL);
-	while (interface) {
+	}
+
+	interface = NULL;
+	while (ast_category_browse(member_config, interface))
 		rt_handle_member_record(q, interface, ast_variable_retrieve(member_config, interface, "penalty"));
-		interface = ast_category_browse(member_config, interface);
-	}
 
 	/* Delete all realtime members that have been deleted in DB. */
 	m = q->members;
@@ -1076,11 +1071,11 @@
 	return q;
 }
 
-static struct ast_call_queue *load_realtime_queue(char *queuename)
-{
-	struct ast_variable *queue_vars = NULL;
+static struct call_queue *load_realtime_queue(char *queuename)
+{
+	struct ast_variable *queue_vars;
 	struct ast_config *member_config = NULL;
-	struct ast_call_queue *q;
+	struct call_queue *q;
 
 	/* Find the queue in the in-core list first. */
 	AST_LIST_LOCK(&queues);
@@ -1125,15 +1120,14 @@
 
 static int join_queue(char *queuename, struct queue_ent *qe, enum queue_result *reason)
 {
-	struct ast_call_queue *q;
+	struct call_queue *q;
 	struct queue_ent *cur, *prev = NULL;
 	int res = -1;
 	int pos = 0;
 	int inserted = 0;
 	enum queue_member_status stat;
 
-	q = load_realtime_queue(queuename);
-	if (!q)
+	if (!(q = load_realtime_queue(queuename)))
 		return res;
 
 	AST_LIST_LOCK(&queues);
@@ -1154,7 +1148,7 @@
 		inserted = 0;
 		prev = NULL;
 		cur = q->head;
-		while(cur) {
+		while (cur) {
 			/* We have higher priority than the current user, enter
 			 * before him, after all the other users with priority
 			 * higher or equal to our priority. */
@@ -1174,7 +1168,6 @@
 		ast_copy_string(qe->context, q->context, sizeof(qe->context));
 		q->count++;
 		res = 0;
-		/* XXX missing CalledIDnum ? */
 		manager_event(EVENT_FLAG_CALL, "Join", 
 			      "Channel: %s\r\nCallerID: %s\r\nCallerIDName: %s\r\nQueue: %s\r\nPosition: %d\r\nCount: %d\r\nUniqueid: %s\r\n",
 			      qe->chan->name, 
@@ -1186,6 +1179,7 @@
 	}
 	ast_mutex_unlock(&q->lock);
 	AST_LIST_UNLOCK(&queues);
+
 	return res;
 }
 
@@ -1195,12 +1189,8 @@
 
 	ast_stopstream(chan);
 	res = ast_streamfile(chan, filename, chan->language);
-
 	if (!res)
 		res = ast_waitstream(chan, AST_DIGIT_ANY);
-	else
-		res = 0;
-
 	ast_stopstream(chan);
 
 	return res;
@@ -1234,6 +1224,7 @@
 		/* Return 1 on a successful goto */
 		return 1;
 	}
+
 	return 0;
 }
 
@@ -1244,11 +1235,11 @@
 
 	/* Check to see if this is ludicrous -- if we just announced position, don't do it again*/
 	time(&now);
-	if ( (now - qe->last_pos) < 15 )
+	if ((now - qe->last_pos) < 15)
 		return 0;
 
 	/* If either our position has changed, or we are over the freq timer, say position */
-	if ( (qe->last_pos_said == qe->pos) && ((now - qe->last_pos) < qe->parent->announcefrequency) )
+	if ((qe->last_pos_said == qe->pos) && ((now - qe->last_pos) < qe->parent->announcefrequency))
 		return 0;
 
 	ast_moh_stop(qe->chan);
@@ -1271,14 +1262,14 @@
 			goto playout;
 	}
 	/* Round hold time to nearest minute */
-	avgholdmins = abs(( (qe->parent->holdtime + 30) - (now - qe->start) ) / 60);
+	avgholdmins = abs(((qe->parent->holdtime + 30) - (now - qe->start)) / 60);
 
 	/* If they have specified a rounding then round the seconds as well */
-	if(qe->parent->roundingseconds) {
-		avgholdsecs = (abs(( (qe->parent->holdtime + 30) - (now - qe->start) )) - 60 * avgholdmins) / qe->parent->roundingseconds;
-		avgholdsecs*= qe->parent->roundingseconds;
+	if (qe->parent->roundingseconds) {
+		avgholdsecs = (abs(((qe->parent->holdtime + 30) - (now - qe->start))) - 60 * avgholdmins) / qe->parent->roundingseconds;
+		avgholdsecs *= qe->parent->roundingseconds;
 	} else {
-		avgholdsecs=0;
+		avgholdsecs = 0;
 	}
 
 	if (option_verbose > 2)
@@ -1292,17 +1283,17 @@
 		if (res && valid_exit(qe, res))
 			goto playout;
 
-		if (avgholdmins>0) {
+		if (avgholdmins > 0) {
 			if (avgholdmins < 2) {
 				res = play_file(qe->chan, qe->parent->sound_lessthan);
 				if (res && valid_exit(qe, res))
 					goto playout;
 
-				res = ast_say_number(qe->chan, 2, AST_DIGIT_ANY, qe->chan->language, (char *)NULL);
+				res = ast_say_number(qe->chan, 2, AST_DIGIT_ANY, qe->chan->language, NULL);
 				if (res && valid_exit(qe, res))
 					goto playout;
 			} else {
-				res = ast_say_number(qe->chan, avgholdmins, AST_DIGIT_ANY, qe->chan->language, (char*) NULL);
+				res = ast_say_number(qe->chan, avgholdmins, AST_DIGIT_ANY, qe->chan->language, NULL);
 				if (res && valid_exit(qe, res))
 					goto playout;
 			}
@@ -1312,7 +1303,7 @@
 				goto playout;
 		}
 		if (avgholdsecs>0) {
-			res = ast_say_number(qe->chan, avgholdsecs, AST_DIGIT_ANY, qe->chan->language, (char*) NULL);
+			res = ast_say_number(qe->chan, avgholdsecs, AST_DIGIT_ANY, qe->chan->language, NULL);
 			if (res && valid_exit(qe, res))
 				goto playout;
 
@@ -1364,18 +1355,16 @@
 
 static void leave_queue(struct queue_ent *qe)
 {
-	struct ast_call_queue *q;
+	struct call_queue *q;
 	struct queue_ent *cur, *prev = NULL;
 	int pos = 0;
 
-	q = qe->parent;
-	if (!q)
+	if (!(q = qe->parent))
 		return;
 	ast_mutex_lock(&q->lock);
 
 	prev = NULL;
-	cur = q->head;
-	while(cur) {
+	for (cur = q->head; cur; cur = cur->next) {
 		if (cur == qe) {
 			q->count--;
 
@@ -1395,9 +1384,9 @@
 			cur->pos = ++pos;
 			prev = cur;
 		}
-		cur = cur->next;
 	}
 	ast_mutex_unlock(&q->lock);
+
 	if (q->dead && !q->count) {	
 		/* It's dead and nobody is in it, so kill it */
 		AST_LIST_LOCK(&queues);
@@ -1412,17 +1401,17 @@
 {
 	struct callattempt *oo;
 
-	while(outgoing) {
+	while (outgoing) {
 		/* Hangup any existing lines we have open */
 		if (outgoing->chan && (outgoing->chan != exception))
 			ast_hangup(outgoing->chan);
 		oo = outgoing;
-		outgoing=outgoing->q_next;
+		outgoing = outgoing->q_next;
 		free(oo);
 	}
 }
 
-static int update_status(struct ast_call_queue *q, struct member *member, int status)
+static int update_status(struct call_queue *q, struct member *member, int status)
 {
 	struct member *cur;
 
@@ -1430,29 +1419,29 @@
 		be sure it's still valid */
 	ast_mutex_lock(&q->lock);
 	for (cur = q->members; cur; cur = cur->next) {
-		if (member == cur) {
-			cur->status = status;
-			if (!q->maskmemberstatus) {
-				manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus",
-					"Queue: %s\r\n"
-					"Location: %s\r\n"
-					"Membership: %s\r\n"
-					"Penalty: %d\r\n"
-					"CallsTaken: %d\r\n"
-					"LastCall: %d\r\n"
-					"Status: %d\r\n"
-					"Paused: %d\r\n",
-				q->name, cur->interface, cur->dynamic ? "dynamic" : "static",
-				cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
-			}
-			break;
+		if (member != cur)
+			continue;
+
+		cur->status = status;
+		if (!q->maskmemberstatus) {
+			manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus",
+				      "Queue: %s\r\n"
+				      "Location: %s\r\n"
+				      "Membership: %s\r\n"
+				      "Penalty: %d\r\n"
+				      "CallsTaken: %d\r\n"
+				      "LastCall: %d\r\n"
+				      "Status: %d\r\n"
+				      "Paused: %d\r\n",
+				      q->name, cur->interface, cur->dynamic ? "dynamic" : "static",
+				      cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
 		}
 	}
 	ast_mutex_unlock(&q->lock);
 	return 0;
 }
 
-static int update_dial_status(struct ast_call_queue *q, struct member *member, int status)
+static int update_dial_status(struct call_queue *q, struct member *member, int status)
 {
 	if (status == AST_CAUSE_BUSY)
 		status = AST_DEVICE_BUSY;
@@ -1467,9 +1456,9 @@
 
 /* traverse all defined queues which have calls waiting and contain this member
    return 0 if no other queue has precedence (higher weight) or 1 if found  */
-static int compare_weight(struct ast_call_queue *rq, struct member *member)
-{
-	struct ast_call_queue *q;
+static int compare_weight(struct call_queue *rq, struct member *member)
+{
+	struct call_queue *q;
 	struct member *mem;
 	int found = 0;
 	
@@ -1481,13 +1470,14 @@
 		ast_mutex_lock(&q->lock);
 		if (q->count && q->members) {
 			for (mem = q->members; mem; mem = mem->next) {
-				if (!strcmp(mem->interface, member->interface)) {
-					ast_log(LOG_DEBUG, "Found matching member %s in queue '%s'\n", mem->interface, q->name);
-					if (q->weight > rq->weight) {
-						ast_log(LOG_DEBUG, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count);
-						found = 1;
-						break;
-					}
+				if (strcmp(mem->interface, member->interface))
+					continue;
+
+				ast_log(LOG_DEBUG, "Found matching member %s in queue '%s'\n", mem->interface, q->name);
+				if (q->weight > rq->weight) {
+					ast_log(LOG_DEBUG, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count);
+					found = 1;
+					break;
 				}
 			}
 		}
@@ -1559,9 +1549,6 @@
 	/* Request the peer */
 	tmp->chan = ast_request(tech, qe->chan->nativeformats, location, &status);
 	if (!tmp->chan) {			/* If we can't, just go on to the next call */
-#if 0
-		ast_log(LOG_NOTICE, "Unable to create channel of type '%s' for Queue\n", cur->tech);
-#endif			
 		if (qe->chan->cdr)
 			ast_cdr_busy(qe->chan->cdr);
 		tmp->stillgoing = 0;
@@ -1591,8 +1578,7 @@
 	tmp->chan->adsicpe = qe->chan->adsicpe;
 
 	/* Place the call, but don't wait on the answer */
-	res = ast_call(tmp->chan, location, 0);
-	if (res) {
+	if ((res = ast_call(tmp->chan, location, 0))) {
 		/* Again, keep going even if there's an error */
 		if (option_debug)
 			ast_log(LOG_DEBUG, "ast call on peer returned %d\n", res);
@@ -1619,6 +1605,7 @@
 		if (option_verbose > 2)
 			ast_verbose(VERBOSE_PREFIX_3 "Called %s\n", tmp->interface);
 	}
+
 	return 1;
 }
 
@@ -1629,11 +1616,12 @@
 
 	for (cur = outgoing; cur; cur = cur->q_next) {
 		if (cur->stillgoing &&					/* Not already done */
-			!cur->chan &&					/* Isn't already going */
-			(!best || cur->metric < best->metric)) {	/* We haven't found one yet, or it's better */
-				best = cur;
-		}
-	}
+		    !cur->chan &&					/* Isn't already going */
+		    (!best || cur->metric < best->metric)) {		/* We haven't found one yet, or it's better */
+			best = cur;
+		}
+	}
+
 	return best;
 }
 
@@ -1667,6 +1655,7 @@
 		if (best->chan) /* break out with result = 1 */
 			ret = 1;
 	}
+
 	return ret;
 }
 
@@ -1690,6 +1679,7 @@
 		}
 	}
 	qe->parent->wrapped = 0;
+
 	return 0;
 }
 
@@ -1708,15 +1698,8 @@
 
 		/* Stop playback */
 		ast_stopstream(chan);
-	} else {
-		res = 0;
 	}
 	
-	/*if (res) {
-		ast_log(LOG_WARNING, "ast_streamfile failed on %s \n", chan->name);
-		res = 0;
-	}*/
-
 	return res;
 }
 
@@ -1777,7 +1760,6 @@
 /*! \brief RNA == Ring No Answer. Common code that is executed when we try a queue member and they don't answer. */
 static void rna(int rnatime, struct queue_ent *qe, char *membername)
 {
-
 	if (option_verbose > 2)
 		ast_verbose( VERBOSE_PREFIX_3 "Nobody picked up in %d ms\n", rnatime);
 	ast_queue_log(qe->parent->name, qe->chan->uniqueid, membername, "RINGNOANSWER", "%d", rnatime);
@@ -1813,7 +1795,7 @@
 	long starttime = 0;
 	long endtime = 0;	
 
-	starttime = (long)time(NULL);
+	starttime = (long) time(NULL);
 	
 	while(*to && !peer) {
 		int numlines, retry, pos = 1;
@@ -1858,9 +1840,10 @@
 			} else if (o->chan && (o->chan == winner)) {
 				ast_copy_string(on, o->member->interface, sizeof(on));
 				if (!ast_strlen_zero(o->chan->call_forward)) {
-					char tmpchan[256]="";
+					char tmpchan[256];
 					char *stuff;

[... 3231 lines stripped ...]


More information about the asterisk-commits mailing list