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

  1. Newsgroups: comp.sources.unix
  2. From: fthood!egray@uxc.cso.uiuc.edu (Emmet Gray)
  3. Subject: v26i157: pcomm-2.0.2 - a serial communications program (clone of ProComm), Part05/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 157
  9. Archive-Name: pcomm-2.0.2/part05
  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 5 (of 6)."
  18. # Contents:  Unixpc.shar pcomm_cmd.c port.c
  19. # Wrapped by vixie@gw.home.vix.com on Wed Apr 14 00:38:43 1993
  20. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  21. if test -f 'Unixpc.shar' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'Unixpc.shar'\"
  23. else
  24. echo shar: Extracting \"'Unixpc.shar'\" \(19535 characters\)
  25. sed "s/^X//" >'Unixpc.shar' <<'END_OF_FILE'
  26. X#! /bin/sh
  27. X# This is a shell archive, meaning:
  28. X# 1. Remove everything above the #! /bin/sh line.
  29. X# 2. Save the resulting text in a file.
  30. X# 3. Execute the file with /bin/sh (not csh) to create:
  31. X#    Makefile
  32. X#    Pcomm.modem
  33. X#    Readme.7300
  34. X#    Setup.sh
  35. X#    config.h
  36. X# This archive created: Sun Sep  6 13:04:17 1992
  37. export PATH; PATH=/bin:/usr/bin:$PATH
  38. echo shar: "extracting 'Makefile'" '(6665 characters)'
  39. if test -f 'Makefile'
  40. then
  41. X    echo shar: "will not over-write existing file 'Makefile'"
  42. else
  43. sed 's/^X//' << \SHAR_EOF > 'Makefile'
  44. XX#                PCOMM v2.0
  45. XX#            for AT&T Unix PC 7300/3b1
  46. XX
  47. XX#for 80286 versions of SCO Xenix
  48. XX#CFLAGS = -Od -DM_TERMINFO -Mle2 -LARGE
  49. XX#LDFLAGS = -SEG 1000 -F 5000 -Mle2
  50. XX#CURSES = -ltinfo -lx
  51. XX
  52. XX#for 80386 versions of SCO Xenix
  53. XX#CFLAGS = -O -DM_TERMINFO
  54. XX#LDFLAGS = -s
  55. XX#CURSES = -ltinfo -lx
  56. XX
  57. XX#for the AT&T Unix PC 7300/3b1
  58. XXLD = ld
  59. XXSHLIB = /lib/crt0s.o /lib/shlib_c.ifile
  60. XXOTHER = /lib/setvbuf.o /lib/doprnt.o -luipc
  61. XX
  62. XX#for Sun OS (using the System V compiler)
  63. XX#CC = /usr/5bin/cc
  64. XX#LD = /usr/5bin/cc
  65. XX
  66. XX#for SVR3.2
  67. XX#SHLIB = -lc_s
  68. XX#OTHER = -lpt
  69. XX
  70. XX#LD = cc
  71. XX#SHLIB =
  72. XX#OTHER =
  73. XXCFLAGS = -O
  74. XXLDFLAGS = -s
  75. XXSHAR = shar -a
  76. XX
  77. XXBIN_DIR = /home/egray/bin
  78. XXMAN_DIR = /usr/man1
  79. XXMAN_EXT = 1
  80. XXPCOMM_LIB = /local/lib/pcomm
  81. XX
  82. XX#for old curses (i.e. Berkeley systems)
  83. XX#CURSES = -lcurses -ltermcap
  84. XXCURSES = -lcurses
  85. XX
  86. XX#for systems without getcwd(3) or getopt(3)
  87. XX#GETCWD.O = getcwd.o
  88. XX#GETCWD.C = getcwd.c
  89. XX#GETOPT.O = getopt.o
  90. XX#GETOPT.C = getopt.c
  91. XX
  92. XX#for System V or Berkeley TTY interface
  93. XX#TTY.O = tty_ucb.o
  94. XX#TTY.C = tty_ucb.c
  95. XXTTY.O = tty_att.o
  96. XXTTY.C = tty_att.c
  97. XX
  98. XX#for System V poll() or Berkeley select()
  99. XXIPC.O = ipc_ucb.o
  100. XXIPC.C = ipc_ucb.c
  101. XX#IPC.O = ipc_att.o
  102. XX#IPC.C = ipc_att.c
  103. XX
  104. XXPCOMM = $(GETCWD.O) $(GETOPT.O) $(TTY.O) $(IPC.O) admin.o chg_dir.o cmd.o \
  105. XX    curses.o d_delete.o d_lib.o d_manual.o d_menu.o d_print.o \
  106. XX    d_prompt.o d_revise.o data_log.o di_delay.o di_win.o dial.o \
  107. XX    e_lib.o expand.o help.o info.o init.o input.o list_dir.o ls_menu.o \
  108. XX    m_lib.o macro.o main.o n_shell.o p_lib.o passthru.o pexit.o \
  109. XX    port.o redial.o s_axfer.o s_extrnl.o s_gen.o s_menu.o s_modem.o \
  110. XX    s_prompt.o s_term.o s_tty.o screen.o script.o st_line.o \
  111. XX    strings.o terminal.o vcs.o x_ascii.o x_batch.o x_extrnl.o \
  112. XX    x_menu.o x_rcv.o x_send.o x_win.o xmodem.o
  113. XX
  114. XXall:    pcomm waitfor matches pcomm_cmd
  115. XX
  116. XXpcomm:    $(PCOMM)
  117. XX    $(LD) $(LDFLAGS) $(PCOMM) $(OTHER) -o pcomm $(CURSES) $(SHLIB)
  118. XX
  119. XXwaitfor: waitfor.o
  120. XX    $(LD) $(LDFLAGS) waitfor.o -o waitfor $(SHLIB)
  121. XX
  122. XXmatches: matches.o
  123. XX    $(LD) $(LDFLAGS) matches.o -o matches $(SHLIB)
  124. XX
  125. XXpcomm_cmd: pcomm_cmd.o
  126. XX    $(LD) $(LDFLAGS) pcomm_cmd.o -o pcomm_cmd $(SHLIB)
  127. XX
  128. XXpcomm_cmd.o:
  129. XX    $(CC) $(CFLAGS) -DIPC=\"$(IPC.C)\" -c pcomm_cmd.c
  130. XX
  131. XXinstall:
  132. XX    cp pcomm waitfor matches pcomm_cmd $(BIN_DIR)
  133. XX#    obviously this requires super-user privelidges...
  134. XX#    chmod 4755 $(BIN_DIR)/pcomm
  135. XX#    chown uucp $(BIN_DIR)/pcomm
  136. XX
  137. XXinstall_man:
  138. XX    cp Pcomm.1 $(MAN_DIR)/pcomm.$(MAN_EXT)
  139. XX    cp Pcomm_cmd.1 $(MAN_DIR)/pcomm_cmd.$(MAN_EXT)
  140. XX    cp Waitfor.1 $(MAN_DIR)/waitfor.$(MAN_EXT)
  141. XX    cp Matches.1 $(MAN_DIR)/matches.$(MAN_EXT)
  142. XX
  143. XXinstall_support:
  144. XX    cp Pcomm.dial_dir $(PCOMM_LIB)/pcomm.dial_dir
  145. XX    cp Pcomm.modem $(PCOMM_LIB)/pcomm.modem
  146. XX    cp Pcomm.param $(PCOMM_LIB)/pcomm.param
  147. XX    cp Pcomm.extrnl $(PCOMM_LIB)/pcomm.extrnl
  148. XX
  149. XXclean:
  150. XX    rm pcomm waitfor matches pcomm_cmd
  151. XX
  152. XXlint:
  153. XX    lint -p -Dlint $(GETCWD.C) $(GETOPT.C) $(TTY.C) $(IPC.C) admin.c \
  154. XX    chg_dir.c cmd.c curses.c d_delete.c d_lib.c d_manual.c d_menu.c \
  155. XX    d_print.c d_prompt.c d_revise.c data_log.c di_delay.c di_win.c \
  156. XX    dial.c e_lib.c expand.c help.c info.c init.c input.c list_dir.c \
  157. XX    ls_menu.c m_lib.c macro.c main.c n_shell.c p_lib.c passthru.c \
  158. XX    pexit.c port.c redial.c s_axfer.c s_extrnl.c s_gen.c s_menu.c \
  159. XX    s_modem.c s_prompt.c s_term.c s_tty.c screen.c script.c \
  160. XX    st_line.c strings.c terminal.c vcs.c x_ascii.c x_batch.c \
  161. XX    x_extrnl.c x_menu.c x_rcv.c x_send.c x_win.c xmodem.c $(CURSES)
  162. XX    lint -p -Dlint -DIPC=\"$(IPC.C)\" pcomm_cmd.c
  163. XX    lint -p -Dlint waitfor.c
  164. XX    lint -p -Dlint matches.c
  165. XX
  166. XXshar:
  167. XX    $(SHAR) Doc.me > pcomm_sh.1
  168. XX    $(SHAR) Configure.sh Convert.sh Makefile Matches.1 Pcomm.1 \
  169. XX    Pcomm.dial_dir Pcomm.extrnl Pcomm.modem Pcomm.param Pcomm_cmd.1 \
  170. XX    Q_and_A Readme Release.notes Sample > pcomm_sh.2
  171. XX    $(SHAR) Unixpc.shar Waitfor.1 admin.c chg_dir.c cmd.c cmd.h \
  172. XX    config.h curses.c d_delete.c d_lib.c d_manual.c > pcomm_sh.3
  173. XX    $(SHAR) d_menu.c d_print.c d_prompt.c d_revise.c data_log.c \
  174. XX    di_delay.c di_win.c dial.c dial_dir.h e_lib.c expand.c extrnl.h \
  175. XX    getcwd.c getopt.c help.c > pcomm_sh.4
  176. XX    $(SHAR) info.c init.c input.c ipc.h ipc_att.c ipc_ucb.c \
  177. XX    list_dir.c ls_menu.c m_lib.c macro.c main.c matches.c misc.h \
  178. XX    modem.h n_shell.c > pcomm_sh.5
  179. XX    $(SHAR) p_lib.c param.h passthru.c patchlevel.h pcomm_cmd.c \
  180. XX    pexit.c port.c redial.c s_axfer.c s_extrnl.c s_gen.c > pcomm_sh.6
  181. XX    $(SHAR) s_menu.c s_modem.c s_prompt.c s_term.c s_tty.c screen.c \
  182. XX    script.c st_line.c status.h strings.c terminal.c tty_att.c \
  183. XX    tty_ucb.c > pcomm_sh.7
  184. XX    $(SHAR) vcs.c vcs.h waitfor.c x_ascii.c x_batch.c x_extrnl.c \
  185. XX    x_menu.c x_rcv.c > pcomm_sh.8
  186. XX    $(SHAR) x_send.c x_win.c xmodem.c xmodem.h > pcomm_sh.9
  187. XX#    $(SHAR) Doc.out Matches.out Pcomm.out Pcomm_cmd.out Waitfor.out \
  188. XX#    > pcomm_sh.10
  189. XX
  190. XXadmin.o:    config.h dial_dir.h param.h
  191. XXchg_dir.o:    config.h misc.h
  192. XXcmd.o:        cmd.h config.h dial_dir.h extrnl.h modem.h param.h status.h xmodem.h
  193. XXcurses.o:    config.h misc.h status.h
  194. XXd_delete.o:    dial_dir.h misc.h param.h
  195. XXd_lib.o:    dial_dir.h param.h
  196. XXd_manual.o:    config.h dial_dir.h misc.h
  197. XXd_menu.o:    config.h dial_dir.h misc.h param.h
  198. XXd_print.o:    config.h dial_dir.h misc.h
  199. XXd_prompt.o:    dial_dir.h misc.h
  200. XXd_revise.o:    dial_dir.h misc.h param.h
  201. XXdata_log.o:    misc.h param.h status.h
  202. XXdi_delay.o:    misc.h param.h
  203. XXdi_win.o:    dial_dir.h misc.h modem.h param.h status.h
  204. XXdial.o:        config.h dial_dir.h misc.h modem.h param.h
  205. XXe_lib.o:    extrnl.h
  206. XXexpand.o:    config.h
  207. XXgetopt.o:    config.h
  208. XXhelp.o:        config.h misc.h
  209. XXinfo.o:        patchlevel.h
  210. XXinit.o:        config.h misc.h status.h
  211. XXinput.o:    config.h misc.h param.h status.h vcs.h
  212. XXipc_att.o:    ipc.h
  213. XXipc_ucb.o:    ipc.h
  214. XXlist_dir.o:    misc.h
  215. XXls_menu.o:    dial_dir.h misc.h param.h
  216. XXm_lib.o:    modem.h
  217. XXmacro.o:    misc.h param.h
  218. XXmain.o:        config.h dial_dir.h extrnl.h misc.h modem.h param.h status.h
  219. XXn_shell.o:    config.h
  220. XXp_lib.o:    param.h
  221. XXpassthru.o:    config.h misc.h
  222. XXpexit.o:    dial_dir.h misc.h param.h status.h
  223. XXport.o:        config.h dial_dir.h modem.h status.h
  224. XXredial.o:    config.h dial_dir.h misc.h
  225. XXs_axfer.o:    misc.h param.h
  226. XXs_extrnl.o:    extrnl.h misc.h
  227. XXs_gen.o:    misc.h param.h
  228. XXs_menu.o:    misc.h
  229. XXs_modem.o:    misc.h modem.h
  230. XXs_prompt.o:    misc.h
  231. XXs_term.o:    dial_dir.h misc.h param.h
  232. XXs_tty.o:    misc.h modem.h
  233. XXscreen.o:    param.h status.h
  234. XXscript.o:    config.h dial_dir.h misc.h modem.h status.h 
  235. XXst_line.o:    config.h dial_dir.h misc.h modem.h param.h status.h
  236. XXstrings.o:    config.h
  237. XXterminal.o:    config.h dial_dir.h ipc.h misc.h modem.h param.h status.h xmodem.h
  238. XXtty_att.o:    dial_dir.h modem.h param.h
  239. XXtty_ucb.o:    dial_dir.h modem.h param.h
  240. XXvcs.o:        config.h status.h vcs.h
  241. XXx_ascii.o:    config.h misc.h param.h
  242. XXx_batch.o:    config.h misc.h xmodem.h
  243. XXx_extrnl.o:    config.h
  244. XXx_menu.o:    extrnl.h misc.h xmodem.h
  245. XXx_rcv.o:    config.h dial_dir.h misc.h xmodem.h
  246. XXx_send.o:    config.h dial_dir.h misc.h xmodem.h
  247. XXx_win.o:    dial_dir.h misc.h status.h xmodem.h
  248. XXxmodem.o:    config.h misc.h param.h xmodem.h
  249. XX
  250. XXpcomm_cmd.o:    config.h cmd.h $(IPC.C)
  251. XXmatches.o:    config.h
  252. XXwaitfor.o:    config.h
  253. SHAR_EOF
  254. if test 6665 -ne "`wc -c < 'Makefile'`"
  255. then
  256. X    echo shar: "error transmitting 'Makefile'" '(should have been 6665 characters)'
  257. fi
  258. fi
  259. echo shar: "extracting 'Pcomm.modem'" '(153 characters)'
  260. if test -f 'Pcomm.modem'
  261. then
  262. X    echo shar: "will not over-write existing file 'Pcomm.modem'"
  263. else
  264. sed 's/^X//' << \SHAR_EOF > 'Pcomm.modem'
  265. XXTTY_1=ph1;OBM;0
  266. XXTTY_2=tty000;DIRECT;0
  267. XXMODEM_1a=OBM;;%;@;
  268. XXMODEM_1b=N;CONNECT;CONNECT;;;;;
  269. XXMODEM_1c=;;;
  270. XXMODEM_2a=DIRECT;;;;
  271. XXMODEM_2b=N;;;;;;;
  272. XXMODEM_2c=;;;
  273. SHAR_EOF
  274. if test 153 -ne "`wc -c < 'Pcomm.modem'`"
  275. then
  276. X    echo shar: "error transmitting 'Pcomm.modem'" '(should have been 153 characters)'
  277. fi
  278. fi
  279. echo shar: "extracting 'Readme.7300'" '(5766 characters)'
  280. if test -f 'Readme.7300'
  281. then
  282. X    echo shar: "will not over-write existing file 'Readme.7300'"
  283. else
  284. sed 's/^X//' << \SHAR_EOF > 'Readme.7300'
  285. XX                  Pcomm v2.0
  286. XX             Additional Notes for users of
  287. XX                 AT&T Unix PC 7300/3b1
  288. XX
  289. XX    1) This version of Pcomm *REQUIRES* the pseudo-tty and socket
  290. XX    emulation library called "uipc" found on osu-cis.
  291. XX
  292. XX    2) You must run the Setup.sh shell script (as root) before
  293. XX    attempting to compile Pcomm.  The shell script will create a 
  294. XX    new link directive file, extract a few missing objects from
  295. XX    the C library, and create a new sys/time.h header.
  296. XX
  297. XX    3) The shared libraries on your system contain Terminal Access
  298. XX    Method (TAM) routines in lieu of curses(3) routines.  However,
  299. XX    many of the routines have the same names!  This means that
  300. XX    curses library is not compatible with the shared library.  So,
  301. XX    to circumvent the problem, an alternate shared library "link
  302. XX    directive file" is needed.  The Setup.sh script creates this
  303. XX    file.
  304. XX
  305. XX    4) Before Pcomm can be compiled, the curses library routines
  306. XX    must be installed on your system.  The diskette labeled
  307. XX    "Curses/Terminfo Programmer's Package" is a part of the "Unix
  308. XX    Development Set".  Likewise, before Pcomm can be used, the
  309. XX    terminfo database must be installed.  The diskettes labeled
  310. XX    "Curses/Terminfo End User Package" and "Terminfo Database" are
  311. XX    a part of the "Unix Foundation Set"
  312. XX
  313. XX    5) Did you know that your system can use DEC vt100 style line
  314. XX    drawing character?  Curses automatically uses the "alternate"
  315. XX    character set (if found) to draw the boxes and lines rather than
  316. XX    using the "-" and "|" characters.  To allow your system to use
  317. XX    this feature, there are two things you must do:
  318. XX
  319. XX        1) Load the line drawing font in slot 1 prior to running
  320. XX        a program requiring them.  This can be done by typing:
  321. XX
  322. XX            setf /usr/lib/wfont/BLD.ft 1
  323. XX
  324. XX        ...or permanently install this font in slot 1 by adding
  325. XX        the following two lines to the end of the /etc/rc file:
  326. XX
  327. XX            sfont /usr/lib/wfont/BLD.ft 1
  328. XX            setf /usr/lib/wfont/BLD.ft 1
  329. XX
  330. XX        2) Tell curses(3) about the alternate character set by
  331. XX        editing the terminfo database.
  332. XX
  333. XX        To get a copy of the terminfo entry to play with,
  334. XX        you type:
  335. XX
  336. XX            infocmp -I s4 > s4.ti
  337. XX
  338. XX        now add the following line (with a leading tab) to the
  339. XX        "s4.ti" file:
  340. XX
  341. XX            acsc=+h\,g.e-fjjkkllmmnnqqttuuvvwwxx,
  342. XX
  343. XX        recompile the new entry:
  344. XX
  345. XX            tic s4.ti
  346. XX
  347. XX    There is one disadvantage...  Sometimes line noise will switch
  348. XX    you to the line drawing character set while you're communicating
  349. XX    with a remote!
  350. XX
  351. XX    6) The "tset" command is broken on every version of Unix this
  352. XX    box has ever seen (it is commented out of /etc/profile for a
  353. XX    good reason).  One of tset's functions was to send a string to
  354. XX    initialize the settings of the terminal and to set the tab
  355. XX    stops.  The fact that this program isn't used is often
  356. XX    overlooked because the console (as well as a lot of other
  357. XX    terminals) doesn't require any initialization.  However, if you
  358. XX    call into your system from a remote terminal that *does* require
  359. XX    initialization, you've got trouble.
  360. XX
  361. XX    For example, curses(3) looks at the terminfo database to see if
  362. XX    your terminal has "hardware tabs", if so, it expects the tab
  363. XX    stops to be set.  Ignoring tabs by using "stty -tabs" (to
  364. XX    convert tabs to spaces) won't work, in fact, curses(3) RESETS
  365. XX    things as if you had typed "stty tabs"!
  366. XX
  367. XX    Likewise, my terminfo entry for PCPLUS v1.1's emulation of a
  368. XX    vt102 has "^[)0" in the initialization string to load the line
  369. XX    drawing character set.  It needs to be sent to the terminal
  370. XX    before running Pcomm.
  371. XX
  372. XX    Some versions of Unix have a "init" option to the "tput" command
  373. XX    to perform all the initialization.  If so, you should edit the
  374. XX    /etc/profile to add the following commands at the bottom:
  375. XX
  376. XX        tput init
  377. XX        tabs
  378. XX
  379. XX    If your version of tput doesn't recognize the "init" option, a
  380. XX    somewhat longer solution is to edit /etc/profile and add the
  381. XX    following commands at the bottom:
  382. XX
  383. XX        eval `tput iprog`
  384. XX        tput is1
  385. XX        tput is2
  386. XX        if [ -n "`tput hts`" ] ;then
  387. XX            stty tabs
  388. XX        else
  389. XX            stty -tabs
  390. XX        fi
  391. XX        tabs
  392. XX        cat -s "`tput if`"
  393. XX        tput is3
  394. XX        echo "\r\c"
  395. XX
  396. XX    7) Pcomm makes (an arrogant) assumption that the phone line for
  397. XX    the OBM is already configured in the DATA mode.  Users with only
  398. XX    one phone line attached to ph0 will have to manually switch the
  399. XX    line to the DATA mode before using Pcomm and then switch it back
  400. XX    to VOICE afterwards.  To aid in this task, the following shell
  401. XX    script could be used:
  402. XX
  403. XX        phtoggle
  404. XX        sleep 1
  405. XX        /usr/local/bin/pcomm $*
  406. XX        phtoggle
  407. XX
  408. XX    Users with one phone line attached to ph0 will have to change
  409. XX    the TTY setup since the default Pcomm.modem file assumes that
  410. XX    ph1 is being used.
  411. XX
  412. XX    If you only have one phone line but *always* use it in the DATA
  413. XX    mode, there is another solution.  Did you know that you can fool
  414. XX    your machine into having a one-line system in the DATA mode?
  415. XX    All you have to do is re-configure the Telephone Setup and tell
  416. XX    the machine that you've got two lines (one line to be shared
  417. XX    between VOICE and DATA on ph0, and one line to be DATA only on
  418. XX    ph1).  Then you just never plug the phone line into ph0, you use
  419. XX    ph1 instead.  The Telephone Setup menu is reached through the
  420. XX    Office of install, Administration, Hardware Setup menues.
  421. XX
  422. XX    8. The SETUID_BROKE pre-processor variable was designed to take
  423. XX    care of systems that aren't able to switch back and forth
  424. XX    between the real and effective user id.  On the Unix PC, this
  425. XX    problem only exists if the program is set-group-id.  So, if
  426. XX    you're running HDB UUCP and have Pcomm set-user-id to uucp, you
  427. XX    don't need to have SETUID_BROKE defined.
  428. XX
  429. XX    9. The default tunable parameters for the size of INPUT_BUF and
  430. XX    OUTPUT_BUF for the Unix PC are rather small in order to prevent a
  431. XX    "choppy" appearance on the screen.  However, if you have
  432. XX    installed the serial patch (called "serial_pat.Z" on osu-cis),
  433. XX    then the nominal sizes of 64 and 32 for INPUT_BUF and OUTPUT_BUF
  434. XX    will provide much better performance.
  435. SHAR_EOF
  436. if test 5766 -ne "`wc -c < 'Readme.7300'`"
  437. then
  438. X    echo shar: "error transmitting 'Readme.7300'" '(should have been 5766 characters)'
  439. fi
  440. fi
  441. echo shar: "extracting 'Setup.sh'" '(1852 characters)'
  442. if test -f 'Setup.sh'
  443. then
  444. X    echo shar: "will not over-write existing file 'Setup.sh'"
  445. else
  446. sed 's/^X//' << \SHAR_EOF > 'Setup.sh'
  447. XXecho This shell script will create a new link directive file, extract
  448. XXecho a few missing objects from the C libraries, and create a new
  449. XXecho sys/time.h header file.
  450. XX
  451. XXecho
  452. XXecho cd /lib
  453. XXcd /lib
  454. XX
  455. XXecho cp shlib.ifile shlib_c.ifile
  456. XXcp shlib.ifile shlib_c.ifile
  457. XX
  458. XXecho editing shlib_c.ifile
  459. XXex - shlib_c.ifile << "EOF"
  460. XX1,$s/^PC/xPC/
  461. XX1,$s/^BC/xBC/
  462. XX1,$s/^UP/xUP/
  463. XX1,$s/^ospeed/xospeed/
  464. XX1,$s/^LINES/xLINES/
  465. XX1,$s/^COLS/xCOLS/
  466. XX1,$s/^tgetflag/xtgetflag/
  467. XX1,$s/^tgetent/xtgetent/
  468. XX1,$s/^tgetstr/xtgetstr/
  469. XX1,$s/^tgetnum/xtgetnum/
  470. XX1,$s/^tgoto/xtgoto/
  471. XX1,$s/^tputs/xtputs/
  472. XX1,$s/^wrefresh/xwrefresh/
  473. XX1,$s/^initscr/xinitscr/
  474. XX1,$s/^cbreak/xcbreak/
  475. XX1,$s/^nl/xnl/
  476. XX1,$s/^flushinp/xflushinp/
  477. XX1,$s/^noecho/xnoecho/
  478. XX1,$s/^savetty/xsavetty/
  479. XX1,$s/^resetty/xresetty/
  480. XX1,$s/^echo/xecho/
  481. XX1,$s/^nocbreak/xnocbreak/
  482. XX1,$s/^nonl/xnonl/
  483. XX1,$s/^keypad/xkeypad/
  484. XX1,$s/^endwin/xendwin/
  485. XX1,$s/^printw/xprintw/
  486. XX1,$s/^fixterm/xfixterm/
  487. XX1,$s/^resetterm/xresetterm/
  488. XX1,$s/^setterm/xsetterm/
  489. XX1,$s/^baudrate/xbaudrate/
  490. XXw
  491. XXq
  492. XXEOF
  493. XX
  494. XXecho ar x libc.a doprnt.o setvbuf.o
  495. XXar x libc.a doprnt.o setvbuf.o
  496. XX
  497. XXecho creating /usr/include/sys/time.h
  498. XXcat > /usr/include/sys/time.h << "EOF"
  499. XX/*
  500. XX * The sys/time.h stuff extracted from select.h in the UIPC code.
  501. XX */
  502. XX
  503. XX#ifndef sys_time_h
  504. XX#define sys_time_h
  505. XX
  506. XXstruct timeval {
  507. XX    long    tv_sec;        /* seconds */
  508. XX    long    tv_usec;    /* and microseconds */
  509. XX};
  510. XX
  511. XX/*
  512. XX * Operations on timevals.
  513. XX *
  514. XX * NB: timercmp does not work for >= or <=.
  515. XX */
  516. XX#define    timerisset(tvp)        ((tvp)->tv_sec || (tvp)->tv_usec)
  517. XX#define    timercmp(tvp, uvp, cmp)    \
  518. XX    ((tvp)->tv_sec cmp (uvp)->tv_sec || \
  519. XX     (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
  520. XX#define    timerclear(tvp)        (tvp)->tv_sec = (tvp)->tv_usec = 0
  521. XX
  522. XX#endif
  523. XXEOF
  524. XX
  525. XXif [ ! -f /lib/libuipc.a -a ! -f /usr/lib/libuipc.a ] ;then
  526. XX    echo "Can't find the uipc library..."
  527. XX    echo "Pcomm v2.0 *REQUIRES* this public domain socket emulation library"
  528. XXfi
  529. SHAR_EOF
  530. if test 1852 -ne "`wc -c < 'Setup.sh'`"
  531. then
  532. X    echo shar: "error transmitting 'Setup.sh'" '(should have been 1852 characters)'
  533. fi
  534. fi
  535. echo shar: "extracting 'config.h'" '(2524 characters)'
  536. if test -f 'config.h'
  537. then
  538. X    echo shar: "will not over-write existing file 'config.h'"
  539. else
  540. sed 's/^X//' << \SHAR_EOF > 'config.h'
  541. XX/*
  542. XX * Various tunable parameters.  This should appear before any other local
  543. XX * header file.
  544. XX */
  545. XX
  546. XX/* Are you using a Berkeley flavor of Unix? */
  547. XX#undef    BSD
  548. XX
  549. XX/* Use the dialing routines specific to the AT&T Unix PC 7300/3b1 */
  550. XX#define    UNIXPC
  551. XX
  552. XX/* Older versions of curses(3) use termcap in lieu of terminfo */
  553. XX#undef    OLDCURSES
  554. XX
  555. XX/* Should a missing video attribute be promoted to standout? */
  556. XX#define    NOPROMOTE
  557. XX
  558. XX/* Should Pcomm make a log of all phone calls? */
  559. XX#define    LOG_CALLS
  560. XX
  561. XX/* The name of the log file (if used).  */
  562. XX#define    LOG_FILE    "/usr/adm/phone.calls"
  563. XX
  564. XX/* Should long distance (toll) calls be limited to a specific group? */
  565. XX#undef    LIMIT_LD
  566. XX
  567. XX/* The name of the privileged group for limiting long distance calls */
  568. XX#define    GROUP_NAME    "uucp"
  569. XX
  570. XX/* The path to the line printer program */
  571. XX#define    LPR        "lp -s"
  572. XX
  573. XX/* The path to the "pretty" printer program (if none, use "pr | lp") */
  574. XX#define    LPRINT        "pr | lp -s"
  575. XX
  576. XX/* The path to the default directory containing the Pcomm support files */
  577. XX#define    DEFAULT_DIR    "/local/lib/pcomm"
  578. XX
  579. XX/* The path to the directory where UUCP locks are found */
  580. XX#define    LOCK_DIR    "/usr/spool/uucp"
  581. XX
  582. XX/* Do the lock files use ASCII encoded PID's? */
  583. XX#undef    ASCII_PID
  584. XX
  585. XX/* Fold the last character of the lock to lower case? */
  586. XX#undef    XENIX_LOCKS
  587. XX
  588. XX/* Use the new SVR4 lock format? */
  589. XX#undef    SVR4_LOCKS
  590. XX
  591. XX/* Does the status line scroll up on "magic cookie" terminals? */
  592. XX#undef    XMC_BROKE
  593. XX
  594. XX/* Does the alarm() system call work correctly with the wgetch() function? */
  595. XX#undef    WGETCH_BROKE
  596. XX
  597. XX/* Does the O_NDELAY mode tend to stick around when asked to leave? */
  598. XX#undef    O_NDELAY_BROKE
  599. XX
  600. XX/* The size of the serial port character buffer (or Stream buffer) */
  601. XX#define    CLIST_SIZ    64
  602. XX
  603. XX/* The size of the input buffer (should be about the same as CLIST_SIZ) */
  604. XX#define    INPUT_BUF    64
  605. XX
  606. XX/* The size of the output buffer (should be about one half INPUT_BUF) */
  607. XX#define    OUTPUT_BUF    32
  608. XX
  609. XX/* Does memmove() exist or is memcpy() well behaved when overlapping? */
  610. XX/* #define    MEMMOVE(a,b,c)    memmove(a,b,c) */
  611. XX#define    MEMMOVE(a,b,c)    memcpy(a,b,c)
  612. XX/* #define    MEMMOVE(a,b,c)    bcopy(b,a,c) */
  613. XX
  614. XX/* Does your Unix allow flip-flop between real and effective user IDs? */
  615. XX#undef    SETUID_BROKE
  616. XX
  617. XX/* Does your system have the strstr() function? */
  618. XX#undef    HAVE_STRSTR
  619. XX
  620. XX/* Does your system have the usleep() function? */
  621. XX#undef    HAVE_USLEEP
  622. XX
  623. XX/* Does your system have the truncate() system call? */
  624. XX#undef    HAVE_TRUNCATE
  625. XX
  626. XX/* typedef void SIG_TYPE; */
  627. XXtypedef int SIG_TYPE;
  628. XX
  629. XX#ifdef BSD
  630. XX#define    strchr    index
  631. XX#define    strrchr    rindex
  632. XX#endif /* BSD */
  633. SHAR_EOF
  634. if test 2524 -ne "`wc -c < 'config.h'`"
  635. then
  636. X    echo shar: "error transmitting 'config.h'" '(should have been 2524 characters)'
  637. fi
  638. fi
  639. exit 0
  640. X#    End of shell archive
  641. END_OF_FILE
  642. if test 19535 -ne `wc -c <'Unixpc.shar'`; then
  643.     echo shar: \"'Unixpc.shar'\" unpacked with wrong size!
  644. fi
  645. # end of 'Unixpc.shar'
  646. fi
  647. if test -f 'pcomm_cmd.c' -a "${1}" != "-c" ; then 
  648.   echo shar: Will not clobber existing file \"'pcomm_cmd.c'\"
  649. else
  650. echo shar: Extracting \"'pcomm_cmd.c'\" \(13550 characters\)
  651. sed "s/^X//" >'pcomm_cmd.c' <<'END_OF_FILE'
  652. X/*
  653. X * An external command facility for Pcomm.  All of the "sanity checking"
  654. X * is done at this end, so virtually no checking is done at Pcomm's end.
  655. X */
  656. X
  657. X#include <stdio.h>
  658. X#include <ctype.h>
  659. X#include "config.h"
  660. X#include "cmd.h"
  661. X
  662. X#ifdef BSD
  663. X#include <sys/file.h>
  664. X#else /* BSD */
  665. X#include <fcntl.h>
  666. X#endif /* BSD */
  667. X
  668. int cmd_ipc;
  669. X
  670. main(argc, argv)
  671. int argc;
  672. char *argv[];
  673. X{
  674. X    static char *cmds[] = {"SET", "QUERY", "IF", "DIAL", "REDIAL", "EXIT",
  675. X    "CLEAR_SCREEN", "CHG_DIR", "HANG_UP", "PRINTER", "MODEM_BREAK", "SEND",
  676. X    "RECEIVE", "SCREEN_DUMP", "DATA_LOG", 0};
  677. X    static char *set_args[] = {"BAUD", "PARITY", "DATA_BITS", "STOP_BITS",
  678. X    "DUPLEX", "AUX", "HOT_KEY", "ASCII_HOT", "FLOW_CTRL", "CR_IN",
  679. X    "CR_OUT", "LOGFILE", "DUMPFILE", "STRIP", "LOCAL_ECHO", "EXPAND",
  680. X    "CR_DELAY", "PACE", "CR_UP", "LF_UP", "TIMER", "CR_DN", "LF_DN", 0};
  681. X    static char *qry_args[] = {"TTY_NAME", "MODEM_NAME", 0};
  682. X    static char *if_args[] = {"CONNECTED", "LOG_STATUS", "PRINTER_STATUS",
  683. X    0};
  684. X    static char *xfer_args[] = {"XMODEM", "XMODEM_1K", "MODEM7", "YMODEM",
  685. X    "YMODEM_G", "ASCII", "EXT_1", "EXT_2", "EXT_3", 0};
  686. X    char *command, buf[256], *mkupper(), *arg1, *arg2, *s, *strchr();
  687. X    char *pcomm_cmd, *getenv();
  688. X    int cmd_num, i, arg_num, got_it;
  689. X    unsigned int ui;
  690. X    void send_cmd(), get_value(), exit(), cmd_exit();
  691. X
  692. X                    /* get the environmental variable */
  693. X    pcomm_cmd = getenv("PCOMM_CMD");
  694. X    if (argc == 1 || pcomm_cmd == NULL || *pcomm_cmd == '\0') {
  695. X        fprintf(stderr, "%s: This is a Pcomm support program.  It is intended for use inside\n", argv[0]);
  696. X        fprintf(stderr, "an auto-login shell script\n");
  697. X        exit(1);
  698. X    }
  699. X                    /* parse the command line */
  700. X    command = mkupper(argv[1]);
  701. X    if (argc > 2)
  702. X        arg1 = mkupper(argv[2]);
  703. X    else
  704. X        arg1 = "";
  705. X    if (argc > 3)
  706. X        arg2 = mkupper(argv[3]);
  707. X    else
  708. X        arg2 = "";
  709. X                    /* convert command to a number */
  710. X    cmd_num = 0;
  711. X    while (cmds[cmd_num] != NULL) {
  712. X        if (!strcmp(command, cmds[cmd_num]))
  713. X            break;
  714. X        cmd_num++;
  715. X    }
  716. X                    /* attach to the IPC channel */
  717. X    if ((cmd_ipc = ipc_attach(pcomm_cmd, O_RDWR)) < 0) {
  718. X        fprintf(stderr, "%s: Can't attach to IPC channel\n", argv[0]);
  719. X        exit(1);
  720. X    }
  721. X                    /* do it! */
  722. X    switch(cmd_num) {
  723. X        case SET:
  724. X            if (argc < 4) {
  725. X                fprintf(stderr, "%s: SET command requires 2 arguments\n", argv[0]);
  726. X                cmd_exit(1);
  727. X            }
  728. X                
  729. X            arg_num = 0;
  730. X            while (set_args[arg_num] != NULL) {
  731. X                if (!strcmp(arg1, set_args[arg_num]))
  732. X                    break;
  733. X                arg_num++;
  734. X            }
  735. X            switch(arg_num) {
  736. X                case BAUD:
  737. X                    ui = (unsigned int) atoi(arg2);
  738. X                    switch(ui) {
  739. X                        case 300:
  740. X                        case 1200:
  741. X                        case 2400:
  742. X                        case 4800:
  743. X                        case 9600:
  744. X                        case 19200:
  745. X                        case 38400:
  746. X                            break;
  747. X                        default:
  748. X                            fprintf(stderr, "%s: bad value '%s' for SET BAUD command\n", argv[0], argv[3]);
  749. X                            cmd_exit(1);
  750. X                    }
  751. X                    sprintf(buf, "%d", ui);
  752. X                    send_cmd(SET, BAUD, buf);
  753. X                    break;
  754. X                case PARITY:
  755. X                    if (strcmp(arg2, "EVEN") && strcmp(arg2, "ODD") && strcmp(arg2, "NONE")) {
  756. X                        fprintf(stderr, "%s: bad value '%s' for SET PARITY command\n", argv[0], argv[3]);
  757. X                        cmd_exit(1);
  758. X                    }
  759. X                    send_cmd(SET, PARITY, arg2);
  760. X                    break;
  761. X                case DATA_BITS:
  762. X                    i = atoi(arg2);
  763. X                    if (i != 7 && i != 8) {
  764. X                        fprintf(stderr, "%s: bad value '%s' for SET DATA_BITS command\n", argv[0], argv[3]);
  765. X                        cmd_exit(1);
  766. X                    }
  767. X                    sprintf(buf, "%d", i);
  768. X                    send_cmd(SET, DATA_BITS, buf);
  769. X                    break;
  770. X                case STOP_BITS:
  771. X                    i = atoi(arg2);
  772. X                    if (i != 1 && i != 2) {
  773. X                        fprintf(stderr, "%s: bad value '%s' for SET STOP_BITS command\n", argv[0], argv[3]);
  774. X                        cmd_exit(1);
  775. X                    }
  776. X                    sprintf(buf, "%d", i);
  777. X                    send_cmd(SET, STOP_BITS, buf);
  778. X                    break;
  779. X                case DUPLEX:
  780. X                    if (strcmp(arg2, "FULL") && strcmp(arg2, "HALF")) {
  781. X                        fprintf(stderr, "%s: bad value '%s' for SET DUPLEX command\n", argv[0], argv[3]);
  782. X                        cmd_exit(1);
  783. X                    }
  784. X                    send_cmd(SET, DUPLEX, arg2);
  785. X                    break;    
  786. X                case AUX:
  787. X                    send_cmd(SET, AUX, argv[3]);
  788. X                    break;
  789. X                case HOT_KEY:
  790. X                    i = atoi(arg2);
  791. X                    if (i <= 0 || i > 256) {
  792. X                        fprintf(stderr, "%s: bad value '%s' for SET HOT_KEY command\n", argv[0], argv[3]);
  793. X                        cmd_exit(1);
  794. X                    }
  795. X                    send_cmd(SET, HOT_KEY, arg2);
  796. X                    break;
  797. X                case ASCII_HOT:
  798. X                    send_cmd(SET, ASCII_HOT, argv[3]);
  799. X                    break;
  800. X                case FLOW_CTRL:
  801. X                    if (strcmp(arg2, "XON/XOFF") && strcmp(arg2, "NONE")) {
  802. X                        fprintf(stderr, "%s: bad value '%s' for SET FLOW_CTRL command\n", argv[0], argv[3]);
  803. X                        cmd_exit(1);
  804. X                    }
  805. X                    send_cmd(SET, FLOW_CTRL, arg2);
  806. X                    break;
  807. X                case CR_IN:    
  808. X                    if (strcmp(arg2, "CR") && strcmp(arg2, "CR/LF")) {
  809. X                        fprintf(stderr, "%s: bad value '%s' for SET CR_IN command\n", argv[0], argv[3]);
  810. X                        cmd_exit(1);
  811. X                    }
  812. X                    send_cmd(SET, CR_IN, arg2);
  813. X                    break;
  814. X                case CR_OUT:
  815. X                    if (strcmp(arg2, "CR") && strcmp(arg2, "CR/LF")) {
  816. X                        fprintf(stderr, "%s: bad value '%s' for SET CR_OUT command\n", argv[0], argv[3]);
  817. X                        cmd_exit(1);
  818. X                    }
  819. X                    send_cmd(SET, CR_OUT, arg2);
  820. X                    break;
  821. X                case LOGFILE:
  822. X                    send_cmd(SET, LOGFILE, argv[3]);
  823. X                    break;
  824. X                case DUMPFILE:
  825. X                    send_cmd(SET, DUMPFILE, argv[3]);
  826. X                    break;
  827. X                case STRIP:    
  828. X                    if (strcmp(arg2, "YES") && strcmp(arg2, "NO")) {
  829. X                        fprintf(stderr, "%s: bad value '%s' for SET STRIP command\n", argv[0], argv[3]);
  830. X                        cmd_exit(1);
  831. X                    }
  832. X                    send_cmd(SET, STRIP, arg2);
  833. X                    break;
  834. X                case LOCAL_ECHO:    
  835. X                    if (strcmp(arg2, "YES") && strcmp(arg2, "NO")) {
  836. X                        fprintf(stderr, "%s: bad value '%s' for SET LOCAL_ECHO command\n", argv[0], argv[3]);
  837. X                        cmd_exit(1);
  838. X                    }
  839. X                    send_cmd(SET, LOCAL_ECHO, arg2);
  840. X                    break;
  841. X                case EXPAND:
  842. X                    if (strcmp(arg2, "YES") && strcmp(arg2, "NO")) {
  843. X                        fprintf(stderr, "%s: bad value '%s' for SET EXPAND command\n", argv[0], argv[3]);
  844. X                        cmd_exit(1);
  845. X                    }
  846. X                    send_cmd(SET, EXPAND, arg2);
  847. X                    break;
  848. X                case CR_DELAY:
  849. X                    i = atoi(arg2);
  850. X                    if (i != 0 && i != 100 && i != 150) {
  851. X                        fprintf(stderr, "%s: bad value '%s' for SET CR_DELAY command\n", argv[0], argv[3]);
  852. X                        cmd_exit(1);
  853. X                    }
  854. X                    sprintf(buf, "%d", i);
  855. X                    send_cmd(SET, CR_DELAY, buf);
  856. X                    break;
  857. X                case PACE:
  858. X                    if (strcmp(arg2, "YES") && strcmp(arg2, "NO")) {
  859. X                        fprintf(stderr, "%s: bad value '%s' for SET PACE command\n", argv[0], argv[3]);
  860. X                        cmd_exit(1);
  861. X                    }
  862. X                    send_cmd(SET, PACE, arg2);
  863. X                    break;
  864. X                case CR_UP:
  865. X                    if (strcmp(arg2, "NONE") && strcmp(arg2, "ADD_LF") && strcmp(arg2, "STRIP")) {
  866. X                        fprintf(stderr, "%s: bad value '%s' for SET CR_UP command\n", argv[0], argv[3]);
  867. X                        cmd_exit(1);
  868. X                    }
  869. X                    send_cmd(SET, CR_UP, arg2);
  870. X                    break;
  871. X                case LF_UP:
  872. X                    if (strcmp(arg2, "NONE") && strcmp(arg2, "ADD_CR") && strcmp(arg2, "STRIP")) {
  873. X                        fprintf(stderr, "%s: bad value '%s' for SET LF_UP command\n", argv[0], argv[3]);
  874. X                        cmd_exit(1);
  875. X                    }
  876. X                    send_cmd(SET, LF_UP, arg2);
  877. X                    break;
  878. X                case TIMER:
  879. X                    i = atoi(arg2);
  880. X                    if (i < 5 || i > 150) {
  881. X                        fprintf(stderr, "%s: bad value '%s' for SET TIMER command\n", argv[0], argv[3]);
  882. X                        cmd_exit(1);
  883. X                    }
  884. X                    sprintf(buf, "%d", i);
  885. X                    send_cmd(SET, CR_DN, buf);
  886. X                    break;
  887. X                case CR_DN:
  888. X                    if (strcmp(arg2, "NONE") && strcmp(arg2, "ADD_LF") && strcmp(arg2, "STRIP")) {
  889. X                        fprintf(stderr, "%s: bad value '%s' for SET CR_DN command\n", argv[0], argv[3]);
  890. X                        cmd_exit(1);
  891. X                    }
  892. X                    send_cmd(SET, CR_DN, arg2);
  893. X                    break;
  894. X                case LF_DN:    
  895. X                    if (strcmp(arg2, "NONE") && strcmp(arg2, "ADD_CR") && strcmp(arg2, "STRIP")) {
  896. X                        fprintf(stderr, "%s: bad value '%s' for SET LF_DN command\n", argv[0], argv[3]);
  897. X                        cmd_exit(1);
  898. X                    }
  899. X                    send_cmd(SET, LF_DN, arg2);
  900. X                    break;
  901. X                default:
  902. X                    fprintf(stderr, "%s: Illegal argument '%s' for SET command\n", argv[0], argv[2]);
  903. X                    cmd_exit(1);
  904. X                    break;
  905. X            }
  906. X            break;
  907. X        case QUERY:        /* the QUERY commands */
  908. X            if (argc < 3) {
  909. X                fprintf(stderr, "%s: QUERY command requires an argument\n", argv[0]);
  910. X                cmd_exit(1);
  911. X            }
  912. X                
  913. X            arg_num = 0;
  914. X            while (qry_args[arg_num] != NULL) {
  915. X                if (!strcmp(arg1, qry_args[arg_num]))
  916. X                    break;
  917. X                arg_num++;
  918. X            }
  919. X
  920. X            switch(arg_num) {
  921. X                case TTY_NAME:
  922. X                    send_cmd(QUERY, TTY_NAME, "dummy");
  923. X                    get_value();
  924. X                    break;
  925. X                case MODEM_NAME:
  926. X                    send_cmd(QUERY, MODEM_NAME, "dummy");
  927. X                    get_value();
  928. X                    break;
  929. X                default:
  930. X                    fprintf(stderr, "%s: Illegal argument '%s' for QUERY command\n", argv[0], argv[2]);
  931. X                    cmd_exit(1);
  932. X                    break;
  933. X            }
  934. X            break;
  935. X        case IF:        /* the IF commands */
  936. X            if (argc < 3) {
  937. X                fprintf(stderr, "%s: IF command requires an argument\n", argv[0]);
  938. X                cmd_exit(1);
  939. X            }
  940. X                
  941. X            arg_num = 0;
  942. X            while (if_args[arg_num] != NULL) {
  943. X                if (!strcmp(arg1, if_args[arg_num]))
  944. X                    break;
  945. X                arg_num++;
  946. X            }
  947. X
  948. X            switch(arg_num) {
  949. X                case CONNECTED:
  950. X                    send_cmd(IF, CONNECTED, "dummy");
  951. X                    break;
  952. X                case LOG_STATUS:
  953. X                    send_cmd(IF, LOG_STATUS, "dummy");
  954. X                    break;
  955. X                case PRINTER_STATUS:
  956. X                    send_cmd(IF, PRINTER_STATUS, "dummy");
  957. X                    break;
  958. X                default:
  959. X                    fprintf(stderr, "%s: Illegal argument '%s' for IF command\n", argv[0], argv[2]);
  960. X                    cmd_exit(1);
  961. X                    break;
  962. X            }
  963. X            break;
  964. X        case DIAL:
  965. X            if (argc < 3) {
  966. X                fprintf(stderr, "%s: DIAL command requires an argument\n", argv[0]);
  967. X                cmd_exit(1);
  968. X            }
  969. X            if (!strcmp(arg1, "MANUAL")) {
  970. X                if (argc < 4) {
  971. X                    fprintf(stderr, "%s: DIAL MANUAL command requires an argument\n", argv[0]);
  972. X                    cmd_exit(1);
  973. X                }
  974. X                send_cmd(DIAL, 1, argv[3]);
  975. X            }
  976. X            else {
  977. X                if (s = strchr("+-@#", *argv[2]))
  978. X                    i = atoi(++s);
  979. X                else
  980. X                    i = atoi(argv[2]);
  981. X                if (i < 1 || i > 100) {
  982. X                    fprintf(stderr, "%s: bad value '%s' for DIAL command\n", argv[0], argv[2]);
  983. X                    cmd_exit(1);
  984. X                }
  985. X                send_cmd(DIAL, 0, argv[2]);
  986. X            }
  987. X            break;
  988. X        case REDIAL:
  989. X            if (argc < 3) {
  990. X                fprintf(stderr, "%s: REDIAL command requires at least 1 argument\n", argv[0]);
  991. X                cmd_exit(1);
  992. X            }
  993. X            send_cmd(REDIAL, 0, argv[2]);
  994. X            break;
  995. X        case EXIT:
  996. X            send_cmd(EXIT, 0, "dummy");
  997. X            /*
  998. X             * Don't wait for a return code... Pcomm won't be
  999. X             * around to send it!  So, assume it got there OK.
  1000. X             */
  1001. X            cmd_exit(0);
  1002. X            break;
  1003. X        case CLEAR_SCREEN:
  1004. X            send_cmd(CLEAR_SCREEN, 0, "dummy");
  1005. X            break;
  1006. X        case CHG_DIR:
  1007. X            if (argc < 3) {
  1008. X                fprintf(stderr, "%s: CHG_DIR command requires an argument\n", argv[0]);
  1009. X                cmd_exit(1);
  1010. X            }
  1011. X            send_cmd(CHG_DIR, 0, argv[2]);
  1012. X            break;
  1013. X        case HANG_UP:
  1014. X            send_cmd(HANG_UP, 0, "dummy");
  1015. X            break;
  1016. X        case PRINTER:
  1017. X            if (argc < 3) {
  1018. X                fprintf(stderr, "%s: PRINTER command requires an argument\n", argv[0]);
  1019. X                cmd_exit(1);
  1020. X            }
  1021. X            if (strcmp(arg1, "ON") && strcmp(arg1, "OFF")) {
  1022. X                fprintf(stderr, "%s: bad value '%s' for PRINTER command\n", argv[0], argv[2]);
  1023. X                cmd_exit(1);
  1024. X            }
  1025. X            if (!strcmp(arg1, "ON"))
  1026. X                send_cmd(PRINTER, 1, "dummy");
  1027. X            else
  1028. X                send_cmd(PRINTER, 0, "dummy");
  1029. X            break;
  1030. X        case MODEM_BREAK:
  1031. X            send_cmd(MODEM_BREAK, 0, "dummy");
  1032. X            break;
  1033. X        case SEND:
  1034. X            if (argc < 4) {
  1035. X                fprintf(stderr, "%s: SEND command requires 2 arguments\n", argv[0]);
  1036. X                cmd_exit(1);
  1037. X            }
  1038. X            arg_num = 0;
  1039. X            got_it = 0;
  1040. X            while (xfer_args[arg_num] != NULL) {
  1041. X                if (!strcmp(xfer_args[arg_num], arg1)) {
  1042. X                    got_it++;
  1043. X                    break;
  1044. X                }
  1045. X                arg_num++;
  1046. X            }
  1047. X            if (!got_it) {
  1048. X                fprintf(stderr, "%s: Illegal argument '%s' for SEND command\n", argv[0], argv[2]);
  1049. X                cmd_exit(1);
  1050. X            }
  1051. X            send_cmd(SEND, ++arg_num, argv[3]);
  1052. X            break;
  1053. X        case RECEIVE:
  1054. X            if (argc < 3) {
  1055. X                fprintf(stderr, "%s: RECEIVE command requires at least 1 argument\n", argv[0]);
  1056. X                cmd_exit(1);
  1057. X            }
  1058. X            arg_num = 0;
  1059. X            got_it = 0;
  1060. X            while (xfer_args[arg_num] != NULL) {
  1061. X                if (!strcmp(xfer_args[arg_num], arg1)) {
  1062. X                    got_it++;
  1063. X                    break;
  1064. X                }
  1065. X                arg_num++;
  1066. X            }
  1067. X            if (!got_it) {
  1068. X                fprintf(stderr, "%s: Illegal argument '%s' for RECEIVE command\n", argv[0], argv[2]);
  1069. X                cmd_exit(1);
  1070. X            }
  1071. X            if (argc < 4)
  1072. X                send_cmd(RECEIVE, ++arg_num, "dummy");
  1073. X            else
  1074. X                send_cmd(RECEIVE, ++arg_num, argv[3]);
  1075. X            break;
  1076. X        case SCREEN_DUMP:
  1077. X            send_cmd(SCREEN_DUMP, 0, "dummy");
  1078. X            break;
  1079. X        case DATA_LOG:
  1080. X            if (!strcmp(arg1, "ON"))
  1081. X                send_cmd(DATA_LOG, 1, "dummy");
  1082. X            else
  1083. X                send_cmd(DATA_LOG, 0, "dummy");
  1084. X            break;
  1085. X        default:
  1086. X            fprintf(stderr, "%s: Illegal command '%s'\n", argv[0], argv[1]);
  1087. X            cmd_exit(1);
  1088. X            break;
  1089. X    }
  1090. X                    /* get the return status */
  1091. X    if (ipc_read(cmd_ipc, buf, 256)) {
  1092. X#ifndef sparc
  1093. X        fprintf(stderr, "Can't read from IPC\n");
  1094. X#endif /* sparc */
  1095. X        cmd_exit(1);
  1096. X    }
  1097. X    cmd_exit(atoi(buf));
  1098. X}
  1099. X
  1100. X/*
  1101. X * Copy and convert a string to all upper case 
  1102. X */
  1103. X
  1104. char *
  1105. mkupper(string)
  1106. char *string;
  1107. X{
  1108. X    int i;
  1109. X    char buf[80], *ans, *strcpy(), *malloc();
  1110. X    void exit();
  1111. X
  1112. X    i = 0;
  1113. X    while (*string != '\0') {
  1114. X        if (islower(*string))
  1115. X            buf[i++] = toupper(*string);
  1116. X        else
  1117. X            buf[i++] = *string;
  1118. X        string++;
  1119. X        if (i == 79)
  1120. X            break;
  1121. X    }
  1122. X    buf[i] = '\0';
  1123. X    if ((ans = malloc((unsigned int) strlen(buf)+1)) == NULL) {
  1124. X        fprintf(stderr, "out of memory!\n");
  1125. X        exit(1);
  1126. X    }
  1127. X    strcpy(ans, buf);
  1128. X    
  1129. X    return(ans);
  1130. X}
  1131. X
  1132. X/*
  1133. X * Get a return value from a command, (and therefore exit prematurely).
  1134. X */
  1135. X
  1136. void 
  1137. get_value()
  1138. X{
  1139. X    char *s, *strchr(), buf[256];
  1140. X    void cmd_exit();
  1141. X
  1142. X    if (ipc_read(cmd_ipc, buf, 256)) {
  1143. X        fprintf(stderr, "Can't read from IPC\n");
  1144. X        cmd_exit(1);
  1145. X    }
  1146. X
  1147. X    if (s = strchr(buf, '\n'))
  1148. X        *++s = '\0';
  1149. X
  1150. X    printf("%s", buf);
  1151. X    cmd_exit(0);
  1152. X}
  1153. X
  1154. X/*
  1155. X * Send a command to the Pcomm process
  1156. X */
  1157. X
  1158. void
  1159. send_cmd(cmd, arg1, arg2)
  1160. int cmd, arg1;
  1161. char *arg2;
  1162. X{
  1163. X    char buf[256];
  1164. X    void cmd_exit();
  1165. X
  1166. X    sprintf(buf, "%d %d %249.249s\n", cmd, arg1, arg2);
  1167. X    if (ipc_write(cmd_ipc, buf, 256)) {
  1168. X        fprintf(stderr, "Can't write to IPC\n");
  1169. X        cmd_exit(1);
  1170. X    }
  1171. X    return;
  1172. X}
  1173. X
  1174. X/*
  1175. X * Clean up and go home...
  1176. X */
  1177. X
  1178. void
  1179. cmd_exit(n)
  1180. int n;
  1181. X{
  1182. X    void exit();
  1183. X
  1184. X    ipc_detach(cmd_ipc);
  1185. X    exit(n);
  1186. X}
  1187. X
  1188. X#define MAIN
  1189. X#include IPC
  1190. END_OF_FILE
  1191. if test 13550 -ne `wc -c <'pcomm_cmd.c'`; then
  1192.     echo shar: \"'pcomm_cmd.c'\" unpacked with wrong size!
  1193. fi
  1194. # end of 'pcomm_cmd.c'
  1195. fi
  1196. if test -f 'port.c' -a "${1}" != "-c" ; then 
  1197.   echo shar: Will not clobber existing file \"'port.c'\"
  1198. else
  1199. echo shar: Extracting \"'port.c'\" \(13371 characters\)
  1200. sed "s/^X//" >'port.c' <<'END_OF_FILE'
  1201. X/*
  1202. X * Routines to get or release a TTY port.
  1203. X */
  1204. X
  1205. X#define MAX_PID    30000
  1206. X#define TRUE    1
  1207. X#define FALSE    0
  1208. X
  1209. X#include <stdio.h>
  1210. X#include <errno.h>
  1211. X#include "config.h"
  1212. X#include "dial_dir.h"
  1213. X#include "modem.h"
  1214. X#include "status.h"
  1215. X
  1216. X#ifdef BSD
  1217. X#include <sys/file.h>
  1218. X#else /* BSD */
  1219. X#include <fcntl.h>
  1220. X#endif /* BSD */
  1221. X
  1222. X#ifdef UNIXPC
  1223. X#include <sys/phone.h>
  1224. X#endif /* UNIXPC */
  1225. X
  1226. X#ifdef XENIX_LOCKS
  1227. X#include <ctype.h>
  1228. X#endif /* XENIX_LOCKS */
  1229. X
  1230. X#ifdef SVR4_LOCKS
  1231. X#include <sys/types.h>
  1232. X#include <sys/stat.h>
  1233. X#include <sys/mkdev.h>
  1234. X#endif /* SVR4_LOCKS */
  1235. X
  1236. static int getty_status = 0;
  1237. static char *lock_path = NULL;
  1238. static int set_getty(), checklock(), ck_speed();
  1239. X
  1240. X/*
  1241. X * Finds a free (or requested) serial port.  Creates a lock file to hold
  1242. X * for our use.  Loads the modem database.  A non-zero return code means
  1243. X * all ports (or the requested port) are busy.
  1244. X */
  1245. X
  1246. int
  1247. get_port()
  1248. X{
  1249. X    extern int fd, errno;
  1250. X    register int i;
  1251. X    int j, k, lfd, list[NUM_TTY], cmask, aux,  progpid, keep_it, trash_it;
  1252. X    char file[80], buf[80], message[80], *str_rep();
  1253. X    void error_win(), line_set(), release_port(), send_str(), ipc_update();
  1254. X#ifdef XENIX_LOCKS
  1255. X    char *last_c;
  1256. X#endif /* XENIX_LOCKS */
  1257. X
  1258. X    aux = chk_aux(dir->aux[dir->d_cur]);
  1259. X    /*
  1260. X     * If you already have a port, see if it is good enough for the
  1261. X     * current request.
  1262. X     */
  1263. X    if (fd != -1) {
  1264. X        keep_it = 0;
  1265. X        trash_it = 0;
  1266. X                    /* got the requested TTY ? */
  1267. X        if (aux == IS_TTY) {
  1268. X            if (!strcmp(dir->aux[dir->d_cur], modem->tty[modem->t_cur]))
  1269. X                keep_it++;
  1270. X            else
  1271. X                trash_it++;
  1272. X        }
  1273. X                    /* got the requested Modem? */
  1274. X        if (aux == IS_MODEM) {
  1275. X            if (!strcmp(dir->aux[dir->d_cur], modem->tname[modem->t_cur]))
  1276. X                keep_it++;
  1277. X            else
  1278. X                trash_it++;
  1279. X        }
  1280. X                    /* can it handle the request baud? */
  1281. X        if (ck_speed(modem->t_cur, dir->baud[dir->d_cur]))
  1282. X            keep_it++;
  1283. X
  1284. X        if (keep_it && !trash_it) {
  1285. X            /*
  1286. X             * Reset the line parameters, because baud rate,
  1287. X             * etc. may have changed.
  1288. X             */
  1289. X            if (dir->d_cur != 0) {
  1290. X                dir->baud[0] = dir->baud[dir->d_cur];
  1291. X                dir->parity[0] = dir->parity[dir->d_cur];
  1292. X                dir->data_bits[0] = dir->data_bits[dir->d_cur];
  1293. X                dir->stop_bits[0] = dir->stop_bits[dir->d_cur];
  1294. X                dir->duplex[0] = dir->duplex[dir->d_cur];
  1295. X                dir->aux[0] = str_rep(dir->aux[0], dir->aux[dir->d_cur]);
  1296. X            }
  1297. X            line_set();
  1298. X            return(0);
  1299. X        }
  1300. X    }
  1301. X
  1302. X    /*
  1303. X     * If we have a script running, we can't swap TTY ports, because
  1304. X     * we've already forked the child process with "fd" as an open
  1305. X     * file descriptor.  Changing "fd" in the parent won't change the
  1306. X     * "fd" in the child.
  1307. X     */
  1308. X    if (fd != -1 && status->dup_fd != -1) {
  1309. X        error_win(0, "Can't change TTYs while a script is being played", "dial aborted");
  1310. X        return(1);
  1311. X    }
  1312. X
  1313. X    release_port(VERBOSE);
  1314. X
  1315. X    list[0] = -1;
  1316. X    /*
  1317. X     * See if you want a specific TTY port.  If the auxiliary field in
  1318. X     * the dialing directory is a valid device name, then use that TTY.
  1319. X     */
  1320. X    if (aux == IS_TTY) {
  1321. X        for (i=0; i<modem->t_entries; i++) {
  1322. X                    /* and it exists in modem database */
  1323. X            if (!strcmp(dir->aux[dir->d_cur], modem->tty[i])) {
  1324. X                list[0] = i;
  1325. X                list[1] = -1;
  1326. X                break;
  1327. X            }
  1328. X        }
  1329. X                    /* oops... we don't know that port */
  1330. X        if (list[0] == -1) {
  1331. X            sprintf(message, "Device \"%s\" in the auxiliary field doesn't exist in", dir->aux[dir->d_cur]);
  1332. X            sprintf(buf, "modem/TTY database \"%s\"", modem->m_path);
  1333. X            error_win(0, message, buf);
  1334. X            return(1);
  1335. X        }
  1336. X    }
  1337. X
  1338. X    /*
  1339. X     * If we haven't specified a port, create a list of acceptable TTYs.
  1340. X     * It searches the modem database for the requested baud rate.
  1341. X     */
  1342. X    k = 0;
  1343. X    if (list[0] == -1) {
  1344. X        for (i=0; i<modem->t_entries; i++) {
  1345. X                    /* skip ports with no modems */
  1346. X            if (!strcmp(modem->tname[i], "DIRECT"))
  1347. X                continue;
  1348. X
  1349. X                    /* weed out the modems we don't want */
  1350. X            if (aux == IS_MODEM) {
  1351. X                if (strcmp(modem->tname[i], dir->aux[dir->d_cur]))
  1352. X                    continue;
  1353. X            }
  1354. X                    /* can handle requested baud rate? */
  1355. X            if (ck_speed(i, dir->baud[dir->d_cur]))
  1356. X                list[k++] = i;
  1357. X        }
  1358. X                    /* the end of list marker */
  1359. X        list[k] = -1;
  1360. X    }
  1361. X                    /* empty list? */
  1362. X    if (list[0] == -1) {
  1363. X        if (aux == IS_MODEM) {
  1364. X            sprintf(message, "The requested modem \"%s\" does not exists", dir->aux[dir->d_cur]);
  1365. X            sprintf(buf, "or does not support the requested baud rate %d", dir->baud[dir->d_cur]);
  1366. X        }
  1367. X        else {
  1368. X            sprintf(message, "No modem at a %d baud rating exists in the", dir->baud[dir->d_cur]);
  1369. X            sprintf(buf, "modem database \"%s\"", modem->m_path);
  1370. X        }
  1371. X        error_win(0, message, buf);
  1372. X        return(1);
  1373. X    }
  1374. X                    /* check the list for a free port */
  1375. X    i = 0;
  1376. X    while (list[i] != -1) {
  1377. X                    /* create a lock file name */
  1378. X#ifdef SVR4_LOCKS
  1379. X        struct stat sbuf;
  1380. X        sprintf(buf, "/dev/%s", modem->tty[list[i]]);
  1381. X        stat(buf, &sbuf);
  1382. X        sprintf(file, "%s/LK.%03d.%03d.%03d", LOCK_DIR, major(sbuf.st_dev), major(sbuf.st_rdev), minor(sbuf.st_rdev));
  1383. X#else /* SVR4_LOCKS */
  1384. X        sprintf(file, "%s/LCK..%s", LOCK_DIR, modem->tty[list[i]]);
  1385. X#endif /* SVR4_LOCKS */
  1386. X
  1387. X#ifdef XENIX_LOCKS
  1388. X        last_c = file + strlen(file)-1;
  1389. X        if (isupper(*last_c))
  1390. X            *last_c = tolower(*last_c);
  1391. X#endif /* XENIX_LOCKS */
  1392. X
  1393. X#ifdef DEBUG
  1394. X        fprintf(stderr, "get_port: checking '/dev/%s'\n", modem->tty[list[i]]);
  1395. X#endif /* DEBUG */
  1396. X
  1397. X                    /* no lock exists or it is dead */
  1398. X        if (checklock(file)) {
  1399. X            getty_status = set_getty(modem->tty[list[i]], FALSE);
  1400. X
  1401. X            cmask = umask(0);
  1402. X            if ((lfd = open(file, O_CREAT|O_EXCL|O_WRONLY, 0666)) < 0) {
  1403. X                if (getty_status)
  1404. X                    set_getty(modem->tty[list[i]], TRUE);
  1405. X                sprintf(buf, "\"%s\"", file);
  1406. X                error_win(0, "Can't create the lockfile", buf);
  1407. X                return(1);
  1408. X            }
  1409. X            umask(cmask);
  1410. X            progpid = getpid();
  1411. X#ifdef ASCII_PID
  1412. X            sprintf(buf, "%10d\n", progpid);
  1413. X            write(lfd, buf, 11);
  1414. X#else /* ASCII_PID */
  1415. X            write(lfd, (char *) &progpid, sizeof(int));
  1416. X#endif /* ASCII_PID */
  1417. X            close(lfd);
  1418. X                    /* store the new values */
  1419. X            lock_path = str_rep(lock_path, file);
  1420. X            modem->t_cur = list[i];
  1421. X
  1422. X                    /* load the modem data base */
  1423. X            modem->m_cur = -1;
  1424. X            for (j=0; j<modem->m_entries; j++) {
  1425. X                if (!strcmp(modem->tname[modem->t_cur], modem->mname[j])) {
  1426. X                    modem->m_cur = j;
  1427. X                    break;
  1428. X                }
  1429. X            }
  1430. X            if (modem->m_cur == -1) {
  1431. X                sprintf(buf, "Modem name \"%s\" in TTY database",
  1432. X                 modem->tname[modem->t_cur]);
  1433. X                error_win(0, buf, "does not exist in modem database");
  1434. X                modem->t_cur = -1;
  1435. X                return(1);
  1436. X            }
  1437. X
  1438. X                    /* open the device (ignore DCD) */
  1439. X            sprintf(buf, "/dev/%s", modem->tty[modem->t_cur]);
  1440. X            if ((fd = open(buf, O_RDWR|O_NDELAY)) < 0) {
  1441. X                if (getty_status)
  1442. X                    set_getty(modem->tty[modem->t_cur], TRUE);
  1443. X                /*
  1444. X                 * For systems that use flock() instead of
  1445. X                 * UUCP lock files
  1446. X                 */
  1447. X                if (errno == EBUSY) {
  1448. X                    unlink(lock_path);
  1449. X                    modem->m_cur = -1;
  1450. X                    modem->t_cur = -1;
  1451. X                    i++;
  1452. X                    continue;
  1453. X                }
  1454. X                sprintf(file, "Can't open port \"%s\" for read and write", buf);
  1455. X                error_win(0, file, "");
  1456. X                modem->m_cur = -1;
  1457. X                modem->t_cur = -1;
  1458. X                return(1);
  1459. X            }
  1460. X                    /* change line settings */
  1461. X            if (dir->d_cur != 0) {
  1462. X                dir->baud[0] = dir->baud[dir->d_cur];
  1463. X                dir->parity[0] = dir->parity[dir->d_cur];
  1464. X                dir->data_bits[0] = dir->data_bits[dir->d_cur];
  1465. X                dir->stop_bits[0] = dir->stop_bits[dir->d_cur];
  1466. X                dir->duplex[0] = dir->duplex[dir->d_cur];
  1467. X                dir->aux[0] = str_rep(dir->aux[0], dir->aux[dir->d_cur]);
  1468. X            }
  1469. X            line_set();
  1470. X
  1471. X                    /* turn off the O_NDELAY setting */
  1472. X            tty_noblock(fd, FALSE);
  1473. X
  1474. X            /*
  1475. X             * For some reason, the following witchcraft is
  1476. X             * often required.
  1477. X             */
  1478. X#ifdef O_NDELAY_BROKE
  1479. X            close(open(buf, O_RDWR));
  1480. X#endif /* O_NDELAY_BROKE */
  1481. X
  1482. X                    /* initialize the modem */
  1483. X            send_str(modem->init[modem->m_cur], SLOW);
  1484. X                    /* update the poll()/select() values */
  1485. X            ipc_update(fd, status->cmd_ipc);
  1486. X            return(0);
  1487. X        }
  1488. X        i++;
  1489. X    }
  1490. X    if (aux == IS_TTY) {
  1491. X        sprintf(buf, "The requested port \"%s\", is busy", modem->tty[modem->t_cur]);
  1492. X        error_win(0, buf, "Try again later");
  1493. X    }
  1494. X    else
  1495. X        error_win(0, "All ports are busy now, try again later", "");
  1496. X    return(1);
  1497. X}
  1498. X
  1499. X/*
  1500. X * Release the port.  Closes the file descriptor and removes the
  1501. X * lock file
  1502. X */
  1503. X
  1504. void
  1505. release_port(verbose)
  1506. int verbose;
  1507. X{
  1508. X    extern int fd;
  1509. X    extern char *null_ptr;
  1510. X    char buf[80];
  1511. X    void free_ptr(), hang_up(), reset_line(), error_win(), ipc_update();
  1512. X
  1513. X    /*
  1514. X     * The modem structure can't be guaranteed to exist yet.  For example,
  1515. X     * an error in reading one of the other support files would cause
  1516. X     * this routine to be used before the MODEM structure gets allocated.
  1517. X     */
  1518. X    if (modem == NULL)
  1519. X        return;
  1520. X                    /* close the port */
  1521. X    if (fd != -1) {
  1522. X        tty_flush(fd, 2);
  1523. X        /*
  1524. X         * Since HUPCL is set, the close() should drop the DTR and
  1525. X         * hang up the modem (provided you've got the modem to
  1526. X         * respond to DTR).  Since this is not guaranteed, we send
  1527. X         * the hang_up string first.
  1528. X         */
  1529. X        hang_up(verbose);
  1530. X        reset_line();
  1531. X        close(fd);
  1532. X    }
  1533. X                    /* remove the lock */
  1534. X    if (lock_path != NULL && *lock_path != '\0') {
  1535. X        if (unlink(lock_path)) {
  1536. X            sprintf(buf, "\"%s\"", lock_path);
  1537. X            error_win(0, "Can't remove the lock file", buf);
  1538. X        }
  1539. X        free_ptr(lock_path);
  1540. X        lock_path = null_ptr;
  1541. X    }
  1542. X                    /* turn the getty back on? */
  1543. X    if (getty_status && modem->t_cur != -1)
  1544. X        set_getty(modem->tty[modem->t_cur], TRUE);
  1545. X                    /* clean up the structure */
  1546. X    fd = -1;
  1547. X    modem->m_cur = -1;
  1548. X    modem->t_cur = -1;
  1549. X    ipc_update(fd, status->cmd_ipc);
  1550. X    return;
  1551. X}
  1552. X
  1553. X/*
  1554. X * Turn the /etc/getty on or off for the specified port.  A non-zero return
  1555. X * code means that the getty was on.  Systems with uugetty() or dedicated
  1556. X * dialout ports won't need this routine.
  1557. X */
  1558. X
  1559. X/* ARGSUSED */
  1560. static int
  1561. set_getty(tty, on)
  1562. char *tty;
  1563. int on;
  1564. X{
  1565. X#ifdef UNIXPC
  1566. X    int i, ret_code;
  1567. X    char buf[40];
  1568. X    unsigned int sleep();
  1569. X                    /* the last three characters */
  1570. X    i = strlen(tty) -3;
  1571. X
  1572. X    ret_code = 0;
  1573. X    if (on) {
  1574. X        sprintf(buf, "setgetty %s 1", tty+i);
  1575. X        system(buf);
  1576. X    }
  1577. X    else {
  1578. X        sprintf(buf, "setgetty %s 0", tty+i);
  1579. X        if (system(buf) == 512)
  1580. X            ret_code++;
  1581. X        sleep(1);
  1582. X    }
  1583. X    return(ret_code);
  1584. X#else /* UNIXPC */
  1585. X    /*
  1586. X     * If you don't have one of these cute little routines, you
  1587. X     * might wanna write one.  It should check for an existing lock
  1588. X     * file, edit the /etc/inittab file, and issue an init -q.
  1589. X     * The return code should tell if there was a getty or not.
  1590. X     * Obviously the program would be suid to root.
  1591. X     */
  1592. X    return(0);
  1593. X#endif /* UNIXPC */
  1594. X}
  1595. X
  1596. X/*
  1597. X * Check the lock file for a valid pid value.  Error conditions such
  1598. X * as not being able to open the lock file or not being able to interpret
  1599. X * the contents of the lock file cause the code to assume that the lock
  1600. X * file is valid.  Let the user worry about weird special cases.  A 
  1601. X * non-zero return code means the lock is dead or doesn't exist.
  1602. X */
  1603. X
  1604. static int
  1605. checklock(lockfile)
  1606. char *lockfile;
  1607. X{
  1608. X    extern int errno;
  1609. X    int lfd, lckpid;
  1610. X    unsigned int sleep();
  1611. X#ifdef ASCII_PID
  1612. X    int n;
  1613. X    char buf[40];
  1614. X#endif /* ASCII_PID */
  1615. X                    /* doesn't exist */
  1616. X    if (access(lockfile, 0))
  1617. X        return(1);
  1618. X                    /* can't open the lock file */
  1619. X    if ((lfd = open(lockfile, 0)) < 0)
  1620. X        return(0);
  1621. X
  1622. X#ifdef ASCII_PID
  1623. X    if ((n = read(lfd, buf, 40)) <= 0) {
  1624. X        close(lfd);
  1625. X        return(0);
  1626. X    }
  1627. X    close(lfd);
  1628. X    buf[n--] = '\0';
  1629. X    lckpid = atoi(buf);
  1630. X#else /* ASCII_PID */
  1631. X    if (read(lfd, (char *) &lckpid, sizeof(int)) != sizeof(int)) {
  1632. X        close(lfd);
  1633. X        return(0);
  1634. X    }
  1635. X    close(lfd);
  1636. X#endif /* ASCII_PID */
  1637. X                    /* invalid pid? */
  1638. X    if (lckpid <= 0 || lckpid > MAX_PID)
  1639. X        return(0);
  1640. X
  1641. X    if ((kill(lckpid, 0) == -1) && (errno == ESRCH)) {
  1642. X        /*
  1643. X         * If the kill was unsuccessful due to an ESRCH error,
  1644. X         * that means the process is no longer active and the
  1645. X         * lock file can be safely removed.
  1646. X         */
  1647. X        unlink(lockfile);
  1648. X        sleep(1);
  1649. X        return(1);
  1650. X    }
  1651. X    /*
  1652. X     * If the kill() was successful, that means the process must
  1653. X     * still be active.
  1654. X     */
  1655. X    return(0);
  1656. X}
  1657. X
  1658. X/*
  1659. X * Check to see if the desired baud rate can be handled by the modem.
  1660. X * Uses the connect strings to make this determination.  The first
  1661. X * argument is the index into the TTY database.  A non-zero return code
  1662. X * means "yes it can".
  1663. X */
  1664. X
  1665. static int
  1666. ck_speed(tty, baud)
  1667. int tty;
  1668. unsigned int baud;
  1669. X{
  1670. X    int i, mod;
  1671. X    char buf[60];
  1672. X    void error_win();
  1673. X                    /* find the modem database */
  1674. X    mod = -1;
  1675. X    for (i=0; i<modem->m_entries; i++) {
  1676. X        if (!strcmp(modem->mname[i], modem->tname[tty])) {
  1677. X            mod = i;
  1678. X            break;
  1679. X        }
  1680. X    }
  1681. X    if (mod == -1) {
  1682. X        sprintf(buf, "Modem name \"%s\" in TTY database", modem->tname[tty]);
  1683. X        error_win(1, buf, "does not exist in modem database");
  1684. X    }
  1685. X
  1686. X#ifdef DEBUG
  1687. X    fprintf(stderr, "ck_speed: checking modem \"%s\" for %d baud\n", modem->mname[mod], baud);
  1688. X#endif /* DEBUG */
  1689. X
  1690. X    switch (baud) {
  1691. X        case 300:
  1692. X            if (*modem->con_3[mod] != '\0')
  1693. X                return(1);
  1694. X            break;
  1695. X        case 1200:
  1696. X            if (*modem->con_12[mod] != '\0')
  1697. X                return(1);
  1698. X            break;
  1699. X        case 2400:
  1700. X            if (*modem->con_24[mod] != '\0')
  1701. X                return(1);
  1702. X            break;
  1703. X        case 4800:
  1704. X            if (*modem->con_48[mod] != '\0')
  1705. X                return(1);
  1706. X            break;
  1707. X        case 7200:
  1708. X        case 9600:
  1709. X            if (*modem->con_96[mod] != '\0')
  1710. X                return(1);
  1711. X            break;
  1712. X        case 12000:
  1713. X        case 14400:
  1714. X        case 19200:
  1715. X            if (*modem->con_192[mod] != '\0')
  1716. X                return(1);
  1717. X            break;
  1718. X        case 38400:
  1719. X            if (*modem->con_384[mod] != '\0')
  1720. X                return(1);
  1721. X            break;
  1722. X    }
  1723. X    return(0);
  1724. X}
  1725. X
  1726. X/*
  1727. X * Check to see if the auxiliary field contains a valid TTY or modem name.
  1728. X */
  1729. X
  1730. chk_aux(aux)
  1731. char *aux;
  1732. X{
  1733. X    int i;
  1734. X    char buf[80], *strcpy(), *strcat();
  1735. X
  1736. X    if (*aux == '\0')
  1737. X        return(0);
  1738. X
  1739. X    strcpy(buf, "/dev/");
  1740. X    strcat(buf, aux);
  1741. X
  1742. X    if (!access(buf, 0))
  1743. X        return(IS_TTY);
  1744. X
  1745. X    for (i=0; i<modem->m_entries; i++) {
  1746. X        if (!strcmp(modem->mname[i], aux))
  1747. X            return(IS_MODEM);
  1748. X    }
  1749. X                      /* Well, is not a TTY or modem */
  1750. X    return(IS_SCRIPT);
  1751. X}
  1752. END_OF_FILE
  1753. if test 13371 -ne `wc -c <'port.c'`; then
  1754.     echo shar: \"'port.c'\" unpacked with wrong size!
  1755. fi
  1756. # end of 'port.c'
  1757. fi
  1758. echo shar: End of archive 5 \(of 6\).
  1759. cp /dev/null ark5isdone
  1760. MISSING=""
  1761. for I in 1 2 3 4 5 6 ; do
  1762.     if test ! -f ark${I}isdone ; then
  1763.     MISSING="${MISSING} ${I}"
  1764.     fi
  1765. done
  1766. if test "${MISSING}" = "" ; then
  1767.     echo You have unpacked all 6 archives.
  1768.     rm -f ark[1-9]isdone
  1769. else
  1770.     echo You still need to unpack the following archives:
  1771.     echo "        " ${MISSING}
  1772. fi
  1773. ##  End of shell archive.
  1774. exit 0
  1775.