[Asterisk-cvs] asterisk/res res_agi.c,NONE,1.1 Makefile,1.16,1.17 res_musiconhold.c,1.35,1.36

markster at lists.digium.com markster at lists.digium.com
Sat Jul 17 16:26:26 CDT 2004


Update of /usr/cvsroot/asterisk/res
In directory localhost.localdomain:/tmp/cvs-serv19949/res

Modified Files:
	Makefile res_musiconhold.c 
Added Files:
	res_agi.c 
Log Message:
Merge musiconhold stuff (bug #2027), restructure AGI to eventually support registration


--- NEW FILE: res_agi.c ---
/*
 * Asterisk -- A telephony toolkit for Linux.
 *
 * Asterisk Gateway Interface
 * 
 * Copyright (C) 1999, Mark Spencer
 *
 * Mark Spencer <markster at linux-support.net>
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License
 */

#include <sys/types.h>
#include <asterisk/file.h>
#include <asterisk/logger.h>
#include <asterisk/channel.h>
#include <asterisk/pbx.h>
#include <asterisk/module.h>
[...1546 lines suppressed...]
	return ast_register_application(app, agi_exec, synopsis, descrip);
}

char *description(void)
{
	return tdesc;
}

int usecount(void)
{
	int res;
	STANDARD_USECOUNT(res);
	return res;
}

char *key()
{
	return ASTERISK_GPL_KEY;
}


Index: Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/res/Makefile,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Makefile	25 Jun 2004 03:59:07 -0000	1.16
+++ Makefile	17 Jul 2004 20:12:28 -0000	1.17
@@ -11,7 +11,8 @@
 # the GNU General Public License
 #
 
-MODS=res_adsi.so res_parking.so res_crypto.so res_musiconhold.so res_indications.so res_monitor.so
+MODS=res_adsi.so res_parking.so res_crypto.so res_musiconhold.so res_indications.so res_monitor.so \
+     res_agi.so
 MODS+=$(shell if [ -f "/usr/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
 MODS+=$(shell if [ -f "/usr/local/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
 MODS+=$(shell if [ -f "/usr/include/osp/osp.h" ]; then echo "res_osp.so"; fi)
@@ -30,6 +31,7 @@
 all: depend $(MODS)
 
 install: all
+	rm -f $(DESTDIR)$(MODULES_DIR)/app_agi.so 
 	for x in $(MODS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
 
 res_crypto.so: res_crypto.o

Index: res_musiconhold.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_musiconhold.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- res_musiconhold.c	14 Jul 2004 13:57:15 -0000	1.35
+++ res_musiconhold.c	17 Jul 2004 20:12:28 -0000	1.36
@@ -79,6 +79,7 @@
 	int pid;		/* PID of mpg123 */
 	int quiet;
 	int single;
+	int custom;
 	pthread_t thread;
 	struct mohdata *members;
 	/* Source of audio */
@@ -119,34 +120,49 @@
 		ast_log(LOG_WARNING, "%s is not a valid directory\n", class->dir);
 		return -1;
  	}
-	argv[argc++] = "mpg123";
-	argv[argc++] = "-q";
-	argv[argc++] = "-s";
-	argv[argc++] = "--mono";
-	argv[argc++] = "-r";
-	argv[argc++] = "8000";
 
-	if (!class->single) {
-		argv[argc++] = "-b";
-		argv[argc++] = "2048";
-	}
+	if (!class->custom) {
+		argv[argc++] = "mpg123";
+		argv[argc++] = "-q";
+		argv[argc++] = "-s";
+		argv[argc++] = "--mono";
+		argv[argc++] = "-r";
+		argv[argc++] = "8000";
+		
+		if (!class->single) {
+			argv[argc++] = "-b";
+			argv[argc++] = "2048";
+		}
 
-	argv[argc++] = "-f";
-	
-	if (class->quiet) {
-		argv[argc++] = "4096";
-	} else
-		argv[argc++] = "8192";
+		argv[argc++] = "-f";
 
-	/* Look for extra arguments and add them to the list */
-	strncpy(xargs, class->miscargs, sizeof(xargs) - 1);
-	argptr = xargs;
-	while(argptr && !ast_strlen_zero(argptr)) {
-		argv[argc++] = argptr;
-		argptr = strchr(argptr, ',');
-		if (argptr) {
-			*argptr = '\0';
-			argptr++;
+		if (class->quiet)
+			argv[argc++] = "4096";
+		else
+			argv[argc++] = "8192";
+
+		/* Look for extra arguments and add them to the list */
+		strncpy(xargs, class->miscargs, sizeof(xargs) - 1);
+		argptr = xargs;
+		while(argptr && !ast_strlen_zero(argptr)) {
+			argv[argc++] = argptr;
+			argptr = strchr(argptr, ',');
+			if (argptr) {
+				*argptr = '\0';
+				argptr++;
+			}
+		}
+	} else {
+		/* Format arguments for argv vector */
+		strncpy(xargs, class->miscargs, sizeof(xargs) - 1);
+		argptr = xargs;
+		while(argptr && !ast_strlen_zero(argptr)) {
+			argv[argc++] = argptr;
+			argptr = strchr(argptr, ' ');
+			if (argptr) {
+				*argptr = '\0';
+				argptr++;
+			}
 		}
 	}
 
@@ -195,12 +211,16 @@
 			close(x);
 		/* Child */
 		chdir(class->dir);
-		/* Default install is /usr/local/bin */
-		execv(LOCAL_MPG_123, argv);
-		/* Many places have it in /usr/bin */
-		execv(MPG_123, argv);
-		/* Check PATH as a last-ditch effort */
-		execvp("mpg123", argv);
+		if(class->custom) {
+			execv(argv[0], argv);
+		} else {
+			/* Default install is /usr/local/bin */
+			execv(LOCAL_MPG_123, argv);
+			/* Many places have it in /usr/bin */
+			execv(MPG_123, argv);
+			/* Check PATH as a last-ditch effort */
+			execvp("mpg123", argv);
+		}
 		ast_log(LOG_WARNING, "Exec failed: %s\n", strerror(errno));
 		close(fds[1]);
 		exit(1);
@@ -506,7 +526,9 @@
 	strncpy(moh->class, classname, sizeof(moh->class) - 1);
 	if (miscargs)
 		strncpy(moh->miscargs, miscargs, sizeof(moh->miscargs) - 1);
-	if (!strcasecmp(mode, "mp3") || !strcasecmp(mode, "mp3nb") || !strcasecmp(mode, "quietmp3") || !strcasecmp(mode, "quietmp3nb") || !strcasecmp(mode, "httpmp3")) {
+	if (!strcasecmp(mode, "mp3") || !strcasecmp(mode, "mp3nb") || !strcasecmp(mode, "quietmp3") || !strcasecmp(mode, "quietmp3nb") || !strcasecmp(mode, "httpmp3") || !strcasecmp(mode, "custom")) {
+		if (!strcasecmp(mode, "custom"))
+			moh->custom = 1;
 		if (!strcasecmp(mode, "mp3nb") || !strcasecmp(mode, "quietmp3nb"))
 			moh->single = 1;
 		if (!strcasecmp(mode, "quietmp3") || !strcasecmp(mode, "quietmp3nb"))




More information about the svn-commits mailing list