[svn-commits] kpfleming: branch 1.6.0 r126362 - /branches/1.6.0/apps/app_dahdibarge.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Jun 29 12:00:56 CDT 2008


Author: kpfleming
Date: Sun Jun 29 12:00:56 2008
New Revision: 126362

URL: http://svn.digium.com/view/asterisk?view=rev&rev=126362
Log:
don't know how this got missed in the DAHDI conversion of this branch

Added:
    branches/1.6.0/apps/app_dahdibarge.c
      - copied, changed from r126361, branches/1.6.0/apps/app_zapbarge.c

Copied: branches/1.6.0/apps/app_dahdibarge.c (from r126361, branches/1.6.0/apps/app_zapbarge.c)
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_dahdibarge.c?view=diff&rev=126362&p1=branches/1.6.0/apps/app_zapbarge.c&r1=126361&p2=branches/1.6.0/apps/app_dahdibarge.c&r2=126362
==============================================================================
--- branches/1.6.0/apps/app_zapbarge.c (original)
+++ branches/1.6.0/apps/app_dahdibarge.c Sun Jun 29 12:00:56 2008
@@ -21,7 +21,7 @@
 
 /*! \file
  *
- * \brief Zap Barge support
+ * \brief DAHDI Barge support
  *
  * \author Mark Spencer <markster at digium.com>
  *
@@ -32,14 +32,15 @@
  */
 
 /*** MODULEINFO
-	<depend>zaptel</depend>
+	<depend>dahdi</depend>
  ***/
 
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/zapata.h"
+#include <sys/ioctl.h>
+#include <dahdi/user.h>
 
 #include "asterisk/lock.h"
 #include "asterisk/file.h"
@@ -52,12 +53,13 @@
 #include "asterisk/say.h"
 #include "asterisk/utils.h"
 
-static char *app = "ZapBarge";
-
-static char *synopsis = "Barge in (monitor) Zap channel";
+static char *app = "DAHDIBarge";
+static char *deprecated_app = "ZapBarge";
+
+static char *synopsis = "Barge in (monitor) DAHDI channel";
 
 static char *descrip = 
-"  ZapBarge([channel]): Barges in on a specified zap\n"
+"  DAHDIBarge([channel]): Barges in on a specified DAHDI\n"
 "channel or prompts if one is not specified.  Returns\n"
 "-1 when caller user hangs up and is independent of the\n"
 "state of the channel being monitored.";
@@ -86,7 +88,7 @@
 static int conf_run(struct ast_channel *chan, int confno, int confflags)
 {
 	int fd;
-	struct zt_confinfo ztc;
+	struct dahdi_confinfo dahdic;
 	struct ast_frame *f;
 	struct ast_channel *c;
 	struct ast_frame fr;
@@ -95,11 +97,11 @@
 	int nfds;
 	int res;
 	int flags;
-	int retryzap;
+	int retrydahdi;
 	int origfd;
 	int ret = -1;
 
-	ZT_BUFFERINFO bi;
+	DAHDI_BUFFERINFO bi;
 	char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET];
 	char *buf = __buf + AST_FRIENDLY_OFFSET;
 
@@ -115,11 +117,11 @@
 		goto outrun;
 	}
 	ast_indicate(chan, -1);
-	retryzap = strcasecmp(chan->tech->type, "Zap");
-zapretry:
+	retrydahdi = strcasecmp(chan->tech->type, "DAHDI");
+dahdiretry:
 	origfd = chan->fds[0];
