home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / pcomm202 / part02 < prev    next >
Encoding:
Text File  |  1993-04-13  |  100.9 KB  |  4,207 lines

  1. Newsgroups: comp.sources.unix
  2. From: fthood!egray@uxc.cso.uiuc.edu (Emmet Gray)
  3. Subject: v26i154: pcomm-2.0.2 - a serial communications program (clone of ProComm), Part02/06
  4. Sender: unix-sources-moderator@vix.com
  5. Approved: paul@vix.com
  6.  
  7. Submitted-By: fthood!egray@uxc.cso.uiuc.edu (Emmet Gray)
  8. Posting-Number: Volume 26, Issue 154
  9. Archive-Name: pcomm-2.0.2/part02
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 2 (of 6)."
  18. # Contents:  Configure.sh Pcomm_cmd.1 Q_and_A admin.c d_print.c
  19. #   d_prompt.c d_revise.c e_lib.c ls_menu.c macro.c s_axfer.c
  20. #   s_extrnl.c s_gen.c s_menu.c s_prompt.c s_term.c s_tty.c script.c
  21. #   strings.c tty_att.c tty_ucb.c
  22. # Wrapped by vixie@gw.home.vix.com on Wed Apr 14 00:38:41 1993
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'Configure.sh' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'Configure.sh'\"
  26. else
  27. echo shar: Extracting \"'Configure.sh'\" \(3789 characters\)
  28. sed "s/^X//" >'Configure.sh' <<'END_OF_FILE'
  29. X:
  30. X: what version of UUCP do you have?
  31. if [ -f /usr/lib/uucp/Systems -o -f /etc/uucp/Systems ] ;then
  32. X    echo "You've got the HoneyDanBer (HDB) version of UUCP"
  33. X    echo "Therefore you need:    #define ASCII_PID"
  34. else
  35. X    if [ -f /usr/lib/uucp/L.sys ] ;then
  36. X        echo "You've got the older version of UUCP (not HDB)"
  37. X        echo "Therefore you need:    #undef ASCII_PID"
  38. X    else
  39. X        echo "Can't determine the UUCP version"
  40. X    fi
  41. fi
  42. X:
  43. X: check the location of the UUCP lock files
  44. if [ -d /usr/spool/locks ] ;then
  45. X    echo "Your UUCP lock files go in /usr/spool/locks"
  46. X    echo "Therefore you need:    #define LOCK_DIR \"/usr/spool/locks\""
  47. else
  48. X    if [ -d /usr/spool/uucp/LCK ]; then
  49. X        echo "Your UUCP lock files go in /usr/spool/uucp/LCK"
  50. X        echo "Therefore you need:    #define LOCK_DIR \"/usr/spool/uucp/LCK\""
  51. X    else
  52. X        echo "Your UUCP lock files go in /usr/spool/uucp"
  53. X        echo "Therefore you need:    #define LOCK_DIR \"/usr/spool/uucp\""
  54. X    fi
  55. fi
  56. X:
  57. X: check the version of curses
  58. GOT_IT=0
  59. if [ -f /usr/5include/curses.h ] ;then
  60. X    GOT_IT=/usr/5include/curses.h
  61. X    echo "You've got a System 5 compatibility library... use it!"
  62. X    echo "Edit the Makefile:    CC=/usr/5bin/cc and LD=/usr/5bin/cc"
  63. else
  64. X    if [ -f /usr/include/curses.h ] ;then
  65. X        GOT_IT=/usr/include/curses.h
  66. X    else
  67. X        echo "Can't determine your version of curses"
  68. X    fi
  69. fi
  70. if [ "$GOT_IT" -eq 0 ] ;then
  71. X    if [ `grep -c ACS_HLINE $GOT_IT` -gt 0 ] ;then
  72. X        echo "You've got the newer version of curses"
  73. X        echo "Therefore you need:    #undef OLDCURSES"
  74. X    else
  75. X        echo "You've got and old version of curses"
  76. X        echo "Therefore you need:    #define OLDCURSES"
  77. X    fi
  78. fi
  79. X:
  80. X: check the libraries
  81. echo checking your C library....
  82. if [ -f /usr/5lib/libc.a ] ;then
  83. X    ar t /usr/5lib/libc.a > /tmp/config.$$
  84. else
  85. X    if [ -f /usr/lib/libc.a ] ;then
  86. X        ar t /usr/lib/libc.a > /tmp/config.$$
  87. X    else
  88. X        if [ -f /lib/libc.a ] ;then
  89. X            ar t /lib/libc.a > /tmp/config.$$
  90. X        else
  91. X            if [ -f /usr/ccs/lib/libc.a ] ;then
  92. X                ar t /usr/ccs/lib/libc.a > /tmp/config.$$
  93. X            fi
  94. X        fi
  95. X    fi
  96. fi
  97. if [ -f /tmp/config.$$ ] ;then
  98. X    if [ `grep -c "^poll.o" /tmp/config.$$` -eq 1 ] ;then
  99. X        echo "You've got the poll() function"
  100. X        echo "Edit the Makefile:    IPC.O=ipc_att.o and IPC.C=ipc_att.c"
  101. X    else
  102. X        if [ `grep -c "^select.o" /tmp/config.$$` -eq 1 ] ;then
  103. X            echo "You've got the select() function"
  104. X            echo "Edit the Makefile:    IPC.O=ipc_ucb.o and IPC.C=ipc_ucb.c"
  105. X        else
  106. X            echo "You don't seem to have either poll() or select()"
  107. X            echo "Perhaps they are in another library?"
  108. X        fi
  109. X    fi
  110. X    if [ `grep -c "^usleep.o" /tmp/config.$$` -eq 1 ] ;then
  111. X        echo "You've got the usleep() function"
  112. X        echo "Therefore you need:    #define HAVE_USLEEP"
  113. X    else
  114. X        echo "You don't have the usleep() function"
  115. X        echo "Therefore you need:    #undef HAVE_USLEEP"
  116. X    fi
  117. X    if [ `grep -c "^strstr.o" /tmp/config.$$` -eq 1 ] ;then
  118. X        echo "You've got the strstr() function"
  119. X        echo "Therefore you need:    #define HAVE_STRSTR"
  120. X    else
  121. X        echo "You don't have the strstr() function"
  122. X        echo "Therefore you need:    #undef HAVE_STRSTR"
  123. X    fi
  124. X    if [ `grep -c "^memmove.o" /tmp/config.$$` -eq 1 ] ;then
  125. X        echo "You've got the memmove() function"
  126. X        echo "Therefore you need:    #define MEMMOVE(a,b,c) memmove(a,b,c)"
  127. X    else
  128. X        if [ `grep -c "^memcpy.o" /tmp/config.$$` -eq 1 ] ;then
  129. X            echo "You've got the memcpy() function"
  130. X            echo "Therefore you need:    #define MEMMOVE(a,b,c) memcpy(a,b,c)"
  131. X        else
  132. X            if [ `grep -c "^bcopy.o" /tmp/config.$$` -eq 1 ] ;then
  133. X                echo "You've got the bcopy() function"
  134. X                echo "Therefore you need:    #define MEMMOVE(a,b,c) bcopy(b,a,c)"
  135. X            fi
  136. X        fi
  137. X    fi
  138. X    if [ `grep -c "^truncate.o" /tmp/config.$$` -eq 1 ] ;then
  139. X        echo "You've got the truncate() function"
  140. X        echo "Therefore you need:    #define HAVE_TRUNCATE"
  141. X    else
  142. X        echo "You don't have the truncate() function"
  143. X        echo "Therefore you need:    #undef HAVE_TRUNCATE"
  144. X    fi
  145. X    rm /tmp/config.$$
  146. else
  147. X    echo "Can't determine your C functions"
  148. fi
  149. END_OF_FILE
  150. if test 3789 -ne `wc -c <'Configure.sh'`; then
  151.     echo shar: \"'Configure.sh'\" unpacked with wrong size!
  152. fi
  153. # end of 'Configure.sh'
  154. fi
  155. if test -f 'Pcomm_cmd.1' -a "${1}" != "-c" ; then 
  156.   echo shar: Will not clobber existing file \"'Pcomm_cmd.1'\"
  157. else
  158. echo shar: Extracting \"'Pcomm_cmd.1'\" \(6127 characters\)
  159. sed "s/^X//" >'Pcomm_cmd.1' <<'END_OF_FILE'
  160. X.if n .ds rq ""
  161. X.el .ds rq ''
  162. X.if n .ds lq ""
  163. X.el .ds lq ``
  164. X.TH pcomm_cmd L
  165. X.SH NAME
  166. pcomm_cmd \- send a command to Pcomm
  167. X.SH SYNOPSIS
  168. X.B pcomm_cmd
  169. X[ command ] [ options ] [ arguments ]
  170. X.SH DESCRIPTION
  171. X.I Pcomm_cmd
  172. is a Pcomm support program.  It is used from inside shell scripts to access
  173. Pcomm commands, such as
  174. X.I \*(lqpcomm_cmd send xmodem junk\*(rq
  175. for sending the file \*(lqjunk\*(rq to the remote using the xmodem file
  176. transfer protocol.
  177. X.PP
  178. The following command line options are supported.
  179. X.TP
  180. SET BAUD [ 300 | 1200 | 2400 | 4800 | 9600 | 19200 | 38400 ]
  181. Set the baud rate for the current connection.  This feature is for use
  182. with the DIAL MANUAL command, since the baud rate information in the
  183. dialing directory entries overrides this value. 
  184. X.TP
  185. SET PARITY [ EVEN | ODD | NONE ]
  186. Set the parity for the current connection.  For use with the DIAL MANUAL
  187. command.
  188. X.TP
  189. SET DATA_BITS [ 7 | 8 ]
  190. The number of data bits (word length) used for the current connection.
  191. XFor use with the DIAL MANUAL command.
  192. X.TP
  193. SET STOP_BITS [ 1 | 2 ]
  194. The number of stop bits for the current connection.  For use with the
  195. DIAL MANUAL command.
  196. X.TP
  197. SET DUPLEX [ HALF | FULL ]
  198. Set the duplex mode (local echo).  The HALF option is used if the remote
  199. system does not echo characters as they are typed.
  200. X.TP
  201. SET AUX filename
  202. Use the argument as the auxiliary file associated with the current
  203. connection.  Since chaining of scripts is not supported, this feature
  204. would only be used to set the TTY or modem.
  205. X.TP
  206. SET HOT_KEY [1-256]
  207. Change the decimal value of the \*(lqhot key\*(rq to this value.
  208. X.TP
  209. SET ASCII_HOT string
  210. Change the ASCII representation of the hot key to the given argument.  The
  211. length of the string must be no more than 4 characters wide.
  212. X.TP
  213. SET FLOW_CTRL [ XON/XOFF | NONE ]
  214. Set the flow control between the local and remote systems to either XON/XOFF
  215. or NONE.
  216. X.TP
  217. SET CR_IN [ CR | CR/LF ]
  218. Translate in-comming carriage returns carriage return followed by a line
  219. feed, or pass the carriage return through unchanged.
  220. X.TP
  221. SET CR_OUT [ CR | CR/LF ]
  222. Translate out-going carriage returns to CR or CR/LF.
  223. X.TP
  224. SET LOGFILE filename
  225. Change the name of the default log file.  For use with the DATA_LOG command.
  226. X.TP
  227. SET DUMPFILE filename
  228. Change the name of the screen dump file.  For use with the SCREEN_DUMP 
  229. command.
  230. X.TP
  231. SET STRIP [ YES | NO ]
  232. Should the in-comming data be stripped to 7 bits?
  233. X.TP
  234. SET LOCAL_ECHO [ YES | NO ]
  235. Should data be shown on the screen during ASCII uploads?
  236. X.TP
  237. SET EXPAND [ YES | NO ]
  238. Should blank lines be \*(lqexpanded\*(rq to a line with a single space?
  239. XFor use only during ASCII uploads.
  240. X.TP
  241. SET CR_DELAY [ 0 | 100 | 150 ]
  242. Set the delay for the carraige returns for ASCII uploads.
  243. X.TP
  244. SET PACE [ YES | NO ]
  245. Should the entire upload be artifically slowed down?  For use during ASCII
  246. uploads.
  247. X.TP
  248. SET CR_UP [ NONE | ADD_LF | STRIP ]
  249. Controls the translation of carraige returns during ASCII uploads.
  250. X.TP
  251. SET LF_UP [ NONE | ADD_CR | STRIP ]
  252. Controls the translation of line feeds during ASCII uploads.
  253. X.TP
  254. SET TIMER [5-150]
  255. Controls the timer (in seconds) that detects the end of an ASCII download.
  256. X.TP
  257. SET CR_DN [ NONE | ADD_LF | STRIP ]
  258. Controls the translation of carraige returns during ASCII downloads.
  259. X.TP
  260. SET LF_DN [ NONE | ADD_CR | STRIP ]
  261. Controls the translation of line feeds during ASCII downloads.
  262. X.TP
  263. QUERY TTY_NAME
  264. Returns the name of the current TTY in use or NONE.
  265. X.TP
  266. QUERY MODEM_NAME
  267. Returns the name of the current modem in use or NONE.
  268. X.TP
  269. IF CONNECTED
  270. Returns a 1 if Pcomm is currently connected to a remote, otherwise a 0.
  271. X.TP
  272. IF LOG_STATUS
  273. Returns a 1 if the data logging feature is turned on, otherwise 0.
  274. X.TP
  275. IF PRINTER_STATUS
  276. Returns a 1 if the printer is turned on, otherwise 0.
  277. X.TP
  278. DIAL [ MANUAL phone_number ] entry_number
  279. Dial an entry from the dialing directory.  The MANUAL option is used to
  280. optionaly dial a phone number without the use of the dialing directory.
  281. DIAL returns after 1 attempt.  A return code of 1 means a connection
  282. was made.
  283. X.ft I
  284. The dial function will not be allowed to switch TTY ports.  If the current
  285. TTY is not suitable (i.e. not attached to the correct modem), the script
  286. will be terminated.
  287. X.ft
  288. X.TP
  289. REDIAL entry_number
  290. Similar to the DIAL command, but 10 attempts are made.
  291. X.TP
  292. XEXIT
  293. Hang up the phone and exit from Pcomm.
  294. X.TP
  295. CLEAR_SCREEN
  296. Clear the screen.
  297. X.TP
  298. CHG_DIR directory
  299. Change the current working directory to the given directory.
  300. X.TP
  301. HANG_UP
  302. Hang up the phone, but remain in Pcomm.
  303. X.TP
  304. PRINTER [ ON | OFF ]
  305. Control the logging of data to the printer.
  306. X.TP
  307. MODEM_BREAK
  308. Send a modem break to the remote system.  This is typically used to
  309. tell the remote to switch to a different baud rate.
  310. X.TP
  311. SEND protocol filename
  312. Send a file to the remote.  The valid protocols are XMODEM, XMODEM_1K,
  313. MODEM7, YMODEM, YMODEM_G, ASCII, EXT_1, EXT_2, and EXT_3.
  314. X.TP
  315. RECEIVE protocol filename
  316. Receive a file from the remote.  The valid protocols are XMODEM,
  317. XXMODEM_1K, MODEM7, YMODEM, YMODEM_G, ASCII, EXT_1, EXT_2, and EXT_3.
  318. X.TP
  319. SCREEN_DUMP
  320. Dump the current contents of the screen to the DUMPFILE.  If the file
  321. already exists, the new contents are appended to the file.
  322. X.TP
  323. DATA_LOG [ ON | OFF ]
  324. Control logging of the terminal session to the LOGFILE.  If the file
  325. already exists, the new contents are appended to the file.
  326. X.SH EXAMLES
  327. The following is an example of a shell script that will dial a system,
  328. log a user on, transfer a file called "junk" using xmodem, log out, and
  329. exit Pcomm.
  330. X.PP
  331. X.nf
  332. X.RS 5
  333. X# dial entry number 23 in my dialing directory
  334. pcomm_cmd dial 23
  335. X# wait for the login prompt
  336. waitfor ogin:
  337. X# send my user id
  338. echo egray
  339. X# wait for the password prompt
  340. waitfor assword:
  341. X# send my passwd
  342. echo abcdefg
  343. X# wait for terminal type prompt
  344. waitfor vt100
  345. X# echo my type
  346. echo vt100
  347. X# wait for a Unix prompt
  348. waitfor $
  349. X# start up an xmodem file transfer
  350. echo sx junk
  351. X# wait for the sx command to say its ready
  352. waitfor now
  353. sleep 1
  354. X# do a file transfer
  355. pcomm_cmd receive xmodem junk
  356. X# wait for the prompt
  357. waitfor $
  358. X# log me out
  359. echo "^D"
  360. sleep 1
  361. X# exit pcomm
  362. pcomm_cmd exit
  363. X.fi
  364. X.RE
  365. X.SH "SEE ALSO"
  366. pcomm(1), waitfor(1), matches(1), Pcomm Reference Manual
  367. END_OF_FILE
  368. if test 6127 -ne `wc -c <'Pcomm_cmd.1'`; then
  369.     echo shar: \"'Pcomm_cmd.1'\" unpacked with wrong size!
  370. fi
  371. # end of 'Pcomm_cmd.1'
  372. fi
  373. if test -f 'Q_and_A' -a "${1}" != "-c" ; then 
  374.   echo shar: Will not clobber existing file \"'Q_and_A'\"
  375. else
  376. echo shar: Extracting \"'Q_and_A'\" \(3301 characters\)
  377. sed "s/^X//" >'Q_and_A' <<'END_OF_FILE'
  378. X            Questions and Answers
  379. X        for the most common Pcomm problems.
  380. X
  381. X1) The "elpase time" doesn't increment during a dialing attempt.
  382. X
  383. X    This is a symptom of a bug in the wgetch() routine in the curses
  384. X    library.  The work-around is to set WGETCH_BROKE in the config.h
  385. X    file and recompile.
  386. X
  387. X2) I can't get Pcomm to dial, it just sits there.
  388. X
  389. X    This typically is due to the wrong device name for the tty port.
  390. X    Some systems have more than one name (different minor device
  391. X    numbers) for the same tty port.  UUCP may use the device name
  392. X    that has "modem control" enabled; if so, that is the one Pcomm
  393. X    needs to use.
  394. X
  395. X3) How do you make Sun's dial in and out on the same port?
  396. X
  397. X    Sun Sparc boxes don't come configured for doing dialin and dialout
  398. X    on the same serial port.  However, there is a blurb in the printed
  399. X    manual that tells you what to do...
  400. X
  401. X    Make a new device (cua0 for ttya, and/or cua1 for ttyb)
  402. X        mknod /dev/cua0 c 12 128
  403. X        mknod /dev/cua1 c 12 129
  404. X
  405. X    Edit /etc/ttytab.  Change the ttya (or ttyb) line to look like
  406. X    the following.  Look in the /etc/gettytab file for the choices
  407. X    for the second field (std.38400, in this example).
  408. X        ttya   "/usr/etc/getty std.38400"  dialup    on remote secure
  409. X        ttyb   "/usr/etc/getty std.38400"  dialup    on remote secure
  410. X
  411. X    Edit /etc/uucp/Devices.  Add a line for each speed your modem
  412. X    supports.  The dialer field (hayes, in this example) must match
  413. X    whatever you've got in /etc/uucp/Dialers.
  414. X        ACU cua0 cua0 1200 hayes
  415. X        ACU cua0 cua0 2400 hayes
  416. X        ACU cua0 cua0 9600 hayes
  417. X        ACU cua0 cua0 19200 hayes
  418. X        ACU cua0 cua0 38400 hayes
  419. X
  420. X4) I get a measage that tells me I can't create the lockfile (or can't
  421. open the tty port).
  422. X
  423. X    Pcomm is typically configured to be set-user-id to uucp.  To do
  424. X    this, you type (as root):
  425. X        chown uucp pcomm
  426. X        chmod 4755 pcomm
  427. X        
  428. X5) As soon as I am connected, the modem lights go crazy.
  429. X
  430. X    This is probably caused by an improper UUCP lock file.  Pcomm
  431. X    understands several variations of UUCP lock files, but must
  432. X    match the one used by your UUCP.  Read the Readme file and check
  433. X    the LOCK_DIR, ASCII_PID, SVR4_LOCKS, and XENIX_LOCKS in the
  434. X    config.h file.
  435. X
  436. X6) I've got a V.32bis modem but without locked DTE speeds, how do I
  437. setup Pcomm for this?
  438. X
  439. X    Change the tty database so that the "locked speed" entry is set
  440. X    to zero.  Then change the "auto-baud detect" flag in the modem
  441. X    database to 'N'.
  442. X
  443. X    In this configuration, the modem will always use the DTE speed
  444. X    as specified in the dialing directory.  The status line will
  445. X    show this speed, regardless of the actual connected baud rate.
  446. X
  447. X7) Some of the Pcomm screens appear messed up.
  448. X
  449. X    Yes, that's unfortunately quite common...  It's a bug in either
  450. X    the curses library or the termcap/terminfo database.  I've
  451. X    included a terminfo entry for AT386 in the Readme file, that
  452. X    seemed to fix the problem for my 386 box.
  453. X
  454. X8) Where do I get xmodem/ymodem/zmodem stand-alone programs for Unix?
  455. X
  456. X    I use Xmodem v3.8 by Steve Grandi, and an older version of rzsz
  457. X    by Omen Technologies.  Both of these should be available at a
  458. X    neighboring archive site.
  459. X
  460. X9) I can't get the external zmodem programs "rz" and "sz" to work from
  461. inside Pcomm.
  462. X
  463. X    The authors of rz and sz have deliberately broken the program so
  464. X    that it will not work from inside another program.  See if you
  465. X    can find an older version.
  466. END_OF_FILE
  467. if test 3301 -ne `wc -c <'Q_and_A'`; then
  468.     echo shar: \"'Q_and_A'\" unpacked with wrong size!
  469. fi
  470. # end of 'Q_and_A'
  471. fi
  472. if test -f 'admin.c' -a "${1}" != "-c" ; then 
  473.   echo shar: Will not clobber existing file \"'admin.c'\"
  474. else
  475. echo shar: Extracting \"'admin.c'\" \(2942 characters\)
  476. sed "s/^X//" >'admin.c' <<'END_OF_FILE'
  477. X/*
  478. X * Perform administrative functions.  Check to see if the user has
  479. X * permission to make long distance calls, and record all phone calls
  480. X * made by Pcomm.
  481. X */
  482. X
  483. X#include <stdio.h>
  484. X#include <grp.h>
  485. X#include "config.h"
  486. X#include "dial_dir.h"
  487. X#include "param.h"
  488. X
  489. static char *build_num();
  490. X
  491. X/*
  492. X * Make a log of all calls made by Pcomm.  The argument is the index
  493. X * into the queue.
  494. X */
  495. X
  496. X/* ARGSUSED */
  497. void
  498. log_calls(i)
  499. int i;
  500. X{
  501. X#ifdef LOG_CALLS
  502. X    FILE *fp;
  503. X    char *number, *date, *ctime(), *getlogin(), buf[80];
  504. X    long now, time();
  505. X    void error_win();
  506. X                    /* build the complete phone number */
  507. X    number = build_num(i);
  508. X                    /* build date and time */
  509. X    time(&now);
  510. X    date = ctime(&now);
  511. X    date[10] = '\0';
  512. X    date[16] = '\0';
  513. X
  514. X    if (!(fp = fopen(LOG_FILE, "a+"))) {
  515. X                    /* fatal! (to prevent hanky panky) */
  516. X        sprintf(buf, "Can't open log file \"%s\"", LOG_FILE);
  517. X        error_win(1, buf, "Contact your system administrator");
  518. X    }
  519. X
  520. X    fprintf(fp, "pcomm: %s called %s at %s on %s\n", getlogin(), number, &date[11], date);
  521. X    fclose(fp);
  522. X#endif /* LOG_CALLS */
  523. X    return;
  524. X}
  525. X
  526. X/*
  527. X * Check to see if long distance (toll) call is authorized.  The argument
  528. X * is the index into the queue.
  529. X */
  530. X
  531. X/* ARGSUSED */
  532. int
  533. limit_ld(i)
  534. int i;
  535. X{
  536. X#ifdef LIMIT_LD
  537. X    char *number, *name, *getlogin();
  538. X    struct group *getgrnam(), *grpbuf;
  539. X
  540. X                    /* if no group, don't bother */
  541. X    grpbuf = getgrnam(GROUP_NAME);
  542. X    if (grpbuf == NULL || *grpbuf->gr_mem == '\0')
  543. X        return(0);
  544. X                    /* are you in the group? */
  545. X    name = getlogin();
  546. X    for (; *grpbuf->gr_mem!='\0'; grpbuf->gr_mem++) {
  547. X        if (!strcmp(*grpbuf->gr_mem, name))
  548. X            return(0);
  549. X    }
  550. X                    /* numbers only... */
  551. X    number = build_num(i);
  552. X
  553. X    /*
  554. X     * VERY SITE SPECIFIC!!!  We use a "9" to get an outside line,
  555. X     * so any 9 followed by a 1 is a toll call (except for 1-800
  556. X     * numbers).
  557. X     */
  558. X    if (!strncmp(number, "91", 2) && strncmp(number, "91800", 5)) {
  559. X        error_win(0, "You are not authorized to place long distance (toll) calls", "");
  560. X        return(1);
  561. X    }
  562. X
  563. X    if (*number == '\0') {
  564. X        error_win(0, "You are not authorized direct access to the line", "Use the automatic dialing feature");
  565. X        return(1);
  566. X    }
  567. X#endif /* LIMIT_LD */
  568. X    return(0);
  569. X}
  570. X
  571. X#if defined(LOG_CALLS) || defined(LIMIT_LD)
  572. X/*
  573. X * Put together the complete phone number but strip out the extraneous
  574. X * characters.
  575. X */
  576. X
  577. static char *
  578. build_num(i)
  579. int i;
  580. X{
  581. X    int j;
  582. X    char *t, temp[80], *strcpy(), *strcat();
  583. X    static char ans[80];
  584. X
  585. X    temp[0] = '\0';
  586. X                    /* add LD codes? */
  587. X    switch (dir->q_ld[i]) {
  588. X        case 0:
  589. X            break;
  590. X        case '+':
  591. X            strcpy(temp, param->ld_plus);
  592. X            break;
  593. X        case '-':
  594. X            strcpy(temp, param->ld_minus);
  595. X            break;
  596. X        case '@':
  597. X            strcpy(temp, param->ld_at);
  598. X            break;
  599. X        case '#':
  600. X            strcpy(temp, param->ld_pound);
  601. X            break;
  602. X    }
  603. X                    /* add the number */
  604. X    strcat(temp, dir->number[dir->q_num[i]]);
  605. X
  606. X                    /* copy only digits */
  607. X    j = 0;
  608. X    t = temp;
  609. X    while (*t) {
  610. X        if (*t >= '0' && *t <= '9')
  611. X            ans[j++] = *t;
  612. X        t++;
  613. X    }
  614. X    ans[j] = '\0';
  615. X
  616. X    return(ans);
  617. X}
  618. X#endif /* LOG_CALLS || LIMIT_LD */
  619. END_OF_FILE
  620. if test 2942 -ne `wc -c <'admin.c'`; then
  621.     echo shar: \"'admin.c'\" unpacked with wrong size!
  622. fi
  623. # end of 'admin.c'
  624. fi
  625. if test -f 'd_print.c' -a "${1}" != "-c" ; then 
  626.   echo shar: Will not clobber existing file \"'d_print.c'\"
  627. else
  628. echo shar: Extracting \"'d_print.c'\" \(3986 characters\)
  629. sed "s/^X//" >'d_print.c' <<'END_OF_FILE'
  630. X/*
  631. X * The print option of the dialing directory.  A carriage return will
  632. X * send the dialing directory to the print spool program, otherwise the
  633. X * selected file will be used.
  634. X */
  635. X
  636. X#define MAX_STRING    80
  637. X
  638. X#include <stdio.h>
  639. X#include <curses.h>
  640. X#include "config.h"
  641. X#include "dial_dir.h"
  642. X#include "misc.h"
  643. X
  644. static char *e_get_str();
  645. X
  646. void
  647. print_dir()
  648. X{
  649. X    FILE *fp, *n_popen(), *uid_fopen();
  650. X    WINDOW *p_win, *newwin();
  651. X    char *ans, *file, buf[100], *expand();
  652. X    int is_printer, i;
  653. X    void error_win();
  654. X    unsigned int sleep();
  655. X
  656. X    p_win = newwin(5, 54, 0, 26);
  657. X
  658. X    mvwaddstr(p_win, 2, 3, "Print to: (printer)");
  659. X    box(p_win, VERT, HORZ);
  660. X    wmove(p_win, 2, 13);
  661. X    wrefresh(p_win);
  662. X
  663. X    /*
  664. X     * This is a special version of get_str() that looks at the
  665. X     * first character to see if it should erase the default answer
  666. X     * already on the screen.
  667. X     */
  668. X    if ((ans = e_get_str(p_win, 80)) == NULL) {
  669. X                    /* erase because it overlaps dm_win */
  670. X        werase(p_win);
  671. X        wrefresh(p_win);
  672. X        delwin(p_win);
  673. X        return;
  674. X    }
  675. X    file = expand(ans);
  676. X    is_printer = 0;
  677. X                    /* the default (printer) */
  678. X    if (*file == '\0') {
  679. X        if (!(fp = n_popen(LPRINT, "w"))) {
  680. X            sprintf(buf, "\"%s\"", LPRINT);
  681. X            error_win(0, "Can't open printer program", buf);
  682. X            werase(p_win);
  683. X            wrefresh(p_win);
  684. X            delwin(p_win);
  685. X            return;
  686. X        }
  687. X        is_printer++;
  688. X    }
  689. X                    /* the requested file */
  690. X    else {
  691. X        /*
  692. X         * Check to see if the file already exists (and if you
  693. X         * have write permission too).  Currently only allows
  694. X         * you to bail out or overwrite the file (no append).
  695. X         */
  696. X        switch(can_write(file)) {
  697. X            case DENIED:
  698. X                sprintf(buf, "\"%s\"", file);
  699. X                error_win(0, "No write permission on file", buf);
  700. X                werase(p_win);
  701. X                wrefresh(p_win);
  702. X                delwin(p_win);
  703. X                return;
  704. X            case OK_BUT_EXISTS:
  705. X                werase(p_win);
  706. X                mvwprintw(p_win, 2, 3, "File \"%s\" already exists!", file);
  707. X                beep();
  708. X                box(p_win, VERT, HORZ);
  709. X                if (!yes_prompt(p_win, 3, 3, A_BOLD, "Overwrite")) {
  710. X                    werase(p_win);
  711. X                    wrefresh(p_win);
  712. X                    delwin(p_win);
  713. X                    return;
  714. X                }
  715. X                /* FALLTHRU */
  716. X            case WRITE_OK:
  717. X                if (!(fp = uid_fopen(file, "w"))) {
  718. X                    sprintf(buf, "\"%s\"", file);
  719. X                    error_win(0, "Can't open file", buf);
  720. X                    werase(p_win);
  721. X                    wrefresh(p_win);
  722. X                    delwin(p_win);
  723. X                    return;
  724. X                }
  725. X                break;
  726. X        }
  727. X    }
  728. X
  729. X    werase(p_win);
  730. X    mvwaddstr(p_win, 2, 13, "Printing Pcomm directory");
  731. X    box(p_win, VERT, HORZ);
  732. X    wrefresh(p_win);
  733. X
  734. X    /*
  735. X     * Only prints up to the end of the physical file, not the entire
  736. X     * structure.  I gave some thought about not printing empty entries,
  737. X     * but...
  738. X     */
  739. X    for (i=1; i<=dir->d_entries; i++)
  740. X        fprintf(fp, "%4d- %-20.20s %18.18s  %5d-%c-%d-%d  %c  %-14.14s\n",
  741. X         i, dir->name[i], dir->number[i], dir->baud[i], dir->parity[i],
  742. X         dir->data_bits[i], dir->stop_bits[i], dir->duplex[i],
  743. X         dir->aux[i]);
  744. X
  745. X    if (is_printer)
  746. X        n_pclose(fp);
  747. X    else {
  748. X                    /* a dramatic delay... */
  749. X        sleep(1);
  750. X        fclose(fp);
  751. X    }
  752. X
  753. X    werase(p_win);
  754. X    wrefresh(p_win);
  755. X    delwin(p_win);
  756. X    return;
  757. X}
  758. X
  759. X/*
  760. X * Get a string from a window but erase the line first.
  761. X */
  762. X
  763. static char *
  764. e_get_str(win, num)
  765. WINDOW *win;
  766. int num;
  767. X{
  768. X    int count, x, y, done_it;
  769. X    char ans;
  770. X    static char buf[MAX_STRING];
  771. X
  772. X    done_it = 0;
  773. X    count = 0;
  774. X    while ((ans = wgetch(win)) != '\r') {
  775. X                    /* do our own backspace */
  776. X        if (ans == BS || ans == DEL) {
  777. X            if (!count) {
  778. X                beep();
  779. X                continue;
  780. X            }
  781. X            count--;
  782. X            buf[count] = '\0';
  783. X            getyx(win, y, x);
  784. X            x--;
  785. X            wmove(win, y, x);
  786. X            waddch(win, (chtype) ' ');
  787. X            wmove(win, y, x);
  788. X            wrefresh(win);
  789. X            continue;
  790. X        }
  791. X                    /* exceeded the max? */
  792. X        if (count >= num || count >= MAX_STRING) {
  793. X            beep();
  794. X            continue;
  795. X        }
  796. X                    /* illegal character? */
  797. X        if (ans == '\n') {
  798. X            beep();
  799. X            continue;
  800. X        }
  801. X                    /* an <ESC> anywhere in the string */
  802. X        if (ans == ESC)
  803. X            return(NULL);
  804. X                    /* erase the default answer */
  805. X        if (!done_it) {
  806. X            waddstr(win, "         ");
  807. X            wmove(win, 2, 13);
  808. X            wrefresh(win);
  809. X            done_it++;
  810. X        }
  811. X
  812. X        buf[count] = ans;
  813. X        waddch(win, (chtype) ans);
  814. X        wrefresh(win);
  815. X        count++;
  816. X    }
  817. X    buf[count] = '\0';
  818. X    return(buf);
  819. X}
  820. END_OF_FILE
  821. if test 3986 -ne `wc -c <'d_print.c'`; then
  822.     echo shar: \"'d_print.c'\" unpacked with wrong size!
  823. fi
  824. # end of 'd_print.c'
  825. fi
  826. if test -f 'd_prompt.c' -a "${1}" != "-c" ; then 
  827.   echo shar: Will not clobber existing file \"'d_prompt.c'\"
  828. else
  829. echo shar: Extracting \"'d_prompt.c'\" \(6131 characters\)
  830. sed "s/^X//" >'d_prompt.c' <<'END_OF_FILE'
  831. X/*
  832. X * Prompt for directory entry changes.  Copies the original values in
  833. X * case you change your mind half way thru.  A non-zero return code means
  834. X * the entry was changed.
  835. X */
  836. X
  837. X#include <stdio.h>
  838. X#include <curses.h>
  839. X#include "dial_dir.h"
  840. X#include "misc.h"
  841. X
  842. int
  843. prompt_lib(win, i)
  844. WINDOW *win;
  845. int i;
  846. X{
  847. X    extern int xmc;
  848. X    extern char *null_ptr;
  849. X    int n, dbits, sbits, spot;
  850. X    unsigned int baud;
  851. X    static unsigned int valid_baud[7] = {300, 1200, 2400, 4800, 9600,
  852. X    19200, 38400};
  853. X    static char *valid_parity[3] = {"Even", "Odd", "None"};
  854. X    char *ans, *get_str(), c, temp, name[40], number[40], aux[40];
  855. X    char parity, duplex, *str_rep(), *strcpy(), buf[40];
  856. X    void free_ptr();
  857. X                    /* make copies */
  858. X    strcpy(name, dir->name[i]);
  859. X    strcpy(number, dir->number[i]);
  860. X    baud = dir->baud[i];
  861. X    parity = dir->parity[i];
  862. X    dbits = dir->data_bits[i];
  863. X    sbits = dir->stop_bits[i];
  864. X    duplex = dir->duplex[i];
  865. X    strcpy(aux, dir->aux[i]);
  866. X                    /* display original values */
  867. X    werase(win);
  868. X    mvwprintw(win, 2, 5, "%-20.20s %18.18s  %5d-%c-%d-%d  %c  %-14.14s\n",
  869. X     dir->name[i], dir->number[i], dir->baud[i], dir->parity[i],
  870. X     dir->data_bits[i], dir->stop_bits[i], dir->duplex[i], dir->aux[i]);
  871. X    box(win, VERT, HORZ);
  872. X
  873. X                    /* prompt for name */
  874. X    mvwaddstr(win, 4, 4, "Name: ");
  875. X    wrefresh(win);
  876. X
  877. X    if ((ans = get_str(win, 20, "", ";\n")) == NULL)
  878. X        return(0);
  879. X    if (*ans != '\0') {
  880. X        strcpy(name, ans);
  881. X        mvwaddstr(win, 2, 5, "                    ");
  882. X        wrefresh(win);
  883. X        mvwattrstr(win, 2, 5, A_BOLD, name);
  884. X    }
  885. X                    /* prompt for number */
  886. X    clear_line(win, 4, 4, TRUE);
  887. X    waddstr(win, "Number: ");
  888. X    wrefresh(win);
  889. X
  890. X    if ((ans = get_str(win, 18, "", ";\n")) == NULL)
  891. X        return(0);
  892. X    if (*ans != '\0') {
  893. X        strcpy(number, ans);
  894. X        mvwaddstr(win, 2, 26, "                  ");
  895. X        wrefresh(win);
  896. X        /*
  897. X         * Should be right justified, but we don't wanna have
  898. X         * the attribute turned on for blanks.
  899. X         */
  900. X        spot = 26 + 18 - strlen(number);
  901. X        mvwattrstr(win, 2, spot, A_BOLD, number);
  902. X    }
  903. X                    /* template for next few */
  904. X    clear_line(win, 4, 4, TRUE);
  905. X    mvwaddstr(win, 4, 31, "(Any key to change, <CR> to accept)");
  906. X
  907. X    /*
  908. X     * These next few prompts display a series of choices and allow
  909. X     * the user to hit <CR> to accept the currently showing value
  910. X     * or any other key to see the next choice.  The first value
  911. X     * displayed is always the current value.
  912. X     */
  913. X                    /* choose from baud menu */
  914. X    for (n=0; n<7; n++) {
  915. X        if (valid_baud[n] == baud)
  916. X            break;
  917. X    }
  918. X    mvwprintw(win, 4, 4, "Baud: %-5d", valid_baud[n]);
  919. X    wmove(win, 4, 10);
  920. X    wrefresh(win);
  921. X
  922. X    while ((c = wgetch(win)) != '\r') {
  923. X        if (c == ESC)
  924. X            return(0);
  925. X        n = (n == 6) ? 0 : n+1;
  926. X        mvwprintw(win, 4, 4, "Baud: %-5d", valid_baud[n]);
  927. X        wmove(win, 4, 10);
  928. X        wrefresh(win);
  929. X    }
  930. X    if (baud != valid_baud[n]) {
  931. X        baud = valid_baud[n];
  932. X        sprintf(buf, "%5d", baud);
  933. X        if (xmc > 0) {
  934. X            sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
  935. X            mvwaddstr(win, 2, 46, "           ");
  936. X            wrefresh(win);
  937. X        }
  938. X        mvwattrstr(win, 2, 46, A_BOLD, buf);
  939. X    }
  940. X                    /* choose from parity menu */
  941. X    for (n=0; n<3; n++) {
  942. X        if (*valid_parity[n] == parity)
  943. X            break;
  944. X    }
  945. X    mvwprintw(win, 4, 4, "Parity: %-5.5s", valid_parity[n]);
  946. X    wmove(win, 4, 12);
  947. X    wrefresh(win);
  948. X
  949. X    while ((c = wgetch(win)) != '\r') {
  950. X        if (c == ESC)
  951. X            return(0);
  952. X        n = (n == 2) ? 0 : n+1;
  953. X        mvwprintw(win, 4, 4, "Parity: %-5.5s", valid_parity[n]);
  954. X        wmove(win, 4, 12);
  955. X        wrefresh(win);
  956. X    }
  957. X    if (parity != *valid_parity[n]) {
  958. X        parity = *valid_parity[n];
  959. X        if (xmc > 0) {
  960. X            sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
  961. X            mvwaddstr(win, 2, 46, "           ");
  962. X            wrefresh(win);
  963. X            mvwattrstr(win, 2, 46, A_BOLD, buf);
  964. X        }
  965. X        else
  966. X            mvwattrch(win, 2, 52, A_BOLD, parity);
  967. X    }
  968. X                    /* choose from data bits menu */
  969. X    n = dbits;
  970. X    mvwprintw(win, 4, 4, "Data Bits: %d    ", n);
  971. X    wmove(win, 4, 15);
  972. X    wrefresh(win);
  973. X
  974. X    while ((c = wgetch(win)) != '\r') {
  975. X        if (c == ESC)
  976. X            return(0);
  977. X        n = (n == 8) ? 7 : 8;
  978. X        mvwprintw(win, 4, 4, "Data Bits: %d    ", n);
  979. X        wmove(win, 4, 15);
  980. X        wrefresh(win);
  981. X    }
  982. X    if (dbits != n) {
  983. X        dbits = n;
  984. X        if (xmc > 0) {
  985. X            sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
  986. X            mvwaddstr(win, 2, 46, "           ");
  987. X            wrefresh(win);
  988. X            mvwattrstr(win, 2, 46, A_BOLD, buf);
  989. X        }
  990. X        else
  991. X            mvwattrnum(win, 2, 54, A_BOLD, dbits);
  992. X    }
  993. X                    /* choose from stop bits menu */
  994. X    n = sbits;
  995. X    mvwprintw(win, 4, 4, "Stop Bits: %d    ", n);
  996. X    wmove(win, 4, 15);
  997. X    wrefresh(win);
  998. X
  999. X    while ((c = wgetch(win)) != '\r') {
  1000. X        if (c == ESC)
  1001. X            return(0);
  1002. X        n = (n == 2) ? 1 : 2;
  1003. X        mvwprintw(win, 4, 4, "Stop Bits: %d    ", n);
  1004. X        wmove(win, 4, 15);
  1005. X        wrefresh(win);
  1006. X    }
  1007. X    if (sbits != n) {
  1008. X        sbits = n;
  1009. X        if (xmc > 0) {
  1010. X            sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
  1011. X            mvwaddstr(win, 2, 46, "           ");
  1012. X            wrefresh(win);
  1013. X            mvwattrstr(win, 2, 46, A_BOLD, buf);
  1014. X        }
  1015. X        else
  1016. X            mvwattrnum(win, 2, 56, A_BOLD, sbits);
  1017. X    }
  1018. X                    /* choose from duplex menu */
  1019. X    temp = duplex;
  1020. X    mvwprintw(win, 4, 4, "Duplex: %c    ", temp);
  1021. X    wmove(win, 4, 12);
  1022. X    wrefresh(win);
  1023. X
  1024. X    while ((c = wgetch(win)) != '\r') {
  1025. X        if (c == ESC)
  1026. X            return(0);
  1027. X        temp = (temp == 'F') ? 'H' : 'F';
  1028. X        mvwprintw(win, 4, 4, "Duplex: %c    ", temp);
  1029. X        wmove(win, 4, 12);
  1030. X        wrefresh(win);
  1031. X    }
  1032. X    if (duplex != temp) {
  1033. X        duplex = temp;
  1034. X        mvwattrch(win, 2, 59, A_BOLD, duplex);
  1035. X    }
  1036. X                    /* prompt for script, TTY, or modem */
  1037. X    clear_line(win, 4, 4, TRUE);
  1038. X    waddstr(win, "Auxiliary file: ");
  1039. X    wrefresh(win);
  1040. X
  1041. X    if ((ans = get_str(win, 17, "", ";\n")) == NULL)
  1042. X        return(0);
  1043. X
  1044. X    if (*ans != '\0') {
  1045. X        strcpy(aux, ans);
  1046. X        mvwaddstr(win, 2, 62, "              ");
  1047. X        wrefresh(win);
  1048. X        mvwattrstr(win, 2, 62, A_BOLD, aux);
  1049. X    }
  1050. X                    /* store 'em for real */
  1051. X
  1052. X    if (!strcmp(name, " ")) {
  1053. X        free_ptr(dir->name[i]);
  1054. X        dir->name[i] = null_ptr;
  1055. X    }
  1056. X    else
  1057. X        dir->name[i] = str_rep(dir->name[i], name);
  1058. X
  1059. X    if (!strcmp(number, " ")) {
  1060. X        free_ptr(dir->number[i]);
  1061. X        dir->number[i] = null_ptr;
  1062. X    }
  1063. X    else
  1064. X        dir->number[i] = str_rep(dir->number[i], number);
  1065. X
  1066. X    dir->baud[i] = baud;
  1067. X    dir->parity[i] = parity;
  1068. X    dir->data_bits[i] = dbits;
  1069. X    dir->stop_bits[i] = sbits;
  1070. X    dir->duplex[i] = duplex;
  1071. X
  1072. X    if (!strcmp(aux, " ")) {
  1073. X        free_ptr(dir->aux[i]);
  1074. X        dir->aux[i] = null_ptr;
  1075. X    }
  1076. X    else
  1077. X        dir->aux[i] = str_rep(dir->aux[i], aux);
  1078. X
  1079. X    return(1);
  1080. X}
  1081. END_OF_FILE
  1082. if test 6131 -ne `wc -c <'d_prompt.c'`; then
  1083.     echo shar: \"'d_prompt.c'\" unpacked with wrong size!
  1084. fi
  1085. # end of 'd_prompt.c'
  1086. fi
  1087. if test -f 'd_revise.c' -a "${1}" != "-c" ; then 
  1088.   echo shar: Will not clobber existing file \"'d_revise.c'\"
  1089. else
  1090. echo shar: Extracting \"'d_revise.c'\" \(4002 characters\)
  1091. sed "s/^X//" >'d_revise.c' <<'END_OF_FILE'
  1092. X/*
  1093. X * The revise option of the dialing directory.  A non-zero return code
  1094. X * means that something was updated.  Prompts for saving changes to disk.
  1095. X */
  1096. X
  1097. X#include <stdio.h>
  1098. X#include <curses.h>
  1099. X#include "dial_dir.h"
  1100. X#include "misc.h"
  1101. X#include "param.h"
  1102. X
  1103. static char *ld_prompt();
  1104. X
  1105. int
  1106. revise()
  1107. X{
  1108. X    WINDOW *r_win, *newwin();
  1109. X    int count, dir_flag, param_flag, num, x, y, save;
  1110. X    char ans, buf[40], *ld, *str_rep();
  1111. X
  1112. X    r_win = newwin(7, 77, 7, 2);
  1113. X
  1114. X    mvwaddstr(r_win, 3, 6, "Entry to revise?");
  1115. X    mvwaddstr(r_win, 3, 35, "(Entry Number, +, -, @, #)");
  1116. X    box(r_win, VERT, HORZ);
  1117. X    wmove(r_win, 3, 23);
  1118. X    wrefresh(r_win);
  1119. X
  1120. X    dir_flag = 0;
  1121. X    param_flag = 0;
  1122. X    count = 0;
  1123. X
  1124. X    /*
  1125. X     * Can't use my home-grown get_str() and get_num() functions
  1126. X     * here, because we are prompting for an entry number or a
  1127. X     * long distance code.  This routine echoes numbers only.
  1128. X     */
  1129. X    while ((ans = wgetch(r_win)) != ESC) {
  1130. X        if (ans >= '0' && ans <= '9') {
  1131. X            if (count == 3) {
  1132. X                beep();
  1133. X                continue;
  1134. X            }
  1135. X            buf[count] = ans;
  1136. X            waddch(r_win, (chtype) ans);
  1137. X            wrefresh(r_win);
  1138. X            count++;
  1139. X            continue;
  1140. X        }
  1141. X                    /* terminating CR */
  1142. X        if (ans == '\r') {
  1143. X            if (!count) {
  1144. X                beep();
  1145. X                continue;
  1146. X            }
  1147. X            buf[count] = '\0';
  1148. X            num = atoi(buf);
  1149. X                    /* valid range of numbers? */
  1150. X            if (num == 0 || num > NUM_DIR) {
  1151. X                beep();
  1152. X                mvwaddstr(r_win, 3, 23, "   ");
  1153. X                wmove(r_win, 3, 23);
  1154. X                wrefresh(r_win);
  1155. X                count = 0;
  1156. X                continue;
  1157. X            }
  1158. X                    /* prompt for that entry */
  1159. X            if (prompt_lib(r_win, num)) {
  1160. X                dir_flag++;
  1161. X                break;
  1162. X            }
  1163. X            delwin(r_win);
  1164. X            return(0);
  1165. X        }
  1166. X                    /* do our own backspace */
  1167. X        if (ans == BS || ans == DEL) {
  1168. X            if (!count) {
  1169. X                beep();
  1170. X                continue;
  1171. X            }
  1172. X            count--;
  1173. X            buf[count] = '\0';
  1174. X            getyx(r_win, y, x);
  1175. X            x--;
  1176. X            wmove(r_win, y, x);
  1177. X            waddch(r_win, (chtype) ' ');
  1178. X            wmove(r_win, y, x);
  1179. X            wrefresh(r_win);
  1180. X            continue;
  1181. X        }
  1182. X                    /* non-number after number is error */
  1183. X        if (count) {
  1184. X            beep();
  1185. X            continue;
  1186. X        }
  1187. X                    /* prompt for LD codes */
  1188. X        switch (ans) {
  1189. X            case '+':
  1190. X                if ((ld = ld_prompt(r_win, param->ld_plus, ans)) != NULL) {
  1191. X                    param->ld_plus = str_rep(param->ld_plus, ld);
  1192. X                    param_flag++;
  1193. X                }
  1194. X                break;
  1195. X            case '-':
  1196. X                if ((ld = ld_prompt(r_win, param->ld_minus, ans)) != NULL) {
  1197. X                    param->ld_minus = str_rep(param->ld_minus, ld);
  1198. X                    param_flag++;
  1199. X                }
  1200. X                break;
  1201. X            case '@':
  1202. X                if ((ld = ld_prompt(r_win, param->ld_at, ans)) != NULL) {
  1203. X                    param->ld_at = str_rep(param->ld_at, ld);
  1204. X                    param_flag++;
  1205. X                }
  1206. X                break;
  1207. X            case '#':
  1208. X                if ((ld = ld_prompt(r_win, param->ld_pound, ans)) != NULL) {
  1209. X                    param->ld_pound = str_rep(param->ld_pound, ld);
  1210. X                    param_flag++;
  1211. X                }
  1212. X                break;
  1213. X            default:
  1214. X                beep();
  1215. X                continue;
  1216. X        }
  1217. X        break;
  1218. X    }
  1219. X                    /* if nothing changed */
  1220. X    if (!param_flag && !dir_flag) {
  1221. X        delwin(r_win);
  1222. X        return(0);
  1223. X    }
  1224. X                    /* save to disk? */
  1225. X    clear_line(r_win, 4, 4, TRUE);
  1226. X    if (dir_flag) {
  1227. X        sprintf(buf, "Save entry %d to disk", num);
  1228. X        save = yes_prompt(r_win, 4, 4, A_BOLD, buf);
  1229. X    }
  1230. X    else
  1231. X        save = yes_prompt(r_win, 4, 4, A_BOLD, "Save to disk");
  1232. X
  1233. X                    /* update the files */
  1234. X    if (save && dir_flag) {
  1235. X        if (up_dir(num)) {
  1236. X            touchwin(r_win);
  1237. X            wrefresh(r_win);
  1238. X        }
  1239. X    }
  1240. X    if (save && param_flag) {
  1241. X        if (up_param()) {
  1242. X            touchwin(r_win);
  1243. X            wrefresh(r_win);
  1244. X        }
  1245. X    }
  1246. X    delwin(r_win);
  1247. X    return(1);
  1248. X}
  1249. X
  1250. X/*
  1251. X * Prompt for long distance code changes.  If new string is a space,
  1252. X * change it to null_ptr.  Returns NULL on escape.  Since it uses
  1253. X * get_str(), the return value is a pointer to a static area.
  1254. X */
  1255. X
  1256. static char *
  1257. ld_prompt(win, current_ld, name)
  1258. WINDOW *win;
  1259. char *current_ld, name;
  1260. X{
  1261. X    extern char *null_ptr;
  1262. X    char *ans, *get_str();
  1263. X
  1264. X    werase(win);
  1265. X    mvwprintw(win, 2, 4, "%-20.20s", current_ld);
  1266. X    mvwprintw(win, 4, 4, "New LD code for %c: ", name);
  1267. X    box(win, VERT, HORZ);
  1268. X    wrefresh(win);
  1269. X
  1270. X    if ((ans = get_str(win, 20, "", "\n")) == NULL)
  1271. X        return(NULL);
  1272. X                    /* if space, change to null_ptr */
  1273. X    if (!strcmp(ans, " "))
  1274. X        ans = null_ptr;
  1275. X                    /* display new value */
  1276. X    clear_line(win, 2, 4, TRUE);
  1277. X    wattrstr(win, A_BOLD, ans);
  1278. X
  1279. X    return(ans);
  1280. X}
  1281. END_OF_FILE
  1282. if test 4002 -ne `wc -c <'d_revise.c'`; then
  1283.     echo shar: \"'d_revise.c'\" unpacked with wrong size!
  1284. fi
  1285. # end of 'd_revise.c'
  1286. fi
  1287. if test -f 'e_lib.c' -a "${1}" != "-c" ; then 
  1288.   echo shar: Will not clobber existing file \"'e_lib.c'\"
  1289. else
  1290. echo shar: Extracting \"'e_lib.c'\" \(3907 characters\)
  1291. sed "s/^X//" >'e_lib.c' <<'END_OF_FILE'
  1292. X/*
  1293. X * Routines to manipulate the pcomm.extrnl file
  1294. X */
  1295. X
  1296. X#include <stdio.h>
  1297. X#include "extrnl.h"
  1298. X
  1299. X/*
  1300. X * Read the external file transfer program database.  Returns a pointer
  1301. X * to a static area containing the EXTRNL structure.  This support file is 
  1302. X * optional.
  1303. X */
  1304. X
  1305. struct EXTRNL *
  1306. read_extrnl()
  1307. X{
  1308. X    extern char *null_ptr;
  1309. X    FILE *fp, *uid_fopen();
  1310. X    int i, line, up, entry, oops;
  1311. X    char *str_dup(), buf[200], message[80], token[40], *str_tok(), *str;
  1312. X    char *sep, *temp_token, *findfile();
  1313. X    static struct EXTRNL e;
  1314. X    void error_win();
  1315. X
  1316. X    if ((e.e_path = findfile("pcomm.extrnl")) == NULL) {
  1317. X                    /* not required to exist */
  1318. X        for (i=0; i<3; i++) {
  1319. X            e.name[0][i] = null_ptr;
  1320. X            e.command[0][i] = null_ptr;
  1321. X            e.prompt[0][i] = 'N';
  1322. X            e.name[1][i] = null_ptr;
  1323. X            e.command[1][i] = null_ptr;
  1324. X            e.prompt[1][i] = 'N';
  1325. X        }
  1326. X        e.up_entries = 0;
  1327. X        e.dn_entries = 0;
  1328. X
  1329. X        return(&e);
  1330. X    }
  1331. X
  1332. X    if (!(fp = uid_fopen(e.e_path, "r"))) {
  1333. X        sprintf(buf, "\"%s\" for read", e.e_path);
  1334. X        error_win(1, "Can't open external program file", buf);
  1335. X    }
  1336. X
  1337. X    sep = ";;\n";
  1338. X    line = 0;
  1339. X    up = 1;
  1340. X    oops = 0;
  1341. X    while (fgets(buf, 200, fp) != NULL) {
  1342. X        line++;
  1343. X        if (line <= 3)
  1344. X            entry = line-1;
  1345. X        else {
  1346. X            up = 0;
  1347. X            entry = line-4;
  1348. X        }
  1349. X                    /* get the token */
  1350. X        if (!(temp_token = str_tok(buf, '='))) {
  1351. X            sprintf(message, "is missing a token at line %d", line);
  1352. X            oops++;
  1353. X            break;
  1354. X        }
  1355. X        /*
  1356. X         * Parse the rest of the line.  This is similar to using
  1357. X         * the "real" strtok() function, but this version returns
  1358. X         * a pointer to NULL if the token is missing.  Note the
  1359. X         * use of the array of separators.
  1360. X         */
  1361. X        for (i=0; i<3; i++) {
  1362. X            if (!(str = str_tok((char *) NULL, sep[i]))) {
  1363. X                sprintf(message, "is missing a parameter at line %d", line);
  1364. X                oops++;
  1365. X                break;
  1366. X            }
  1367. X            switch(i) {
  1368. X                case 0:
  1369. X                    e.name[up][entry] = str_dup(str);
  1370. X                    break;
  1371. X                case 1:
  1372. X                    e.command[up][entry] = str_dup(str);
  1373. X                    break;
  1374. X                case 2:
  1375. X                    e.prompt[up][entry] = *str;
  1376. X                    break;
  1377. X            }
  1378. X        }
  1379. X        if (oops)
  1380. X            break;
  1381. X
  1382. X                    /* sanity checking */
  1383. X        if (up)
  1384. X            sprintf(token, "SEND_%d", entry+1);
  1385. X        else
  1386. X            sprintf(token, "RCV_%d", entry+1);
  1387. X
  1388. X        if (strcmp(temp_token, token)) {
  1389. X            sprintf(message, "is corrupted at line %d", line);
  1390. X            oops++;
  1391. X            break;
  1392. X        }
  1393. X    }
  1394. X    fclose(fp);
  1395. X
  1396. X    if (oops) {
  1397. X        sprintf(buf, "External program file \"%s\"", e.e_path);
  1398. X        error_win(1, buf, message);
  1399. X    }
  1400. X                    /* find number of upload entries */
  1401. X    for (i=0; i<3; i++) {
  1402. X        if (e.name[1][i] == null_ptr)
  1403. X            break;
  1404. X    }
  1405. X    e.up_entries = i;
  1406. X                    /* find number of download entries */
  1407. X    for (i=0; i<3; i++) {
  1408. X        if (e.name[0][i] == null_ptr)
  1409. X            break;
  1410. X    }
  1411. X    e.dn_entries = i;
  1412. X                    /* if empty database */
  1413. X    if (!e.up_entries || !e.dn_entries) {
  1414. X        sprintf(buf, "External program file \"%s\"", e.e_path);
  1415. X        error_win(0, buf, "has no data");
  1416. X    }
  1417. X
  1418. X    return(&e);
  1419. X}
  1420. X
  1421. X/*
  1422. X * Update the external file transfer program database.  A non-zero return
  1423. X * code means a non-fatal error.
  1424. X */
  1425. X
  1426. int
  1427. up_extrnl()
  1428. X{
  1429. X    FILE *fp, *uid_fopen();
  1430. X    int i, up, entry;
  1431. X    char buf[200];
  1432. X    void error_win();
  1433. X
  1434. X    /* 
  1435. X     * I don't remember why I made this file optional.  For the next
  1436. X     * release, it will be mandatory!  The following is kludge to tell
  1437. X     * the user that there is no file to save anything to.
  1438. X     */
  1439. X    if (extrnl->e_path == NULL) {
  1440. X        error_win(0, "No \"pcomm.extrnl\" file in use", "");
  1441. X        return(1);
  1442. X    }
  1443. X                    /* open for write */
  1444. X    if (!(fp = uid_fopen(extrnl->e_path, "w"))) {
  1445. X        sprintf(buf, "\"%s\"", extrnl->e_path);
  1446. X        error_win(0, "No write permission on external program file", buf);
  1447. X        return(1);
  1448. X    }
  1449. X                    /* put 'em back */
  1450. X    up = 1;
  1451. X    for (i=0; i<6; i++) {
  1452. X        if (i < 3)
  1453. X            entry = i;
  1454. X        else {
  1455. X            up = 0;
  1456. X            entry = i-3;
  1457. X        }
  1458. X        if (up)
  1459. X            fprintf(fp, "SEND_%d=%s;%s;%c\n", entry+1, extrnl->name[up][entry], extrnl->command[up][entry], extrnl->prompt[up][entry]);
  1460. X        else
  1461. X            fprintf(fp, "RCV_%d=%s;%s;%c\n", entry+1, extrnl->name[up][entry], extrnl->command[up][entry], extrnl->prompt[up][entry]);
  1462. X    }
  1463. X
  1464. X    fclose(fp);
  1465. X    return(0);
  1466. X}
  1467. END_OF_FILE
  1468. if test 3907 -ne `wc -c <'e_lib.c'`; then
  1469.     echo shar: \"'e_lib.c'\" unpacked with wrong size!
  1470. fi
  1471. # end of 'e_lib.c'
  1472. fi
  1473. if test -f 'ls_menu.c' -a "${1}" != "-c" ; then 
  1474.   echo shar: Will not clobber existing file \"'ls_menu.c'\"
  1475. else
  1476. echo shar: Extracting \"'ls_menu.c'\" \(4713 characters\)
  1477. sed "s/^X//" >'ls_menu.c' <<'END_OF_FILE'
  1478. X/*
  1479. X * Routines for displaying current line settings and prompting for changes.
  1480. X */
  1481. X
  1482. X#include <stdio.h>
  1483. X#include <curses.h>
  1484. X#include "dial_dir.h"
  1485. X#include "misc.h"
  1486. X#include "param.h"
  1487. X
  1488. static void disp_settings();
  1489. X
  1490. X/*
  1491. X * Display the current line settings and prompt for changes.  A non-zero
  1492. X * return code means settings were changed.
  1493. X */
  1494. X
  1495. int
  1496. ls_menu()
  1497. X{
  1498. X    extern int fd;
  1499. X    WINDOW *l_win, *newwin();
  1500. X    int num, ret_code;
  1501. X
  1502. X    l_win = newwin(21, 47, 0, 16);
  1503. X
  1504. X    mvwattrstr(l_win, 1, 16, A_BOLD, "Line Settings");
  1505. X    horizontal(l_win, 2, 0, 47);
  1506. X    mvwaddstr(l_win, 6, 5, "1)     300,E,7,1     8)     300,N,8,1");
  1507. X    mvwaddstr(l_win, 7, 5, "2)    1200,E,7,1     9)    1200,N,8,1");
  1508. X    mvwaddstr(l_win, 8, 5, "3)    2400,E,7,1    10)    2400,N,8,1");
  1509. X    mvwaddstr(l_win, 9, 5, "4)    4800,E,7,1    11)    4800,N,8,1");
  1510. X    mvwaddstr(l_win, 10, 5, "5)    9600,E,7,1    12)    9600,N,8,1");
  1511. X    mvwaddstr(l_win, 11, 5, "6)   19200,E,7,1    13)   19200,N,8,1");
  1512. X    mvwaddstr(l_win, 12, 5, "7)   38400,E,7,1    14)   38400,N,8,1");
  1513. X    mvwaddstr(l_win, 14, 4, "Parity        Data Bits       Stop Bits");
  1514. X    mvwaddstr(l_win, 15, 4, "15) Odd       16) 7 bits      18) 1 bit");
  1515. X    mvwaddstr(l_win, 16, 18, "17) 8 bits      19) 2 bits");
  1516. X    mvwaddstr(l_win, 18, 4, "20) Save Changes");
  1517. X    mvwattrstr(l_win, 18, 28, A_BOLD, "YOUR CHOICE:");
  1518. X    wmove(l_win, 18, 41);
  1519. X    box(l_win, VERT, HORZ);
  1520. X
  1521. X    mvwaddstr(l_win, 20, 13, " Press <ESC> to return ");
  1522. X                    /* display current settings */
  1523. X    disp_settings(l_win);
  1524. X    wmove(l_win, 18, 41);
  1525. X    wrefresh(l_win);
  1526. X                    /* get the options */
  1527. X    ret_code = 0;
  1528. X    while ((num = get_num(l_win, 2)) != -1) {
  1529. X        switch (num) {
  1530. X            case 1:
  1531. X                dir->baud[0] = 300;
  1532. X                dir->parity[0] = 'E';
  1533. X                dir->data_bits[0] = 7;
  1534. X                dir->stop_bits[0] = 1;
  1535. X                break;
  1536. X            case 2:
  1537. X                dir->baud[0] = 1200;
  1538. X                dir->parity[0] = 'E';
  1539. X                dir->data_bits[0] = 7;
  1540. X                dir->stop_bits[0] = 1;
  1541. X                break;
  1542. X            case 3:
  1543. X                dir->baud[0] = 2400;
  1544. X                dir->parity[0] = 'E';
  1545. X                dir->data_bits[0] = 7;
  1546. X                dir->stop_bits[0] = 1;
  1547. X                break;
  1548. X            case 4:
  1549. X                dir->baud[0] = 4800;
  1550. X                dir->parity[0] = 'E';
  1551. X                dir->data_bits[0] = 7;
  1552. X                dir->stop_bits[0] = 1;
  1553. X                break;
  1554. X            case 5:
  1555. X                dir->baud[0] = 9600;
  1556. X                dir->parity[0] = 'E';
  1557. X                dir->data_bits[0] = 7;
  1558. X                dir->stop_bits[0] = 1;
  1559. X                break;
  1560. X            case 6:
  1561. X                dir->baud[0] = 19200;
  1562. X                dir->parity[0] = 'E';
  1563. X                dir->data_bits[0] = 7;
  1564. X                dir->stop_bits[0] = 1;
  1565. X                break;
  1566. X            case 7:
  1567. X                dir->baud[0] = 38400;
  1568. X                dir->parity[0] = 'E';
  1569. X                dir->data_bits[0] = 7;
  1570. X                dir->stop_bits[0] = 1;
  1571. X                break;
  1572. X            case 8:
  1573. X                dir->baud[0] = 300;
  1574. X                dir->parity[0] = 'N';
  1575. X                dir->data_bits[0] = 8;
  1576. X                dir->stop_bits[0] = 1;
  1577. X                break;
  1578. X            case 9:
  1579. X                dir->baud[0] = 1200;
  1580. X                dir->parity[0] = 'N';
  1581. X                dir->data_bits[0] = 8;
  1582. X                dir->stop_bits[0] = 1;
  1583. X                break;
  1584. X            case 10:
  1585. X                dir->baud[0] = 2400;
  1586. X                dir->parity[0] = 'N';
  1587. X                dir->data_bits[0] = 8;
  1588. X                dir->stop_bits[0] = 1;
  1589. X                break;
  1590. X            case 11:
  1591. X                dir->baud[0] = 4800;
  1592. X                dir->parity[0] = 'N';
  1593. X                dir->data_bits[0] = 8;
  1594. X                dir->stop_bits[0] = 1;
  1595. X                break;
  1596. X            case 12:
  1597. X                dir->baud[0] = 9600;
  1598. X                dir->parity[0] = 'N';
  1599. X                dir->data_bits[0] = 8;
  1600. X                dir->stop_bits[0] = 1;
  1601. X                break;
  1602. X            case 13:
  1603. X                dir->baud[0] = 19200;
  1604. X                dir->parity[0] = 'N';
  1605. X                dir->data_bits[0] = 8;
  1606. X                dir->stop_bits[0] = 1;
  1607. X                break;
  1608. X            case 14:
  1609. X                dir->baud[0] = 38400;
  1610. X                dir->parity[0] = 'N';
  1611. X                dir->data_bits[0] = 8;
  1612. X                dir->stop_bits[0] = 1;
  1613. X                break;
  1614. X            case 15:
  1615. X                dir->parity[0] = 'O';
  1616. X                break;
  1617. X            case 16:
  1618. X                dir->data_bits[0] = 7;
  1619. X                break;
  1620. X            case 17:
  1621. X                dir->data_bits[0] = 8;
  1622. X                break;
  1623. X            case 18:
  1624. X                dir->stop_bits[0] = 1;
  1625. X                break;
  1626. X            case 19:
  1627. X                dir->stop_bits[0] = 2;
  1628. X                break;
  1629. X            case 20:
  1630. X                    /* copy the current settings */
  1631. X                param->d_baud = dir->baud[0];
  1632. X                param->d_parity = dir->parity[0];
  1633. X                param->d_data_bits = dir->data_bits[0];
  1634. X                param->d_stop_bits = dir->stop_bits[0];
  1635. X                /*
  1636. X                 * We've changed the values in memory even
  1637. X                 * if the update fails.
  1638. X                 */
  1639. X                if (up_param()) {
  1640. X                    touchwin(l_win);
  1641. X                    wrefresh(l_win);
  1642. X                }
  1643. X                break;
  1644. X            default:
  1645. X                beep();
  1646. X        }
  1647. X        ret_code++;
  1648. X        disp_settings(l_win);
  1649. X        mvwaddstr(l_win, 17, 41, "    ");
  1650. X        wmove(l_win, 18, 41);
  1651. X        wrefresh(l_win);
  1652. X    }
  1653. X    if (fd == -1) {
  1654. X        werase(l_win);
  1655. X        wrefresh(l_win);
  1656. X    }
  1657. X    delwin(l_win);
  1658. X    return(ret_code);
  1659. X}
  1660. X
  1661. X/*
  1662. X * Display the current settings.  Formats the entire string at one
  1663. X * time, in case you've got a magic cookie terminal.
  1664. X */
  1665. X
  1666. static void
  1667. disp_settings(win)
  1668. WINDOW *win;
  1669. X{
  1670. X    extern int xmc;
  1671. X    char buf[40];
  1672. X
  1673. X    sprintf(buf, "Current Settings: %5d,%c,%d,%d", dir->baud[0],
  1674. X     dir->parity[0], dir->data_bits[0], dir->stop_bits[0]);
  1675. X
  1676. X    if (xmc > 0) {
  1677. X        touchwin(win);
  1678. X        clear_line(win, 4, 8, TRUE);
  1679. X        wrefresh(win);
  1680. X    }
  1681. X    mvwattrstr(win, 4, 8, A_BOLD, buf);
  1682. X    return;
  1683. X}
  1684. END_OF_FILE
  1685. if test 4713 -ne `wc -c <'ls_menu.c'`; then
  1686.     echo shar: \"'ls_menu.c'\" unpacked with wrong size!
  1687. fi
  1688. # end of 'ls_menu.c'
  1689. fi
  1690. if test -f 'macro.c' -a "${1}" != "-c" ; then 
  1691.   echo shar: Will not clobber existing file \"'macro.c'\"
  1692. else
  1693. echo shar: Extracting \"'macro.c'\" \(5244 characters\)
  1694. sed "s/^X//" >'macro.c' <<'END_OF_FILE'
  1695. X/*
  1696. X * The keyboard macro feature.  Displays (and prompts for editing) the
  1697. X * macros assigned to the shifted number keys.  Prompts for saving
  1698. X * changes to disk.
  1699. X */
  1700. X
  1701. X#include <stdio.h>
  1702. X#include <curses.h>
  1703. X#include "misc.h"
  1704. X#include "param.h"
  1705. X
  1706. static char *mac_prompt();
  1707. X
  1708. void
  1709. macro()
  1710. X{
  1711. X    extern int fd;
  1712. X    WINDOW *ma_win, *newwin();
  1713. X    int ans, changed;
  1714. X    char *mac, *str_rep();
  1715. X
  1716. X    ma_win = newwin(18, 65, 2, 15);
  1717. X    mvwattrstr(ma_win, 1, 25, A_BOLD, "Keyboard Macros");
  1718. X    horizontal(ma_win, 2, 0, 65);
  1719. X    mvwprintw(ma_win, 4, 0, " %4.4s-!  %-50.50s\n", param->ascii_hot, param->mac_1);
  1720. X    wprintw(ma_win, " %4.4s-@  %-50.50s\n", param->ascii_hot, param->mac_2);
  1721. X    wprintw(ma_win, " %4.4s-#  %-50.50s\n", param->ascii_hot, param->mac_3);
  1722. X    wprintw(ma_win, " %4.4s-$  %-50.50s\n", param->ascii_hot, param->mac_4);
  1723. X    wprintw(ma_win, " %4.4s-%%  %-50.50s\n", param->ascii_hot, param->mac_5);
  1724. X    wprintw(ma_win, " %4.4s-^  %-50.50s\n", param->ascii_hot, param->mac_6);
  1725. X    wprintw(ma_win, " %4.4s-&  %-50.50s\n", param->ascii_hot, param->mac_7);
  1726. X    wprintw(ma_win, " %4.4s-*  %-50.50s\n", param->ascii_hot, param->mac_8);
  1727. X    wprintw(ma_win, " %4.4s-(  %-50.50s\n", param->ascii_hot, param->mac_9);
  1728. X    wprintw(ma_win, " %4.4s-)  %-50.50s\n", param->ascii_hot, param->mac_0);
  1729. X    mvwaddstr(ma_win, 15, 5, "Macro key to revise:");
  1730. X    box(ma_win, VERT, HORZ);
  1731. X                    /* on the bottom line */
  1732. X    mvwaddstr(ma_win, 17, 21, " Press <ESC> to continue ");
  1733. X    wmove(ma_win, 15, 26);
  1734. X    wrefresh(ma_win);
  1735. X
  1736. X    changed = 0;
  1737. X
  1738. X    while ((ans = wgetch(ma_win)) != ESC) {
  1739. X        switch (ans) {
  1740. X            case '!':    /* shifted 1 */
  1741. X                if ((mac = mac_prompt(ans, param->mac_1)) != NULL) {
  1742. X                    param->mac_1 = str_rep(param->mac_1, mac);
  1743. X                    clear_line(ma_win, 4, 9, TRUE);
  1744. X                    mvwattrstr(ma_win, 4, 9, A_BOLD, mac);
  1745. X                    changed++;
  1746. X                }
  1747. X                break;
  1748. X            case '@':    /* shifted 2 */
  1749. X                if ((mac = mac_prompt(ans, param->mac_2)) != NULL) {
  1750. X                    param->mac_2 = str_rep(param->mac_2, mac);
  1751. X                    clear_line(ma_win, 5, 9, TRUE);
  1752. X                    mvwattrstr(ma_win, 5, 9, A_BOLD, mac);
  1753. X                    changed++;
  1754. X                }
  1755. X                break;
  1756. X            case '#':    /* shifted 3 */
  1757. X                if ((mac = mac_prompt(ans, param->mac_3)) != NULL) {
  1758. X                    param->mac_3 = str_rep(param->mac_3, mac);
  1759. X                    clear_line(ma_win, 6, 9, TRUE);
  1760. X                    mvwattrstr(ma_win, 6, 9, A_BOLD, mac);
  1761. X                    changed++;
  1762. X                }
  1763. X                break;
  1764. X            case '$':    /* shifted 4 */
  1765. X                if ((mac = mac_prompt(ans, param->mac_4)) != NULL) {
  1766. X                    param->mac_4 = str_rep(param->mac_4, mac);
  1767. X                    clear_line(ma_win, 7, 9, TRUE);
  1768. X                    mvwattrstr(ma_win, 7, 9, A_BOLD, mac);
  1769. X                    changed++;
  1770. X                }
  1771. X                break;
  1772. X            case '%':    /* shifted 5 */
  1773. X                if ((mac = mac_prompt(ans, param->mac_5)) != NULL) {
  1774. X                    param->mac_5 = str_rep(param->mac_5, mac);
  1775. X                    clear_line(ma_win, 8, 9, TRUE);
  1776. X                    mvwattrstr(ma_win, 8, 9, A_BOLD, mac);
  1777. X                    changed++;
  1778. X                }
  1779. X                break;
  1780. X            case '^':    /* shifted 6 */
  1781. X                if ((mac = mac_prompt(ans, param->mac_6)) != NULL) {
  1782. X                    param->mac_6 = str_rep(param->mac_6, mac);
  1783. X                    clear_line(ma_win, 9, 9, TRUE);
  1784. X                    mvwattrstr(ma_win, 9, 9, A_BOLD, mac);
  1785. X                    changed++;
  1786. X                }
  1787. X                break;
  1788. X            case '&':    /* shifted 7 */
  1789. X                if ((mac = mac_prompt(ans, param->mac_7)) != NULL) {
  1790. X                    param->mac_7 = str_rep(param->mac_7, mac);
  1791. X                    clear_line(ma_win, 10, 9, TRUE);
  1792. X                    mvwattrstr(ma_win, 10, 9, A_BOLD, mac);
  1793. X                    changed++;
  1794. X                }
  1795. X                break;
  1796. X            case '*':    /* shifted 8 */
  1797. X                if ((mac = mac_prompt(ans, param->mac_8)) != NULL) {
  1798. X                    param->mac_8 = str_rep(param->mac_8, mac);
  1799. X                    clear_line(ma_win, 11, 9, TRUE);
  1800. X                    mvwattrstr(ma_win, 11, 9, A_BOLD, mac);
  1801. X                    changed++;
  1802. X                }
  1803. X                break;
  1804. X            case '(':    /* shifted 9 */
  1805. X                if ((mac = mac_prompt(ans, param->mac_9)) != NULL) {
  1806. X                    param->mac_9 = str_rep(param->mac_9, mac);
  1807. X                    clear_line(ma_win, 12, 9, TRUE);
  1808. X                    mvwattrstr(ma_win, 12, 9, A_BOLD, mac);
  1809. X                    changed++;
  1810. X                }
  1811. X                break;
  1812. X            case ')':    /* shifted 0 */
  1813. X                if ((mac = mac_prompt(ans, param->mac_0)) != NULL) {
  1814. X                    param->mac_0 = str_rep(param->mac_0, mac);
  1815. X                    clear_line(ma_win, 13, 9, TRUE);
  1816. X                    mvwattrstr(ma_win, 13, 9, A_BOLD, mac);
  1817. X                    changed++;
  1818. X                }
  1819. X                break;
  1820. X            default:
  1821. X                beep();
  1822. X                break;
  1823. X        }
  1824. X        touchwin(ma_win);
  1825. X        wmove(ma_win, 15, 26);
  1826. X        wrefresh(ma_win);
  1827. X    }
  1828. X                    /* if something changed */
  1829. X    if (changed) {
  1830. X                    /* save to disk? */
  1831. X        if (yes_prompt(ma_win, 15, 30, A_BOLD, "Save to disk")) {
  1832. X            if (up_param()) {
  1833. X                touchwin(ma_win);
  1834. X                wrefresh(ma_win);
  1835. X            }
  1836. X        }
  1837. X    }
  1838. X    if (fd == -1) {
  1839. X        werase(ma_win);
  1840. X        wrefresh(ma_win);
  1841. X    }
  1842. X    delwin(ma_win);
  1843. X    return;
  1844. X}
  1845. X
  1846. X/*
  1847. X * Sounds like McDonalds doesn't it?  Actually, it opens a new window
  1848. X * and prompts for the new macro.  Returns a pointer to the new string.
  1849. X * Since it uses get_str(), the return value points to a static area.
  1850. X */
  1851. X
  1852. static char *
  1853. mac_prompt(key, string)
  1854. char key, *string;
  1855. X{
  1856. X    extern char *null_ptr;
  1857. X    WINDOW *mp_win, *newwin();
  1858. X    char *new, *get_str();
  1859. X
  1860. X    mp_win = newwin(6, 65, 8, 0);
  1861. X    mvwprintw(mp_win, 2, 3, "%4.4s-%c  %-50.50s", param->ascii_hot, key, string);
  1862. X    mvwaddstr(mp_win, 3, 5, "New : ");
  1863. X    box(mp_win, VERT, HORZ);
  1864. X    wrefresh(mp_win);
  1865. X
  1866. X    if ((new = get_str(mp_win, 50, "", "\n")) != NULL) {
  1867. X                    /* if CR, return NULL */
  1868. X        if (*new == '\0')
  1869. X            new = NULL;
  1870. X                    /* if space, change to null_ptr */
  1871. X        else if (!strcmp(new, " "))
  1872. X            new = null_ptr;
  1873. X    }
  1874. X
  1875. X    werase(mp_win);
  1876. X    wrefresh(mp_win);
  1877. X    delwin(mp_win);
  1878. X    return(new);
  1879. X}
  1880. END_OF_FILE
  1881. if test 5244 -ne `wc -c <'macro.c'`; then
  1882.     echo shar: \"'macro.c'\" unpacked with wrong size!
  1883. fi
  1884. # end of 'macro.c'
  1885. fi
  1886. if test -f 's_axfer.c' -a "${1}" != "-c" ; then 
  1887.   echo shar: Will not clobber existing file \"'s_axfer.c'\"
  1888. else
  1889. echo shar: Extracting \"'s_axfer.c'\" \(3830 characters\)
  1890. sed "s/^X//" >'s_axfer.c' <<'END_OF_FILE'
  1891. X/*
  1892. X * Display the ASCII transfer setup, query for changes.  A non-zero return
  1893. X * code means something was changed.
  1894. X */
  1895. X
  1896. X#include <stdio.h>
  1897. X#include <curses.h>
  1898. X#include "misc.h"
  1899. X#include "param.h"
  1900. X
  1901. int
  1902. axfer_setup()
  1903. X{
  1904. X    extern char *v_yes[];
  1905. X    WINDOW *x_win, *newwin();
  1906. X    int i, ret_code, num;
  1907. X    char *ans, *menu_prompt(), *str_rep();
  1908. X    static char *v_cr[4] = {"NONE", "STRIP", "ADD LF", NULL};
  1909. X    static char *v_lf[4] = {"NONE", "STRIP", "ADD CR", NULL};
  1910. X    static char *v_delay[4] = {"0", "100", "150", NULL};
  1911. X
  1912. X    x_win = newwin(23, 80, 0, 0);
  1913. X
  1914. X    horizontal(x_win, 0, 0, 28);
  1915. X    mvwattrstr(x_win, 0, 29, A_BOLD, "ASCII Transfer Setup");
  1916. X    horizontal(x_win, 0, 50, 29);
  1917. X    mvwaddstr(x_win, 3, 33, "ASCII UPLOAD");
  1918. X    mvwprintw(x_win, 5, 22, "1) Echo locally ........... %s", param->local_echo);
  1919. X    mvwprintw(x_win, 6, 22, "2) Expand blank lines ..... %s", param->expand);
  1920. X    mvwprintw(x_win, 7, 22, "3) CR delay (ms) .......... %d", param->cr_delay);
  1921. X    mvwprintw(x_win, 8, 22, "4) Pace the output ........ %s", param->pace);
  1922. X    mvwprintw(x_win, 9, 22, "5) CR translation ......... %s", param->cr_up);
  1923. X    mvwprintw(x_win, 10, 22, "6) LF translation ......... %s", param->lf_up);
  1924. X    mvwaddstr(x_win, 12, 32, "ASCII DOWNLOAD");
  1925. X    mvwprintw(x_win, 14, 22, "7) Transfer timeout (sec) . %d", param->timer);
  1926. X    mvwprintw(x_win, 15, 22, "8) CR translation ......... %s", param->cr_dn);
  1927. X    mvwprintw(x_win, 16, 22, "9) LF translation ......... %s", param->lf_dn);
  1928. X    horizontal(x_win, 19, 0, 80);
  1929. X    mvwattrstr(x_win, 20, 0, A_BOLD, "OPTION ==> ");
  1930. X    mvwaddstr(x_win, 20, 58, "Press <ESC> to return");
  1931. X    wmove(x_win, 20, 12);
  1932. X    touchwin(x_win);
  1933. X    wrefresh(x_win);
  1934. X                    /* get the option number */
  1935. X    ret_code = 0;
  1936. X    while ((i = get_num(x_win, 1)) != -1) {
  1937. X        switch (i) {
  1938. X            case 1:
  1939. X                if ((ans = menu_prompt(x_win, 5, 50, "Echo locally", v_yes)) != NULL) {
  1940. X                    param->local_echo = str_rep(param->local_echo, ans);
  1941. X                    ret_code++;
  1942. X                }
  1943. X                break;
  1944. X            case 2:
  1945. X                if ((ans = menu_prompt(x_win, 6, 50, "Expand blank lines", v_yes)) != NULL) {
  1946. X                    param->expand = str_rep(param->expand, ans);
  1947. X                    ret_code++;
  1948. X                }
  1949. X                break;
  1950. X            case 3:
  1951. X                if ((ans = menu_prompt(x_win, 7, 50, "CR delay (ms)", v_delay)) != NULL) {
  1952. X                    param->cr_delay = atoi(ans);
  1953. X                    ret_code++;
  1954. X                }
  1955. X                break;
  1956. X            case 4:
  1957. X                if ((ans = menu_prompt(x_win, 8, 50, "Pace the output", v_yes)) != NULL) {
  1958. X                    param->pace = str_rep(param->pace, ans);
  1959. X                    ret_code++;
  1960. X                }
  1961. X                break;
  1962. X            case 5:
  1963. X                if ((ans = menu_prompt(x_win, 9, 50, "CR translation (upload)", v_cr)) != NULL) {
  1964. X                    param->cr_up = str_rep(param->cr_up, ans);
  1965. X                    ret_code++;
  1966. X                }
  1967. X                break;
  1968. X            case 6:
  1969. X                if ((ans = menu_prompt(x_win, 10, 50, "LF translation (upload)", v_lf)) != NULL) {
  1970. X                    param->lf_up = str_rep(param->lf_up, ans);
  1971. X                    ret_code++;
  1972. X                }
  1973. X                break;
  1974. X            case 7:
  1975. X                if ((num = num_prompt(x_win, 14, 50, "Transfer timeout", "(in seconds)")) != -1) {
  1976. X                    if (num > MAX_TIMER || num < MIN_TIMER) {
  1977. X                        beep();
  1978. X                    /* some reasonable range of values */
  1979. X                        if (num < MIN_TIMER)
  1980. X                            num = MIN_TIMER;
  1981. X                        else
  1982. X                            num = MAX_TIMER;
  1983. X                        mvwaddstr(x_win, 14, 50, "   ");
  1984. X                        wrefresh(x_win);
  1985. X                        mvwattrnum(x_win, 14, 50, A_BOLD, num);
  1986. X                        wrefresh(x_win);
  1987. X                    }
  1988. X                    param->timer = num;
  1989. X                    ret_code++;
  1990. X                }
  1991. X                break;
  1992. X            case 8:
  1993. X                if ((ans = menu_prompt(x_win, 15, 50, "CR translation (download)", v_cr)) != NULL) {
  1994. X                    param->cr_dn = str_rep(param->cr_dn, ans);
  1995. X                    ret_code++;
  1996. X                }
  1997. X                break;
  1998. X            case 9:
  1999. X                if ((ans = menu_prompt(x_win, 16, 50, "LF translation (download)", v_lf)) != NULL) {
  2000. X                    param->lf_dn = str_rep(param->lf_dn, ans);
  2001. X                    ret_code++;
  2002. X                }
  2003. X                break;
  2004. X            default:
  2005. X                beep();
  2006. X        }
  2007. X        mvwaddch(x_win, 20, 12, (chtype) ' ');
  2008. X        clear_line(x_win, 21, 0, FALSE);
  2009. X        clear_line(x_win, 22, 0, FALSE);
  2010. X        wmove(x_win, 20, 12);
  2011. X        wrefresh(x_win);
  2012. X    }
  2013. X    delwin(x_win);
  2014. X    return(ret_code);
  2015. X}
  2016. END_OF_FILE
  2017. if test 3830 -ne `wc -c <'s_axfer.c'`; then
  2018.     echo shar: \"'s_axfer.c'\" unpacked with wrong size!
  2019. fi
  2020. # end of 's_axfer.c'
  2021. fi
  2022. if test -f 's_extrnl.c' -a "${1}" != "-c" ; then 
  2023.   echo shar: Will not clobber existing file \"'s_extrnl.c'\"
  2024. else
  2025. echo shar: Extracting \"'s_extrnl.c'\" \(4098 characters\)
  2026. sed "s/^X//" >'s_extrnl.c' <<'END_OF_FILE'
  2027. X/*
  2028. X * Display the external protocol setup, query for changes.  A non-zero
  2029. X * return code means something was changed.
  2030. X */
  2031. X
  2032. X#include <stdio.h>
  2033. X#include <curses.h>
  2034. X#include "extrnl.h"
  2035. X#include "misc.h"
  2036. X
  2037. static int ext_prompt();
  2038. static void disp_ext();
  2039. X
  2040. int
  2041. ext_setup()
  2042. X{
  2043. X    extern char *null_ptr;
  2044. X    WINDOW *ext_win, *newwin();
  2045. X    int i, ret_code;
  2046. X    char *str, *get_str();
  2047. X
  2048. X    ext_win = newwin(23, 80, 0, 0);
  2049. X
  2050. X    horizontal(ext_win, 0, 0, 27);
  2051. X    mvwattrstr(ext_win, 0, 28, A_BOLD, "External Protocol Setup");
  2052. X    horizontal(ext_win, 0, 52, 27);
  2053. X    mvwaddstr(ext_win, 3, 36, "UPLOAD");
  2054. X    mvwaddstr(ext_win, 5, 8, "Name");
  2055. X    mvwaddstr(ext_win, 5, 21, "Command line");
  2056. X    mvwaddstr(ext_win, 5, 54, "Requires file list?");
  2057. X    mvwaddstr(ext_win, 10, 35, "DOWNLOAD");
  2058. X    mvwaddstr(ext_win, 12, 8, "Name");
  2059. X    mvwaddstr(ext_win, 12, 21, "Command line");
  2060. X    mvwaddstr(ext_win, 12, 54, "Requires file list?");
  2061. X                    /* display the current list */
  2062. X    disp_ext(ext_win);
  2063. X
  2064. X    horizontal(ext_win, 19, 0, 80);
  2065. X    mvwattrstr(ext_win, 20, 0, A_BOLD, "OPTION ==> ");
  2066. X    mvwaddstr(ext_win, 20, 58, "Press <ESC> to return");
  2067. X    wmove(ext_win, 20, 12);
  2068. X    touchwin(ext_win);
  2069. X    wrefresh(ext_win);
  2070. X                    /* get the option */
  2071. X    ret_code = 0;
  2072. X    while ((str = get_str(ext_win, 1, "1234356", "")) != NULL) {
  2073. X        switch(*str) {
  2074. X            case '1':
  2075. X                if (ext_prompt(ext_win, 1, 0, 6))
  2076. X                    ret_code++;
  2077. X                break;
  2078. X            case '2':
  2079. X                if (ext_prompt(ext_win, 1, 1, 7))
  2080. X                    ret_code++;
  2081. X                break;
  2082. X            case '3':
  2083. X                if (ext_prompt(ext_win, 1, 2, 8))
  2084. X                    ret_code++;
  2085. X                break;
  2086. X            case '4':
  2087. X                if (ext_prompt(ext_win, 0, 0, 13))
  2088. X                    ret_code++;
  2089. X                break;
  2090. X            case '5':
  2091. X                if (ext_prompt(ext_win, 0, 1, 14))
  2092. X                    ret_code++;
  2093. X                break;
  2094. X            case '6':
  2095. X                if (ext_prompt(ext_win, 0, 2, 15))
  2096. X                    ret_code++;
  2097. X                break;
  2098. X        }
  2099. X        mvwaddstr(ext_win, 20, 12, "  ");
  2100. X        clear_line(ext_win, 21, 0, FALSE);
  2101. X        clear_line(ext_win, 22, 0, FALSE);
  2102. X        wmove(ext_win, 20, 12);
  2103. X        wrefresh(ext_win);
  2104. X    }
  2105. X    /*
  2106. X     * Recalculate the number of entries.  Please notice that if you
  2107. X     * create an empty entry (a hole), all entries after that are ignored.  
  2108. X     * The software doesn't compact the holes out.. you're on your own.
  2109. X     */
  2110. X    if (ret_code) {
  2111. X        for (i=0; i<3; i++) {
  2112. X            if (extrnl->name[1][i] == null_ptr)
  2113. X                break;
  2114. X        }
  2115. X        extrnl->up_entries = i;
  2116. X
  2117. X        for (i=0; i<3; i++) {
  2118. X            if (extrnl->name[0][i] == null_ptr)
  2119. X                break;
  2120. X        }
  2121. X        extrnl->dn_entries = i;
  2122. X    }
  2123. X    delwin(ext_win);
  2124. X    return(ret_code);
  2125. X}
  2126. X
  2127. X/*
  2128. X * Display the current list of external file transfer programs.
  2129. X */
  2130. X
  2131. static void
  2132. disp_ext(win)
  2133. WINDOW *win;
  2134. X{
  2135. X    int i, up, entry, line;
  2136. X
  2137. X    up = 1;
  2138. X    line = 6;
  2139. X    for (i=0; i<6; i++) {
  2140. X        if (i < 3)
  2141. X            entry = i;
  2142. X        else {
  2143. X            up = 0;
  2144. X            entry = i-3;
  2145. X            line = 10;
  2146. X        }
  2147. X        mvwprintw(win, i+line, 5, "%d) %-12.12s %-40.40s  %c\n",
  2148. X         i+1, extrnl->name[up][entry], extrnl->command[up][entry],
  2149. X         extrnl->prompt[up][entry]);
  2150. X    }
  2151. X    return;
  2152. X}
  2153. X
  2154. X/*
  2155. X * Prompt for the info in the database.  A non-zero return code means
  2156. X * that something was changed.  To delete the line, you enter a single
  2157. X * space character at the first prompt.
  2158. X */
  2159. X
  2160. static int
  2161. ext_prompt(win, up, entry, line)
  2162. WINDOW *win;
  2163. int up, entry, line;
  2164. X{
  2165. X    extern char *v_yn[], *null_ptr;
  2166. X    char *ans, t_name[80], t_command[80], *str_prompt(), *str_rep();
  2167. X    char *strcpy(), *menu_prompt();
  2168. X
  2169. X                    /* get temp name */
  2170. X    if ((ans = str_prompt(win, line, 8, "Protocol name", "")) == NULL)
  2171. X        return(0);
  2172. X
  2173. X    strcpy(t_name, ans);
  2174. X    clear_line(win, 21, 0, FALSE);
  2175. X                    /* are we zapping the line */
  2176. X    if (ans == null_ptr) {
  2177. X        extrnl->name[up][entry] = null_ptr;
  2178. X        extrnl->command[up][entry] = null_ptr;
  2179. X        extrnl->prompt[up][entry] = 'N';
  2180. X        return(1);
  2181. X    }
  2182. X                    /* get temp command */
  2183. X    if ((ans = str_prompt(win, line, 21, "Command line", "")) == NULL)
  2184. X        return(0);
  2185. X
  2186. X    strcpy(t_command, ans);
  2187. X    clear_line(win, 21, 0, FALSE);
  2188. X
  2189. X                    /* get temp prompt */
  2190. X    if ((ans = menu_prompt(win, line, 63, "Does it require a file list", v_yn)) == NULL)
  2191. X        return(0);
  2192. X
  2193. X    wrefresh(win);
  2194. X                    /* store 'em for real */
  2195. X    extrnl->name[up][entry] = str_rep(extrnl->name[up][entry], t_name);
  2196. X    extrnl->command[up][entry] = str_rep(extrnl->command[up][entry], t_command);
  2197. X    extrnl->prompt[up][entry] = *ans;
  2198. X
  2199. X    return(1);
  2200. X}
  2201. END_OF_FILE
  2202. if test 4098 -ne `wc -c <'s_extrnl.c'`; then
  2203.     echo shar: \"'s_extrnl.c'\" unpacked with wrong size!
  2204. fi
  2205. # end of 's_extrnl.c'
  2206. fi
  2207. if test -f 's_gen.c' -a "${1}" != "-c" ; then 
  2208.   echo shar: Will not clobber existing file \"'s_gen.c'\"
  2209. else
  2210. echo shar: Extracting \"'s_gen.c'\" \(4393 characters\)
  2211. sed "s/^X//" >'s_gen.c' <<'END_OF_FILE'
  2212. X/*
  2213. X * Display the general setup, query for changes.  A non-zero return code
  2214. X * means something was changed.
  2215. X */
  2216. X
  2217. X#include <stdio.h>
  2218. X#include <curses.h>
  2219. X#include "misc.h"
  2220. X#include "param.h"
  2221. X
  2222. int
  2223. gen_setup()
  2224. X{
  2225. X    extern char *v_yes[];
  2226. X    WINDOW *g_win, *newwin();
  2227. X    int i, num, ret_code;
  2228. X    char c, *ans, *str_prompt(), *menu_prompt(), chr_prompt();
  2229. X    char *str_rep();
  2230. X    void line_set();
  2231. X    static char *v_abort[3] = {"KEEP", "DELETE", NULL};
  2232. X
  2233. X    g_win = newwin(23, 80, 0, 0);
  2234. X
  2235. X    horizontal(g_win, 0, 0, 32);
  2236. X    mvwattrstr(g_win, 0, 33, A_BOLD, "General Setup");
  2237. X    horizontal(g_win, 0, 47, 32);
  2238. X    mvwprintw(g_win, 3, 22, "1) Default log file ....... %s", param->logfile);
  2239. X    mvwprintw(g_win, 4, 22, "2) Screen dump file ....... %s", param->dumpfile);
  2240. X    mvwprintw(g_win, 6, 22, "3) Strip high bit  ........ %s", param->strip);
  2241. X    mvwprintw(g_win, 8, 22, "4) Pause character ........ %c", param->pause_char);
  2242. X    mvwprintw(g_win, 9, 22, "5) CR character ........... %c", param->cr_char);
  2243. X    mvwprintw(g_win, 10, 22, "6) CTRL character ......... %c", param->ctrl_char);
  2244. X    mvwprintw(g_win, 11, 22, "7) ESC character .......... %c", param->esc_char);
  2245. X    mvwprintw(g_win, 12, 22, "8) Break character ........ %c", param->brk_char);
  2246. X    mvwprintw(g_win, 14, 22, "9) Aborted downloads ...... %s", param->abort);
  2247. X    mvwprintw(g_win, 16, 21, "10) Connect delay (sec) .... %d", param->c_delay);
  2248. X    mvwprintw(g_win, 17, 21, "11) Redial delay (sec) ..... %d", param->r_delay);
  2249. X    horizontal(g_win, 19, 0, 80);
  2250. X    mvwattrstr(g_win, 20, 0, A_BOLD, "OPTION ==> ");
  2251. X    mvwaddstr(g_win, 20, 58, "Press <ESC> to return");
  2252. X    wmove(g_win, 20, 12);
  2253. X    touchwin(g_win);
  2254. X    wrefresh(g_win);
  2255. X                    /* get the option number */
  2256. X    ret_code = 0;
  2257. X    while ((i = get_num(g_win, 2)) != -1) {
  2258. X        switch (i) {
  2259. X            case 1:
  2260. X                if ((ans = str_prompt(g_win, 3, 50, "Default log file", "")) != NULL) {
  2261. X                    param->logfile = str_rep(param->logfile, ans);
  2262. X                    ret_code++;
  2263. X                }
  2264. X                break;
  2265. X            case 2:
  2266. X                if ((ans = str_prompt(g_win, 4, 50, "Default screen dump file", "")) != NULL) {
  2267. X                    param->dumpfile = str_rep(param->dumpfile, ans);
  2268. X                    ret_code++;
  2269. X                }
  2270. X                break;
  2271. X            case 3:
  2272. X                if ((ans = menu_prompt(g_win, 6, 50, "Strip high bit?", v_yes)) != NULL) {
  2273. X                    param->strip = str_rep(param->strip, ans);
  2274. X                    line_set();
  2275. X                    ret_code++;
  2276. X                }
  2277. X                break;
  2278. X            case 4:
  2279. X                if ((c = chr_prompt(g_win, 8, 50, "Pause character", "1 second")) != '\0') {
  2280. X                    param->pause_char = c;
  2281. X                    ret_code++;
  2282. X                }
  2283. X                break;
  2284. X            case 5:
  2285. X                if ((c = chr_prompt(g_win, 9, 50, "CR character", "(carriage return)")) != '\0') {
  2286. X                    param->cr_char = c;
  2287. X                    ret_code++;
  2288. X                }
  2289. X                break;
  2290. X            case 6:
  2291. X                if ((c = chr_prompt(g_win, 10, 50, "CTRL character", "(control)")) != '\0') {
  2292. X                    param->ctrl_char = c;
  2293. X                    ret_code++;
  2294. X                }
  2295. X                break;
  2296. X            case 7:
  2297. X                if ((c = chr_prompt(g_win, 11, 50, "ESC character", "(escape)")) != '\0') {
  2298. X                    param->esc_char = c;
  2299. X                    ret_code++;
  2300. X                }
  2301. X                break;
  2302. X            case 8:
  2303. X                if ((c = chr_prompt(g_win, 12, 50, "Break character", "")) != '\0') {
  2304. X                    param->brk_char = c;
  2305. X                    ret_code++;
  2306. X                }
  2307. X                break;
  2308. X            case 9:
  2309. X                if ((ans = menu_prompt(g_win, 14, 50, "Aborted downloads", v_abort)) != NULL) {
  2310. X                    param->abort = str_rep(param->abort, ans);
  2311. X                    ret_code++;
  2312. X                }
  2313. X                break;
  2314. X            case 10:
  2315. X                if ((num = num_prompt(g_win, 16, 50, "Connect delay time", "(in seconds)")) != -1) {
  2316. X                    if (num > MAX_CDELAY || num < MIN_CDELAY) {
  2317. X                        beep();
  2318. X                    /* some reasonable range of values */
  2319. X                        if (num < MIN_CDELAY)
  2320. X                            num = MIN_CDELAY;
  2321. X                        else
  2322. X                            num = MAX_CDELAY;
  2323. X                        mvwaddstr(g_win, 16, 50, "   ");
  2324. X                        wrefresh(g_win);
  2325. X                        mvwattrnum(g_win, 16, 50, A_BOLD, num);
  2326. X                        wrefresh(g_win);
  2327. X                    }
  2328. X                    param->c_delay = num;
  2329. X                    ret_code++;
  2330. X                }
  2331. X                break;
  2332. X            case 11:
  2333. X                if ((num = num_prompt(g_win, 17, 50, "Redial delay time", "(in seconds)")) != -1) {
  2334. X                    if (num > MAX_PAUSE || num < MIN_PAUSE) {
  2335. X                        beep();
  2336. X                    /* some reasonable range */
  2337. X                        if (num < MIN_PAUSE)
  2338. X                            num = MIN_PAUSE;
  2339. X                        else
  2340. X                            num = MAX_PAUSE;
  2341. X                        mvwaddstr(g_win, 17, 50, "    ");
  2342. X                        wrefresh(g_win);
  2343. X                        mvwattrnum(g_win, 17, 50, A_BOLD, num);
  2344. X                        wrefresh(g_win);
  2345. X                    }
  2346. X                    param->r_delay = num;
  2347. X                    ret_code++;
  2348. X                }
  2349. X                break;
  2350. X            default:
  2351. X                beep();
  2352. X        }
  2353. X        mvwaddstr(g_win, 20, 12, "  ");
  2354. X        clear_line(g_win, 21, 0, FALSE);
  2355. X        clear_line(g_win, 22, 0, FALSE);
  2356. X        wmove(g_win, 20, 12);
  2357. X        wrefresh(g_win);
  2358. X    }
  2359. X    delwin(g_win);
  2360. X    return(ret_code);
  2361. X}
  2362. END_OF_FILE
  2363. if test 4393 -ne `wc -c <'s_gen.c'`; then
  2364.     echo shar: \"'s_gen.c'\" unpacked with wrong size!
  2365. fi
  2366. # end of 's_gen.c'
  2367. fi
  2368. if test -f 's_menu.c' -a "${1}" != "-c" ; then 
  2369.   echo shar: Will not clobber existing file \"'s_menu.c'\"
  2370. else
  2371. echo shar: Extracting \"'s_menu.c'\" \(2972 characters\)
  2372. sed "s/^X//" >'s_menu.c' <<'END_OF_FILE'
  2373. X/*
  2374. X * Display the setup menu, prompts for a bunch of other menus. 
  2375. X */
  2376. X
  2377. X#include <stdio.h>
  2378. X#include <curses.h>
  2379. X#include "misc.h"
  2380. X
  2381. static void top_line();
  2382. X
  2383. void
  2384. setup_menu()
  2385. X{
  2386. X    extern int fd, xmc;
  2387. X    WINDOW *s_win, *newwin();
  2388. X    char *ans, *get_str();
  2389. X    static int param_flag = 0, modem_flag = 0, ext_flag = 0;
  2390. X
  2391. X    s_win = newwin(LINES-1, COLS, 0, 0);
  2392. X
  2393. X    top_line(s_win);
  2394. X    mvwaddstr(s_win, 3, 29, "1) TTY Setup");
  2395. X    mvwaddstr(s_win, 5, 29, "2) Modem Setup");
  2396. X    mvwaddstr(s_win, 7, 29, "3) Terminal Setup");
  2397. X    mvwaddstr(s_win, 9, 29, "4) General Setup");
  2398. X    mvwaddstr(s_win, 11, 29, "5) ASCII Transfer Setup");
  2399. X    mvwaddstr(s_win, 13, 29, "6) External Protocol Setup");
  2400. X    mvwaddstr(s_win, 15, 29, "S) Save setup to disk");
  2401. X    horizontal(s_win, 19, 0, 80);
  2402. X    mvwattrstr(s_win, 20, 0, A_BOLD, "OPTION ==> ");
  2403. X    mvwaddstr(s_win, 20, 58, "  Press <ESC> to exit");
  2404. X    wmove(s_win, 20, 12);
  2405. X    touchwin(s_win);
  2406. X    wrefresh(s_win);
  2407. X
  2408. X                    /* get the options */
  2409. X    while ((ans = get_str(s_win, 1, "123456Ss", "")) != NULL) {
  2410. X        if (xmc > 0) {
  2411. X            clear_line(s_win, 0, 0, FALSE);
  2412. X            wrefresh(s_win);
  2413. X        }
  2414. X        switch (*ans) {
  2415. X            case '1':
  2416. X                if (tty_setup())
  2417. X                    modem_flag++;
  2418. X                break;
  2419. X            case '2':
  2420. X                if (modem_setup())
  2421. X                    modem_flag++;
  2422. X                break;
  2423. X            case '3':
  2424. X                if (term_setup())
  2425. X                    param_flag++;
  2426. X                break;
  2427. X            case '4':
  2428. X                if (gen_setup())
  2429. X                    param_flag++;
  2430. X                break;
  2431. X            case '5':
  2432. X                if (axfer_setup())
  2433. X                    param_flag++;
  2434. X                break;
  2435. X            case '6':
  2436. X                if (ext_setup())
  2437. X                    ext_flag++;
  2438. X                break;
  2439. X            case 's':
  2440. X            case 'S':
  2441. X                if (xmc > 0)
  2442. X                    top_line(s_win);
  2443. X                /*
  2444. X                 * Writes to disk are not critical, since
  2445. X                 * the changes are made in memory.
  2446. X                 */
  2447. X                if (param_flag) {
  2448. X                    mvwattrstr(s_win, 22, 27, A_BLINK, "Updating Parameter File");
  2449. X                    wrefresh(s_win);
  2450. X                    wait_key(s_win, 3);
  2451. X                    if (up_param()) {
  2452. X                        touchwin(s_win);
  2453. X                        wrefresh(s_win);
  2454. X                    }
  2455. X                    else
  2456. X                        param_flag = 0;
  2457. X                }
  2458. X                if (modem_flag) {
  2459. X                    mvwattrstr(s_win, 22, 27, A_BLINK, "Updating Modem Database");
  2460. X                    wrefresh(s_win);
  2461. X                    wait_key(s_win, 3);
  2462. X                    if (up_modem()) {
  2463. X                        touchwin(s_win);
  2464. X                        wrefresh(s_win);
  2465. X                    }
  2466. X                    else
  2467. X                        modem_flag = 0;
  2468. X                }
  2469. X                if (ext_flag) {
  2470. X                    mvwattrstr(s_win, 22, 25, A_BLINK, "Updating External Protocols");
  2471. X                    wrefresh(s_win);
  2472. X                    wait_key(s_win, 3);
  2473. X                    if (up_extrnl()) {
  2474. X                        touchwin(s_win);
  2475. X                        wrefresh(s_win);
  2476. X                    }
  2477. X                    else
  2478. X                        ext_flag = 0;
  2479. X                }
  2480. X                clear_line(s_win, 22, 25, FALSE);
  2481. X                wrefresh(s_win);
  2482. X                break;
  2483. X            default:
  2484. X                beep();
  2485. X        }
  2486. X        touchwin(s_win);
  2487. X        if (xmc > 0)
  2488. X            top_line(s_win);
  2489. X
  2490. X        mvwaddch(s_win, 20, 12, (chtype) ' ');
  2491. X        wmove(s_win, 20, 12);
  2492. X        wrefresh(s_win);
  2493. X    }
  2494. X    if (fd == -1) {
  2495. X        werase(s_win);
  2496. X        wrefresh(s_win);
  2497. X    }
  2498. X    delwin(s_win);
  2499. X    return;
  2500. X}
  2501. X
  2502. X/*
  2503. X * Put the top line on the window.
  2504. X */
  2505. X
  2506. static void
  2507. top_line(win)
  2508. WINDOW *win;
  2509. X{
  2510. X    clear_line(win, 0, 0, FALSE);
  2511. X    wrefresh(win);
  2512. X    horizontal(win, 0, 0, 33);
  2513. X    mvwattrstr(win, 0, 34, A_BOLD, "Setup Menu");
  2514. X    horizontal(win, 0, 45, 34);
  2515. X    wrefresh(win);
  2516. X    return;
  2517. X}
  2518. END_OF_FILE
  2519. if test 2972 -ne `wc -c <'s_menu.c'`; then
  2520.     echo shar: \"'s_menu.c'\" unpacked with wrong size!
  2521. fi
  2522. # end of 's_menu.c'
  2523. fi
  2524. if test -f 's_prompt.c' -a "${1}" != "-c" ; then 
  2525.   echo shar: Will not clobber existing file \"'s_prompt.c'\"
  2526. else
  2527. echo shar: Extracting \"'s_prompt.c'\" \(3077 characters\)
  2528. sed "s/^X//" >'s_prompt.c' <<'END_OF_FILE'
  2529. X/*
  2530. X * Prompting routines used in the setup menus.
  2531. X */
  2532. X
  2533. X#include <stdio.h>
  2534. X#include <curses.h>
  2535. X#include "misc.h"
  2536. X
  2537. X/*
  2538. X * Prompt for a string at line 21 (with optional line 22 for additional
  2539. X * information).  Display the new string in bold at its original location
  2540. X * in the menu.  Used in virtually all of the *_setup() routines.  Since
  2541. X * it uses get_str(), the return value points to a static area.
  2542. X */
  2543. X
  2544. char *
  2545. str_prompt(win, y, x, p1, p2)
  2546. WINDOW *win;
  2547. int y, x;
  2548. char *p1, *p2;
  2549. X{
  2550. X    extern char *null_ptr;
  2551. X    char *ans, *get_str();
  2552. X                    /* print first prompt last */
  2553. X    mvwaddstr(win, 22, 0, p2);
  2554. X    mvwaddstr(win, 21, 0, p1);
  2555. X    waddstr(win, ": ");
  2556. X    wrefresh(win);
  2557. X
  2558. X    if ((ans = get_str(win, 80, "", ";\n")) == NULL)
  2559. X        return(NULL);
  2560. X                    /* check the value */
  2561. X    if (!strcmp(ans, " "))
  2562. X        ans = null_ptr;
  2563. X                    /* display the value in bold */
  2564. X    clear_line(win, y, x, FALSE);
  2565. X    wattrstr(win, A_BOLD, ans);
  2566. X
  2567. X    return(ans);
  2568. X}
  2569. X
  2570. X/*
  2571. X * Same as above, except we return a single character.
  2572. X */
  2573. X
  2574. char
  2575. chr_prompt(win, y, x, p1, p2)
  2576. WINDOW *win;
  2577. int y, x;
  2578. char *p1, *p2;
  2579. X{
  2580. X    char *ans, *get_str();
  2581. X                    /* print first prompt last */
  2582. X    mvwaddstr(win, 22, 0, p2);
  2583. X    mvwaddstr(win, 21, 0, p1);
  2584. X    waddstr(win, ": ");
  2585. X    wrefresh(win);
  2586. X
  2587. X    if ((ans = get_str(win, 1, "", "\n")) == NULL)
  2588. X        return('\0');
  2589. X                    /* display the value in bold */
  2590. X    mvwaddstr(win, y, x, "  ");
  2591. X    wrefresh(win);
  2592. X    mvwattrstr(win, y, x, A_BOLD, ans);
  2593. X
  2594. X    return((char) *ans);
  2595. X}
  2596. X
  2597. X/*
  2598. X * Same as above, except that it prompts for a three digit number.
  2599. X */
  2600. X
  2601. int
  2602. num_prompt(win, y, x, p1, p2)
  2603. WINDOW *win;
  2604. int y, x;
  2605. char *p1, *p2;
  2606. X{
  2607. X    int i;
  2608. X                    /* print first prompt last */
  2609. X    mvwaddstr(win, 22, 0, p2);
  2610. X    mvwaddstr(win, 21, 0, p1);
  2611. X    waddstr(win, ": ");
  2612. X    wrefresh(win);
  2613. X
  2614. X    if ((i = get_num(win, 3)) == -1)
  2615. X        return(-1);
  2616. X                    /* display the value in bold */
  2617. X    mvwaddstr(win, y, x, "    ");
  2618. X    wrefresh(win);
  2619. X    mvwattrnum(win, y, x, A_BOLD, i);
  2620. X                    /* return the number */
  2621. X    return(i);
  2622. X}
  2623. X
  2624. X/*
  2625. X * Prompts for a selection from a menu.  We display the prompt lines,
  2626. X * and show the choices one at a time.  The user selects the currently
  2627. X * showing choice by hitting a carriage return.  Unlike the similar
  2628. X * routines in d_prompt(), the first choice shown is not necessarily
  2629. X * the current.
  2630. X */
  2631. X
  2632. char *v_yes[3] = {"YES", "NO", NULL};
  2633. char *v_yn[3] = {"Y", "N", NULL};
  2634. X
  2635. char *
  2636. menu_prompt(win, y, x, p, menu)
  2637. WINDOW *win;
  2638. int y, x;
  2639. char *p, *menu[];
  2640. X{
  2641. X    char ans;
  2642. X    int i, cy, cx;
  2643. X                    /* print first prompt last */
  2644. X    mvwaddstr(win, 22, 0, "Press any key to change, or <CR> to accept");
  2645. X    mvwaddstr(win, 21, 0, p);
  2646. X    waddstr(win, ": ");
  2647. X                    /* show first choice */
  2648. X    i = 0;
  2649. X    getyx(win, cy, cx);
  2650. X    mvwprintw(win, cy, cx, "%-30.30s", menu[i]);
  2651. X    wmove(win, cy, cx);
  2652. X    wrefresh(win);
  2653. X                    /* show the choices one at a time */
  2654. X    while ((ans = wgetch(win)) != '\r') {
  2655. X        i++;
  2656. X        if (menu[i] == NULL)
  2657. X            i = 0;
  2658. X        if (ans == ESC)
  2659. X            return(NULL);
  2660. X        mvwprintw(win, cy, cx, "%-30.30s", menu[i]);
  2661. X        wmove(win, cy, cx);
  2662. X        wrefresh(win);
  2663. X    }
  2664. X                    /* display the value in bold */
  2665. X    clear_line(win, y, x, FALSE);
  2666. X    wattrstr(win, A_BOLD, menu[i]);
  2667. X                    /* return the value */
  2668. X    return(menu[i]);
  2669. X}
  2670. END_OF_FILE
  2671. if test 3077 -ne `wc -c <'s_prompt.c'`; then
  2672.     echo shar: \"'s_prompt.c'\" unpacked with wrong size!
  2673. fi
  2674. # end of 's_prompt.c'
  2675. fi
  2676. if test -f 's_term.c' -a "${1}" != "-c" ; then 
  2677.   echo shar: Will not clobber existing file \"'s_term.c'\"
  2678. else
  2679. echo shar: Extracting \"'s_term.c'\" \(2909 characters\)
  2680. sed "s/^X//" >'s_term.c' <<'END_OF_FILE'
  2681. X/*
  2682. X * Display the terminal setup, query for changes.  A non-zero return
  2683. X * means something was changed.
  2684. X */
  2685. X
  2686. X#include <stdio.h>
  2687. X#include <curses.h>
  2688. X#include "dial_dir.h"
  2689. X#include "misc.h"
  2690. X#include "param.h"
  2691. X
  2692. int
  2693. term_setup()
  2694. X{
  2695. X    WINDOW *t_win, *newwin();
  2696. X    int i, num, ret_code;
  2697. X    char *ans, *str_rep(), *str_prompt(), *menu_prompt();
  2698. X    void line_set();
  2699. X    static char *v_crio[3] = {"CR", "CR/LF", NULL};
  2700. X    static char *v_duplex[3] = {"FULL", "HALF", NULL};
  2701. X    static char *v_flow[3] = {"NONE", "XON/XOFF", NULL};
  2702. X
  2703. X    t_win = newwin(23, 80, 0, 0);
  2704. X
  2705. X    horizontal(t_win, 0, 0, 32);
  2706. X    mvwattrstr(t_win, 0, 33, A_BOLD, "Terminal Setup");
  2707. X    horizontal(t_win, 0, 48, 32);
  2708. X    mvwprintw(t_win, 4, 22, "1) Hot key (decimal) ...... %d", param->hot_key);
  2709. X    mvwprintw(t_win, 6, 22, "2) ASCII version of hot ... %s", param->ascii_hot);
  2710. X    mvwprintw(t_win, 9, 22, "3) Duplex ................. %s", param->d_duplex);
  2711. X    mvwprintw(t_win, 11, 22, "4) Flow control ........... %s", param->flow_ctrl);
  2712. X    mvwprintw(t_win, 13, 22, "5) CR translation (in) .... %s", param->cr_in);
  2713. X    mvwprintw(t_win, 15, 22, "6) CR translation (out) ... %s", param->cr_out);
  2714. X    horizontal(t_win, 19, 0, 80);
  2715. X    mvwattrstr(t_win, 20, 0, A_BOLD, "OPTION ==> ");
  2716. X    mvwaddstr(t_win, 20, 58, "Press <ESC> to return");
  2717. X    wmove(t_win, 20, 12);
  2718. X    touchwin(t_win);
  2719. X    wrefresh(t_win);
  2720. X                    /* get the option number */
  2721. X    ret_code = 0;
  2722. X    while ((i = get_num(t_win, 1)) != -1) {
  2723. X        switch (i) {
  2724. X            case 1:
  2725. X                if ((num = num_prompt(t_win, 4, 50, "Hot key", "decimal code for the hot key")) != -1) {
  2726. X                    param->hot_key = num;
  2727. X                    ret_code++;
  2728. X                }
  2729. X                break;
  2730. X            case 2:
  2731. X                again:
  2732. X                ans = str_prompt(t_win, 6, 50, "ASCII version of hot key", "(printable version, max of 4 characters)");
  2733. X                if (ans != NULL) {
  2734. X                    if (strlen(ans) > 4) {
  2735. X                        beep();
  2736. X                        clear_line(t_win, 21, 0, 0);
  2737. X                        goto again;
  2738. X                    }
  2739. X                    param->ascii_hot = str_rep(param->ascii_hot, ans);
  2740. X                    ret_code++;
  2741. X                }
  2742. X                break;
  2743. X            case 3:
  2744. X                if ((ans = menu_prompt(t_win, 9, 50, "Duplex", v_duplex)) != NULL) {
  2745. X                    param->d_duplex = str_rep(param->d_duplex, ans);
  2746. X                    dir->duplex[0] = *param->d_duplex;
  2747. X                    ret_code++;
  2748. X                }
  2749. X                break;
  2750. X            case 4:
  2751. X                if ((ans = menu_prompt(t_win, 11, 50, "Flow control", v_flow)) != NULL) {
  2752. X                    param->flow_ctrl = str_rep(param->flow_ctrl, ans);
  2753. X                    line_set();
  2754. X                    ret_code++;
  2755. X                }
  2756. X                break;
  2757. X            case 5:
  2758. X                if ((ans = menu_prompt(t_win, 13, 50, "CR translation (in)", v_crio)) != NULL) {
  2759. X
  2760. X                    param->cr_in = str_rep(param->cr_in, ans);
  2761. X                    ret_code++;
  2762. X                }
  2763. X                break;
  2764. X            case 6:
  2765. X                if ((ans = menu_prompt(t_win, 15, 50, "CR translation (out)", v_crio)) != NULL) {
  2766. X                    param->cr_out = str_rep(param->cr_out, ans);
  2767. X                    ret_code++;
  2768. X                }
  2769. X                break;
  2770. X            default:
  2771. X                beep();
  2772. X        }
  2773. X        mvwaddch(t_win, 20, 12, (chtype) ' ');
  2774. X        clear_line(t_win, 21, 0, FALSE);
  2775. X        clear_line(t_win, 22, 0, FALSE);
  2776. X        wmove(t_win, 20, 12);
  2777. X        wrefresh(t_win);
  2778. X    }
  2779. X    delwin(t_win);
  2780. X    return(ret_code);
  2781. X}
  2782. END_OF_FILE
  2783. if test 2909 -ne `wc -c <'s_term.c'`; then
  2784.     echo shar: \"'s_term.c'\" unpacked with wrong size!
  2785. fi
  2786. # end of 's_term.c'
  2787. fi
  2788. if test -f 's_tty.c' -a "${1}" != "-c" ; then 
  2789.   echo shar: Will not clobber existing file \"'s_tty.c'\"
  2790. else
  2791. echo shar: Extracting \"'s_tty.c'\" \(4931 characters\)
  2792. sed "s/^X//" >'s_tty.c' <<'END_OF_FILE'
  2793. X/*
  2794. X * Display the TTY setup, query for changes.  A non-zero return code
  2795. X * means something was changed.
  2796. X */
  2797. X
  2798. X#include <stdio.h>
  2799. X#include <curses.h>
  2800. X#include "misc.h"
  2801. X#include "modem.h"
  2802. X
  2803. static int tty_prompt();
  2804. static void disp_tty(), del_tty();
  2805. X
  2806. int
  2807. tty_setup()
  2808. X{
  2809. X    WINDOW *tt_win, *newwin();
  2810. X    char message[80], *str, *get_str();
  2811. X    int num, i, j, ret_code;
  2812. X    void create_modem(), del_modem(), error_win();
  2813. X
  2814. X    tt_win = newwin(23, 80, 0, 0);
  2815. X
  2816. X    horizontal(tt_win, 0, 0, 34);
  2817. X    mvwattrstr(tt_win, 0, 35, A_BOLD, "TTY Setup");
  2818. X    horizontal(tt_win, 0, 45, 34);
  2819. X    mvwaddstr(tt_win, 2, 22, "TTY name");
  2820. X    mvwaddstr(tt_win, 2, 37, "Modem name");
  2821. X    mvwaddstr(tt_win, 2, 50, "Locked speed");
  2822. X                    /* display the current TTY list */
  2823. X    disp_tty(tt_win);
  2824. X                    /* prompt for options */
  2825. X    mvwaddstr(tt_win, 15, 20, "A) Add a TTY entry");
  2826. X    mvwaddstr(tt_win, 16, 20, "D) Delete a TTY entry");
  2827. X    horizontal(tt_win, 19, 0, 80);
  2828. X    mvwattrstr(tt_win, 20, 0, A_BOLD, "OPTION ==> ");
  2829. X    mvwaddstr(tt_win, 20, 58, "Press <ESC> to return");
  2830. X    wmove(tt_win, 20, 12);
  2831. X    touchwin(tt_win);
  2832. X    wrefresh(tt_win);
  2833. X                    /* get the option */
  2834. X    ret_code = 0;
  2835. X    while ((str = get_str(tt_win, 2, "01234356789AaDd", "")) != NULL) {
  2836. X        switch(*str) {
  2837. X            case '0':
  2838. X            case '1':
  2839. X            case '2':
  2840. X            case '3':
  2841. X            case '4':
  2842. X            case '5':
  2843. X            case '6':
  2844. X            case '7':
  2845. X            case '8':
  2846. X            case '9':
  2847. X                i = atoi(str);
  2848. X                    /* if beyond t_entries */
  2849. X                if (i > modem->t_entries) {
  2850. X                    beep();
  2851. X                    break;
  2852. X                }
  2853. X
  2854. X                    /* change the entry  */
  2855. X                if (tty_prompt(tt_win, i-1)) {
  2856. X
  2857. X                    /* requires modem update? */
  2858. X                    create_modem(modem->tname[i-1]);
  2859. X                    del_modem();
  2860. X                    ret_code++;
  2861. X                }
  2862. X                break;
  2863. X            case 'a':
  2864. X            case 'A':    /* add an entry */
  2865. X                if (modem->t_entries == NUM_TTY) {
  2866. X                    sprintf(message, "\"%s\"", modem->m_path);
  2867. X                    error_win(0, "No empty TTY slots in modem/TTY database", message);
  2868. X                    break;
  2869. X                }
  2870. X                    /* prompt for info */
  2871. X                j = modem->t_entries;
  2872. X                if (tty_prompt(tt_win, j)) {
  2873. X
  2874. X                    /* add modem entry? */
  2875. X                    modem->t_entries++;
  2876. X                    create_modem(modem->tname[j]);
  2877. X                    ret_code++;
  2878. X                }
  2879. X                break;
  2880. X            case 'd':
  2881. X            case 'D':    /* delete an entry */
  2882. X                mvwaddstr(tt_win, 21, 0, "Entry number to delete: ");
  2883. X                wrefresh(tt_win);
  2884. X                while ((num = get_num(tt_win, 4)) != -1) {
  2885. X                    /* valid range */
  2886. X                    if (!num || num>modem->t_entries) {
  2887. X                        beep();
  2888. X                        mvwaddstr(tt_win, 21, 24, "   ");
  2889. X                        wmove(tt_win, 21, 24);
  2890. X                        wrefresh(tt_win);
  2891. X                        continue;
  2892. X                    }
  2893. X                    del_tty(num-1);
  2894. X                    del_modem();
  2895. X
  2896. X                    /* show the new list */
  2897. X                    disp_tty(tt_win);
  2898. X                    ret_code++;
  2899. X                    break;
  2900. X                }
  2901. X                break;
  2902. X            default:
  2903. X                beep();
  2904. X                break;
  2905. X        }
  2906. X        mvwaddstr(tt_win, 20, 12, "  ");
  2907. X        clear_line(tt_win, 21, 0, FALSE);
  2908. X        clear_line(tt_win, 22, 0, FALSE);
  2909. X        wmove(tt_win, 20, 12);
  2910. X        wrefresh(tt_win);
  2911. X    }
  2912. X    delwin(tt_win);
  2913. X    return(ret_code);
  2914. X}
  2915. X
  2916. X/*
  2917. X * Display the current TTY list.  No scrolling yet, so if your NUM_TTY is
  2918. X * greater than ten, this routine will need some work.
  2919. X */
  2920. X
  2921. static void
  2922. disp_tty(win)
  2923. WINDOW *win;
  2924. X{
  2925. X    int i;
  2926. X
  2927. X    for (i=0; i<NUM_TTY; i++)
  2928. X        mvwprintw(win, i+4, 20, "%2d) %-14.14s %-14.14s  %d\n",
  2929. X         i+1, modem->tty[i], modem->tname[i], modem->lock_sp[i]);
  2930. X    return;
  2931. X}
  2932. X
  2933. X/*
  2934. X * Prompt the user for the TTY database info.  A non-zero return code means
  2935. X * something was changed.  The second argument is the zero based index.
  2936. X */
  2937. X
  2938. static int
  2939. tty_prompt(win, i)
  2940. WINDOW *win;
  2941. int i;
  2942. X{
  2943. X    char *ans, t_tty[80], t_tname[80], *str_prompt(), *menu_prompt();
  2944. X    char *str_rep(), *strcpy();
  2945. X    static char *v_baud[9] = {"0", "300", "1200", "2400", "4800", "9600",
  2946. X     "19200", "38400", NULL};
  2947. X                    /* get temp TTY */
  2948. X    if ((ans = str_prompt(win, i+4, 24, "TTY name", "")) == NULL)
  2949. X        return(0);
  2950. X
  2951. X    strcpy(t_tty, ans);
  2952. X    clear_line(win, 21, 0, FALSE);
  2953. X
  2954. X                    /* get temp tname */
  2955. X    if ((ans = str_prompt(win, i+4, 39, "Modem name", "")) == NULL)
  2956. X        return(0);
  2957. X
  2958. X    strcpy(t_tname, ans);
  2959. X    clear_line(win, 21, 0, FALSE);
  2960. X
  2961. X                    /* get DTE locked baud */
  2962. X    if ((ans = menu_prompt(win, i+4, 55, "Locked speed", v_baud)) == NULL)
  2963. X        return(0);
  2964. X
  2965. X    wrefresh(win);
  2966. X                    /* store 'em for real */
  2967. X    modem->tty[i] = str_rep(modem->tty[i], t_tty);
  2968. X    modem->tname[i] = str_rep(modem->tname[i], t_tname);
  2969. X    modem->lock_sp[i] = atoi(ans);
  2970. X
  2971. X    return(1);
  2972. X}
  2973. X
  2974. X/*
  2975. X * Delete a TTY entry.  Since the list must be contiguous, we collapse the
  2976. X * list to cover the hole we made.
  2977. X */
  2978. X
  2979. static void
  2980. del_tty(i)
  2981. int i;
  2982. X{
  2983. X    extern char *null_ptr;
  2984. X    int j;
  2985. X    char *str_rep();
  2986. X    void free_ptr();
  2987. X                    /* collapse the list */
  2988. X    for (j=i; j<modem->t_entries-1; j++) {
  2989. X        modem->tty[j] = str_rep(modem->tty[j], modem->tty[j+1]);
  2990. X        modem->tname[j] = str_rep(modem->tname[j], modem->tname[j+1]);
  2991. X        modem->lock_sp[j] = modem->lock_sp[j+1];
  2992. X    }
  2993. X    j = modem->t_entries-1;
  2994. X                    /* zap the entry */
  2995. X    free_ptr(modem->tty[j]);
  2996. X    free_ptr(modem->tname[j]);
  2997. X    modem->tty[j] = null_ptr;
  2998. X    modem->tname[j] = null_ptr;
  2999. X    modem->lock_sp[j] = 0;
  3000. X                    /* update the count */
  3001. X    modem->t_entries--;
  3002. X    if (modem->t_cur >= modem->t_entries)
  3003. X        modem->t_cur = -1;
  3004. X    return;
  3005. X}
  3006. END_OF_FILE
  3007. if test 4931 -ne `wc -c <'s_tty.c'`; then
  3008.     echo shar: \"'s_tty.c'\" unpacked with wrong size!
  3009. fi
  3010. # end of 's_tty.c'
  3011. fi
  3012. if test -f 'script.c' -a "${1}" != "-c" ; then 
  3013.   echo shar: Will not clobber existing file \"'script.c'\"
  3014. else
  3015. echo shar: Extracting \"'script.c'\" \(5952 characters\)
  3016. sed "s/^X//" >'script.c' <<'END_OF_FILE'
  3017. X/*
  3018. X * Spawn a shell with file descriptors that look like this:
  3019. X *
  3020. X *                   + ---> screen (& virtual screen)
  3021. X *                   |
  3022. X *              +---------+                     +-----------+
  3023. X *              |         | <---> cmd IPC <---> | pcomm_cmd |
  3024. X *              |  Pcomm  |                     +-----------+
  3025. X *   TTYin ---> |         | ---> pipe --> stdin |           |
  3026. X *              +---------+                     |   shell   |
  3027. X *   TTYout <--------------------------- stdout |           |
  3028. X *                                              +-----------+
  3029. X *
  3030. X * This allows the characters to appear on the screen *and* be interpreted
  3031. X * by the shell script.
  3032. X */
  3033. X
  3034. X#include <stdio.h>
  3035. X#include <curses.h>
  3036. X#include <signal.h>
  3037. X#include <errno.h>
  3038. X#include "config.h"
  3039. X#include "dial_dir.h"
  3040. X#include "misc.h"
  3041. X#include "modem.h"
  3042. X#include "status.h"
  3043. X
  3044. static int epid, dup_pipe[2];
  3045. static char **fixup_env();
  3046. X
  3047. void
  3048. do_script(script)
  3049. char *script;
  3050. X{
  3051. X    extern int fd;
  3052. X    char buf[80], *path, *findfile(), **envp, *ipc_key(), *strcpy();
  3053. X    void _exit(), error_win(), ipc_update();
  3054. X
  3055. X    if (*script == '\0')
  3056. X        return;
  3057. X    /*
  3058. X     * Chaining of scripts, is not allowed.  If a script performs the
  3059. X     * "pcomm_cmd dial" command and that dialing directory entry has
  3060. X     * something in the script field, then ignore the second script.
  3061. X     */
  3062. X    if (status->dup_fd != -1)
  3063. X        return;
  3064. X                    /* find the script file */
  3065. X    if ((path = findfile(script)) == NULL) {
  3066. X        /*
  3067. X         * Fail quietly, if the script is actually a TTY or a
  3068. X         * modem 
  3069. X         */
  3070. X        if (chk_aux(script) != IS_SCRIPT)
  3071. X            return;
  3072. X
  3073. X        sprintf(buf, "Can't locate script \"%s\"", script);
  3074. X        error_win(0, buf, "");
  3075. X        return;
  3076. X    }
  3077. X                    /* execute permission ? */
  3078. X    if (access(path, 1)) {
  3079. X        sprintf(buf, "\"%s\"", path);
  3080. X        error_win(0, "No execute permission on script file", buf);
  3081. X        return;
  3082. X    }
  3083. X    /*
  3084. X     * If a script is invoked prior to dialing, then we need to 
  3085. X     * pass a valid "fd" to the child process.  If the script
  3086. X     * then does a "pcomm_cmd dial", it *must* use that fd.
  3087. X     */
  3088. X    if (fd == -1) {
  3089. X        dir->d_cur = 0;
  3090. X        dir->q_num[0] = 0;
  3091. X        if (get_port())
  3092. X            return;
  3093. X    }
  3094. X                    /* create a fd for duplicating input */
  3095. X    if (pipe(dup_pipe) < 0) {
  3096. X        error_win(0, "Out of pipe resources", "");
  3097. X        return;
  3098. X    }
  3099. X
  3100. X    status->dup_fd = dup_pipe[1];
  3101. X                    /* open an IPC channel */
  3102. X    if ((status->cmd_ipc = ipc_open()) < 0) {
  3103. X        close(dup_pipe[0]);
  3104. X        close(dup_pipe[1]);
  3105. X        status->dup_fd = -1;
  3106. X        error_win(0, "Can't open IPC channel", "");
  3107. X        return;
  3108. X    }
  3109. X    ipc_update(fd, status->cmd_ipc);
  3110. X                    /* pass the "key" in the environment */
  3111. X    strcpy(buf, ipc_key(status->cmd_ipc));
  3112. X    envp = fixup_env(buf);
  3113. X
  3114. X    if (!(epid = fork())) {
  3115. X                    /* create a new process group ID */
  3116. X#ifdef BSD
  3117. X        setpgrp(0, getpid());
  3118. X#else /* BSD */
  3119. X        setpgrp();
  3120. X#endif /* BSD */
  3121. X                    /* swap the stdin and stdout */
  3122. X        close(0);
  3123. X        dup(dup_pipe[0]);
  3124. X        close(1);
  3125. X        dup(fd);
  3126. X
  3127. X        setgid(getgid());
  3128. X        setuid(getuid());
  3129. X
  3130. X        execle("/bin/sh", "sh", "-c", path, (char *) 0, envp);
  3131. X        _exit(1);
  3132. X    }
  3133. X    return;
  3134. X}
  3135. X
  3136. X/*
  3137. X * See if the script process is still active
  3138. X */
  3139. X
  3140. void
  3141. is_active()
  3142. X{
  3143. X    extern int errno, fd;
  3144. X    int dummy;
  3145. X    void ipc_update();
  3146. X
  3147. X#ifdef BSD
  3148. X    if ((kill(epid, 0) == -1) && errno == ESRCH) {
  3149. X#else /* BSD */
  3150. X    if ((kill(-epid, 0) == -1) && errno == ESRCH) {
  3151. X#endif /* BSD */
  3152. X                    /* shut down the duplication of input */
  3153. X        close(dup_pipe[0]);
  3154. X        close(dup_pipe[1]);
  3155. X        ipc_close(status->cmd_ipc);
  3156. X
  3157. X        status->dup_fd = -1;
  3158. X        status->cmd_ipc = -1;
  3159. X        ipc_update(fd, status->cmd_ipc);
  3160. X
  3161. X        wait(&dummy);
  3162. X        beep();
  3163. X    }
  3164. X    return;
  3165. X}
  3166. X
  3167. X/*
  3168. X * Abort the script prematurely.
  3169. X */
  3170. X
  3171. void
  3172. stop_script()
  3173. X{
  3174. X    extern int fd;
  3175. X    int dummy;
  3176. X    unsigned int sleep();
  3177. X    void ipc_update();
  3178. X
  3179. X#ifdef BSD
  3180. X    killpg(epid, SIGKILL);
  3181. X#else /* BSD */
  3182. X    kill(-epid, SIGKILL);
  3183. X#endif /* BSD */
  3184. X
  3185. X    sleep(1);
  3186. X
  3187. X    close(dup_pipe[0]);
  3188. X    close(dup_pipe[1]);
  3189. X    ipc_close(status->cmd_ipc);
  3190. X
  3191. X    status->dup_fd = -1;
  3192. X    status->cmd_ipc = -1;
  3193. X    ipc_update(fd, status->cmd_ipc);
  3194. X
  3195. X    wait(&dummy);
  3196. X    return;
  3197. X}
  3198. X
  3199. X/*
  3200. X * Prompt the user for a shell script.
  3201. X */
  3202. X
  3203. char *
  3204. script_menu()
  3205. X{
  3206. X    extern int fd;
  3207. X    WINDOW *sc_win, *newwin();
  3208. X    char *ans, *script, *get_str(), *findfile(), *str_dup(), *path;
  3209. X    char *strchr(), buf[80], *strcpy();
  3210. X    void free_ptr(), error_win();
  3211. X
  3212. X    if (status->dup_fd != -1) {
  3213. X        error_win(0, "A script is already running", "Concurrent scripts are not allowed");
  3214. X        return(NULL);
  3215. X    }
  3216. X
  3217. X    sc_win = newwin(5, 55, 4, 7);
  3218. X
  3219. X    box(sc_win, VERT, HORZ);
  3220. X    mvwaddstr(sc_win, 2, 4, "Shell script: ");
  3221. X    mvwattrstr(sc_win, 0, 3, A_BOLD, " Command Files ");
  3222. X    wmove(sc_win, 2, 18);
  3223. X    wrefresh(sc_win);
  3224. X
  3225. X    script = NULL;
  3226. X    strcpy(buf, "Shell script not found");
  3227. X                    /* get the answer */
  3228. X    while ((ans = get_str(sc_win, 80, "", " \t\n")) != NULL) {
  3229. X                    /* a CR means exit */
  3230. X        if (*ans == '\0')
  3231. X            break;
  3232. X                    /* see if we can find it */
  3233. X        if ((path = findfile(ans)) != NULL) {
  3234. X            if (!access(path, 1)) {
  3235. X                free_ptr(path);
  3236. X                script = str_dup(ans);
  3237. X                break;
  3238. X            }
  3239. X            else
  3240. X                strcpy(buf, "No execute permission");
  3241. X        }
  3242. X
  3243. X        beep();
  3244. X        if (strchr(ans, '/'))
  3245. X            strcpy(buf, "Don't include the path");
  3246. X
  3247. X        mvwattrstr(sc_win, 3, 16, A_BOLD, buf);
  3248. X        wrefresh(sc_win);
  3249. X        wait_key(sc_win, 3);
  3250. X                    /* clean up the mess */
  3251. X        clear_line(sc_win, 2, 18, TRUE);
  3252. X        clear_line(sc_win, 3, 16, TRUE);
  3253. X        wmove(sc_win, 2, 18);
  3254. X        wrefresh(sc_win);
  3255. X
  3256. X        free_ptr(path);
  3257. X    }
  3258. X    if (fd == -1) {
  3259. X        werase(sc_win);
  3260. X        wrefresh(sc_win);
  3261. X    }
  3262. X    delwin(sc_win);
  3263. X    return(script);
  3264. X}
  3265. X
  3266. X/*
  3267. X * Put PCOMM_CMD into a new environmental variable array.
  3268. X */
  3269. X
  3270. static char **
  3271. fixup_env(key)
  3272. char *key;
  3273. X{
  3274. X    int n;
  3275. X    extern char **environ;
  3276. X    char **envp, buf[80], **old, **new, *malloc(), *str_dup();
  3277. X
  3278. X                    /* how many variables do we have? */
  3279. X    old = environ;
  3280. X    n = 0;
  3281. X    while (*old != NULL) {
  3282. X        n++;
  3283. X        old++;
  3284. X    }
  3285. X
  3286. X    envp = (char **) malloc((n+2) * sizeof(char *));
  3287. X    new = envp;
  3288. X    old = environ;
  3289. X    while (*old != NULL) {
  3290. X                    /* don't copy an old value */
  3291. X        if (strncmp(*old, "PCOMM_CMD=", 10)) {
  3292. X            *new = str_dup(*old);
  3293. X            new++;
  3294. X        }
  3295. X        old++;
  3296. X    }
  3297. X    sprintf(buf, "PCOMM_CMD=%s", key);
  3298. X    *new = str_dup(buf);
  3299. X    new++;
  3300. X    *new = NULL;
  3301. X    return(envp);
  3302. X}
  3303. END_OF_FILE
  3304. if test 5952 -ne `wc -c <'script.c'`; then
  3305.     echo shar: \"'script.c'\" unpacked with wrong size!
  3306. fi
  3307. # end of 'script.c'
  3308. fi
  3309. if test -f 'strings.c' -a "${1}" != "-c" ; then 
  3310.   echo shar: Will not clobber existing file \"'strings.c'\"
  3311. else
  3312. echo shar: Extracting \"'strings.c'\" \(4196 characters\)
  3313. sed "s/^X//" >'strings.c' <<'END_OF_FILE'
  3314. X/*
  3315. X * Miscellaneous string routines.
  3316. X */
  3317. X
  3318. X#include <stdio.h>
  3319. X#include "config.h"
  3320. X
  3321. X/*
  3322. X * Do a fancy string copy.  If NULL, return null.  If pointer to NULL, then
  3323. X * return the special "null_ptr" variable.  If a normal copy, allocate
  3324. X * memory first.
  3325. X */
  3326. X
  3327. char *
  3328. str_dup(str)
  3329. char *str;
  3330. X{
  3331. X    extern char *null_ptr;
  3332. X    char *ret, *malloc(), *strcpy();
  3333. X    void error_win();
  3334. X
  3335. X    if (str == NULL)
  3336. X        return(NULL);
  3337. X                    /* if pointer to null */
  3338. X    if (*str == '\0')
  3339. X        return(null_ptr);
  3340. X
  3341. X    if (!(ret = malloc((unsigned int) strlen(str)+1)))
  3342. X        error_win(1, "Out of memory", "");
  3343. X
  3344. X    strcpy(ret, str);
  3345. X    return(ret);
  3346. X}
  3347. X
  3348. X/*
  3349. X * Perform the free(2) function, but check for NULL and the special
  3350. X * "null_ptr" variable first.
  3351. X */
  3352. X
  3353. void
  3354. free_ptr(str)
  3355. char *str;
  3356. X{
  3357. X    extern char *null_ptr;
  3358. X    void free();
  3359. X
  3360. X    if (str != NULL && str != null_ptr)
  3361. X        free(str);
  3362. X    return;
  3363. X}
  3364. X
  3365. X/*
  3366. X * Replace a string.  Follows the same convention as str_dup(), except
  3367. X * that realloc() is used instead of malloc().  Returns a pointer to
  3368. X * the new string (which may have moved).
  3369. X */
  3370. X
  3371. char *
  3372. str_rep(s1, s2)
  3373. char *s1, *s2;
  3374. X{
  3375. X    extern char *null_ptr;
  3376. X    void free_ptr(), error_win();
  3377. X    char *s, *malloc(), *realloc(), *strcpy();
  3378. X
  3379. X                    /* copy null pointer ? */
  3380. X    if (s2 == NULL) {
  3381. X        free_ptr(s1);
  3382. X        return(NULL);
  3383. X    }
  3384. X    if (s2 == '\0') {
  3385. X        free_ptr(s1);
  3386. X        return(null_ptr);
  3387. X    }
  3388. X                    /* use realloc()? */
  3389. X    if (s1 == NULL || s1 == null_ptr) {
  3390. X        if (!(s = malloc((unsigned int) strlen(s2)+1)))
  3391. X            error_win(1, "Out of memory", "");
  3392. X    }
  3393. X    else {
  3394. X        if (!(s = realloc(s1, (unsigned int) strlen(s2)+1)))
  3395. X            error_win(1, "Out of memory", "");
  3396. X    }
  3397. X
  3398. X    strcpy(s, s2);
  3399. X    return(s);
  3400. X}
  3401. X
  3402. X/*
  3403. X * This routine is similar to strtok(3).  But this version handles missing
  3404. X * tokens by returning a pointer to null.  Also it takes a single separator
  3405. X * character as an argument.  Returns a NULL on end of string or error.
  3406. X */
  3407. X
  3408. char *
  3409. str_tok(str, c)
  3410. char *str, c;
  3411. X{
  3412. X    char *strchr();
  3413. X    static char *ptr, *sep;
  3414. X                    /* start at beginning */
  3415. X    if (str != NULL)
  3416. X        ptr = str;
  3417. X    else
  3418. X        ptr = sep;
  3419. X                    /* at the end? */
  3420. X    if (*ptr == '\0')
  3421. X        return(NULL);
  3422. X                    /* no separator? */
  3423. X    if (!(sep = strchr(ptr, c)))
  3424. X        return(NULL);
  3425. X                    /* zap the sep, move past it */
  3426. X    *sep = '\0';
  3427. X    sep++;
  3428. X
  3429. X    return(ptr);
  3430. X}
  3431. X
  3432. X#ifndef HAVE_STRSTR
  3433. X/*
  3434. X * Return a pointer to the first occurrence of string str2 in str1.
  3435. X * Returns a NULL if str2 is not in str1.
  3436. X */
  3437. X
  3438. char *
  3439. strstr(str1, str2)
  3440. char *str1, *str2;
  3441. X{
  3442. X    int len;
  3443. X
  3444. X    len = strlen(str2);
  3445. X    while (*str1) {
  3446. X        if (*str2 == *str1) {
  3447. X            if (!strncmp(str2, str1, len))
  3448. X                return(str1);
  3449. X        }
  3450. X        str1++;
  3451. X    }
  3452. X    return(NULL);
  3453. X}
  3454. X#endif /* HAVE_STRSTR */
  3455. X
  3456. X#ifdef BSD
  3457. X/*
  3458. X * Returns the length of the initial segment of string which consists
  3459. X * entirely of characters from charset.
  3460. X */
  3461. X
  3462. int
  3463. strspn(string, charset)
  3464. char    *string;
  3465. register char    *charset;
  3466. X{
  3467. X    register char *p, *q;
  3468. X
  3469. X    for(q=string; *q != '\0'; ++q) {
  3470. X        for(p=charset; *p != '\0' && *p != *q; ++p)
  3471. X            ;
  3472. X        if(*p == '\0')
  3473. X            break;
  3474. X    }
  3475. X    return(q-string);
  3476. X}
  3477. X
  3478. X/*
  3479. X * Strtok considers string to consist of a sequence of zero or more
  3480. X * text tokens separated by spans of one or more characters from sepset.
  3481. X */
  3482. X
  3483. char *
  3484. strtok(string, sepset)
  3485. char    *string, *sepset;
  3486. X{
  3487. X    register char    *p, *q, *r;
  3488. X    static char    *savept;
  3489. X    char *strpbrk();
  3490. X
  3491. X    /*first or subsequent call*/
  3492. X    p = (string == NULL)? savept: string;
  3493. X
  3494. X    if(p == 0)        /* return if no tokens remaining */
  3495. X        return(NULL);
  3496. X
  3497. X    q = p + strspn(p, sepset);    /* skip leading separators */
  3498. X
  3499. X    if(*q == '\0')        /* return if no tokens remaining */
  3500. X        return(NULL);
  3501. X
  3502. X    if((r = strpbrk(q, sepset)) == NULL)    /* move past token */
  3503. X        savept = 0;    /* indicate this is last token */
  3504. X    else {
  3505. X        *r = '\0';
  3506. X        savept = ++r;
  3507. X    }
  3508. X    return(q);
  3509. X}
  3510. X
  3511. X/*
  3512. X * Return ptr to first occurrence of any character from `brkset'
  3513. X * in the character string `string'; NULL if none exists.
  3514. X */
  3515. X
  3516. char *
  3517. strpbrk(string, brkset)
  3518. register char *string, *brkset;
  3519. X{
  3520. X    register char *p;
  3521. X
  3522. X    if(!string || !brkset)
  3523. X        return(0);
  3524. X    do {
  3525. X        for(p=brkset; *p != '\0' && *p != *string; ++p)
  3526. X            ;
  3527. X        if(*p != '\0')
  3528. X            return(string);
  3529. X    }
  3530. X    while(*string++);
  3531. X    return(0);
  3532. X}
  3533. X
  3534. X/*
  3535. X * Copies the character c, n times to string s
  3536. X */
  3537. X
  3538. char *
  3539. memset(s, c, n)
  3540. char *s, c;
  3541. int n;
  3542. X{
  3543. X    char *s1 = s;
  3544. X
  3545. X    while (n > 0) {
  3546. X        --n;
  3547. X        *s++ = c;
  3548. X    }
  3549. X    return(s1);
  3550. X}
  3551. X#endif /* BSD */
  3552. END_OF_FILE
  3553. if test 4196 -ne `wc -c <'strings.c'`; then
  3554.     echo shar: \"'strings.c'\" unpacked with wrong size!
  3555. fi
  3556. # end of 'strings.c'
  3557. fi
  3558. if test -f 'tty_att.c' -a "${1}" != "-c" ; then 
  3559.   echo shar: Will not clobber existing file \"'tty_att.c'\"
  3560. else
  3561. echo shar: Extracting \"'tty_att.c'\" \(5206 characters\)
  3562. sed "s/^X//" >'tty_att.c' <<'END_OF_FILE'
  3563. X/*
  3564. X * System V specific routines for manipulating the TTY
  3565. X */
  3566. X
  3567. X#include <stdio.h>
  3568. X#include <termio.h>
  3569. X#include <fcntl.h>
  3570. X#include "dial_dir.h"
  3571. X#include "modem.h"
  3572. X#include "param.h"
  3573. X
  3574. static struct termio hold;
  3575. X
  3576. X/*
  3577. X * Change the communication line settings to the new values.
  3578. X */
  3579. X
  3580. void
  3581. line_set()
  3582. X{
  3583. X    static int first = 1;
  3584. X    extern int fd;
  3585. X    struct termio tbuf;
  3586. X    unsigned int baud;
  3587. X                    /* nothing to do! */
  3588. X    if (fd == -1)
  3589. X        return;
  3590. X
  3591. X    if (first) {
  3592. X        ioctl(fd, TCGETA, &hold);
  3593. X        first = 0;
  3594. X    }
  3595. X                    /* get the current settings */
  3596. X    ioctl(fd, TCGETA, &tbuf);
  3597. X                    /* set some beginning values */
  3598. X    tbuf.c_cc[4] = 1;        /* VMIN */
  3599. X    tbuf.c_cc[5] = 1;        /* VTIME */
  3600. X    tbuf.c_oflag = 0;
  3601. X    tbuf.c_iflag = 0;
  3602. X    tbuf.c_cflag = (CREAD|HUPCL|CLOCAL);
  3603. X    tbuf.c_lflag = 0;
  3604. X
  3605. X    if (*param->flow_ctrl == 'X')
  3606. X        tbuf.c_iflag |= (IXON|IXOFF);
  3607. X                    /* strip high bit? */
  3608. X    if (*param->strip == 'Y')
  3609. X        tbuf.c_iflag |= ISTRIP;
  3610. X
  3611. X    /*
  3612. X     * If the DTE speed is locked, then ignore all request to 
  3613. X     * change the speed.
  3614. X     */
  3615. X    baud = modem->lock_sp[modem->t_cur];
  3616. X    if (baud == 0)
  3617. X        baud = dir->baud[0];
  3618. X                    /* the baud rate */
  3619. X    switch (baud) {
  3620. X        case 300:
  3621. X            tbuf.c_cflag |= B300;
  3622. X            break;
  3623. X        case 1200:
  3624. X            tbuf.c_cflag |= B1200;
  3625. X            break;
  3626. X        case 2400:
  3627. X            tbuf.c_cflag |= B2400;
  3628. X            break;
  3629. X        case 4800:
  3630. X            tbuf.c_cflag |= B4800;
  3631. X            break;
  3632. X        case 9600:
  3633. X            tbuf.c_cflag |= B9600;
  3634. X            break;
  3635. X        case 19200:
  3636. X#ifdef B19200
  3637. X            tbuf.c_cflag |= B19200;
  3638. X#else /* B19200 */
  3639. X#ifdef EXTA
  3640. X            tbuf.c_cflag |= EXTA;
  3641. X#endif /* EXTA */
  3642. X#endif /* B19200 */
  3643. X            break;
  3644. X        case 38400:
  3645. X#ifdef B38400
  3646. X            tbuf.c_cflag |= B38400;
  3647. X#else /* B38400 */
  3648. X#ifdef EXTB
  3649. X            tbuf.c_cflag |= EXTB;
  3650. X#endif /* EXTB */
  3651. X#endif /* B38400 */
  3652. X            break;
  3653. X    }
  3654. X                    /* the parity */
  3655. X    switch (dir->parity[0]) {
  3656. X        case 'N':
  3657. X            break;
  3658. X        case 'O':
  3659. X            tbuf.c_cflag |= (PARENB|PARODD);
  3660. X            break;
  3661. X        case 'E':
  3662. X            tbuf.c_cflag |= PARENB;
  3663. X            break;
  3664. X    }
  3665. X                    /* the data bits */
  3666. X    if (dir->data_bits[0] == 8)
  3667. X        tbuf.c_cflag |= CS8;
  3668. X    else
  3669. X        tbuf.c_cflag |= CS7;
  3670. X                    /* the stop bits */
  3671. X    if (dir->stop_bits[0] == 2)
  3672. X        tbuf.c_cflag |= CSTOPB;
  3673. X
  3674. X                    /* now set 'em! */
  3675. X    ioctl(fd, TCSETAF, &tbuf);
  3676. X    return;
  3677. X}
  3678. X
  3679. X/*
  3680. X * Put things back the way they were.
  3681. X */
  3682. X
  3683. void
  3684. reset_line()
  3685. X{
  3686. X    extern int fd;
  3687. X
  3688. X    ioctl(fd, TCSETAF, &hold);
  3689. X    return;
  3690. X}
  3691. X
  3692. X/*
  3693. X * Put the stdin/stdout in terminal mode.  We've divided up the
  3694. X * responsibility for the line settings options between the serial port
  3695. X * and the stdin and stdout.
  3696. X */
  3697. X
  3698. void
  3699. term_mode()
  3700. X{
  3701. X    struct termio tbuf;
  3702. X
  3703. X    ioctl(0, TCGETA, &tbuf);
  3704. X
  3705. X    tbuf.c_cc[4] = 1;        /* VMIN */
  3706. X    tbuf.c_cc[5] = 0;        /* VTIME */
  3707. X    tbuf.c_iflag = 0;
  3708. X    tbuf.c_oflag = 0;
  3709. X    tbuf.c_lflag = 0;
  3710. X                    /* duplex */
  3711. X    if (dir->duplex[0] == 'H')
  3712. X        tbuf.c_lflag = ECHO;
  3713. X
  3714. X    ioctl(0, TCSETAF, &tbuf);
  3715. X    return;
  3716. X}
  3717. X
  3718. X/*
  3719. X * Put the TTY driver in the mode suitable for xmodem transfers.
  3720. X */
  3721. X
  3722. void
  3723. xmodem_mode(fds)
  3724. int fds;
  3725. X{
  3726. X    struct termio tbuf;
  3727. X
  3728. X    ioctl(fds, TCGETA, &tbuf);
  3729. X    /*
  3730. X     * Turn off the XON/XOFF flow control, turn off echoing, and
  3731. X     * switch to 8 bit no parity.
  3732. X     */
  3733. X    tbuf.c_cc[4] = 1;        /* VMIN */
  3734. X    tbuf.c_cc[5] = 0;        /* VTIME */
  3735. X    tbuf.c_iflag = 0;        /* no flow control or mapping */
  3736. X    tbuf.c_oflag = 0;        /* no char mapping or delays */
  3737. X    tbuf.c_lflag = 0;        /* no echo or signals */
  3738. X    tbuf.c_cflag &= ~(PARENB|CSIZE);/* no parity */
  3739. X    tbuf.c_cflag |= CS8;        /* 8 bit */
  3740. X
  3741. X    ioctl(fds, TCSETAF, &tbuf);
  3742. X    return;
  3743. X}
  3744. X
  3745. X/*
  3746. X * Put the TTY line in a mode suitable for the ASCII transfer.  Puts the
  3747. X * terminal in the raw, non-blocking mode.
  3748. X */
  3749. X
  3750. void
  3751. ascii_mode(up)
  3752. int up;
  3753. X{
  3754. X    extern int fd;
  3755. X    struct termio tbuf;
  3756. X
  3757. X    ioctl(fd, TCGETA, &tbuf);
  3758. X    tbuf.c_oflag = 0;
  3759. X                    /* flow control & 8th bit stripping */
  3760. X    if (up) {
  3761. X        tbuf.c_iflag = (ISTRIP|IXON);
  3762. X
  3763. X                    /* if no CR's, use NL delays */
  3764. X        if (!strcmp(param->cr_up, "STRIP"))
  3765. X            tbuf.c_oflag = (OPOST|ONLRET);
  3766. X
  3767. X                    /* CR delay times */
  3768. X        switch (param->cr_delay) {
  3769. X            case 0:
  3770. X                break;
  3771. X            case 100:
  3772. X                tbuf.c_oflag |= (OPOST|CR2);
  3773. X                break;
  3774. X            case 150:
  3775. X                tbuf.c_oflag |= (OPOST|CR3);
  3776. X                break;
  3777. X        }
  3778. X    }
  3779. X                    /* if down loading */
  3780. X    else
  3781. X        tbuf.c_iflag = (ISTRIP|IXOFF);
  3782. X
  3783. X    ioctl(fd, TCSETAF, &tbuf);
  3784. X    return;
  3785. X}
  3786. X
  3787. X/*
  3788. X * Flush the file descriptor
  3789. X */
  3790. X
  3791. int
  3792. tty_flush(fds, mode)
  3793. int fds, mode;
  3794. X{
  3795. X    return(ioctl(fds, TCFLSH, mode));
  3796. X}
  3797. X
  3798. X/*
  3799. X * Wait for the output to drain
  3800. X */
  3801. X
  3802. int
  3803. tty_drain(fds)
  3804. int fds;
  3805. X{
  3806. X    return(ioctl(fds, TCSBRK, 1));
  3807. X}
  3808. X
  3809. X/*
  3810. X * Send a modem break
  3811. X */
  3812. X
  3813. int
  3814. tty_break(fds)
  3815. int fds;
  3816. X{
  3817. X    return(ioctl(fds, TCSBRK, 0));
  3818. X}
  3819. X
  3820. X/*
  3821. X * Fix the file descriptor so that a read is satisfied immediately.  When
  3822. X * read() is called it returns the character in the queue, or an error if
  3823. X * no key was pressed.
  3824. X */
  3825. X
  3826. int
  3827. tty_noblock(fds, on)
  3828. int fds, on;
  3829. X{
  3830. X    int current;
  3831. X
  3832. X    current = fcntl(fds, F_GETFL, 0);
  3833. X    if (on)
  3834. X        return(fcntl(fds, F_SETFL, current | O_NDELAY));
  3835. X    else
  3836. X        return(fcntl(fds, F_SETFL, current & ~O_NDELAY));
  3837. X}
  3838. X
  3839. X/*
  3840. X * Get the current baud rate of the terminal
  3841. X */
  3842. X
  3843. int
  3844. my_speed()
  3845. X{
  3846. X    static unsigned int speed[16] = {0, 50, 75, 110, 134, 150, 200, 300,
  3847. X    600, 1200, 1800, 2400, 4800, 9600, 19200, 38400};
  3848. X    struct termio tbuf;
  3849. X
  3850. X    ioctl(0, TCGETA, &tbuf);
  3851. X    return(speed[tbuf.c_cflag & CBAUD]);
  3852. X}
  3853. X
  3854. X/*
  3855. X * Restart any XON/XOFF flow control that may have stopped the tty 
  3856. X */
  3857. X
  3858. void
  3859. tty_restart()
  3860. X{
  3861. X    extern int fd;
  3862. X
  3863. X    if (fd != -1 && *param->flow_ctrl == 'X')
  3864. X        ioctl(fd, TCXONC, 1);
  3865. X    return;
  3866. X}
  3867. END_OF_FILE
  3868. if test 5206 -ne `wc -c <'tty_att.c'`; then
  3869.     echo shar: \"'tty_att.c'\" unpacked with wrong size!
  3870. fi
  3871. # end of 'tty_att.c'
  3872. fi
  3873. if test -f 'tty_ucb.c' -a "${1}" != "-c" ; then 
  3874.   echo shar: Will not clobber existing file \"'tty_ucb.c'\"
  3875. else
  3876. echo shar: Extracting \"'tty_ucb.c'\" \(5184 characters\)
  3877. sed "s/^X//" >'tty_ucb.c' <<'END_OF_FILE'
  3878. X/*
  3879. X * Berkeley specific routines for manipulating the TTY
  3880. X */
  3881. X
  3882. X#include <stdio.h>
  3883. X#include <sgtty.h>
  3884. X#include <fcntl.h>
  3885. X#include "dial_dir.h"
  3886. X#include "modem.h"
  3887. X#include "param.h"
  3888. X
  3889. static struct sgttyb hold;
  3890. X
  3891. X/*
  3892. X * Change the communication line settings to the new values.
  3893. X */
  3894. X
  3895. void
  3896. line_set()
  3897. X{
  3898. X    static int first = 1;
  3899. X    extern int fd;
  3900. X    struct sgttyb tbuf;
  3901. X    unsigned int baud;
  3902. X                    /* nothing to do! */
  3903. X    if (fd == -1)
  3904. X        return;
  3905. X
  3906. X    if (first) {
  3907. X        ioctl(fd, TIOCGETP, &hold);
  3908. X        first = 0;
  3909. X    }
  3910. X                    /* get the current settings */
  3911. X    ioctl(fd, TIOCGETP, &tbuf);
  3912. X                    /* set some beginning values */
  3913. X    tbuf.sg_flags = CBREAK;
  3914. X
  3915. X    if (*param->flow_ctrl == 'X')
  3916. X        tbuf.sg_flags |= TANDEM;
  3917. X    /*
  3918. X     * If the DTE speed is locked, then ignore all request to change
  3919. X     * the speed.
  3920. X     */
  3921. X    baud = modem->lock_sp[modem->t_cur];
  3922. X    if (baud == 0)
  3923. X        baud = dir->baud[0];
  3924. X                    /* the baud rate */
  3925. X    switch (baud) {
  3926. X        case 300:
  3927. X            tbuf.sg_ispeed = B300;
  3928. X            tbuf.sg_ospeed = B300;
  3929. X            break;
  3930. X        case 1200:
  3931. X            tbuf.sg_ispeed = B1200;
  3932. X            tbuf.sg_ospeed = B1200;
  3933. X            break;
  3934. X        case 2400:
  3935. X            tbuf.sg_ispeed = B2400;
  3936. X            tbuf.sg_ospeed = B2400;
  3937. X            break;
  3938. X        case 4800:
  3939. X            tbuf.sg_ispeed = B4800;
  3940. X            tbuf.sg_ospeed = B4800;
  3941. X            break;
  3942. X        case 9600:
  3943. X            tbuf.sg_ispeed = B9600;
  3944. X            tbuf.sg_ospeed = B9600;
  3945. X            break;
  3946. X        case 19200:
  3947. X#ifdef B19200
  3948. X            tbuf.sg_ispeed = B19200;
  3949. X            tbuf.sg_ospeed = B19200;
  3950. X#else /* B19200 */
  3951. X#ifdef EXTA
  3952. X            tbuf.sg_ispeed = EXTA;
  3953. X            tbuf.sg_ospeed = EXTA;
  3954. X#endif /* EXTA */
  3955. X#endif /* B19200 */
  3956. X            break;
  3957. X        case 38400:
  3958. X#ifdef B38400
  3959. X            tbuf.sg_ispeed = B38400;
  3960. X            tbuf.sg_ospeed = B38400;
  3961. X#else /* B38400 */
  3962. X#ifdef EXTB
  3963. X            tbuf.sg_ispeed = EXTB;
  3964. X            tbuf.sg_ospeed = EXTB;
  3965. X#endif /* EXTB */
  3966. X#endif /* B38400 */
  3967. X            break;
  3968. X    }
  3969. X                    /* the parity */
  3970. X    switch (dir->parity[0]) {
  3971. X        case 'N':
  3972. X            tbuf.sg_flags |= ANYP;
  3973. X            break;
  3974. X        case 'O':
  3975. X            tbuf.sg_flags |= ODDP;
  3976. X            break;
  3977. X        case 'E':
  3978. X            tbuf.sg_flags |= EVENP;
  3979. X            break;
  3980. X    }
  3981. X                    /* now set 'em! */
  3982. X    ioctl(fd, TIOCSETP, &tbuf);
  3983. X    ioctl(fd, TIOCHPCL, 0);
  3984. X    return;
  3985. X}
  3986. X
  3987. X/*
  3988. X * Put things back the way they were.
  3989. X */
  3990. X
  3991. void
  3992. reset_line()
  3993. X{
  3994. X    extern int fd;
  3995. X
  3996. X    ioctl(fd, TIOCSETP, &hold);
  3997. X    return;
  3998. X}
  3999. X
  4000. X/*
  4001. X * Put the stdin/stdout in terminal mode.  We've divided up the
  4002. X * responsibility for the line settings options between the serial port
  4003. X * and the stdin and stdout.
  4004. X */
  4005. X
  4006. void
  4007. term_mode()
  4008. X{
  4009. X    struct sgttyb tbuf;
  4010. X
  4011. X    ioctl(0, TIOCGETP, &tbuf);
  4012. X    
  4013. X    tbuf.sg_flags |= RAW;
  4014. X    tbuf.sg_flags &= ~(CRMOD|ECHO);
  4015. X
  4016. X    if (dir->duplex[0] == 'H')
  4017. X        tbuf.sg_flags |= ECHO;
  4018. X
  4019. X    ioctl(0, TIOCSETP, &tbuf);
  4020. X    return;
  4021. X}
  4022. X
  4023. X/*
  4024. X * Put the TTY driver in the mode suitable for xmodem transfers.
  4025. X */
  4026. X
  4027. void
  4028. xmodem_mode(fds)
  4029. int fds;
  4030. X{
  4031. X    struct sgttyb tbuf;
  4032. X
  4033. X    ioctl(fds, TIOCGETP, &tbuf);
  4034. X    /*
  4035. X     * Turn off the XON/XOFF flow control, turn off echoing, and
  4036. X     * switch to 8 bit no parity.
  4037. X     */
  4038. X    tbuf.sg_flags |= (RAW|ANYP);
  4039. X    tbuf.sg_flags &= ~ECHO;
  4040. X    ioctl(fds, TIOCSETP, &tbuf);
  4041. X    return;
  4042. X}
  4043. X
  4044. X/*
  4045. X * Put the TTY line in a mode suitable for the ASCII transfer.
  4046. X */
  4047. X
  4048. void
  4049. ascii_mode(up)
  4050. int up;
  4051. X{
  4052. X    extern int fd;
  4053. X    struct sgttyb tbuf;
  4054. X
  4055. X    ioctl(fd, TIOCGETP, &tbuf);
  4056. X
  4057. X    tbuf.sg_flags |= (CBREAK|TANDEM);
  4058. X    tbuf.sg_flags &= ~(RAW|CRMOD|ECHO|CRDELAY);
  4059. X
  4060. X    if (up) {
  4061. X                    /* CR delay times */
  4062. X        switch (param->cr_delay) {
  4063. X            case 0:
  4064. X                break;
  4065. X            case 100:
  4066. X                tbuf.sg_flags |= CR1;
  4067. X                break;
  4068. X            case 150:
  4069. X                tbuf.sg_flags |= CR2;
  4070. X                break;
  4071. X        }
  4072. X    }
  4073. X
  4074. X    ioctl(fd, TIOCSETP, &tbuf);
  4075. X    return;
  4076. X}
  4077. X
  4078. X/*
  4079. X * Flush the file descriptor.  Very messy... flushing the input causes a
  4080. X * wait for the output to drain, and there is no output flushing.
  4081. X */
  4082. X
  4083. int
  4084. tty_flush(fds, mode)
  4085. int fds, mode;
  4086. X{
  4087. X    int ret_code = 0;
  4088. X    struct sgttyb tbuf;
  4089. X
  4090. X    switch(mode) {
  4091. X        case 0:            /* flush input queue */
  4092. X            ioctl(fds, TIOCGETP, &tbuf);
  4093. X            ioctl(fds, TIOCSETP, &tbuf);
  4094. X            break;
  4095. X        case 1:            /* flush output queue */
  4096. X            /* sorry! */
  4097. X            break;
  4098. X        case 2:            /* flush both input and output */
  4099. X            ioctl(fds, TIOCFLUSH, 0);
  4100. X            break;
  4101. X        default:
  4102. X            ret_code++;
  4103. X            break;
  4104. X    }
  4105. X    return(ret_code);
  4106. X}
  4107. X
  4108. X/*
  4109. X * Wait for the output to drain
  4110. X */
  4111. X
  4112. int
  4113. tty_drain(fds)
  4114. int fds;
  4115. X{
  4116. X    struct sgttyb tbuf;
  4117. X                    /* this flushes the input too */
  4118. X    ioctl(fds, TIOCGETP, &tbuf);
  4119. X    return(ioctl(fds, TIOCSETP, &tbuf));
  4120. X}
  4121. X
  4122. X/*
  4123. X * Send a modem break
  4124. X */
  4125. X
  4126. int
  4127. tty_break(fds)
  4128. int fds;
  4129. X{
  4130. X    unsigned int sleep();
  4131. X
  4132. X    ioctl(fds, TIOCSBRK, (struct sgttyb *) 0);
  4133. X    sleep(1);
  4134. X    return(ioctl(fds, TIOCCBRK, (struct sgttyb *) 0));
  4135. X}
  4136. X
  4137. X/*
  4138. X * Fix the file descriptor so that a read is satisfied immediately.  When
  4139. X * read() is called it returns the character in the queue, or an error if
  4140. X * no key was pressed.
  4141. X */
  4142. X
  4143. int
  4144. tty_noblock(fds, on)
  4145. int fds, on;
  4146. X{
  4147. X    int current;
  4148. X
  4149. X    current = fcntl(fds, F_GETFL, 0);
  4150. X    if (on)
  4151. X        return(fcntl(fds, F_SETFL, current | FNDELAY));
  4152. X    else
  4153. X        return(fcntl(fds, F_SETFL, current & ~FNDELAY));
  4154. X}
  4155. X
  4156. X/*
  4157. X * Get the current baud rate of the terminal
  4158. X */
  4159. X
  4160. int
  4161. my_speed()
  4162. X{
  4163. X    static unsigned int speed[16] = {0, 50, 75, 110, 134, 150, 200, 300,
  4164. X    600, 1200, 1800, 2400, 4800, 9600, 19200, 38400};
  4165. X    struct sgttyb tbuf;
  4166. X
  4167. X    ioctl(0, TIOCGETP, &tbuf);
  4168. X    return(speed[tbuf.sg_ispeed]);
  4169. X}
  4170. X
  4171. X/*
  4172. X * Restart any XON/XOFF flow control that may have stopped the tty 
  4173. X */
  4174. X
  4175. void
  4176. tty_restart()
  4177. X{
  4178. X    extern int fd;
  4179. X
  4180. X    if (fd != -1 && *param->flow_ctrl == 'X')
  4181. X        ioctl(fd, TIOCFLUSH, (struct sgttyb *) 0);
  4182. X    return;
  4183. X}
  4184. END_OF_FILE
  4185. if test 5184 -ne `wc -c <'tty_ucb.c'`; then
  4186.     echo shar: \"'tty_ucb.c'\" unpacked with wrong size!
  4187. fi
  4188. # end of 'tty_ucb.c'
  4189. fi
  4190. echo shar: End of archive 2 \(of 6\).
  4191. cp /dev/null ark2isdone
  4192. MISSING=""
  4193. for I in 1 2 3 4 5 6 ; do
  4194.     if test ! -f ark${I}isdone ; then
  4195.     MISSING="${MISSING} ${I}"
  4196.     fi
  4197. done
  4198. if test "${MISSING}" = "" ; then
  4199.     echo You have unpacked all 6 archives.
  4200.     rm -f ark[1-9]isdone
  4201. else
  4202.     echo You still need to unpack the following archives:
  4203.     echo "        " ${MISSING}
  4204. fi
  4205. ##  End of shell archive.
  4206. exit 0
  4207.