home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / alt / sources / 3065 < prev    next >
Encoding:
Internet Message Format  |  1993-01-23  |  49.9 KB

  1. Path: sparky!uunet!cs.utexas.edu!uwm.edu!rutgers!modus!lpds!wcp
  2. From: wcp@lpds.sublink.org (Walter C. Pelissero)
  3. Newsgroups: alt.sources
  4. Subject: mgetty - A modular getty v1.0, Part03/04
  5. Message-ID: <1993Jan22.162156.939@lpds.sublink.org>
  6. Date: 22 Jan 93 16:21:56 GMT
  7. Organization: Sweet home under white clouds
  8. Lines: 1930
  9. Phone: + 39 2 8464117 - 8435411 (work)    8267089 (home)
  10. Postal-Address: Via G. de Ruggiero 87, 20142 Milano - Italia
  11.  
  12. Submitted-by: wcp@lpds
  13. Archive-name: mgetty-1.0/part03
  14.  
  15. ---- Cut Here and feed the following to sh ----
  16. #!/bin/sh
  17. # this is mgetty10.03 (part 3 of mgetty-1.0)
  18. # do not concatenate these parts, unpack them in order with /bin/sh
  19. # file modemio.c continued
  20. #
  21. if test ! -r _shar_seq_.tmp; then
  22.     echo 'Please unpack part 1 first!'
  23.     exit 1
  24. fi
  25. (read Scheck
  26.  if test "$Scheck" != 3; then
  27.     echo Please unpack part "$Scheck" next!
  28.     exit 1
  29.  else
  30.     exit 0
  31.  fi
  32. ) < _shar_seq_.tmp || exit 1
  33. if test ! -f _shar_wnt_.tmp; then
  34.     echo 'x - still skipping modemio.c'
  35. else
  36. echo 'x - continuing file modemio.c'
  37. sed 's/^X//' << 'SHAR_EOF' >> 'modemio.c' &&
  38. X    {
  39. X      c &= 0177;
  40. X      if ((*bp = c) != '\0')
  41. X    *++bp = '\0';
  42. X      if (mdverbosity > 6)
  43. X    fprintf(stderr, "%s", vgets(c));
  44. X      if (bp >= mdread_buffer + sizeof(mdread_buffer))
  45. X    {
  46. X      relSignals();
  47. X      if (mdverbosity > 6)
  48. X        fprintf(stderr, ">>-FAIL\n");
  49. X      return 0;
  50. X    }
  51. X      if (c == '\r' || c == '\n')
  52. X    {
  53. X      if (tokens)
  54. X        {
  55. X          const char **mp;
  56. X          
  57. X          for (mp = tokens; *mp; ++mp)
  58. X        if (substr(*mp, mdread_buffer) == 0)
  59. X          {
  60. X            relSignals();
  61. X            if (mdverbosity > 6)
  62. X              fprintf(stderr, ">>-OK\n");
  63. X            if (mdverbosity > 4)
  64. X              fprintf(stderr, "%s: got %s\n", myname, *mp);
  65. X            if (ret)
  66. X              *ret = mp - tokens;
  67. X            return (char *)*mp;
  68. X          }
  69. X        }
  70. X      else
  71. X        if (strlen(rp) > 1)
  72. X          {
  73. X        relSignals();
  74. X        bp[-1] = '\0';
  75. X        if (mdverbosity > 6)
  76. X          fprintf(stderr, ">>-OK\n");
  77. X        if (mdverbosity > 4)
  78. X          fprintf(stderr, "%s: got %s\n", myname, rp);
  79. X        return rp;
  80. X          }
  81. X        else
  82. X          rp = bp;
  83. X    }
  84. X    }
  85. X  relSignals();
  86. X  if (mdverbosity > 6)
  87. X    fprintf(stderr, ">>-FAIL");
  88. X  if (!mdtimedout)
  89. X    fprintf(stderr, " %s\n", sys_errlist[errno]);
  90. X  else
  91. X    if (mdverbosity > 4)
  92. X      fprintf(stderr, " no response\n");
  93. X  return 0;
  94. X}
  95. X
  96. Xbool mdhangup(int fd)
  97. X{
  98. X  struct termio tty_settings, old_tty;
  99. X  bool ret = FAILED;
  100. X  SIGTYPE (*exsh)(int);
  101. X
  102. X  exsh = signal(SIGHUP, SIG_IGN);    /* just in case fd is the
  103. X                       controlling tty */
  104. X  if (ioctl(fd, TCGETA, &tty_settings) >= 0)
  105. X    {
  106. X      old_tty = tty_settings;
  107. X      tty_settings.c_cflag &= ~CBAUD;
  108. X      tty_settings.c_cflag |= B0;
  109. X      if (mdverbosity > 5)
  110. X    fprintf(stderr, "%s: hanging\n", myname);
  111. X      if (ioctl(fd, TCSETA, &tty_settings) >= 0)
  112. X    {
  113. X      sleep(1);
  114. X      if (ioctl(fd, TCSETA, &old_tty) >= 0)
  115. X        ret = SUCCEEDED;
  116. X    }
  117. X    }
  118. X  signal(SIGHUP, exsh);
  119. X  return ret;
  120. X}
  121. X
  122. Xvoid mdflushin(int fd)
  123. X{
  124. X  getSignals();
  125. X  while (!mdtimedout)
  126. X    {
  127. X      char c;
  128. X
  129. X      alarm(2);
  130. X      read(fd, &c, 1);
  131. X    }
  132. X  relSignals();
  133. X}
  134. SHAR_EOF
  135. echo 'File modemio.c is complete' &&
  136. true || echo 'restore of modemio.c failed'
  137. rm -f _shar_wnt_.tmp
  138. fi
  139. # ============= modemio.h ==============
  140. if test -f 'modemio.h' -a X"$1" != X"-c"; then
  141.     echo 'x - skipping modemio.h (File already exists)'
  142.     rm -f _shar_wnt_.tmp
  143. else
  144. > _shar_wnt_.tmp
  145. echo 'x - extracting modemio.h (Text)'
  146. sed 's/^X//' << 'SHAR_EOF' > 'modemio.h' &&
  147. X/*
  148. X * $Id: modemio.h,v 1.1 1993/01/06 18:10:08 wcp Exp $
  149. X *
  150. X * Copyright (C) 1992    Walter Pelissero
  151. X *
  152. X * This program is free software; you can redistribute it and/or modify
  153. X * it under the terms of the GNU General Public License as published by
  154. X * the Free Software Foundation; either version 1, or (at your option)
  155. X * any later version.
  156. X *
  157. X * This program is distributed in the hope that it will be useful,
  158. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  159. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  160. X * GNU General Public License for more details.
  161. X *
  162. X * You should have received a copy of the GNU General Public License
  163. X * along with this program; if not, write to the Free Software
  164. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  165. X */
  166. X
  167. X/*
  168. X * $Log: modemio.h,v $
  169. X * Revision 1.1  1993/01/06  18:10:08  wcp
  170. X * Initial revision
  171. X *
  172. X */
  173. X
  174. Xextern unsigned mdverbosity;
  175. Xextern int mdwrite(const char *, int);
  176. Xextern char *mdread(unsigned, int, const char **, unsigned *);
  177. Xextern bool mdhangup(int);
  178. Xextern void mdflushin(int);
  179. Xextern bool mdslowrite;
  180. Xextern char mdread_buffer[];
  181. SHAR_EOF
  182. true || echo 'restore of modemio.h failed'
  183. rm -f _shar_wnt_.tmp
  184. fi
  185. # ============= play.c ==============
  186. if test -f 'play.c' -a X"$1" != X"-c"; then
  187.     echo 'x - skipping play.c (File already exists)'
  188.     rm -f _shar_wnt_.tmp
  189. else
  190. > _shar_wnt_.tmp
  191. echo 'x - extracting play.c (Text)'
  192. sed 's/^X//' << 'SHAR_EOF' > 'play.c' &&
  193. X/*
  194. X * @(#)$Id: play.c,v 1.2 1993/01/13 21:31:54 wcp Exp $
  195. X *
  196. X * Copyright (C) 1993    Walter Pelissero
  197. X *
  198. X * This program is free software; you can redistribute it and/or modify
  199. X * it under the terms of the GNU General Public License as published by
  200. X * the Free Software Foundation; either version 2 of the License, or
  201. X * (at your option) any later version.
  202. X *
  203. X * This program is distributed in the hope that it will be useful,
  204. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  205. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  206. X * GNU General Public License for more details.
  207. X *
  208. X * You should have received a copy of the GNU General Public License
  209. X * along with this program; if not, write to the Free Software
  210. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  211. X */
  212. X
  213. X/*
  214. X * $Log: play.c,v $
  215. X * Revision 1.2  1993/01/13  21:31:54  wcp
  216. X * Changed speaker default to TELCOLINE, and forced default change to
  217. X * INTSPKR if -c is specified.
  218. X *
  219. X * Revision 1.1  1993/01/06  18:10:45  wcp
  220. X * Initial revision
  221. X *
  222. X */
  223. X
  224. X#include <stdio.h>
  225. X#include <termio.h>
  226. X#include <fcntl.h>
  227. X#include <stdlib.h>
  228. X#include <errno.h>
  229. X#include <getopt.h>
  230. X#include <signal.h>
  231. X#include "common.h"
  232. X#include "modemio.h"
  233. X#include "zyxel.h"
  234. X#include "voice.h"
  235. X
  236. Xstatic char RcsId[] = "@(#)$Id: play.c,v 1.2 1993/01/13 21:31:54 wcp Exp $";
  237. X#ifdef DEBUG
  238. Xstatic int verbosity = 9;
  239. X#else
  240. Xstatic int verbosity = 0;
  241. X#endif
  242. Xconst char *myname;
  243. Xstatic bool terminated = TRUE;
  244. Xstatic Port port;
  245. Xstatic bool already_connected = TRUE;
  246. X
  247. Xstatic SIGTYPE terminate(int sig)
  248. X{
  249. X  if (verbosity)
  250. X    fprintf(stderr, "%s: got signal %d\n", myname, sig);
  251. X  if (terminated)
  252. X    {
  253. X      if (already_connected)
  254. X    resetLine(port);
  255. X      else
  256. X    {
  257. X      mdhangup(port.outfd);
  258. X      mdwrite("ATZ\r", port.outfd);
  259. X      mdflushin(port.infd);
  260. X      closeLine(port);
  261. X    }
  262. X      exit(0);
  263. X    }
  264. X  else
  265. X    {
  266. X      terminated = TRUE;
  267. X      signal(sig, terminate);
  268. X    }
  269. X#if SIGTYPE == int
  270. X  return 0;
  271. X#endif
  272. X}
  273. X
  274. Xstatic bool playFile(int infd, int outfd)
  275. X{
  276. X  int nread;
  277. X  static char eof[] = { DLE, ETX };
  278. X  
  279. X  terminated = FALSE;
  280. X  do
  281. X    {
  282. X      char buf[1024];
  283. X      int i;
  284. X
  285. X      nread = read(infd, buf, sizeof(buf));
  286. X      for (i = 0; i < nread; ++i)
  287. X    {
  288. X      if (write(outfd, &buf[i], 1) < 1)
  289. X        nread = -1;
  290. X      else
  291. X        if (buf[i] == DLE)
  292. X          write(outfd, &buf[i], 1);
  293. X    }
  294. X    }
  295. X  while (nread > 0 && !terminated);
  296. X  if (write(outfd, eof, sizeof(eof)) < sizeof(eof) || terminated)
  297. X    return FALSE;
  298. X  else
  299. X    {
  300. X      terminated = TRUE;
  301. X      return TRUE;
  302. X    }
  303. X}
  304. X
  305. Xstatic bool play(int fd, Port port, Speaker spkr, VoiceEncoding encoding,
  306. X         unsigned volume)
  307. X{
  308. X  if (!already_connected)
  309. X    {
  310. X      char buf[32];
  311. X      
  312. X      if (verbosity > 2)
  313. X    fprintf(stderr, "%s: initializing modem\n", myname);
  314. X      sprintf(buf, "ATL%u+FCLASS=8\r", volume);
  315. X      mdwrite(buf, port.outfd);
  316. X      if (receive(2, port.infd) != MDOK)
  317. X    return FALSE;
  318. X      sprintf(buf, "AT+VSM=%u\r", encoding);
  319. X      mdwrite(buf, port.outfd);
  320. X      if (receive(2, port.infd) != MDOK)
  321. X    return FALSE;
  322. X      sprintf(buf, "AT+VLS=%u\r", spkr);
  323. X      mdwrite(buf, port.outfd);
  324. X      if (receive(2, port.infd) != MDVCON)
  325. X    return FALSE;
  326. X    }
  327. X  if (verbosity > 1)
  328. X    fprintf(stderr, "%s: starting playing\n", myname);
  329. X  mdwrite("AT+VTX\r", port.outfd);
  330. X  if (receive(10, port.infd) != MDCONNECT)
  331. X    return FALSE;
  332. X  if (verbosity > 4)
  333. X    fprintf(stderr, "%s: connected: playing...\n", myname);
  334. X  playFile(fd, port.outfd);
  335. X  if (verbosity > 4)
  336. X    fprintf(stderr, "%s: expecting VCON at end of playing\n", myname);
  337. X  if (receive(30, port.infd) != MDVCON)
  338. X    return FALSE;
  339. X  if (!already_connected)
  340. X    {
  341. X      if (verbosity > 2)
  342. X    fprintf(stderr, "%s: resetting modem\n", myname);
  343. X      mdwrite("AT+VLS=0\r", port.outfd);
  344. X      if (receive(2, port.infd) != MDOK)
  345. X    return FALSE;
  346. X      mdwrite("AT+FCLASS=0\r", port.outfd);
  347. X      if (receive(2, port.infd) != MDOK)
  348. X    return FALSE;
  349. X      mdwrite("ATZ\r", port.outfd);
  350. X      sleep(2);
  351. X      mdflushin(port.infd);
  352. X    }
  353. X  return TRUE;
  354. X}
  355. X
  356. Xint main(unsigned argc, char *argv[])
  357. X{
  358. X  unsigned i;
  359. X  VoiceEncoding encoding = ADPCM2;
  360. X  unsigned volume = 5;    /* I don't know if it is relevant */
  361. X  Speaker spkr = TELCOLINE;
  362. X  bool error;
  363. X  const char *device;
  364. X
  365. X  myname = basename(argv[0]);
  366. X  while ((i = getopt(argc, argv, "s:x:c:v:e:")) != EOF)
  367. X    switch (i)
  368. X      {
  369. X      case 'e':
  370. X    if ((encoding = atoi(optarg)) > LAST_VOICEEN ||
  371. X        encoding < FIRST_VOICEEN)
  372. X      {
  373. X        fprintf(stderr, "%s: encoding not in allowable range (1-3)\n",
  374. X            myname);
  375. X        error = TRUE;
  376. X      }
  377. X    break;
  378. X      case 'v':
  379. X    if ((volume = atoi(optarg)) > 7 || volume < 1)
  380. X      {
  381. X        fprintf(stderr, "%s: volume not in allowable range (1-7)\n",
  382. X            myname);
  383. X        error = TRUE;
  384. X      }
  385. X    break;
  386. X      case 'c':
  387. X    device = optarg;
  388. X    already_connected = FALSE;
  389. X    spkr = INTSPKR;
  390. X    break;
  391. X      case 'x':
  392. X    verbosity = atoi(optarg);
  393. X    break;
  394. X      case 's':
  395. X    switch (atoi(optarg))
  396. X      {
  397. X      case 0:
  398. X        spkr = TELCOLINE;
  399. X        break;
  400. X      case 1:
  401. X        spkr = EXTMIC;
  402. X        break;
  403. X      case 2:
  404. X        spkr = INTSPKR;
  405. X        break;
  406. X      default:
  407. X        fprintf(stderr, "%s: invalid speaker (0=telco, 1=mic, 2=int)\n",
  408. X            myname);
  409. X        error = TRUE;
  410. X        break;
  411. X      }
  412. X    break;
  413. X      default:
  414. X    error = TRUE;
  415. X    break;
  416. X      }
  417. X  if (argc - optind < 1)
  418. X    if (already_connected)
  419. X      {
  420. X    fprintf(stderr, "%s: cannot get data data from stdin while connected to stdin/out\n", myname);
  421. X    error = TRUE;
  422. X      }
  423. X    else if (isatty(0))
  424. X      {
  425. X    fprintf(stderr, "%s: are you sure you want to play from your keyboard?\n", myname);
  426. X    error = TRUE;
  427. X      }
  428. X  if (error)
  429. X    {
  430. X      fprintf(stderr, "%s\nusage: %s [-s speaker][-x debug_level][-c device][-v volume]
  431. X \t[-e encoding][voice_file ...]\n",
  432. X          RcsId, myname);
  433. X      exit(-1);
  434. X    }
  435. X  mdverbosity = verbosity;
  436. X  signal(SIGQUIT, terminate);
  437. X  signal(SIGTERM, terminate);
  438. X  signal(SIGHUP, terminate);
  439. X  signal(SIGINT, terminate);
  440. X  if (already_connected)
  441. X    {
  442. X      struct termio tty;
  443. X
  444. X      port.infd = 0;
  445. X      port.outfd = 1;
  446. X      ioctl(port.outfd, TCGETA, &tty);
  447. X      port.orig_tty_settings = tty;
  448. X      setLine(port);
  449. X    }
  450. X  else
  451. X    port = openLine(device);
  452. X  if (argc - optind)
  453. X    for (i = optind; i < argc; ++i)
  454. X      {
  455. X    int fd;
  456. X      
  457. X    if ((fd = open(argv[i], O_RDONLY)) >= 0)
  458. X      {
  459. X        play(fd, port, spkr, encoding, volume);
  460. X        close(fd);
  461. X      }
  462. X    else
  463. X      fprintf(stderr, "%s: cannot open %s: skipped\n", myname, argv[i]);
  464. X      }
  465. X  else
  466. X    /* If no files specified in command line, get data from stdin */
  467. X    play(0, port, spkr, encoding, volume);
  468. X  if (already_connected)
  469. X    resetLine(port);
  470. X  else
  471. X    {
  472. X      mdhangup(port.outfd);
  473. X      closeLine(port);
  474. X    }
  475. X  return exit(0), 0;
  476. X}
  477. SHAR_EOF
  478. true || echo 'restore of play.c failed'
  479. rm -f _shar_wnt_.tmp
  480. fi
  481. # ============= printfax.sh ==============
  482. if test -f 'printfax.sh' -a X"$1" != X"-c"; then
  483.     echo 'x - skipping printfax.sh (File already exists)'
  484.     rm -f _shar_wnt_.tmp
  485. else
  486. > _shar_wnt_.tmp
  487. echo 'x - extracting printfax.sh (Text)'
  488. sed 's/^X//' << 'SHAR_EOF' > 'printfax.sh' &&
  489. X: use /bin/sh
  490. X#
  491. X# $Id: printfax.sh,v 1.3 1993/01/22 15:14:24 wcp Exp $
  492. X#
  493. X# Copyright (C) 1992    Walter Pelissero
  494. X#
  495. X# This program is free software; you can redistribute it and/or modify
  496. X# it under the terms of the GNU General Public License as published by
  497. X# the Free Software Foundation; either version 1, or (at your option)
  498. X# any later version.
  499. X#
  500. X# This program is distributed in the hope that it will be useful,
  501. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  502. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  503. X# GNU General Public License for more details.
  504. X#
  505. X# You should have received a copy of the GNU General Public License
  506. X# along with this program; if not, write to the Free Software
  507. X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  508. X#
  509. X
  510. X#
  511. X# $Log: printfax.sh,v $
  512. X# Revision 1.3  1993/01/22  15:14:24  wcp
  513. X# Removed magic string.
  514. X#
  515. X# Revision 1.2  1993/01/07  23:18:00  wcp
  516. X# Corrected a test.
  517. X#
  518. X# Revision 1.1  1993/01/06  18:11:29  wcp
  519. X# Initial revision
  520. X#
  521. X#
  522. X
  523. XPBMPLUS=%PBMPLUS%
  524. XG3TOPBM=$PBMPLUS/g3topbm
  525. XPNMSCALE=$PBMPLUS/pnmscale
  526. XPGMTOPBM=$PBMPLUS/pgmtopbm
  527. XPBMTOEPSON=$PBMPLUS/pbmtoepson
  528. XTMP=/tmp/pf$$
  529. X
  530. X[ $# -ne 1 ] && {
  531. X    echo "usage: $0 base_name"
  532. X    exit 1
  533. X}
  534. X
  535. Xtrap 'rm -f $TMP; exit 1' 1 2 3 4 5 6 7 8 9 10 12 14 15 16 17
  536. X(
  537. Xpage=0
  538. Xfor f in `ls -tr $1.*`
  539. Xdo
  540. X    [ "$f" = "$1.*" ] && break
  541. X    [ $page -eq 0 ] || echo "\f"
  542. X    caller=`sed -n '1,/^DATA:/s/^CALLER:[ \t]*\(.*\)/\1/p' $f`
  543. X    date=`sed -n '1,/^DATA:/s/^DATE:[ \t]*\(.*\)/\1/p' $f`
  544. X    resolution=`sed -n '1,/^DATA:/s/^RESOLUTION:[ \t]*\(.*\)/\1/p' $f`
  545. X    speed=`sed -n '1,/^DATA:/s/^SPEED:[ \t]*\(.*\)/\1/p' $f`
  546. X    page=`expr $page + 1`
  547. X    echo "Date: $date\tFrom: $caller"
  548. X    echo "Page: $page\r\t\t\t\tSpeed: $speed\t\tResolution: \c"
  549. X    tail +`awk '/^DATA:$/ { print NR + 1; exit }' $f` $f > $TMP
  550. X    if [ "$resolution" -eq 0 ]
  551. X    then
  552. X        echo LOW
  553. X        $G3TOPBM -big -delete -stretch $TMP | $PBMTOEPSON -triple -24pin
  554. X    else
  555. X        echo HIGH
  556. X        $G3TOPBM -big -delete $TMP | $PBMTOEPSON -triple -24pin
  557. X    fi
  558. Xdone
  559. X) | lp -s # -tFax
  560. Xrm -f $TMP
  561. SHAR_EOF
  562. true || echo 'restore of printfax.sh failed'
  563. rm -f _shar_wnt_.tmp
  564. fi
  565. # ============= record.c ==============
  566. if test -f 'record.c' -a X"$1" != X"-c"; then
  567.     echo 'x - skipping record.c (File already exists)'
  568.     rm -f _shar_wnt_.tmp
  569. else
  570. > _shar_wnt_.tmp
  571. echo 'x - extracting record.c (Text)'
  572. sed 's/^X//' << 'SHAR_EOF' > 'record.c' &&
  573. X/*
  574. X * @(#)$Id: record.c,v 1.3 1993/01/22 15:14:24 wcp Exp $
  575. X *
  576. X * Copyright (C) 1993    Walter Pelissero
  577. X *
  578. X * This program is free software; you can redistribute it and/or modify
  579. X * it under the terms of the GNU General Public License as published by
  580. X * the Free Software Foundation; either version 2 of the License, or
  581. X * (at your option) any later version.
  582. X *
  583. X * This program is distributed in the hope that it will be useful,
  584. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  585. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  586. X * GNU General Public License for more details.
  587. X *
  588. X * You should have received a copy of the GNU General Public License
  589. X * along with this program; if not, write to the Free Software
  590. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  591. X */
  592. X
  593. X/*
  594. X * $Log: record.c,v $
  595. X * Revision 1.3  1993/01/22  15:14:24  wcp
  596. X * Removed magic string.
  597. X *
  598. X * Revision 1.2  1993/01/13  21:33:46  wcp
  599. X * Forced default to EXTMIC in case of -c option.
  600. X *
  601. X * Revision 1.1  1993/01/06  18:12:32  wcp
  602. X * Initial revision
  603. X *
  604. X */
  605. X
  606. X#include <sys/types.h>
  607. X#ifdef DEBUG
  608. X#include <dbmalloc.h>
  609. X#endif
  610. X#include <stdio.h>
  611. X#include <fcntl.h>
  612. X#include <termio.h>
  613. X#include <getopt.h>
  614. X#include <string.h>
  615. X#include <ctype.h>
  616. X#include <errno.h>
  617. X#include <signal.h>
  618. X#include <utmp.h>
  619. X#include <stdlib.h>
  620. X#include "common.h"
  621. X#include "modemio.h"
  622. X#include "zyxel.h"
  623. X#include "voice.h"
  624. X
  625. Xstatic char RcsId[] = "@(#)$Id: record.c,v 1.3 1993/01/22 15:14:24 wcp Exp $";
  626. Xstatic Port port;
  627. Xstatic bool already_connected = TRUE;
  628. Xconst char *myname;
  629. Xunsigned allow_digits = 0;
  630. Xbool allow_fax = TRUE;
  631. X#ifdef DEBUG
  632. Xstatic int verbosity = 9;
  633. X#else
  634. Xstatic int verbosity = 0;
  635. X#endif
  636. Xstatic bool timedout = TRUE;
  637. X
  638. Xstatic SIGTYPE terminate(int sig)
  639. X{
  640. X  if (verbosity)
  641. X    fprintf(stderr, "%s: got signal %d\n", myname, sig);
  642. X  if (timedout)
  643. X    {
  644. X      if (already_connected)
  645. X    resetLine(port);
  646. X      else
  647. X    {
  648. X      mdhangup(port.outfd);
  649. X      mdwrite("ATZ\r", port.outfd);
  650. X      mdflushin(port.infd);
  651. X      closeLine(port);
  652. X    }
  653. X      exit(0);
  654. X    }
  655. X  else
  656. X    {
  657. X      timedout = TRUE;
  658. X      signal(sig, terminate);
  659. X    }
  660. X#if SIGTYPE == int
  661. X  return 0;
  662. X#endif
  663. X}
  664. X
  665. Xstatic SIGTYPE timeout(int sig)
  666. X{
  667. X  timedout = TRUE;
  668. X  signal(sig, timeout);
  669. X#if SIGTYPE == int
  670. X  return 0;
  671. X#endif
  672. X}
  673. X
  674. Xtypedef enum {
  675. X  REC_ERROR = -1,
  676. X  REC_OK = 0,
  677. X  REC_SILENCE,
  678. X  REC_FAX,
  679. X  REC_0 = 10,
  680. X  REC_1,
  681. X  REC_2,
  682. X  REC_3,
  683. X  REC_4,
  684. X  REC_5,
  685. X  REC_6,
  686. X  REC_7,
  687. X  REC_8,
  688. X  REC_9,
  689. X  REC_D,
  690. X  REC_A
  691. X  } ReceiveResult;
  692. X
  693. Xinline int safe_write(int fd, const char *p, unsigned len)
  694. X{
  695. X  if (fd < 0)
  696. X    return 0;
  697. X  return write(fd, p, len);
  698. X}
  699. X
  700. X#define ELAPSED        (time(0) - timerStart)
  701. X
  702. Xstatic int receiveMessage(int infd, int outfd,
  703. X              unsigned min_secs, unsigned max_secs)
  704. X{
  705. X  bool dle = FALSE;
  706. X  unsigned phase = 0;
  707. X  unsigned long timerStart;
  708. X
  709. X  timedout = FALSE;
  710. X  alarm(max_secs);
  711. X  timerStart = time(0);
  712. X  do
  713. X    {
  714. X      char buf[1024];
  715. X      int received;
  716. X
  717. X      if ((received = read(infd, buf, sizeof(buf))) < 0)
  718. X    {
  719. X      alarm(0);
  720. X      timedout = TRUE;
  721. X      return ELAPSED >= max_secs ? REC_OK : REC_ERROR;
  722. X    }
  723. X      else
  724. X    {
  725. X      int mark, i;
  726. X
  727. X      for (i = mark = 0; i < received; ++i)
  728. X        {
  729. X          if (dle)
  730. X        {
  731. X          switch (buf[i])
  732. X            {
  733. X            case DLE:
  734. X              safe_write(outfd, &buf[i], 1);
  735. X              break;
  736. X            case '0':
  737. X            case '1':
  738. X            case '2':
  739. X            case '3':
  740. X            case '4':
  741. X            case '5':
  742. X            case '6':
  743. X            case '7':
  744. X            case '8':
  745. X            case '9':
  746. X              if (verbosity > 6)
  747. X            fprintf(stderr, "%s: got DTMF %c\n", myname, buf[i]);
  748. X              if (allow_digits && ELAPSED < min_secs)
  749. X            {
  750. X              /* caller typed a digit */
  751. X              timedout = TRUE;
  752. X              return REC_0 + buf[i] - '0';
  753. X            }
  754. X              break;
  755. X            case '#':
  756. X            case '*':
  757. X              if (verbosity > 6)
  758. X            fprintf(stderr, "%s: got DTMF %c\n", myname, buf[i]);
  759. X              if (allow_digits && ELAPSED < min_secs)
  760. X            {
  761. X              /* caller typed '#' or '*' */
  762. X              timedout = TRUE;
  763. X              return buf[i] == '#' ? REC_D : REC_A;
  764. X            }
  765. X              break;
  766. X            case 'c':    /* T.30 fax calling tone */
  767. X              if (verbosity > 6)
  768. X            fprintf(stderr, "%s: got T.30 fax tone\n", myname);
  769. X              if (allow_fax)
  770. X            {
  771. X              /* it was a fax machine */
  772. X              timedout = TRUE;
  773. X              return REC_FAX;
  774. X            }
  775. X              break;
  776. X            case 'b':    /* Busy tone */
  777. X              if (verbosity > 6)
  778. X            fprintf(stderr, "%s: got busy tone\n", myname);
  779. X              timedout = TRUE;
  780. X              return (ELAPSED < min_secs) ? REC_ERROR : REC_OK;
  781. X            case 'q':    /* quiet after talking */
  782. X              if (verbosity > 6)
  783. X            fprintf(stderr, "%s: got quiet\n", myname);
  784. X              timedout = TRUE;
  785. X              /* 5 is a magic number to be parametrized
  786. X             later -wcp1/3/93. */
  787. X              return (ELAPSED - 5 < min_secs) ? REC_SILENCE : REC_OK;
  788. X            case 's':    /* silence (no response) */
  789. X              if (verbosity > 6)
  790. X            fprintf(stderr, "%s: got silence\n", myname);
  791. X              timedout = TRUE;
  792. X              return REC_SILENCE; /* not a human */
  793. X            case ETX:
  794. X              alarm(0);
  795. X              timedout = TRUE;
  796. X              return REC_OK;
  797. X            default:
  798. X              break;
  799. X            }
  800. X          dle = FALSE;
  801. X        }
  802. X          else
  803. X        {
  804. X          if (buf[i] == DLE)
  805. X            {
  806. X              dle = TRUE;
  807. X              safe_write(outfd, &buf[mark], i - mark);
  808. X              mark = i + 2;
  809. X            }
  810. X        }
  811. X        }
  812. X      if (mark < i)
  813. X        safe_write(outfd, &buf[mark], received - mark);
  814. X    }
  815. X      if (timedout)
  816. X    {
  817. X      if (phase++)
  818. X        return REC_ERROR;
  819. X      mdwrite("AT\r", 1);    /* close the connection */
  820. X      timedout = FALSE;
  821. X      alarm(30);        /* should be enough to drain input */
  822. X    }
  823. X    }
  824. X  while (!timedout);
  825. X  return REC_OK;
  826. X}
  827. X
  828. X#undef ELAPSED
  829. X
  830. Xstatic int recordVoice(int outfd, unsigned min_secs, unsigned max_secs,
  831. X               Speaker mic, Port port, VoiceEncoding encoding)
  832. X{
  833. X  int ret;
  834. X
  835. X  if (verbosity > 3)
  836. X    fprintf(stderr, "%s: starting receiving\n", myname);
  837. X  if (already_connected && outfd >= 0)
  838. X    {
  839. X      FILE *outfp = fdopen(outfd, "w");
  840. X      long t = time(0);
  841. X
  842. X      fprintf(outfp, "DATE: %s", ctime(&t));
  843. X#ifdef NEVER
  844. X      fprintf(outfp, "CALLER: unknown\n"); /* currently not implemented */
  845. X#endif /* NEVER */
  846. X      fprintf(outfp, "ENCODING: %u\n", encoding);
  847. X      fprintf(outfp, "DATA:\n");
  848. X      fflush(outfp);
  849. X    }
  850. X  else
  851. X    {
  852. X      char buf[16];
  853. X
  854. X      mdwrite("AT+FCLASS=8\r", port.outfd);
  855. X      if (receive(2, port.infd) != MDOK)
  856. X    return REC_ERROR;
  857. X      sprintf(buf, "AT+VSM=%u\r", encoding);
  858. X      mdwrite(buf, port.outfd);
  859. X      if (receive(2, port.infd) != MDOK)
  860. X    return REC_ERROR;
  861. X      sprintf(buf, "AT+VLS=%u\r", mic);
  862. X      mdwrite(buf, port.outfd);
  863. X      if (receive(2, port.infd) != MDVCON)
  864. X    return REC_ERROR;
  865. X    }
  866. X  mdwrite("AT+VRX\r", port.outfd);
  867. X  if (receive(10, port.infd) != MDCONNECT)
  868. X    return REC_ERROR;
  869. X  if (verbosity > 4)
  870. X    fprintf(stderr, "%s: recording...\n", myname);
  871. X  ret = receiveMessage(port.infd, outfd, min_secs, max_secs);
  872. X  /* the following line may be a repetition butit is necessary
  873. X     to be sure to break any recording */
  874. X  mdwrite("AT\r", port.outfd);
  875. X  if (verbosity > 7)
  876. X    fprintf(stderr, "%s: flushing input...\n", myname);
  877. X  mdflushin(port.infd);
  878. X  if (!already_connected)
  879. X    {
  880. X      mdwrite("AT+VLS=0\r", port.outfd);
  881. X      if (receive(2, port.infd) != MDOK)
  882. X    return REC_ERROR;
  883. X      mdwrite("AT+FCLASS=0\r", port.outfd);
  884. X      if (receive(2, port.infd) != MDOK)
  885. X    return REC_ERROR;
  886. X      mdwrite("ATZ\r", port.outfd);
  887. X      sleep(2);
  888. X      mdflushin(port.infd);
  889. X    }
  890. X  return ret;
  891. X}
  892. X
  893. Xint main(unsigned argc, char *argv[])
  894. X{
  895. X  unsigned max_rec_time = 5 * 60, min_rec_time = 10;
  896. X  const char *base = 0;
  897. X  int i, ret;
  898. X  bool error = FALSE;
  899. X  const char *device;
  900. X  Speaker mic = TELCOLINE;
  901. X  VoiceEncoding encoding = ADPCM2;
  902. X
  903. X  myname = basename(argv[0]);
  904. X  while ((i = getopt(argc, argv, "fdt:x:c:m:e:")) != EOF)
  905. X    switch (i)
  906. X      {
  907. X      case 'e':
  908. X    if ((encoding = atoi(optarg)) > LAST_VOICEEN ||
  909. X        encoding < FIRST_VOICEEN)
  910. X      {
  911. X        fprintf(stderr, "%s: encoding not in allowable range (%u-%u)\n",
  912. X            myname, FIRST_VOICEEN, LAST_VOICEEN);
  913. X        error = TRUE;
  914. X      }
  915. X    break;
  916. X      case 'm':
  917. X    switch (atoi(optarg))
  918. X      {
  919. X      case 0:
  920. X        mic = TELCOLINE;
  921. X        break;
  922. X      case 1:
  923. X        mic = EXTMIC;
  924. X        break;
  925. X      case 2:
  926. X        mic = INTSPKR;
  927. X        break;
  928. X      default:
  929. X        fprintf(stderr, "%s: invalid speaker (0=telco, 1=mic, 2=int)\n",
  930. X            myname);
  931. X        error = TRUE;
  932. X        break;
  933. X      }
  934. X    break;
  935. X      case 'c':
  936. X    device = optarg;
  937. X    already_connected = FALSE;
  938. X    mic = EXTMIC;
  939. X    break;
  940. X      case 'f':
  941. X    allow_fax = FALSE;
  942. X    break;
  943. X      case 'd':
  944. X    ++allow_digits;
  945. X    break;
  946. X      case 'x':
  947. X    verbosity = atoi(optarg);
  948. X    break;
  949. X      case 't':
  950. X    {
  951. X      char *p = strchr(optarg, ':');
  952. X
  953. X      if (p)
  954. X        {
  955. X          *p++ = '\0';
  956. X          max_rec_time = atoi(p);
  957. X        }
  958. X      min_rec_time = atoi(optarg);
  959. X    }
  960. X    break;
  961. X      default:
  962. X    error = TRUE;
  963. X    break;
  964. X      }
  965. X  if (argc > optind)
  966. X    base = argv[optind++];
  967. X  if (!base)
  968. X    if (already_connected)
  969. X      {
  970. X    error = TRUE;
  971. X    fprintf(stderr, "%s: at least -c or output must be specified\n",
  972. X        myname);
  973. X      }
  974. X    else if (isatty(1))
  975. X      {
  976. X    error = TRUE;
  977. X    fprintf(stderr, "%s: are you sure you want do \"display\" sound?\n",
  978. X        myname);
  979. X      }
  980. X  if (optind < argc)        /* too many arguments */
  981. X    error = TRUE;
  982. X  if (error)
  983. X    {
  984. X      fprintf(stderr, "%s\nusage: %s [-x level][-f][-d][-m microphone][-e encoding]
  985. X\t[-t min_seconds[:max_seconds][-c device][out{file|dir}]\n", RcsId, myname);
  986. X      exit(-1);
  987. X    }
  988. X  mdverbosity = verbosity;
  989. X  signal(SIGALRM, timeout);
  990. X  signal(SIGQUIT, terminate);
  991. X  signal(SIGTERM, terminate);
  992. X  signal(SIGHUP, timeout);
  993. X  signal(SIGINT, terminate);
  994. X  if (already_connected)
  995. X    {
  996. X      struct termio tty;
  997. X
  998. X      port.infd = 0;
  999. X      port.outfd = 1;
  1000. X      ioctl(port.outfd, TCGETA, &tty);
  1001. X      port.orig_tty_settings = tty;
  1002. X      setLine(port);
  1003. X    }
  1004. X  else
  1005. X    port = openLine(device);
  1006. X  if (base)
  1007. X    {
  1008. X      unsigned nmsg = 1;
  1009. X      char msg_name[1024];
  1010. X      struct stat st;
  1011. X
  1012. X      if (stat(base, &st) == 0 && (st.st_mode & S_IFDIR))
  1013. X    {
  1014. X      /* Base is a directory.
  1015. X       */
  1016. X      for (; nmsg > 0; ++nmsg)
  1017. X        {
  1018. X          sprintf(msg_name, "%s/in%08u", base, nmsg);
  1019. X          /* We avoid to overwrite existing messages */
  1020. X          if (access(msg_name, F_OK))
  1021. X        break;
  1022. X        }
  1023. X    }
  1024. X      else
  1025. X    /* Base is a probably inexistent file name.
  1026. X     */
  1027. X    strcpy(msg_name, base);
  1028. X      if (nmsg == 0)
  1029. X    {
  1030. X      fprintf(stderr, "%s: spool area is full.\n", myname);
  1031. X      if (already_connected)
  1032. X        resetLine(port);
  1033. X      else
  1034. X        {
  1035. X          mdhangup(port.outfd);
  1036. X          closeLine(port);
  1037. X        }
  1038. X      exit(1);
  1039. X    }
  1040. X      else
  1041. X    {
  1042. X      int outfd;
  1043. X
  1044. X      if (allow_digits > 1)
  1045. X        outfd = -1;
  1046. X      else
  1047. X        if ((outfd = open(msg_name, O_WRONLY | O_CREAT, 0644)) < 0)
  1048. X          {
  1049. X        fprintf(stderr, "%s: cannot create %s (%s)\n",
  1050. X            myname, msg_name, sys_errlist[errno]);
  1051. X        if (!already_connected)
  1052. X          {
  1053. X            mdhangup(port.outfd);
  1054. X            closeLine(port);
  1055. X          }
  1056. X        exit(2);
  1057. X          }
  1058. X      ret = recordVoice(outfd, min_rec_time, max_rec_time, mic, port,
  1059. X                encoding);
  1060. X      if (outfd >= 0)
  1061. X        close(outfd);
  1062. X      if (ret != REC_OK)
  1063. X        unlink(msg_name);
  1064. X    }
  1065. X    }
  1066. X  else
  1067. X    ret = recordVoice(1, min_rec_time, max_rec_time, mic, port, encoding);
  1068. X  if (!already_connected)
  1069. X    {
  1070. X      mdhangup(port.outfd);
  1071. X      closeLine(port);
  1072. X    }
  1073. X  if (verbosity > 8)
  1074. X    fprintf(stderr, "%s: returning %d\n", myname, ret);
  1075. X  return exit(ret), -1;
  1076. X}
  1077. SHAR_EOF
  1078. true || echo 'restore of record.c failed'
  1079. rm -f _shar_wnt_.tmp
  1080. fi
  1081. # ============= scripts/zyxel4.tcl ==============
  1082. if test ! -d 'scripts'; then
  1083.     echo 'x - creating directory scripts'
  1084.     mkdir 'scripts'
  1085. fi
  1086. if test -f 'scripts/zyxel4.tcl' -a X"$1" != X"-c"; then
  1087.     echo 'x - skipping scripts/zyxel4.tcl (File already exists)'
  1088.     rm -f _shar_wnt_.tmp
  1089. else
  1090. > _shar_wnt_.tmp
  1091. echo 'x - extracting scripts/zyxel4.tcl (Text)'
  1092. sed 's/^X//' << 'SHAR_EOF' > 'scripts/zyxel4.tcl' &&
  1093. X#
  1094. X# $Id: zyxel4.tcl,v 1.3 1993/01/21 19:33:18 wcp Exp $
  1095. X#
  1096. X# Copyright (C) 1992    Walter Pelissero
  1097. X#
  1098. X# This program is free software; you can redistribute it and/or modify
  1099. X# it under the terms of the GNU General Public License as published by
  1100. X# the Free Software Foundation; either version 1, or (at your option)
  1101. X# any later version.
  1102. X#
  1103. X# This program is distributed in the hope that it will be useful,
  1104. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  1105. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1106. X# GNU General Public License for more details.
  1107. X#
  1108. X# You should have received a copy of the GNU General Public License
  1109. X# along with this program; if not, write to the Free Software
  1110. X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1111. X#
  1112. X
  1113. X#
  1114. X# $Log: zyxel4.tcl,v $
  1115. X# Revision 1.3  1993/01/21  19:33:18  wcp
  1116. X# Changed buggy invocation of fax receiver.
  1117. X#
  1118. X# Revision 1.2  1993/01/13  21:37:24  wcp
  1119. X# Removed unuseful options in CLASS2_RECEIVER and changed
  1120. X# syntax to the new "invoke" command.
  1121. X#
  1122. X# Revision 1.1  1993/01/06  18:20:26  wcp
  1123. X# Initial revision
  1124. X#
  1125. X#
  1126. X
  1127. X#
  1128. X# Mgetty tcl startup script for ZyXEL U1496 modems with ROMs 4.xx
  1129. X# supporting modem and fax capabilities.
  1130. X#
  1131. X
  1132. Xset LOCAL_NUMBER "+39-2-8435411"
  1133. Xset CLASS2_RECEIVER "/usr/local/lib/mgetty/c2rec"
  1134. X
  1135. Xbaudrate 19200
  1136. Xsend "ATZ\r"
  1137. Xsleep 2
  1138. Xsend "ATE0Q0\r"
  1139. Xflush_input
  1140. Xsend "ATPV1X6S0=1S7=60&B0&C1&D3&N0\r"
  1141. Xif { [receive 2 "OK"] != "OK" } { exit }
  1142. Xsend "ATM0+FCLASS=2;+FAA=1;+FCR=1;+FBOR=0;+FLID=\"$LOCAL_NUMBER\"\r"
  1143. Xif { [receive 2 "OK"] != "OK" } { exit }
  1144. Xsend "AT+FDCC=1,5,0,2,0,0,0\r"
  1145. Xif { [receive 2 "OK"] != "OK" } { exit }
  1146. Xset buffer ""
  1147. Xwhile { $buffer == "" } {
  1148. X    set buffer [ listen ]
  1149. X    case $buffer in {
  1150. X        { "CONNECT 1200*" } { baudrate 1200 }
  1151. X        { "CONNECT 2400*" } { baudrate 2400 }
  1152. X        { "CONNECT 4800*" } { baudrate 4800 }
  1153. X        { "CONNECT 9600*" } { baudrate 9600 }
  1154. X        { "CONNECT 19200*" } { baudrate 19200 }
  1155. X        { "CONNECT 7200*" } { baudrate 7200 }
  1156. X        { "CONNECT 12000*" } { baudrate 12000 }
  1157. X        { "CONNECT 14400*" } { baudrate 14400 }
  1158. X        { "CONNECT 16800*" } { baudrate 16800 }
  1159. X        { "CONNECT 38400*" } { baudrate 38400 }
  1160. X        { "CONNECT 57600*" } { baudrate 57600 }
  1161. X        { "CONNECT 76800*" } { baudrate 76800 }
  1162. X        { "+FCON*" } {
  1163. X            baudrate 19200
  1164. X            invoke $CLASS2_RECEIVER -p /usr/spool/fax
  1165. X            exit
  1166. X        }
  1167. X        default { set buffer "" }
  1168. X    }
  1169. X}
  1170. X
  1171. X# If we are not able to decipher what comes from tty it is probably
  1172. X# time to give a try to getty
  1173. X# mode remote cooked no_flow
  1174. Xlogin
  1175. SHAR_EOF
  1176. true || echo 'restore of scripts/zyxel4.tcl failed'
  1177. rm -f _shar_wnt_.tmp
  1178. fi
  1179. # ============= scripts/zyxel5.tcl ==============
  1180. if test -f 'scripts/zyxel5.tcl' -a X"$1" != X"-c"; then
  1181.     echo 'x - skipping scripts/zyxel5.tcl (File already exists)'
  1182.     rm -f _shar_wnt_.tmp
  1183. else
  1184. > _shar_wnt_.tmp
  1185. echo 'x - extracting scripts/zyxel5.tcl (Text)'
  1186. sed 's/^X//' << 'SHAR_EOF' > 'scripts/zyxel5.tcl' &&
  1187. X#
  1188. X# $Id: zyxel5.tcl,v 1.4 1993/01/21 19:40:54 wcp Exp $
  1189. X#
  1190. X# Copyright (C) 1992    Walter Pelissero
  1191. X#
  1192. X# This program is free software; you can redistribute it and/or modify
  1193. X# it under the terms of the GNU General Public License as published by
  1194. X# the Free Software Foundation; either version 1, or (at your option)
  1195. X# any later version.
  1196. X#
  1197. X# This program is distributed in the hope that it will be useful,
  1198. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  1199. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1200. X# GNU General Public License for more details.
  1201. X#
  1202. X# You should have received a copy of the GNU General Public License
  1203. X# along with this program; if not, write to the Free Software
  1204. X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1205. X#
  1206. X
  1207. X#
  1208. X# $Log: zyxel5.tcl,v $
  1209. X# Revision 1.4  1993/01/21  19:40:54  wcp
  1210. X# Minor mods.
  1211. X#
  1212. X# Revision 1.3  1993/01/13  21:39:35  wcp
  1213. X# Changed to use the new "invoke" command.
  1214. X#
  1215. X# Revision 1.2  1993/01/07  23:20:23  wcp
  1216. X# Removed DTMF support. No way to test it.
  1217. X# Various cleanings.
  1218. X#
  1219. X# Revision 1.1  1993/01/06  18:20:26  wcp
  1220. X# Initial revision
  1221. X#
  1222. X#
  1223. X
  1224. X#
  1225. X# Mgetty tcl startup script for ZyXEL U1496 modems with ROMs 5.xx
  1226. X# supporting voice, modem, and fax connections.
  1227. X#
  1228. X
  1229. Xset LOCAL_NUMBER "+39-2-8435411"
  1230. Xset LIBDIR /usr/local/lib/mgetty
  1231. Xset CLASS2_RECEIVER $LIBDIR/c2rec
  1232. Xset RECORDER $LIBDIR/record
  1233. Xset PLAYER $LIBDIR/play
  1234. Xset SOUND $LIBDIR/sound
  1235. X
  1236. Xbaudrate 38400
  1237. Xsend "ATZ\r"
  1238. Xsleep 2
  1239. Xsend "ATE0Q0\r"
  1240. Xflush_input
  1241. Xsend "ATPV1X7S0=0S7=60&B0&C1&D3&N0S39.4=1S38.4=0S41.7=0\r"
  1242. Xif { [receive 2 OK] == "" } { exit }
  1243. Xsend "ATM0+FCLASS=2;+FBOR=0;+FCR=1;+FLID=\"$LOCAL_NUMBER\"\r"
  1244. Xif { [receive 2 OK] == "" } { exit }
  1245. Xsend "AT+FDCC=1,5,0,2,0,0,0\r"
  1246. Xif { [receive 2 OK] == "" } { exit }
  1247. X
  1248. X# set in voice mode
  1249. Xsend "AT+FCLASS=8\r"
  1250. Xif { [receive 2 OK] == "" } { exit }
  1251. X#
  1252. X# Wait an incoming call
  1253. X#
  1254. Xif { [listen] != "RING" } { exit }
  1255. X
  1256. X#
  1257. X# Someone is ringing, let's listen to him/her
  1258. X#
  1259. Xsend "AT+VSM=2;+VBT=2;+VSD=20,40\r"
  1260. Xif { [receive 2 OK] == "" } { exit }
  1261. Xsend "AT+VLS=2\r"
  1262. Xif { [receive 2 VCON] == "" } { exit }
  1263. X
  1264. X# Give a greeting message...
  1265. Xsleep 1
  1266. Xinvoke $PLAYER $SOUND/greetings
  1267. X# ...and end it with a beep.
  1268. Xsend "AT+VTS=\[1355,0,5\]\r"
  1269. Xif { [receive 5 OK] == "" } { exit }
  1270. X
  1271. X# start recording
  1272. Xcase [invoke $RECORDER -t 6:60 /usr/spool/voice] in {
  1273. X     { 0 } {
  1274. X       #
  1275. X       # Message has been recorded succesfully.
  1276. X       # (also if time expired)
  1277. X       #
  1278. X       send "AT+VTS=\[955,0,10\]\r"
  1279. X       if { [receive 5 OK] == "" } { exit }
  1280. X       invoke $PLAYER $SOUND/salutations
  1281. X       send "AT+VLS=0\r"
  1282. X       if { [receive 2 OK] == "" } { exit }
  1283. X       send "AT+FCLASS=0\r"
  1284. X       if { [receive 2 OK] == "" } { exit }
  1285. X       send "ATZ\r"
  1286. X       sleep 2
  1287. X       exit
  1288. X     }
  1289. X     { 1 } {
  1290. X       #
  1291. X       # Got silence. It may be a modem or someone who
  1292. X       # hanged without talking.
  1293. X       #
  1294. X       send "AT+FCLASS=0\r"
  1295. X       if { [receive 2 OK] == "" } { exit }
  1296. X       send "ATA\r"
  1297. X       set buffer [receive 60]
  1298. X       case $buffer in {
  1299. X        { "CONNECT 1200*" } { baudrate 1200 }
  1300. X        { "CONNECT 2400*" } { baudrate 2400 }
  1301. X        { "CONNECT 4800*" } { baudrate 4800 }
  1302. X        { "CONNECT 9600*" } { baudrate 9600 }
  1303. X        { "CONNECT 19200*" } { baudrate 19200 }
  1304. X        { "CONNECT 7200*" } { baudrate 7200 }
  1305. X        { "CONNECT 12000*" } { baudrate 12000 }
  1306. X        { "CONNECT 14400*" } { baudrate 14400 }
  1307. X        { "CONNECT 16800*" } { baudrate 16800 }
  1308. X        { "CONNECT 38400*" } { baudrate 38400 }
  1309. X        { "CONNECT 57600*" } { baudrate 57600 }
  1310. X        { "CONNECT 76800*" } { baudrate 76800 }
  1311. X        { "NO CARRIER*" } { exit }
  1312. X        default { exit }
  1313. X       }
  1314. X       login
  1315. X       exit 1       
  1316. X     }
  1317. X     { 2 } {
  1318. X       #
  1319. X       # Received a T.30 fax tone.
  1320. X       #
  1321. X       baudrate 19200
  1322. X       send "AT+FCLASS=2;+FAA=0\r"
  1323. X       if { [receive 2 OK] == "" } { exit }
  1324. X       send "ATA\r"
  1325. X       if { [receive 20 +FCON] == "" } { exit }
  1326. X       invoke $CLASS2_RECEIVER -p /usr/spool/fax
  1327. X       exit
  1328. X     }
  1329. X     default { exit }
  1330. X}
  1331. SHAR_EOF
  1332. true || echo 'restore of scripts/zyxel5.tcl failed'
  1333. rm -f _shar_wnt_.tmp
  1334. fi
  1335. # ============= scripts/zyxel5cb.tcl ==============
  1336. if test -f 'scripts/zyxel5cb.tcl' -a X"$1" != X"-c"; then
  1337.     echo 'x - skipping scripts/zyxel5cb.tcl (File already exists)'
  1338.     rm -f _shar_wnt_.tmp
  1339. else
  1340. > _shar_wnt_.tmp
  1341. echo 'x - extracting scripts/zyxel5cb.tcl (Text)'
  1342. sed 's/^X//' << 'SHAR_EOF' > 'scripts/zyxel5cb.tcl' &&
  1343. X#
  1344. X# $Id: zyxel5cb.tcl,v 1.3 1993/01/21 19:35:49 wcp Exp $
  1345. X#
  1346. X# Copyright (C) 1992    Walter Pelissero
  1347. X#
  1348. X# This program is free software; you can redistribute it and/or modify
  1349. X# it under the terms of the GNU General Public License as published by
  1350. X# the Free Software Foundation; either version 1, or (at your option)
  1351. X# any later version.
  1352. X#
  1353. X# This program is distributed in the hope that it will be useful,
  1354. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  1355. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1356. X# GNU General Public License for more details.
  1357. X#
  1358. X# You should have received a copy of the GNU General Public License
  1359. X# along with this program; if not, write to the Free Software
  1360. X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1361. X#
  1362. X
  1363. X#
  1364. X# $Log: zyxel5cb.tcl,v $
  1365. X# Revision 1.3  1993/01/21  19:35:49  wcp
  1366. X# Modified documentation; Added support for different, previosly
  1367. X# unexpected, return strings when dialing back.
  1368. X# Added a "default" sequence of commands in case of unexpected
  1369. X# return code of record.
  1370. X#
  1371. X# Revision 1.2  1993/01/13  21:38:47  wcp
  1372. X# Changed to use the new "invoke" command.
  1373. X#
  1374. X# Revision 1.1  1993/01/07  23:22:05  wcp
  1375. X# Initial revision
  1376. X#
  1377. X#
  1378. X
  1379. X#
  1380. X# Mgetty tcl startup script for ZyXEL U1496 modems with ROMs 5.xx
  1381. X# supporting voice, modem, and fax connections and "blind" call-back.
  1382. X#
  1383. X
  1384. Xset LOCAL_NUMBER "+39-2-8435411"    ;# the local fax number
  1385. Xset LIBDIR /usr/local/lib/mgetty
  1386. Xset CLASS2_RECEIVER $LIBDIR/c2rec
  1387. Xset RECORDER $LIBDIR/record
  1388. Xset PLAYER $LIBDIR/play
  1389. Xset SOUND $LIBDIR/sound
  1390. Xset ANRING 3                ;# number of rings to answer
  1391. X# this is the call-back string: it must contain all the parameter
  1392. X# settings one may need plus a "D" character preceding the phone number
  1393. Xset CBNUMBER "&N16D82,67089"        ;# example: set V.21 and dial
  1394. X
  1395. Xbaudrate 38400
  1396. Xsend "ATZ\r"
  1397. Xsleep 2
  1398. Xsend "ATE0Q0\r"
  1399. Xflush_input
  1400. Xsend "ATPV1X7S0=0S7=60&B0&C1&D3&N0S39.4=1S38.4=0S41.7=0\r"
  1401. Xif { [receive 2 OK] == "" } { exit }
  1402. Xsend "ATM0+FCLASS=2;+FBOR=0;+FCR=1;+FLID=\"$LOCAL_NUMBER\"\r"
  1403. Xif { [receive 2 OK] == "" } { exit }
  1404. Xsend "AT+FDCC=1,5,0,2,0,0,0\r"
  1405. Xif { [receive 2 OK] == "" } { exit }
  1406. X
  1407. Xsend "AT+FCLASS=8\r"            ;# set in voice mode
  1408. Xif { [receive 2 OK] == "" } { exit }
  1409. X#
  1410. X# Wait an incoming call
  1411. X#
  1412. Xif { [listen] != "RING" } { exit }
  1413. Xset rings 1
  1414. Xset phase 1
  1415. Xwhile { $rings < $ANRING } {
  1416. X      if { [receive 10 RING] == "" } {
  1417. X     if { $phase == 2 } {
  1418. X        flush_input
  1419. X        send "AT&B1+FCLASS=0;$CBNUMBER\r"
  1420. X        case [receive [expr {[string length $CBNUMBER] * 3 + 60}] CONNECT BUSY "NO CARRIER" "NO ANSWER"] in {
  1421. X         { CONNECT } {
  1422. X            sleep 2
  1423. X           login
  1424. X           exit 1
  1425. X         }
  1426. X         default { exit 1 }
  1427. X        }
  1428. X     }
  1429. X     if { [receive 20 RING] == "" } { exit }
  1430. X     set phase [expr {$phase + 1}]
  1431. X     set rings 1
  1432. X      } else { set rings [expr {$rings + 1}] }
  1433. X}
  1434. X
  1435. X#
  1436. X# Someone is ringing, let's listen to him/her
  1437. X#
  1438. Xsend "AT+VSM=2;+VBT=2;+VSD=20,30\r"
  1439. Xif { [receive 2 OK] == "" } { exit }
  1440. Xsend "AT+VLS=2\r"
  1441. Xif { [receive 2 VCON] == "" } { exit }
  1442. X
  1443. Xsleep 1
  1444. Xinvoke $PLAYER $SOUND/greetings        ;# Give a greeting message...
  1445. Xsend "AT+VTS=\[1355,0,5\]\r"        ;# ...and end it with a beep.
  1446. Xif { [receive 5 OK] == "" } { exit }
  1447. X
  1448. X# start recording
  1449. Xcase [invoke $RECORDER -t 7:60 /usr/spool/voice] in {
  1450. X     { 0 } {
  1451. X       #
  1452. X       # Message has been recorded succesfully.
  1453. X       # (also if time expired)
  1454. X       #
  1455. X       send "AT+VTS=\[955,0,10\]\r"
  1456. X       if { [receive 5 OK] == "" } { exit }
  1457. X       invoke $PLAYER $SOUND/salutations
  1458. X       send "AT+VLS=0\r"
  1459. X       if { [receive 2 OK] == "" } { exit }
  1460. X       send "AT+FCLASS=0\r"
  1461. X       if { [receive 2 OK] == "" } { exit }
  1462. X       send "ATZ\r"
  1463. X       sleep 2
  1464. X       exit
  1465. X     }
  1466. X     { 1 } {
  1467. X       #
  1468. X       # Got silence. It may be a modem or someone who
  1469. X       # hanged without talking.
  1470. X       #
  1471. X       send "AT+FCLASS=0\r"
  1472. X       if { [receive 2 OK] == "" } { exit }
  1473. X       send "ATA\r"
  1474. X       set buffer [receive 60]
  1475. X       case $buffer in {
  1476. X        { "CONNECT 1200*" } { baudrate 1200 }
  1477. X        { "CONNECT 2400*" } { baudrate 2400 }
  1478. X        { "CONNECT 4800*" } { baudrate 4800 }
  1479. X        { "CONNECT 9600*" } { baudrate 9600 }
  1480. X        { "CONNECT 19200*" } { baudrate 19200 }
  1481. X        { "CONNECT 7200*" } { baudrate 7200 }
  1482. X        { "CONNECT 12000*" } { baudrate 12000 }
  1483. X        { "CONNECT 14400*" } { baudrate 14400 }
  1484. X        { "CONNECT 16800*" } { baudrate 16800 }
  1485. X        { "CONNECT 38400*" } { baudrate 38400 }
  1486. X        { "CONNECT 57600*" } { baudrate 57600 }
  1487. X        { "CONNECT 76800*" } { baudrate 76800 }
  1488. X        { "NO CARRIER*" } { exit }
  1489. X        default { exit }
  1490. X       }
  1491. X       login
  1492. X       exit 1       
  1493. X     }
  1494. X     { 2 } {
  1495. X       #
  1496. X       # Received a T.30 fax tone.
  1497. X       #
  1498. X       baudrate 19200
  1499. X       send "AT+FCLASS=2;+FAA=0\r"
  1500. X       if { [receive 2 OK] == "" } { exit }
  1501. X       send "ATA\r"
  1502. X       if { [receive 20 +FCON] == "" } { exit }
  1503. X       invoke $CLASS2_RECEIVER -p /usr/spool/fax
  1504. X       exit
  1505. X     }
  1506. X     default {
  1507. X       #
  1508. X       # Got a busy signal too soon or there was problems during recording
  1509. X       #
  1510. X       send "AT+VLS=0\r"
  1511. X       if { [receive 2 OK] == "" } { exit }
  1512. X       send "AT+FCLASS=0\r"
  1513. X       if { [receive 2 OK] == "" } { exit }
  1514. X       send "ATZ\r"
  1515. X       sleep 2
  1516. X       exit
  1517. X     }
  1518. X}
  1519. SHAR_EOF
  1520. true || echo 'restore of scripts/zyxel5cb.tcl failed'
  1521. rm -f _shar_wnt_.tmp
  1522. fi
  1523. # ============= temp.c ==============
  1524. if test -f 'temp.c' -a X"$1" != X"-c"; then
  1525.     echo 'x - skipping temp.c (File already exists)'
  1526.     rm -f _shar_wnt_.tmp
  1527. else
  1528. > _shar_wnt_.tmp
  1529. echo 'x - extracting temp.c (Text)'
  1530. sed 's/^X//' << 'SHAR_EOF' > 'temp.c' &&
  1531. X/*
  1532. X * $Id: temp.c,v 1.1 1993/01/06 18:13:18 wcp Exp $
  1533. X *
  1534. X * Copyright (C) 1992    Walter Pelissero
  1535. X *
  1536. X * This program is free software; you can redistribute it and/or modify
  1537. X * it under the terms of the GNU General Public License as published by
  1538. X * the Free Software Foundation; either version 1, or (at your option)
  1539. X * any later version.
  1540. X *
  1541. X * This program is distributed in the hope that it will be useful,
  1542. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1543. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1544. X * GNU General Public License for more details.
  1545. X *
  1546. X * You should have received a copy of the GNU General Public License
  1547. X * along with this program; if not, write to the Free Software
  1548. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1549. X */
  1550. X
  1551. X/*
  1552. X * $Log: temp.c,v $
  1553. X * Revision 1.1  1993/01/06  18:13:18  wcp
  1554. X * Initial revision
  1555. X *
  1556. X * Revision 1.1  1992/07/07  17:27:24  wally
  1557. X * Initial revision
  1558. X *
  1559. X */
  1560. X
  1561. X#include <sys/types.h>
  1562. X#ifdef DEBUG
  1563. X#include <dbmalloc.h>
  1564. X#else
  1565. X#include <malloc.h>
  1566. X#endif
  1567. X#include <string.h>
  1568. X#include <stdio.h>
  1569. X#include "common.h"
  1570. X
  1571. Xstatic char RcsId[] = "$Id: temp.c,v 1.1 1993/01/06 18:13:18 wcp Exp $";
  1572. X
  1573. Xchar *makeTemp(const char *directory)
  1574. X{
  1575. X  char *pathname;
  1576. X  unsigned i = 0;
  1577. X
  1578. X  if (!directory)
  1579. X    directory = TMP_DIR;
  1580. X  pathname = malloc(strlen(directory) + 64);
  1581. X  do
  1582. X    sprintf(pathname, "%s/fx%u-%u", directory, getpid(), i++);
  1583. X  while (access(pathname, 0) == 0);
  1584. X  return pathname;
  1585. X}
  1586. SHAR_EOF
  1587. true || echo 'restore of temp.c failed'
  1588. rm -f _shar_wnt_.tmp
  1589. fi
  1590. # ============= voice.c ==============
  1591. if test -f 'voice.c' -a X"$1" != X"-c"; then
  1592.     echo 'x - skipping voice.c (File already exists)'
  1593.     rm -f _shar_wnt_.tmp
  1594. else
  1595. > _shar_wnt_.tmp
  1596. echo 'x - extracting voice.c (Text)'
  1597. sed 's/^X//' << 'SHAR_EOF' > 'voice.c' &&
  1598. X/*
  1599. X * @(#)$Id: voice.c,v 1.1 1993/01/06 18:14:13 wcp Exp $
  1600. X *
  1601. X * Copyright (C) 1993    Walter Pelissero
  1602. X *
  1603. X * This program is free software; you can redistribute it and/or modify
  1604. X * it under the terms of the GNU General Public License as published by
  1605. X * the Free Software Foundation; either version 2 of the License, or
  1606. X * (at your option) any later version.
  1607. X *
  1608. X * This program is distributed in the hope that it will be useful,
  1609. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1610. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1611. X * GNU General Public License for more details.
  1612. X *
  1613. X * You should have received a copy of the GNU General Public License
  1614. X * along with this program; if not, write to the Free Software
  1615. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1616. X */
  1617. X
  1618. X/*
  1619. X * $Log: voice.c,v $
  1620. X * Revision 1.1  1993/01/06  18:14:13  wcp
  1621. X * Initial revision
  1622. X *
  1623. X */
  1624. X
  1625. X#include <stdio.h>
  1626. X#include <errno.h>
  1627. X#include <fcntl.h>
  1628. X#include <stdlib.h>
  1629. X#include "voice.h"
  1630. X
  1631. Xstatic char RcsId[] = "@(#)$Id: voice.c,v 1.1 1993/01/06 18:14:13 wcp Exp $";
  1632. X
  1633. Xextern const char *myname;
  1634. X
  1635. Xbool setLine(Port port)
  1636. X{
  1637. X  struct termio tty_settings;
  1638. X
  1639. X  if (ioctl(port.outfd, TCGETA, &tty_settings) < 0)
  1640. X    {
  1641. X      fprintf(stderr, "%s: can't ioctl()\n", myname);
  1642. X      return FALSE;
  1643. X    }
  1644. X  tty_settings.c_iflag &= ~(BRKINT | ICRNL | ISTRIP);
  1645. X  tty_settings.c_iflag |= IXON | IXANY;
  1646. X  tty_settings.c_cflag &= ~(PARENB | CBAUD);
  1647. X  tty_settings.c_cflag |= HUPCL | CSIZE | CS8 | CREAD | B38400;
  1648. X  tty_settings.c_cflag |= CTSFLOW | RTSFLOW | CLOCAL;
  1649. X  tty_settings.c_lflag &= ~(ISIG | ECHO | ICANON);
  1650. X  tty_settings.c_cc[VMIN] = 1;
  1651. X  tty_settings.c_cc[VTIME] = 0;
  1652. X  tty_settings.c_oflag &= ~OPOST;
  1653. X  if (ioctl(port.outfd, TCSETAF, &tty_settings) < 0)
  1654. X    {
  1655. X      fprintf(stderr, "%s: can't prepare line settings\n", myname);
  1656. X      return FALSE;
  1657. X    }
  1658. X  return TRUE;
  1659. X}
  1660. X
  1661. XPort openLine(const char *portname)
  1662. X{
  1663. X  Port port, bad;
  1664. X  struct termio    tty_settings;
  1665. X
  1666. X  port.infd = port.outfd = bad.infd = bad.outfd = -1;
  1667. X  errno = 0;
  1668. X  if ((port.infd = open(portname, (O_RDONLY | O_NDELAY))) < 0 ||
  1669. X      (port.outfd = open(portname, (O_WRONLY | O_NDELAY))) < 0)
  1670. X    {
  1671. X      if (errno == EBUSY)
  1672. X    fprintf(stderr, "%s: port %s BUSY\n", myname, portname);
  1673. X      else
  1674. X    fprintf(stderr, "%s: can't connect into %s (%s)\n", myname,
  1675. X        portname, sys_errlist[errno]);
  1676. X      return bad;
  1677. X    }
  1678. X  if (ioctl(port.outfd, TCGETA, &tty_settings) < 0)
  1679. X    {
  1680. X      fprintf(stderr, "%s: can't ioctl()\n", myname);
  1681. X      return bad;
  1682. X    }
  1683. X  port.orig_tty_settings = tty_settings;
  1684. X  if (ioctl(port.outfd, TCSETAF, &tty_settings) < 0)
  1685. X    {
  1686. X      fprintf(stderr, "%s: can't prepare line settings\n", myname);
  1687. X      return bad;
  1688. X    }
  1689. X  if (!setLine(port))
  1690. X    {
  1691. X      fprintf(stderr, "%s: cannot prepare line settings\n", myname);
  1692. X      return bad;
  1693. X    }
  1694. X  if (fcntl(port.infd, F_SETFL, O_RDONLY) == ERROR ||
  1695. X      fcntl(port.outfd, F_SETFL, O_WRONLY) == ERROR)
  1696. X    {
  1697. X      fprintf(stderr, "%s: can't unset O_NDELAY for %s\n", myname, portname);
  1698. X      return bad;
  1699. X    }
  1700. X  return port;
  1701. X}
  1702. X
  1703. Xbool resetLine(Port p)
  1704. X{
  1705. X  if (ioctl(p.outfd, TCSETAF, &p.orig_tty_settings) < 0)
  1706. X    {
  1707. X      fprintf(stderr, "%s: can't restore line settings\n", myname);
  1708. X      return FAILED;
  1709. X    }
  1710. X  return TRUE;
  1711. X}
  1712. X
  1713. Xbool closeLine(Port p)
  1714. X{
  1715. X  resetLine(p);
  1716. X  close(p.infd);
  1717. X  close(p.outfd);
  1718. X  return TRUE;
  1719. X}
  1720. SHAR_EOF
  1721. true || echo 'restore of voice.c failed'
  1722. rm -f _shar_wnt_.tmp
  1723. fi
  1724. # ============= voice.h ==============
  1725. if test -f 'voice.h' -a X"$1" != X"-c"; then
  1726.     echo 'x - skipping voice.h (File already exists)'
  1727.     rm -f _shar_wnt_.tmp
  1728. else
  1729. > _shar_wnt_.tmp
  1730. echo 'x - extracting voice.h (Text)'
  1731. sed 's/^X//' << 'SHAR_EOF' > 'voice.h' &&
  1732. X/*
  1733. X * @(#)$Id: voice.h,v 1.1 1993/01/06 18:14:13 wcp Exp $
  1734. X *
  1735. X * Copyright (C) 1993    Walter Pelissero
  1736. X *
  1737. X * This program is free software; you can redistribute it and/or modify
  1738. X * it under the terms of the GNU General Public License as published by
  1739. X * the Free Software Foundation; either version 2 of the License, or
  1740. X * (at your option) any later version.
  1741. X *
  1742. X * This program is distributed in the hope that it will be useful,
  1743. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1744. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1745. X * GNU General Public License for more details.
  1746. X *
  1747. X * You should have received a copy of the GNU General Public License
  1748. X * along with this program; if not, write to the Free Software
  1749. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1750. X */
  1751. X
  1752. X/*
  1753. X * $Log: voice.h,v $
  1754. X * Revision 1.1  1993/01/06  18:14:13  wcp
  1755. X * Initial revision
  1756. X *
  1757. X */
  1758. X
  1759. X#ifndef _voice_h_INCLUDED
  1760. X#define _voice_h_INCLUDED
  1761. X
  1762. X#include <termio.h>
  1763. X#include "common.h"
  1764. X#include "modemio.h"
  1765. X#include "zyxel.h"
  1766. X
  1767. Xtypedef struct {
  1768. X  int infd, outfd;
  1769. X  struct termio orig_tty_settings;
  1770. X} Port;
  1771. X
  1772. Xtypedef enum {
  1773. X  NOSPKR = 0,
  1774. X  TELCOLINE = 2,
  1775. X  EXTMIC = 8,
  1776. X  INTSPKR = 16
  1777. X  } Speaker;
  1778. X
  1779. Xtypedef enum {
  1780. X  CELP = 1,
  1781. X  FIRST_VOICEEN = CELP,
  1782. X  ADPCM2,
  1783. X  ADPCM3,
  1784. X  LAST_VOICEEN = ADPCM3
  1785. X  } VoiceEncoding;
  1786. X
  1787. Xextern bool closeLine(Port);
  1788. Xextern Port openLine(const char *);
  1789. Xextern bool setLine(Port);
  1790. Xextern bool resetLine(Port);
  1791. X
  1792. X#endif /* _voice_h_INCLUDED */
  1793. SHAR_EOF
  1794. true || echo 'restore of voice.h failed'
  1795. rm -f _shar_wnt_.tmp
  1796. fi
  1797. # ============= xgetty.c ==============
  1798. if test -f 'xgetty.c' -a X"$1" != X"-c"; then
  1799.     echo 'x - skipping xgetty.c (File already exists)'
  1800.     rm -f _shar_wnt_.tmp
  1801. else
  1802. > _shar_wnt_.tmp
  1803. echo 'x - extracting xgetty.c (Text)'
  1804. sed 's/^X//' << 'SHAR_EOF' > 'xgetty.c' &&
  1805. X/*
  1806. X * $Id: xgetty.c,v 1.1 1993/01/06 18:15:22 wcp Exp $
  1807. X *
  1808. X * Copyright (C) 1992    Walter Pelissero
  1809. X *
  1810. X * This program is free software; you can redistribute it and/or modify
  1811. X * it under the terms of the GNU General Public License as published by
  1812. X * the Free Software Foundation; either version 1, or (at your option)
  1813. X * any later version.
  1814. X *
  1815. X * This program is distributed in the hope that it will be useful,
  1816. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1817. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1818. X * GNU General Public License for more details.
  1819. X *
  1820. X * You should have received a copy of the GNU General Public License
  1821. X * along with this program; if not, write to the Free Software
  1822. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1823. X */
  1824. X
  1825. X/*
  1826. X * $Log: xgetty.c,v $
  1827. X * Revision 1.1  1993/01/06  18:15:22  wcp
  1828. X * Initial revision
  1829. X *
  1830. X */
  1831. X
  1832. X#include <stdio.h>
  1833. X#include <string.h>
  1834. X#include <stdlib.h>
  1835. X
  1836. X#define REAL_GETTY    "/etc/Getty"
  1837. X
  1838. Xstatic char RcsId[] = "$Id: xgetty.c,v 1.1 1993/01/06 18:15:22 wcp Exp $";
  1839. X
  1840. Xint main(unsigned argc, char *argv[])
  1841. X{
  1842. X  if (defopen("/usr/local/etc/gettys") == 0)
  1843. X    {
  1844. X      char buf[1024];
  1845. X      
  1846. X      strcpy(buf, argv[1]);
  1847. X      strcat(buf, "=");
  1848. X      strcpy(buf, defread(buf));
  1849. X      if (strlen(buf))
  1850. X    {
  1851. X      char *av[1024], *p;
  1852. X      unsigned i = 0, j;
  1853. X      
  1854. X      av[i++] = strtok(buf, " \t");
  1855. X      av[i++] = REAL_GETTY;
  1856. X      for (j = 1; argv[j]; ++i, ++j)
  1857. X        av[i] = argv[j];
  1858. X      while (p = strtok(0, " \t"))
  1859. X        av[i++] = p;
  1860. X      av[i] = 0;
  1861. X      execv(av[0], av);
  1862. X      printf("Warning cannot exec \"%s\"\n", av[0]);
  1863. X    }
  1864. X    }
  1865. X  execv(REAL_GETTY, argv);
  1866. X  return exit(2), 2;
  1867. X}
  1868. SHAR_EOF
  1869. true || echo 'restore of xgetty.c failed'
  1870. rm -f _shar_wnt_.tmp
  1871. fi
  1872. # ============= zyxel.c ==============
  1873. if test -f 'zyxel.c' -a X"$1" != X"-c"; then
  1874.     echo 'x - skipping zyxel.c (File already exists)'
  1875.     rm -f _shar_wnt_.tmp
  1876. else
  1877. > _shar_wnt_.tmp
  1878. echo 'x - extracting zyxel.c (Text)'
  1879. sed 's/^X//' << 'SHAR_EOF' > 'zyxel.c' &&
  1880. X/*
  1881. X * @(#)$Id: zyxel.c,v 1.1 1993/01/06 18:17:28 wcp Exp $
  1882. X *
  1883. X * Copyright (C) 1993    Walter Pelissero
  1884. X *
  1885. X * This program is free software; you can redistribute it and/or modify
  1886. X * it under the terms of the GNU General Public License as published by
  1887. X * the Free Software Foundation; either version 2 of the License, or
  1888. X * (at your option) any later version.
  1889. X *
  1890. X * This program is distributed in the hope that it will be useful,
  1891. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1892. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1893. X * GNU General Public License for more details.
  1894. X *
  1895. X * You should have received a copy of the GNU General Public License
  1896. X * along with this program; if not, write to the Free Software
  1897. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1898. X */
  1899. X
  1900. X/*
  1901. X * $Log: zyxel.c,v $
  1902. X * Revision 1.1  1993/01/06  18:17:28  wcp
  1903. X * Initial revision
  1904. X *
  1905. X */
  1906. X
  1907. X#include <string.h>
  1908. X#include "common.h"
  1909. X#include "modemio.h"
  1910. X#include "zyxel.h"
  1911. X
  1912. Xstatic char RcsId[] = "@(#)$Id: zyxel.c,v 1.1 1993/01/06 18:17:28 wcp Exp $";
  1913. X
  1914. Xconst char *ModemAnswers[] = {
  1915. X  "ERROR",
  1916. X  "OK",
  1917. X  "RING",
  1918. X  "CONNECT 1200",
  1919. X  "CONNECT 2400",
  1920. X  "CONNECT 4800",
  1921. X  "CONNECT 9600",
  1922. X  "CONNECT 19200",
  1923. X  "CONNECT 7200",
  1924. X  "CONNECT 12000",
  1925. X  "CONNECT 14400",
  1926. X  "CONNECT 16800",
  1927. X  "CONNECT 38400",
  1928. X  "CONNECT 57600",
  1929. X  "CONNECT 76800",
  1930. X  "CONNECT",
  1931. X  "NO CARRIER",
  1932. SHAR_EOF
  1933. true || echo 'restore of zyxel.c failed'
  1934. fi
  1935. echo 'End of mgetty-1.0 part 3'
  1936. echo 'File zyxel.c is continued in part 4'
  1937. echo 4 > _shar_seq_.tmp
  1938. exit 0
  1939.  
  1940. -- 
  1941. P4 32 8 @A ^@@A ^@@Ax^@@A ^@DA"^@D]%xJe&H1\236\331\306
  1942.