-	if (retryzap) {
-		fd = open("/dev/zap/pseudo", O_RDWR);
+	if (retrydahdi) {
+		fd = open("/dev/dahdi/pseudo", O_RDWR);
 		if (fd < 0) {
 			ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
 			goto outrun;
@@ -139,10 +141,10 @@
 		/* Setup buffering information */
 		memset(&bi, 0, sizeof(bi));
 		bi.bufsize = CONF_SIZE;
-		bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
-		bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
+		bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
+		bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
 		bi.numbufs = 4;
-		if (ioctl(fd, ZT_SET_BUFINFO, &bi)) {
+		if (ioctl(fd, DAHDI_SET_BUFINFO, &bi)) {
 			ast_log(LOG_WARNING, "Unable to set buffering information: %s\n", strerror(errno));
 			close(fd);
 			goto outrun;
@@ -153,34 +155,34 @@
 		fd = chan->fds[0];
 		nfds = 0;
 	}
-	memset(&ztc, 0, sizeof(ztc));
+	memset(&dahdic, 0, sizeof(dahdic));
 	/* Check to see if we're in a conference... */
-	ztc.chan = 0;	
-	if (ioctl(fd, ZT_GETCONF, &ztc)) {
+	dahdic.chan = 0;	
+	if (ioctl(fd, DAHDI_GETCONF, &dahdic)) {
 		ast_log(LOG_WARNING, "Error getting conference\n");
 		close(fd);
 		goto outrun;
 	}
-	if (ztc.confmode) {
+	if (dahdic.confmode) {
 		/* Whoa, already in a conference...  Retry... */
-		if (!retryzap) {
-			ast_debug(1, "Zap channel is in a conference already, retrying with pseudo\n");
-			retryzap = 1;
-			goto zapretry;
-		}
-	}
-	memset(&ztc, 0, sizeof(ztc));
+		if (!retrydahdi) {
+			ast_debug(1, "DAHDI channel is in a conference already, retrying with pseudo\n");
+			retrydahdi = 1;
+			goto dahdiretry;
+		}
+	}
+	memset(&dahdic, 0, sizeof(dahdic));
 	/* Add us to the conference */
-	ztc.chan = 0;	
-	ztc.confno = confno;
-	ztc.confmode = ZT_CONF_MONITORBOTH;
-
-	if (ioctl(fd, ZT_SETCONF, &ztc)) {
+	dahdic.chan = 0;	
+	dahdic.confno = confno;
+	dahdic.confmode = DAHDI_CONF_MONITORBOTH;
+
+	if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
 		ast_log(LOG_WARNING, "Error setting conference\n");
 		close(fd);
 		goto outrun;
 	}
-	ast_debug(1, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
+	ast_debug(1, "Placed channel %s in DAHDI channel %d monitor\n", chan->name, confno);
 
 	for(;;) {
 		outfd = -1;
@@ -188,13 +190,13 @@
 		c = ast_waitfor_nandfds(&chan, 1, &fd, nfds, NULL, &outfd, &ms);
 		if (c) {
 			if (c->fds[0] != origfd) {
-				if (retryzap) {
+				if (retrydahdi) {
 					/* Kill old pseudo */
 					close(fd);
 				}
 				ast_debug(1, "Ooh, something swapped out under us, starting over\n");
-				retryzap = 0;
-				goto zapretry;
+				retrydahdi = 0;
+				goto dahdiretry;
 			}
 			f = ast_read(c);
 			if (!f) 
@@ -236,10 +238,10 @@
 	else {
 		/* Take out of conference */
 		/* Add us to the conference */
-		ztc.chan = 0;	
-		ztc.confno = 0;
-		ztc.confmode = 0;
-		if (ioctl(fd, ZT_SETCONF, &ztc)) {
+		dahdic.chan = 0;	
+		dahdic.confno = 0;
+		dahdic.confmode = 0;
+		if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
 			ast_log(LOG_WARNING, "Error setting conference\n");
 		}
 	}
@@ -258,9 +260,9 @@
 	char confstr[80] = "";
 	
 	if (!ast_strlen_zero(data)) {
-		if ((sscanf(data, "Zap/%d", &confno) != 1) &&
+		if ((sscanf(data, "DAHDI/%d", &confno) != 1) &&
 		    (sscanf(data, "%d", &confno) != 1)) {
-			ast_log(LOG_WARNING, "ZapBarge Argument (if specified) must be a channel number, not '%s'\n", (char *)data);
+			ast_log(LOG_WARNING, "DAHDIBarge Argument (if specified) must be a channel number, not '%s'\n", (char *)data);
 			return 0;
 		}
 	}
@@ -286,6 +288,12 @@
 	return res;
 }
 
+static int conf_exec_warn(struct ast_channel *chan, void *data)
+{
+	ast_log(LOG_WARNING, "Use of the command %s is deprecated, please use %s instead.\n", deprecated_app, app);
+	return conf_exec(chan, data);
+}
+
 static int unload_module(void)
 {
 	return ast_unregister_application(app);
@@ -293,7 +301,8 @@
 
 static int load_module(void)
 {
+	ast_register_application(deprecated_app, conf_exec_warn, synopsis, descrip);
 	return ((ast_register_application(app, conf_exec, synopsis, descrip)) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS);
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Barge in on Zap channel application");
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Barge in on DAHDI channel application");




More information about the svn-commits mailing list