markster: trunk r107 - in /trunk: ./ tools/

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Thu Nov 2 21:48:09 MST 2006


Author: markster
Date: Thu Nov  2 22:48:08 2006
New Revision: 107

URL: http://svn.digium.com/view/asterisk-gui?rev=107&view=rev
Log:
Add zapscan utility

Added:
    trunk/tools/
    trunk/tools/Makefile
    trunk/tools/zapscan   (with props)
    trunk/tools/zapscan.bin   (with props)
    trunk/tools/zapscan.c
Modified:
    trunk/Makefile

Modified: trunk/Makefile
URL: http://svn.digium.com/view/asterisk-gui/trunk/Makefile?rev=107&r1=106&r2=107&view=diff
==============================================================================
--- trunk/Makefile (original)
+++ trunk/Makefile Thu Nov  2 22:48:08 2006
@@ -14,6 +14,10 @@
 # Basics...
 INSTALL?=install
 BASENAME?=basename
+
+export INSTALL
+export DESTDIR
+export BASENAME
 
 # Overwite config files on "make samples"
 OVERWRITE=y
@@ -52,16 +56,21 @@
   HTTPPREFIX=asterisk
 endif
 HTTPURL=http://$(HTTPHOST):$(HTTPBINDPORT)/$(HTTPPREFIX)/static/config/cfgbasic.html
-
+SUBDIRS=tools
 # Nothing to do yet for building, but one day there could be...
 
-all:
+all: _all
 	@echo " +------- Asterisk-GUI Build Complete -------+"
 	@echo " + Asterisk-GUI has successfully been built, +"
 	@echo " + and can be installed by running:          +"
 	@echo " +                                           +"
 	@echo " +               make install                +"
 	@echo " +-------------------------------------------+"
+
+_all:
+	for x in $(SUBDIRS); do \
+		make -C $$x all ; \
+	done
 
 checkconfig:
 	@echo " --- Checking Asterisk configuration to see if it will support the GUI ---"
@@ -133,8 +142,11 @@
 	@echo ""
 	@echo " --- Good luck! ---	"
 
-_install:
+_install: _all
 	@echo "Installing into $(HTTPDIR)"
+	for x in $(SUBDIRS); do \
+		make -C $$x install ; \
+	done
 	mkdir -p $(CONFIGDIR)
 	mkdir -p $(CONFIGDIR)/images
 	mkdir -p $(CONFIGDIR)/scripts
@@ -182,6 +194,11 @@
 	@echo " +               $(MAKE) checkconfig            +"
 	@echo " +                                           +"
 	@echo " +-------------------------------------------+"
+
+clean:
+	for x in $(SUBDIRS); do \
+		make -C $$x clean ; \
+	done
 
 samples:
 	mkdir -p $(DESTDIR)$(ASTETCDIR)

Added: trunk/tools/Makefile
URL: http://svn.digium.com/view/asterisk-gui/trunk/tools/Makefile?rev=107&view=auto
==============================================================================
--- trunk/tools/Makefile (added)
+++ trunk/tools/Makefile Thu Nov  2 22:48:08 2006
@@ -1,0 +1,25 @@
+#
+# Asterisk -- A telephony toolkit for Linux.
+#
+# Tools makefile
+#
+# Copyright (C) 1999-2006, Digium, Inc.
+#
+# Mark Spencer <markster at digium.com>
+#
+# This program is free software, distributed under the terms of
+# the GNU General Public License
+#
+all: zapscan.bin
+
+
+zapscan.bin: zapscan.o
+	$(CC) -o zapscan.bin zapscan.o
+
+install:
+	$(INSTALL) -m 755 zapscan $(DESTDIR)/sbin
+	$(INSTALL) -m 755 zapscan.bin $(DESTDIR)/sbin
+
+clean: 
+	rm -f zapscan.o
+	rm -f zapscan.bin

Added: trunk/tools/zapscan
URL: http://svn.digium.com/view/asterisk-gui/trunk/tools/zapscan?rev=107&view=auto
==============================================================================
--- trunk/tools/zapscan (added)
+++ trunk/tools/zapscan Thu Nov  2 22:48:08 2006
@@ -1,0 +1,16 @@
+#!/bin/sh
+if [ -f /etc/zaptel.conf.zapscan ] && [ -f /etc/asterisk/zapata.conf.zapscan ]; then
+	rm -f /etc/zaptel.conf
+	rm -f /etc/asterisk/zapata.conf
+	cp -f /etc/zaptel.conf.zapscan /etc/zaptel.conf
+	cp -f /etc/asterisk/zapata.conf.zapscan /etc/asterisk/zapata.conf
+	rm -f /etc/asterisk/zapscan.conf
+	echo -n "Scanning for zaptel devices..."
+	if /sbin/zapscan.bin; then
+		echo "OK"
+	else
+		echo "Failed!"
+	fi
+else
+	echo "Skipping Zap Scanning"
+fi

Propchange: trunk/tools/zapscan
------------------------------------------------------------------------------
    svn:executable = *

Added: trunk/tools/zapscan.bin
URL: http://svn.digium.com/view/asterisk-gui/trunk/tools/zapscan.bin?rev=107&view=auto
==============================================================================
Binary file - no diff available.

Propchange: trunk/tools/zapscan.bin
------------------------------------------------------------------------------
    svn:executable = *

Propchange: trunk/tools/zapscan.bin
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: trunk/tools/zapscan.c
URL: http://svn.digium.com/view/asterisk-gui/trunk/tools/zapscan.c?rev=107&view=auto
==============================================================================
--- trunk/tools/zapscan.c (added)
+++ trunk/tools/zapscan.c Thu Nov  2 22:48:08 2006
@@ -1,0 +1,88 @@
+/*
+ * Detect Zaptel interfaces.
+ *
+ * Written by Mark Spencer <markster at digium.com>
+ *
+ * Copyright (C) 2006 Digium, Inc.
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under thet erms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */  
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <zaptel/zaptel.h>
+
+int main(int argc, char *argv[])
+{
+	int x;
+	int oldsig=-1;
+	int fd = open("/dev/zap/ctl", O_RDWR);
+	struct zt_params ztp;
+	FILE *zdc = fopen("/etc/zaptel.conf", "a");
+	FILE *zsc = fopen("/etc/asterisk/zapscan.conf", "w");
+	FILE *zap = fopen("/etc/asterisk/zapata.conf", "a");
+	if (fd < 0) {
+		fprintf(stderr, "Failed to open /dev/zap/ctl: %s\n", strerror(errno));
+		exit(1);
+	}
+	if (!zdc||!zsc||!zap) {
+		fprintf(stderr, "Failed to open zaptel.conf or zapscan.conf or zapata.conf");
+		exit(1);
+	}
+	for (x=1;;x++) {
+		memset(&ztp, 0, sizeof(ztp));
+		ztp.channo = x;
+		if (ioctl(fd, ZT_GET_PARAMS, &ztp))
+			break;
+		switch (ztp.sigcap & (__ZT_SIG_FXO|__ZT_SIG_FXS)) {
+		case __ZT_SIG_FXO:
+			if (oldsig != 1) {
+				fprintf(zdc, "\nfxoks=%d", x);
+				fprintf(zap, "\nsignalling = fxo_ks\nchannel => %d",x);
+			} else {
+				fprintf(zdc, ",%d",x);
+				fprintf(zap, ",%d",x);
+			}
+			fprintf(zsc, "[%d]\nport=fxo\n", x);
+			oldsig = 1;
+			break;
+		case __ZT_SIG_FXS:
+			if (oldsig != 2) {
+				fprintf(zdc, "\nfxsks=%d", x);
+				fprintf(zap, "\nsignalling = fxs_ks\nchannel => %d",x);
+			} else {
+				fprintf(zdc, ",%d",x);
+				fprintf(zap, ",%d",x);
+			}
+			fprintf(zsc, "[%d]\nport=fxs\n", x);
+			oldsig = 2;
+			break;
+		}
+	}
+	fprintf(zdc, "\n");
+	fprintf(zsc, "\n");
+	fprintf(zap, "\n");
+	fclose(zdc);
+	fclose(zsc);
+	fclose(zap);
+	exit(0);
+}



More information about the asterisk-gui-commits mailing list