Thread View: de.comp.sources.unix
1 messages
1 total messages
Started by Frank Kaefer
Wed, 22 Jul 1992 05:04
v01i003: Pcomm 2.0 - telecommunication program for Unix, Part03/08
Author: Frank Kaefer
Date: Wed, 22 Jul 1992 05:04
Date: Wed, 22 Jul 1992 05:04
3117 lines
85443 bytes
85443 bytes
Submitted-by: egray@osiris.cso.uiuc.edu (Emmet P. Gray)
Posting-number: Volume 1, Issue 3
Archive-name: pcomm/part03
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 3 (of 8)."
# Contents: pcomm-2.0/Makefile pcomm-2.0/Makefile.sun
# pcomm-2.0/Pcomm_cmd.1 pcomm-2.0/cmd.c pcomm-2.0/d_lib.c
# pcomm-2.0/d_menu.c pcomm-2.0/d_prompt.c pcomm-2.0/input.c
# pcomm-2.0/s_modem.c pcomm-2.0/script.c pcomm-2.0/x_ascii.c
# Wrapped by fkk@stasys on Tue Jul 21 22:05:58 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'pcomm-2.0/Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pcomm-2.0/Makefile'\"
else
echo shar: Extracting \"'pcomm-2.0/Makefile'\" \(6622 characters\)
sed "s/^X//" >'pcomm-2.0/Makefile' <<'END_OF_FILE'
X# PCOMM v2.0
X# for generic SVR4
X
X#for 80286 versions of SCO Xenix
X#CFLAGS = -Od -DM_TERMINFO -Mle2 -LARGE
X#LDFLAGS = -SEG 1000 -F 5000 -Mle2
X#CURSES = -ltinfo -lx
X
X#for 80386 versions of SCO Xenix
X#CFLAGS = -O -DM_TERMINFO
X#LDFLAGS = -s
X#CURSES = -ltinfo -lx
X
X#for the AT&T Unix PC 7300/3b1
X#LD = ld
X#SHLIB = /lib/crt0s.o /lib/shlib_c.ifile
X#OTHER = /lib/setvbuf.o /lib/doprnt.o -luipc
X
X#for Sun OS (using the System V compiler)
X#CC = /usr/5bin/cc
X#LD = /usr/5bin/cc
X
XLD = cc
XSHLIB =
XOTHER =
XCFLAGS = -O
XLDFLAGS = -s
XSHAR = shar -a
X
XBIN_DIR = /usr/local/bin
XMAN_DIR = /usr/man1
XMAN_EXT = 1
XPCOMM_LIB = /usr/local/lib/pcomm
X
X#for old curses (i.e. Berkeley systems)
X#CURSES = -lcurses -ltermcap
XCURSES = -lcurses
X
X#for systems without getcwd(3) or getopt(3)
X#GETCWD.O = getcwd.o
X#GETCWD.C = getcwd.c
X#GETOPT.O = getopt.o
X#GETOPT.C = getopt.c
X
X#for System V or Berkeley TTY interface
X#TTY.O = tty_ucb.o
X#TTY.C = tty_ucb.c
XTTY.O = tty_att.o
XTTY.C = tty_att.c
X
X#for System V poll() or Berkeley select()
X#IPC.O = ipc_ucb.o
X#IPC.C = ipc_ucb.c
XIPC.O = ipc_att.o
XIPC.C = ipc_att.c
X
XPCOMM = $(GETCWD.O) $(GETOPT.O) $(TTY.O) $(IPC.O) admin.o chg_dir.o cmd.o \
X curses.o d_delete.o d_lib.o d_manual.o d_menu.o d_print.o \
X d_prompt.o d_revise.o data_log.o di_delay.o di_win.o dial.o \
X e_lib.o expand.o help.o info.o init.o input.o list_dir.o ls_menu.o \
X m_lib.o macro.o main.o n_shell.o p_lib.o passthru.o pexit.o \
X port.o redial.o s_axfer.o s_extrnl.o s_gen.o s_menu.o s_modem.o \
X s_prompt.o s_term.o s_tty.o screen.o script.o st_line.o \
X strings.o terminal.o vcs.o x_ascii.o x_batch.o x_extrnl.o \
X x_menu.o x_rcv.o x_send.o x_win.o xmodem.o
X
Xall: pcomm waitfor matches pcomm_cmd
X
Xpcomm: $(PCOMM)
X $(LD) $(LDFLAGS) $(PCOMM) $(OTHER) -o pcomm $(CURSES) $(SHLIB)
X
Xwaitfor: waitfor.o
X $(LD) $(LDFLAGS) waitfor.o -o waitfor $(SHLIB)
X
Xmatches: matches.o
X $(LD) $(LDFLAGS) matches.o -o matches $(SHLIB)
X
Xpcomm_cmd: pcomm_cmd.o
X $(LD) $(LDFLAGS) pcomm_cmd.o -o pcomm_cmd $(SHLIB)
X
Xpcomm_cmd.o:
X $(CC) $(CFLAGS) -DIPC=\"$(IPC.C)\" -c pcomm_cmd.c
X
Xinstall:
X cp pcomm waitfor matches pcomm_cmd $(BIN_DIR)
X# obviously this requires super-user privelidges...
X# chmod 4755 $(BIN_DIR)/pcomm
X# chown uucp $(BIN_DIR)/pcomm
X
Xinstall_man:
X cp Pcomm.1 $(MAN_DIR)/pcomm.$(MAN_EXT)
X cp Pcomm_cmd.1 $(MAN_DIR)/pcomm_cmd.$(MAN_EXT)
X cp Waitfor.1 $(MAN_DIR)/waitfor.$(MAN_EXT)
X cp Matches.1 $(MAN_DIR)/matches.$(MAN_EXT)
X
Xinstall_support:
X cp Pcomm.dial_dir $(PCOMM_LIB)/pcomm.dial_dir
X cp Pcomm.modem $(PCOMM_LIB)/pcomm.modem
X cp Pcomm.param $(PCOMM_LIB)/pcomm.param
X cp Pcomm.extrnl $(PCOMM_LIB)/pcomm.extrnl
X
Xclean:
X rm pcomm waitfor matches pcomm_cmd
X
Xlint:
X lint -p -Dlint $(GETCWD.C) $(GETOPT.C) $(TTY.C) $(IPC.C) admin.c \
X chg_dir.c cmd.c curses.c d_delete.c d_lib.c d_manual.c d_menu.c \
X d_print.c d_prompt.c d_revise.c data_log.c di_delay.c di_win.c \
X dial.c e_lib.c expand.c help.c info.c init.c input.c list_dir.c \
X ls_menu.c m_lib.c macro.c main.c n_shell.c p_lib.c passthru.c \
X pexit.c port.c redial.c s_axfer.c s_extrnl.c s_gen.c s_menu.c \
X s_modem.c s_prompt.c s_term.c s_tty.c screen.c script.c \
X st_line.c strings.c terminal.c vcs.c x_ascii.c x_batch.c \
X x_extrnl.c x_menu.c x_rcv.c x_send.c x_win.c xmodem.c $(CURSES)
X lint -p -Dlint -DIPC=\"$(IPC.C)\" pcomm_cmd.c
X lint -p -Dlint waitfor.c
X lint -p -Dlint matches.c
X
Xshar:
X $(SHAR) Doc.me > pcomm_sh.1
X $(SHAR) Configure.sh Convert.sh Makefile Matches.1 Pcomm.1 \
X Pcomm.dial_dir Pcomm.extrnl Pcomm.modem Pcomm.param Pcomm_cmd.1 \
X Q_and_A Readme Release.notes Sample > pcomm_sh.2
X $(SHAR) Unixpc.shar Waitfor.1 admin.c chg_dir.c cmd.c cmd.h \
X config.h curses.c d_delete.c d_lib.c d_manual.c > pcomm_sh.3
X $(SHAR) d_menu.c d_print.c d_prompt.c d_revise.c data_log.c \
X di_delay.c di_win.c dial.c dial_dir.h e_lib.c expand.c extrnl.h \
X getcwd.c getopt.c help.c > pcomm_sh.4
X $(SHAR) info.c init.c input.c ipc.h ipc_att.c ipc_ucb.c \
X list_dir.c ls_menu.c m_lib.c macro.c main.c matches.c misc.h \
X modem.h n_shell.c > pcomm_sh.5
X $(SHAR) p_lib.c param.h passthru.c patchlevel.h pcomm_cmd.c \
X pexit.c port.c redial.c s_axfer.c s_extrnl.c s_gen.c > pcomm_sh.6
X $(SHAR) s_menu.c s_modem.c s_prompt.c s_term.c s_tty.c screen.c \
X script.c st_line.c status.h strings.c terminal.c tty_att.c \
X tty_ucb.c > pcomm_sh.7
X $(SHAR) vcs.c vcs.h waitfor.c x_ascii.c x_batch.c x_extrnl.c \
X x_menu.c x_rcv.c > pcomm_sh.8
X $(SHAR) x_send.c x_win.c xmodem.c xmodem.h > pcomm_sh.9
X# $(SHAR) Doc.out Matches.out Pcomm.out Pcomm_cmd.out Waitfor.out \
X# > pcomm_sh.10
X
Xadmin.o: config.h dial_dir.h param.h
Xchg_dir.o: config.h misc.h
Xcmd.o: cmd.h config.h dial_dir.h extrnl.h modem.h param.h status.h xmodem.h
Xcurses.o: config.h misc.h status.h
Xd_delete.o: dial_dir.h misc.h param.h
Xd_lib.o: dial_dir.h param.h
Xd_manual.o: config.h dial_dir.h misc.h
Xd_menu.o: config.h dial_dir.h misc.h param.h
Xd_print.o: config.h dial_dir.h misc.h
Xd_prompt.o: dial_dir.h misc.h
Xd_revise.o: dial_dir.h misc.h param.h
Xdata_log.o: misc.h param.h status.h
Xdi_delay.o: misc.h param.h
Xdi_win.o: dial_dir.h misc.h modem.h param.h status.h
Xdial.o: config.h dial_dir.h misc.h modem.h param.h
Xe_lib.o: extrnl.h
Xexpand.o: config.h
Xgetopt.o: config.h
Xhelp.o: config.h misc.h
Xinfo.o: patchlevel.h
Xinit.o: config.h misc.h status.h
Xinput.o: config.h misc.h param.h status.h vcs.h
Xipc_att.o: ipc.h
Xipc_ucb.o: ipc.h
Xlist_dir.o: misc.h
Xls_menu.o: dial_dir.h misc.h param.h
Xm_lib.o: modem.h
Xmacro.o: misc.h param.h
Xmain.o: config.h dial_dir.h extrnl.h misc.h modem.h param.h status.h
Xn_shell.o: config.h
Xp_lib.o: param.h
Xpassthru.o: config.h misc.h
Xpexit.o: dial_dir.h misc.h param.h status.h
Xport.o: config.h dial_dir.h modem.h status.h
Xredial.o: config.h dial_dir.h misc.h
Xs_axfer.o: misc.h param.h
Xs_extrnl.o: extrnl.h misc.h
Xs_gen.o: misc.h param.h
Xs_menu.o: misc.h
Xs_modem.o: misc.h modem.h
Xs_prompt.o: misc.h
Xs_term.o: dial_dir.h misc.h param.h
Xs_tty.o: misc.h modem.h
Xscreen.o: param.h status.h
Xscript.o: config.h dial_dir.h misc.h modem.h status.h
Xst_line.o: config.h dial_dir.h misc.h modem.h param.h status.h
Xstrings.o: config.h
Xterminal.o: config.h dial_dir.h ipc.h misc.h modem.h param.h status.h xmodem.h
Xtty_att.o: dial_dir.h modem.h param.h
Xtty_ucb.o: dial_dir.h modem.h param.h
Xvcs.o: config.h status.h vcs.h
Xx_ascii.o: config.h misc.h param.h
Xx_batch.o: config.h misc.h xmodem.h
Xx_extrnl.o: config.h
Xx_menu.o: extrnl.h misc.h xmodem.h
Xx_rcv.o: config.h dial_dir.h misc.h xmodem.h
Xx_send.o: config.h dial_dir.h misc.h xmodem.h
Xx_win.o: dial_dir.h misc.h status.h xmodem.h
Xxmodem.o: config.h misc.h param.h xmodem.h
X
Xpcomm_cmd.o: config.h cmd.h $(IPC.C)
Xmatches.o: config.h
Xwaitfor.o: config.h
END_OF_FILE
if test 6622 -ne `wc -c <'pcomm-2.0/Makefile'`; then
echo shar: \"'pcomm-2.0/Makefile'\" unpacked with wrong size!
fi
# end of 'pcomm-2.0/Makefile'
fi
if test -f 'pcomm-2.0/Makefile.sun' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pcomm-2.0/Makefile.sun'\"
else
echo shar: Extracting \"'pcomm-2.0/Makefile.sun'\" \(6657 characters\)
sed "s/^X//" >'pcomm-2.0/Makefile.sun' <<'END_OF_FILE'
X# PCOMM v2.0
X# for SunOS 4.1.x
X
X#for 80286 versions of SCO Xenix
X#CFLAGS = -Od -DM_TERMINFO -Mle2 -LARGE
X#LDFLAGS = -SEG 1000 -F 5000 -Mle2
X#CURSES = -ltinfo -lx
X
X#for 80386 versions of SCO Xenix
X#CFLAGS = -O -DM_TERMINFO
X#LDFLAGS = -s
X#CURSES = -ltinfo -lx
X
X#for the AT&T Unix PC 7300/3b1
X#LD = ld
X#SHLIB = /lib/crt0s.o /lib/shlib_c.ifile
X#OTHER = /lib/setvbuf.o /lib/doprnt.o -luipc
X
X#for Sun OS (using the System V compiler)
XCC = /usr/5bin/cc
XLD = /usr/5bin/cc
X
X#LD = cc
XSHLIB =
XOTHER =
XCFLAGS = -O
XLDFLAGS = -s
XSHAR = shar -a
X
XBIN_DIR = /home/egray/bin
XMAN_DIR = /usr/man1
XMAN_EXT = 1
XPCOMM_LIB = /local/lib/pcomm
X
X#for old curses (i.e. Berkeley systems)
X#CURSES = -lcurses -ltermcap
XCURSES = -lcurses
X
X#for systems without getcwd(3) or getopt(3)
X#GETCWD.O = getcwd.o
X#GETCWD.C = getcwd.c
X#GETOPT.O = getopt.o
X#GETOPT.C = getopt.c
X
X#for System V or Berkeley TTY interface
X#TTY.O = tty_ucb.o
X#TTY.C = tty_ucb.c
XTTY.O = tty_att.o
XTTY.C = tty_att.c
X
X#for System V poll() or Berkeley select()
XIPC.O = ipc_ucb.o
XIPC.C = ipc_ucb.c
X#IPC.O = ipc_att.o
X#IPC.C = ipc_att.c
X
XPCOMM = $(GETCWD.O) $(GETOPT.O) $(TTY.O) $(IPC.O) admin.o chg_dir.o cmd.o \
X curses.o d_delete.o d_lib.o d_manual.o d_menu.o d_print.o \
X d_prompt.o d_revise.o data_log.o di_delay.o di_win.o dial.o \
X e_lib.o expand.o help.o info.o init.o input.o list_dir.o ls_menu.o \
X m_lib.o macro.o main.o n_shell.o p_lib.o passthru.o pexit.o \
X port.o redial.o s_axfer.o s_extrnl.o s_gen.o s_menu.o s_modem.o \
X s_prompt.o s_term.o s_tty.o screen.o script.o st_line.o \
X strings.o terminal.o vcs.o x_ascii.o x_batch.o x_extrnl.o \
X x_menu.o x_rcv.o x_send.o x_win.o xmodem.o
X
Xall: pcomm waitfor matches pcomm_cmd
X
Xpcomm: $(PCOMM)
X $(LD) $(LDFLAGS) $(PCOMM) $(OTHER) -o pcomm $(CURSES) $(SHLIB)
X
Xwaitfor: waitfor.o
X $(LD) $(LDFLAGS) waitfor.o -o waitfor $(SHLIB)
X
Xmatches: matches.o
X $(LD) $(LDFLAGS) matches.o -o matches $(SHLIB)
X
Xpcomm_cmd: pcomm_cmd.o
X $(LD) $(LDFLAGS) pcomm_cmd.o -o pcomm_cmd $(SHLIB)
X
Xpcomm_cmd.o:
X $(CC) $(CFLAGS) -DIPC=\"$(IPC.C)\" -c pcomm_cmd.c
X
Xinstall:
X cp pcomm waitfor matches pcomm_cmd $(BIN_DIR)
X# obviously this requires super-user privelidges...
X# chmod 4755 $(BIN_DIR)/pcomm
X# chown uucp $(BIN_DIR)/pcomm
X
Xinstall_man:
X cp Pcomm.1 $(MAN_DIR)/pcomm.$(MAN_EXT)
X cp Pcomm_cmd.1 $(MAN_DIR)/pcomm_cmd.$(MAN_EXT)
X cp Waitfor.1 $(MAN_DIR)/waitfor.$(MAN_EXT)
X cp Matches.1 $(MAN_DIR)/matches.$(MAN_EXT)
X
Xinstall_support:
X cp Pcomm.dial_dir $(PCOMM_LIB)/pcomm.dial_dir
X cp Pcomm.modem $(PCOMM_LIB)/pcomm.modem
X cp Pcomm.param $(PCOMM_LIB)/pcomm.param
X cp Pcomm.extrnl $(PCOMM_LIB)/pcomm.extrnl
X
Xclean:
X rm pcomm waitfor matches pcomm_cmd
X
Xlint:
X /usr/5bin/lint -p -Dlint $(GETCWD.C) $(GETOPT.C) $(TTY.C) $(IPC.C) admin.c \
X chg_dir.c cmd.c curses.c d_delete.c d_lib.c d_manual.c d_menu.c \
X d_print.c d_prompt.c d_revise.c data_log.c di_delay.c di_win.c \
X dial.c e_lib.c expand.c help.c info.c init.c input.c list_dir.c \
X ls_menu.c m_lib.c macro.c main.c n_shell.c p_lib.c passthru.c \
X pexit.c port.c redial.c s_axfer.c s_extrnl.c s_gen.c s_menu.c \
X s_modem.c s_prompt.c s_term.c s_tty.c screen.c script.c \
X st_line.c strings.c terminal.c vcs.c x_ascii.c x_batch.c \
X x_extrnl.c x_menu.c x_rcv.c x_send.c x_win.c xmodem.c $(CURSES)
X /usr/5bin/lint -p -Dlint -DIPC=\"$(IPC.C)\" pcomm_cmd.c
X /usr/5bin/lint -p -Dlint waitfor.c
X /usr/5bin/lint -p -Dlint matches.c
X
Xshar:
X $(SHAR) Doc.me > pcomm_sh.1
X $(SHAR) Configure.sh Convert.sh Makefile Matches.1 Pcomm.1 \
X Pcomm.dial_dir Pcomm.extrnl Pcomm.modem Pcomm.param Pcomm_cmd.1 \
X Q_and_A Readme Release.notes Sample > pcomm_sh.2
X $(SHAR) Unixpc.shar Waitfor.1 admin.c chg_dir.c cmd.c cmd.h \
X config.h curses.c d_delete.c d_lib.c d_manual.c > pcomm_sh.3
X $(SHAR) d_menu.c d_print.c d_prompt.c d_revise.c data_log.c \
X di_delay.c di_win.c dial.c dial_dir.h e_lib.c expand.c extrnl.h \
X getcwd.c getopt.c help.c > pcomm_sh.4
X $(SHAR) info.c init.c input.c ipc.h ipc_att.c ipc_ucb.c \
X list_dir.c ls_menu.c m_lib.c macro.c main.c matches.c misc.h \
X modem.h n_shell.c > pcomm_sh.5
X $(SHAR) p_lib.c param.h passthru.c patchlevel.h pcomm_cmd.c \
X pexit.c port.c redial.c s_axfer.c s_extrnl.c s_gen.c > pcomm_sh.6
X $(SHAR) s_menu.c s_modem.c s_prompt.c s_term.c s_tty.c screen.c \
X script.c st_line.c status.h strings.c terminal.c tty_att.c \
X tty_ucb.c > pcomm_sh.7
X $(SHAR) vcs.c vcs.h waitfor.c x_ascii.c x_batch.c x_extrnl.c \
X x_menu.c x_rcv.c > pcomm_sh.8
X $(SHAR) x_send.c x_win.c xmodem.c xmodem.h > pcomm_sh.9
X# $(SHAR) Doc.out Matches.out Pcomm.out Pcomm_cmd.out Waitfor.out \
X# > pcomm_sh.10
X
Xadmin.o: config.h dial_dir.h param.h
Xchg_dir.o: config.h misc.h
Xcmd.o: cmd.h config.h dial_dir.h extrnl.h modem.h param.h status.h xmodem.h
Xcurses.o: config.h misc.h status.h
Xd_delete.o: dial_dir.h misc.h param.h
Xd_lib.o: dial_dir.h param.h
Xd_manual.o: config.h dial_dir.h misc.h
Xd_menu.o: config.h dial_dir.h misc.h param.h
Xd_print.o: config.h dial_dir.h misc.h
Xd_prompt.o: dial_dir.h misc.h
Xd_revise.o: dial_dir.h misc.h param.h
Xdata_log.o: misc.h param.h status.h
Xdi_delay.o: misc.h param.h
Xdi_win.o: dial_dir.h misc.h modem.h param.h status.h
Xdial.o: config.h dial_dir.h misc.h modem.h param.h
Xe_lib.o: extrnl.h
Xexpand.o: config.h
Xgetopt.o: config.h
Xhelp.o: config.h misc.h
Xinfo.o: patchlevel.h
Xinit.o: config.h misc.h status.h
Xinput.o: config.h misc.h param.h status.h vcs.h
Xipc_att.o: ipc.h
Xipc_ucb.o: ipc.h
Xlist_dir.o: misc.h
Xls_menu.o: dial_dir.h misc.h param.h
Xm_lib.o: modem.h
Xmacro.o: misc.h param.h
Xmain.o: config.h dial_dir.h extrnl.h misc.h modem.h param.h status.h
Xn_shell.o: config.h
Xp_lib.o: param.h
Xpassthru.o: config.h misc.h
Xpexit.o: dial_dir.h misc.h param.h status.h
Xport.o: config.h dial_dir.h modem.h status.h
Xredial.o: config.h dial_dir.h misc.h
Xs_axfer.o: misc.h param.h
Xs_extrnl.o: extrnl.h misc.h
Xs_gen.o: misc.h param.h
Xs_menu.o: misc.h
Xs_modem.o: misc.h modem.h
Xs_prompt.o: misc.h
Xs_term.o: dial_dir.h misc.h param.h
Xs_tty.o: misc.h modem.h
Xscreen.o: param.h status.h
Xscript.o: config.h dial_dir.h misc.h modem.h status.h
Xst_line.o: config.h dial_dir.h misc.h modem.h param.h status.h
Xstrings.o: config.h
Xterminal.o: config.h dial_dir.h ipc.h misc.h modem.h param.h status.h xmodem.h
Xtty_att.o: dial_dir.h modem.h param.h
Xtty_ucb.o: dial_dir.h modem.h param.h
Xvcs.o: config.h status.h vcs.h
Xx_ascii.o: config.h misc.h param.h
Xx_batch.o: config.h misc.h xmodem.h
Xx_extrnl.o: config.h
Xx_menu.o: extrnl.h misc.h xmodem.h
Xx_rcv.o: config.h dial_dir.h misc.h xmodem.h
Xx_send.o: config.h dial_dir.h misc.h xmodem.h
Xx_win.o: dial_dir.h misc.h status.h xmodem.h
Xxmodem.o: config.h misc.h param.h xmodem.h
X
Xpcomm_cmd.o: config.h cmd.h $(IPC.C)
Xmatches.o: config.h
Xwaitfor.o: config.h
END_OF_FILE
if test 6657 -ne `wc -c <'pcomm-2.0/Makefile.sun'`; then
echo shar: \"'pcomm-2.0/Makefile.sun'\" unpacked with wrong size!
fi
# end of 'pcomm-2.0/Makefile.sun'
fi
if test -f 'pcomm-2.0/Pcomm_cmd.1' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pcomm-2.0/Pcomm_cmd.1'\"
else
echo shar: Extracting \"'pcomm-2.0/Pcomm_cmd.1'\" \(6126 characters\)
sed "s/^X//" >'pcomm-2.0/Pcomm_cmd.1' <<'END_OF_FILE'
X.if n .ds rq ""
X.el .ds rq ''
X.if n .ds lq ""
X.el .ds lq ``
X.TH PCOMM_CMD 1 local
X.SH NAME
Xpcomm_cmd \- send a command to Pcomm
X.SH SYNOPSIS
X.B pcomm_cmd
X[ command ] [ options ] [ arguments ]
X.SH DESCRIPTION
X.I Pcomm_cmd
Xis a Pcomm support program. It is used from inside shell scripts to access
XPcomm commands, such as
X.I \*(lqpcomm_cmd send xmodem junk\*(rq
Xfor sending the file \*(lqjunk\*(rq to the remote using the xmodem file
Xtransfer protocol.
X.PP
XThe following command line options are supported.
X.TP
XSET BAUD [ 300 | 1200 | 2400 | 4800 | 9600 | 19200 | 38400 ]
XSet the baud rate for the current connection. This feature is for use
Xwith the DIAL MANUAL command, since the baud rate information in the
Xdialing directory entries overrides this value.
X.TP
XSET PARITY [ EVEN | ODD | NONE ]
XSet the parity for the current connection. For use with the DIAL MANUAL
Xcommand.
X.TP
XSET DATA_BITS [ 7 | 8 ]
XThe number of data bits (word length) used for the current connection.
XFor use with the DIAL MANUAL command.
X.TP
XSET STOP_BITS [ 1 | 2 ]
XThe number of stop bits for the current connection. For use with the
XDIAL MANUAL command.
X.TP
XSET DUPLEX [ HALF | FULL ]
XSet the duplex mode (local echo). The HALF option is used if the remote
Xsystem does not echo characters as they are typed.
X.TP
XSET AUX filename
XUse the argument as the auxiliary file associated with the current
Xconnection. Since chaining of scripts is not supported, this feature
Xwould only be used to set the TTY or modem.
X.TP
XSET HOT_KEY [1-256]
XChange the decimal value of the \*(lqhot key\*(rq to this value.
X.TP
XSET ASCII_HOT string
XChange the ASCII representation of the hot key to the given argument. The
Xlength of the string must be no more than 4 characters wide.
X.TP
XSET FLOW_CTRL [ XON/XOFF | NONE ]
XSet the flow control between the local and remote systems to either XON/XOFF
Xor NONE.
X.TP
XSET CR_IN [ CR | CR/LF ]
XTranslate in-comming carriage returns carriage return followed by a line
Xfeed, or pass the carriage return through unchanged.
X.TP
XSET CR_OUT [ CR | CR/LF ]
XTranslate out-going carriage returns to CR or CR/LF.
X.TP
XSET LOGFILE filename
XChange the name of the default log file. For use with the DATA_LOG command.
X.TP
XSET DUMPFILE filename
XChange the name of the screen dump file. For use with the SCREEN_DUMP
Xcommand.
X.TP
XSET STRIP [ YES | NO ]
XShould the in-comming data be stripped to 7 bits?
X.TP
XSET LOCAL_ECHO [ YES | NO ]
XShould data be shown on the screen during ASCII uploads?
X.TP
XSET EXPAND [ YES | NO ]
XShould blank lines be \*(lqexpanded\*(rq to a line with a single space?
XFor use only during ASCII uploads.
X.TP
XSET CR_DELAY [ 0 | 100 | 150 ]
XSet the delay for the carraige returns for ASCII uploads.
X.TP
XSET PACE [ YES | NO ]
XShould the entire upload be artifically slowed down? For use during ASCII
Xuploads.
X.TP
XSET CR_UP [ NONE | ADD_LF | STRIP ]
XControls the translation of carraige returns during ASCII uploads.
X.TP
XSET LF_UP [ NONE | ADD_CR | STRIP ]
XControls the translation of line feeds during ASCII uploads.
X.TP
XSET TIMER [5-150]
XControls the timer (in seconds) that detects the end of an ASCII download.
X.TP
XSET CR_DN [ NONE | ADD_LF | STRIP ]
XControls the translation of carraige returns during ASCII downloads.
X.TP
XSET LF_DN [ NONE | ADD_CR | STRIP ]
XControls the translation of line feeds during ASCII downloads.
X.TP
XQUERY TTY_NAME
XReturns the name of the current TTY in use or NONE.
X.TP
XQUERY MODEM_NAME
XReturns the name of the current modem in use or NONE.
X.TP
XIF CONNECTED
XReturns a 1 if Pcomm is currently connected to a remote, otherwise a 0.
X.TP
XIF LOG_STATUS
XReturns a 1 if the data logging feature is turned on, otherwise 0.
X.TP
XIF PRINTER_STATUS
XReturns a 1 if the printer is turned on, otherwise 0.
X.TP
XDIAL [ MANUAL phone_number ] entry_number
XDial an entry from the dialing directory. The MANUAL option is used to
Xoptionaly dial a phone number without the use of the dialing directory.
XDIAL returns after 1 attempt. A return code of 1 means a connection
Xwas made.
X.I
XThe dial function will not be allowed to switch TTY ports. If the current
XTTY is not suitable (i.e. not attached to the correct modem), the script
Xwill be terminated.
X.TP
XREDIAL entry_number
XSimilar to the DIAL command, but 10 attempts are made.
X.TP
XEXIT
XHang up the phone and exit from Pcomm.
X.TP
XCLEAR_SCREEN
XClear the screen.
X.TP
XCHG_DIR directory
XChange the current working directory to the given directory.
X.TP
XHANG_UP
XHang up the phone, but remain in Pcomm.
X.TP
XPRINTER [ ON | OFF ]
XControl the logging of data to the printer.
X.TP
XMODEM_BREAK
XSend a modem break to the remote system. This is typically used to
Xtell the remote to switch to a different baud rate.
X.TP
XSEND protocol filename
XSend a file to the remote. The valid protocols are XMODEM, XMODEM_1K,
XMODEM7, YMODEM, YMODEM_G, ASCII, EXT_1, EXT_2, and EXT_3.
X.TP
XRECEIVE protocol filename
XReceive a file from the remote. The valid protocols are XMODEM,
XXMODEM_1K, MODEM7, YMODEM, YMODEM_G, ASCII, EXT_1, EXT_2, and EXT_3.
X.TP
XSCREEN_DUMP
XDump the current contents of the screen to the DUMPFILE. If the file
Xalready exists, the new contents are appended to the file.
X.TP
XDATA_LOG [ ON | OFF ]
XControl logging of the terminal session to the LOGFILE. If the file
Xalready exists, the new contents are appended to the file.
X.SH EXAMLES
XThe following is an example of a shell script that will dial a system,
Xlog a user on, transfer a file called "junk" using xmodem, log out, and
Xexit Pcomm.
X.PP
X.nf
X.RS 5
X# dial entry number 23 in my dialing directory
Xpcomm_cmd dial 23
X# wait for the login prompt
Xwaitfor ogin:
X# send my user id
Xecho egray
X# wait for the password prompt
Xwaitfor assword:
X# send my passwd
Xecho abcdefg
X# wait for terminal type prompt
Xwaitfor vt100
X# echo my type
Xecho vt100
X# wait for a Unix prompt
Xwaitfor $
X# start up an xmodem file transfer
Xecho sx junk
X# wait for the sx command to say its ready
Xwaitfor now
Xsleep 1
X# do a file transfer
Xpcomm_cmd receive xmodem junk
X# wait for the prompt
Xwaitfor $
X# log me out
Xecho "^D"
Xsleep 1
X# exit pcomm
Xpcomm_cmd exit
X.fi
X.RE
X.SH "SEE ALSO"
Xpcomm(1), waitfor(1), matches(1), Pcomm Reference Manual
END_OF_FILE
if test 6126 -ne `wc -c <'pcomm-2.0/Pcomm_cmd.1'`; then
echo shar: \"'pcomm-2.0/Pcomm_cmd.1'\" unpacked with wrong size!
fi
# end of 'pcomm-2.0/Pcomm_cmd.1'
fi
if test -f 'pcomm-2.0/cmd.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pcomm-2.0/cmd.c'\"
else
echo shar: Extracting \"'pcomm-2.0/cmd.c'\" \(6823 characters\)
sed "s/^X//" >'pcomm-2.0/cmd.c' <<'END_OF_FILE'
X/*
X * Pcomm script commands. Since these will be executed from a forked
X * shell script, the commands, queries, and responses are sent thru an
X * IPC channel to Pcomm.
X */
X
X#include <stdio.h>
X#include <curses.h>
X#include "cmd.h"
X#include "config.h"
X#include "dial_dir.h"
X#include "extrnl.h"
X#include "modem.h"
X#include "param.h"
X#include "status.h"
X#include "xmodem.h"
X
Xstatic void send_reply(), do_xfer(), cmode(), tmode();
X
Xvoid
Xcmd_input()
X{
X extern int fd;
X int cmd, arg1, i, n, ret_code;
X char buf[256], *s, arg2[256], *strchr(), *str_rep();
X char *entry, *strtok(), ld_code;
X void hang_up(), line_set(), pexit(), screen_dump();
X
X if (ipc_read(status->cmd_ipc, buf, 256))
X return;
X
X /* parse the comand line */
X if (sscanf(buf, "%d %d %s\n", &cmd, &arg1, arg2) != 3)
X return;
X
X ret_code = 0;
X switch(cmd) {
X case SET: /* the SET command */
X switch(arg1) {
X case BAUD:
X dir->baud[0] = (unsigned int) atoi(arg2);
X line_set();
X break;
X case PARITY:
X dir->parity[0] = arg2[0];
X line_set();
X break;
X case DATA_BITS:
X dir->data_bits[0] = atoi(arg2);
X line_set();
X break;
X case STOP_BITS:
X dir->stop_bits[0] = atoi(arg2);
X line_set();
X break;
X case DUPLEX:
X dir->duplex[0] = arg2[0];
X line_set();
X break;
X case AUX:
X dir->aux[0] = str_rep(dir->aux[0], arg2);
X break;
X case HOT_KEY:
X param->hot_key = atoi(arg2);
X break;
X case ASCII_HOT:
X param->ascii_hot = str_rep(param->ascii_hot, arg2);
X break;
X case FLOW_CTRL:
X param->flow_ctrl = str_rep(param->flow_ctrl, arg2);
X break;
X case CR_IN:
X param->cr_in = str_rep(param->cr_in, arg2);
X break;
X case CR_OUT:
X param->cr_out = str_rep(param->cr_out, arg2);
X break;
X case LOGFILE:
X param->logfile = str_rep(param->logfile, arg2);
X break;
X case DUMPFILE:
X param->dumpfile = str_rep(param->dumpfile, arg2);
X break;
X case STRIP:
X param->strip = str_rep(param->strip, arg2);
X break;
X case LOCAL_ECHO:
X param->local_echo = str_rep(param->local_echo, arg2);
X break;
X case EXPAND:
X param->expand = str_rep(param->expand, arg2);
X break;
X case CR_DELAY:
X param->cr_delay = atoi(arg2);
X break;
X case PACE:
X param->pace = str_rep(param->pace, arg2);
X break;
X case CR_UP:
X param->cr_up = str_rep(param->cr_up, arg2);
X break;
X case LF_UP:
X param->lf_up = str_rep(param->lf_up, arg2);
X break;
X case TIMER:
X param->timer = atoi(arg2);
X break;
X case CR_DN:
X param->cr_dn = str_rep(param->cr_dn, arg2);
X break;
X case LF_DN:
X param->lf_dn = str_rep(param->lf_dn, arg2);
X break;
X default:
X break;
X }
X break;
X case QUERY: /* the QUERY commands */
X switch(arg1) {
X case TTY_NAME:
X if (modem->t_cur != -1)
X send_reply(modem->tty[modem->t_cur]);
X else
X send_reply("NONE");
X ret_code = 99;
X break;
X case MODEM_NAME:
X if (modem->m_cur != -1)
X send_reply(modem->mname[modem->m_cur]);
X else
X send_reply("NONE");
X ret_code = 99;
X break;
X default:
X break;
X }
X break;
X case IF: /* the IF commands */
X switch(arg1) {
X case CONNECTED:
X if (status->connected)
X ret_code = 1;
X break;
X case LOG_STATUS:
X if (status->log_status)
X ret_code = 1;
X break;
X case PRINTER_STATUS:
X if (status->print_status)
X ret_code = 1;
X break;
X default:
X break;
X }
X break;
X case DIAL:
X cmode();
X ld_code = '\0';
X s = arg2;
X if (strchr("+-@#", *s)) {
X ld_code = *s;
X s++;
X }
X
X if (arg1 == 1) { /* manual dial */
X dir->name[0] = str_rep(dir->number[0], s);
X dir->number[0] = str_rep(dir->number[0], s);
X dir->d_cur = 0;
X dir->q_num[0] = 0;
X }
X else {
X n = atoi(s);
X if (n == 0 || n > NUM_DIR) {
X tmode();
X break;
X }
X
X dir->d_cur = n;
X dir->q_num[0] = n;
X }
X dir->q_ld[0] = ld_code;
X dir->q_num[1] = -1;
X ret_code = dial_win(1);
X tmode();
X break;
X case REDIAL:
X cmode();
X entry = strtok(arg2, " ");
X for (i=0; i<NUM_QUEUE; i++) {
X if (entry == NULL) {
X dir->q_num[i] = -1;
X break;
X }
X
X ld_code = '\0';
X if (strchr("+-@#", *entry)) {
X ld_code = *entry;
X entry++;
X }
X
X n = atoi(entry);
X if (n > NUM_DIR || *dir->number[n] == '\0')
X continue;
X
X dir->q_ld[i] = ld_code;
X dir->q_num[i] = n;
X entry = strtok((char *) NULL, " \t");
X }
X ret_code = dial_win(10);
X tmode();
X break;
X case EXIT:
X pexit();
X break;
X case CLEAR_SCREEN:
X fixterm();
X erase();
X refresh();
X resetterm();
X break;
X case CHG_DIR:
X chdir(arg2);
X break;
X case HANG_UP:
X hang_up(QUIET);
X break;
X case PRINTER:
X status->print_status = arg1;
X break;
X case MODEM_BREAK:
X tty_break(fd);
X break;
X case SEND:
X do_xfer(arg1, UP_LOAD, arg2);
X break;
X case RECEIVE:
X do_xfer(arg1, DOWN_LOAD, arg2);
X break;
X case SCREEN_DUMP:
X screen_dump();
X break;
X case DATA_LOG:
X status->log_status = arg1;
X break;
X default:
X break;
X }
X if (ret_code != 99) {
X sprintf(buf, "%d", ret_code);
X send_reply(buf);
X }
X return;
X}
X
X/*
X * Send a string back to pcomm_cmd
X */
X
Xstatic void
Xsend_reply(s)
Xchar *s;
X{
X char buf[256];
X
X sprintf(buf, "%254.254s\n", s);
X if (ipc_write(status->cmd_ipc, buf, 256))
X fprintf(stderr, "Can't write to IPC\n");
X return;
X}
X
X/*
X * Put the screen in the "curses" mode
X */
X
Xstatic void
Xcmode()
X{
X void load_vs(), st_line();
X
X fixterm();
X load_vs();
X st_line("");
X return;
X}
X
X/*
X * Put the screen in the "terminal" mode
X */
X
Xstatic void
Xtmode()
X{
X extern int fd;
X void term_mode();
X
X if (fd != -1) {
X touchwin(stdscr);
X refresh();
X }
X resetterm();
X term_mode();
X return;
X}
X
X/*
X * Do the file transfers
X */
X
Xstatic void
Xdo_xfer(type, up, files)
Xint type, up;
Xchar *files;
X{
X int n, is_batch, num_extrnl;
X char buf[256], *strcpy(), *strcat();
X void xfer_win(), xfer_ascii(), do_extrnl();
X
X num_extrnl = (up == UP_LOAD) ? extrnl->up_entries : extrnl->dn_entries;
X
X is_batch = 0;
X switch(type) {
X case MODEM7:
X case YMODEM:
X case YMODEM_G: /* built-in batch protocols */
X is_batch++;
X /* FALLTHRU */
X case XMODEM:
X case XMODEM_1k: /* non-batch built-ins */
X cmode();
X if (up == UP_LOAD || !is_batch)
X xfer_win(files, up, type);
X else
X xfer_win("", up, type);
X tmode();
X break;
X case XASCII: /* ascii xfer, yuck! */
X xfer_ascii(files, up);
X break;
X case EXT_1:
X case EXT_2:
X case EXT_3: /* one of the externals */
X n = type -NUM_INTERNAL -1;
X if (n > num_extrnl)
X break;
X strcpy(buf, extrnl->command[up][n]);
X /* see if we need to add files */
X if (extrnl->prompt[up][n] == 'Y') {
X strcat(buf, " ");
X strcat(buf, files);
X }
X do_extrnl(buf);
X break;
X default:
X break;
X }
X return;
X}
END_OF_FILE
if test 6823 -ne `wc -c <'pcomm-2.0/cmd.c'`; then
echo shar: \"'pcomm-2.0/cmd.c'\" unpacked with wrong size!
fi
# end of 'pcomm-2.0/cmd.c'
fi
if test -f 'pcomm-2.0/d_lib.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pcomm-2.0/d_lib.c'\"
else
echo shar: Extracting \"'pcomm-2.0/d_lib.c'\" \(6988 characters\)
sed "s/^X//" >'pcomm-2.0/d_lib.c' <<'END_OF_FILE'
X/*
X * Routines to manipulate the dialing directory file pcomm.dial_dir
X */
X
X#include <stdio.h>
X#include "dial_dir.h"
X#include "param.h"
X
X/*
X * Read the dialing directory. Returns a pointer to a static area
X * containing the DIAL_DIR structure. All of the entries are created
X * regardless of the number of physical entries in the file. Element
X * number zero is reserved for the "manual" entry. All errors are fatal.
X */
X
Xstruct DIAL_DIR *
Xread_dir()
X{
X extern char *null_ptr;
X FILE *fp, *uid_fopen();
X int i, line, oops;
X char *str_dup(), buf[200], *temp_token, *str, *str_tok(), token[20];
X char message[80], *sep, *findfile();
X static struct DIAL_DIR d;
X void error_win();
X
X if ((d.d_path = findfile("pcomm.dial_dir")) == NULL)
X error_win(1, "Support file \"pcomm.dial_dir\" is missing", "or no read permission");
X
X if (!(fp = uid_fopen(d.d_path, "r"))) {
X sprintf(buf, "\"%s\" for read", d.d_path);
X error_win(1, "Can't open dialing directory file", buf);
X }
X
X sep = ";;---;;\n";
X line = 0;
X oops = 0;
X while (fgets(buf, 200, fp) != NULL) {
X line++;
X if (line > NUM_DIR)
X break;
X /* get the token */
X if (!(temp_token = str_tok(buf, '='))) {
X sprintf(message, "is missing a token at line %d", line);
X oops++;
X break;
X }
X /*
X * Parse the rest of the line. This is similar to using
X * the "real" strtok() function, but this version returns
X * a pointer to NULL if the token is missing. Note the use
X * of the array of field separators.
X */
X for (i=0; i<8; i++) {
X if (!(str = str_tok((char *) NULL, sep[i]))) {
X sprintf(message, "is missing a parameter at line %d", line);
X oops++;
X break;
X }
X switch (i) {
X case 0:
X d.name[line] = str_dup(str);
X break;
X case 1:
X d.number[line] = str_dup(str);
X break;
X case 2:
X d.baud[line] = (unsigned int) atoi(str);
X break;
X case 3:
X d.parity[line] = *str;
X break;
X case 4:
X d.data_bits[line] = atoi(str);
X break;
X case 5:
X d.stop_bits[line] = atoi(str);
X break;
X case 6:
X d.duplex[line] = *str;
X break;
X case 7:
X d.aux[line] = str_dup(str);
X break;
X }
X }
X if (oops)
X break;
X /* sanity checking */
X sprintf(token, "DIR_%d", line);
X if (strcmp(temp_token, token)) {
X sprintf(message, "is corrupted at line %d", line);
X oops++;
X break;
X }
X }
X fclose(fp);
X
X if (oops) {
X sprintf(buf, "Dialing directory file \"%s\"", d.d_path);
X error_win(1, buf, message);
X }
X d.d_entries = line;
X /* if empty database */
X if (!line) {
X sprintf(buf, "Dialing directory file \"%s\"", d.d_path);
X error_win(0, buf, "has no data");
X }
X /* fill in the rest with defaults */
X for (i=line+1; i<=NUM_DIR; i++) {
X d.name[i] = null_ptr;
X d.number[i] = null_ptr;
X d.baud[i] = param->d_baud;
X d.parity[i] = param->d_parity;
X d.data_bits[i] = param->d_data_bits;
X d.stop_bits[i] = param->d_stop_bits;
X d.duplex[i] = *param->d_duplex;
X d.aux[i] = null_ptr;
X }
X /* create an empty "manual" entry */
X d.name[0] = null_ptr;
X d.number[0] = null_ptr;
X d.baud[0] = param->d_baud;
X d.parity[0] = param->d_parity;
X d.data_bits[0] = param->d_data_bits;
X d.stop_bits[0] = param->d_stop_bits;
X d.duplex[0] = *param->d_duplex;
X d.aux[0] = null_ptr;
X /* create an empty queue */
X for (i=0; i<NUM_QUEUE; i++) {
X d.q_ld[i] = '\0';
X d.q_num[i] = -1;
X }
X /* the start up d_cur is 0 */
X d.d_cur = 0;
X return(&d);
X}
X
X/*
X * Update a dialing directory entry. Update only the one entry asked for,
X * not the entire image in memory. If the new entry is beyond the end of
X * the physical file, then fill in the holes, and update "dir->d_entries".
X * A non-zero return code means a non-fatal error.
X */
X
Xint
Xup_dir(entry)
Xint entry;
X{
X FILE *fp_in, *fp_out, *uid_fopen();
X int i;
X char *temp[NUM_DIR+1], buf[200], *str_dup(), *str_rep();
X void error_win(), free_ptr();
X
X /* open for read */
X if (!(fp_in = uid_fopen(dir->d_path, "r"))) {
X sprintf(buf, "\"%s\" for read", dir->d_path);
X error_win(1, "Can't open dialing directory file", buf);
X }
X /* read in a temporary version */
X i = 0;
X while (fgets(buf, 200, fp_in) != NULL)
X temp[++i] = str_dup(buf);
X
X fclose(fp_in);
X /* alter only 1 entry */
X sprintf(buf, "DIR_%d=%s;%s;%d-%c-%d-%d;%c;%s\n", entry,
X dir->name[entry], dir->number[entry], dir->baud[entry],
X dir->parity[entry], dir->data_bits[entry], dir->stop_bits[entry],
X dir->duplex[entry], dir->aux[entry]);
X
X if (entry <= dir->d_entries)
X temp[entry] = str_rep(temp[entry], buf);
X else
X temp[entry] = str_dup(buf);
X
X /* fill in holes if beyond end */
X if (entry > dir->d_entries+1) {
X for (i=dir->d_entries+1; i<entry; i++) {
X sprintf(buf, "DIR_%d=;;%d-%c-%d-%d;%c;\n", i,
X param->d_baud, param->d_parity, param->d_data_bits,
X param->d_stop_bits, *param->d_duplex);
X temp[i] = str_dup(buf);
X }
X }
X /* update "dir->d_entries" */
X if (entry > dir->d_entries)
X dir->d_entries = entry;
X
X /* open for write */
X if (!(fp_out = uid_fopen(dir->d_path, "w"))) {
X for (i=1; i<=dir->d_entries; i++)
X free_ptr(temp[i]);
X sprintf(buf, "\"%s\"", dir->d_path);
X error_win(0, "No write permission on dialing directory file", buf);
X return(1);
X }
X /* put it back */
X for (i=1; i<=dir->d_entries; i++) {
X fputs(temp[i], fp_out);
X free_ptr(temp[i]);
X }
X
X fclose(fp_out);
X return(0);
X}
X
X/*
X * Delete a range of dialing directory entries. Actually, just copies
X * default (empty) entries in place of deleted entries. However, it will
X * shrink the file if deletions occur at the physical EOF. A non-zero
X * return code means a non-fatal error.
X */
X
Xint
Xdel_dir(first, last)
Xint first, last;
X{
X FILE *fp_in, *fp_out, *uid_fopen();
X int i;
X char *temp[NUM_DIR+1], buf[200], *str_dup(), *str_rep();
X void error_win(), free_ptr();
X /* sanity checking */
X if (first > dir->d_entries)
X return(0);
X if (last > dir->d_entries)
X last = dir->d_entries;
X
X /* open for read */
X if (!(fp_in = uid_fopen(dir->d_path, "r"))) {
X sprintf(buf, "\"%s\" for read", dir->d_path);
X error_win(1, "Can't open dialing directory file", buf);
X }
X /* read in a temporary version */
X i = 0;
X while (fgets(buf, 200, fp_in) != NULL)
X temp[++i] = str_dup(buf);
X
X fclose(fp_in);
X /* delete the range of values */
X for (i=first; i<=last; i++) {
X sprintf(buf, "DIR_%d=;;%d-%c-%d-%d;%c;\n", i, param->d_baud,
X param->d_parity, param->d_data_bits, param->d_stop_bits,
X *param->d_duplex);
X temp[i] = str_rep(temp[i], buf);
X }
X /* shrink the file? */
X if (last >= dir->d_entries) {
X for (i=first; i<=last; i++)
X free_ptr(temp[i]);
X dir->d_entries = first-1;
X }
X /* open for write */
X if (!(fp_out = uid_fopen(dir->d_path, "w"))) {
X for (i=1; i<=dir->d_entries; i++)
X free_ptr(temp[i]);
X sprintf(buf, "\"%s\"", dir->d_path);
X error_win(0, "No write permission on dialing directory file", buf);
X return(1);
X }
X /* put it all back */
X for (i=1; i<=dir->d_entries; i++) {
X fputs(temp[i], fp_out);
X free_ptr(temp[i]);
X }
X
X fclose(fp_out);
X return(0);
X}
END_OF_FILE
if test 6988 -ne `wc -c <'pcomm-2.0/d_lib.c'`; then
echo shar: \"'pcomm-2.0/d_lib.c'\" unpacked with wrong size!
fi
# end of 'pcomm-2.0/d_lib.c'
fi
if test -f 'pcomm-2.0/d_menu.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pcomm-2.0/d_menu.c'\"
else
echo shar: Extracting \"'pcomm-2.0/d_menu.c'\" \(7134 characters\)
sed "s/^X//" >'pcomm-2.0/d_menu.c' <<'END_OF_FILE'
X/*
X * Routines for the dialing directory menu.
X */
X
X#include <stdio.h>
X#include <curses.h>
X#include "config.h"
X#include "dial_dir.h"
X#include "misc.h"
X#include "param.h"
X
Xstatic int current = 1;
Xstatic void dir_scroll(), active_ld(), disp_ld();
X
X/*
X * Display the dialing directory and prompt for options. A non-zero return
X * code means we're ready to dial.
X */
X
Xint
Xdial_menu()
X{
X extern int xmc;
X WINDOW *dm_win, *newwin();
X char buf[5], ld_code;
X int ans, start, needs_repair, count, x, y, i, ret_code;
X void print_dir(), st_line();
X
X touchwin(stdscr);
X refresh();
X st_line("");
X
X dm_win = newwin(22, 78, 1, 1);
X mvwattrstr(dm_win, 1, 20, A_BOLD, "D I A L I N G D I R E C T O R Y");
X horizontal(dm_win, 2, 0, 78);
X mvwattrstr(dm_win, 3, 0, A_STANDOUT, " Name Number Baud P D S Dpx Auxiliary ");
X /* show 10 entries */
X dir_scroll(dm_win, current);
X
X mvwaddstr(dm_win, 15, 4, "==>");
X mvwattrch(dm_win, 15, 14, A_BOLD, 'R');
X waddstr(dm_win, " Revise");
X mvwattrch(dm_win, 15, 34, A_BOLD, 'M');
X waddstr(dm_win, " Manual Dialing");
X mvwaddstr(dm_win, 15, 55, "Entry to Dial");
X
X mvwattrch(dm_win, 16, 14, A_BOLD, 'P');
X waddstr(dm_win, " LD Codes");
X mvwattrch(dm_win, 16, 34, A_BOLD, 'D');
X waddstr(dm_win, " Delete Entry");
X mvwattrstr(dm_win, 16, 55, A_BOLD, "<CR>");
X waddstr(dm_win, " Scroll Down");
X
X#ifdef OLDCURSES
X mvwattrstr(dm_win, 17, 14, A_BOLD, "U/N");
X#else /* OLDCURSES */
X mvwattrstr(dm_win, 17, 14, A_BOLD, "<up>/<down>");
X#endif /* OLDCURSES */
X waddstr(dm_win, " Page");
X mvwattrch(dm_win, 17, 34, A_BOLD, 'L');
X waddstr(dm_win, " Print Entries");
X mvwattrstr(dm_win, 17, 55, A_BOLD, "<ESC>");
X waddstr(dm_win, " Exit");
X
X mvwaddstr(dm_win, 19, 4, "LD Codes Active:");
X /* show which LD codes are active */
X active_ld(dm_win);
X
X box(dm_win, VERT, HORZ);
X y = 15;
X x = 8;
X wmove(dm_win, 15, 8);
X wrefresh(dm_win);
X
X#ifndef OLDCURSES
X keypad(dm_win, TRUE);
X#endif /* OLDCURSES */
X /* prompt for options */
X count = 0;
X ld_code = '\0';
X ret_code = 0;
X do {
X needs_repair = 0;
X ans = wgetch(dm_win);
X /* get an entry number */
X if (ans >= '0' && ans <= '9') {
X if (count > 2) {
X beep();
X continue;
X }
X buf[count] = (char) ans;
X waddch(dm_win, (chtype) ans);
X wrefresh(dm_win);
X count++;
X continue;
X }
X switch (ans) {
X case DEL:
X case BS: /* do our own backspace */
X if (!count) {
X beep();
X break;
X }
X count--;
X if (!count)
X ld_code = '\0';
X buf[count] = '\0';
X getyx(dm_win, y, x);
X x--;
X wmove(dm_win, y, x);
X waddch(dm_win, (chtype) ' ');
X wmove(dm_win, y, x);
X wrefresh(dm_win);
X break;
X#ifndef OLDCURSES
X case KEY_UP:
X#endif /* OLDCURSES */
X case 'u':
X case 'U': /* up arrow key */
X if (current == 1) {
X beep();
X break;
X }
X start = current - 10;
X if (start < 1)
X start = 1;
X current = start;
X dir_scroll(dm_win, start);
X break;
X#ifndef OLDCURSES
X case KEY_DOWN:
X case '\n':
X#endif /* OLDCURSES */
X case 'n':
X case 'N': /* down arrow key */
X if (current == NUM_DIR-9) {
X beep();
X break;
X }
X start = current + 10;
X if (start > NUM_DIR-9)
X start = NUM_DIR-9;
X current = start;
X dir_scroll(dm_win, start);
X break;
X case '\r': /* <CR> key */
X if (!count) {
X if (current == NUM_DIR-9) {
X beep();
X break;
X }
X current++;
X if (current > NUM_DIR-9)
X current = NUM_DIR-9;
X dir_scroll(dm_win, current);
X }
X /*
X * The <CR> is used for the scroll-down-one-line
X * function, and to terminate numeric input.
X */
X else {
X buf[count] = '\0';
X i = atoi(buf);
X if (!i || i > NUM_DIR) {
X beep();
X mvwaddstr(dm_win, 15, 8, " ");
X x = 8;
X count = 0;
X break;
X }
X dir->q_ld[0] = ld_code;
X dir->q_num[0] = i;
X dir->d_cur = i;
X
X /* end of queue marker */
X dir->q_num[1] = -1;
X
X ret_code++;
X break;
X }
X break;
X case 'r':
X case 'R': /* revise */
X if (revise()) {
X active_ld(dm_win);
X dir_scroll(dm_win, current);
X }
X touchwin(dm_win);
X break;
X case 'p': /* display LD codes */
X case 'P':
X disp_ld();
X touchwin(dm_win);
X needs_repair++;
X break;
X case 'd':
X case 'D': /* delete a range of entries */
X if (delete())
X dir_scroll(dm_win, current);
X touchwin(dm_win);
X break;
X case 'm':
X case 'M': /* manual dial */
X if (manual()) {
X ret_code++;
X break;
X }
X touchwin(dm_win);
X needs_repair++;
X break;
X case 'l':
X case 'L': /* print the entries */
X print_dir();
X touchwin(dm_win);
X needs_repair++;
X break;
X case '+': /* LD codes */
X case '-':
X case '@':
X case '#':
X waddch(dm_win, (chtype) ans);
X wrefresh(dm_win);
X ld_code = (char) ans;
X continue;
X case ESC: /* <ESC> key (exit) */
X break;
X default:
X beep();
X }
X if (ret_code)
X break;
X /* magic cookie terminal? */
X if (xmc > 0 && needs_repair) {
X clear_line(dm_win, 1, 0, FALSE);
X clear_line(dm_win, 3, 0, FALSE);
X wrefresh(dm_win);
X mvwattrstr(dm_win, 1, 20, A_BOLD, "D I A L I N G D I R E C T O R Y");
X mvwattrstr(dm_win, 3, 0, A_STANDOUT, " Name Number Baud P D S Dpx Auxiliary ");
X box(dm_win, VERT, HORZ);
X }
X wmove(dm_win, y, x);
X wrefresh(dm_win);
X } while (ans != ESC);
X
X werase(dm_win);
X wrefresh(dm_win);
X delwin(dm_win);
X if (ret_code) {
X touchwin(stdscr);
X refresh();
X }
X return(ret_code);
X}
X
X/*
X * Scroll the dialing directory. Actually, we're not doing a real scroll
X * function on the screen, we're just repainting 10 lines.
X */
X
Xstatic void
Xdir_scroll(win, start)
XWINDOW *win;
Xint start;
X{
X int i;
X
X wmove(win, 4, 0);
X for (i=start; i<start+10; i++)
X wprintw(win,
X "%4d- %-20.20s %18.18s %5d-%c-%d-%d %c %-14.14s\n", i,
X dir->name[i], dir->number[i], dir->baud[i], dir->parity[i],
X dir->data_bits[i], dir->stop_bits[i], dir->duplex[i],
X dir->aux[i]);
X box(win, VERT, HORZ);
X return;
X}
X
X/*
X * Display the Long Distance codes. Press any key to continue.
X */
X
Xstatic void
Xdisp_ld()
X{
X WINDOW *ld_win, *newwin();
X
X ld_win = newwin(12, 30, 0, 0);
X mvwaddstr(ld_win, 1, 5, "Long Distance Codes\n");
X horizontal(ld_win, 2, 0, 30);
X mvwprintw(ld_win, 3, 2, "+ %-20.20s", param->ld_plus);
X mvwprintw(ld_win, 5, 2, "- %-20.20s", param->ld_minus);
X mvwprintw(ld_win, 7, 2, "@ %-20.20s", param->ld_at);
X mvwprintw(ld_win, 9, 2, "# %-20.20s", param->ld_pound);
X box(ld_win, VERT, HORZ);
X
X mvwaddstr(ld_win, 11, 8, " Press any key ");
X wmove(ld_win, 11, 29);
X wrefresh(ld_win);
X wgetch(ld_win);
X /* it overlaps, so erase it */
X werase(ld_win);
X wrefresh(ld_win);
X delwin(ld_win);
X return;
X}
X
X/*
X * Display which of the Long Distance codes are active.
X */
X
Xstatic void
Xactive_ld(win)
XWINDOW *win;
X{
X mvwaddstr(win, 19, 21, " ");
X wmove(win, 19, 21);
X /* a NULL means it's not active */
X if (*param->ld_plus != '\0')
X waddstr(win, "+ ");
X if (*param->ld_minus != '\0')
X waddstr(win, "- ");
X if (*param->ld_at != '\0')
X waddstr(win, "@ ");
X if (*param->ld_pound != '\0')
X waddstr(win, "# ");
X return;
X}
END_OF_FILE
if test 7134 -ne `wc -c <'pcomm-2.0/d_menu.c'`; then
echo shar: \"'pcomm-2.0/d_menu.c'\" unpacked with wrong size!
fi
# end of 'pcomm-2.0/d_menu.c'
fi
if test -f 'pcomm-2.0/d_prompt.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pcomm-2.0/d_prompt.c'\"
else
echo shar: Extracting \"'pcomm-2.0/d_prompt.c'\" \(6131 characters\)
sed "s/^X//" >'pcomm-2.0/d_prompt.c' <<'END_OF_FILE'
X/*
X * Prompt for directory entry changes. Copies the original values in
X * case you change your mind half way thru. A non-zero return code means
X * the entry was changed.
X */
X
X#include <stdio.h>
X#include <curses.h>
X#include "dial_dir.h"
X#include "misc.h"
X
Xint
Xprompt_lib(win, i)
XWINDOW *win;
Xint i;
X{
X extern int xmc;
X extern char *null_ptr;
X int n, dbits, sbits, spot;
X unsigned int baud;
X static unsigned int valid_baud[7] = {300, 1200, 2400, 4800, 9600,
X 19200, 38400};
X static char *valid_parity[3] = {"Even", "Odd", "None"};
X char *ans, *get_str(), c, temp, name[40], number[40], aux[40];
X char parity, duplex, *str_rep(), *strcpy(), buf[40];
X void free_ptr();
X /* make copies */
X strcpy(name, dir->name[i]);
X strcpy(number, dir->number[i]);
X baud = dir->baud[i];
X parity = dir->parity[i];
X dbits = dir->data_bits[i];
X sbits = dir->stop_bits[i];
X duplex = dir->duplex[i];
X strcpy(aux, dir->aux[i]);
X /* display original values */
X werase(win);
X mvwprintw(win, 2, 5, "%-20.20s %18.18s %5d-%c-%d-%d %c %-14.14s\n",
X dir->name[i], dir->number[i], dir->baud[i], dir->parity[i],
X dir->data_bits[i], dir->stop_bits[i], dir->duplex[i], dir->aux[i]);
X box(win, VERT, HORZ);
X
X /* prompt for name */
X mvwaddstr(win, 4, 4, "Name: ");
X wrefresh(win);
X
X if ((ans = get_str(win, 20, "", ";\n")) == NULL)
X return(0);
X if (*ans != '\0') {
X strcpy(name, ans);
X mvwaddstr(win, 2, 5, " ");
X wrefresh(win);
X mvwattrstr(win, 2, 5, A_BOLD, name);
X }
X /* prompt for number */
X clear_line(win, 4, 4, TRUE);
X waddstr(win, "Number: ");
X wrefresh(win);
X
X if ((ans = get_str(win, 18, "", ";\n")) == NULL)
X return(0);
X if (*ans != '\0') {
X strcpy(number, ans);
X mvwaddstr(win, 2, 26, " ");
X wrefresh(win);
X /*
X * Should be right justified, but we don't wanna have
X * the attribute turned on for blanks.
X */
X spot = 26 + 18 - strlen(number);
X mvwattrstr(win, 2, spot, A_BOLD, number);
X }
X /* template for next few */
X clear_line(win, 4, 4, TRUE);
X mvwaddstr(win, 4, 31, "(Any key to change, <CR> to accept)");
X
X /*
X * These next few prompts display a series of choices and allow
X * the user to hit <CR> to accept the currently showing value
X * or any other key to see the next choice. The first value
X * displayed is always the current value.
X */
X /* choose from baud menu */
X for (n=0; n<7; n++) {
X if (valid_baud[n] == baud)
X break;
X }
X mvwprintw(win, 4, 4, "Baud: %-5d", valid_baud[n]);
X wmove(win, 4, 10);
X wrefresh(win);
X
X while ((c = wgetch(win)) != '\r') {
X if (c == ESC)
X return(0);
X n = (n == 6) ? 0 : n+1;
X mvwprintw(win, 4, 4, "Baud: %-5d", valid_baud[n]);
X wmove(win, 4, 10);
X wrefresh(win);
X }
X if (baud != valid_baud[n]) {
X baud = valid_baud[n];
X sprintf(buf, "%5d", baud);
X if (xmc > 0) {
X sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
X mvwaddstr(win, 2, 46, " ");
X wrefresh(win);
X }
X mvwattrstr(win, 2, 46, A_BOLD, buf);
X }
X /* choose from parity menu */
X for (n=0; n<3; n++) {
X if (*valid_parity[n] == parity)
X break;
X }
X mvwprintw(win, 4, 4, "Parity: %-5.5s", valid_parity[n]);
X wmove(win, 4, 12);
X wrefresh(win);
X
X while ((c = wgetch(win)) != '\r') {
X if (c == ESC)
X return(0);
X n = (n == 2) ? 0 : n+1;
X mvwprintw(win, 4, 4, "Parity: %-5.5s", valid_parity[n]);
X wmove(win, 4, 12);
X wrefresh(win);
X }
X if (parity != *valid_parity[n]) {
X parity = *valid_parity[n];
X if (xmc > 0) {
X sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
X mvwaddstr(win, 2, 46, " ");
X wrefresh(win);
X mvwattrstr(win, 2, 46, A_BOLD, buf);
X }
X else
X mvwattrch(win, 2, 52, A_BOLD, parity);
X }
X /* choose from data bits menu */
X n = dbits;
X mvwprintw(win, 4, 4, "Data Bits: %d ", n);
X wmove(win, 4, 15);
X wrefresh(win);
X
X while ((c = wgetch(win)) != '\r') {
X if (c == ESC)
X return(0);
X n = (n == 8) ? 7 : 8;
X mvwprintw(win, 4, 4, "Data Bits: %d ", n);
X wmove(win, 4, 15);
X wrefresh(win);
X }
X if (dbits != n) {
X dbits = n;
X if (xmc > 0) {
X sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
X mvwaddstr(win, 2, 46, " ");
X wrefresh(win);
X mvwattrstr(win, 2, 46, A_BOLD, buf);
X }
X else
X mvwattrnum(win, 2, 54, A_BOLD, dbits);
X }
X /* choose from stop bits menu */
X n = sbits;
X mvwprintw(win, 4, 4, "Stop Bits: %d ", n);
X wmove(win, 4, 15);
X wrefresh(win);
X
X while ((c = wgetch(win)) != '\r') {
X if (c == ESC)
X return(0);
X n = (n == 2) ? 1 : 2;
X mvwprintw(win, 4, 4, "Stop Bits: %d ", n);
X wmove(win, 4, 15);
X wrefresh(win);
X }
X if (sbits != n) {
X sbits = n;
X if (xmc > 0) {
X sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
X mvwaddstr(win, 2, 46, " ");
X wrefresh(win);
X mvwattrstr(win, 2, 46, A_BOLD, buf);
X }
X else
X mvwattrnum(win, 2, 56, A_BOLD, sbits);
X }
X /* choose from duplex menu */
X temp = duplex;
X mvwprintw(win, 4, 4, "Duplex: %c ", temp);
X wmove(win, 4, 12);
X wrefresh(win);
X
X while ((c = wgetch(win)) != '\r') {
X if (c == ESC)
X return(0);
X temp = (temp == 'F') ? 'H' : 'F';
X mvwprintw(win, 4, 4, "Duplex: %c ", temp);
X wmove(win, 4, 12);
X wrefresh(win);
X }
X if (duplex != temp) {
X duplex = temp;
X mvwattrch(win, 2, 59, A_BOLD, duplex);
X }
X /* prompt for script, TTY, or modem */
X clear_line(win, 4, 4, TRUE);
X waddstr(win, "Auxiliary file: ");
X wrefresh(win);
X
X if ((ans = get_str(win, 17, "", ";\n")) == NULL)
X return(0);
X
X if (*ans != '\0') {
X strcpy(aux, ans);
X mvwaddstr(win, 2, 62, " ");
X wrefresh(win);
X mvwattrstr(win, 2, 62, A_BOLD, aux);
X }
X /* store 'em for real */
X
X if (!strcmp(name, " ")) {
X free_ptr(dir->name[i]);
X dir->name[i] = null_ptr;
X }
X else
X dir->name[i] = str_rep(dir->name[i], name);
X
X if (!strcmp(number, " ")) {
X free_ptr(dir->number[i]);
X dir->number[i] = null_ptr;
X }
X else
X dir->number[i] = str_rep(dir->number[i], number);
X
X dir->baud[i] = baud;
X dir->parity[i] = parity;
X dir->data_bits[i] = dbits;
X dir->stop_bits[i] = sbits;
X dir->duplex[i] = duplex;
X
X if (!strcmp(aux, " ")) {
X free_ptr(dir->aux[i]);
X dir->aux[i] = null_ptr;
X }
X else
X dir->aux[i] = str_rep(dir->aux[i], aux);
X
X return(1);
X}
END_OF_FILE
if test 6131 -ne `wc -c <'pcomm-2.0/d_prompt.c'`; then
echo shar: \"'pcomm-2.0/d_prompt.c'\" unpacked with wrong size!
fi
# end of 'pcomm-2.0/d_prompt.c'
fi
if test -f 'pcomm-2.0/input.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pcomm-2.0/input.c'\"
else
echo shar: Extracting \"'pcomm-2.0/input.c'\" \(7059 characters\)
sed "s/^X//" >'pcomm-2.0/input.c' <<'END_OF_FILE'
X/*
X * The input routines.
X */
X
X#include <stdio.h>
X#include "config.h"
X#include "misc.h"
X#include "param.h"
X#include "status.h"
X#include "vcs.h"
X
Xstatic int add_lf;
Xstatic void vs_scroll();
Xstatic FILE *logfp = (FILE *) NULL;
Xstatic FILE *lprfp = (FILE *) NULL;
X
X/*
X * Read the serial port and write the characters to the screen. Watch
X * for changes in status structure to toggle the fancy options.
X * Writes the characters received to a virtual screen buffer.
X */
X
Xvoid
Xtty_input()
X{
X extern int fd;
X register int in_cnt, out_cnt;
X char c, *bufp, in_buf[INPUT_BUF], out_buf[INPUT_BUF*2];
X void vs_putchar();
X
X /* here we go... */
X if ((in_cnt = read(fd, in_buf, INPUT_BUF)) <= 0)
X return;
X
X /*
X * If we're doing a script, send a duplicate down the pipe
X */
X if (status->dup_fd != -1)
X write(status->dup_fd, in_buf, in_cnt);
X
X /* "peel" the buffer one at a time */
X out_cnt = 0;
X bufp = in_buf;
X add_lf = !strcmp(param->cr_in, "CR/LF");
X while (--in_cnt >= 0) {
X c = *bufp++ & 0xff;
X /* send to logfile? */
X if (status->log_status) {
X if (c == '\r' && add_lf)
X putc('\n', logfp);
X /* no carriage returns in logfile */
X if (c != '\r')
X putc(c, logfp);
X }
X /* send to printer too? */
X if (status->print_status)
X putc(c, lprfp);
X
X /* put a char in virtual screen */
X vs_putchar(c);
X
X /* build the output buffer */
X out_buf[out_cnt++] = c;
X if (c == '\r' && add_lf)
X out_buf[out_cnt++] = '\n';
X
X /* output in smaller chunks */
X if (out_cnt >= OUTPUT_BUF) {
X write(1, out_buf, out_cnt);
X out_cnt = 0;
X }
X }
X if (out_cnt)
X write(1, out_buf, out_cnt);
X
X return;
X}
X
X/*
X * Put a character in the virtual screen. This routine saves incoming
X * characters in a two dimensional buffer designed to mimic the real
X * screen.
X */
X
Xvoid
Xvs_putchar(c)
Xchar c;
X{
X register int i;
X extern int vcs_param[NUM_VCS][5], vcs_opt[NUM_VCS][10];
X char *memset();
X int tab_stop;
X
X switch (vcs_filter(c)) {
X case MAYBE: /* wait and see... */
X break;
X case 256+HOME: /* home virtual screen "cursor" */
X status->row = 0;
X status->col = 0;
X break;
X case 256+CLR_EOL: /* clear to end of line */
X memset(&status->vs[status->row][status->col], ' ', status->max_col - status->col);
X status->col = status->max_col -1;
X break;
X case 256+CLR_EOS: /* clear to end of screen */
X memset(&status->vs[status->row][status->col], ' ', status->max_col - status->col);
X for (i=status->row+1; i<status->max_row; i++)
X memset(status->vs[i], ' ', status->max_col);
X status->row = status->max_row -1;
X status->col = status->max_col -1;
X break;
X case 256+CLEAR: /* clear all and home "cursor" */
X for (i=0; i<status->max_row; i++)
X memset(status->vs[i], ' ', status->max_col);
X status->row = 0;
X status->col = 0;
X break;
X case 256+MV_UP: /* move "cursor" up */
X status->row--;
X if (status->row < 0)
X status->row = 0;
X break;
X case 256+MV_DOWN: /* move "cursor" down */
X status->row++;
X if (status->row >= status->max_row)
X status->row = status->max_row -1;
X break;
X case 256+MV_RIGHT: /* move "cursor" right */
X status->col++;
X if (status->col >= status->max_col)
X status->col = status->max_col -1;
X break;
X case 256+MV_LEFT: /* move "cursor" left */
X case BS: /* non destructive back space */
X status->col--;
X if (status->col < 0)
X status->col = 0;
X break;
X case 256+MV_DIRECT: /* direct cursor movement */
X status->row = vcs_param[MV_DIRECT][0];
X status->col = vcs_param[MV_DIRECT][1];
X
X /* if "add one" and "decimal" */
X if (vcs_opt[MV_DIRECT][0] && vcs_opt[MV_DIRECT][1]) {
X status->row--;
X status->col--;
X }
X /* if "character" */
X if (vcs_opt[MV_DIRECT][2]) {
X /* if "add offset" */
X if (vcs_opt[MV_DIRECT][3]) {
X status->row -= vcs_opt[MV_DIRECT][5];
X status->col -= vcs_opt[MV_DIRECT][5];
X }
X /* if "subtract offset" */
X if (vcs_opt[MV_DIRECT][4]) {
X status->row += vcs_opt[MV_DIRECT][5];
X status->col += vcs_opt[MV_DIRECT][5];
X }
X status->row--;
X status->col--;
X }
X break;
X case 0:
X case 7: /* skip NULL and "bell" character */
X break;
X case '\t': /* tab character */
X tab_stop = status->col + 8 - (status->col % 8);
X /* if wrap around */
X if (tab_stop >= status->max_col) {
X /* spaces up to eol */
X memset(&status->vs[status->row][status->col], ' ', status->max_col - status->col);
X status->row++;
X if (status->row >= status->max_row)
X vs_scroll();
X
X /* the remainder of the tab */
X status->col = tab_stop - status->max_col;
X }
X else {
X memset(&status->vs[status->row][status->col], ' ', tab_stop - status->col);
X status->col = tab_stop;
X }
X break;
X case '\r': /* carriage return */
X status->col = 0;
X if (!add_lf)
X break;
X /* FALLTHRU */
X case '\n': /* line feed */
X status->row++;
X if (status->row >= status->max_row)
X vs_scroll();
X break;
X default: /* a normal character */
X status->vs[status->row][status->col] = c;
X status->col++;
X /* wrap around */
X if (status->col >= status->max_col) {
X status->col = 0;
X status->row++;
X if (status->row >= status->max_row)
X vs_scroll();
X }
X break;
X }
X return;
X}
X
X/*
X * Do a software scroll on the virtual screen. Does not alter the
X * "col" variable.
X */
X
Xstatic void
Xvs_scroll()
X{
X char *memset();
X /* move 'em up 1 line */
X#ifdef MEMMOVE
X MEMMOVE(status->vs[0], status->vs[1], (status->max_row -1) * MAX_COL);
X#else /* MEMMOVE */
X register int i;
X char *strcpy();
X
X for (i=0; i<status->max_row-1; i++)
X strcpy(status->vs[i], status->vs[i+1]);
X#endif /* MEMMOVE */
X /* clear the bottom line */
X memset(status->vs[status->max_row-1], ' ', status->max_col);
X
X status->row = status->max_row -1;
X return;
X}
X
X/*
X * A short-cut for charcters that are "echoed" in the half duplex
X * mode. Since the TTY driver is putting the characters on the
X * screen (rather than being sent back by the modem), they need
X * to be faked as modem input.
X */
X
Xvoid
Xhalf_duplex(c)
Xchar c;
X{
X /* send to logfile? */
X if (status->log_status) {
X if (c == '\r' && add_lf)
X putc('\n', logfp);
X /* no carriage returns in logfile */
X if (c != '\r')
X putc(c, logfp);
X }
X /* send to printer too? */
X if (status->print_status)
X putc(c, lprfp);
X
X /* put a char in virtual screen */
X vs_putchar(c);
X return;
X}
X
X/*
X * Toggle the printer log
X */
X
Xvoid
Xlpr_toggle()
X{
X FILE *n_popen();
X
X status->print_status = status->print_status ? 0 : 1;
X
X if (status->print_status && lprfp == NULL) {
X if (!(lprfp = n_popen(LPR, "w")))
X status->print_status = 0;
X }
X
X if (!status->print_status && lprfp != NULL) {
X putc('\f', lprfp);
X n_pclose(lprfp);
X lprfp = (FILE *) NULL;
X }
X return;
X}
X
X/*
X * Toggle the data log
X */
X
Xvoid
Xlog_toggle()
X{
X FILE *uid_fopen();
X
X status->log_status = status->log_status ? 0 : 1;
X
X if (status->log_status && logfp == NULL) {
X if (!(logfp = uid_fopen(status->log_path, "a")))
X status->log_status = 0;
X }
X
X if (!status->log_status && logfp != NULL) {
X fclose(logfp);
X logfp = (FILE *) NULL;
X }
X return;
X}
END_OF_FILE
if test 7059 -ne `wc -c <'pcomm-2.0/input.c'`; then
echo shar: \"'pcomm-2.0/input.c'\" unpacked with wrong size!
fi
# end of 'pcomm-2.0/input.c'
fi
if test -f 'pcomm-2.0/s_modem.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pcomm-2.0/s_modem.c'\"
else
echo shar: Extracting \"'pcomm-2.0/s_modem.c'\" \(6948 characters\)
sed "s/^X//" >'pcomm-2.0/s_modem.c' <<'END_OF_FILE'
X/*
X * Display the modem setup, query for changes. A non-zero return code
X * means something was changed.
X */
X
X#include <stdio.h>
X#include <curses.h>
X#include "misc.h"
X#include "modem.h"
X
Xstatic int mod_prompt();
Xstatic void disp_modem();
X
Xint
Xmodem_setup()
X{
X WINDOW *mo_win, *newwin();
X int i, j, ret_code;
X char *ans, *str_rep(), *str_prompt(), *menu_prompt();
X extern char *v_yn[];
X /* the current modem */
X j = 0;
X if (modem->m_cur != -1)
X j = modem->m_cur;
X
X mo_win = newwin(23, 80, 0, 0);
X
X horizontal(mo_win, 0, 0, 33);
X mvwattrstr(mo_win, 0, 34, A_BOLD, "Modem Setup");
X horizontal(mo_win, 0, 46, 34);
X /* display the current settings */
X disp_modem(mo_win, j);
X horizontal(mo_win, 19, 0, 80);
X mvwattrstr(mo_win, 20, 0, A_BOLD, "OPTION ==> ");
X mvwaddstr(mo_win, 20, 58, "Press <ESC> to return");
X wmove(mo_win, 20, 12);
X touchwin(mo_win);
X wrefresh(mo_win);
X /* get the option number */
X ret_code = 0;
X while ((i = get_num(mo_win, 2)) != -1) {
X switch (i) {
X case 1:
X j = mod_prompt(mo_win);
X break;
X case 2:
X if ((ans = str_prompt(mo_win, 3, 39, "Modem init string", "sent to the modem once")) != NULL) {
X modem->init[j] = str_rep(modem->init[j], ans);
X ret_code++;
X }
X break;
X case 3:
X if ((ans = str_prompt(mo_win, 4, 39, "Dialing command", "")) != NULL) {
X modem->dial[j] = str_rep(modem->dial[j], ans);
X ret_code++;
X }
X break;
X case 4:
X if ((ans = str_prompt(mo_win, 5, 39, "Dialing cmd suffix", "typically the <CR> character")) != NULL) {
X modem->suffix[j] = str_rep(modem->suffix[j], ans);
X ret_code++;
X }
X break;
X case 5:
X if ((ans = str_prompt(mo_win, 6, 39, "Hang up string", "")) != NULL) {
X modem->hang_up[j] = str_rep(modem->hang_up[j], ans);
X ret_code++;
X }
X break;
X case 6:
X if ((ans = menu_prompt(mo_win, 7, 39, "Auto Baud detect", v_yn)) != NULL) {
X modem->auto_baud[j] = *ans;
X ret_code++;
X }
X break;
X case 7:
X if ((ans = str_prompt(mo_win, 8, 39, "300 baud connect string", "")) != NULL) {
X modem->con_3[j] = str_rep(modem->con_3[j], ans);
X ret_code++;
X }
X break;
X case 8:
X if ((ans = str_prompt(mo_win, 9, 39, "1200 baud connect string", "")) != NULL) {
X modem->con_12[j] = str_rep(modem->con_12[j], ans);
X ret_code++;
X }
X break;
X case 9:
X if ((ans = str_prompt(mo_win, 10, 39, "2400 baud connect string", "")) != NULL) {
X modem->con_24[j] = str_rep(modem->con_24[j], ans);
X ret_code++;
X }
X break;
X case 10:
X if ((ans = str_prompt(mo_win, 11, 39, "4800 baud connect string", "")) != NULL) {
X modem->con_48[j] = str_rep(modem->con_48[j], ans);
X ret_code++;
X }
X break;
X case 11:
X if ((ans = str_prompt(mo_win, 12, 39, "9600 baud connect string", "")) != NULL) {
X modem->con_96[j] = str_rep(modem->con_96[j], ans);
X ret_code++;
X }
X break;
X case 12:
X if ((ans = str_prompt(mo_win, 13, 39, "19200 baud connect string", "")) != NULL) {
X modem->con_192[j] = str_rep(modem->con_192[j], ans);
X ret_code++;
X }
X break;
X case 13:
X if ((ans = str_prompt(mo_win, 14, 39, "38400 baud connect string", "")) != NULL) {
X modem->con_384[j] = str_rep(modem->con_384[j], ans);
X ret_code++;
X }
X break;
X case 14:
X if ((ans = str_prompt(mo_win, 15, 39, "No connect string 1", "")) != NULL) {
X modem->no_con1[j] = str_rep(modem->no_con1[j], ans);
X ret_code++;
X }
X break;
X case 15:
X if ((ans = str_prompt(mo_win, 16, 39, "No connect string 2", "")) != NULL) {
X modem->no_con2[j] = str_rep(modem->no_con2[j], ans);
X ret_code++;
X }
X break;
X case 16:
X if ((ans = str_prompt(mo_win, 17, 39, "No connect string 3", "")) != NULL) {
X modem->no_con3[j] = str_rep(modem->no_con3[j], ans);
X ret_code++;
X }
X break;
X case 17:
X if ((ans = str_prompt(mo_win, 18, 39, "No connect string 4", "")) != NULL) {
X modem->no_con4[j] = str_rep(modem->no_con4[j], ans);
X ret_code++;
X }
X break;
X default:
X beep();
X }
X /* clear the previous prompts */
X mvwaddstr(mo_win, 20, 12, " ");
X clear_line(mo_win, 21, 0, FALSE);
X clear_line(mo_win, 22, 0, FALSE);
X wmove(mo_win, 20, 12);
X wrefresh(mo_win);
X }
X delwin(mo_win);
X return(ret_code);
X}
X
X/*
X * Prompts for the modem name. The user selects the currently showing
X * choice by hitting a carriage return. Returns the modem entry number.
X * DOES NOT change the value of modem->m_cur.
X */
X
Xstatic int
Xmod_prompt(win)
XWINDOW *win;
X{
X char ans;
X int i;
X void disp_modem();
X /* print prompt lines */
X mvwaddstr(win, 22, 0, "Press any key to change, or <CR> to accept");
X mvwaddstr(win, 21, 0, "Modem name: ");
X /* show current choice */
X i = 0;
X if (modem->m_cur != -1)
X i = modem->m_cur;
X mvwprintw(win, 21, 12, "%-30.30s", modem->mname[i]);
X wmove(win, 21, 12);
X wrefresh(win);
X /* show the choices one at a time */
X while ((ans = wgetch(win)) != '\r') {
X i++;
X if (*modem->mname[i] == '\0')
X i = 0;
X if (ans == ESC)
X return(0);
X mvwprintw(win, 21, 12, "%-30.30s", modem->mname[i]);
X wmove(win, 21, 12);
X wrefresh(win);
X }
X /* display the new values */
X disp_modem(win, i);
X /* display the name in bold */
X clear_line(win, 2, 39, FALSE);
X wrefresh(win);
X mvwattrstr(win, 2, 39, A_BOLD, modem->mname[i]);
X mvwprintw(win, 2, 25, "(%d of %d) ", i+1, modem->m_entries);
X
X return(i);
X}
X
X/*
X * Show the current settings for the given modem entry number.
X */
X
Xstatic void
Xdisp_modem(w, i)
XWINDOW *w;
Xint i;
X{
X mvwprintw(w, 2, 11, "1) Modem name ............. %-39.39s", modem->mname[i]);
X mvwprintw(w, 2, 25, "(%d of %d) ", i+1, modem->m_entries);
X mvwprintw(w, 3, 11, "2) Modem init string ...... %-39.39s", modem->init[i]);
X mvwprintw(w, 4, 11, "3) Dialing command ........ %-39.39s", modem->dial[i]);
X mvwprintw(w, 5, 11, "4) Dialing cmd suffix ..... %-39.39s", modem->suffix[i]);
X mvwprintw(w, 6, 11, "5) Hang up string ......... %-39.39s", modem->hang_up[i]);
X mvwprintw(w, 7, 11, "6) Auto baud detect ....... %c", modem->auto_baud[i]);
X mvwprintw(w, 8, 11, "7) 300 baud connect ....... %-39.39s", modem->con_3[i]);
X mvwprintw(w, 9, 11, "8) 1200 baud connect ...... %-39.39s", modem->con_12[i]);
X mvwprintw(w, 10, 11, "9) 2400 baud connect ...... %-39.39s", modem->con_24[i]);
X mvwprintw(w, 11, 10, "10) 4800 baud connect ...... %-39.39s", modem->con_48[i]);
X mvwprintw(w, 12, 10, "11) 9600 baud connect ...... %-39.39s", modem->con_96[i]);
X mvwprintw(w, 13, 10, "12) 19200 baud connect ..... %-39.39s", modem->con_192[i]);
X mvwprintw(w, 14, 10, "13) 38400 baud connect ..... %-39.39s", modem->con_384[i]);
X mvwprintw(w, 15, 10, "14) No connect string 1 .... %-39.39s", modem->no_con1[i]);
X mvwprintw(w, 16, 10, "15) No connect string 2 .... %-39.39s", modem->no_con2[i]);
X mvwprintw(w, 17, 10, "16) No connect string 3 .... %-39.39s", modem->no_con3[i]);
X mvwprintw(w, 18, 10, "17) No connect string 4 .... %-39.39s", modem->no_con4[i]);
X return;
X}
END_OF_FILE
if test 6948 -ne `wc -c <'pcomm-2.0/s_modem.c'`; then
echo shar: \"'pcomm-2.0/s_modem.c'\" unpacked with wrong size!
fi
# end of 'pcomm-2.0/s_modem.c'
fi
if test -f 'pcomm-2.0/script.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pcomm-2.0/script.c'\"
else
echo shar: Extracting \"'pcomm-2.0/script.c'\" \(5862 characters\)
sed "s/^X//" >'pcomm-2.0/script.c' <<'END_OF_FILE'
X/*
X * Spawn a shell with file descriptors that look like this:
X *
X * + ---> screen (& virtual screen)
X * |
X * +---------+ +-----------+
X * | | <---> cmd IPC <---> | pcomm_cmd |
X * | Pcomm | +-----------+
X * TTYin ---> | | ---> pipe --> stdin | |
X * +---------+ | shell |
X * TTYout <--------------------------- stdout | |
X * +-----------+
X *
X * This allows the characters to appear on the screen *and* be interpreted
X * by the shell script.
X */
X
X#include <stdio.h>
X#include <curses.h>
X#include <signal.h>
X#include <errno.h>
X#include "config.h"
X#include "dial_dir.h"
X#include "misc.h"
X#include "modem.h"
X#include "status.h"
X
Xstatic int epid, dup_pipe[2];
Xstatic char **fixup_env();
X
Xvoid
Xdo_script(script)
Xchar *script;
X{
X extern int fd;
X char buf[80], *path, *findfile(), **envp, *ipc_key(), *strcpy();
X void _exit(), error_win(), ipc_update();
X
X if (*script == '\0')
X return;
X /*
X * Chaining of scripts, is not allowed. If a script performs the
X * "pcomm_cmd dial" command and that dialing directory entry has
X * something in the script field, then ignore the second script.
X */
X if (status->dup_fd != -1)
X return;
X /* find the script file */
X if ((path = findfile(script)) == NULL) {
X /*
X * Fail quietly, if the script is actually a TTY or a
X * modem
X */
X if (chk_aux(script) != IS_SCRIPT)
X return;
X
X sprintf(buf, "Can't locate script \"%s\"", script);
X error_win(0, buf, "");
X return;
X }
X /* execute permission ? */
X if (access(path, 1)) {
X sprintf(buf, "\"%s\"", path);
X error_win(0, "No execute permission on script file", buf);
X return;
X }
X /*
X * If a script is invoked prior to dialing, then we need to
X * pass a valid "fd" to the child process. If the script
X * then does a "pcomm_cmd dial", it *must* use that fd.
X */
X if (fd == -1) {
X dir->d_cur = 0;
X dir->q_num[0] = 0;
X if (get_port())
X return;
X }
X /* create a fd for duplicating input */
X if (pipe(dup_pipe) < 0) {
X error_win(0, "Out of pipe resources", "");
X return;
X }
X
X status->dup_fd = dup_pipe[1];
X /* open an IPC channel */
X if ((status->cmd_ipc = ipc_open()) < 0) {
X close(dup_pipe[0]);
X close(dup_pipe[1]);
X status->dup_fd = -1;
X error_win(0, "Can't open IPC channel", "");
X return;
X }
X ipc_update(fd, status->cmd_ipc);
X /* pass the "key" in the environment */
X strcpy(buf, ipc_key(status->cmd_ipc));
X envp = fixup_env(buf);
X
X if (!(epid = fork())) {
X /* create a new process group ID */
X#ifdef BSD
X setpgrp(0, getpid());
X#else /* BSD */
X setpgrp();
X#endif /* BSD */
X /* swap the stdin and stdout */
X close(0);
X dup(dup_pipe[0]);
X close(1);
X dup(fd);
X
X setgid(getgid());
X setuid(getuid());
X
X execle("/bin/sh", "sh", "-c", path, (char *) 0, envp);
X _exit(1);
X }
X return;
X}
X
X/*
X * See if the script process is still active
X */
X
Xvoid
Xis_active()
X{
X extern int errno, fd;
X int dummy;
X void ipc_update();
X
X if ((kill(epid, 0) == -1) && errno == ESRCH) {
X /* shut down the duplication of input */
X close(dup_pipe[0]);
X close(dup_pipe[1]);
X ipc_close(status->cmd_ipc);
X
X status->dup_fd = -1;
X status->cmd_ipc = -1;
X ipc_update(fd, status->cmd_ipc);
X
X wait(&dummy);
X beep();
X }
X return;
X}
X
X/*
X * Abort the script prematurely.
X */
X
Xvoid
Xstop_script()
X{
X extern int fd;
X int dummy;
X unsigned int sleep();
X void ipc_update();
X
X#ifdef BSD
X killpg(epid, SIGKILL);
X#else /* BSD */
X kill(-epid, SIGKILL);
X#endif /* BSD */
X
X sleep(1);
X
X close(dup_pipe[0]);
X close(dup_pipe[1]);
X ipc_close(status->cmd_ipc);
X
X status->dup_fd = -1;
X status->cmd_ipc = -1;
X ipc_update(fd, status->cmd_ipc);
X
X wait(&dummy);
X return;
X}
X
X/*
X * Prompt the user for a shell script.
X */
X
Xchar *
Xscript_menu()
X{
X extern int fd;
X WINDOW *sc_win, *newwin();
X char *ans, *script, *get_str(), *findfile(), *str_dup(), *path;
X char *strchr(), buf[80], *strcpy();
X void free_ptr(), error_win();
X
X if (status->dup_fd != -1) {
X error_win(0, "A script is already running", "Concurrent scripts are not allowed");
X return(NULL);
X }
X
X sc_win = newwin(5, 55, 4, 7);
X
X box(sc_win, VERT, HORZ);
X mvwaddstr(sc_win, 2, 4, "Shell script: ");
X mvwattrstr(sc_win, 0, 3, A_BOLD, " Command Files ");
X wmove(sc_win, 2, 18);
X wrefresh(sc_win);
X
X script = NULL;
X strcpy(buf, "Shell script not found");
X /* get the answer */
X while ((ans = get_str(sc_win, 80, "", " \t\n")) != NULL) {
X /* a CR means exit */
X if (*ans == '\0')
X break;
X /* see if we can find it */
X if ((path = findfile(ans)) != NULL) {
X if (!access(path, 1)) {
X free_ptr(path);
X script = str_dup(ans);
X break;
X }
X else
X strcpy(buf, "No execute permission");
X }
X
X beep();
X if (strchr(ans, '/'))
X strcpy(buf, "Don't include the path");
X
X mvwattrstr(sc_win, 3, 16, A_BOLD, buf);
X wrefresh(sc_win);
X wait_key(sc_win, 3);
X /* clean up the mess */
X clear_line(sc_win, 2, 18, TRUE);
X clear_line(sc_win, 3, 16, TRUE);
X wmove(sc_win, 2, 18);
X wrefresh(sc_win);
X
X free_ptr(path);
X }
X if (fd == -1) {
X werase(sc_win);
X wrefresh(sc_win);
X }
X delwin(sc_win);
X return(script);
X}
X
X/*
X * Put PCOMM_CMD into a new environmental variable array.
X */
X
Xstatic char **
Xfixup_env(key)
Xchar *key;
X{
X int n;
X extern char **environ;
X char **envp, buf[80], **temp, *malloc(), *str_dup();
X
X /* how many variables do we have? */
X temp = environ;
X n = 0;
X while (*temp != NULL) {
X n++;
X temp++;
X }
X
X envp = (char **) malloc((n+2) * sizeof(char *));
X temp = envp;
X while (*environ != NULL) {
X /* don't copy an old value */
X if (strncmp(*environ, "PCOMM_CMD=", 10)) {
X *temp = str_dup(*environ);
X temp++;
X }
X environ++;
X }
X sprintf(buf, "PCOMM_CMD=%s", key);
X *temp = str_dup(buf);
X temp++;
X *temp = NULL;
X return(envp);
X}
END_OF_FILE
if test 5862 -ne `wc -c <'pcomm-2.0/script.c'`; then
echo shar: \"'pcomm-2.0/script.c'\" unpacked with wrong size!
fi
# end of 'pcomm-2.0/script.c'
fi
if test -f 'pcomm-2.0/x_ascii.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pcomm-2.0/x_ascii.c'\"
else
echo shar: Extracting \"'pcomm-2.0/x_ascii.c'\" \(6560 characters\)
sed "s/^X//" >'pcomm-2.0/x_ascii.c' <<'END_OF_FILE'
X/*
X * Transfer a file using just XON/XOFF flow control. Currently limited to
X * 7 bit ASCII codes. (If this causes too much trouble, I'll change it).
X */
X
X#include <stdio.h>
X#include <curses.h>
X#include <signal.h>
X#include "config.h"
X#include "misc.h"
X#include "param.h"
X
X#ifdef BSD
X#include <setjmp.h>
Xjmp_buf bl_buf;
X#endif /* BSD */
X
Xstatic void send_ascii(), rcv_ascii(), putc_ascii();
Xstatic int bgetc_line(), buf_read();
X
Xvoid
Xxfer_ascii(list, up)
Xchar *list;
Xint up;
X{
X int cr_lf;
X char *file, *strtok();
X void line_set(), st_line();
X void ascii_mode(), term_mode();
X unsigned int sleep();
X
X touchwin(stdscr);
X refresh();
X /* only one file from list */
X file = strtok(list, " \t");
X
X cr_lf = !strcmp(param->cr_out, "CR/LF");
X ascii_mode(up);
X /* out of curses mode */
X resetterm();
X term_mode();
X tty_noblock(0, TRUE);
X
X if (up)
X send_ascii(file, cr_lf);
X else
X rcv_ascii(file, cr_lf);
X
X /*
X * Restoring the TTY modes is easier than setting them... The
X * fixterm() and line_set() routines fix most of the damage.
X */
X line_set();
X fixterm();
X tty_noblock(0, FALSE);
X
X beep();
X st_line("xfer complete");
X
X sleep(2);
X return;
X}
X
X/*
X * Send a file. The local echo option is independent of the duplex option,
X * and would very rarely be used since the characters are most likely
X * being echoed on the screen anyway.
X */
X
Xstatic void
Xsend_ascii(file, cr_lf)
Xchar *file;
Xint cr_lf;
X{
X extern int fd;
X FILE *fp, *uid_fopen();
X int i, j, strip_cr, strip_lf, add_cr, add_lf, expand, local_echo, pace;
X char buf[80], c, last;
X unsigned int sleep();
X void error_win();
X /* permission already checked */
X if (!(fp = uid_fopen(file, "r"))) {
X sprintf(buf, "\"%s\"", file);
X error_win(0, "Can't open file for read", buf);
X return;
X }
X /* ASCII transfer options */
X strip_cr = !strcmp(param->cr_up, "STRIP");
X add_lf = !strcmp(param->cr_up, "ADD LF");
X strip_lf = !strcmp(param->lf_up, "STRIP");
X add_cr = !strcmp(param->lf_up, "ADD CR");
X expand = !strcmp(param->expand, "YES");
X local_echo = !strcmp(param->local_echo, "YES");
X pace = !strcmp(param->pace, "YES");
X
X last = 0;
X while ((i = fgetc(fp)) != EOF) {
X /* any keyboard activity? */
X switch (j = getchar()) {
X case -1: /* no key was pressed */
X break;
X case ESC: /* <ESC> key for abort */
X fclose(fp);
X sleep(2);
X tty_drain(fd);
X return;
X default: /* send the char */
X c = (char) j & 0x7f;
X putc_ascii(c, local_echo);
X if (c == '\r' && cr_lf)
X putc_ascii('\n', local_echo);
X break;
X }
X c = (char) i & 0x7f;
X /* expand blank lines */
X if (expand && last == '\n' && c == '\n')
X putc_ascii(' ', local_echo);
X last = c;
X
X /* CR translations */
X if (c == '\r' && strip_cr)
X continue;
X if (c == '\r' && add_lf) {
X putc_ascii(c, local_echo);
X putc_ascii('\n', local_echo);
X continue;
X }
X /* LF translations */
X if (c == '\n' && strip_lf)
X continue;
X if (c == '\n' && add_cr)
X putc_ascii('\r', local_echo);
X
X putc_ascii(c, local_echo);
X /*
X * There's really no mechanism for delaying characters
X * going to the output, so we fake it by waiting for
X * each character to clear the I/O buffer.
X */
X if (pace)
X tty_drain(fd);
X }
X fclose(fp);
X sleep(2);
X tty_drain(fd);
X return;
X}
X
X/* Put a character on the line, echo it too, if required */
X
Xstatic void
Xputc_ascii(c, local_echo)
Xchar c;
Xint local_echo;
X{
X extern int fd;
X void vs_putchar();
X
X write(fd, &c, 1);
X if (local_echo) {
X write(1, &c, 1);
X vs_putchar(c);
X }
X return;
X}
X
X/*
X * Receive a file. The timer is used to end the transfer. This is not
X * that much different from the data logging option. The use of bgetc_line()
X * and non-blocking input makes it seem like full duplex, but it's not.
X * Be aware that while the timer is active the keyboard is deaf.
X */
X
Xstatic void
Xrcv_ascii(file, cr_lf)
Xchar *file;
Xint cr_lf;
X{
X FILE *fp, *uid_fopen();
X int i, strip_cr, strip_lf, add_cr, add_lf, got_first;
X unsigned int delay;
X char c, buf[80];
X void error_win(), vs_putchar();
X /* permission already checked */
X if (!(fp = uid_fopen(file, "w"))) {
X sprintf(buf, "\"%s\"", file);
X error_win(0, "Can't open file for write", buf);
X return;
X }
X /* ASCII transfer options */
X strip_cr = !strcmp(param->cr_dn, "STRIP");
X add_lf = !strcmp(param->cr_dn, "ADD LF");
X strip_lf = !strcmp(param->lf_dn, "STRIP");
X add_cr = !strcmp(param->lf_dn, "ADD CR");
X
X got_first = 0;
X delay = 1;
X /* CONSTCOND */
X while (1) {
X /* keyboard activity */
X switch (i = getchar()) {
X case -1: /* no key was pressed */
X break;
X case ESC: /* <ESC> key */
X fclose(fp);
X return;
X default: /* send it */
X c = (unsigned int) i;
X putc_line((unsigned char) c);
X if (c == '\r' && cr_lf)
X putc_line('\n');
X break;
X }
X /* read a character */
X if ((i = bgetc_line(delay)) == -1) {
X /*
X * The transfer timeout is not activated until the
X * first character is received. Until then, it polls
X * the line for one second and loops backs for
X * keyboard input.
X */
X if (got_first) {
X fclose(fp);
X return;
X }
X continue;
X }
X got_first = 1;
X delay = param->timer;
X c = i & 0x7f;
X /* display it on the screen */
X write(1, &c, 1);
X vs_putchar(c);
X /* CR translations */
X if (c == '\r' && strip_cr)
X continue;
X if (c == '\r' && add_lf) {
X fputc(c, fp);
X fputc('\n', fp);
X continue;
X }
X /* LF translations */
X if (c == '\n' && strip_lf)
X continue;
X if (c == '\n' && add_cr) {
X fputc('\r', fp);
X fputc(c, fp);
X continue;
X }
X fputc(c, fp);
X }
X}
X
X/*
X * Get a character from the line (using buffered I/O) with a specified
X * time-out period in seconds. If the function times-out, it returns a -1.
X */
X
Xstatic int bl_flag;
Xstatic int bl_force();
X
Xstatic int
Xbgetc_line(sec)
Xunsigned int sec;
X{
X int c;
X unsigned int alarm();
X
X signal(SIGALRM, (SIG_TYPE(*) ()) bl_force);
X bl_flag = 0;
X
X alarm(sec);
X
X#ifdef BSD
X if (setjmp(bl_buf))
X return(-1);
X#endif /* BSD */
X
X if ((c = buf_read()) < 0) {
X alarm(0);
X return(-1);
X }
X if (bl_flag)
X return(-1);
X alarm(0);
X return(c);
X}
X
X/* ARGSUSED */
Xstatic int
Xbl_force(dummy)
Xint dummy;
X{
X#ifdef BSD
X longjmp(bl_buf, 1);
X#else /* BSD */
X signal(SIGALRM, (SIG_TYPE(*) ()) bl_force);
X bl_flag = 1;
X return(0);
X#endif /* BSD */
X}
X
X/*
X * Do a single character buffered read from the serial port.
X */
X
Xstatic int
Xbuf_read()
X{
X extern int fd;
X static char buf[CLIST_SIZ];
X static char *bufp = buf;
X static int n = 0;
X
X if (n <= 0) {
X n = read(fd, buf, CLIST_SIZ);
X bufp = buf;
X }
X if (--n >= 0)
X return(*bufp++ & 0xff);
X return(-1);
X}
END_OF_FILE
if test 6560 -ne `wc -c <'pcomm-2.0/x_ascii.c'`; then
echo shar: \"'pcomm-2.0/x_ascii.c'\" unpacked with wrong size!
fi
# end of 'pcomm-2.0/x_ascii.c'
fi
echo shar: End of archive 3 \(of 8\).
cp /dev/null ark3isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 8 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
Frank Kaefer # fkk@stasys.sta.sub.org # Starnberg, Germany
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads