home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!uwm.edu!rutgers!modus!lpds!wcp
- From: wcp@lpds.sublink.org (Walter C. Pelissero)
- Newsgroups: alt.sources
- Subject: mgetty - A modular getty v1.0, Part03/04
- Message-ID: <1993Jan22.162156.939@lpds.sublink.org>
- Date: 22 Jan 93 16:21:56 GMT
- Organization: Sweet home under white clouds
- Lines: 1930
- Phone: + 39 2 8464117 - 8435411 (work) 8267089 (home)
- Postal-Address: Via G. de Ruggiero 87, 20142 Milano - Italia
-
- Submitted-by: wcp@lpds
- Archive-name: mgetty-1.0/part03
-
- ---- Cut Here and feed the following to sh ----
- #!/bin/sh
- # this is mgetty10.03 (part 3 of mgetty-1.0)
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file modemio.c continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 3; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test ! -f _shar_wnt_.tmp; then
- echo 'x - still skipping modemio.c'
- else
- echo 'x - continuing file modemio.c'
- sed 's/^X//' << 'SHAR_EOF' >> 'modemio.c' &&
- X {
- X c &= 0177;
- X if ((*bp = c) != '\0')
- X *++bp = '\0';
- X if (mdverbosity > 6)
- X fprintf(stderr, "%s", vgets(c));
- X if (bp >= mdread_buffer + sizeof(mdread_buffer))
- X {
- X relSignals();
- X if (mdverbosity > 6)
- X fprintf(stderr, ">>-FAIL\n");
- X return 0;
- X }
- X if (c == '\r' || c == '\n')
- X {
- X if (tokens)
- X {
- X const char **mp;
- X
- X for (mp = tokens; *mp; ++mp)
- X if (substr(*mp, mdread_buffer) == 0)
- X {
- X relSignals();
- X if (mdverbosity > 6)
- X fprintf(stderr, ">>-OK\n");
- X if (mdverbosity > 4)
- X fprintf(stderr, "%s: got %s\n", myname, *mp);
- X if (ret)
- X *ret = mp - tokens;
- X return (char *)*mp;
- X }
- X }
- X else
- X if (strlen(rp) > 1)
- X {
- X relSignals();
- X bp[-1] = '\0';
- X if (mdverbosity > 6)
- X fprintf(stderr, ">>-OK\n");
- X if (mdverbosity > 4)
- X fprintf(stderr, "%s: got %s\n", myname, rp);
- X return rp;
- X }
- X else
- X rp = bp;
- X }
- X }
- X relSignals();
- X if (mdverbosity > 6)
- X fprintf(stderr, ">>-FAIL");
- X if (!mdtimedout)
- X fprintf(stderr, " %s\n", sys_errlist[errno]);
- X else
- X if (mdverbosity > 4)
- X fprintf(stderr, " no response\n");
- X return 0;
- X}
- X
- Xbool mdhangup(int fd)
- X{
- X struct termio tty_settings, old_tty;
- X bool ret = FAILED;
- X SIGTYPE (*exsh)(int);
- X
- X exsh = signal(SIGHUP, SIG_IGN); /* just in case fd is the
- X controlling tty */
- X if (ioctl(fd, TCGETA, &tty_settings) >= 0)
- X {
- X old_tty = tty_settings;
- X tty_settings.c_cflag &= ~CBAUD;
- X tty_settings.c_cflag |= B0;
- X if (mdverbosity > 5)
- X fprintf(stderr, "%s: hanging\n", myname);
- X if (ioctl(fd, TCSETA, &tty_settings) >= 0)
- X {
- X sleep(1);
- X if (ioctl(fd, TCSETA, &old_tty) >= 0)
- X ret = SUCCEEDED;
- X }
- X }
- X signal(SIGHUP, exsh);
- X return ret;
- X}
- X
- Xvoid mdflushin(int fd)
- X{
- X getSignals();
- X while (!mdtimedout)
- X {
- X char c;
- X
- X alarm(2);
- X read(fd, &c, 1);
- X }
- X relSignals();
- X}
- SHAR_EOF
- echo 'File modemio.c is complete' &&
- true || echo 'restore of modemio.c failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= modemio.h ==============
- if test -f 'modemio.h' -a X"$1" != X"-c"; then
- echo 'x - skipping modemio.h (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting modemio.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'modemio.h' &&
- X/*
- X * $Id: modemio.h,v 1.1 1993/01/06 18:10:08 wcp Exp $
- X *
- X * Copyright (C) 1992 Walter Pelissero
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 1, or (at your option)
- X * any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X/*
- X * $Log: modemio.h,v $
- X * Revision 1.1 1993/01/06 18:10:08 wcp
- X * Initial revision
- X *
- X */
- X
- Xextern unsigned mdverbosity;
- Xextern int mdwrite(const char *, int);
- Xextern char *mdread(unsigned, int, const char **, unsigned *);
- Xextern bool mdhangup(int);
- Xextern void mdflushin(int);
- Xextern bool mdslowrite;
- Xextern char mdread_buffer[];
- SHAR_EOF
- true || echo 'restore of modemio.h failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= play.c ==============
- if test -f 'play.c' -a X"$1" != X"-c"; then
- echo 'x - skipping play.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting play.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'play.c' &&
- X/*
- X * @(#)$Id: play.c,v 1.2 1993/01/13 21:31:54 wcp Exp $
- X *
- X * Copyright (C) 1993 Walter Pelissero
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 2 of the License, or
- X * (at your option) any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X/*
- X * $Log: play.c,v $
- X * Revision 1.2 1993/01/13 21:31:54 wcp
- X * Changed speaker default to TELCOLINE, and forced default change to
- X * INTSPKR if -c is specified.
- X *
- X * Revision 1.1 1993/01/06 18:10:45 wcp
- X * Initial revision
- X *
- X */
- X
- X#include <stdio.h>
- X#include <termio.h>
- X#include <fcntl.h>
- X#include <stdlib.h>
- X#include <errno.h>
- X#include <getopt.h>
- X#include <signal.h>
- X#include "common.h"
- X#include "modemio.h"
- X#include "zyxel.h"
- X#include "voice.h"
- X
- Xstatic char RcsId[] = "@(#)$Id: play.c,v 1.2 1993/01/13 21:31:54 wcp Exp $";
- X#ifdef DEBUG
- Xstatic int verbosity = 9;
- X#else
- Xstatic int verbosity = 0;
- X#endif
- Xconst char *myname;
- Xstatic bool terminated = TRUE;
- Xstatic Port port;
- Xstatic bool already_connected = TRUE;
- X
- Xstatic SIGTYPE terminate(int sig)
- X{
- X if (verbosity)
- X fprintf(stderr, "%s: got signal %d\n", myname, sig);
- X if (terminated)
- X {
- X if (already_connected)
- X resetLine(port);
- X else
- X {
- X mdhangup(port.outfd);
- X mdwrite("ATZ\r", port.outfd);
- X mdflushin(port.infd);
- X closeLine(port);
- X }
- X exit(0);
- X }
- X else
- X {
- X terminated = TRUE;
- X signal(sig, terminate);
- X }
- X#if SIGTYPE == int
- X return 0;
- X#endif
- X}
- X
- Xstatic bool playFile(int infd, int outfd)
- X{
- X int nread;
- X static char eof[] = { DLE, ETX };
- X
- X terminated = FALSE;
- X do
- X {
- X char buf[1024];
- X int i;
- X
- X nread = read(infd, buf, sizeof(buf));
- X for (i = 0; i < nread; ++i)
- X {
- X if (write(outfd, &buf[i], 1) < 1)
- X nread = -1;
- X else
- X if (buf[i] == DLE)
- X write(outfd, &buf[i], 1);
- X }
- X }
- X while (nread > 0 && !terminated);
- X if (write(outfd, eof, sizeof(eof)) < sizeof(eof) || terminated)
- X return FALSE;
- X else
- X {
- X terminated = TRUE;
- X return TRUE;
- X }
- X}
- X
- Xstatic bool play(int fd, Port port, Speaker spkr, VoiceEncoding encoding,
- X unsigned volume)
- X{
- X if (!already_connected)
- X {
- X char buf[32];
- X
- X if (verbosity > 2)
- X fprintf(stderr, "%s: initializing modem\n", myname);
- X sprintf(buf, "ATL%u+FCLASS=8\r", volume);
- X mdwrite(buf, port.outfd);
- X if (receive(2, port.infd) != MDOK)
- X return FALSE;
- X sprintf(buf, "AT+VSM=%u\r", encoding);
- X mdwrite(buf, port.outfd);
- X if (receive(2, port.infd) != MDOK)
- X return FALSE;
- X sprintf(buf, "AT+VLS=%u\r", spkr);
- X mdwrite(buf, port.outfd);
- X if (receive(2, port.infd) != MDVCON)
- X return FALSE;
- X }
- X if (verbosity > 1)
- X fprintf(stderr, "%s: starting playing\n", myname);
- X mdwrite("AT+VTX\r", port.outfd);
- X if (receive(10, port.infd) != MDCONNECT)
- X return FALSE;
- X if (verbosity > 4)
- X fprintf(stderr, "%s: connected: playing...\n", myname);
- X playFile(fd, port.outfd);
- X if (verbosity > 4)
- X fprintf(stderr, "%s: expecting VCON at end of playing\n", myname);
- X if (receive(30, port.infd) != MDVCON)
- X return FALSE;
- X if (!already_connected)
- X {
- X if (verbosity > 2)
- X fprintf(stderr, "%s: resetting modem\n", myname);
- X mdwrite("AT+VLS=0\r", port.outfd);
- X if (receive(2, port.infd) != MDOK)
- X return FALSE;
- X mdwrite("AT+FCLASS=0\r", port.outfd);
- X if (receive(2, port.infd) != MDOK)
- X return FALSE;
- X mdwrite("ATZ\r", port.outfd);
- X sleep(2);
- X mdflushin(port.infd);
- X }
- X return TRUE;
- X}
- X
- Xint main(unsigned argc, char *argv[])
- X{
- X unsigned i;
- X VoiceEncoding encoding = ADPCM2;
- X unsigned volume = 5; /* I don't know if it is relevant */
- X Speaker spkr = TELCOLINE;
- X bool error;
- X const char *device;
- X
- X myname = basename(argv[0]);
- X while ((i = getopt(argc, argv, "s:x:c:v:e:")) != EOF)
- X switch (i)
- X {
- X case 'e':
- X if ((encoding = atoi(optarg)) > LAST_VOICEEN ||
- X encoding < FIRST_VOICEEN)
- X {
- X fprintf(stderr, "%s: encoding not in allowable range (1-3)\n",
- X myname);
- X error = TRUE;
- X }
- X break;
- X case 'v':
- X if ((volume = atoi(optarg)) > 7 || volume < 1)
- X {
- X fprintf(stderr, "%s: volume not in allowable range (1-7)\n",
- X myname);
- X error = TRUE;
- X }
- X break;
- X case 'c':
- X device = optarg;
- X already_connected = FALSE;
- X spkr = INTSPKR;
- X break;
- X case 'x':
- X verbosity = atoi(optarg);
- X break;
- X case 's':
- X switch (atoi(optarg))
- X {
- X case 0:
- X spkr = TELCOLINE;
- X break;
- X case 1:
- X spkr = EXTMIC;
- X break;
- X case 2:
- X spkr = INTSPKR;
- X break;
- X default:
- X fprintf(stderr, "%s: invalid speaker (0=telco, 1=mic, 2=int)\n",
- X myname);
- X error = TRUE;
- X break;
- X }
- X break;
- X default:
- X error = TRUE;
- X break;
- X }
- X if (argc - optind < 1)
- X if (already_connected)
- X {
- X fprintf(stderr, "%s: cannot get data data from stdin while connected to stdin/out\n", myname);
- X error = TRUE;
- X }
- X else if (isatty(0))
- X {
- X fprintf(stderr, "%s: are you sure you want to play from your keyboard?\n", myname);
- X error = TRUE;
- X }
- X if (error)
- X {
- X fprintf(stderr, "%s\nusage: %s [-s speaker][-x debug_level][-c device][-v volume]
- X \t[-e encoding][voice_file ...]\n",
- X RcsId, myname);
- X exit(-1);
- X }
- X mdverbosity = verbosity;
- X signal(SIGQUIT, terminate);
- X signal(SIGTERM, terminate);
- X signal(SIGHUP, terminate);
- X signal(SIGINT, terminate);
- X if (already_connected)
- X {
- X struct termio tty;
- X
- X port.infd = 0;
- X port.outfd = 1;
- X ioctl(port.outfd, TCGETA, &tty);
- X port.orig_tty_settings = tty;
- X setLine(port);
- X }
- X else
- X port = openLine(device);
- X if (argc - optind)
- X for (i = optind; i < argc; ++i)
- X {
- X int fd;
- X
- X if ((fd = open(argv[i], O_RDONLY)) >= 0)
- X {
- X play(fd, port, spkr, encoding, volume);
- X close(fd);
- X }
- X else
- X fprintf(stderr, "%s: cannot open %s: skipped\n", myname, argv[i]);
- X }
- X else
- X /* If no files specified in command line, get data from stdin */
- X play(0, port, spkr, encoding, volume);
- X if (already_connected)
- X resetLine(port);
- X else
- X {
- X mdhangup(port.outfd);
- X closeLine(port);
- X }
- X return exit(0), 0;
- X}
- SHAR_EOF
- true || echo 'restore of play.c failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= printfax.sh ==============
- if test -f 'printfax.sh' -a X"$1" != X"-c"; then
- echo 'x - skipping printfax.sh (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting printfax.sh (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'printfax.sh' &&
- X: use /bin/sh
- X#
- X# $Id: printfax.sh,v 1.3 1993/01/22 15:14:24 wcp Exp $
- X#
- X# Copyright (C) 1992 Walter Pelissero
- X#
- X# This program is free software; you can redistribute it and/or modify
- X# it under the terms of the GNU General Public License as published by
- X# the Free Software Foundation; either version 1, or (at your option)
- X# any later version.
- X#
- X# This program is distributed in the hope that it will be useful,
- X# but WITHOUT ANY WARRANTY; without even the implied warranty of
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X# GNU General Public License for more details.
- X#
- X# You should have received a copy of the GNU General Public License
- X# along with this program; if not, write to the Free Software
- X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X#
- X
- X#
- X# $Log: printfax.sh,v $
- X# Revision 1.3 1993/01/22 15:14:24 wcp
- X# Removed magic string.
- X#
- X# Revision 1.2 1993/01/07 23:18:00 wcp
- X# Corrected a test.
- X#
- X# Revision 1.1 1993/01/06 18:11:29 wcp
- X# Initial revision
- X#
- X#
- X
- XPBMPLUS=%PBMPLUS%
- XG3TOPBM=$PBMPLUS/g3topbm
- XPNMSCALE=$PBMPLUS/pnmscale
- XPGMTOPBM=$PBMPLUS/pgmtopbm
- XPBMTOEPSON=$PBMPLUS/pbmtoepson
- XTMP=/tmp/pf$$
- X
- X[ $# -ne 1 ] && {
- X echo "usage: $0 base_name"
- X exit 1
- X}
- X
- Xtrap 'rm -f $TMP; exit 1' 1 2 3 4 5 6 7 8 9 10 12 14 15 16 17
- X(
- Xpage=0
- Xfor f in `ls -tr $1.*`
- Xdo
- X [ "$f" = "$1.*" ] && break
- X [ $page -eq 0 ] || echo "\f"
- X caller=`sed -n '1,/^DATA:/s/^CALLER:[ \t]*\(.*\)/\1/p' $f`
- X date=`sed -n '1,/^DATA:/s/^DATE:[ \t]*\(.*\)/\1/p' $f`
- X resolution=`sed -n '1,/^DATA:/s/^RESOLUTION:[ \t]*\(.*\)/\1/p' $f`
- X speed=`sed -n '1,/^DATA:/s/^SPEED:[ \t]*\(.*\)/\1/p' $f`
- X page=`expr $page + 1`
- X echo "Date: $date\tFrom: $caller"
- X echo "Page: $page\r\t\t\t\tSpeed: $speed\t\tResolution: \c"
- X tail +`awk '/^DATA:$/ { print NR + 1; exit }' $f` $f > $TMP
- X if [ "$resolution" -eq 0 ]
- X then
- X echo LOW
- X $G3TOPBM -big -delete -stretch $TMP | $PBMTOEPSON -triple -24pin
- X else
- X echo HIGH
- X $G3TOPBM -big -delete $TMP | $PBMTOEPSON -triple -24pin
- X fi
- Xdone
- X) | lp -s # -tFax
- Xrm -f $TMP
- SHAR_EOF
- true || echo 'restore of printfax.sh failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= record.c ==============
- if test -f 'record.c' -a X"$1" != X"-c"; then
- echo 'x - skipping record.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting record.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'record.c' &&
- X/*
- X * @(#)$Id: record.c,v 1.3 1993/01/22 15:14:24 wcp Exp $
- X *
- X * Copyright (C) 1993 Walter Pelissero
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 2 of the License, or
- X * (at your option) any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X/*
- X * $Log: record.c,v $
- X * Revision 1.3 1993/01/22 15:14:24 wcp
- X * Removed magic string.
- X *
- X * Revision 1.2 1993/01/13 21:33:46 wcp
- X * Forced default to EXTMIC in case of -c option.
- X *
- X * Revision 1.1 1993/01/06 18:12:32 wcp
- X * Initial revision
- X *
- X */
- X
- X#include <sys/types.h>
- X#ifdef DEBUG
- X#include <dbmalloc.h>
- X#endif
- X#include <stdio.h>
- X#include <fcntl.h>
- X#include <termio.h>
- X#include <getopt.h>
- X#include <string.h>
- X#include <ctype.h>
- X#include <errno.h>
- X#include <signal.h>
- X#include <utmp.h>
- X#include <stdlib.h>
- X#include "common.h"
- X#include "modemio.h"
- X#include "zyxel.h"
- X#include "voice.h"
- X
- Xstatic char RcsId[] = "@(#)$Id: record.c,v 1.3 1993/01/22 15:14:24 wcp Exp $";
- Xstatic Port port;
- Xstatic bool already_connected = TRUE;
- Xconst char *myname;
- Xunsigned allow_digits = 0;
- Xbool allow_fax = TRUE;
- X#ifdef DEBUG
- Xstatic int verbosity = 9;
- X#else
- Xstatic int verbosity = 0;
- X#endif
- Xstatic bool timedout = TRUE;
- X
- Xstatic SIGTYPE terminate(int sig)
- X{
- X if (verbosity)
- X fprintf(stderr, "%s: got signal %d\n", myname, sig);
- X if (timedout)
- X {
- X if (already_connected)
- X resetLine(port);
- X else
- X {
- X mdhangup(port.outfd);
- X mdwrite("ATZ\r", port.outfd);
- X mdflushin(port.infd);
- X closeLine(port);
- X }
- X exit(0);
- X }
- X else
- X {
- X timedout = TRUE;
- X signal(sig, terminate);
- X }
- X#if SIGTYPE == int
- X return 0;
- X#endif
- X}
- X
- Xstatic SIGTYPE timeout(int sig)
- X{
- X timedout = TRUE;
- X signal(sig, timeout);
- X#if SIGTYPE == int
- X return 0;
- X#endif
- X}
- X
- Xtypedef enum {
- X REC_ERROR = -1,
- X REC_OK = 0,
- X REC_SILENCE,
- X REC_FAX,
- X REC_0 = 10,
- X REC_1,
- X REC_2,
- X REC_3,
- X REC_4,
- X REC_5,
- X REC_6,
- X REC_7,
- X REC_8,
- X REC_9,
- X REC_D,
- X REC_A
- X } ReceiveResult;
- X
- Xinline int safe_write(int fd, const char *p, unsigned len)
- X{
- X if (fd < 0)
- X return 0;
- X return write(fd, p, len);
- X}
- X
- X#define ELAPSED (time(0) - timerStart)
- X
- Xstatic int receiveMessage(int infd, int outfd,
- X unsigned min_secs, unsigned max_secs)
- X{
- X bool dle = FALSE;
- X unsigned phase = 0;
- X unsigned long timerStart;
- X
- X timedout = FALSE;
- X alarm(max_secs);
- X timerStart = time(0);
- X do
- X {
- X char buf[1024];
- X int received;
- X
- X if ((received = read(infd, buf, sizeof(buf))) < 0)
- X {
- X alarm(0);
- X timedout = TRUE;
- X return ELAPSED >= max_secs ? REC_OK : REC_ERROR;
- X }
- X else
- X {
- X int mark, i;
- X
- X for (i = mark = 0; i < received; ++i)
- X {
- X if (dle)
- X {
- X switch (buf[i])
- X {
- X case DLE:
- X safe_write(outfd, &buf[i], 1);
- X break;
- X case '0':
- X case '1':
- X case '2':
- X case '3':
- X case '4':
- X case '5':
- X case '6':
- X case '7':
- X case '8':
- X case '9':
- X if (verbosity > 6)
- X fprintf(stderr, "%s: got DTMF %c\n", myname, buf[i]);
- X if (allow_digits && ELAPSED < min_secs)
- X {
- X /* caller typed a digit */
- X timedout = TRUE;
- X return REC_0 + buf[i] - '0';
- X }
- X break;
- X case '#':
- X case '*':
- X if (verbosity > 6)
- X fprintf(stderr, "%s: got DTMF %c\n", myname, buf[i]);
- X if (allow_digits && ELAPSED < min_secs)
- X {
- X /* caller typed '#' or '*' */
- X timedout = TRUE;
- X return buf[i] == '#' ? REC_D : REC_A;
- X }
- X break;
- X case 'c': /* T.30 fax calling tone */
- X if (verbosity > 6)
- X fprintf(stderr, "%s: got T.30 fax tone\n", myname);
- X if (allow_fax)
- X {
- X /* it was a fax machine */
- X timedout = TRUE;
- X return REC_FAX;
- X }
- X break;
- X case 'b': /* Busy tone */
- X if (verbosity > 6)
- X fprintf(stderr, "%s: got busy tone\n", myname);
- X timedout = TRUE;
- X return (ELAPSED < min_secs) ? REC_ERROR : REC_OK;
- X case 'q': /* quiet after talking */
- X if (verbosity > 6)
- X fprintf(stderr, "%s: got quiet\n", myname);
- X timedout = TRUE;
- X /* 5 is a magic number to be parametrized
- X later -wcp1/3/93. */
- X return (ELAPSED - 5 < min_secs) ? REC_SILENCE : REC_OK;
- X case 's': /* silence (no response) */
- X if (verbosity > 6)
- X fprintf(stderr, "%s: got silence\n", myname);
- X timedout = TRUE;
- X return REC_SILENCE; /* not a human */
- X case ETX:
- X alarm(0);
- X timedout = TRUE;
- X return REC_OK;
- X default:
- X break;
- X }
- X dle = FALSE;
- X }
- X else
- X {
- X if (buf[i] == DLE)
- X {
- X dle = TRUE;
- X safe_write(outfd, &buf[mark], i - mark);
- X mark = i + 2;
- X }
- X }
- X }
- X if (mark < i)
- X safe_write(outfd, &buf[mark], received - mark);
- X }
- X if (timedout)
- X {
- X if (phase++)
- X return REC_ERROR;
- X mdwrite("AT\r", 1); /* close the connection */
- X timedout = FALSE;
- X alarm(30); /* should be enough to drain input */
- X }
- X }
- X while (!timedout);
- X return REC_OK;
- X}
- X
- X#undef ELAPSED
- X
- Xstatic int recordVoice(int outfd, unsigned min_secs, unsigned max_secs,
- X Speaker mic, Port port, VoiceEncoding encoding)
- X{
- X int ret;
- X
- X if (verbosity > 3)
- X fprintf(stderr, "%s: starting receiving\n", myname);
- X if (already_connected && outfd >= 0)
- X {
- X FILE *outfp = fdopen(outfd, "w");
- X long t = time(0);
- X
- X fprintf(outfp, "DATE: %s", ctime(&t));
- X#ifdef NEVER
- X fprintf(outfp, "CALLER: unknown\n"); /* currently not implemented */
- X#endif /* NEVER */
- X fprintf(outfp, "ENCODING: %u\n", encoding);
- X fprintf(outfp, "DATA:\n");
- X fflush(outfp);
- X }
- X else
- X {
- X char buf[16];
- X
- X mdwrite("AT+FCLASS=8\r", port.outfd);
- X if (receive(2, port.infd) != MDOK)
- X return REC_ERROR;
- X sprintf(buf, "AT+VSM=%u\r", encoding);
- X mdwrite(buf, port.outfd);
- X if (receive(2, port.infd) != MDOK)
- X return REC_ERROR;
- X sprintf(buf, "AT+VLS=%u\r", mic);
- X mdwrite(buf, port.outfd);
- X if (receive(2, port.infd) != MDVCON)
- X return REC_ERROR;
- X }
- X mdwrite("AT+VRX\r", port.outfd);
- X if (receive(10, port.infd) != MDCONNECT)
- X return REC_ERROR;
- X if (verbosity > 4)
- X fprintf(stderr, "%s: recording...\n", myname);
- X ret = receiveMessage(port.infd, outfd, min_secs, max_secs);
- X /* the following line may be a repetition butit is necessary
- X to be sure to break any recording */
- X mdwrite("AT\r", port.outfd);
- X if (verbosity > 7)
- X fprintf(stderr, "%s: flushing input...\n", myname);
- X mdflushin(port.infd);
- X if (!already_connected)
- X {
- X mdwrite("AT+VLS=0\r", port.outfd);
- X if (receive(2, port.infd) != MDOK)
- X return REC_ERROR;
- X mdwrite("AT+FCLASS=0\r", port.outfd);
- X if (receive(2, port.infd) != MDOK)
- X return REC_ERROR;
- X mdwrite("ATZ\r", port.outfd);
- X sleep(2);
- X mdflushin(port.infd);
- X }
- X return ret;
- X}
- X
- Xint main(unsigned argc, char *argv[])
- X{
- X unsigned max_rec_time = 5 * 60, min_rec_time = 10;
- X const char *base = 0;
- X int i, ret;
- X bool error = FALSE;
- X const char *device;
- X Speaker mic = TELCOLINE;
- X VoiceEncoding encoding = ADPCM2;
- X
- X myname = basename(argv[0]);
- X while ((i = getopt(argc, argv, "fdt:x:c:m:e:")) != EOF)
- X switch (i)
- X {
- X case 'e':
- X if ((encoding = atoi(optarg)) > LAST_VOICEEN ||
- X encoding < FIRST_VOICEEN)
- X {
- X fprintf(stderr, "%s: encoding not in allowable range (%u-%u)\n",
- X myname, FIRST_VOICEEN, LAST_VOICEEN);
- X error = TRUE;
- X }
- X break;
- X case 'm':
- X switch (atoi(optarg))
- X {
- X case 0:
- X mic = TELCOLINE;
- X break;
- X case 1:
- X mic = EXTMIC;
- X break;
- X case 2:
- X mic = INTSPKR;
- X break;
- X default:
- X fprintf(stderr, "%s: invalid speaker (0=telco, 1=mic, 2=int)\n",
- X myname);
- X error = TRUE;
- X break;
- X }
- X break;
- X case 'c':
- X device = optarg;
- X already_connected = FALSE;
- X mic = EXTMIC;
- X break;
- X case 'f':
- X allow_fax = FALSE;
- X break;
- X case 'd':
- X ++allow_digits;
- X break;
- X case 'x':
- X verbosity = atoi(optarg);
- X break;
- X case 't':
- X {
- X char *p = strchr(optarg, ':');
- X
- X if (p)
- X {
- X *p++ = '\0';
- X max_rec_time = atoi(p);
- X }
- X min_rec_time = atoi(optarg);
- X }
- X break;
- X default:
- X error = TRUE;
- X break;
- X }
- X if (argc > optind)
- X base = argv[optind++];
- X if (!base)
- X if (already_connected)
- X {
- X error = TRUE;
- X fprintf(stderr, "%s: at least -c or output must be specified\n",
- X myname);
- X }
- X else if (isatty(1))
- X {
- X error = TRUE;
- X fprintf(stderr, "%s: are you sure you want do \"display\" sound?\n",
- X myname);
- X }
- X if (optind < argc) /* too many arguments */
- X error = TRUE;
- X if (error)
- X {
- X fprintf(stderr, "%s\nusage: %s [-x level][-f][-d][-m microphone][-e encoding]
- X\t[-t min_seconds[:max_seconds][-c device][out{file|dir}]\n", RcsId, myname);
- X exit(-1);
- X }
- X mdverbosity = verbosity;
- X signal(SIGALRM, timeout);
- X signal(SIGQUIT, terminate);
- X signal(SIGTERM, terminate);
- X signal(SIGHUP, timeout);
- X signal(SIGINT, terminate);
- X if (already_connected)
- X {
- X struct termio tty;
- X
- X port.infd = 0;
- X port.outfd = 1;
- X ioctl(port.outfd, TCGETA, &tty);
- X port.orig_tty_settings = tty;
- X setLine(port);
- X }
- X else
- X port = openLine(device);
- X if (base)
- X {
- X unsigned nmsg = 1;
- X char msg_name[1024];
- X struct stat st;
- X
- X if (stat(base, &st) == 0 && (st.st_mode & S_IFDIR))
- X {
- X /* Base is a directory.
- X */
- X for (; nmsg > 0; ++nmsg)
- X {
- X sprintf(msg_name, "%s/in%08u", base, nmsg);
- X /* We avoid to overwrite existing messages */
- X if (access(msg_name, F_OK))
- X break;
- X }
- X }
- X else
- X /* Base is a probably inexistent file name.
- X */
- X strcpy(msg_name, base);
- X if (nmsg == 0)
- X {
- X fprintf(stderr, "%s: spool area is full.\n", myname);
- X if (already_connected)
- X resetLine(port);
- X else
- X {
- X mdhangup(port.outfd);
- X closeLine(port);
- X }
- X exit(1);
- X }
- X else
- X {
- X int outfd;
- X
- X if (allow_digits > 1)
- X outfd = -1;
- X else
- X if ((outfd = open(msg_name, O_WRONLY | O_CREAT, 0644)) < 0)
- X {
- X fprintf(stderr, "%s: cannot create %s (%s)\n",
- X myname, msg_name, sys_errlist[errno]);
- X if (!already_connected)
- X {
- X mdhangup(port.outfd);
- X closeLine(port);
- X }
- X exit(2);
- X }
- X ret = recordVoice(outfd, min_rec_time, max_rec_time, mic, port,
- X encoding);
- X if (outfd >= 0)
- X close(outfd);
- X if (ret != REC_OK)
- X unlink(msg_name);
- X }
- X }
- X else
- X ret = recordVoice(1, min_rec_time, max_rec_time, mic, port, encoding);
- X if (!already_connected)
- X {
- X mdhangup(port.outfd);
- X closeLine(port);
- X }
- X if (verbosity > 8)
- X fprintf(stderr, "%s: returning %d\n", myname, ret);
- X return exit(ret), -1;
- X}
- SHAR_EOF
- true || echo 'restore of record.c failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= scripts/zyxel4.tcl ==============
- if test ! -d 'scripts'; then
- echo 'x - creating directory scripts'
- mkdir 'scripts'
- fi
- if test -f 'scripts/zyxel4.tcl' -a X"$1" != X"-c"; then
- echo 'x - skipping scripts/zyxel4.tcl (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting scripts/zyxel4.tcl (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'scripts/zyxel4.tcl' &&
- X#
- X# $Id: zyxel4.tcl,v 1.3 1993/01/21 19:33:18 wcp Exp $
- X#
- X# Copyright (C) 1992 Walter Pelissero
- X#
- X# This program is free software; you can redistribute it and/or modify
- X# it under the terms of the GNU General Public License as published by
- X# the Free Software Foundation; either version 1, or (at your option)
- X# any later version.
- X#
- X# This program is distributed in the hope that it will be useful,
- X# but WITHOUT ANY WARRANTY; without even the implied warranty of
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X# GNU General Public License for more details.
- X#
- X# You should have received a copy of the GNU General Public License
- X# along with this program; if not, write to the Free Software
- X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X#
- X
- X#
- X# $Log: zyxel4.tcl,v $
- X# Revision 1.3 1993/01/21 19:33:18 wcp
- X# Changed buggy invocation of fax receiver.
- X#
- X# Revision 1.2 1993/01/13 21:37:24 wcp
- X# Removed unuseful options in CLASS2_RECEIVER and changed
- X# syntax to the new "invoke" command.
- X#
- X# Revision 1.1 1993/01/06 18:20:26 wcp
- X# Initial revision
- X#
- X#
- X
- X#
- X# Mgetty tcl startup script for ZyXEL U1496 modems with ROMs 4.xx
- X# supporting modem and fax capabilities.
- X#
- X
- Xset LOCAL_NUMBER "+39-2-8435411"
- Xset CLASS2_RECEIVER "/usr/local/lib/mgetty/c2rec"
- X
- Xbaudrate 19200
- Xsend "ATZ\r"
- Xsleep 2
- Xsend "ATE0Q0\r"
- Xflush_input
- Xsend "ATPV1X6S0=1S7=60&B0&C1&D3&N0\r"
- Xif { [receive 2 "OK"] != "OK" } { exit }
- Xsend "ATM0+FCLASS=2;+FAA=1;+FCR=1;+FBOR=0;+FLID=\"$LOCAL_NUMBER\"\r"
- Xif { [receive 2 "OK"] != "OK" } { exit }
- Xsend "AT+FDCC=1,5,0,2,0,0,0\r"
- Xif { [receive 2 "OK"] != "OK" } { exit }
- Xset buffer ""
- Xwhile { $buffer == "" } {
- X set buffer [ listen ]
- X case $buffer in {
- X { "CONNECT 1200*" } { baudrate 1200 }
- X { "CONNECT 2400*" } { baudrate 2400 }
- X { "CONNECT 4800*" } { baudrate 4800 }
- X { "CONNECT 9600*" } { baudrate 9600 }
- X { "CONNECT 19200*" } { baudrate 19200 }
- X { "CONNECT 7200*" } { baudrate 7200 }
- X { "CONNECT 12000*" } { baudrate 12000 }
- X { "CONNECT 14400*" } { baudrate 14400 }
- X { "CONNECT 16800*" } { baudrate 16800 }
- X { "CONNECT 38400*" } { baudrate 38400 }
- X { "CONNECT 57600*" } { baudrate 57600 }
- X { "CONNECT 76800*" } { baudrate 76800 }
- X { "+FCON*" } {
- X baudrate 19200
- X invoke $CLASS2_RECEIVER -p /usr/spool/fax
- X exit
- X }
- X default { set buffer "" }
- X }
- X}
- X
- X# If we are not able to decipher what comes from tty it is probably
- X# time to give a try to getty
- X# mode remote cooked no_flow
- Xlogin
- SHAR_EOF
- true || echo 'restore of scripts/zyxel4.tcl failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= scripts/zyxel5.tcl ==============
- if test -f 'scripts/zyxel5.tcl' -a X"$1" != X"-c"; then
- echo 'x - skipping scripts/zyxel5.tcl (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting scripts/zyxel5.tcl (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'scripts/zyxel5.tcl' &&
- X#
- X# $Id: zyxel5.tcl,v 1.4 1993/01/21 19:40:54 wcp Exp $
- X#
- X# Copyright (C) 1992 Walter Pelissero
- X#
- X# This program is free software; you can redistribute it and/or modify
- X# it under the terms of the GNU General Public License as published by
- X# the Free Software Foundation; either version 1, or (at your option)
- X# any later version.
- X#
- X# This program is distributed in the hope that it will be useful,
- X# but WITHOUT ANY WARRANTY; without even the implied warranty of
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X# GNU General Public License for more details.
- X#
- X# You should have received a copy of the GNU General Public License
- X# along with this program; if not, write to the Free Software
- X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X#
- X
- X#
- X# $Log: zyxel5.tcl,v $
- X# Revision 1.4 1993/01/21 19:40:54 wcp
- X# Minor mods.
- X#
- X# Revision 1.3 1993/01/13 21:39:35 wcp
- X# Changed to use the new "invoke" command.
- X#
- X# Revision 1.2 1993/01/07 23:20:23 wcp
- X# Removed DTMF support. No way to test it.
- X# Various cleanings.
- X#
- X# Revision 1.1 1993/01/06 18:20:26 wcp
- X# Initial revision
- X#
- X#
- X
- X#
- X# Mgetty tcl startup script for ZyXEL U1496 modems with ROMs 5.xx
- X# supporting voice, modem, and fax connections.
- X#
- X
- Xset LOCAL_NUMBER "+39-2-8435411"
- Xset LIBDIR /usr/local/lib/mgetty
- Xset CLASS2_RECEIVER $LIBDIR/c2rec
- Xset RECORDER $LIBDIR/record
- Xset PLAYER $LIBDIR/play
- Xset SOUND $LIBDIR/sound
- X
- Xbaudrate 38400
- Xsend "ATZ\r"
- Xsleep 2
- Xsend "ATE0Q0\r"
- Xflush_input
- Xsend "ATPV1X7S0=0S7=60&B0&C1&D3&N0S39.4=1S38.4=0S41.7=0\r"
- Xif { [receive 2 OK] == "" } { exit }
- Xsend "ATM0+FCLASS=2;+FBOR=0;+FCR=1;+FLID=\"$LOCAL_NUMBER\"\r"
- Xif { [receive 2 OK] == "" } { exit }
- Xsend "AT+FDCC=1,5,0,2,0,0,0\r"
- Xif { [receive 2 OK] == "" } { exit }
- X
- X# set in voice mode
- Xsend "AT+FCLASS=8\r"
- Xif { [receive 2 OK] == "" } { exit }
- X#
- X# Wait an incoming call
- X#
- Xif { [listen] != "RING" } { exit }
- X
- X#
- X# Someone is ringing, let's listen to him/her
- X#
- Xsend "AT+VSM=2;+VBT=2;+VSD=20,40\r"
- Xif { [receive 2 OK] == "" } { exit }
- Xsend "AT+VLS=2\r"
- Xif { [receive 2 VCON] == "" } { exit }
- X
- X# Give a greeting message...
- Xsleep 1
- Xinvoke $PLAYER $SOUND/greetings
- X# ...and end it with a beep.
- Xsend "AT+VTS=\[1355,0,5\]\r"
- Xif { [receive 5 OK] == "" } { exit }
- X
- X# start recording
- Xcase [invoke $RECORDER -t 6:60 /usr/spool/voice] in {
- X { 0 } {
- X #
- X # Message has been recorded succesfully.
- X # (also if time expired)
- X #
- X send "AT+VTS=\[955,0,10\]\r"
- X if { [receive 5 OK] == "" } { exit }
- X invoke $PLAYER $SOUND/salutations
- X send "AT+VLS=0\r"
- X if { [receive 2 OK] == "" } { exit }
- X send "AT+FCLASS=0\r"
- X if { [receive 2 OK] == "" } { exit }
- X send "ATZ\r"
- X sleep 2
- X exit
- X }
- X { 1 } {
- X #
- X # Got silence. It may be a modem or someone who
- X # hanged without talking.
- X #
- X send "AT+FCLASS=0\r"
- X if { [receive 2 OK] == "" } { exit }
- X send "ATA\r"
- X set buffer [receive 60]
- X case $buffer in {
- X { "CONNECT 1200*" } { baudrate 1200 }
- X { "CONNECT 2400*" } { baudrate 2400 }
- X { "CONNECT 4800*" } { baudrate 4800 }
- X { "CONNECT 9600*" } { baudrate 9600 }
- X { "CONNECT 19200*" } { baudrate 19200 }
- X { "CONNECT 7200*" } { baudrate 7200 }
- X { "CONNECT 12000*" } { baudrate 12000 }
- X { "CONNECT 14400*" } { baudrate 14400 }
- X { "CONNECT 16800*" } { baudrate 16800 }
- X { "CONNECT 38400*" } { baudrate 38400 }
- X { "CONNECT 57600*" } { baudrate 57600 }
- X { "CONNECT 76800*" } { baudrate 76800 }
- X { "NO CARRIER*" } { exit }
- X default { exit }
- X }
- X login
- X exit 1
- X }
- X { 2 } {
- X #
- X # Received a T.30 fax tone.
- X #
- X baudrate 19200
- X send "AT+FCLASS=2;+FAA=0\r"
- X if { [receive 2 OK] == "" } { exit }
- X send "ATA\r"
- X if { [receive 20 +FCON] == "" } { exit }
- X invoke $CLASS2_RECEIVER -p /usr/spool/fax
- X exit
- X }
- X default { exit }
- X}
- SHAR_EOF
- true || echo 'restore of scripts/zyxel5.tcl failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= scripts/zyxel5cb.tcl ==============
- if test -f 'scripts/zyxel5cb.tcl' -a X"$1" != X"-c"; then
- echo 'x - skipping scripts/zyxel5cb.tcl (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting scripts/zyxel5cb.tcl (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'scripts/zyxel5cb.tcl' &&
- X#
- X# $Id: zyxel5cb.tcl,v 1.3 1993/01/21 19:35:49 wcp Exp $
- X#
- X# Copyright (C) 1992 Walter Pelissero
- X#
- X# This program is free software; you can redistribute it and/or modify
- X# it under the terms of the GNU General Public License as published by
- X# the Free Software Foundation; either version 1, or (at your option)
- X# any later version.
- X#
- X# This program is distributed in the hope that it will be useful,
- X# but WITHOUT ANY WARRANTY; without even the implied warranty of
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X# GNU General Public License for more details.
- X#
- X# You should have received a copy of the GNU General Public License
- X# along with this program; if not, write to the Free Software
- X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X#
- X
- X#
- X# $Log: zyxel5cb.tcl,v $
- X# Revision 1.3 1993/01/21 19:35:49 wcp
- X# Modified documentation; Added support for different, previosly
- X# unexpected, return strings when dialing back.
- X# Added a "default" sequence of commands in case of unexpected
- X# return code of record.
- X#
- X# Revision 1.2 1993/01/13 21:38:47 wcp
- X# Changed to use the new "invoke" command.
- X#
- X# Revision 1.1 1993/01/07 23:22:05 wcp
- X# Initial revision
- X#
- X#
- X
- X#
- X# Mgetty tcl startup script for ZyXEL U1496 modems with ROMs 5.xx
- X# supporting voice, modem, and fax connections and "blind" call-back.
- X#
- X
- Xset LOCAL_NUMBER "+39-2-8435411" ;# the local fax number
- Xset LIBDIR /usr/local/lib/mgetty
- Xset CLASS2_RECEIVER $LIBDIR/c2rec
- Xset RECORDER $LIBDIR/record
- Xset PLAYER $LIBDIR/play
- Xset SOUND $LIBDIR/sound
- Xset ANRING 3 ;# number of rings to answer
- X# this is the call-back string: it must contain all the parameter
- X# settings one may need plus a "D" character preceding the phone number
- Xset CBNUMBER "&N16D82,67089" ;# example: set V.21 and dial
- X
- Xbaudrate 38400
- Xsend "ATZ\r"
- Xsleep 2
- Xsend "ATE0Q0\r"
- Xflush_input
- Xsend "ATPV1X7S0=0S7=60&B0&C1&D3&N0S39.4=1S38.4=0S41.7=0\r"
- Xif { [receive 2 OK] == "" } { exit }
- Xsend "ATM0+FCLASS=2;+FBOR=0;+FCR=1;+FLID=\"$LOCAL_NUMBER\"\r"
- Xif { [receive 2 OK] == "" } { exit }
- Xsend "AT+FDCC=1,5,0,2,0,0,0\r"
- Xif { [receive 2 OK] == "" } { exit }
- X
- Xsend "AT+FCLASS=8\r" ;# set in voice mode
- Xif { [receive 2 OK] == "" } { exit }
- X#
- X# Wait an incoming call
- X#
- Xif { [listen] != "RING" } { exit }
- Xset rings 1
- Xset phase 1
- Xwhile { $rings < $ANRING } {
- X if { [receive 10 RING] == "" } {
- X if { $phase == 2 } {
- X flush_input
- X send "AT&B1+FCLASS=0;$CBNUMBER\r"
- X case [receive [expr {[string length $CBNUMBER] * 3 + 60}] CONNECT BUSY "NO CARRIER" "NO ANSWER"] in {
- X { CONNECT } {
- X sleep 2
- X login
- X exit 1
- X }
- X default { exit 1 }
- X }
- X }
- X if { [receive 20 RING] == "" } { exit }
- X set phase [expr {$phase + 1}]
- X set rings 1
- X } else { set rings [expr {$rings + 1}] }
- X}
- X
- X#
- X# Someone is ringing, let's listen to him/her
- X#
- Xsend "AT+VSM=2;+VBT=2;+VSD=20,30\r"
- Xif { [receive 2 OK] == "" } { exit }
- Xsend "AT+VLS=2\r"
- Xif { [receive 2 VCON] == "" } { exit }
- X
- Xsleep 1
- Xinvoke $PLAYER $SOUND/greetings ;# Give a greeting message...
- Xsend "AT+VTS=\[1355,0,5\]\r" ;# ...and end it with a beep.
- Xif { [receive 5 OK] == "" } { exit }
- X
- X# start recording
- Xcase [invoke $RECORDER -t 7:60 /usr/spool/voice] in {
- X { 0 } {
- X #
- X # Message has been recorded succesfully.
- X # (also if time expired)
- X #
- X send "AT+VTS=\[955,0,10\]\r"
- X if { [receive 5 OK] == "" } { exit }
- X invoke $PLAYER $SOUND/salutations
- X send "AT+VLS=0\r"
- X if { [receive 2 OK] == "" } { exit }
- X send "AT+FCLASS=0\r"
- X if { [receive 2 OK] == "" } { exit }
- X send "ATZ\r"
- X sleep 2
- X exit
- X }
- X { 1 } {
- X #
- X # Got silence. It may be a modem or someone who
- X # hanged without talking.
- X #
- X send "AT+FCLASS=0\r"
- X if { [receive 2 OK] == "" } { exit }
- X send "ATA\r"
- X set buffer [receive 60]
- X case $buffer in {
- X { "CONNECT 1200*" } { baudrate 1200 }
- X { "CONNECT 2400*" } { baudrate 2400 }
- X { "CONNECT 4800*" } { baudrate 4800 }
- X { "CONNECT 9600*" } { baudrate 9600 }
- X { "CONNECT 19200*" } { baudrate 19200 }
- X { "CONNECT 7200*" } { baudrate 7200 }
- X { "CONNECT 12000*" } { baudrate 12000 }
- X { "CONNECT 14400*" } { baudrate 14400 }
- X { "CONNECT 16800*" } { baudrate 16800 }
- X { "CONNECT 38400*" } { baudrate 38400 }
- X { "CONNECT 57600*" } { baudrate 57600 }
- X { "CONNECT 76800*" } { baudrate 76800 }
- X { "NO CARRIER*" } { exit }
- X default { exit }
- X }
- X login
- X exit 1
- X }
- X { 2 } {
- X #
- X # Received a T.30 fax tone.
- X #
- X baudrate 19200
- X send "AT+FCLASS=2;+FAA=0\r"
- X if { [receive 2 OK] == "" } { exit }
- X send "ATA\r"
- X if { [receive 20 +FCON] == "" } { exit }
- X invoke $CLASS2_RECEIVER -p /usr/spool/fax
- X exit
- X }
- X default {
- X #
- X # Got a busy signal too soon or there was problems during recording
- X #
- X send "AT+VLS=0\r"
- X if { [receive 2 OK] == "" } { exit }
- X send "AT+FCLASS=0\r"
- X if { [receive 2 OK] == "" } { exit }
- X send "ATZ\r"
- X sleep 2
- X exit
- X }
- X}
- SHAR_EOF
- true || echo 'restore of scripts/zyxel5cb.tcl failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= temp.c ==============
- if test -f 'temp.c' -a X"$1" != X"-c"; then
- echo 'x - skipping temp.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting temp.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'temp.c' &&
- X/*
- X * $Id: temp.c,v 1.1 1993/01/06 18:13:18 wcp Exp $
- X *
- X * Copyright (C) 1992 Walter Pelissero
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 1, or (at your option)
- X * any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X/*
- X * $Log: temp.c,v $
- X * Revision 1.1 1993/01/06 18:13:18 wcp
- X * Initial revision
- X *
- X * Revision 1.1 1992/07/07 17:27:24 wally
- X * Initial revision
- X *
- X */
- X
- X#include <sys/types.h>
- X#ifdef DEBUG
- X#include <dbmalloc.h>
- X#else
- X#include <malloc.h>
- X#endif
- X#include <string.h>
- X#include <stdio.h>
- X#include "common.h"
- X
- Xstatic char RcsId[] = "$Id: temp.c,v 1.1 1993/01/06 18:13:18 wcp Exp $";
- X
- Xchar *makeTemp(const char *directory)
- X{
- X char *pathname;
- X unsigned i = 0;
- X
- X if (!directory)
- X directory = TMP_DIR;
- X pathname = malloc(strlen(directory) + 64);
- X do
- X sprintf(pathname, "%s/fx%u-%u", directory, getpid(), i++);
- X while (access(pathname, 0) == 0);
- X return pathname;
- X}
- SHAR_EOF
- true || echo 'restore of temp.c failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= voice.c ==============
- if test -f 'voice.c' -a X"$1" != X"-c"; then
- echo 'x - skipping voice.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting voice.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'voice.c' &&
- X/*
- X * @(#)$Id: voice.c,v 1.1 1993/01/06 18:14:13 wcp Exp $
- X *
- X * Copyright (C) 1993 Walter Pelissero
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 2 of the License, or
- X * (at your option) any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X/*
- X * $Log: voice.c,v $
- X * Revision 1.1 1993/01/06 18:14:13 wcp
- X * Initial revision
- X *
- X */
- X
- X#include <stdio.h>
- X#include <errno.h>
- X#include <fcntl.h>
- X#include <stdlib.h>
- X#include "voice.h"
- X
- Xstatic char RcsId[] = "@(#)$Id: voice.c,v 1.1 1993/01/06 18:14:13 wcp Exp $";
- X
- Xextern const char *myname;
- X
- Xbool setLine(Port port)
- X{
- X struct termio tty_settings;
- X
- X if (ioctl(port.outfd, TCGETA, &tty_settings) < 0)
- X {
- X fprintf(stderr, "%s: can't ioctl()\n", myname);
- X return FALSE;
- X }
- X tty_settings.c_iflag &= ~(BRKINT | ICRNL | ISTRIP);
- X tty_settings.c_iflag |= IXON | IXANY;
- X tty_settings.c_cflag &= ~(PARENB | CBAUD);
- X tty_settings.c_cflag |= HUPCL | CSIZE | CS8 | CREAD | B38400;
- X tty_settings.c_cflag |= CTSFLOW | RTSFLOW | CLOCAL;
- X tty_settings.c_lflag &= ~(ISIG | ECHO | ICANON);
- X tty_settings.c_cc[VMIN] = 1;
- X tty_settings.c_cc[VTIME] = 0;
- X tty_settings.c_oflag &= ~OPOST;
- X if (ioctl(port.outfd, TCSETAF, &tty_settings) < 0)
- X {
- X fprintf(stderr, "%s: can't prepare line settings\n", myname);
- X return FALSE;
- X }
- X return TRUE;
- X}
- X
- XPort openLine(const char *portname)
- X{
- X Port port, bad;
- X struct termio tty_settings;
- X
- X port.infd = port.outfd = bad.infd = bad.outfd = -1;
- X errno = 0;
- X if ((port.infd = open(portname, (O_RDONLY | O_NDELAY))) < 0 ||
- X (port.outfd = open(portname, (O_WRONLY | O_NDELAY))) < 0)
- X {
- X if (errno == EBUSY)
- X fprintf(stderr, "%s: port %s BUSY\n", myname, portname);
- X else
- X fprintf(stderr, "%s: can't connect into %s (%s)\n", myname,
- X portname, sys_errlist[errno]);
- X return bad;
- X }
- X if (ioctl(port.outfd, TCGETA, &tty_settings) < 0)
- X {
- X fprintf(stderr, "%s: can't ioctl()\n", myname);
- X return bad;
- X }
- X port.orig_tty_settings = tty_settings;
- X if (ioctl(port.outfd, TCSETAF, &tty_settings) < 0)
- X {
- X fprintf(stderr, "%s: can't prepare line settings\n", myname);
- X return bad;
- X }
- X if (!setLine(port))
- X {
- X fprintf(stderr, "%s: cannot prepare line settings\n", myname);
- X return bad;
- X }
- X if (fcntl(port.infd, F_SETFL, O_RDONLY) == ERROR ||
- X fcntl(port.outfd, F_SETFL, O_WRONLY) == ERROR)
- X {
- X fprintf(stderr, "%s: can't unset O_NDELAY for %s\n", myname, portname);
- X return bad;
- X }
- X return port;
- X}
- X
- Xbool resetLine(Port p)
- X{
- X if (ioctl(p.outfd, TCSETAF, &p.orig_tty_settings) < 0)
- X {
- X fprintf(stderr, "%s: can't restore line settings\n", myname);
- X return FAILED;
- X }
- X return TRUE;
- X}
- X
- Xbool closeLine(Port p)
- X{
- X resetLine(p);
- X close(p.infd);
- X close(p.outfd);
- X return TRUE;
- X}
- SHAR_EOF
- true || echo 'restore of voice.c failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= voice.h ==============
- if test -f 'voice.h' -a X"$1" != X"-c"; then
- echo 'x - skipping voice.h (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting voice.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'voice.h' &&
- X/*
- X * @(#)$Id: voice.h,v 1.1 1993/01/06 18:14:13 wcp Exp $
- X *
- X * Copyright (C) 1993 Walter Pelissero
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 2 of the License, or
- X * (at your option) any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X/*
- X * $Log: voice.h,v $
- X * Revision 1.1 1993/01/06 18:14:13 wcp
- X * Initial revision
- X *
- X */
- X
- X#ifndef _voice_h_INCLUDED
- X#define _voice_h_INCLUDED
- X
- X#include <termio.h>
- X#include "common.h"
- X#include "modemio.h"
- X#include "zyxel.h"
- X
- Xtypedef struct {
- X int infd, outfd;
- X struct termio orig_tty_settings;
- X} Port;
- X
- Xtypedef enum {
- X NOSPKR = 0,
- X TELCOLINE = 2,
- X EXTMIC = 8,
- X INTSPKR = 16
- X } Speaker;
- X
- Xtypedef enum {
- X CELP = 1,
- X FIRST_VOICEEN = CELP,
- X ADPCM2,
- X ADPCM3,
- X LAST_VOICEEN = ADPCM3
- X } VoiceEncoding;
- X
- Xextern bool closeLine(Port);
- Xextern Port openLine(const char *);
- Xextern bool setLine(Port);
- Xextern bool resetLine(Port);
- X
- X#endif /* _voice_h_INCLUDED */
- SHAR_EOF
- true || echo 'restore of voice.h failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= xgetty.c ==============
- if test -f 'xgetty.c' -a X"$1" != X"-c"; then
- echo 'x - skipping xgetty.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting xgetty.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'xgetty.c' &&
- X/*
- X * $Id: xgetty.c,v 1.1 1993/01/06 18:15:22 wcp Exp $
- X *
- X * Copyright (C) 1992 Walter Pelissero
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 1, or (at your option)
- X * any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X/*
- X * $Log: xgetty.c,v $
- X * Revision 1.1 1993/01/06 18:15:22 wcp
- X * Initial revision
- X *
- X */
- X
- X#include <stdio.h>
- X#include <string.h>
- X#include <stdlib.h>
- X
- X#define REAL_GETTY "/etc/Getty"
- X
- Xstatic char RcsId[] = "$Id: xgetty.c,v 1.1 1993/01/06 18:15:22 wcp Exp $";
- X
- Xint main(unsigned argc, char *argv[])
- X{
- X if (defopen("/usr/local/etc/gettys") == 0)
- X {
- X char buf[1024];
- X
- X strcpy(buf, argv[1]);
- X strcat(buf, "=");
- X strcpy(buf, defread(buf));
- X if (strlen(buf))
- X {
- X char *av[1024], *p;
- X unsigned i = 0, j;
- X
- X av[i++] = strtok(buf, " \t");
- X av[i++] = REAL_GETTY;
- X for (j = 1; argv[j]; ++i, ++j)
- X av[i] = argv[j];
- X while (p = strtok(0, " \t"))
- X av[i++] = p;
- X av[i] = 0;
- X execv(av[0], av);
- X printf("Warning cannot exec \"%s\"\n", av[0]);
- X }
- X }
- X execv(REAL_GETTY, argv);
- X return exit(2), 2;
- X}
- SHAR_EOF
- true || echo 'restore of xgetty.c failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= zyxel.c ==============
- if test -f 'zyxel.c' -a X"$1" != X"-c"; then
- echo 'x - skipping zyxel.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting zyxel.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'zyxel.c' &&
- X/*
- X * @(#)$Id: zyxel.c,v 1.1 1993/01/06 18:17:28 wcp Exp $
- X *
- X * Copyright (C) 1993 Walter Pelissero
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 2 of the License, or
- X * (at your option) any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X/*
- X * $Log: zyxel.c,v $
- X * Revision 1.1 1993/01/06 18:17:28 wcp
- X * Initial revision
- X *
- X */
- X
- X#include <string.h>
- X#include "common.h"
- X#include "modemio.h"
- X#include "zyxel.h"
- X
- Xstatic char RcsId[] = "@(#)$Id: zyxel.c,v 1.1 1993/01/06 18:17:28 wcp Exp $";
- X
- Xconst char *ModemAnswers[] = {
- X "ERROR",
- X "OK",
- X "RING",
- X "CONNECT 1200",
- X "CONNECT 2400",
- X "CONNECT 4800",
- X "CONNECT 9600",
- X "CONNECT 19200",
- X "CONNECT 7200",
- X "CONNECT 12000",
- X "CONNECT 14400",
- X "CONNECT 16800",
- X "CONNECT 38400",
- X "CONNECT 57600",
- X "CONNECT 76800",
- X "CONNECT",
- X "NO CARRIER",
- SHAR_EOF
- true || echo 'restore of zyxel.c failed'
- fi
- echo 'End of mgetty-1.0 part 3'
- echo 'File zyxel.c is continued in part 4'
- echo 4 > _shar_seq_.tmp
- exit 0
-
- --
- P4 32 8 @A ^@@A ^@@Ax^@@A ^@DA"^@D]%xJe&H1\236\331\306
-