diff options
author | Greg Hudson <ghudson@mit.edu> | 1997-09-14 18:12:16 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 1997-09-14 18:12:16 +0000 |
commit | ce6018836c422c86a729ba39fe5433ec11b87b02 (patch) | |
tree | cc2e6601489384fcf41e0565e8906822897b46c8 | |
parent | ac16f380e349fa39ec7e26bccb5456cb300006a5 (diff) |
Pull in sources from zephyr locker. See /mit/zephyr/repository for
detailed change information.
150 files changed, 1586 insertions, 5482 deletions
diff --git a/util.old/et/.Imakefile,l b/util.old/et/.Imakefile,l deleted file mode 100644 index 6d6483e..0000000 --- a/util.old/et/.Imakefile,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/Imakefile
\ No newline at end of file diff --git a/util.old/et/.com_err.3,l b/util.old/et/.com_err.3,l deleted file mode 100644 index 4190732..0000000 --- a/util.old/et/.com_err.3,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/com_err.3
\ No newline at end of file diff --git a/util.old/et/.com_err.c,l b/util.old/et/.com_err.c,l deleted file mode 100644 index c1144a0..0000000 --- a/util.old/et/.com_err.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/com_err.c
\ No newline at end of file diff --git a/util.old/et/.com_err.h,l b/util.old/et/.com_err.h,l deleted file mode 100644 index 738cd08..0000000 --- a/util.old/et/.com_err.h,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/com_err.h
\ No newline at end of file diff --git a/util.old/et/.com_err.texinfo,l b/util.old/et/.com_err.texinfo,l deleted file mode 100644 index 5e51a58..0000000 --- a/util.old/et/.com_err.texinfo,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/com_err.texinfo
\ No newline at end of file diff --git a/util.old/et/.compile_et.1,l b/util.old/et/.compile_et.1,l deleted file mode 100644 index a72e7b9..0000000 --- a/util.old/et/.compile_et.1,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/compile_et.1
\ No newline at end of file diff --git a/util.old/et/.compile_et.c,l b/util.old/et/.compile_et.c,l deleted file mode 100644 index 13c8234..0000000 --- a/util.old/et/.compile_et.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/compile_et.c
\ No newline at end of file diff --git a/util.old/et/.compiler.h,l b/util.old/et/.compiler.h,l deleted file mode 100644 index bfb5287..0000000 --- a/util.old/et/.compiler.h,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/compiler.h
\ No newline at end of file diff --git a/util.old/et/.error_message.c,l b/util.old/et/.error_message.c,l deleted file mode 100644 index ff27856..0000000 --- a/util.old/et/.error_message.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/error_message.c
\ No newline at end of file diff --git a/util.old/et/.error_table.h,l b/util.old/et/.error_table.h,l deleted file mode 100644 index 761375e..0000000 --- a/util.old/et/.error_table.h,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/error_table.h
\ No newline at end of file diff --git a/util.old/et/.error_table.y,l b/util.old/et/.error_table.y,l deleted file mode 100644 index 6f6743f..0000000 --- a/util.old/et/.error_table.y,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/error_table.y
\ No newline at end of file diff --git a/util.old/et/.et_lex.lex.l,l b/util.old/et/.et_lex.lex.l,l deleted file mode 100644 index e76d177..0000000 --- a/util.old/et/.et_lex.lex.l,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/et_lex.lex.l
\ No newline at end of file diff --git a/util.old/et/.et_name.c,l b/util.old/et/.et_name.c,l deleted file mode 100644 index 9edb7d3..0000000 --- a/util.old/et/.et_name.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/et_name.c
\ No newline at end of file diff --git a/util.old/et/.init_et.c,l b/util.old/et/.init_et.c,l deleted file mode 100644 index e0641ca..0000000 --- a/util.old/et/.init_et.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/init_et.c
\ No newline at end of file diff --git a/util.old/et/.internal.h,l b/util.old/et/.internal.h,l deleted file mode 100644 index ba7faef..0000000 --- a/util.old/et/.internal.h,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/internal.h
\ No newline at end of file diff --git a/util.old/et/.mit-sipb-copyright.h,l b/util.old/et/.mit-sipb-copyright.h,l deleted file mode 100644 index 5b0d67d..0000000 --- a/util.old/et/.mit-sipb-copyright.h,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/mit-sipb-copyright.h
\ No newline at end of file diff --git a/util.old/et/.test.c,l b/util.old/et/.test.c,l deleted file mode 100644 index 66847ad..0000000 --- a/util.old/et/.test.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/test.c
\ No newline at end of file diff --git a/util.old/et/.test1.et,l b/util.old/et/.test1.et,l deleted file mode 100644 index df2e9a0..0000000 --- a/util.old/et/.test1.et,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/test1.et
\ No newline at end of file diff --git a/util.old/et/.test2.et,l b/util.old/et/.test2.et,l deleted file mode 100644 index ada475d..0000000 --- a/util.old/et/.test2.et,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/test2.et
\ No newline at end of file diff --git a/util.old/et/.texinfo.tex,l b/util.old/et/.texinfo.tex,l deleted file mode 100644 index 241a0a5..0000000 --- a/util.old/et/.texinfo.tex,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/et/texinfo.tex
\ No newline at end of file diff --git a/util.old/imake/.Imakefile,l b/util.old/imake/.Imakefile,l deleted file mode 100644 index bcd58f1..0000000 --- a/util.old/imake/.Imakefile,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/util/imake/Imakefile
\ No newline at end of file diff --git a/util.old/imake/.Makefile,l b/util.old/imake/.Makefile,l deleted file mode 100644 index 2c5ac0b..0000000 --- a/util.old/imake/.Makefile,l +++ /dev/null @@ -1 +0,0 @@ -Makefile.ini
\ No newline at end of file diff --git a/util.old/imake/.Makefile.ini,l b/util.old/imake/.Makefile.ini,l deleted file mode 100644 index 943476f..0000000 --- a/util.old/imake/.Makefile.ini,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/util/imake/Makefile.ini
\ No newline at end of file diff --git a/util.old/imake/.ccimake.c,l b/util.old/imake/.ccimake.c,l deleted file mode 100644 index 53094b2..0000000 --- a/util.old/imake/.ccimake.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/util/imake/ccimake.c
\ No newline at end of file diff --git a/util.old/imake/.imake.c,l b/util.old/imake/.imake.c,l deleted file mode 100644 index aa89788..0000000 --- a/util.old/imake/.imake.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/util/imake/imake.c
\ No newline at end of file diff --git a/util.old/imake/.imakemdep.h,l b/util.old/imake/.imakemdep.h,l deleted file mode 100644 index 7fa9876..0000000 --- a/util.old/imake/.imakemdep.h,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/util/imake/imakemdep.h
\ No newline at end of file diff --git a/util.old/ss/.Imakefile,l b/util.old/ss/.Imakefile,l deleted file mode 100644 index 5a69131..0000000 --- a/util.old/ss/.Imakefile,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/Imakefile
\ No newline at end of file diff --git a/util.old/ss/.cmd_tbl.l,l b/util.old/ss/.cmd_tbl.l,l deleted file mode 100644 index 9d344fe..0000000 --- a/util.old/ss/.cmd_tbl.l,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/cmd_tbl.l
\ No newline at end of file diff --git a/util.old/ss/.commands.ct,l b/util.old/ss/.commands.ct,l deleted file mode 100644 index 819e77c..0000000 --- a/util.old/ss/.commands.ct,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/commands.ct
\ No newline at end of file diff --git a/util.old/ss/.copyright.h,l b/util.old/ss/.copyright.h,l deleted file mode 100644 index f5edea1..0000000 --- a/util.old/ss/.copyright.h,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/copyright.h
\ No newline at end of file diff --git a/util.old/ss/.ct.y,l b/util.old/ss/.ct.y,l deleted file mode 100644 index 12f181f..0000000 --- a/util.old/ss/.ct.y,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/ct.y
\ No newline at end of file diff --git a/util.old/ss/.data.c,l b/util.old/ss/.data.c,l deleted file mode 100644 index 9cacdd4..0000000 --- a/util.old/ss/.data.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/data.c
\ No newline at end of file diff --git a/util.old/ss/.error.c,l b/util.old/ss/.error.c,l deleted file mode 100644 index 9161238..0000000 --- a/util.old/ss/.error.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/error.c
\ No newline at end of file diff --git a/util.old/ss/.execute_cmd.c,l b/util.old/ss/.execute_cmd.c,l deleted file mode 100644 index 20898d2..0000000 --- a/util.old/ss/.execute_cmd.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/execute_cmd.c
\ No newline at end of file diff --git a/util.old/ss/.help.c,l b/util.old/ss/.help.c,l deleted file mode 100644 index a74c5a1..0000000 --- a/util.old/ss/.help.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/help.c
\ No newline at end of file diff --git a/util.old/ss/.invocation.c,l b/util.old/ss/.invocation.c,l deleted file mode 100644 index 3c13e8f..0000000 --- a/util.old/ss/.invocation.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/invocation.c
\ No newline at end of file diff --git a/util.old/ss/.list_rqs.c,l b/util.old/ss/.list_rqs.c,l deleted file mode 100644 index 0924575..0000000 --- a/util.old/ss/.list_rqs.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/list_rqs.c
\ No newline at end of file diff --git a/util.old/ss/.listen.c,l b/util.old/ss/.listen.c,l deleted file mode 100644 index 61d89fe..0000000 --- a/util.old/ss/.listen.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/listen.c
\ No newline at end of file diff --git a/util.old/ss/.mit-sipb-copyright.h,l b/util.old/ss/.mit-sipb-copyright.h,l deleted file mode 100644 index 3401c9c..0000000 --- a/util.old/ss/.mit-sipb-copyright.h,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/mit-sipb-copyright.h
\ No newline at end of file diff --git a/util.old/ss/.mk_cmds.c,l b/util.old/ss/.mk_cmds.c,l deleted file mode 100644 index a26bbfa..0000000 --- a/util.old/ss/.mk_cmds.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/mk_cmds.c
\ No newline at end of file diff --git a/util.old/ss/.options.c,l b/util.old/ss/.options.c,l deleted file mode 100644 index e19e361..0000000 --- a/util.old/ss/.options.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/options.c
\ No newline at end of file diff --git a/util.old/ss/.pager.c,l b/util.old/ss/.pager.c,l deleted file mode 100644 index a7e9ffa..0000000 --- a/util.old/ss/.pager.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/pager.c
\ No newline at end of file diff --git a/util.old/ss/.parse.c,l b/util.old/ss/.parse.c,l deleted file mode 100644 index bcd0a1a..0000000 --- a/util.old/ss/.parse.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/parse.c
\ No newline at end of file diff --git a/util.old/ss/.prompt.c,l b/util.old/ss/.prompt.c,l deleted file mode 100644 index f72aa6b..0000000 --- a/util.old/ss/.prompt.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/prompt.c
\ No newline at end of file diff --git a/util.old/ss/.request_tbl.c,l b/util.old/ss/.request_tbl.c,l deleted file mode 100644 index c186fbd..0000000 --- a/util.old/ss/.request_tbl.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/request_tbl.c
\ No newline at end of file diff --git a/util.old/ss/.requests.c,l b/util.old/ss/.requests.c,l deleted file mode 100644 index 3c478d2..0000000 --- a/util.old/ss/.requests.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/requests.c
\ No newline at end of file diff --git a/util.old/ss/.ss.h,l b/util.old/ss/.ss.h,l deleted file mode 100644 index 99983a8..0000000 --- a/util.old/ss/.ss.h,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/ss.h
\ No newline at end of file diff --git a/util.old/ss/.ss_err.et,l b/util.old/ss/.ss_err.et,l deleted file mode 100644 index d76904a..0000000 --- a/util.old/ss/.ss_err.et,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/ss_err.et
\ No newline at end of file diff --git a/util.old/ss/.ss_internal.h,l b/util.old/ss/.ss_internal.h,l deleted file mode 100644 index 8b93167..0000000 --- a/util.old/ss/.ss_internal.h,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/ss_internal.h
\ No newline at end of file diff --git a/util.old/ss/.std_rqs.ct,l b/util.old/ss/.std_rqs.ct,l deleted file mode 100644 index 0829cdf..0000000 --- a/util.old/ss/.std_rqs.ct,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/std_rqs.ct
\ No newline at end of file diff --git a/util.old/ss/.test.c,l b/util.old/ss/.test.c,l deleted file mode 100644 index 93567b6..0000000 --- a/util.old/ss/.test.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/test.c
\ No newline at end of file diff --git a/util.old/ss/.utils.c,l b/util.old/ss/.utils.c,l deleted file mode 100644 index e988303..0000000 --- a/util.old/ss/.utils.c,l +++ /dev/null @@ -1 +0,0 @@ -../../ATHENA/athena/athena.lib/ss/utils.c
\ No newline at end of file diff --git a/util/ss/ChangeLog b/util/ss/ChangeLog deleted file mode 100644 index a5ce5ab..0000000 --- a/util/ss/ChangeLog +++ /dev/null @@ -1,65 +0,0 @@ -Sat Oct 22 09:54:50 1994 (tytso@rsx-11) - - * list_rqs.c (ss_list_requests): - * listen.c (ss_listen): - * configure.in: Add AC_RETSIGTYPE to get proper return type for - signal hanlders. - -Fri Oct 21 21:07:16 1994 (tytso@rsx-11) - - * Makefile.in (SED): Don't specify an explicit pathname for sed. - -Tue Oct 11 12:41:40 1994 Theodore Y. Ts'o (tytso@dcl) - - * Makefile.in: Don't rm the awk and sed scripts during a make clean! - -Fri Oct 7 15:37:19 1994 Theodore Y. Ts'o (tytso@dcl) - - * ct_c.sed: Add extra check to make sure blank lines get squeezed - out. Needed for AIX's sed, for some reason. - -Thu Oct 6 19:40:09 1994 Theodore Y. Ts'o (tytso@dcl) - - * mk_cmds.sh -- replace basename with sed -- more portable - -Mon Oct 3 17:26:27 1994 Theodore Y. Ts'o (tytso@dcl) - - * Makefile.in: - configure.in: Don't try to compile mk_cmds. Use awk/sed shell - script replacement instead. It's more apt to be - portable, since it doesn't use lex or yacc. :-( - -Tue Aug 30 21:30:18 1994 Theodore Y. Ts'o (tytso at tsx-11) - - * cmd_tbl.lex.l: Add declaration for strdup() if HAS_STRDUP is not - defined. - - * ct.y: Added #include of string.h; added declaration for - strdup() if HAS_STRDUP is not defined. - -Tue Jul 19 20:27:59 1994 Tom Yu (tlyu at dragons-lair) - - * Makefile.in: remove spurious includes rules - -Wed Jul 13 23:20:44 1994 Tom Yu (tlyu at dragons-lair) - - * Makefile.in: nuke libss.a.bak crud - -Sun Jul 3 07:48:43 1994 Tom Yu (tlyu at dragons-lair) - - * Makefile.in: changing things to now spew ignored errors. - -Wed Jun 22 18:51:50 1994 Mark Eichin (eichin@cygnus.com) - - * configure.in: ss_err.h is *not* a SrcHeader. Note that there is - duplication between the Copy*Header lines and the includes: rule - in the Makefile.in, which should later be fixed. - -Tue Jun 21 00:21:05 1994 Tom Yu (tlyu at dragons-lair) - - * configure.in: should be CopySrcHeader - -Mon Jun 20 21:58:40 1994 Tom Yu (tlyu at dragons-lair) - - * configure.in: install headers during build - diff --git a/util/ss/Makefile.in b/util/ss/Makefile.in deleted file mode 100644 index dd1b12d..0000000 --- a/util/ss/Makefile.in +++ /dev/null @@ -1,159 +0,0 @@ -CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE) -LDFLAGS = -g -SED = sed - -INSTALLLIB=cp -INSTALLFILE=cp - -all:: - -TOP=$(BUILDTOP) - -# hard coded srcdir/.. is so that ss/ss.h works - -# hard coded .. is so that ss/ss_err.h works -# hard coded ../et is so com_err.h works -# CFLAGS= -I${INCDIR} -I. -I.. -I../et -g -LOCALINCLUDE= -I. -I$(srcdir)/ -I$(srcdir)/.. -I$(srcdir)/../et -I.. - -# for the library - -LIB= libss.a - -# with ss_err.o first, ss_err.h should get rebuilt first too. should not -# be relying on this, though. -OBJS= ss_err.o \ - std_rqs.o \ - invocation.o help.o \ - execute_cmd.o listen.o parse.o error.o prompt.o \ - request_tbl.o list_rqs.o pager.o requests.o \ - data.o - -SRCS= invocation.c help.c \ - execute_cmd.c listen.c parse.c error.c prompt.c \ - request_tbl.c list_rqs.c pager.c requests.c \ - data.c \ - ss_err.h -# ss_err.h here, so that make depend catches it. - -std_rqs.o:: std_rqs.c ss_err.h - -CODE= $(SRCS) $(MKCMDSFILES) - -MKCMDSOBJS= mk_cmds.o utils.o options.o ct.tab.o cmd_tbl.lex.o - -MKCMDSFILES= mk_cmds.c utils.c options.c ct.y cmd_tbl.lex.l - -MKCMDSCSRCS= mk_cmds.c utils.c options.c ct.tab.c cmd_tbl.lex.c - - -HFILES= ss.h ss_internal.h copyright.h - -# for 'tags' and dependencies - -CFILES= $(SRCS) $(MKCMDSCSRCS) test_ss.c - -# for building archives - -FILES= $(SRCS) $(MKCMDSFILES) $(HFILES) \ - ss_err.et std_rqs.ct Makefile \ - test_ss.c ss mit-sipb-copyright.h copyright.h - -# -# stuff to build -# - -all:: mk_cmds libss.a includes # libss_p.a lint - -dist: archives - -install:: libss.a - $(INSTALLLIB) libss.a ${DESTDIR}$(LIBDIR)/libss.a - $(RANLIB) ${DESTDIR}$(LIBDIR)/libss.a - @rm -rf ${DESTDIR}$(INCLDIR)/ss - @mkdir ${DESTDIR}$(INCLDIR)/ss - - -includes:: mk_cmds ss_err.h - -install:: $(HFILES) copyright.h - for i in $(HFILES) copyright.h; do \ - $(INSTALLFILE) $(srcdir)/$$i ${DESTDIR}$(INCLDIR)/ss/$$i; \ - done - -install:: copyright.h - $(INSTALLFILE) $(srcdir)/copyright.h ${DESTDIR}$(INCLDIR)/ss/mit-sipb-copyright.h - -std_rqs.c: std_rqs.ct - -ss_err.h: ss_err.et - -ss_err.c: ss_err.et - -clean:: - $(RM) ss_err.o ss_err.c ss_err.h std_rqs.c - -depend:: ss_err.h - -ct.tab.c ct.tab.h: ct.y - $(RM) ct.tab.* y.* - $(YACC) -d $(srcdir)/ct.y - $(MV) y.tab.c ct.tab.c - $(MV) y.tab.h ct.tab.h - -# install_library_target(ss,$(OBJS),$(SRCS),) -all:: libss.a - -libss.a: $(OBJS) - $(ARCHIVE) $@ $(OBJS) - $(RANLIB) $@ - -clean:: - $(RM) libss.a - -install:: - $(INSTALLLIB) libss.a $(DESTDIR)$(LIBDIR)/libss.a - $(CHMOD) 644 $(DESTDIR)$(LIBDIR)/libss.a - $(RANLIB) $(DESTDIR)$(LIBDIR)/libss.a - $(CHMOD) 444 $(DESTDIR)$(LIBDIR)/libss.a -## - - -libss.o: $(OBJS) - $(LD) -r -s -o $@ $(OBJS) - $(CHMOD) -x $@ - -# program(mk_cmds,$(MKCMDSOBJS), , LEXLIB BSDLIB,$(PROGDIR)) -all:: mk_cmds - -#mk_cmds: $(MKCMDSOBJS) -# $(CC) $(CFLAGS) -o $@ $(MKCMDSOBJS) $(LEXLIB) $(BSDLIB) -# -#mk_cmds.o: ss_err.h -# -#install:: -# $(INSTALLPROG) mk_cmds ${DESTDIR}$(PROGDIR)/mk_cmds - -mk_cmds: $(srcdir)/mk_cmds.sh $(srcdir)/config_script - $(srcdir)/config_script $(srcdir)/mk_cmds.sh $(AWK) $(SED) > mk_cmds - chmod 755 mk_cmds - -ct_c.awk: $(srcdir)/ct_c.awk - $(CP) $(srcdir)/ct_c.awk ct_c.awk - -ct_c.sed: $(srcdir)/ct_c.sed - $(CP) $(srcdir)/ct_c.sed ct_c.sed - -clean:: - $(RM) mk_cmds $(MKCMDSOBJS) - -# - -clean:: - rm -f *.o *~ \#* *.bak core \ - ss_err.h ct.tab.c ct.tab.h cmd_tbl.lex.c \ - lex.yy.c y.tab.c \ - libss.a libss_p.a llib-lss.ln mk_cmds \ - ss.ar ss.tar \ - TAGS test_ss - diff --git a/util/ss/cmd_tbl.lex.l b/util/ss/cmd_tbl.lex.l deleted file mode 100644 index 166f76d..0000000 --- a/util/ss/cmd_tbl.lex.l +++ /dev/null @@ -1,82 +0,0 @@ -N [0-9] -PC [^\"] -AN [A-Z_a-z0-9] -%% - -command_table return l_command_table(); -request return l_request(); -unimplemented return l_unimplemented(); -end return l_end(); - -[\t\n ] ; - -\"{PC}*\" return l_quoted_string(); - -{AN}* return l_string(); - -#.*\n ; - -. return (*yytext); -%% -/* - * User-subroutines section. - * - * Have to put all this stuff here so that the include file - * from YACC output can be included, since LEX doesn't allow - * an include file before the code it generates for the above - * rules. - * - * Copyright 1987 by MIT Student Information Processing Board. - * - * For copyright info, see mit-sipb-copyright.h. - */ -#include <string.h> -#include "ct.tab.h" -#include "mit-sipb-copyright.h" - -#ifndef HAS_STRDUP -extern char *strdup(); -#endif - -extern char *last_token; - -static l_command_table() -{ - last_token = "command_table"; - return COMMAND_TABLE; -} - -static l_request() -{ - last_token = "request"; - return REQUEST; -} - -static l_unimplemented() -{ - last_token = "unimplemented"; - return UNIMPLEMENTED; -} - -static l_end() -{ - last_token = "end"; - return END; -} - -static l_quoted_string() -{ - register char *p; - yylval.dynstr = strdup(yytext+1); - if (p=strrchr(yylval.dynstr, '"')) - *p='\0'; - last_token = strdup(yylval.dynstr); - return STRING; -} - -static l_string() -{ - yylval.dynstr = strdup(yytext); - last_token = strdup(yylval.dynstr); - return STRING; -} diff --git a/util/ss/config_script b/util/ss/config_script deleted file mode 100755 index e3de35c..0000000 --- a/util/ss/config_script +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# -# This program takes a shell script and configures for the following -# variables: @DIR@ -# @AWK@ -# @SED@ -# -# Usage: config_script <filename> [<awk>] [<sed>] -# - -FILE=$1 -AWK=$2 -SED=$3 - -# Grr.... not all Unix's have the dirname command -TMP=`echo $1 | sed -e 's;[^/]*$;;' -e 's/^$/./'` -DIR=`cd ${TMP}; pwd` - -if test "${AWK}x" = "x" ; then - AWK=awk -fi -if test "${SED}x" = "x" ; then - SED=sed -fi -sed -e "s;@DIR@;${DIR};" -e "s;@AWK@;${AWK};" -e "s;@SED@;${SED};" $FILE diff --git a/util/ss/configure b/util/ss/configure deleted file mode 100755 index 43c4bf4..0000000 --- a/util/ss/configure +++ /dev/null @@ -1,1394 +0,0 @@ -#!/bin/sh - - -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.1 -# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: -ac_help="$ac_help - --with-ccopts=CCOPTS select compiler command line options" -ac_help="$ac_help - --with-cc=COMPILER select compiler to use" -ac_help="$ac_help - --with-cppopts=CPPOPTS select compiler preprocessor command line options" - -# Initialize some variables set by options. -# The variables have the same names as the options, with -# dashes changed to underlines. -build=NONE -cache_file=./config.cache -exec_prefix=NONE -host=NONE -no_create= -nonopt=NONE -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -target=NONE -verbose= -x_includes=NONE -x_libraries=NONE - -# Initialize some other variables. -subdirs= - -ac_prev= -for ac_option -do - - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case "$ac_option" in - - -build | --build | --buil | --bui | --bu | --b) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*) - build="$ac_optarg" ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; - - -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; - - -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "enable_${ac_feature}='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=PREFIX install architecture-dependent files in PREFIX - [same as prefix] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR ---enable and --with options recognized:$ac_help -EOF - exit 0 ;; - - -host | --host | --hos | --ho) - ac_prev=host ;; - -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.1" - exit 0 ;; - - -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "with_${ac_package}='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; - - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } - ;; - - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" - ;; - - esac -done - -if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 unused; standard input -# 1 file creation -# 2 errors and warnings -# 3 unused; some systems may open it to /dev/tty -# 4 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 4>/dev/null -else - exec 4>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 - -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg -do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; - esac -done - -# NLS nuisances. -# Only set LANG and LC_ALL to C if already set. -# These must not be set unconditionally because not all systems understand -# e.g. LANG=C (notably SCO). -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LANG+set}" = set; then LANG=C; export LANG; fi - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=ct.y - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } - else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } - fi -fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` - -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file -else - echo "creating cache $cache_file" - > $cache_file -fi - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} $CFLAGS $CPPFLAGS conftest.$ac_ext -c 1>&5 2>&5' -ac_link='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext -o conftest $LIBS 1>&5 2>&5' - -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - - - -# Check whether --with-ccopts or --without-ccopts was given. -withval="$with_ccopts" -if test -n "$withval"; then - echo "$ac_t""CCOPTS is $withval" 1>&4 -CCOPTS=$withval -CFLAGS="$CFLAGS $withval" -else - CCOPTS= -fi - - - -# Check whether --with-cc or --without-cc was given. -withval="$with_cc" -if test -n "$withval"; then - echo "$ac_t""CC=$withval" 1>&4 -CC=$withval -else - if test -z "$CC" ; then CC=cc; fi -echo "$ac_t""CC defaults to $CC" 1>&4 -fi - -# Check whether --with-cppopts or --without-cppopts was given. -withval="$with_cppopts" -if test -n "$withval"; then - echo "$ac_t""CPPOPTS=$withval" 1>&4 -CPPOPTS=$withval -CPPFLAGS="$CPPFLAGS $withval" -else - echo "$ac_t""CPPOPTS defaults to $CPPOPTS" 1>&4 -fi - -ac_config_fragdir= -for ac_dir in . .. ../.. ../../.. ../../../.. ../../../../.. ../../../../../..; do - if test -d $srcdir/$ac_dir/config; then - ac_reltopdir=$ac_dir - ac_topdir=$srcdir/$ac_reltopdir - ac_config_fragdir=$ac_reltopdir/config - break - fi -done -if test -z "$ac_config_fragdir"; then - { echo "configure: error: can not find config/ directory in . .. ../.. ../../.. ../../../.. ../../../../.. ../../../../../.." 1>&2; exit 1; } -else - ac_aux_dir= -for ac_dir in $ac_config_fragdir $srcdir/$ac_config_fragdir; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in $ac_config_fragdir $srcdir/$ac_config_fragdir" 1>&2; exit 1; } -fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. - -fi - ac_tmpin="$srcdir/${ac_config_fragdir}/pre.in" - if test -r $ac_tmpin; then - ac_prepend=$ac_config_fragdir/pre.in - else - ac_prepend= - fi - ac_tmpin="$srcdir/${ac_config_fragdir}/post.in" - if test -r $ac_tmpin; then - ac_postpend=$ac_config_fragdir/post.in - else - ac_postpend= - fi -BUILDTOP=$ac_reltopdir - -# Extract the first word of "flex", so it can be a program name with args. -set dummy flex; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_LEX'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - if test -n "$LEX"; then - ac_cv_prog_LEX="$LEX" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_LEX="flex" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_LEX" && ac_cv_prog_LEX="lex" -fi -fi -LEX="$ac_cv_prog_LEX" -if test -n "$LEX"; then - echo "$ac_t""$LEX" 1>&4 -else - echo "$ac_t""no" 1>&4 -fi -if test -z "$LEXLIB" -then - case "$LEX" in - flex*) echo $ac_n "checking for -lfl""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_lib_fl'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - ac_save_LIBS="$LIBS" -LIBS="$LIBS -lfl " -cat > conftest.$ac_ext <<EOF -#line 524 "configure" -#include "confdefs.h" - -int main() { return 0; } -int t() { -main() -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_lib_fl=yes" -else - rm -rf conftest* - eval "ac_cv_lib_fl=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'fl`\" = yes"; then - echo "$ac_t""yes" 1>&4 - LEXLIB="-lfl" -else - echo "$ac_t""no" 1>&4 -fi - ;; - *) echo $ac_n "checking for -ll""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_lib_l'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - ac_save_LIBS="$LIBS" -LIBS="$LIBS -ll " -cat > conftest.$ac_ext <<EOF -#line 557 "configure" -#include "confdefs.h" - -int main() { return 0; } -int t() { -main() -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_lib_l=yes" -else - rm -rf conftest* - eval "ac_cv_lib_l=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'l`\" = yes"; then - echo "$ac_t""yes" 1>&4 - LEXLIB="-ll" -else - echo "$ac_t""no" 1>&4 -fi - ;; - esac -fi -echo "$ac_t""setting LEXLIB to $LEXLIB" 1>&4 - -for ac_prog in 'bison -y' byacc -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_YACC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - if test -n "$YACC"; then - ac_cv_prog_YACC="$YACC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_YACC="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -YACC="$ac_cv_prog_YACC" -if test -n "$YACC"; then - echo "$ac_t""$YACC" 1>&4 -else - echo "$ac_t""no" 1>&4 -fi - -test -n "$YACC" && break -done -test -n "$YACC" || YACC="yacc" - -for ac_prog in mawk gawk nawk awk -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_AWK'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_AWK="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -AWK="$ac_cv_prog_AWK" -if test -n "$AWK"; then - echo "$ac_t""$AWK" 1>&4 -else - echo "$ac_t""no" 1>&4 -fi - -test -n "$AWK" && break -done - -# Extract the first word of "ar", so it can be a program name with args. -set dummy ar; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_ARCHIVE'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - if test -n "$ARCHIVE"; then - ac_cv_prog_ARCHIVE="$ARCHIVE" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_ARCHIVE="ar qv" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_ARCHIVE" && ac_cv_prog_ARCHIVE="false" -fi -fi -ARCHIVE="$ac_cv_prog_ARCHIVE" -if test -n "$ARCHIVE"; then - echo "$ac_t""$ARCHIVE" 1>&4 -else - echo "$ac_t""no" 1>&4 -fi - -# Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&4 -else - echo "$ac_t""no" 1>&4 -fi - -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&4 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '${'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext <<EOF -#line 723 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext <<EOF -#line 737 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" -fi -fi -CPP="$ac_cv_prog_CPP" -echo "$ac_t""$CPP" 1>&4 - -echo $ac_n "checking for yylineno declaration""... $ac_c" 1>&4 -if eval "test \"`echo '${'krb5_cv_type_yylineno'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - # some systems have yylineno, others don't... - echo '%% -%%' | ${LEX} -t > conftest.out - if egrep yylineno conftest.out >/dev/null 2>&1; then - krb5_cv_type_yylineno=yes - else - krb5_cv_type_yylineno=no - fi - rm -f conftest.out -fi - - echo "$ac_t""$krb5_cv_type_yylineno" 1>&4 - if test $krb5_cv_type_yylineno = no; then - cat >> confdefs.h <<\EOF -#define NO_YYLINENO 1 -EOF - - fi - -echo $ac_n "checking for strdup""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_strdup'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <<EOF -#line 788 "configure" -#include "confdefs.h" -#include <ctype.h> /* Arbitrary system header to define __stub macros. */ -/* Override any gcc2 internal prototype to avoid an error. */ -char strdup(); - -int main() { return 0; } -int t() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_strdup) || defined (__stub___strdup) -choke me -#else -strdup(); -#endif - -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_func_strdup=yes" -else - rm -rf conftest* - eval "ac_cv_func_strdup=no" -fi -rm -f conftest* - -fi -if eval "test \"`echo '$ac_cv_func_'strdup`\" = yes"; then - echo "$ac_t""yes" 1>&4 - cat >> confdefs.h <<\EOF -#define HAS_STRDUP 1 -EOF - -else - echo "$ac_t""no" 1>&4 -fi - - -for ac_prog in mawk gawk nawk awk -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_AWK'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_AWK="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -AWK="$ac_cv_prog_AWK" -if test -n "$AWK"; then - echo "$ac_t""$AWK" 1>&4 -else - echo "$ac_t""no" 1>&4 -fi - -test -n "$AWK" && break -done - - - - -ac_safe=`echo "dirent.h" | tr './\055' '___'` -echo $ac_n "checking for dirent.h""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <<EOF -#line 870 "configure" -#include "confdefs.h" -#include <dirent.h> -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&4 - cat >> confdefs.h <<\EOF -#define USE_DIRENT_H 1 -EOF - -else - echo "$ac_t""no" 1>&4 -fi - - -echo $ac_n "checking if O_RDONLY is needed from sys/fcntl.h""... $ac_c" 1>&4 -if eval "test \"`echo '${'krb5_cv_decl_fcntl_ordonly'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <<EOF -#line 902 "configure" -#include "confdefs.h" -#include <sys/param.h> -#include <sys/types.h> -#include <sys/file.h> -int main() { return 0; } -int t() { -1+O_RDONLY; -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - krb5_cv_decl_fcntl_ordonly=no -else - rm -rf conftest* - cat > conftest.$ac_ext <<EOF -#line 918 "configure" -#include "confdefs.h" -#include <sys/param.h> -#include <sys/types.h> -#include <sys/file.h> -#include <sys/fcntl.h> -int main() { return 0; } -int t() { -1+O_RDONLY; -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - krb5_cv_decl_fcntl_ordonly=yes -else - rm -rf conftest* - krb5_cv_decl_fcntl_ordonly=no -fi -rm -f conftest* - -fi -rm -f conftest* - -fi - -echo "$ac_t""$krb5_cv_decl_fcntl_ordonly" 1>&4 -if test $krb5_cv_decl_fcntl_ordonly = yes; then - cat >> confdefs.h <<\EOF -#define NEED_SYS_FCNTL_H 1 -EOF - -fi - - -echo $ac_n "checking for union wait""... $ac_c" 1>&4 -if eval "test \"`echo '${'krb5_cv_struct_wait'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <<EOF -#line 957 "configure" -#include "confdefs.h" -#include <sys/wait.h> -int main() { return 0; } -int t() { -union wait i; -; return 0; } -EOF -if eval $ac_compile; then - rm -rf conftest* - krb5_cv_struct_wait=yes -else - rm -rf conftest* - krb5_cv_struct_wait=no -fi -rm -f conftest* - -fi - -echo "$ac_t""$krb5_cv_struct_wait" 1>&4 -if test $krb5_cv_struct_wait = no; then - cat >> confdefs.h <<\EOF -#define WAIT_USES_INT 1 -EOF - -fi - - -echo $ac_n "checking for use of sigprocmask""... $ac_c" 1>&4 -if eval "test \"`echo '${'krb5_cv_func_sigprocmask_use'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <<EOF -#line 990 "configure" -#include "confdefs.h" -#include <signal.h> -int main() { return 0; } -int t() { -sigmask(1); -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - krb5_cv_func_sigprocmask_use=no -else - rm -rf conftest* - cat > conftest.$ac_ext <<EOF -#line 1004 "configure" -#include "confdefs.h" -#include <signal.h> -int main() { return 0; } -int t() { -sigprocmask(SIG_SETMASK,0,0); -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - krb5_cv_func_sigprocmask_use=yes -else - rm -rf conftest* - krb5_cv_func_sigprocmask_use=no -fi -rm -f conftest* - -fi -rm -f conftest* - -fi - -echo "$ac_t""$krb5_cv_func_sigprocmask_use" 1>&4 -if test $krb5_cv_func_sigprocmask_use = yes; then - cat >> confdefs.h <<\EOF -#define USE_SIGPROCMASK 1 -EOF - -fi - -echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_type_signal'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <<EOF -#line 1039 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <signal.h> -#ifdef signal -#undef signal -#endif -extern void (*signal ()) (); -int main() { return 0; } -int t() { -int i; -; return 0; } -EOF -if eval $ac_compile; then - rm -rf conftest* - ac_cv_type_signal=void -else - rm -rf conftest* - ac_cv_type_signal=int -fi -rm -f conftest* - -fi -echo "$ac_t""$ac_cv_type_signal" 1>&4 -cat <<EOF | tr '\201-\377' '\001-\177' >> confdefs.h -#define RETSIGTYPE $ac_cv_type_signal -EOF - - - -ac_safe=`echo "stdarg.h" | tr './\055' '___'` -echo $ac_n "checking for stdarg.h""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <<EOF -#line 1075 "configure" -#include "confdefs.h" -#include <stdarg.h> -EOF -eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&4 - cat >> confdefs.h <<\EOF -#define STDARG_PROTOTYPES 1 -EOF - -else - echo "$ac_t""no" 1>&4 -fi - - - - - - - - - - - -trap '' 1 2 15 -if test -w $cache_file; then -echo "updating cache $cache_file" -cat > $cache_file <<\EOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. -# -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. -# -EOF -# Ultrix sh set writes to stderr and can't be redirected directly. -# Ultrix sh set also returns variables that were read in from the config file -# with their high bit set. -(set) 2>&1 | tr '\201-\377' '\001-\177' | - sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/: \${\1='\2'}/p" \ - >> $cache_file -else -echo "not updating unwritable cache $cache_file" -fi - -trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' -fi - -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -cat > conftest.defs <<\EOF -s%#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)%-D\1=\2%g -s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g -s%\[%\\&%g -s%\]%\\&%g -s%\$%$$%g -EOF -DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` -rm -f conftest.defs - - -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS <<EOF -#!/bin/sh -# Generated automatically by configure. -# Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# $0 $ac_configure_args -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option -do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.1" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=$srcdir - -trap 'rm -f pre.out:$ac_prepend Makefile.out:Makefile.in post.out:$ac_postpend; exit 1' 1 2 15 - -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g; - s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF -$ac_vpsub -$extrasub -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@CCOPTS@%$CCOPTS%g -s%@CC@%$CC%g -s%@CPPOPTS@%$CPPOPTS%g -s%@BUILDTOP@%$BUILDTOP%g -s%@LEX@%$LEX%g -s%@LEXLIB@%$LEXLIB%g -s%@YACC@%$YACC%g -s%@AWK@%$AWK%g -s%@ARCHIVE@%$ARCHIVE%g -s%@RANLIB@%$RANLIB%g -s%@CPP@%$CPP%g - -CEOF -EOF -cat >> $CONFIG_STATUS <<EOF - -CONFIG_FILES=\${CONFIG_FILES-"pre.out:$ac_prepend Makefile.out:Makefile.in post.out:$ac_postpend"} -EOF -cat >> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust relative srcdir, etc. for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/$ac_dir" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file -fi; done -rm -f conftest.subs - -EOF -cat >> $CONFIG_STATUS <<EOF -cat pre.out Makefile.out post.out > Makefile -EOF -cat >> $CONFIG_STATUS <<\EOF - -cat >> Makefile <<"SUBDIREOF" -# [DIVERSION_MAKEFILE] contents - -SHELL=/bin/sh - -Makefile: $(srcdir)/Makefile.in config.status $(SRCTOP)/config/pre.in $(SRCTOP)/config/post.in - $(SHELL) config.status -config.status: $(srcdir)/configure - $(SHELL) config.status --recheck -$(srcdir)/configure: $(srcdir)/configure.in $(SRCTOP)/aclocal.m4 - cd $(srcdir); autoconf --localdir=$(BUILDTOP) --macrodir=$(BUILDTOP)/util/autoconf - - - -### /* these are invoked as $(...) foo.et, which works, but could be better */ -COMPILE_ET_H= $(AWK) -f $(SRCTOP)/util/et/et_h.awk outfile= -COMPILE_ET_C= $(AWK) -f $(SRCTOP)/util/et/et_c.awk outfile= -.SUFFIXES: .h .c .et .ct - -.et.h: - $(AWK) -f $(SRCTOP)/util/et/et_h.awk outfile=$*.h $< - -.et.c: - $(AWK) -f $(SRCTOP)/util/et/et_c.awk outfile=$*.c $< - - - - -MAKE_COMMANDS= $(BUILDTOP)/util/ss/mk_cmds -.SUFFIXES: .h .c .et .ct - -.ct.c: - @if [ $< != $*.ct ]; then \ - (set -x; cp $< $*.ct && $(MAKE_COMMANDS) $*.ct && rm $*.ct) || exit 1; \ - else \ - (set -x; $(MAKE_COMMANDS) $*.ct) || exit 1; \ - fi - - - -includes:: ss.h - @if test -d $(BUILDTOP)/include/ss; then :; else mkdir $(BUILDTOP)/include/ss; fi - @if cmp $(srcdir)/ss.h $(BUILDTOP)/include/ss/ss.h >/dev/null 2>&1; then :; \ - else \ - (set -x; $(RM) $(BUILDTOP)/include/ss/ss.h; $(CP) $(srcdir)/ss.h $(BUILDTOP)/include/ss/ss.h) \ - fi - -clean:: - $(RM) $(BUILDTOP)/include/ss/ss.h - - -includes:: mit-sipb-copyright.h - @if test -d $(BUILDTOP)/include/ss; then :; else mkdir $(BUILDTOP)/include/ss; fi - @if cmp $(srcdir)/mit-sipb-copyright.h $(BUILDTOP)/include/ss/mit-sipb-copyright.h >/dev/null 2>&1; then :; \ - else \ - (set -x; $(RM) $(BUILDTOP)/include/ss/mit-sipb-copyright.h; $(CP) $(srcdir)/mit-sipb-copyright.h $(BUILDTOP)/include/ss/mit-sipb-copyright.h) \ - fi - -clean:: - $(RM) $(BUILDTOP)/include/ss/mit-sipb-copyright.h - - -includes:: copyright.h - @if test -d $(BUILDTOP)/include/ss; then :; else mkdir $(BUILDTOP)/include/ss; fi - @if cmp $(srcdir)/copyright.h $(BUILDTOP)/include/ss/copyright.h >/dev/null 2>&1; then :; \ - else \ - (set -x; $(RM) $(BUILDTOP)/include/ss/copyright.h; $(CP) $(srcdir)/copyright.h $(BUILDTOP)/include/ss/copyright.h) \ - fi - -clean:: - $(RM) $(BUILDTOP)/include/ss/copyright.h - - -includes:: ss_err.h - @if test -d $(BUILDTOP)/include/ss; then :; else (set -x; mkdir $(BUILDTOP)/include/ss) fi - @if cmp ss_err.h $(BUILDTOP)/include/ss/ss_err.h >/dev/null 2>&1; then :; \ - else \ - (set -x; $(RM) $(BUILDTOP)/include/ss/ss_err.h; $(CP) ss_err.h $(BUILDTOP)/include/ss/ss_err.h) \ - fi - -clean:: - $(RM) $(BUILDTOP)/include/ss/ss_err.h - - -includes:: ss_internal.h - @if test -d $(BUILDTOP)/include/ss; then :; else mkdir $(BUILDTOP)/include/ss; fi - @if cmp $(srcdir)/ss_internal.h $(BUILDTOP)/include/ss/ss_internal.h >/dev/null 2>&1; then :; \ - else \ - (set -x; $(RM) $(BUILDTOP)/include/ss/ss_internal.h; $(CP) $(srcdir)/ss_internal.h $(BUILDTOP)/include/ss/ss_internal.h) \ - fi - -clean:: - $(RM) $(BUILDTOP)/include/ss/ss_internal.h - - -SUBDIREOF - -exit 0 -EOF -chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS - diff --git a/util/ss/configure.in b/util/ss/configure.in deleted file mode 100644 index da021ec..0000000 --- a/util/ss/configure.in +++ /dev/null @@ -1,24 +0,0 @@ -AC_INIT(ct.y) -CONFIG_RULES -AC_SET_BUILDTOP -AC_PROG_LEX -AC_PROG_YACC -AC_PROG_AWK -AC_PROG_ARCHIVE -AC_PROG_RANLIB -HAVE_YYLINENO -AC_FUNC_CHECK(strdup,AC_DEFINE(HAS_STRDUP)) -ET_RULES -SS_RULES -CHECK_DIRENT -CHECK_FCNTL -CHECK_WAIT_TYPE -CHECK_SIGPROCMASK -AC_RETSIGTYPE -CHECK_STDARG -CopySrcHeader(ss.h,$(BUILDTOP)/include/ss) -CopySrcHeader(mit-sipb-copyright.h,$(BUILDTOP)/include/ss) -CopySrcHeader(copyright.h,$(BUILDTOP)/include/ss) -CopyHeader(ss_err.h,$(BUILDTOP)/include/ss) -CopySrcHeader(ss_internal.h,$(BUILDTOP)/include/ss) -V5_AC_OUTPUT_MAKEFILE diff --git a/util/ss/copyright.h b/util/ss/copyright.h deleted file mode 100644 index e0d1572..0000000 --- a/util/ss/copyright.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - -Copyright 1987, 1989 by the Student Information Processing Board - of the Massachusetts Institute of Technology - -Permission to use, copy, modify, and distribute this software -and its documentation for any purpose and without fee is -hereby granted, provided that the above copyright notice -appear in all copies and that both that copyright notice and -this permission notice appear in supporting documentation, -and that the names of M.I.T. and the M.I.T. S.I.P.B. not be -used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. -M.I.T. and the M.I.T. S.I.P.B. make no representations about -the suitability of this software for any purpose. It is -provided "as is" without express or implied warranty. - -*/ - diff --git a/util/ss/ct.y b/util/ss/ct.y deleted file mode 100644 index f1941fc..0000000 --- a/util/ss/ct.y +++ /dev/null @@ -1,82 +0,0 @@ -%{ -/* - * Copyright 1987 by MIT Student Information Processing Board - * - * For copyright info, see mit-sipb-copyright.h. - */ -#include <stdio.h> -#include <string.h> -#include "mit-sipb-copyright.h" - -#ifndef HAS_STRDUP -extern char *strdup(); -#endif - -char *str_concat3(), *generate_rqte(), *quote(); -long flag_value(); -char *last_token = (char *)NULL; -FILE *output_file; -long gensym_n = 0; - -%} -%union { - char *dynstr; - long flags; -} - -%token COMMAND_TABLE REQUEST UNKNOWN UNIMPLEMENTED END -%token <dynstr> STRING -%token <dynstr> FLAGNAME -%type <dynstr> namelist header request_list -%type <dynstr> request_entry -%type <flags> flag_list options -%left OPTIONS -%{ -#include "ss.h" -%} -%start command_table -%% -command_table : header request_list END ';' - { write_ct($1, $2); } - ; - -header : COMMAND_TABLE STRING ';' - { $$ = $2; } - ; - -request_list : request_list request_entry - { $$ = str_concat3($1, $2, ""); } - | - { $$ = ""; } - ; - -request_entry : REQUEST STRING ',' STRING ',' namelist ',' options ';' - { $$ = generate_rqte($2, quote($4), $6, $8); } - | REQUEST STRING ',' STRING ',' namelist ';' - { $$ = generate_rqte($2, quote($4), $6, 0); } - | UNKNOWN namelist ';' - { $$ = generate_rqte("ss_unknown_request", - (char *)NULL, $2, 0); } - | UNIMPLEMENTED STRING ',' STRING ',' namelist ';' - { $$ = generate_rqte("ss_unimplemented", quote($4), $6, 3); } - ; - -options : '(' flag_list ')' - { $$ = $2; } - | '(' ')' - { $$ = 0; } - ; - -flag_list : flag_list ',' STRING - { $$ = $1 | flag_val($3); } - | STRING - { $$ = flag_val($1); } - ; - -namelist: STRING - { $$ = quote(strdup($1)); } - | namelist ',' STRING - { $$ = str_concat3($1, quote($3), ",\n "); } - ; - -%% diff --git a/util/ss/ct_c.awk b/util/ss/ct_c.awk deleted file mode 100644 index 872f6e0..0000000 --- a/util/ss/ct_c.awk +++ /dev/null @@ -1,77 +0,0 @@ -/^command_table / { - cmdtbl = $2; - printf "/* %s.c - automatically generated from %s.ct */\n", \ - rootname, rootname > outfile - print "#include <ss/ss.h>" > outfile - print "" >outfile - print "#ifndef __STDC__" > outfile - print "#define const" > outfile - print "#endif" > outfile - print "" > outfile -} - -/^BOR$/ { - cmdnum++ - options = 0 - cmdtab = "" - printf "static char const * const ssu%05d[] = {\n", cmdnum > outfile -} - -/^sub/ { - subr = substr($0, 6, length($0)-5) -} - -/^hlp/ { - help = substr($0, 6, length($0)-5) -} - -/^cmd/ { - cmd = substr($0, 6, length($0)-5) - printf "%s\"%s\",\n", cmdtab, cmd > outfile - cmdtab = " " -} - -/^opt/ { - opt = substr($0, 6, length($0)-5) - if (opt == "dont_list") { - options += 1 - } - if (opt == "dont_summarize") { - options += 2 - } -} - -/^EOR/ { - print " (char const *)0" > outfile - print "};" > outfile - printf "extern void %s __SS_PROTO;\n", subr > outfile - subr_tab[cmdnum] = subr - options_tab[cmdnum] = options - help_tab[cmdnum] = help -} - -/^[0-9]/ { - linenum = $1; -} - -/^ERROR/ { - error = substr($0, 8, length($0)-7) - printf "Error in line %d: %s\n", linenum, error - print "#__ERROR_IN_FILE__" > outfile -} - -END { - printf "static ss_request_entry ssu%05d[] = {\n", cmdnum+1 > outfile - for (i=1; i <= cmdnum; i++) { - printf " { ssu%05d,\n", i > outfile - printf " %s,\n", subr_tab[i] > outfile - printf " \"%s\",\n", help_tab[i] > outfile - printf " %d },\n", options_tab[i] > outfile - } - print " { 0, 0, 0, 0 }" > outfile - print "};" > outfile - print "" > outfile - printf "ss_request_table %s = { 2, ssu%05d };\n", \ - cmdtbl, cmdnum+1 > outfile -} - diff --git a/util/ss/ct_c.sed b/util/ss/ct_c.sed deleted file mode 100644 index f99cd7f..0000000 --- a/util/ss/ct_c.sed +++ /dev/null @@ -1,161 +0,0 @@ -# -# This script parses a command_table file into something which is a bit -# easier for an awk script to understand. -# -# Input syntax: a .ct file -# -# Output syntax: -# (for the command_table line) -# command_table <command_table> -# -#(for each request definition) -# BOR -# sub: <subroutine name> -# hlp: <help text> -# cmd: <command> -# opt: <option> -# EOR -# (there may be more than one 'cmd' or 'opt' line -# -# A number sent to the output represents a parse error --- it will be -# followed by the next line which will have the form: -# ERROR: <error text> -# -# The design of this output syntax is such that it should be easy for -# an awk script to parse. - -# -# The first section of this script is just to cannoicalize the file. -# It removes comments, and puts each command_table request onto a single -# line -# -:FIRST -y/ / / -s/^ *// -s/#.*$// -/; *$/!{ -N -y/ / / -s/\n */ / -bFIRST -} -s/, */, /g -/^$/d -# -# Now we take care of some syntatic sugar..... -# -/^unimplemented/ { - s/^unimplemented [A-Za-z_0-9]*/request ss_unimplemented/ - s/;/, (dont_list, dont_summarize);/ -} -/^unknown/ { - s/^unknown /request ss_unknown, "", / -} -# -# Dispatch based on the keyword.... illegal keywords are prefixed by ERROR: -# and are handled by the awk script. -# -/^command_table /bCMD -/^request /bREQUEST -/^end;/bEND -s/ .*// -s/^/ERROR: unknown keyword: / -= -b -# -# Handle the command_table keyword -# -:CMD -s/;$// -p -d -b -# -# Handle the request keyword --- this is the heart of the sed script. -# -:REQUEST -s/^request *// -h -i\ -BOR -# First, parse out the subroutine name -s/^/sub: / -s/,.*// -p -# Next, parse out the help message, being careful to handle a quoted string -g -s/^[^,]*, *// -h -/^"/ { - s/^"// - s/".*// - x - s/^"[^"]*", *// - x - b EMITHLP -} -s/[^a-zA-Z0-9].*// -x -s/[a-zA-Z0-9]*, *// -x -:EMITHLP -s/^/hlp: / -p -# Next take care of the command names -:CMDLIST -g -/^(/b OPTIONS -/^;/b EOR -/^"/ { - s/^"// - s/".*// - x - s/^"[^"]*"// - s/, *// - x - b EMITREQ -} -s/[^A-Za-z_0-9].*// -x -s/[A-Za-z_0-9]*// -s/, *// -x -:EMITREQ -s/^/cmd: / -p -b CMDLIST -# -# Here we parse the list of options. -# -: OPTIONS -g -s/^(// -h -: OPTLIST -/^)/ b EOR -/^[^A-Za-z_0-9]/ { - = - c\ -ERROR: parse error in options list -} -s/[^A-Za-z_0-9].*// -x -s/[A-Za-z_0-9]*// -s/, *// -x -s/^/opt: / -p -g -b OPTLIST -: EOR -c\ -EOR\ - -d -b -# -# Handle the end keyword --- it's basically ignored. -# -:END -d -b diff --git a/util/ss/data.c b/util/ss/data.c deleted file mode 100644 index dd6341c..0000000 --- a/util/ss/data.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 1987, 1988, 1989 Massachusetts Institute of Technology - * (Student Information Processing Board) - * - * For copyright info, see copyright.h. - */ - -#include <stdio.h> -#include "ss_internal.h" -#include "copyright.h" - -const static char copyright[] = - "Copyright 1987, 1988, 1989 by the Massachusetts Institute of Technology"; - -ss_data **_ss_table = (ss_data **)NULL; -char *_ss_pager_name = (char *)NULL; diff --git a/util/ss/error.c b/util/ss/error.c deleted file mode 100644 index 43898ab..0000000 --- a/util/ss/error.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 1987, 1988, 1989 by MIT Student Information Processing - * Board - * - * For copyright information, see copyright.h. - */ - -#include <stdio.h> - -/* - * I'm assuming that com_err.h includes varargs.h, which it does - * (right now). There really ought to be a way for me to include the - * file without worrying about whether com_err.h includes it or not, - * but varargs.h doesn't define anything that I can use as a flag, and - * gcc will lose if I try to include it twice and redefine stuff. - */ -#if !defined(__STDC__) || !defined(ibm032) || !defined(NeXT) -#define ss_error ss_error_external -#endif - -#include "copyright.h" -#include <com_err.h> -#include "ss_internal.h" - -#undef ss_error - -char * ss_name(sci_idx) - int sci_idx; -{ - register char *ret_val; - register ss_data *infop; - - infop = ss_info(sci_idx); - if (infop->current_request == (char const *)NULL) { - ret_val = malloc((unsigned) - (strlen(infop->subsystem_name)+1) - * sizeof(char)); - if (ret_val == (char *)NULL) - return((char *)NULL); - strcpy(ret_val, infop->subsystem_name); - return(ret_val); - } - else { - register char *cp; - register char const *cp1; - ret_val = malloc((unsigned)sizeof(char) * - (strlen(infop->subsystem_name)+ - strlen(infop->current_request)+ - 4)); - cp = ret_val; - cp1 = infop->subsystem_name; - while (*cp1) - *cp++ = *cp1++; - *cp++ = ' '; - *cp++ = '('; - cp1 = infop->current_request; - while (*cp1) - *cp++ = *cp1++; - *cp++ = ')'; - *cp = '\0'; - return(ret_val); - } -} - -#ifdef STDARG_PROTOTYPES -void ss_error (int sci_idx, long code, const char * fmt, ...) -#else -void ss_error (va_alist) - va_dcl -#endif -{ - register char const *whoami; - va_list pvar; -#ifndef STDARG_PROTOTYPES - int sci_idx; - long code; - char * fmt; - va_start (pvar); - sci_idx = va_arg (pvar, int); - code = va_arg (pvar, long); - fmt = va_arg (pvar, char *); -#else - va_start (pvar, fmt); -#endif - whoami = ss_name (sci_idx); - com_err_va (whoami, code, fmt, pvar); - free (whoami); - va_end(pvar); -} - -void ss_perror (sci_idx, code, msg) /* for compatibility */ - int sci_idx; - long code; - char const *msg; -{ - ss_error (sci_idx, code, "%s", msg); -} diff --git a/util/ss/execute_cmd.c b/util/ss/execute_cmd.c deleted file mode 100644 index 52f07e2..0000000 --- a/util/ss/execute_cmd.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright 1987, 1988, 1989 by Massachusetts Institute of Technology - * - * For copyright info, see copyright.h. - */ - -#include "ss_internal.h" -#include "copyright.h" -#include <stdio.h> - - -/* - * get_request(tbl, idx) - * - * Function: - * Gets the idx'th request from the request table pointed to - * by tbl. - * Arguments: - * tbl (ss_request_table *) - * pointer to request table - * idx (int) - * index into table - * Returns: - * (ss_request_entry *) - * pointer to request table entry - * Notes: - * Has been replaced by a macro. - */ - -#ifdef __SABER__ -/* sigh. saber won't deal with pointer-to-const-struct */ -static struct _ss_request_entry * get_request (tbl, idx) - ss_request_table * tbl; - int idx; -{ - struct _ss_request_table *tbl1 = (struct _ss_request_table *) tbl; - struct _ss_request_entry *e = (struct _ss_request_entry *) tbl1->requests; - return e + idx; -} -#else -#define get_request(tbl,idx) ((tbl) -> requests + (idx)) -#endif - -/* - * check_request_table(rqtbl, argc, argv, sci_idx) - * - * Function: - * If the command string in argv[0] is in the request table, execute - * the commands and return error code 0. Otherwise, return error - * code ss_et_command_not_found. - * Arguments: - * rqtbl (ss_request_table *) - * pointer to request table - * argc (int) - * number of elements in argv[] - * argv (char *[]) - * argument string array - * sci_idx (int) - * ss-internal index for subsystem control info structure - * Returns: - * (int) - * zero if command found, ss_et_command_not_found otherwise - * Notes: - */ - -static int check_request_table (rqtbl, argc, argv, sci_idx) - register ss_request_table *rqtbl; - int argc; - char *argv[]; - int sci_idx; -{ -#ifdef __SABER__ - struct _ss_request_entry *request; -#else - register ss_request_entry *request; -#endif - register ss_data *info; - register char const * const * name; - char *string = argv[0]; - int i; - - info = ss_info(sci_idx); - info->argc = argc; - info->argv = argv; - for (i = 0; (request = get_request(rqtbl, i))->command_names; i++) { - for (name = request->command_names; *name; name++) - if (!strcmp(*name, string)) { - info->current_request = request->command_names[0]; - (request->function)(argc, (const char *const *) argv, - sci_idx,info->info_ptr); - info->current_request = (char *)NULL; - return(0); - } - } - return(SS_ET_COMMAND_NOT_FOUND); -} - -/* - * really_execute_command(sci_idx, argc, argv) - * - * Function: - * Fills in the argc, argv values in the subsystem entry and - * call the appropriate routine. - * Arguments: - * sci_idx (int) - * ss-internal index for subsystem control info structure - * argc (int) - * number of arguments in argument list - * argv (char **[]) - * pointer to parsed argument list (may be reallocated - * on abbrev expansion) - * - * Returns: - * (int) - * Zero if successful, ss_et_command_not_found otherwise. - * Notes: - */ - -static int really_execute_command (sci_idx, argc, argv) - int sci_idx; - int argc; - char **argv[]; -{ - register ss_request_table **rqtbl; - register ss_data *info; - - info = ss_info(sci_idx); - - for (rqtbl = info->rqt_tables; *rqtbl; rqtbl++) { - if (check_request_table (*rqtbl, argc, *argv, sci_idx) == 0) - return(0); - } - return(SS_ET_COMMAND_NOT_FOUND); -} - -/* - * ss_execute_command(sci_idx, argv) - * - * Function: - * Executes a parsed command list within the subsystem. - * Arguments: - * sci_idx (int) - * ss-internal index for subsystem control info structure - * argv (char *[]) - * parsed argument list - * Returns: - * (int) - * Zero if successful, ss_et_command_not_found otherwise. - * Notes: - */ - -ss_execute_command(sci_idx, argv) - int sci_idx; - register char *argv[]; -{ - register int i, argc; - char **argp; - - argc = 0; - for (argp = argv; *argp; argp++) - argc++; - argp = (char **)malloc((argc+1)*sizeof(char *)); - for (i = 0; i <= argc; i++) - argp[i] = argv[i]; - i = really_execute_command(sci_idx, argc, &argp); - free(argp); - return(i); -} - -/* - * ss_execute_line(sci_idx, line_ptr) - * - * Function: - * Parses and executes a command line within a subsystem. - * Arguments: - * sci_idx (int) - * ss-internal index for subsystem control info structure - * line_ptr (char *) - * Pointer to command line to be parsed. - * Returns: - * (int) - * Error code. - * Notes: - */ - -int ss_execute_line (sci_idx, line_ptr) - int sci_idx; - char *line_ptr; -{ - char **argv; - int argc; - - /* flush leading whitespace */ - while (line_ptr[0] == ' ' || line_ptr[0] == '\t') - line_ptr++; - - /* check if it should be sent to operating system for execution */ - if (*line_ptr == '!') { - if (ss_info(sci_idx)->flags.escape_disabled) - return SS_ET_ESCAPE_DISABLED; - else { - line_ptr++; - system(line_ptr); - return 0; - } - } - - /* parse it */ - argv = ss_parse(sci_idx, line_ptr, &argc); - if (argc == 0) - return 0; - - /* look it up in the request tables, execute if found */ - return really_execute_command (sci_idx, argc, &argv); -} diff --git a/util/ss/help.c b/util/ss/help.c deleted file mode 100644 index ad3b90b..0000000 --- a/util/ss/help.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright info, see copyright.h. - */ - -#include <sys/param.h> -#include <sys/types.h> -#include <sys/file.h> -#ifdef NEED_SYS_FCNTL_H -/* just for O_* */ -#include <sys/fcntl.h> -#endif -#include <sys/wait.h> -#include "ss_internal.h" -#include "copyright.h" - -extern int errno; - -void ss_help (argc, argv, sci_idx, info_ptr) - int argc; - char const * const *argv; - int sci_idx; - pointer info_ptr; -{ - char buffer[MAXPATHLEN]; - char const *request_name; - int code; - int fd, child; - register int idx; - register ss_data *info; - - request_name = ss_current_request(sci_idx, &code); - if (code != 0) { - ss_perror(sci_idx, code, ""); - return; /* no ss_abort_line, if invalid invocation */ - } - if (argc == 1) { - ss_list_requests(argc, argv, sci_idx, info_ptr); - return; - } - else if (argc != 2) { - /* should do something better than this */ - sprintf(buffer, "usage:\n\t%s [topic|command]\nor\t%s\n", - request_name, request_name); - ss_perror(sci_idx, 0, buffer); - return; - } - info = ss_info(sci_idx); - if (info->info_dirs == (char **)NULL) { - ss_perror(sci_idx, SS_ET_NO_INFO_DIR, (char *)NULL); - return; - } - if (info->info_dirs[0] == (char *)NULL) { - ss_perror(sci_idx, SS_ET_NO_INFO_DIR, (char *)NULL); - return; - } - for (idx = 0; info->info_dirs[idx] != (char *)NULL; idx++) { - (void) strcpy(buffer, info->info_dirs[idx]); - (void) strcat(buffer, "/"); - (void) strcat(buffer, argv[1]); - (void) strcat(buffer, ".info"); - if ((fd = open(&buffer[0], O_RDONLY)) >= 0) goto got_it; - } - if ((fd = open(&buffer[0], O_RDONLY)) < 0) { - char buf[MAXPATHLEN]; - strcpy(buf, "No info found for "); - strcat(buf, argv[1]); - ss_perror(sci_idx, 0, buf); - return; - } -got_it: - switch (child = fork()) { - case -1: - ss_perror(sci_idx, errno, "Can't fork for pager"); - return; - case 0: - (void) dup2(fd, 0); /* put file on stdin */ - ss_page_stdin(); - default: - (void) close(fd); /* what can we do if it fails? */ - while (wait((union wait *)NULL) != child) { - /* do nothing if wrong pid */ - }; - } -} - -#ifndef USE_DIRENT_H -#include <sys/dir.h> -#else -#include <dirent.h> -#endif - -void ss_add_info_dir(sci_idx, info_dir, code_ptr) - int sci_idx; - char *info_dir; - int *code_ptr; -{ - register ss_data *info; - DIR *d; - int n_dirs; - register char **dirs; - - info = ss_info(sci_idx); - if (info_dir == NULL && *info_dir) { - *code_ptr = SS_ET_NO_INFO_DIR; - return; - } - if ((d = opendir(info_dir)) == (DIR *)NULL) { - *code_ptr = errno; - return; - } - closedir(d); - dirs = info->info_dirs; - for (n_dirs = 0; dirs[n_dirs] != (char *)NULL; n_dirs++) - ; /* get number of non-NULL dir entries */ - dirs = (char **)realloc((char *)dirs, - (unsigned)(n_dirs + 2)*sizeof(char *)); - if (dirs == (char **)NULL) { - info->info_dirs = (char **)NULL; - *code_ptr = errno; - return; - } - info->info_dirs = dirs; - dirs[n_dirs + 1] = (char *)NULL; - dirs[n_dirs] = malloc((unsigned)strlen(info_dir)+1); - strcpy(dirs[n_dirs], info_dir); - *code_ptr = 0; -} - -void ss_delete_info_dir(sci_idx, info_dir, code_ptr) - int sci_idx; - char *info_dir; - int *code_ptr; -{ - register char **i_d; - register char **info_dirs; - - info_dirs = ss_info(sci_idx)->info_dirs; - for (i_d = info_dirs; *i_d; i_d++) { - if (!strcmp(*i_d, info_dir)) { - while (*i_d) { - *i_d = *(i_d+1); - i_d++; - } - *code_ptr = 0; - return; - } - } - *code_ptr = SS_ET_NO_INFO_DIR; -} diff --git a/util/ss/invocation.c b/util/ss/invocation.c deleted file mode 100644 index c7cef48..0000000 --- a/util/ss/invocation.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright information, see copyright.h. - */ -#include "ss_internal.h" -#include "copyright.h" -#define size sizeof(ss_data *) - - -int ss_create_invocation(subsystem_name, version_string, info_ptr, - request_table_ptr, code_ptr) - char *subsystem_name, *version_string; - char *info_ptr; - ss_request_table *request_table_ptr; - int *code_ptr; -{ - register int sci_idx; - register ss_data *new_table; - register ss_data **table; - - *code_ptr = 0; - table = _ss_table; - new_table = (ss_data *) malloc(sizeof(ss_data)); - - if (table == (ss_data **) NULL) { - table = (ss_data **) malloc(2 * size); - table[0] = table[1] = (ss_data *)NULL; - } - initialize_ss_error_table (); - - for (sci_idx = 1; table[sci_idx] != (ss_data *)NULL; sci_idx++) - ; - table = (ss_data **) realloc((char *)table, - ((unsigned)sci_idx+2)*size); - table[sci_idx+1] = (ss_data *) NULL; - table[sci_idx] = new_table; - - new_table->subsystem_name = subsystem_name; - new_table->subsystem_version = version_string; - new_table->argv = (char **)NULL; - new_table->current_request = (char *)NULL; - new_table->info_dirs = (char **)malloc(sizeof(char *)); - *new_table->info_dirs = (char *)NULL; - new_table->info_ptr = info_ptr; - new_table->prompt = malloc((unsigned)strlen(subsystem_name)+4); - strcpy(new_table->prompt, subsystem_name); - strcat(new_table->prompt, ": "); -#ifdef silly - new_table->abbrev_info = ss_abbrev_initialize("/etc/passwd", code_ptr); -#else - new_table->abbrev_info = NULL; -#endif - new_table->flags.escape_disabled = 0; - new_table->flags.abbrevs_disabled = 0; - new_table->rqt_tables = - (ss_request_table **) calloc(2, sizeof(ss_request_table *)); - *(new_table->rqt_tables) = request_table_ptr; - *(new_table->rqt_tables+1) = (ss_request_table *) NULL; - _ss_table = table; - return(sci_idx); -} - -void -ss_delete_invocation(sci_idx) - int sci_idx; -{ - register ss_data *t; - int ignored_code; - - t = ss_info(sci_idx); - free(t->prompt); - free((char *)t->rqt_tables); - while(t->info_dirs[0] != (char *)NULL) - ss_delete_info_dir(sci_idx, t->info_dirs[0], &ignored_code); - free((char *)t->info_dirs); - free((char *)t); -} diff --git a/util/ss/list_rqs.c b/util/ss/list_rqs.c deleted file mode 100644 index c44ebed..0000000 --- a/util/ss/list_rqs.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright information, see copyright.h. - */ -#include "copyright.h" -#include "ss_internal.h" -#include <signal.h> -#include <setjmp.h> -#include <sys/wait.h> - -#ifdef lint /* "lint returns a value which is sometimes ignored" */ -#define DONT_USE(x) x=x; -#else /* !lint */ -#define DONT_USE(x) ; -#endif /* lint */ - -static char const twentyfive_spaces[26] = - " "; -static char const NL[2] = "\n"; - -ss_list_requests(argc, argv, sci_idx, info_ptr) - int argc; - char **argv; - int sci_idx; - pointer info_ptr; -{ - register ss_request_entry *entry; - register char const * const *name; - register int spacing; - register ss_request_table **table; - - char buffer[BUFSIZ]; - FILE *output; - int fd; - int mask; - RETSIGTYPE (*func)(); -#ifndef WAIT_USES_INT - union wait waitb; -#else - int waitb; -#endif - - DONT_USE(argc); - DONT_USE(argv); - - mask = sigblock(sigmask(SIGINT)); - func = signal(SIGINT, SIG_IGN); - fd = ss_pager_create(); - output = fdopen(fd, "w"); - sigsetmask(mask); - - fprintf (output, "Available %s requests:\n\n", - ss_info (sci_idx) -> subsystem_name); - - for (table = ss_info(sci_idx)->rqt_tables; *table; table++) { - entry = (*table)->requests; - for (; entry->command_names; entry++) { - spacing = -2; - buffer[0] = '\0'; - if (entry->flags & SS_OPT_DONT_LIST) - continue; - for (name = entry->command_names; *name; name++) { - register int len = strlen(*name); - strncat(buffer, *name, len); - spacing += len + 2; - if (name[1]) { - strcat(buffer, ", "); - } - } - if (spacing > 23) { - strcat(buffer, NL); - fputs(buffer, output); - spacing = 0; - buffer[0] = '\0'; - } - strncat(buffer, twentyfive_spaces, 25-spacing); - strcat(buffer, entry->info_string); - strcat(buffer, NL); - fputs(buffer, output); - } - } - fclose(output); -#ifndef NO_FORK - wait(&waitb); -#endif - (void) signal(SIGINT, func); -} diff --git a/util/ss/listen.c b/util/ss/listen.c deleted file mode 100644 index dd47601..0000000 --- a/util/ss/listen.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Listener loop for subsystem library libss.a. - * - * util/ss/listen.c - * - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright information, see copyright.h. - */ - -#include "copyright.h" -#include "ss_internal.h" -#include <stdio.h> -#include <setjmp.h> -#include <signal.h> -#include <sys/param.h> -#ifdef BSD -#include <sgtty.h> -#endif - -static ss_data *current_info; -static jmp_buf listen_jmpb; - -static RETSIGTYPE print_prompt() -{ -#ifdef BSD - /* put input into a reasonable mode */ - struct sgttyb ttyb; - if (ioctl(fileno(stdin), TIOCGETP, &ttyb) != -1) { - if (ttyb.sg_flags & (CBREAK|RAW)) { - ttyb.sg_flags &= ~(CBREAK|RAW); - (void) ioctl(0, TIOCSETP, &ttyb); - } - } -#endif - (void) fputs(current_info->prompt, stdout); - (void) fflush(stdout); -} - -static RETSIGTYPE listen_int_handler() -{ - putc('\n', stdout); - longjmp(listen_jmpb, 1); -} - -int ss_listen (sci_idx) - int sci_idx; -{ - register char *cp; - register RETSIGTYPE (*sig_cont)(); - register ss_data *info; - RETSIGTYPE (*sig_int)(), (*old_sig_cont)(); - char input[BUFSIZ]; - char buffer[BUFSIZ]; - char *end = buffer; - int mask; - int code; - jmp_buf old_jmpb; - ss_data *old_info = current_info; - - current_info = info = ss_info(sci_idx); - sig_cont = (RETSIGTYPE (*)())0; - info->abort = 0; - mask = sigblock(sigmask(SIGINT)); - memcpy(old_jmpb, listen_jmpb, sizeof(jmp_buf)); - sig_int = signal(SIGINT, listen_int_handler); - setjmp(listen_jmpb); - (void) sigsetmask(mask); - while(!info->abort) { - print_prompt(); - *end = '\0'; - old_sig_cont = sig_cont; - sig_cont = signal(SIGCONT, print_prompt); - if (sig_cont == print_prompt) - sig_cont = old_sig_cont; - if (fgets(input, BUFSIZ, stdin) != input) { - code = SS_ET_EOF; - goto egress; - } - cp = strchr(input, '\n'); - if (cp) { - *cp = '\0'; - if (cp == input) - continue; - } - (void) signal(SIGCONT, sig_cont); - for (end = input; *end; end++) - ; - - code = ss_execute_line (sci_idx, input); - if (code == SS_ET_COMMAND_NOT_FOUND) { - register char *c = input; - while (*c == ' ' || *c == '\t') - c++; - cp = strchr (c, ' '); - if (cp) - *cp = '\0'; - cp = strchr (c, '\t'); - if (cp) - *cp = '\0'; - ss_error (sci_idx, 0, - "Unknown request \"%s\". Type \"?\" for a request list.", - c); - } - } - code = 0; -egress: - (void) signal(SIGINT, sig_int); - memcpy(listen_jmpb, old_jmpb, sizeof(jmp_buf)); - current_info = old_info; - return code; -} - -void ss_abort_subsystem(sci_idx, code) - int sci_idx; - int code; -{ - ss_info(sci_idx)->abort = 1; - ss_info(sci_idx)->exit_status = code; - -} - -int ss_quit(argc, argv, sci_idx, infop) - int argc; - char **argv; - int sci_idx; - pointer infop; -{ - ss_abort_subsystem(sci_idx, 0); -} diff --git a/util/ss/mit-sipb-copyright.h b/util/ss/mit-sipb-copyright.h deleted file mode 100644 index ffcfc38..0000000 --- a/util/ss/mit-sipb-copyright.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - -Copyright 1987 by the Student Information Processing Board - of the Massachusetts Institute of Technology - -Permission to use, copy, modify, and distribute this software -and its documentation for any purpose and without fee is -hereby granted, provided that the above copyright notice -appear in all copies and that both that copyright notice and -this permission notice appear in supporting documentation, -and that the names of M.I.T. and the M.I.T. S.I.P.B. not be -used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. -M.I.T. and the M.I.T. S.I.P.B. make no representations about -the suitability of this software for any purpose. It is -provided "as is" without express or implied warranty. - -*/ - diff --git a/util/ss/mk_cmds.c b/util/ss/mk_cmds.c deleted file mode 100644 index fa69b59..0000000 --- a/util/ss/mk_cmds.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * make_commands.c - * - * util/ss/mk_cmds.c - * - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright information, see copyright.h. - */ - -#include "copyright.h" -#include <stdio.h> -#include <sys/param.h> -#include <sys/types.h> -#include <sys/file.h> -#include <string.h> -#include "ss_internal.h" - -static const char copyright[] = - "Copyright 1987 by MIT Student Information Processing Board"; - -extern pointer malloc PROTOTYPE((unsigned)); -extern char *last_token; -extern FILE *output_file; - -extern FILE *yyin, *yyout; -#ifndef NO_YYLINENO -extern int yylineno; -#endif - -int main(argc, argv) - int argc; - char **argv; -{ - char c_file[MAXPATHLEN]; - int result; - char *path, *p; - - if (argc != 2) { - fputs("Usage: ", stderr); - fputs(argv[0], stderr); - fputs("cmdtbl.ct\n", stderr); - exit(1); - } - - path = malloc(strlen(argv[1])+4); /* extra space to add ".ct" */ - strcpy(path, argv[1]); - p = strrchr(path, '/'); - if (p == (char *)NULL) - p = path; - else - p++; - p = strrchr(p, '.'); - if (p == (char *)NULL || strcmp(p, ".ct")) - strcat(path, ".ct"); - yyin = fopen(path, "r"); - if (!yyin) { - perror(path); - exit(1); - } - - p = strrchr(path, '.'); - *p = '\0'; - strcpy(c_file, path); - strcat(c_file, ".c"); - *p = '.'; - - output_file = fopen(c_file, "w+"); - if (!output_file) { - perror(c_file); - exit(1); - } - - fputs("/* ", output_file); - fputs(c_file, output_file); - fputs(" - automatically generated from ", output_file); - fputs(path, output_file); - fputs(" */\n", output_file); - fputs("#include <ss/ss.h>\n\n", output_file); - fputs("#ifndef __STDC__\n#define const\n#endif\n\n", output_file); - /* parse it */ - result = yyparse(); - /* put file descriptors back where they belong */ - fclose(yyin); /* bye bye input file */ - fclose(output_file); /* bye bye output file */ - - return result; -} - -yyerror(s) - char *s; -{ - fputs(s, stderr); -#ifdef NO_YYLINENO - fprintf(stderr, "\nLast token was '%s'\n", last_token); -#else - fprintf(stderr, "\nLine %d; last token was '%s'\n", - yylineno, last_token); -#endif -} diff --git a/util/ss/mk_cmds.sh b/util/ss/mk_cmds.sh deleted file mode 100755 index d41ab90..0000000 --- a/util/ss/mk_cmds.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# -# - -DIR=@DIR@ -AWK=@AWK@ -SED=@SED@ - -FILE=$1 -ROOT=`echo $1 | sed -e s/.ct$//` -BASE=`echo $ROOT | sed -e 's;.*/;;'` -TMP=ct$$.c - -${SED} -f ${DIR}/ct_c.sed ${FILE} \ - | ${AWK} -f ${DIR}/ct_c.awk rootname=${ROOT} outfile=${TMP} - - -if grep "^#__ERROR_IN_FILE" ${TMP} > /dev/null; then - rm ${TMP} - exit 1 -else - mv ${TMP} ${BASE}.c - exit 0 -fi diff --git a/util/ss/options.c b/util/ss/options.c deleted file mode 100644 index dd648b0..0000000 --- a/util/ss/options.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright information, see copyright.h. - */ -#include "copyright.h" -#include <stdio.h> -#include "ss.h" - -struct option { - char *text; - long value; -}; - -static struct option options[] = { - { "dont_list", SS_OPT_DONT_LIST }, - { "^list", SS_OPT_DONT_LIST }, - { "dont_summarize", SS_OPT_DONT_SUMMARIZE }, - { "^summarize", SS_OPT_DONT_SUMMARIZE }, - { (char *)NULL, 0 } -}; - -long -flag_val(string) - register char *string; -{ - register struct option *opt; - for (opt = options; opt->text; opt++) - if (!strcmp(opt->text, string)) - return(opt->value); - return(0); -} diff --git a/util/ss/pager.c b/util/ss/pager.c deleted file mode 100644 index b951fa6..0000000 --- a/util/ss/pager.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Pager: Routines to create a "more" running out of a particular file - * descriptor. - * - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright information, see copyright.h. - */ - -#include "ss_internal.h" -#include "copyright.h" -#include <stdio.h> -#include <sys/types.h> -#include <sys/file.h> -#include <signal.h> - -static char MORE[] = "more"; -extern char *_ss_pager_name; -extern char *getenv(); -extern int errno; - -/* - * this needs a *lot* of work.... - * - * run in same process - * handle SIGINT sensibly - * allow finer control -- put-page-break-here - */ -void ss_page_stdin(); - -#ifndef NO_FORK -int ss_pager_create() -{ - int filedes[2]; - - if (pipe(filedes) != 0) - return(-1); - - switch(fork()) { - case -1: - return(-1); - case 0: - /* - * Child; dup read half to 0, close all but 0, 1, and 2 - */ - if (dup2(filedes[0], 0) == -1) - exit(1); - ss_page_stdin(); - default: - /* - * Parent: close "read" side of pipe, return - * "write" side. - */ - (void) close(filedes[0]); - return(filedes[1]); - } -} -#else /* don't fork */ -int ss_pager_create() -{ - int fd; - fd = open("/dev/tty", O_WRONLY, 0); - return fd; -} -#endif - -void ss_page_stdin() -{ - int i; - for (i = 3; i < 32; i++) - (void) close(i); - (void) signal(SIGINT, SIG_DFL); - { - int mask = sigblock(0); - mask &= ~sigmask(SIGINT); - sigsetmask(mask); - } - if (_ss_pager_name == (char *)NULL) { - if ((_ss_pager_name = getenv("PAGER")) == (char *)NULL) - _ss_pager_name = MORE; - } - (void) execlp(_ss_pager_name, _ss_pager_name, (char *) NULL); - { - /* minimal recovery if pager program isn't found */ - char buf[80]; - register int n; - while ((n = read(0, buf, 80)) > 0) - write(1, buf, n); - } - exit(errno); -} diff --git a/util/ss/parse.c b/util/ss/parse.c deleted file mode 100644 index ddb6378..0000000 --- a/util/ss/parse.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright info, see copyright.h. - */ - -#include "ss_internal.h" -#include "copyright.h" - - -enum parse_mode { WHITESPACE, TOKEN, QUOTED_STRING }; - -/* - * parse(line_ptr, argc_ptr) - * - * Function: - * Parses line, dividing at whitespace, into tokens, returns - * the "argc" and "argv" values. - * Arguments: - * line_ptr (char *) - * Pointer to text string to be parsed. - * argc_ptr (int *) - * Where to put the "argc" (number of tokens) value. - * Returns: - * argv (char **) - * Series of pointers to parsed tokens. - */ - -#define NEW_ARGV(old,n) (char **)realloc((char *)old,\ - (unsigned)(n+2)*sizeof(char*)) - -char **ss_parse (sci_idx, line_ptr, argc_ptr) - int sci_idx; - register char *line_ptr; - int *argc_ptr; -{ - register char **argv, *cp; - register int argc; - register enum parse_mode parse_mode; - - argv = (char **) malloc (sizeof(char *)); - if (argv == (char **)NULL) { - ss_error(sci_idx, errno, "Can't allocate storage"); - *argc_ptr = 0; - return(argv); - } - *argv = (char *)NULL; - - argc = 0; - - parse_mode = WHITESPACE; /* flushing whitespace */ - cp = line_ptr; /* cp is for output */ - while (1) { -#ifdef DEBUG - { - printf ("character `%c', mode %d\n", *line_ptr, parse_mode); - } -#endif - while (parse_mode == WHITESPACE) { - if (*line_ptr == '\0') - goto end_of_line; - if (*line_ptr == ' ' || *line_ptr == '\t') { - line_ptr++; - continue; - } - if (*line_ptr == '"') { - /* go to quoted-string mode */ - parse_mode = QUOTED_STRING; - cp = line_ptr++; - argv = NEW_ARGV (argv, argc); - argv[argc++] = cp; - argv[argc] = NULL; - } - else { - /* random-token mode */ - parse_mode = TOKEN; - cp = line_ptr; - argv = NEW_ARGV (argv, argc); - argv[argc++] = line_ptr; - argv[argc] = NULL; - } - } - while (parse_mode == TOKEN) { - if (*line_ptr == '\0') { - *cp++ = '\0'; - goto end_of_line; - } - else if (*line_ptr == ' ' || *line_ptr == '\t') { - *cp++ = '\0'; - line_ptr++; - parse_mode = WHITESPACE; - } - else if (*line_ptr == '"') { - line_ptr++; - parse_mode = QUOTED_STRING; - } - else { - *cp++ = *line_ptr++; - } - } - while (parse_mode == QUOTED_STRING) { - if (*line_ptr == '\0') { - ss_error (sci_idx, 0, - "Unbalanced quotes in command line"); - free (argv); - *argc_ptr = 0; - return NULL; - } - else if (*line_ptr == '"') { - if (*++line_ptr == '"') { - *cp++ = '"'; - line_ptr++; - } - else { - parse_mode = TOKEN; - } - } - else { - *cp++ = *line_ptr++; - } - } - } -end_of_line: - *argc_ptr = argc; -#ifdef DEBUG - { - int i; - printf ("argc = %d\n", argc); - for (i = 0; i <= argc; i++) - printf ("\targv[%2d] = `%s'\n", i, - argv[i] ? argv[i] : "<NULL>"); - } -#endif - return(argv); -} diff --git a/util/ss/prompt.c b/util/ss/prompt.c deleted file mode 100644 index 5df2731..0000000 --- a/util/ss/prompt.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * prompt.c: Routines for retrieving and setting a prompt. - * - * util/ss/prompt.c - * - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright information, see copyright.h. - */ - -#include "copyright.h" -#include <stdio.h> -#include "ss_internal.h" - -ss_set_prompt(sci_idx, new_prompt) - int sci_idx; - char *new_prompt; -{ - ss_info(sci_idx)->prompt = new_prompt; -} - -char * -ss_get_prompt(sci_idx) - int sci_idx; -{ - return(ss_info(sci_idx)->prompt); -} diff --git a/util/ss/request_tbl.c b/util/ss/request_tbl.c deleted file mode 100644 index 8dcb583..0000000 --- a/util/ss/request_tbl.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright information, see copyright.h. - */ - -#include "copyright.h" -#include "ss_internal.h" - -#define ssrt ss_request_table /* for some readable code... */ - -ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr) - int sci_idx; - ssrt *rqtbl_ptr; - int position; /* 1 -> becomes second... */ - int *code_ptr; -{ - register ss_data *info; - register int i, size; - - info = ss_info(sci_idx); - for (size=0; info->rqt_tables[size] != (ssrt *)NULL; size++) - ; - /* size == C subscript of NULL == #elements */ - size += 2; /* new element, and NULL */ - info->rqt_tables = (ssrt **)realloc((char *)info->rqt_tables, - (unsigned)size*sizeof(ssrt)); - if (info->rqt_tables == (ssrt **)NULL) { - *code_ptr = errno; - return; - } - if (position > size - 2) - position = size - 2; - - if (size > 1) - for (i = size - 2; i >= position; i--) - info->rqt_tables[i+1] = info->rqt_tables[i]; - - info->rqt_tables[position] = rqtbl_ptr; - info->rqt_tables[size-1] = (ssrt *)NULL; - *code_ptr = 0; -} - -ss_delete_request_table(sci_idx, rqtbl_ptr, code_ptr) - int sci_idx; - ssrt *rqtbl_ptr; - int *code_ptr; -{ - register ss_data *info; - register ssrt **rt1, **rt2; - - *code_ptr = SS_ET_TABLE_NOT_FOUND; - info = ss_info(sci_idx); - rt1 = info->rqt_tables; - for (rt2 = rt1; *rt1; rt1++) { - if (*rt1 != rqtbl_ptr) { - *rt2++ = *rt1; - *code_ptr = 0; - } - } - *rt2 = (ssrt *)NULL; - return; -} diff --git a/util/ss/requests.c b/util/ss/requests.c deleted file mode 100644 index bfe69f1..0000000 --- a/util/ss/requests.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Various minor routines... - * - * Copyright 1987, 1988, 1989 by MIT - * - * For copyright information, see mit-sipb-copyright.h. - */ - -#include "mit-sipb-copyright.h" -#include <stdio.h> -#include "ss_internal.h" - -#define DECLARE(name) name(argc,argv,sci_idx)int argc,sci_idx;char **argv; - -/* - * ss_self_identify -- assigned by default to the "." request - */ -DECLARE(ss_self_identify) -{ - register ss_data *info = ss_info(sci_idx); - printf("%s version %s\n", info->subsystem_name, - info->subsystem_version); -} - -/* - * ss_subsystem_name -- print name of subsystem - */ -DECLARE(ss_subsystem_name) -{ - printf("%s\n", ss_info(sci_idx)->subsystem_name); -} - -/* - * ss_subsystem_version -- print version of subsystem - */ -DECLARE(ss_subsystem_version) -{ - printf("%s\n", ss_info(sci_idx)->subsystem_version); -} - -/* - * ss_unimplemented -- routine not implemented (should be - * set up as (dont_list,dont_summarize)) - */ -DECLARE(ss_unimplemented) -{ - ss_perror(sci_idx, SS_ET_UNIMPLEMENTED, ""); -} diff --git a/util/ss/ss.h b/util/ss/ss.h deleted file mode 100644 index ca3197d..0000000 --- a/util/ss/ss.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright information, see mit-sipb-copyright.h. - */ - -#ifndef _ss_h -#define _ss_h __FILE__ - -#include <ss/mit-sipb-copyright.h> -#include <ss/ss_err.h> - -extern int errno; - -#ifdef __STDC__ -#define __SS_CONST const -#define __SS_PROTO (int, const char * const *, int, void *) -#else -#define __SS_CONST -#define __SS_PROTO () -#endif - -typedef __SS_CONST struct _ss_request_entry { - __SS_CONST char * __SS_CONST *command_names; /* whatever */ - void (* __SS_CONST function) __SS_PROTO; /* foo */ - __SS_CONST char * __SS_CONST info_string; /* NULL */ - int flags; /* 0 */ -} ss_request_entry; - -typedef __SS_CONST struct _ss_request_table { - int version; - ss_request_entry *requests; -} ss_request_table; - -#define SS_RQT_TBL_V2 2 - -typedef struct _ss_rp_options { /* DEFAULT VALUES */ - int version; /* SS_RP_V1 */ - void (*unknown) __SS_PROTO; /* call for unknown command */ - int allow_suspend; - int catch_int; -} ss_rp_options; - -#define SS_RP_V1 1 - -#define SS_OPT_DONT_LIST 0x0001 -#define SS_OPT_DONT_SUMMARIZE 0x0002 - -void ss_help __SS_PROTO; -char *ss_current_request(); -char *ss_name(); -#ifdef __STDC__ -void ss_error (int, long, char const *, ...); -void ss_perror (int, long, char const *); -#else -void ss_error (); -void ss_perror (); -#endif -void ss_abort_subsystem(); -extern ss_request_table ss_std_requests; -#endif /* _ss_h */ diff --git a/util/ss/ss_err.et b/util/ss/ss_err.et deleted file mode 100644 index 80e9dfa..0000000 --- a/util/ss/ss_err.et +++ /dev/null @@ -1,39 +0,0 @@ - error_table ss - -ec SS_ET_SUBSYSTEM_ABORTED, - "Subsystem aborted" - -ec SS_ET_VERSION_MISMATCH, - "Version mismatch" - -ec SS_ET_NULL_INV, - "No current invocation" - -ec SS_ET_NO_INFO_DIR, - "No info directory" - -ec SS_ET_COMMAND_NOT_FOUND, - "Command not found" - -ec SS_ET_LINE_ABORTED, - "Command line aborted" - -ec SS_ET_EOF, - "End-of-file reached" - -ec SS_ET_PERMISSION_DENIED, - "Permission denied" - -ec SS_ET_TABLE_NOT_FOUND, - "Request table not found" - -ec SS_ET_NO_HELP_FILE, - "No info available" - -ec SS_ET_ESCAPE_DISABLED, - "Shell escapes are disabled" - -ec SS_ET_UNIMPLEMENTED, - "Sorry, this request is not yet implemented" - - end diff --git a/util/ss/ss_internal.h b/util/ss/ss_internal.h deleted file mode 100644 index 4b9ea23..0000000 --- a/util/ss/ss_internal.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright information, see copyright.h. - */ - -#ifndef _ss_ss_internal_h -#define _ss_ss_internal_h __FILE__ -#include <stdio.h> -#include <string.h> - -#ifdef __STDC__ - -#define PROTOTYPE(p) p -typedef void * pointer; - -#else - -#define const -#define volatile -#define PROTOTYPE(p) () -typedef char * pointer; - -#endif /* not __STDC__ */ - -#include "ss.h" - -#if defined(__GNUC__) -#define LOCAL_ALLOC(x) __builtin_alloca(x) -#define LOCAL_FREE(x) -#else -#if defined(vax) -#define LOCAL_ALLOC(x) alloca(x) -#define LOCAL_FREE(x) -extern pointer alloca PROTOTYPE((unsigned)); -#else -#if defined(__HIGHC__) /* Barf! */ -pragma on(alloca); -#define LOCAL_ALLOC(x) alloca(x) -#define LOCAL_FREE(x) -extern pointer alloca PROTOTYPE((unsigned)); -#else -/* no alloca? */ -#define LOCAL_ALLOC(x) malloc(x) -#define LOCAL_FREE(x) free(x) -#endif -#endif -#endif /* LOCAL_ALLOC stuff */ - -typedef char BOOL; - -typedef struct _ss_abbrev_entry { - char *name; /* abbrev name */ - char **abbrev; /* new tokens to insert */ - unsigned int beginning_of_line : 1; -} ss_abbrev_entry; - -typedef struct _ss_abbrev_list { - int n_abbrevs; - ss_abbrev_entry *first_abbrev; -} ss_abbrev_list; - -typedef struct { -/* char *path; */ - ss_abbrev_list abbrevs[127]; -} ss_abbrev_info; - -typedef struct _ss_data { /* init values */ - /* this subsystem */ - char *subsystem_name; - char *subsystem_version; - /* current request info */ - int argc; - char **argv; /* arg list */ - char const *current_request; /* primary name */ - /* info directory for 'help' */ - char **info_dirs; - /* to be extracted by subroutines */ - pointer info_ptr; /* (void *) NULL */ - /* for ss_listen processing */ - char *prompt; - ss_request_table **rqt_tables; - ss_abbrev_info *abbrev_info; - struct { - unsigned int escape_disabled : 1, - abbrevs_disabled : 1; - } flags; - /* to get out */ - int abort; /* exit subsystem */ - int exit_status; -} ss_data; - -#define CURRENT_SS_VERSION 1 - -#define ss_info(sci_idx) (_ss_table[sci_idx]) -#define ss_current_request(sci_idx,code_ptr) \ - (*code_ptr=0,ss_info(sci_idx)->current_request) -void ss_unknown_function(); -void ss_delete_info_dir(); -int ss_execute_line(); -char **ss_parse(); -ss_abbrev_info *ss_abbrev_initialize PROTOTYPE((char *, int *)); -void ss_page_stdin(); - -extern ss_data **_ss_table; -extern char *ss_et_msgs[]; - -extern pointer malloc PROTOTYPE((unsigned)); -extern pointer realloc PROTOTYPE((pointer, unsigned)); -extern pointer calloc PROTOTYPE((unsigned, unsigned)); - -#ifdef USE_SIGPROCMASK -/* fake sigmask, sigblock, sigsetmask */ -#include <signal.h> -#define sigmask(x) (1L<<(x)-1) -#define sigsetmask(x) sigprocmask(SIG_SETMASK,&x,NULL) -static int _fake_sigstore; -#define sigblock(x) (_fake_sigstore=x,sigprocmask(SIG_BLOCK,&_fake_sigstore,0)) -#endif -#endif /* _ss_internal_h */ diff --git a/util/ss/std_rqs.ct b/util/ss/std_rqs.ct deleted file mode 100644 index 500288a..0000000 --- a/util/ss/std_rqs.ct +++ /dev/null @@ -1,46 +0,0 @@ - command_table ss_std_requests; - - request ss_self_identify, "Identify the subsystem.", - ".", - (dont_list, dont_summarize); - - request ss_help, "Display info on command or topic.", - help; - - unimplemented - ss_list_help, - "List topics for which help is available.", - list_help, lh; - - request ss_list_requests, "List available commands.", - list_requests, lr, "?"; - - request ss_quit, "Leave the subsystem.", - quit, q; - - unimplemented - ss_abbrev, - "Enable/disable abbreviation processing of request lines.", - abbrev, ab; - - unimplemented - ss_execute, - "Execute a UNIX command line.", - execute, e; - - unimplemented - ss_summarize_requests, - "Produce a list of the most commonly used requests.", - "?"; - - request ss_subsystem_name, - "Return the name of this subsystem.", - subsystem_name, - (dont_list); - - request ss_subsystem_version, - "Return the version of this subsystem.", - subsystem_version, - (dont_list); - - end; diff --git a/util/ss/test_ss.c b/util/ss/test_ss.c deleted file mode 100644 index db0af6f..0000000 --- a/util/ss/test_ss.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * util/ss/test_ss.c - */ - - -#include <stdio.h> -#include "ss.h" - -extern ss_request_table test_cmds; - -#define TRUE 1 -#define FALSE 0 - -static char def_subsystem_name[5] = "test"; -static char version [4] = "1.0"; -extern void ss_listen(); - -int main(argc, argv) - int argc; - char **argv; -{ - int code; - char *argv0 = argv[0]; - char *initial_request = (char *)NULL; - int quit = FALSE; /* quit after processing request */ - int sci_idx; - char *subsystem_name; - - subsystem_name = def_subsystem_name; - - for (; *argv; ++argv, --argc) { - printf("checking arg: %s\n", *argv); - if (!strcmp(*argv, "-prompt")) { - if (argc == 1) { - fprintf(stderr, - "No argument supplied with -prompt\n"); - exit(1); - } - argc--; argv++; - subsystem_name = *argv; - } - else if (!strcmp(*argv, "-request") || !strcmp(*argv, "-rq")) { - if (argc == 1) { - fprintf(stderr, - "No string supplied with -request.\n"); - exit(1); - } - argc--; argv++; - initial_request = *argv; - } - else if (!strcmp(*argv, "-quit")) - quit = TRUE; - else if (!strcmp(*argv, "-no_quit")) - quit = FALSE; - else if (**argv == '-') { - fprintf(stderr, "Unknown control argument %s\n", - *argv); - fprintf(stderr, - "Usage: %s [gateway] [ -prompt name ] [ -request name ] [ -quit ]\n", - argv0); - exit(1); - } - } - - sci_idx = ss_create_invocation(subsystem_name, version, - (char *)NULL, &test_cmds, &code); - if (code) { - ss_perror(sci_idx, code, "creating invocation"); - exit(1); - } - - (void) ss_add_request_table (sci_idx, &ss_std_requests, 1, &code); - if (code) { - ss_perror (sci_idx, code, "adding standard requests"); - exit (1); - } - - if (!quit) - printf("test version %s. Type '?' for a list of commands.\n\n", - version); - - if (initial_request != (char *)NULL) { - code = ss_execute_line(sci_idx, initial_request); - if (code != 0) - ss_perror(sci_idx, code, initial_request); - } - if (!quit || code) - (void) ss_listen (sci_idx, &code); - exit(0); -} - - -void test_cmd (argc, argv) - int argc; - char **argv; -{ - while (++argv, --argc) - fputs(*argv, stdout); - putchar ('\n'); -} diff --git a/util/ss/utils.c b/util/ss/utils.c deleted file mode 100644 index 3520601..0000000 --- a/util/ss/utils.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright 1987, 1988 by MIT Student Information Processing Board - * - * For copyright information, see copyright.h. - */ - -#include <string.h> -#include "copyright.h" -#include "ss_internal.h" /* includes stdio and string */ - -extern FILE *output_file; - -char *gensym(), *str_concat3(), *quote(); -extern long gensym_n; - -void write_ct(hdr, rql) - char const *hdr, *rql; -{ - char *sym; - sym = gensym("ssu"); - fputs("static ss_request_entry ", output_file); - fputs(sym, output_file); - fputs("[] = {\n", output_file); - fputs(rql, output_file); - fputs(" { 0, 0, 0, 0 }\n", output_file); - fputs("};\n\nss_request_table ", output_file); - fputs(hdr, output_file); - fprintf(output_file, " = { %d, ", SS_RQT_TBL_V2); - fputs(sym, output_file); - fputs(" };\n", output_file); -} - -char * generate_cmds_string(cmds) - char const *cmds; -{ - char * var_name = gensym("ssu"); - fputs("static char const * const ", output_file); - fputs(var_name, output_file); - fputs("[] = {\n", output_file); - fputs(cmds, output_file); - fputs(",\n (char const *)0\n};\n", output_file); - return(var_name); -} - -void generate_function_definition(func) - char const *func; -{ - fputs("extern void ", output_file); - fputs(func, output_file); - fputs(" __SS_PROTO;\n", output_file); -} - -char * generate_rqte(func_name, info_string, cmds, options) - char const *func_name; - char const *info_string; - char const *cmds; - int options; -{ - int size; - char *string, *var_name, numbuf[16]; - var_name = generate_cmds_string(cmds); - generate_function_definition(func_name); - size = 6; /* " { " */ - size += strlen(var_name)+7; /* "quux, " */ - size += strlen(func_name)+7; /* "foo, " */ - size += strlen(info_string)+9; /* "\"Info!\", " */ - sprintf(numbuf, "%d", options); - size += strlen(numbuf); - size += 4; /* " }," + NL */ - string = malloc(size * sizeof(char *)); - strcpy(string, " { "); - strcat(string, var_name); - strcat(string, ",\n "); - strcat(string, func_name); - strcat(string, ",\n "); - strcat(string, info_string); - strcat(string, ",\n "); - strcat(string, numbuf); - strcat(string, " },\n"); - return(string); -} - -char * -gensym(name) - char *name; -{ - char *symbol; - - symbol = malloc((strlen(name)+6) * sizeof(char)); - gensym_n++; - sprintf(symbol, "%s%05ld", name, gensym_n); - return(symbol); -} - -/* concatenate three strings and return the result */ -char *str_concat3(a, b, c) - register char *a, *b, *c; -{ - char *result; - int size_a = strlen(a); - int size_b = strlen(b); - int size_c = strlen(c); - - result = malloc((size_a + size_b + size_c + 2)*sizeof(char)); - strcpy(result, a); - strcpy(&result[size_a], c); - strcpy(&result[size_a+size_c], b); - return(result); -} - -/* return copy of string enclosed in double-quotes */ -char *quote(string) - register char *string; -{ - register char *result; - int len; - len = strlen(string)+1; - result = malloc(len+2); - result[0] = '"'; - strncpy(&result[1], string, len-1); - result[len] = '"'; - result[len+1] = '\0'; - return(result); -} - -#ifndef HAS_STRDUP -/* make duplicate of string and return pointer */ -char *strdup(s) - register char *s; -{ - register int len = strlen(s) + 1; - register char *new; - new = malloc(len); - strncpy(new, s, len); - return(new); -} -#endif diff --git a/zhm/Imakefile b/zhm/Imakefile deleted file mode 100644 index f008e04..0000000 --- a/zhm/Imakefile +++ /dev/null @@ -1,27 +0,0 @@ -/**/# Copyright 1988, 1993 Massachusetts Institute of Technology. -/**/# -/**/# For copying and distribution information, see the file -/**/# "mit-copyright.h". -/**/# -/**/# $Source$ -/**/# $Author$ -/**/# $Zephyr: /mit/zephyr/src/zhm/RCS/Imakefile,v 1.8 91/03/21 11:38:01 raeburn Exp $ -/**/# - -#if defined(SYSLOG_COMPAT42) -SOBJS= ../clients/syslogd/syslog.o -SINCLUDE= -I../clients/syslogd -#endif - -#ifdef __NetBSD__ -OSLIBS=-lcompat /* for insque() */ -#endif - -SRCS= zhm.c zhm_server.c zhm_client.c queue.c -OBJS= zhm.o zhm_server.o zhm_client.o queue.o - -XDEFS= $(SINCLUDE) -DPIDFILE=\"$(ZPIDDIR)/zhm.pid\" - -SimpleProgram(zhm,$(OBJS) $(SOBJS) $(ZLIB),$(ZLIBS) $(OSLIBS),$(ATHRETCDIR)) -install_man(zhm.8,zhm.8) -create_depend($(SRCS)) diff --git a/zhm/Makefile.in b/zhm/Makefile.in new file mode 100644 index 0000000..d591586 --- /dev/null +++ b/zhm/Makefile.in @@ -0,0 +1,48 @@ +SHELL = /bin/sh + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +datadir=@datadir@ +confdir=@confdir@ +sbindir=@sbindir@ +lsbindir=@lsbindir@ + +includedir=${prefix}/include +mandir=${prefix}/man +libdir=${exec_prefix}/lib + +srcdir=@srcdir@ +top_srcdir=@top_srcdir@ +BUILDTOP=.. +VPATH=@srcdir@ +CC=@CC@ +INSTALL=@INSTALL@ + +DEBUG=-O +CFLAGS=${DEBUG} -DCONFDIR=\"${confdir}\" -I${top_srcdir}/h -I${BUILDTOP}/h \ + @CPPFLAGS@ +LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @LDFLAGS@ +LIBS=-lzephyr @LIBS@ -lcom_err + +OBJS= timer.o queue.o zhm.o zhm_client.o zhm_server.o + +all: zhm + +zhm: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@ + ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} + +check: + +install: zhm + ${INSTALL} -m 755 -s zhm ${DESTDIR}${lsbindir} + ${INSTALL} -m 644 ${srcdir}/zhm.8 ${DESTDIR}${mandir}/man8 + +clean: + rm -f ${OBJS} zhm + +${OBJS}: zhm.h timer.h ${top_srcdir}/h/internal.h ${top_srcdir}/h/sysdep.h +${OBJS}: ${BUILDTOP}/h/config.h ${BUILDTOP}/h/zephyr/zephyr.h +${OBJS}: ${BUILDTOP}/h/zephyr/zephyr_err.h + +.PHONY: all check install clean + diff --git a/zhm/TODO b/zhm/TODO deleted file mode 100644 index 4562044..0000000 --- a/zhm/TODO +++ /dev/null @@ -1,9 +0,0 @@ - -Search for all occurences of (void) typecasting, and see whether I -should be checking return values. Make sure all mallocs are checked -for return values. - -Set system up to handle SERVNAK returns if we cannot reach a server. - -Set to handle emergency notices. - diff --git a/zhm/queue.c b/zhm/queue.c index fd87546..5e0ca3a 100644 --- a/zhm/queue.c +++ b/zhm/queue.c @@ -20,249 +20,224 @@ static char rcsid_queue_c[] = "$Header$"; #endif /* lint */ typedef struct _Queue { - long timeout; - int retries; - ZNotice_t z_notice; - caddr_t z_packet; - struct sockaddr_in reply; + Timer *timer; + int retries; + ZNotice_t notice; + caddr_t packet; + struct sockaddr_in reply; + struct _Queue *next, **prev_p; } Queue; -struct _qelem { - struct _qelem *q_forw; - struct _qelem *q_back; - Queue *q_data; -}; +static Queue *hm_queue; +static int retransmits_enabled = 0; -typedef struct _qelem Qelem; - -Qelem hm_queue = { &hm_queue, &hm_queue, NULL }, *is_in_queue(); +static Queue *find_notice_in_queue __P((ZNotice_t *notice)); +static Code_t dump_queue __P((void)); +static void queue_timeout __P((void *arg)); int rexmit_times[] = { 2, 2, 4, 4, 8, -1 }; -extern long time(); -extern int timeout_type; +#ifdef DEBUG +Code_t dump_queue(); +#endif void init_queue() { - while (hm_queue.q_forw != &hm_queue) { - free(hm_queue.q_forw->q_data->z_packet); - free((char *)hm_queue.q_forw->q_data); - remque(hm_queue.q_forw); - free((char *)hm_queue.q_forw); - } - - hm_queue.q_forw = hm_queue.q_back = &hm_queue; - hm_queue.q_data = NULL; - DPR ("Queue initialized and flushed.\n"); + Queue *q; + + while (hm_queue) { + q = hm_queue; + if (q->timer) + timer_reset(q->timer); + free(q->packet); + hm_queue = q->next; + free(q); + } + + DPR("Queue initialized and flushed.\n"); } Code_t add_notice_to_queue(notice, packet, repl, len) -ZNotice_t *notice; -caddr_t packet; -struct sockaddr_in *repl; -int len; + ZNotice_t *notice; + char * packet; + struct sockaddr_in *repl; + int len; { - Qelem *elem; - Queue *entry; - - DPR ("Adding notice to queue...\n"); - if (!is_in_queue(notice)) { - elem = (Qelem *)malloc(sizeof(Qelem)); - entry = (Queue *)malloc(sizeof(Queue)); - entry->timeout = time((time_t *)0) + rexmit_times[0]; - entry->retries = 0; - entry->z_packet = (char *)malloc(Z_MAXPKTLEN); - (void) memcpy(entry->z_packet, packet, Z_MAXPKTLEN); - if (ZParseNotice(entry->z_packet, len, &entry->z_notice) - != ZERR_NONE) { - syslog(LOG_ERR, "ZParseNotice failed, but succeeded before"); - free(entry->z_packet); - } else { - entry->reply = *repl; - elem->q_data = entry; - elem->q_forw = elem; - elem->q_back = elem; - insque(elem, hm_queue.q_back); - } - } -#ifdef DEBUG - if (!is_in_queue(notice)) - return(ZERR_NONOTICE); - else -#endif /* DEBUG */ - return(ZERR_NONE); + Queue *entry; + + DPR("Adding notice to queue...\n"); + if (!find_notice_in_queue(notice)) { + entry = (Queue *) malloc(sizeof(Queue)); + entry->retries = 0; + entry->packet = (char *) malloc(Z_MAXPKTLEN); + memcpy(entry->packet, packet, Z_MAXPKTLEN); + if (ZParseNotice(entry->packet, len, &entry->notice) != ZERR_NONE) { + syslog(LOG_ERR, "ZParseNotice failed, but succeeded before"); + free(entry->packet); + } else { + entry->reply = *repl; + LIST_INSERT(&hm_queue, entry); + } + entry->timer = (retransmits_enabled) ? + timer_set_rel(rexmit_times[0], queue_timeout, entry) : NULL; + } + return(ZERR_NONE); } Code_t remove_notice_from_queue(notice, kind, repl) -ZNotice_t *notice; -ZNotice_Kind_t *kind; -struct sockaddr_in *repl; + ZNotice_t *notice; + ZNotice_Kind_t *kind; + struct sockaddr_in *repl; { - Qelem *elem; - - DPR ("Removing notice from queue...\n"); - if ((elem = is_in_queue(notice)) == NULL) - return(ZERR_NONOTICE); - else { - *kind = elem->q_data->z_notice.z_kind; - *repl = elem->q_data->reply; - free(elem->q_data->z_packet); - free((char *)elem->q_data); - remque(elem); - free((char *)elem); - if (hm_queue.q_forw == &hm_queue) - (void)alarm(0); + Queue *entry; + + DPR("Removing notice from queue...\n"); + entry = find_notice_in_queue(notice); + if (entry == NULL) + return(ZERR_NONOTICE); + + *kind = entry->notice.z_kind; + *repl = entry->reply; + timer_reset(entry->timer); + free(entry->packet); + LIST_DELETE(entry); #ifdef DEBUG - dump_queue(); + dump_queue(); #endif /* DEBUG */ - return(ZERR_NONE); - } + return(ZERR_NONE); } +/* We have a server; transmit all of our packets. */ void retransmit_queue(sin) -struct sockaddr_in *sin; + struct sockaddr_in *sin; { - Qelem *srch; - Code_t ret; + Queue *entry; + Code_t ret; + + DPR("Retransmitting queue to new server...\n"); + ret = ZSetDestAddr(sin); + if (ret != ZERR_NONE) { + Zperr (ret); + com_err("queue", ret, "setting destination"); + } + for (entry = hm_queue; entry; entry = entry->next) { + DPR("notice:\n"); + DPR2("\tz_kind: %d\n", entry->notice.z_kind); + DPR2("\tz_port: %u\n", ntohs(entry->notice.z_port)); + DPR2("\tz_class: %s\n", entry->notice.z_class); + DPR2("\tz_clss_inst: %s\n", entry->notice.z_class_inst); + DPR2("\tz_opcode: %s\n", entry->notice.z_opcode); + DPR2("\tz_sender: %s\n", entry->notice.z_sender); + DPR2("\tz_recip: %s\n", entry->notice.z_recipient); + ret = send_outgoing(&entry->notice); + if (ret != ZERR_NONE) { + Zperr(ret); + com_err("queue", ret, "sending raw notice"); + } + entry->timer = timer_set_rel(rexmit_times[0], queue_timeout, entry); + entry->retries = 0; + } + retransmits_enabled = 1; +} - DPR ("Retransmitting queue to new server...\n"); - if ((ret = ZSetDestAddr(sin)) != ZERR_NONE) { - Zperr (ret); - com_err("queue", ret, "setting destination"); - } - if ((srch = hm_queue.q_forw) != &hm_queue) { - do { - DPR ("notice:\n"); - DPR2 ("\tz_kind: %d\n", srch->q_data->z_notice.z_kind); - DPR2 ("\tz_port: %u\n", - ntohs(srch->q_data->z_notice.z_port)); - DPR2 ("\tz_class: %s\n", srch->q_data->z_notice.z_class); - DPR2 ("\tz_clss_inst: %s\n", - srch->q_data->z_notice.z_class_inst); - DPR2 ("\tz_opcode: %s\n", srch->q_data->z_notice.z_opcode); - DPR2 ("\tz_sender: %s\n", srch->q_data->z_notice.z_sender); - DPR2 ("\tz_recip: %s\n", srch->q_data->z_notice.z_recipient); - if ((ret = send_outgoing(&srch->q_data->z_notice)) - != ZERR_NONE) { - Zperr (ret); - com_err("queue", ret, "sending raw notice"); - } - srch->q_data->timeout = time(0) + rexmit_times[0]; - srch->q_data->retries = 0; - srch = srch->q_forw; - } while (srch != &hm_queue); - timeout_type = NOTICES; - (void)alarm(rexmit_times[0]); - } +/* We lost our server; nuke all of our timers. */ +void disable_queue_retransmits() +{ + Queue *entry; + + for (entry = hm_queue; entry; entry = entry->next) { + if (entry->timer) + timer_reset(entry->timer); + entry->timer = NULL; + } + retransmits_enabled = 0; } #ifdef DEBUG -Code_t dump_queue() +static Code_t dump_queue() { - Qelem *srch; - caddr_t mp; - int ml; - - DPR ("Dumping queue...\n"); - if ((srch = hm_queue.q_forw) == &hm_queue) - printf("Queue is empty.\n"); - else do { - printf("notice:\n"); - printf("\tz_kind: %d\n", srch->q_data->z_notice.z_kind); - printf("\tz_port: %u\n", ntohs(srch->q_data->z_notice.z_port)); - printf("\tz_class: %s\n", srch->q_data->z_notice.z_class); - printf("\tz_clss_inst: %s\n", srch->q_data->z_notice.z_class_inst); - printf("\tz_opcode: %s\n", srch->q_data->z_notice.z_opcode); - printf("\tz_sender: %s\n", srch->q_data->z_notice.z_sender); - printf("\tz_recip: %s\n", srch->q_data->z_notice.z_recipient); - printf("\tMessage:\n"); - mp = srch->q_data->z_notice.z_message; - for (ml = strlen(mp)+1; - ml <= srch->q_data->z_notice.z_message_len; ml++) { - printf("\t%s\n", mp); - mp += strlen(mp)+1; - ml += strlen(mp); - } - srch = srch->q_forw; - } while (srch != &hm_queue); + Queue *entry; + caddr_t mp; + int ml; + + DPR("Dumping queue...\n"); + if (!hm_queue) { + printf("Queue is empty.\n"); + return; + } + + for (entry = hm_queue; entry; entry = entry->next) { + printf("notice:\n"); + printf("\tz_kind: %d\n", entry->notice.z_kind); + printf("\tz_port: %u\n", ntohs(entry->notice.z_port)); + printf("\tz_class: %s\n", entry->notice.z_class); + printf("\tz_clss_inst: %s\n", entry->notice.z_class_inst); + printf("\tz_opcode: %s\n", entry->notice.z_opcode); + printf("\tz_sender: %s\n", entry->notice.z_sender); + printf("\tz_recip: %s\n", entry->notice.z_recipient); + printf("\tMessage:\n"); + mp = entry->notice.z_message; + for (ml = strlen(mp) + 1; ml <= entry->notice.z_message_len; ml++) { + printf("\t%s\n", mp); + mp += strlen(mp)+1; + ml += strlen(mp); + } + } } #endif /* DEBUG */ int queue_len() { - int length = 0; - Qelem *srch; + int length = 0; + Queue *entry; - if ((srch = hm_queue.q_forw) != &hm_queue) { - do { - length++; - srch = srch->q_forw; - } while (srch != &hm_queue); - } - return(length); + for (entry = hm_queue; entry; entry = entry->next) + length++; + return length; } -Qelem *is_in_queue(notice) -ZNotice_t *notice; +static Queue *find_notice_in_queue(notice) + ZNotice_t *notice; { - Qelem *srch; + Queue *entry; - srch = hm_queue.q_forw; - if (srch == &hm_queue) - return(NULL); - do { - if (ZCompareUID(&(srch->q_data->z_notice.z_uid), &(notice->z_uid))) - return(srch); - srch = srch->q_forw; - } while (srch != &hm_queue); - return(NULL); + for (entry = hm_queue; entry; entry = entry->next) { + if (ZCompareUID(&entry->notice.z_uid, ¬ice->z_uid)) + return entry; + } + return NULL; } -void resend_notices(sin) -struct sockaddr_in *sin; +static void queue_timeout(arg) + void *arg; { - Qelem *srch; - Code_t ret; - - DPR ("Resending notices...\n"); - if ((ret = ZSetDestAddr(sin)) != ZERR_NONE) { - Zperr(ret); - com_err("queue", ret, "setting destination"); - } - if ((srch = hm_queue.q_forw) == &hm_queue) { - syslog (LOG_INFO, "No notices, shouldn't have happened!"); - } else do { - if (srch->q_data->timeout <= time((time_t *)0)) { - srch->q_data->retries++; - if (rexmit_times[srch->q_data->retries] == -1) { - new_server((char *)NULL); - break; - } else { - DPR ("notice:\n"); - DPR2 ("\tz_kind: %d\n", srch->q_data->z_notice.z_kind); - DPR2 ("\tz_port: %u\n", - ntohs(srch->q_data->z_notice.z_port)); - DPR2 ("\tz_class: %s\n", - srch->q_data->z_notice.z_class); - DPR2 ("\tz_clss_inst: %s\n", - srch->q_data->z_notice.z_class_inst); - DPR2 ("\tz_opcode: %s\n", - srch->q_data->z_notice.z_opcode); - DPR2 ("\tz_sender: %s\n", - srch->q_data->z_notice.z_sender); - DPR2 ("\tz_recip: %s\n", - srch->q_data->z_notice.z_recipient); - if ((ret = send_outgoing(&srch->q_data->z_notice)) - != ZERR_NONE) { - Zperr(ret); - com_err("queue", ret, "sending raw notice"); - } - srch->q_data->timeout = time((time_t *)0) + - rexmit_times[srch->q_data->retries]; - } - srch = srch->q_forw; - } - } while (srch != &hm_queue); - if (timeout_type == NOTICES) - (void)alarm(rexmit_times[0]); + Queue *entry = (Queue *) arg; + Code_t ret; + + ret = ZSetDestAddr(&serv_sin); + if (ret != ZERR_NONE) { + Zperr(ret); + com_err("queue", ret, "setting destination"); + } + entry->retries++; + if (rexmit_times[entry->retries] == -1) { + new_server(NULL); + return; + } + DPR("Resending notice:\n"); + DPR2("\tz_kind: %d\n", entry->notice.z_kind); + DPR2("\tz_port: %u\n", ntohs(entry->notice.z_port)); + DPR2("\tz_class: %s\n", entry->notice.z_class); + DPR2("\tz_clss_inst: %s\n", entry->notice.z_class_inst); + DPR2("\tz_opcode: %s\n", entry->notice.z_opcode); + DPR2("\tz_sender: %s\n", entry->notice.z_sender); + DPR2("\tz_recip: %s\n", entry->notice.z_recipient); + ret = send_outgoing(&entry->notice); + if (ret != ZERR_NONE) { + Zperr(ret); + com_err("queue", ret, "sending raw notice"); + } + entry->timer = timer_set_rel(rexmit_times[entry->retries], queue_timeout, + entry); } + diff --git a/zhm/timer.c b/zhm/timer.c new file mode 100644 index 0000000..8fb68e5 --- /dev/null +++ b/zhm/timer.c @@ -0,0 +1,257 @@ +/* This file is part of the Project Athena Zephyr Notification System. + * It contains functions for managing multiple timeouts. + * + * Created by: John T. Kohl + * Derived from timer_manager_ by Ken Raeburn + * + * $Source$ + * $Author$ + * + */ + +#include "internal.h" +#include "timer.h" + +#ifndef SABER +#ifndef lint +static const char rcsid[] = +"$Id$"; +#endif /* lint */ +#endif /* SABER */ + +/* + * timer_manager_ -- routines for handling timers in login_shell + * (and elsewhere) + * + * Copyright 1986 Student Information Processing Board, + * Massachusetts Institute of Technology + * + * written by Ken Raeburn + + Permission to use, copy, modify, and distribute this + software and its documentation for any purpose and without + fee is hereby granted, provided that the above copyright + notice appear in all copies and that both that copyright + notice and this permission notice appear in supporting + documentation, and that the name of M.I.T. and the Student + Information Processing Board not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + M.I.T. and the Student Information Processing Board + make no representations about the suitability of + this software for any purpose. It is provided "as is" + without express or implied warranty. + + */ + + +/* + * External functions: + * + * Timer *timer_set_rel (time_rel, proc, arg) + * long time_rel; + * void (*proc)(); + * caddr_t arg; + * Timer *timer_set_abs (time_abs, proc, arg) + * long time_abs; + * void (*proc)(); + * caddr_t arg; + * + * void timer_reset(tmr) + * Timer *tmr; + * + * void timer_process() + * + */ + +/* DELTA is just an offset to keep the size a bit less than a power + * of two. It's measured in pointers, so it's 32 bytes on most + * systems. */ +#define DELTA 8 +#define INITIAL_HEAP_SIZE (1024 - DELTA) + +/* We have three operations which we need to be able to perform + * quickly: adding a timer, deleting a timer given a pointer to + * it, and determining which timer will be the next to go off. A + * heap is an ideal data structure for these purposes, so we use + * one. The heap is an array of pointers to timers, and each timer + * knows the position of its pointer in the heap. + * + * Okay, what is the heap, exactly? It's a data structure, + * represented as an array, with the invariant condition that + * the timeout of heap[i] is less than or equal to the timeout of + * heap[i * 2 + 1] and heap[i * 2 + 2] (assuming i * 2 + 1 and + * i * 2 + 2 are valid * indices). An obvious consequence of this + * is that heap[0] has the lowest timer value, so finding the first + * timer to go off is easy. We say that an index i has "children" + * i * 2 + 1 and i * 2 + 1, and the "parent" (i - 1) / 2. + * + * To add a timer to the heap, we start by adding it to the end, and + * then keep swapping it with its parent until it has a parent with + * a timer value less than its value. With a little bit of thought, + * you can see that this preserves the heap property on all indices + * of the array. + * + * To delete a timer at position i from the heap, we discard it and + * fill in its position with the last timer in the heap. In order + * to restore the heap, we have to consider two cases: the timer + * value at i is less than that of its parent, or the timer value at + * i is greater than that of one of its children. In the first case, + * we propagate the timer at i up the tree, swapping it with its + * parent, until the heap is restored; in the second case, we + * propagate the timer down the tree, swapping it with its least + * child, until the heap is restored. */ + +/* In order to ensure that the back pointers from timers are consistent + * with the heap pointers, all heap assignments should be done with the + * HEAP_ASSIGN() macro, which sets the back pointer and updates the + * heap at the same time. */ +#define PARENT(i) (((i) - 1) / 2) +#define CHILD1(i) ((i) * 2 + 1) +#define CHILD2(i) ((i) * 2 + 2) +#define TIME(i) (heap[i]->abstime) +#define HEAP_ASSIGN(pos, tmr) ((heap[pos] = (tmr))->heap_pos = (pos)) + +static Timer **heap; +static int num_timers = 0; +static int heap_size = 0; + +static void timer_botch __P((void*)); +static Timer *add_timer __P((Timer *)); + +Timer *timer_set_rel(time_rel, proc, arg) + long time_rel; + void (*proc) __P((void *)); + void *arg; +{ + Timer *new_t; + + new_t = (Timer *) malloc(sizeof(*new_t)); + if (new_t == NULL) + return(NULL); + new_t->abstime = time_rel + time(NULL); + new_t->func = proc; + new_t->arg = arg; + return add_timer(new_t); +} + +void +timer_reset(tmr) + Timer *tmr; +{ + int pos, min; + + /* Free the timer, saving its heap position. */ + pos = tmr->heap_pos; + free(tmr); + + if (pos != num_timers - 1) { + /* Replace the timer with the last timer in the heap and + * restore the heap, propagating the timer either up or + * down, depending on which way it violates the heap + * property to insert the last timer in place of the + * deleted timer. */ + if (pos > 0 && TIME(num_timers - 1) < TIME(PARENT(pos))) { + do { + HEAP_ASSIGN(pos, heap[PARENT(pos)]); + pos = PARENT(pos); + } while (pos > 0 && TIME(num_timers - 1) < TIME(PARENT(pos))); + HEAP_ASSIGN(pos, heap[num_timers - 1]); + } else { + while (CHILD2(pos) < num_timers) { + min = num_timers - 1; + if (TIME(CHILD1(pos)) < TIME(min)) + min = CHILD1(pos); + if (TIME(CHILD2(pos)) < TIME(min)) + min = CHILD2(pos); + HEAP_ASSIGN(pos, heap[min]); + pos = min; + } + if (pos != num_timers - 1) + HEAP_ASSIGN(pos, heap[num_timers - 1]); + } + } + num_timers--; +} + + +#define set_timeval(t,s) ((t).tv_sec=(s),(t).tv_usec=0,(t)) + +static Timer * +add_timer(new) + Timer *new; +{ + int pos; + + /* Create or resize the heap as necessary. */ + if (heap_size == 0) { + heap_size = INITIAL_HEAP_SIZE; + heap = (Timer **) malloc(heap_size * sizeof(Timer *)); + } else if (num_timers >= heap_size) { + heap_size = heap_size * 2 + DELTA; + heap = (Timer **) realloc(heap, heap_size * sizeof(Timer *)); + } + if (!heap) { + free(new); + return NULL; + } + + /* Insert the Timer *into the heap. */ + pos = num_timers; + while (pos > 0 && new->abstime < TIME(PARENT(pos))) { + HEAP_ASSIGN(pos, heap[PARENT(pos)]); + pos = PARENT(pos); + } + HEAP_ASSIGN(pos, new); + num_timers++; + + return new; +} + +void +timer_process() +{ + Timer *t; + timer_proc func; + void *arg; + int valid = 0; + + if (num_timers == 0 || heap[0]->abstime > time(NULL)) + return; + + /* Remove the first timer from the heap, remembering its + * function and argument. */ + t = heap[0]; + func = t->func; + arg = t->arg; + t->func = timer_botch; + t->arg = NULL; + timer_reset(t); + + /* Run the function. */ + func(arg); +} + +struct timeval * +timer_timeout(tvbuf) + struct timeval *tvbuf; +{ + if (num_timers > 0) { + tvbuf->tv_sec = heap[0]->abstime - time(NULL); + if (tvbuf->tv_sec < 0) + tvbuf->tv_sec = 0; + tvbuf->tv_usec = 0; + return tvbuf; + } else { + return NULL; + } +} + +static void +timer_botch(arg) + void *arg; +{ + syslog(LOG_CRIT, "timer botch\n"); + abort(); +} + diff --git a/zhm/timer.h b/zhm/timer.h new file mode 100644 index 0000000..42c0081 --- /dev/null +++ b/zhm/timer.h @@ -0,0 +1,56 @@ +/* This file is part of the Project Athena Zephyr Notification System. + * It contains definitions used by timer.c + * + * Created by: John T. Kohl + * Derived from timer_manager_.h by Ken Raeburn + * + * $Source$ + * $Author$ + * $Header$ + * + */ + +#ifndef __TIMER_H + +/* + * timer_manager_ -- routines for handling timers in login_shell + * (and elsewhere) + * + * Copyright 1986 Student Information Processing Board, + * Massachusetts Institute of Technology + * + * written by Ken Raeburn + +Permission to use, copy, modify, and distribute this +software and its documentation for any purpose and without +fee is hereby granted, provided that the above copyright +notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting +documentation, and that the name of M.I.T. and the Student +Information Processing Board not be used in +advertising or publicity pertaining to distribution of the +software without specific, written prior permission. +M.I.T. and the Student Information Processing Board +make no representations about the suitability of +this software for any purpose. It is provided "as is" +without express or implied warranty. + + */ + +typedef void (*timer_proc) __P((void *)); + +typedef struct _Timer { + int heap_pos; /* Position in timer heap */ + long abstime; + timer_proc func; + void *arg; +} Timer; + +Timer *timer_set_rel __P((long, timer_proc, void *)); +Timer *timer_set_abs __P((long, timer_proc, void *)); +void timer_reset __P((Timer *)); +void timer_process __P((void)); +struct timeval *timer_timeout __P((struct timeval *tvbuf)); + +#endif /* __TIMER_H */ + @@ -13,28 +13,9 @@ #include "zhm.h" -static char rcsid_hm_c[] = "$Id$"; +static const char rcsid_hm_c[] = "$Id$"; -#ifdef POSIX -#include <unistd.h> -#include <stdlib.h> -#endif - -#include <ctype.h> -#include <signal.h> -#include <sys/ioctl.h> -#include <sys/file.h> -#include <fcntl.h> -#include <errno.h> -#include <string.h> -/* - * warning: sys/param.h may include sys/types.h which may not be protected from - * multiple inclusions on your system - */ -#include <sys/param.h> - -#ifdef Z_HaveHesiod -#include <hesiod.h> +#ifdef ZEPHYR_USES_HESIOD int use_hesiod = 0; #endif @@ -42,6 +23,12 @@ int use_hesiod = 0; #define srandom srand48 #endif +#ifdef _PATH_VARRUN +#define PIDDIR _PATH_VARRUN +#else +#define PIDDIR "/etc/" +#endif + int hmdebug, rebootflag, errflg, dieflag, inetd, oldpid, nofork; int no_server = 1, nservchang, nserv, nclt; int booting = 1, timeout_type, deactivated = 1; @@ -49,219 +36,220 @@ long starttime; u_short cli_port; struct sockaddr_in cli_sin, serv_sin, from; int numserv; -char **serv_list = (char **)0; +char **serv_list = NULL; char prim_serv[MAXHOSTNAMELEN], cur_serv[MAXHOSTNAMELEN]; char *zcluster; -int sig_type; +int deactivating = 0; +int terminating = 0; struct hostent *hp; char **clust_info; char hostname[MAXHOSTNAMELEN], loopback[4]; -char *PidFile = PIDFILE; - -void choose_server(), init_hm(), detach(), - handle_timeout(), resend_notices(), die_gracefully(); - -#ifdef POSIX -void -#endif - set_sig_type(sig) - int sig; +char PidFile[128]; + +static RETSIGTYPE deactivate __P((void)); +static RETSIGTYPE terminate __P((void)); +static void choose_server __P((void)); +static void init_hm __P((void)); +static void detach __P((void)); +static void send_stats __P((ZNotice_t *, struct sockaddr_in *)); +static char *strsave __P((const char *)); +extern int optind; + +static RETSIGTYPE deactivate() { - sig_type = sig; + deactivating = 1; } -char *strsave(); +static RETSIGTYPE terminate() +{ + terminating = 1; +} main(argc, argv) char *argv[]; { - ZNotice_t notice; - ZPacket_t packet; - Code_t ret; - int opt, pak_len; - extern int optind; - register int i, j = 0; - -#ifdef _AIX - struct sigaction sa; - - sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_FULLDUMP; - sa.sa_handler = SIG_DFL; - sigaction(SIGSEGV, &sa, (struct sigaction *)0); -#endif - - if (gethostname(hostname, MAXHOSTNAMELEN) < 0) { - printf("Can't find my hostname?!\n"); - exit(-1); - } - prim_serv[0] = '\0'; - while ((opt = getopt(argc, argv, "drhin")) != EOF) - switch(opt) { + ZNotice_t notice; + ZPacket_t packet; + Code_t ret; + int opt, pak_len, i, j = 0, fd, count; + fd_set readers; + struct timeval tv; + + sprintf(PidFile, "%szhm.pid", PIDDIR); + + if (gethostname(hostname, MAXHOSTNAMELEN) < 0) { + printf("Can't find my hostname?!\n"); + exit(-1); + } + prim_serv[0] = '\0'; + while ((opt = getopt(argc, argv, "drhin")) != EOF) + switch(opt) { case 'd': - hmdebug++; - break; + hmdebug = 1; + break; case 'h': - /* Die on SIGHUP */ - dieflag++; - break; + /* Die on SIGHUP */ + dieflag = 1; + break; case 'r': - /* Reboot host -- send boot notice -- and exit */ - rebootflag++; - break; + /* Reboot host -- send boot notice -- and exit */ + rebootflag= 1; + break; case 'i': - /* inetd operation: don't do bind ourselves, fd 0 is - already connected to a socket. Implies -h */ - inetd++; - dieflag++; - break; + /* inetd operation: don't do bind ourselves, fd 0 is + already connected to a socket. Implies -h */ + inetd = 1; + dieflag = 1; + break; case 'n': - nofork = 1; - break; + nofork = 1; + break; case '?': default: - errflg++; - break; - } - if (errflg) { - fprintf(stderr, "Usage: %s [-d] [-h] [-r] [-n] [server]\n", argv[0]); - exit(2); - } + errflg++; + break; + } + if (errflg) { + fprintf(stderr, "Usage: %s [-d] [-h] [-r] [-n] [server]\n", argv[0]); + exit(2); + } + + numserv = 0; - numserv = 0; - - /* Override server argument? */ - if (optind < argc) { - if ((hp = gethostbyname(argv[optind++])) == NULL) { - printf("Unknown server name: %s\n", argv[optind-1]); - } else - (void) strcpy(prim_serv, hp->h_name); - - /* argc-optind is the # of other servers on the command line */ - serv_list = (char **)malloc((argc-optind + 2) * sizeof(char *)); - serv_list[numserv++] = prim_serv; - for (; optind < argc; optind++) { - if ((hp = gethostbyname(argv[optind])) == NULL) { - printf("Unknown server name '%s', ignoring\n", argv[optind]); - continue; - } + /* Override server argument? */ + if (optind < argc) { + if ((hp = gethostbyname(argv[optind++])) == NULL) { + printf("Unknown server name: %s\n", argv[optind-1]); + } else + strcpy(prim_serv, hp->h_name); + + /* argc-optind is the # of other servers on the command line */ + serv_list = (char **) malloc((argc - optind + 2) * sizeof(char *)); + serv_list[numserv++] = prim_serv; + for (; optind < argc; optind++) { + if ((hp = gethostbyname(argv[optind])) == NULL) { + printf("Unknown server name '%s', ignoring\n", argv[optind]); + continue; + } serv_list[numserv++] = strsave(hp->h_name); - } - serv_list[numserv] = NULL; - } -#ifdef Z_HaveHesiod - else - use_hesiod = 1; + } + serv_list[numserv] = NULL; + } +#ifdef ZEPHYR_USES_HESIOD + else + use_hesiod = 1; #endif - choose_server(); - if (*prim_serv == '\0') { - printf("No valid primary server found, exiting.\n"); - exit(ZERR_SERVNAK); - } - init_hm(); + choose_server(); + if (*prim_serv == '\0') { + printf("No valid primary server found, exiting.\n"); + exit(ZERR_SERVNAK); + } + init_hm(); - DPR2 ("zephyr server port: %u\n", ntohs(serv_sin.sin_port)); - DPR2 ("zephyr client port: %u\n", ntohs(cli_port)); + DPR2("zephyr server port: %u\n", ntohs(serv_sin.sin_port)); + DPR2("zephyr client port: %u\n", ntohs(cli_port)); - /* Main loop */ - for ever { - DPR ("Waiting for a packet..."); - switch(sig_type) { - case 0: - break; - case SIGHUP: /* A SIGHUP means we are deactivating the ws. */ - sig_type = 0; - if (dieflag) { - die_gracefully(); - } else { - choose_server(); - send_flush_notice(HM_FLUSH); - deactivated = 1; - } - break; - case SIGTERM: - sig_type = 0; - die_gracefully(); - break; - case SIGALRM: - sig_type = 0; - handle_timeout(); - break; - default: - sig_type = 0; - syslog (LOG_WARNING, "Unknown system interrupt."); - break; - } - ret = ZReceivePacket(packet, &pak_len, &from); - if ((ret != ZERR_NONE) && (ret != EINTR)){ - Zperr(ret); - com_err("hm", ret, "receiving notice"); - } else if (ret != EINTR) { - /* Where did it come from? */ - if ((ret = ZParseNotice(packet, pak_len, ¬ice)) - != ZERR_NONE) { - Zperr(ret); - com_err("hm", ret, "parsing notice"); - } else { - DPR ("Got a packet.\n"); - DPR ("notice:\n"); - DPR2("\tz_kind: %d\n", notice.z_kind); - DPR2("\tz_port: %u\n", ntohs(notice.z_port)); - DPR2("\tz_class: %s\n", notice.z_class); - DPR2("\tz_class_inst: %s\n", notice.z_class_inst); - DPR2("\tz_opcode: %s\n", notice.z_opcode); - DPR2("\tz_sender: %s\n", notice.z_sender); - DPR2("\tz_recip: %s\n", notice.z_recipient); - DPR2("\tz_def_format: %s\n", notice.z_default_format); - DPR2("\tz_message: %s\n", notice.z_message); - if (memcmp(loopback, (char *)&from.sin_addr, 4) && - ((notice.z_kind == SERVACK) || - (notice.z_kind == SERVNAK) || - (notice.z_kind == HMCTL))) { - server_manager(¬ice); - } else { - if (!memcmp(loopback, (char *)&from.sin_addr, 4) && - ((notice.z_kind == UNSAFE) || - (notice.z_kind == UNACKED) || - (notice.z_kind == ACKED) || - (notice.z_kind == HMCTL))) { - /* Client program... */ - if (deactivated) { + /* Main loop */ + for ever { + /* Wait for incoming packets or queue timeouts. */ + DPR("Waiting for a packet..."); + fd = ZGetFD(); + FD_ZERO(&readers); + FD_SET(fd, &readers); + count = select(fd + 1, &readers, NULL, NULL, timer_timeout(&tv)); + if (count == -1 && errno != EINTR) { + syslog(LOG_CRIT, "select() failed: %m"); + die_gracefully(); + } + + if (terminating) + die_gracefully(); + + if (deactivating) { + deactivating = 0; + if (dieflag) { + die_gracefully(); + } else { + choose_server(); + send_flush_notice(HM_FLUSH); + deactivated = 1; + } + } + + timer_process(); + + if (count > 0) { + ret = ZReceivePacket(packet, &pak_len, &from); + if ((ret != ZERR_NONE) && (ret != EINTR)){ + Zperr(ret); + com_err("hm", ret, "receiving notice"); + } else if (ret != EINTR) { + /* Where did it come from? */ + if ((ret = ZParseNotice(packet, pak_len, ¬ice)) + != ZERR_NONE) { + Zperr(ret); + com_err("hm", ret, "parsing notice"); + } else { + DPR("Got a packet.\n"); + DPR("notice:\n"); + DPR2("\tz_kind: %d\n", notice.z_kind); + DPR2("\tz_port: %u\n", ntohs(notice.z_port)); + DPR2("\tz_class: %s\n", notice.z_class); + DPR2("\tz_class_inst: %s\n", notice.z_class_inst); + DPR2("\tz_opcode: %s\n", notice.z_opcode); + DPR2("\tz_sender: %s\n", notice.z_sender); + DPR2("\tz_recip: %s\n", notice.z_recipient); + DPR2("\tz_def_format: %s\n", notice.z_default_format); + DPR2("\tz_message: %s\n", notice.z_message); + if (memcmp(loopback, &from.sin_addr, 4) && + ((notice.z_kind == SERVACK) || + (notice.z_kind == SERVNAK) || + (notice.z_kind == HMCTL))) { + server_manager(¬ice); + } else { + if (!memcmp(loopback, &from.sin_addr, 4) && + ((notice.z_kind == UNSAFE) || + (notice.z_kind == UNACKED) || + (notice.z_kind == ACKED) || + (notice.z_kind == HMCTL))) { + /* Client program... */ + if (deactivated) { send_boot_notice(HM_BOOT); deactivated = 0; - } - transmission_tower(¬ice, packet, pak_len); - DPR2 ("Pending = %d\n", ZPending()); - } else { - if (notice.z_kind == STAT) { + } + transmission_tower(¬ice, packet, pak_len); + DPR2("Pending = %d\n", ZPending()); + } else { + if (notice.z_kind == STAT) { send_stats(¬ice, &from); - } else { + } else { syslog(LOG_INFO, "Unknown notice type: %d", notice.z_kind); - } - } - } - } - } - } + } + } + } + } + } + } + } } -void choose_server() +static void choose_server() { int i = 0; -#ifdef Z_HaveHesiod +#ifdef ZEPHYR_USES_HESIOD if (use_hesiod) { /* Free up any previously used resources */ if (prim_serv[0]) i = 1; while (i < numserv) - (void) free(serv_list[i++]); + free(serv_list[i++]); if (serv_list) - (void) free(serv_list); + free(serv_list); numserv = 0; prim_serv[0] = '\0'; @@ -280,7 +268,7 @@ void choose_server() if ((c = strchr(*clust_info, ' ')) == 0) { printf("Hesiod error getting primary server info.\n"); } else - (void)strcpy(prim_serv, c+1); + strcpy(prim_serv, c+1); break; } if (!strncasecmp("ZCLUSTER", *clust_info, 9)) { @@ -291,7 +279,7 @@ void choose_server() } else { if ((zcluster = malloc((unsigned)(strlen(c+1)+1))) != NULL) { - (void)strcpy(zcluster, c+1); + strcpy(zcluster, c+1); } else { printf("Out of memory.\n"); exit(-5); @@ -303,14 +291,14 @@ void choose_server() if (zcluster == NULL) { if ((zcluster = malloc((unsigned)(strlen("zephyr")+1))) != NULL) - (void)strcpy(zcluster, "zephyr"); + strcpy(zcluster, "zephyr"); } while ((serv_list = hes_resolve(zcluster, "sloc")) == (char **)NULL) { syslog(LOG_ERR, "No servers or no hesiod"); /* wait a bit, and try again */ sleep(30); } - clust_info = (char **)malloc(2*sizeof(char *)); + clust_info = (char **) malloc(2 * sizeof(char *)); if (prim_serv[0]) clust_info[numserv++] = prim_serv; for (i = 0; serv_list[i]; i++) @@ -327,85 +315,68 @@ void choose_server() #endif if (!prim_serv[0] && numserv) { - srandom(time((long *) 0)); - (void) strcpy(prim_serv, serv_list[random() % numserv]); + srandom(time(NULL)); + strcpy(prim_serv, serv_list[random() % numserv]); } } -void init_hm() +static void init_hm() { struct servent *sp; Code_t ret; FILE *fp; -#ifdef POSIX +#ifdef _POSIX_VERSION struct sigaction sa; #endif starttime = time((time_t *)0); OPENLOG("hm", LOG_PID, LOG_DAEMON); + ZSetServerState(1); /* Aargh!!! */ if ((ret = ZInitialize()) != ZERR_NONE) { - Zperr(ret); - com_err("hm", ret, "initializing"); - closelog(); - exit(-1); + Zperr(ret); + com_err("hm", ret, "initializing"); + closelog(); + exit(-1); } - (void)ZSetServerState(1); /* Aargh!!! */ init_queue(); if (*prim_serv == '\0') - (void)strcpy(prim_serv, *serv_list); + strcpy(prim_serv, *serv_list); loopback[0] = 127; loopback[1] = 0; loopback[2] = 0; loopback[3] = 1; - /* kill old hm if it exists */ - fp = fopen(PidFile, "r"); - if (fp != NULL) { - (void)fscanf(fp, "%d\n", &oldpid); - while (!kill(oldpid, SIGTERM)) - sleep(1); - syslog(LOG_INFO, "Killed old image."); - (void) fclose(fp); - } - if (inetd) { - (void) ZSetFD(0); /* fd 0 is on the socket, - thanks to inetd */ + ZSetFD(0); /* fd 0 is on the socket, thanks to inetd */ } else { - /* Open client socket, for receiving client and server notices */ - if ((sp = getservbyname(HM_SVCNAME, "udp")) == NULL) { - printf("No %s entry in /etc/services.\n", HM_SVCNAME); - exit(1); - } - cli_port = sp->s_port; + /* Open client socket, for receiving client and server notices */ + sp = getservbyname(HM_SVCNAME, "udp"); + cli_port = (sp) ? sp->s_port : HM_SVC_FALLBACK; - if ((ret = ZOpenPort(&cli_port)) != ZERR_NONE) { - Zperr(ret); - com_err("hm", ret, "opening port"); - exit(ret); - } + if ((ret = ZOpenPort(&cli_port)) != ZERR_NONE) { + Zperr(ret); + com_err("hm", ret, "opening port"); + exit(ret); + } } cli_sin = ZGetDestAddr(); - - /* Open the server socket */ - - if ((sp = getservbyname(SERVER_SVCNAME, "udp")) == NULL) { - printf("No %s entry in /etc/services.\n", SERVER_SVCNAME); - exit(1); - } + sp = getservbyname(SERVER_SVCNAME, "udp"); + memset(&serv_sin, 0, sizeof(struct sockaddr_in)); + serv_sin.sin_port = (sp) ? sp->s_port : SERVER_SVC_FALLBACK; + #ifndef DEBUG if (!inetd && !nofork) - detach(); + detach(); /* Write pid to file */ fp = fopen(PidFile, "w"); if (fp != NULL) { - fprintf(fp, "%d\n", getpid()); - (void) fclose(fp); + fprintf(fp, "%d\n", getpid()); + fclose(fp); } #endif /* DEBUG */ @@ -413,9 +384,6 @@ void init_hm() syslog(LOG_INFO, "Debugging on."); } - (void) memset((char *)&serv_sin, 0, sizeof(struct sockaddr_in)); - serv_sin.sin_port = sp->s_port; - /* Set up communications with server */ /* target is SERVER_SVCNAME port on server machine */ @@ -424,31 +392,30 @@ void init_hm() /* who to talk to */ if ((hp = gethostbyname(prim_serv)) == NULL) { DPR("gethostbyname failed\n"); - find_next_server((char *)NULL); + find_next_server(NULL); } else { - DPR2 ("Server = %s\n", prim_serv); - (void)strcpy(cur_serv, prim_serv); - (void)memcpy((char *)&serv_sin.sin_addr, hp->h_addr, hp->h_length); + DPR2("Server = %s\n", prim_serv); + strcpy(cur_serv, prim_serv); + memcpy(&serv_sin.sin_addr, hp->h_addr, hp->h_length); } send_boot_notice(HM_BOOT); deactivated = 0; -#ifdef POSIX +#ifdef _POSIX_VERSION sigemptyset(&sa.sa_mask); sa.sa_flags = 0; - sa.sa_handler = set_sig_type; + sa.sa_handler = deactivate; sigaction(SIGHUP, &sa, (struct sigaction *)0); - sigaction(SIGALRM, &sa, (struct sigaction *)0); + sa.sa_handler = terminate; sigaction(SIGTERM, &sa, (struct sigaction *)0); #else - (void)signal (SIGHUP, set_sig_type); - (void)signal (SIGALRM, set_sig_type); - (void)signal (SIGTERM, set_sig_type); + signal(SIGHUP, deactivate); + signal(SIGTERM, terminate); #endif } -void detach() +static void detach() { /* detach from terminal and fork. */ register int i, x = ZGetFD(); @@ -459,31 +426,36 @@ void detach() perror("fork"); exit(0); } -#ifdef POSIX +#ifdef _POSIX_VERSION size = sysconf(_SC_OPEN_MAX); #else size = getdtablesize(); #endif for (i = 0; i < size; i++) if (i != x) - (void) close(i); + close(i); - if ((i = open("/dev/tty", O_RDWR, 666)) < 0) + if ((i = open("/dev/tty", O_RDWR, 0666)) < 0) ; /* Can't open tty, but don't flame about it. */ else { #ifdef TIOCNOTTY - (void) ioctl(i, TIOCNOTTY, (caddr_t) 0); + /* Necessary for old non-POSIX systems which automatically assign + * an opened tty as the controlling terminal of a process which + * doesn't already have one. POSIX systems won't include + * <sys/ioctl.h> (see ../h/sysdep.h); if TIOCNOTTY is defined anyway, + * this is unnecessary but won't hurt. */ + ioctl(i, TIOCNOTTY, (caddr_t) 0); #endif - (void) close(i); + close(i); } -#ifdef POSIX - (void) setsid(); +#ifdef _POSIX_VERSION + setsid(); #endif } static char version[BUFSIZ]; -send_stats(notice, sin) +static void send_stats(notice, sin) ZNotice_t *notice; struct sockaddr_in *sin; { @@ -492,7 +464,7 @@ send_stats(notice, sin) char *bfr; char *list[20]; int len, i, nitems = 10; - unsigned int size; + unsigned long size; newnotice = *notice; @@ -502,91 +474,75 @@ send_stats(notice, sin) } newnotice.z_kind = HMACK; - list[0] = (char *)malloc(MAXHOSTNAMELEN); - (void)strcpy(list[0], cur_serv); - list[1] = (char *)malloc(64); - (void)sprintf(list[1], "%d", queue_len()); - list[2] = (char *)malloc(64); - (void)sprintf(list[2], "%d", nclt); - list[3] = (char *)malloc(64); - (void)sprintf(list[3], "%d", nserv); - list[4] = (char *)malloc(64); - (void)sprintf(list[4], "%d", nservchang); - list[5] = (char *)malloc(64); - (void)strcpy(list[5], rcsid_hm_c); - list[6] = (char *)malloc(64); + list[0] = (char *) malloc(MAXHOSTNAMELEN); + strcpy(list[0], cur_serv); + list[1] = (char *) malloc(64); + sprintf(list[1], "%d", queue_len()); + list[2] = (char *) malloc(64); + sprintf(list[2], "%d", nclt); + list[3] = (char *) malloc(64); + sprintf(list[3], "%d", nserv); + list[4] = (char *) malloc(64); + sprintf(list[4], "%d", nservchang); + list[5] = (char *) malloc(64); + strcpy(list[5], rcsid_hm_c); + list[6] = (char *) malloc(64); if (no_server) - (void)sprintf(list[6], "yes"); + sprintf(list[6], "yes"); else - (void)sprintf(list[6], "no"); - list[7] = (char *)malloc(64); - (void)sprintf(list[7], "%ld", time((time_t *)0) - starttime); + sprintf(list[6], "no"); + list[7] = (char *) malloc(64); + sprintf(list[7], "%ld", time((time_t *)0) - starttime); #ifdef adjust_size - size = (unsigned int)sbrk(0); + size = (unsigned long)sbrk(0); adjust_size (size); #else size = -1; #endif list[8] = (char *)malloc(64); - (void)sprintf(list[8], "%ld", size); + sprintf(list[8], "%ld", size); list[9] = (char *)malloc(32); - (void)strcpy(list[9], MACHINE); + strcpy(list[9], MACHINE_TYPE); /* Since ZFormatRaw* won't change the version number on notices, we need to set the version number explicitly. This code is taken from Zinternal.c, function Z_FormatHeader */ if (!*version) - (void) sprintf(version, "%s%d.%d", ZVERSIONHDR, ZVERSIONMAJOR, - ZVERSIONMINOR); + sprintf(version, "%s%d.%d", ZVERSIONHDR, ZVERSIONMAJOR, + ZVERSIONMINOR); newnotice.z_version = version; if ((ret = ZFormatRawNoticeList(&newnotice, list, nitems, &bfr, &len)) != ZERR_NONE) { - syslog(LOG_INFO, "Couldn't format stats packet"); - } else - if ((ret = ZSendPacket(bfr, len, 0)) != ZERR_NONE) { - Zperr(ret); - com_err("hm", ret, "sending stats"); - } + syslog(LOG_INFO, "Couldn't format stats packet"); + } else { + if ((ret = ZSendPacket(bfr, len, 0)) != ZERR_NONE) { + Zperr(ret); + com_err("hm", ret, "sending stats"); + } + } free(bfr); for(i=0;i<nitems;i++) free(list[i]); } -void handle_timeout() -{ - switch(timeout_type) { - case BOOTING: - new_server((char *)NULL); - break; - case NOTICES: - DPR ("Notice timeout\n"); - resend_notices(&serv_sin); - break; - default: - syslog (LOG_ERR, "Unknown timeout type: %d\n", timeout_type); - break; - } -} - void die_gracefully() { syslog(LOG_INFO, "Terminate signal caught..."); send_flush_notice(HM_FLUSH); - (void)unlink(PidFile); + unlink(PidFile); closelog(); exit(0); } -char * -strsave(sp) -char *sp; +static char *strsave(sp) + const char *sp; { register char *ret; if((ret = malloc((unsigned) strlen(sp)+1)) == NULL) { abort(); } - (void) strcpy(ret,sp); + strcpy(ret,sp); return(ret); } @@ -15,14 +15,23 @@ */ #include <zephyr/mit-copyright.h> -#include <zephyr/zephyr.h> -#include <zephyr/zsyslog.h> +#include <internal.h> #include <sys/socket.h> -#include <sys/param.h> -#include <netdb.h> -#ifdef lint -#include <sys/uio.h> /* make lint shut up */ -#endif /* lint */ +#include <sys/time.h> +#include "timer.h" + +/* These macros are for insertion into and deletion from a singly-linked list + * with back pointers to the previous element's next pointer. In order to + * make these macros act like expressions, they use the comma operator for + * sequenced evaluations of assignment, and "a && b" for "evaluate assignment + * b if expression a is true". */ +#define LIST_INSERT(head, elem) \ + ((elem)->next = *(head), \ + (*head) && ((*(head))->prev_p = &(elem)->next), \ + (*head) = (elem), (elem)->prev_p = (head)) +#define LIST_DELETE(elem) \ + (*(elem)->prev_p = (elem)->next, \ + (elem)->next && ((elem)->next->prev_p = (elem)->prev_p)) #ifdef DEBUG #define DPR(a) fprintf(stderr, a); fflush(stderr) @@ -36,76 +45,58 @@ #define ever (;;) -#define SERV_TIMEOUT 20 +#define SERV_TIMEOUT 5 #define BOOTING 1 #define NOTICES 2 -extern Code_t send_outgoing(); -extern void init_queue(), retransmit_queue(); +/* main.c */ +void die_gracefully __P((void)); + +/* zhm_client.c */ +void transmission_tower __P((ZNotice_t *, char *, int)); +Code_t send_outgoing __P((ZNotice_t *)); + +/* queue.c */ +void init_queue __P((void)); +Code_t add_notice_to_queue __P((ZNotice_t *, char *, struct sockaddr_in *, + int)); +Code_t remove_notice_from_queue __P((ZNotice_t *, ZNotice_Kind_t *, + struct sockaddr_in *)); +void retransmit_queue __P((struct sockaddr_in *)); +void disable_queue_retransmits __P((void)); +int queue_len __P((void)); + +struct sockaddr_in serv_sin; extern int rexmit_times[]; #ifdef vax -#define MACHINE "vax" #define use_etext -#define ok #endif /* vax */ #ifdef ibm032 -#define MACHINE "rt" #define adjust_size(size) size -= 0x10000000 -#define ok #endif /* ibm032 */ -#ifdef NeXT -#define MACHINE "NeXT" -#define ok -#endif /* NeXT */ - -#ifdef sun -#ifdef SUN2_ARCH -#define MACHINE "sun2" -#define ok -#endif /* SUN2_ARCH */ - -#ifdef SUN3_ARCH -#define MACHINE "sun3" -#define ok -#endif /* SUN3_ARCH */ - -#if defined (SUN4_ARCH) || defined (sparc) -#define MACHINE "sun4" +#if defined(sun) && (defined (SUN4_ARCH) || defined (sparc)) #define use_etext -#define ok -#endif /* SUN4_ARCH */ - -#ifndef ok -#if defined (m68k) -#define MACHINE "sun (unknown 68k)" -#else -#define MACHINE "sun (unknown)" #endif -#define ok -#endif /* ! ok */ -#endif /* sun */ #ifdef _AIX #ifdef i386 -#define MACHINE "ps2" #define adjust_size(size) size -= 0x400000 #endif #ifdef _IBMR2 -#define MACHINE "IBM RISC/6000" #define adjust_size(size) size -= 0x20000000 #endif -#define ok #endif -#if defined(ultrix) && defined(mips) -#define MACHINE "decmips" +#if (defined(ultrix) || defined(sgi)) && defined(mips) #define adjust_size(size) size -= 0x10000000 -#define ok -#endif /* ultrix && mips */ +#endif /* (ultrix || sgi) && mips */ +#if defined(__alpha) +#define adjust_size(size) size -= 0x140000000 +#endif /* alpha */ #ifdef use_etext extern int etext; @@ -113,9 +104,4 @@ extern int etext; #undef use_etext #endif -#ifndef ok -#define MACHINE "unknown" -#endif -#undef ok - #endif diff --git a/zhm/zhm_client.c b/zhm/zhm_client.c index ec41466..ff7d3ea 100644 --- a/zhm/zhm_client.c +++ b/zhm/zhm_client.c @@ -19,89 +19,84 @@ static char rcsid_hm_client_c[] = "$Header$"; #endif /* SABER */ #endif /* lint */ -extern int no_server, timeout_type, nclt, deactivated; +extern int no_server, nclt, deactivated; extern struct sockaddr_in cli_sin, serv_sin, from; -transmission_tower(notice, packet, pak_len) +void transmission_tower(notice, packet, pak_len) ZNotice_t *notice; - caddr_t packet; + char *packet; int pak_len; { - ZNotice_t gack; - Code_t ret; - struct sockaddr_in gsin; - unsigned int tleft; + ZNotice_t gack; + Code_t ret; + struct sockaddr_in gsin; - nclt++; - if (notice->z_kind == HMCTL) { - if (!strcmp(notice->z_opcode, CLIENT_FLUSH)) { - send_flush_notice(HM_FLUSH); - deactivated = 1; - } - else if (!strcmp(notice->z_opcode, CLIENT_NEW_SERVER)) - new_server((char *)NULL); - else - syslog (LOG_INFO, "Bad control notice from client."); - return; - } else + nclt++; + if (notice->z_kind == HMCTL) { + if (!strcmp(notice->z_opcode, CLIENT_FLUSH)) { + send_flush_notice(HM_FLUSH); + deactivated = 1; + } else if (!strcmp(notice->z_opcode, CLIENT_NEW_SERVER)) { + new_server((char *)NULL); + } else { + syslog (LOG_INFO, "Bad control notice from client."); + } + return; + } else { if (notice->z_kind != UNSAFE) { - gack = *notice; - gack.z_kind = HMACK; - gack.z_message_len = 0; - gack.z_multinotice = ""; - gsin = cli_sin; - gsin.sin_port = from.sin_port; - if (gack.z_port == 0) + gack = *notice; + gack.z_kind = HMACK; + gack.z_message_len = 0; + gack.z_multinotice = ""; + gsin = cli_sin; + gsin.sin_port = from.sin_port; + if (gack.z_port == 0) gack.z_port = from.sin_port; - DPR2 ("Client Port = %u\n", ntohs(gack.z_port)); - notice->z_port = gack.z_port; - if ((ret = ZSetDestAddr(&gsin)) != ZERR_NONE) { - Zperr(ret); - com_err("hm", ret, "setting destination"); - } - /* Bounce ACK to library */ - if ((ret = send_outgoing(&gack)) != ZERR_NONE) { - Zperr(ret); - com_err("hm", ret, "sending raw notice"); - } - } - if (!no_server) { - DPR2 ("Server Port = %u\n", ntohs(serv_sin.sin_port)); - if ((ret = ZSetDestAddr(&serv_sin)) != ZERR_NONE) { - Zperr(ret); - com_err("hm", ret, "setting destination"); + DPR2 ("Client Port = %u\n", ntohs(gack.z_port)); + notice->z_port = gack.z_port; + if ((ret = ZSetDestAddr(&gsin)) != ZERR_NONE) { + Zperr(ret); + com_err("hm", ret, "setting destination"); } - if ((ret = send_outgoing(notice)) != ZERR_NONE) { - Zperr(ret); - com_err("hm", ret, "while sending raw notice"); + /* Bounce ACK to library */ + if ((ret = send_outgoing(&gack)) != ZERR_NONE) { + Zperr(ret); + com_err("hm", ret, "sending raw notice"); } - if (tleft = alarm(0)) - (void)alarm(tleft); - else { - timeout_type = NOTICES; - (void)alarm(rexmit_times[0]); - } - } - (void)add_notice_to_queue(notice, packet, &gsin, pak_len); + } + } + if (!no_server) { + DPR2 ("Server Port = %u\n", ntohs(serv_sin.sin_port)); + if ((ret = ZSetDestAddr(&serv_sin)) != ZERR_NONE) { + Zperr(ret); + com_err("hm", ret, "setting destination"); + } + if ((ret = send_outgoing(notice)) != ZERR_NONE) { + Zperr(ret); + com_err("hm", ret, "while sending raw notice"); + } + } + add_notice_to_queue(notice, packet, &gsin, pak_len); } Code_t send_outgoing(notice) ZNotice_t *notice; { - Code_t retval; - char *packet; - int length; + Code_t retval; + char *packet; + int length; - if (!(packet = (char *) malloc((unsigned)sizeof(ZPacket_t)))) - return(ENOMEM); + if (!(packet = (char *) malloc((unsigned)sizeof(ZPacket_t)))) + return(ENOMEM); - if ((retval = ZFormatSmallRawNotice(notice, packet, &length)) - != ZERR_NONE) { - free(packet); - return(retval); - } - retval = ZSendPacket(packet, length, 0); + if ((retval = ZFormatSmallRawNotice(notice, packet, &length)) + != ZERR_NONE) { free(packet); return(retval); + } + retval = ZSendPacket(packet, length, 0); + free(packet); + return(retval); } + diff --git a/zhm/zhm_server.c b/zhm/zhm_server.c index 8d95788..760d4c7 100644 --- a/zhm/zhm_server.c +++ b/zhm/zhm_server.c @@ -19,6 +19,10 @@ static char rcsid_hm_server_c[] = "$Header$"; #endif /* SABER */ #endif /* lint */ +static void boot_timeout __P((void *)); + +static Timer *boot_timer = NULL; + int serv_loop = 0; extern u_short cli_port; extern struct sockaddr_in serv_sin, from; @@ -59,8 +63,7 @@ char *op; Zperr(ret); com_err("hm", ret, "sending startup notice"); } - timeout_type = BOOTING; - (void)alarm(SERV_TIMEOUT); + boot_timer = timer_set_rel(SERV_TIMEOUT, boot_timeout, NULL); } /* Argument is whether we are detaching or really going down */ @@ -165,121 +168,130 @@ char *sugg_serv; server_manager(notice) ZNotice_t *notice; { - if (memcmp((char *)&serv_sin.sin_addr, (char *)&from.sin_addr, 4) || - (serv_sin.sin_port != from.sin_port)) { - syslog (LOG_INFO, "Bad notice from port %u.", notice->z_port); - } else { - /* This is our server, handle the notice */ - booting = 0; - DPR ("A notice came in from the server.\n"); - nserv++; - switch(notice->z_kind) { - case HMCTL: - hm_control(notice); - break; - case SERVNAK: - case SERVACK: - send_back(notice); - break; - default: - syslog (LOG_INFO, "Bad notice kind!?"); - break; - } - } + if (memcmp((char *)&serv_sin.sin_addr, (char *)&from.sin_addr, 4) || + (serv_sin.sin_port != from.sin_port)) { + syslog (LOG_INFO, "Bad notice from port %u.", notice->z_port); + } else { + /* This is our server, handle the notice */ + if (boot_timer) { + timer_reset(boot_timer); + boot_timer = NULL; + } + DPR ("A notice came in from the server.\n"); + nserv++; + switch(notice->z_kind) { + case HMCTL: + hm_control(notice); + break; + case SERVNAK: + case SERVACK: + send_back(notice); + break; + default: + syslog (LOG_INFO, "Bad notice kind!?"); + break; + } + } } hm_control(notice) ZNotice_t *notice; { - Code_t ret; - struct hostent *hp; - char suggested_server[64]; - unsigned long addr; + Code_t ret; + struct hostent *hp; + char suggested_server[64]; + unsigned long addr; - DPR("Control message!\n"); - if (!strcmp(notice->z_opcode, SERVER_SHUTDOWN)) { - if (notice->z_message_len) { - addr = inet_addr(notice->z_message); - if ((hp = gethostbyaddr((char *)&addr, sizeof(addr), - AF_INET)) != NULL) { - (void)strcpy(suggested_server, hp->h_name); - new_server(suggested_server); - } else - new_server((char *)NULL); - } - else - new_server((char *)NULL); - } else if (!strcmp(notice->z_opcode, SERVER_PING)) { - if (no_server) - (void)alarm(0); - notice->z_kind = HMACK; - if ((ret = ZSetDestAddr(&serv_sin)) != ZERR_NONE) { - Zperr(ret); - com_err("hm", ret, "setting destination"); - } - if ((ret = send_outgoing(notice)) != ZERR_NONE) { - Zperr(ret); - com_err("hm", ret, "sending ACK"); - } - if (no_server) { - no_server = 0; - retransmit_queue(&serv_sin); - } - } else - syslog (LOG_INFO, "Bad control message."); + DPR("Control message!\n"); + if (!strcmp(notice->z_opcode, SERVER_SHUTDOWN)) { + if (notice->z_message_len) { + addr = inet_addr(notice->z_message); + hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET); + if (hp != NULL) { + strcpy(suggested_server, hp->h_name); + new_server(suggested_server); + } else { + new_server(NULL); + } + } else { + new_server((char *)NULL); + } + } else if (!strcmp(notice->z_opcode, SERVER_PING)) { + notice->z_kind = HMACK; + if ((ret = ZSetDestAddr(&serv_sin)) != ZERR_NONE) { + Zperr(ret); + com_err("hm", ret, "setting destination"); + } + if ((ret = send_outgoing(notice)) != ZERR_NONE) { + Zperr(ret); + com_err("hm", ret, "sending ACK"); + } + if (no_server) { + no_server = 0; + retransmit_queue(&serv_sin); + } + } else { + syslog (LOG_INFO, "Bad control message."); + } } send_back(notice) ZNotice_t *notice; { - ZNotice_Kind_t kind; - struct sockaddr_in repl; - Code_t ret; + ZNotice_Kind_t kind; + struct sockaddr_in repl; + Code_t ret; - if (no_server) - (void)alarm(0); - if (!strcmp(notice->z_opcode, HM_BOOT) || - !strcmp(notice->z_opcode, HM_ATTACH)) { - /* ignore message, just an ack from boot, but exit if we - * are rebooting. - */ - if (rebootflag) - die_gracefully(); - } else { - if (remove_notice_from_queue(notice, &kind, - &repl) != ZERR_NONE) { - syslog (LOG_INFO, "Hey! This packet isn't in my queue!"); - } else { - /* check if client wants an ACK, and send it */ - if (kind == ACKED) { - DPR2 ("Client ACK port: %u\n", ntohs(repl.sin_port)); - if ((ret = ZSetDestAddr(&repl)) != ZERR_NONE) { - Zperr(ret); - com_err("hm", ret, "setting destination"); - } - if ((ret = send_outgoing(notice)) != ZERR_NONE) { - Zperr(ret); - com_err("hm", ret, "sending ACK"); - } - } - } - } - if (no_server) { - no_server = 0; - retransmit_queue(&serv_sin); - } + if (!strcmp(notice->z_opcode, HM_BOOT) || + !strcmp(notice->z_opcode, HM_ATTACH)) { + /* ignore message, just an ack from boot, but exit if we + * are rebooting. + */ + if (rebootflag) + die_gracefully(); + } else { + if (remove_notice_from_queue(notice, &kind, &repl) != ZERR_NONE) { + syslog (LOG_INFO, "Hey! This packet isn't in my queue!"); + } else { + /* check if client wants an ACK, and send it */ + if (kind == ACKED) { + DPR2 ("Client ACK port: %u\n", ntohs(repl.sin_port)); + if ((ret = ZSetDestAddr(&repl)) != ZERR_NONE) { + Zperr(ret); + com_err("hm", ret, "setting destination"); + } + if ((ret = send_outgoing(notice)) != ZERR_NONE) { + Zperr(ret); + com_err("hm", ret, "sending ACK"); + } + } + } + } + if (no_server) { + no_server = 0; + retransmit_queue(&serv_sin); + } } new_server(sugg_serv) char *sugg_serv; { - no_server = 1; - syslog (LOG_INFO, "Server went down, finding new server."); - send_flush_notice(HM_DETACH); - find_next_server(sugg_serv); - if (booting) { - send_boot_notice(HM_BOOT); - deactivated = 0; - } else - send_boot_notice(HM_ATTACH); + no_server = 1; + syslog (LOG_INFO, "Server went down, finding new server."); + send_flush_notice(HM_DETACH); + find_next_server(sugg_serv); + if (booting) { + send_boot_notice(HM_BOOT); + deactivated = 0; + } else { + send_boot_notice(HM_ATTACH); + } + disable_queue_retransmits(); } + +static void boot_timeout(arg) +void *arg; +{ + new_server(NULL); +} + diff --git a/zwgc/Dictionary/Imakefile b/zwgc/Dictionary/Imakefile deleted file mode 100644 index 2bae6c7..0000000 --- a/zwgc/Dictionary/Imakefile +++ /dev/null @@ -1,32 +0,0 @@ -/**/# Copyright 1988, 1993 Massachusetts Institute of Technology. -/**/# -/**/# For copying and distribution information, see the file -/**/# "mit-copyright.h". -/**/# -/**/# $Id$ - -OBJS = string_dictionary_aux.o int_dictionary.o string_dictionary.o -SRCS = string_dictionary_aux.c int_dictionary.c string_dictionary.c - -XDEFS = -I../String -I../Memory - -all:: string_dictionary.h dictionary_spec $(OBJS) -depend:: $(SRCS) - -/**/# Automatically generate a spec file from the template include file: -dictionary_spec: dictionary.h - cat dictionary.h | grep "^.\*" | grep -v "^ \*/" | sed 's/.\*//' > dictionary_spec - -/**/# Generate a int dictionary instance: -int_dictionary.c int_dictionary.h: dictionary.c dictionary.h - ../generate_instance . dictionary int - -/**/# Generate a string dictionary instance: -string_dictionary.c string_dictionary.h: dictionary.c dictionary.h - ../generate_instance . dictionary string new_string.h - -clean:: - $(RM) $(OBJS) dictionary_spec int_dictionary.c string_dictionary.c \ - int_dictionary.h string_dictionary.h - -string_dictionary_aux.o: string_dictionary.h diff --git a/zwgc/Imakefile b/zwgc/Imakefile deleted file mode 100644 index 21dca3a..0000000 --- a/zwgc/Imakefile +++ /dev/null @@ -1,117 +0,0 @@ -/**/# Copyright 1988, 1993 Massachusetts Institute of Technology. -/**/# -/**/# For copying and distribution information, see the file -/**/# "mit-copyright.h". -/**/# -/**/# $Id$ - -#ifdef _AIX -TERMCAP = -lcurses -#else -TERMCAP = -ltermcap -#endif - -#ifdef macII -OSLIBS = -lc -lPW -#endif -#ifdef SOLARIS -OSLIBS = -lgen -#endif - -#ifdef __NetBSD__ -OSDEFS=-DPOSIX_REGEXP -#endif - -LIBS = $(ZLIB) $(LIB_X) $(TERMCAP) $(OSLIBS) $(OSLIBS) - -SRCS = port_dictionary.c pointer_dictionary.c ulong_dictionary.c \ - parser.y lexer.c node.c exec.c buffer.c main.c zephyr.c X_driver.c\ - substitute.c port.c xshow.c \ - mux.c eval.c subscriptions.c notice.c xcut.c regexp.c\ - character_class.c text_operations.c file.c error.c variables.c\ - formatter.c X_fonts.c X_gram.c tty_filter.c standard_ports.c\ - xselect.c xmark.c xrevstack.c xerror.c - -OBJS = parser.o lexer.o node.o exec.o buffer.o main.o zephyr.o X_driver.o\ - substitute.o port_dictionary.o port.o xshow.o pointer_dictionary.o\ - mux.o eval.o subscriptions.o notice.o xcut.o regexp.o\ - character_class.o text_operations.o file.o error.o variables.o\ - formatter.o X_fonts.o X_gram.o tty_filter.o standard_ports.o\ - xselect.o xmark.o xrevstack.o xerror.o ulong_dictionary.o \ - $(LIBRARIES) - -LIBRARIES = ./String/new_string.o\ - ./Dictionary/string_dictionary.o\ - ./Dictionary/string_dictionary_aux.o\ - ./Dictionary/int_dictionary.o\ - ./Memory/new_memory.o - -GENSRCS= port_dictionary.c pointer_dictionary.c ulong_dictionary.c - -GENERATED= $(GENSRCS) \ - port_dictionary.h pointer_dictionary.h ulong_dictionary.h \ - char_stack.h string_stack.h xmode_stack.h \ - y.tab.h - -XDEFS = -I./Memory -I./String -I./Dictionary -DREVSTACK \ - -DDEFDESC=\"$(ZLIBDIR)/zwgc.desc\" \ - -DAPPDEFDATABASE=\"$(ZLIBDIR)/zwgc_resources\" \ - -DZWGCPATH=\"$(ATHBINDIR)/zwgc\" \ - -DSGI_DESKS $(OSDEFS) - -SUBDIRS = Memory String Dictionary - -do_subdirs_imakefile($(SUBDIRS)) -foreach_subdirs(clean,$(SUBDIRS)) -foreach_subdirs(all,$(SUBDIRS)) -foreach_subdirs(depend,$(SUBDIRS)) - -zprogram(zwgc,$(LIBS)) -install_man(zwgc.1,zwgc.1) - -install_file(zwgc.desc,$(ZLIBDIR)) -install_file(zwgc_resources,$(ZLIBDIR)) -install_file(zephyr.vars,$(ATHCONFDIR)) - -YFLAGS=-d - -/**/# use implicit yacc rule for the following: -parser.o: parser.y -y.tab.h: parser.o - -/**/# How to generate a port dictionary: -port_dictionary.c port_dictionary.h: Dictionary/dictionary.c Dictionary/dictionary.h - ./generate_instance ./Dictionary dictionary port port.h - -/**/# How to generate a pointer dictionary: -pointer_dictionary.c pointer_dictionary.h: Dictionary/dictionary.c Dictionary/dictionary.h - ./generate_instance ./Dictionary dictionary pointer pointer.h - -/**/# How to generate a ulong dictionary: -ulong_dictionary.c ulong_dictionary.h: Dictionary/dictionary.c Dictionary/dictionary.h - ./generate_instance ./Dictionary dictionary ulong ulong.h - -/**/# How to generate a char stack: -char_stack.h: stack.h - ./generate_instance . stack char - -/**/# How to generate a string stack: -string_stack.h: stack.h - ./generate_instance . stack string - -/**/# How to generate a xmode stack: -xmode_stack.h: stack.h - ./generate_instance . stack xmode - -clean:: - $(RM) $(GENERATED) - -eval.c eval.o: port.h string_stack.h -exec.c exec.o: port.h string_stack.h -lexer.c: y.tab.h -main.c main.o: port.h string_stack.h -port.c port.o: port_dictionary.h -standard_ports.c standard_ports.o: port.h string_stack.h -text_operations.c text_operations.o: char_stack.h -xshow.c xshow.o: pointer_dictionary.h xmode_stack.h -X_driver.c X_driver.o: ulong_dictionary.h diff --git a/zwgc/Makefile.in b/zwgc/Makefile.in new file mode 100644 index 0000000..a7e55cb --- /dev/null +++ b/zwgc/Makefile.in @@ -0,0 +1,140 @@ +SHELL = /bin/sh + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +datadir=@datadir@ +confdir=@confdir@ +sbindir=@sbindir@ +lsbindir=@lsbindir@ + +includedir=${prefix}/include +mandir=${prefix}/man +libdir=${exec_prefix}/lib +bindir=${exec_prefix}/bin + +srcdir=@srcdir@ +top_srcdir=@top_srcdir@ +BUILDTOP=../.. +VPATH=@srcdir@ +CC=@CC@ +YACC=@YACC@ +INSTALL=@INSTALL@ +INSTANTIATE=${srcdir}/instantiate + +DEBUG=-O +CFLAGS=${DEBUG} -DDATADIR=\"${datadir}\" -I${top_srcdir}/h \ + -I${BUILDTOP}/h -I${srcdir} -I. @X_CFLAGS@ @CPPFLAGS@ +YFLAGS=-d +LDFLAGS=${DEBUG} -L${BUILDTOP}/lib/zephyr @ET_LDFLAGS@ @X_LIBS@ @LDFLAGS@ +LIBS=-lzephyr @LIBS@ -lcom_err @X_PRE_LIBS@ @ZWGC_LIBX11@ @X_EXTRA_LIBS@ \ + @TLIB@ @RLIB@ + +OBJS= port_dictionary.o pointer_dictionary.o unsigned_long_dictionary.o \ + string_dictionary.o int_dictionary.o string_dictionary_aux.o \ + parser.o lexer.o node.o exec.o buffer.o main.o zephyr.o X_driver.o \ + substitute.o port.o xshow.o mux.o eval.o subscriptions.o notice.o \ + xcut.o regexp.o character_class.o text_operations.o file.o error.o \ + variables.o formatter.o X_fonts.o X_gram.o tty_filter.o \ + standard_ports.o xselect.o xmark.o xrevstack.o xerror.o \ + new_string.o new_memory.o + +all: zwgc + +zwgc: ${OBJS} ${BUILDTOP}/lib/zephyr/libzephyr.a @ETDEP@ + ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} + +port_dictionary.c port_dictionary.h: dictionary.c dictionary.h + ${INSTANTIATE} ${srcdir} dictionary port port.h + +pointer_dictionary.c pointer_dictionary.h: dictionary.c dictionary.h + ${INSTANTIATE} ${srcdir} dictionary pointer pointer.h + +unsigned_long_dictionary.c unsigned_long_dictionary.h: dictionary.c \ + dictionary.h + ${INSTANTIATE} ${srcdir} dictionary unsigned_long unsigned_long.h + +string_dictionary.c string_dictionary.h: dictionary.c dictionary.h + ${INSTANTIATE} ${srcdir} dictionary string new_string.h + +int_dictionary.c int_dictionary.h: dictionary.c dictionary.h + ${INSTANTIATE} ${srcdir} dictionary int + +char_stack.h: stack.h + ${INSTANTIATE} ${srcdir} stack char + +string_stack.h: stack.h + ${INSTANTIATE} ${srcdir} stack string + +xmode_stack.h: stack.h + ${INSTANTIATE} ${srcdir} stack xmode + +check: + +install: zwgc + ${INSTALL} -m 755 -s zwgc ${DESTDIR}${bindir} + ${INSTALL} -m 644 ${srcdir}/zwgc.1 ${DESTDIR}${mandir}/man1 + ${INSTALL} -m 644 ${srcdir}/zwgc.desc ${DESTDIR}${datadir} + ${INSTALL} -m 644 ${srcdir}/zwgc_resources ${DESTDIR}${datadir} + ${INSTALL} -m 644 zephyr.vars ${DESTDIR}${confdir} + +clean: + rm -f ${OBJS} zwgc port_dictionary.[ch] pointer_dictionary.[ch] + rm -f unsigned_long_dictionary.[ch] string_dictionary.[ch] + rm -f int_dictionary.[ch] char_stack.h string_stack.h xmode_stack.h + +${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h +zephyr.o: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h + +port_dictionary.o: port.h string_stack.h new_string.h new_memory.h +pointer_dictionary.o: pointer.h new_string.h new_memory.h +unsigned_long_dictionary.o: new_string.h new_memory.h +string_dictionary.o: new_string.h new_memory.h +int_dictionary.o: new_string.h new_memory.h +X_driver.o: X_driver.h new_memory.h formatter.h mux.h variables.h error.h +X_driver.o: X_gram.h xselect.h unsigned_long_dictionary.h +X_fonts.o: X_fonts.h new_memory.h new_string.h error.h pointer_dictionary.h +X_fonts.o: zwgc.h +X_gram.o: X_gram.h xmark.h zwgc.h X_driver.h X_fonts.h error.h new_string.h +X_gram.o: xrevstack.h xerror.h xselect.h +browser.o: zwgc.h +buffer.o: new_memory.h buffer.h +character_class.o: character_class.h +display.o: new_memory.h new_string.h variables.h display.h +eval.o: new_memory.h node.h eval.h substitute.h port.h buffer.h regexp.h +eval.o: text_operations.h zwgc.h variables.h +exec.o: new_memory.h exec.h eval.h node.h buffer.h port.h variables.h notice.h +file.o: new_memory.h new_string.h error.h +formatter.o: new_memory.h char_stack.h string_dictionary.h formatter.h +formatter.o: text_operations.h +lexer.o: new_memory.h new_string.h int_dictionary.h lexer.h parser.h y.tab.h +main.o: new_memory.h zwgc.h parser.h node.h exec.h zephyr.h notice.h +main.o: subscriptions.h file.h mux.h port.h variables.h main.h +mux.o: mux.h error.h zwgc.h pointer.h +new_memory.o: new_memory.h int_dictionary.h +new_string.o: new_memory.h +node.o: new_memory.h node.h +notice.o: new_memory.h error.h variables.h notice.h +port.o: new_string.h port_dictionary.h port.h notice.h variables.h +regexp.o: regexp.h +standard_ports.o: new_memory.h port.h variables.h error.h main.h +string_dictionary_aux.o: new_memory.h string_dictionary.h +subscriptions.o: new_memory.h new_string.h int_dictionary.h zwgc.h +subscriptions.o: subscriptions.h error.h file.h main.h +substitute.o: new_memory.h lexer.h substitute.h +text_operations.o: new_memory.h text_operations.h char_stack.h +tty_filter.o: new_memory.h new_string.h string_dictionary_aux.h formatter.h +tty_filter.o: zwgc.h error.h +variables.o: new_memory.h notice.h string_dictionary_aux.h variables.h +xcut.o: new_memory.h new_string.h X_gram.h zwgc.h xselect.h xmark.h error.h +xcut.o: xrevstack.h +xerror.o: mux.h +xmark.o: X_gram.h X_fonts.h xmark.h new_string.h +xrevstack.o: X_gram.h zwgc.h +xselect.o: new_string.h xselect.h +xshow.o: pointer_dictionary.h new_memory.h formatter.h variables.h zwgc.h +xshow.o: X_fonts.h X_gram.h xmode_stack.h +zephyr.o: new_string.h zephyr.h error.h mux.h subscriptions.h variables.h +zephyr.o: pointer.h X_driver.h + +.PHONY: all check install clean + diff --git a/zwgc/Memory/Imakefile b/zwgc/Memory/Imakefile deleted file mode 100644 index 5d01802..0000000 --- a/zwgc/Memory/Imakefile +++ /dev/null @@ -1,19 +0,0 @@ -/**/# Copyright 1988, 1993 Massachusetts Institute of Technology. -/**/# -/**/# For copying and distribution information, see the file -/**/# "mit-copyright.h". -/**/# -/**/# $Id$ - -OBJS = new_memory.o -SRCS = new_memory.c - -all:: memory_spec $(OBJS) - -/**/# Automatically generate a spec file from the template include file: -memory_spec: new_memory.h - cat new_memory.h | grep "^.\*" | grep -v "^ \*/" | sed 's/.\*//' > memory_spec - -clean:: - $(RM) $(OBJS) memory_spec - diff --git a/zwgc/String/Imakefile b/zwgc/String/Imakefile deleted file mode 100644 index e47f681..0000000 --- a/zwgc/String/Imakefile +++ /dev/null @@ -1,22 +0,0 @@ -/**/# Copyright 1988, 1993 Massachusetts Institute of Technology. -/**/# -/**/# For copying and distribution information, see the file -/**/# "mit-copyright.h". -/**/# -/**/# $Id$ - - -OBJS = new_string.o -SRCS = new_string.c - -XDEFS= -I../Memory - -all:: string_spec $(OBJS) - -/**/# Automatically generate a spec file from the template include file: -string_spec: new_string.h - cat new_string.h | grep "^.\*" | grep -v "^ \*/" | sed 's/.\*//' > string_spec - -clean:: - $(RM) $(OBJS) string_spec - diff --git a/zwgc/String/new_string.c.old b/zwgc/String/new_string.c.old deleted file mode 100644 index 5009b06..0000000 --- a/zwgc/String/new_string.c.old +++ /dev/null @@ -1,197 +0,0 @@ -/* This file is part of the Project Athena Zephyr Notification System. - * It is one of the source files comprising zwgc, the Zephyr WindowGram - * client. - * - * Created by: Marc Horowitz <marc@athena.mit.edu> - * - * $Source$ - * $Author$ - * - * Copyright (c) 1989 by the Massachusetts Institute of Technology. - * For copying and distribution information, see the file - * "mit-copyright.h". - */ - -#if (!defined(lint) && !defined(SABER)) -static char rcsid_new_string_c[] = "$Id$"; -#endif - -/* - * string - a module providing operations on C strings. (i.e., char *'s) - * - * Overview: - * - * A string is a standard C string. I.e., a char pointer to a - * null-terminated sequence of characters. 0 is NOT considered a valid - * string! Various operations are available. See the string_spec file - * for details. - * - * Note: This module assumes that malloc NEVER returns 0 for reasonable - * requests. It is the users responsibility to either ensure that - * this happens or supply a version of malloc with error - * handling. - * - * Some strings are mutable. - */ - -#ifdef DEBUG -#define assert(x) if (!(x)) abort() -#else -#define assert(x) -#endif - -#include <ctype.h> -#include "new_memory.h" - -#include <strings.h> - -#define string_Length(s) strlen(s) -typedef char *string; - -/* - * string string_CreateFromData(char *data, int length): - * Requires: data[0], data[1], ..., data[length-1] != 0 - * Effects: Takes the first length characters at data and - * creates a string containing them. The returned string - * is on the heap & must be freed eventually. - * I.e., if passed "foobar" and 3, it would return - * string_Copy("foo"). - */ - -string string__CreateFromData(data, length) - char *data; - int length; -{ - string result; - - assert(length>=0); - - result = (string)malloc(length+1); - assert(result); - - (void) memcpy(result, data, length); - result[length] = 0; - - return(result); -} - -/* - * string string_Copy(string s): - * Effects: Returns a copy of s on the heap. The copy must be - * freed eventually. - */ - -string string__Copy(s) - string s; -{ - int length; - string result; - - assert(s); - - length = string_Length(s)+1; - result = (string)malloc(length); - assert(result); - - (void) memcpy(result, s, length); - return(result); -} - -/* - * string string_Concat(string a, b): - * Effects: Returns a string equal to a concatenated to b. - * The returned string is on the heap and must be - * freed eventually. I.e., given "abc" and "def", - * returns string_Copy("abcdef"). - */ - -string string__Concat(a, b) - string a, b; -{ - string result; - int a_length, b_size, result_size; - - a_length = string_Length(a); - b_size = string_Length(b)+1; - result_size = a_length+b_size; - result = (string)malloc(result_size); - assert(result); - - (void) memcpy(result, a, a_length); - (void) memcpy(result+a_length, b, b_size); - - return(result); -} - -/* - * string string_Concat2(string a, b): - * Modifies: a - * Requires: a is on the heap, b does not point into a. - * Effects: Equivalent to: - * string temp; - * temp = string_Concat(a,b); - * free(a); - * return(temp); - * only faster. I.e., uses realloc instead of malloc+memcpy. - */ - -string string__Concat2(a, b) - string a, b; -{ - int a_length = string_Length(a); - int b_size = string_Length(b)+1; - -#ifdef DEBUG_MEMORY - assert(memory__on_heap_p(a)); -#endif - - a = (string)realloc(a, a_length+b_size); - assert(a); - (void) memcpy(a+a_length, b, b_size); - - return(a); -} - -/* - * string string_Downcase(string s): - * Modifies: s - * Effects: Modifies s by changing every uppercase character in s - * to the corresponding lowercase character. Nothing else - * is changed. I.e., "FoObAr19." is changed to "foobar19.". - * S is returned as a convenience. - */ - -string string_Downcase(s) - string s; -{ - char *ptr; - - for (ptr=s; *ptr; ptr++) { - if (isupper(*ptr)) - *ptr = tolower(*ptr); - } - - return(s); -} - -/* - * string string_Upcase(string s): - * Modifies: s - * Effects: Modifies s by changing every lowercase character in s - * to the corresponding uppercase character. Nothing else - * is changed. I.e., "FoObAr19." is changed to "FOOBAR19.". - * S is returned as a convenience. - */ - -string string_Upcase(s) - string s; -{ - char *ptr; - - for (ptr=s; *ptr; ptr++) { - if (islower(*ptr)) - *ptr = toupper(*ptr); - } - - return(s); -} diff --git a/zwgc/X_driver.c b/zwgc/X_driver.c index 96aa2c1..ba118b7 100644 --- a/zwgc/X_driver.c +++ b/zwgc/X_driver.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_X_driver_c[] = "$Id$"; +static const char rcsid_X_driver_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -24,7 +26,8 @@ static char rcsid_X_driver_c[] = "$Id$"; /* */ /****************************************************************************/ -#include <stdio.h> +#ifndef X_DISPLAY_MISSING + #include "X_driver.h" #include <X11/Xresource.h> #include "new_memory.h" @@ -34,7 +37,7 @@ static char rcsid_X_driver_c[] = "$Id$"; #include "error.h" #include "X_gram.h" #include "xselect.h" -#include "ulong_dictionary.h" +#include "unsigned_long_dictionary.h" char *app_instance; @@ -54,14 +57,6 @@ Display *dpy = NULL; * */ -#ifndef APPDEFDATABASE -#define APPDEFDATABASE "/usr/athena/lib/zephyr/zwgc_resources" -#endif - -/* - * - */ - #ifndef APPNAME #define APPNAME "zwgc" #endif @@ -158,7 +153,7 @@ int get_bool_resource(name, class, default_value) return(result); } -static ulong_dictionary color_dict = NULL; +static unsigned_long_dictionary color_dict = NULL; /* Requires: name points to color name or hex string. name must be free'd * eventually by the caller. @@ -175,14 +170,14 @@ unsigned long x_string_to_color(name,def) char *name; unsigned long def; { - ulong_dictionary_binding *binding; + unsigned_long_dictionary_binding *binding; int exists; XColor xc; if (name == NULL) return(def); - binding = ulong_dictionary_Define(color_dict,name,&exists); + binding = unsigned_long_dictionary_Define(color_dict,name,&exists); if (exists) { return((unsigned long) binding->value); @@ -192,7 +187,7 @@ unsigned long x_string_to_color(name,def) if (XAllocColor(dpy, DefaultColormapOfScreen(DefaultScreenOfDisplay(dpy)), &xc)) { - binding->value = (ulong) xc.pixel; + binding->value = (unsigned long) xc.pixel; return(xc.pixel); } else { ERROR2("Error in XAllocColor on \"%s\": using default color\n", @@ -202,7 +197,7 @@ unsigned long x_string_to_color(name,def) ERROR2("Error in XParseColor on \"%s\": using default color\n", name); } - ulong_dictionary_Delete(color_dict,binding); + unsigned_long_dictionary_Delete(color_dict,binding); return(def); } /*NOTREACHED*/ @@ -248,6 +243,7 @@ int open_display_and_load_resources(pargc, argv) { XrmDatabase temp_db1, temp_db2, temp_db3; char *filename, *res, *xdef; + char dbasename[128]; extern char *getenv(); /* Initialize X resource manager: */ @@ -269,7 +265,8 @@ int open_display_and_load_resources(pargc, argv) return(1); /* Read in our application-specific resources: */ - temp_db1 = XrmGetFileDatabase(APPDEFDATABASE); + sprintf(dbasename, "%s/zwgc_resources", DATADIR); + temp_db1 = XrmGetFileDatabase(dbasename); /* * Get resources from the just opened display: @@ -371,7 +368,7 @@ int X_driver_init(drivername, notfirst, pargc, argv) app_instance=string_Copy(temp?temp+1:argv[0]); - color_dict = ulong_dictionary_Create(37); + color_dict = unsigned_long_dictionary_Create(37); xshowinit(); x_gram_init(dpy); @@ -408,3 +405,6 @@ char *X_driver(text) free_desc(desc); return(NULL); } + +#endif /* X_DISPLAY_MISSING */ + diff --git a/zwgc/X_fonts.c b/zwgc/X_fonts.c index 23b9cc1..51647d8 100644 --- a/zwgc/X_fonts.c +++ b/zwgc/X_fonts.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_X_fonts_c[] = "$Id$"; +static const char rcsid_X_fonts_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -24,7 +26,8 @@ static char rcsid_X_fonts_c[] = "$Id$"; /* */ /****************************************************************************/ -#include <stdio.h> +#ifndef X_DISPLAY_MISSING + #include "X_fonts.h" #include "new_memory.h" #include "new_string.h" @@ -297,3 +300,6 @@ XFontStruct *get_font(dpy,style,substyle,size,face) exit(1); #endif } + +#endif /* X_DISPLAY_MISSING */ + diff --git a/zwgc/X_gram.c b/zwgc/X_gram.c index 79586cd..8b8a5af 100644 --- a/zwgc/X_gram.c +++ b/zwgc/X_gram.c @@ -12,17 +12,20 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_X_gram_c[] = "$Id$"; +static const char rcsid_X_gram_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> +#ifndef X_DISPLAY_MISSING + #include "X_gram.h" #include "xmark.h" #include <X11/Xutil.h> #include <X11/cursorfont.h> -#include <X11/Xatom.h> #include "zwgc.h" #include "X_driver.h" #include "X_fonts.h" @@ -52,10 +55,6 @@ static int border_width = 1; static int cursor_code = XC_sailboat; static int set_transient; static int enable_delete; -#ifdef SGI_DESKS -static int global_4dwm; -static Atom desks_hints, desks_always_global; -#endif static char *title_name,*icon_name; static Cursor cursor; static Window group_leader; /* In order to have transient windows, @@ -144,18 +143,6 @@ void x_gram_init(dpy) set_transient = get_bool_resource("transient", "Transient", 0); enable_delete = get_bool_resource("enableDelete", "EnableDelete", 1); -#ifdef SGI_DESKS - global_4dwm = get_bool_resource("global", "Global", 1); - - if (global_4dwm) - { - desks_hints = XInternAtom(dpy, "_SGI_DESKS_HINTS", False); - - desks_always_global = XInternAtom(dpy, "_SGI_DESKS_ALWAYS_GLOBAL", - False); - } -#endif - temp = get_string_resource("borderWidth", "BorderWidth"); /* <<<>>> */ if (temp && atoi(temp)>=0) @@ -324,13 +311,7 @@ void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize, x_set_icccm_hints(dpy,w,title_name,icon_name,&sizehints,&wmhints,0); } - -#ifdef SGI_DESKS - if (global_4dwm) - (void)XChangeProperty(dpy, w, - desks_hints, XA_ATOM, 32, PropModeAppend, - (char *)&desks_always_global, 1); -#endif + XSaveContext(dpy, w, desc_context, (caddr_t)gram); @@ -501,3 +482,6 @@ void x_gram_expose(dpy,w,gram,event) XDestroyRegion(region); } } + +#endif /* X_DISPLAY_MISSING */ + diff --git a/zwgc/browser.c b/zwgc/browser.c index 5d94644..4fb7dcc 100644 --- a/zwgc/browser.c +++ b/zwgc/browser.c @@ -18,8 +18,7 @@ static char rcsid_browser_c[] = "$Header$"; #include <zephyr/mit-copyright.h> -#include <stdio.h> -#include <sys/types.h> +#include <sysdep.h> #include <sys/socket.h> #include <sys/un.h> #include "zwgc.h" diff --git a/zwgc/buffer.c b/zwgc/buffer.c index adf6803..f6d5db3 100644 --- a/zwgc/buffer.c +++ b/zwgc/buffer.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_buffer_c[] = "$Id$"; +static const char rcsid_buffer_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> diff --git a/zwgc/character_class.c b/zwgc/character_class.c index 2a3f2c6..3a99286 100644 --- a/zwgc/character_class.c +++ b/zwgc/character_class.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_character_class_c[] = "$Id$"; +static const char rcsid_character_class_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> diff --git a/zwgc/Dictionary/dictionary.c b/zwgc/dictionary.c index f9962f3..6474a82 100644 --- a/zwgc/Dictionary/dictionary.c +++ b/zwgc/dictionary.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_dictionary_c[] = "$Id$"; +static const char rcsid_dictionary_c[] = "$Id$"; #endif /* diff --git a/zwgc/Dictionary/dictionary.h b/zwgc/dictionary.h index 3299825..3299825 100644 --- a/zwgc/Dictionary/dictionary.h +++ b/zwgc/dictionary.h diff --git a/zwgc/display.c b/zwgc/display.c index 27ce268..0631326 100644 --- a/zwgc/display.c +++ b/zwgc/display.c @@ -24,7 +24,7 @@ static char rcsid_display_c[] = "$Header$"; /* */ /****************************************************************************/ -#include <stdio.h> +#include <sysdep.h> #include "new_memory.h" #include "new_string.h" #include "variables.h" @@ -34,21 +34,26 @@ static char rcsid_display_c[] = "$Header$"; * driver_table - <<<>>> */ -extern void X_driver(); extern void tty_driver(); extern void plain_driver(); extern void raw_driver(); -extern int X_driver_init(); extern int tty_driver_init(); +#ifndef X_DISPLAY_MISSING +extern int X_driver_init(); +extern void X_driver(); +#endif + static struct driver_info { string driver_name; void (*driver)(); int (*driver_init)(); void (*driver_reset)(); } driver_table[] = { +#ifndef X_DISPLAY_MISSING {"X", X_driver, X_driver_init, X_driver_reset}, +#endif {"tty", tty_driver, tty_driver_init, NULL}, {"plain", plain_driver, NULL, NULL}, {"raw", raw_driver, NULL, NULL}, diff --git a/zwgc/error.c b/zwgc/error.c index f24e97a..2ade086 100644 --- a/zwgc/error.c +++ b/zwgc/error.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_error_c[] = "$Id$"; +static const char rcsid_error_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> diff --git a/zwgc/eval.c b/zwgc/eval.c index 650838b..ab59a61 100644 --- a/zwgc/eval.c +++ b/zwgc/eval.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_eval_c[] = "$Id$"; +static const char rcsid_eval_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -139,6 +141,7 @@ string eval_expr(expr) case SUBSTITUTE_OPCODE: case PROTECT_OPCODE: case VERBATIM_OPCODE: + case STYLESTRIP_OPCODE: case GETENV_OPCODE: case UPCASE_OPCODE: case DOWNCASE_OPCODE: @@ -162,6 +165,9 @@ string eval_expr(expr) case VERBATIM_OPCODE: return(verbatim(first,0)); + case STYLESTRIP_OPCODE: + return(stylestrip(first)); + case GETENV_OPCODE: result = getenv(first); if (!result) diff --git a/zwgc/exec.c b/zwgc/exec.c index 27ff1d5..7fac477 100644 --- a/zwgc/exec.c +++ b/zwgc/exec.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_exec_c[] = "$Id$"; +static const char rcsid_exec_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -34,10 +36,6 @@ static char rcsid_exec_c[] = "$Id$"; #include "variables.h" #include "notice.h" -#if !defined(__STDC__) && !defined(const) -#define const -#endif - static int exec_subtree(), exec_fields(); /****************************************************************************/ @@ -371,6 +369,7 @@ static struct _Opstuff { { exec_noop }, /* substitute */ { exec_noop }, /* protect */ { exec_noop }, /* verbatim */ + { exec_noop }, /* stylestrip */ { exec_noop }, /* getenv */ { exec_noop }, /* upcase */ { exec_noop }, /* downcase */ diff --git a/zwgc/file.c b/zwgc/file.c index 2f048dd..39067cf 100644 --- a/zwgc/file.c +++ b/zwgc/file.c @@ -12,15 +12,14 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_file_c[] = "$Id$"; +static const char rcsid_file_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> -#include <errno.h> -#include <sys/types.h> -#include <stdio.h> #include <pwd.h> #include "new_memory.h" #include "new_string.h" diff --git a/zwgc/formatter.c b/zwgc/formatter.c index 03ee3d0..c74bc7d 100644 --- a/zwgc/formatter.c +++ b/zwgc/formatter.c @@ -12,16 +12,15 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_formatter_c[] = "$Id$"; +static const char rcsid_formatter_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> #include <zephyr/zephyr.h> -#include <stdio.h> -#include <ctype.h> -#include <string.h> #include "new_memory.h" #include "char_stack.h" #include "string_dictionary.h" @@ -375,6 +374,51 @@ string protect(str) return(temp); } +/* str points to a string. return value is another string + which is the original with all styles removed. */ +string stylestrip(str) + string str; +{ + int templen = 0, otherchar; + char *temp = (char *) malloc(string_Length(str) + 1); + char_stack chs; + string ostr = str; + + chs = char_stack_create(); + + while (*str) { + if (*str == '@') { + int len = env_length(str + 1); + if (len != -1) { + otherchar = 0; + if ((len == 4 && !strncasecmp(str + 1, "font", 4)) + || (len == 5 && !strncasecmp(str + 1, "color", 5))) + otherchar = 0x80; + otherchar |= otherside(str[len + 1]); + char_stack_push(chs, otherchar); + str += len + 2; + continue; + } + } + if (!char_stack_empty(chs) && *str == (char_stack_top(chs) & 0x7f)) { + char_stack_pop(chs); + str++; + continue; + } + if (!char_stack_empty(chs) && (char_stack_top(chs) & 0x80)) + str++; + else + temp[templen++] = *str++; + } + temp[templen] = 0; + + while (!char_stack_empty(chs)) + char_stack_pop(chs); + free(ostr); + + return(temp); +} + void free_desc(desc) desctype *desc; { diff --git a/zwgc/generate_instance b/zwgc/instantiate index 0a42621..dae134d 100755 --- a/zwgc/generate_instance +++ b/zwgc/instantiate @@ -12,7 +12,7 @@ # if [ "$1" = "" ]; then - echo "Usage: generate_instance <srcdir> <stack|dictionary> <name> [<include file>]" + echo "Usage: generate_instance <srcdir> <type> <name> [<include file>]" exit 1 fi @@ -21,22 +21,19 @@ type=$2 name=$3 incfile=$4 -if [ ! -f ${source}/${type}.h ]; then - echo "$0: unable to open ${source}/${type}.h" - exit 2 -fi - -case $type in -dictionary) +if [ "$type" != "stack" ]; then if [ ! -f ${source}/${type}.c ]; then echo "$0: unable to open ${source}/${type}.c" exit 2 fi sed "s/TYPE_T/$name/g" ${source}/${type}.c > ${name}_${type}.c - ;; -esac +fi if [ "$incfile" != "" ]; then echo "#include \"$incfile\"" > ${name}_${type}.h fi +if [ ! -f ${source}/${type}.h ]; then + echo "$0: unable to open ${source}/${type}.h" + exit 2 +fi sed "s/TYPE_T/$name/g" ${source}/${type}.h >> ${name}_${type}.h diff --git a/zwgc/lexer.c b/zwgc/lexer.c index 5ee3f81..23276e9 100644 --- a/zwgc/lexer.c +++ b/zwgc/lexer.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_lexer_c[] = "$Id$"; +static const char rcsid_lexer_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -24,7 +26,6 @@ static char rcsid_lexer_c[] = "$Id$"; /* */ /****************************************************************************/ -#include <stdio.h> #include "new_memory.h" #include "new_string.h" #include "int_dictionary.h" @@ -158,6 +159,7 @@ static struct keyword_info keywords[] = { { "rspan", RSPAN }, { "set", SET }, { "show", SHOW }, + { "stylestrip", STYLESTRIP }, { "substitute", SUBSTITUTE }, { "then", THEN }, { "upcase", UPCASE }, diff --git a/zwgc/main.c b/zwgc/main.c index 52be870..1b842cb 100644 --- a/zwgc/main.c +++ b/zwgc/main.c @@ -12,15 +12,16 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_main_c[] = "$Id$"; +static const char rcsid_main_c[] = "$Id$"; #endif +#include <sys/resource.h> #include <zephyr/mit-copyright.h> #include <zephyr/zephyr.h> -#include <stdio.h> -#include <signal.h> #include "new_memory.h" #include "zwgc.h" #include "parser.h" @@ -36,7 +37,7 @@ static char rcsid_main_c[] = "$Id$"; #include "main.h" extern void notice_handler(); -static void setup_signals(), detach(); +static void setup_signals(), detach(), signal_exit(); /* * Global zwgc-wide variables: @@ -46,7 +47,7 @@ static void setup_signals(), detach(); int zwgc_debug = 0; #endif -static char *zwgc_version_string = "0.4.7"; +static char *zwgc_version_string = "1.0"; /* * description_filename_override - <<<>>> @@ -55,6 +56,12 @@ static char *zwgc_version_string = "0.4.7"; static char *description_filename_override = NULL; /* + * progname - <<<>>> export! + */ + +char *progname = NULL; + +/* * subscriptions_filename_override - <<<>>> export! */ @@ -109,10 +116,12 @@ static void fake_startup_packet() static void read_in_description_file() { FILE *input_file; + char defdesc[128]; /* var_clear_all_variables(); <<<>>> */ - input_file = locate_file(description_filename_override, USRDESC, DEFDESC); + sprintf(defdesc, "%s/%s", DATADIR, DEFDESC); + input_file = locate_file(description_filename_override, USRDESC, defdesc); if (input_file) program = parse_file(input_file); else @@ -192,6 +201,8 @@ int main(argc, argv) register char **current; int dofork = 1; + progname = argv[0]; + /* * Process "-f <filename>", "-subfile <filename>", "-nofork", * "-reenter" (which is ignored) and (if DEBUG) "-debug" @@ -309,6 +320,8 @@ void notice_handler(notice) free(class); free(instance); free(recipient); + } else if (!strcasecmp(control_opcode, USER_EXIT)) { + signal_exit(); } else printf("zwgc: unknown control opcode %s.\n", control_opcode); @@ -347,15 +360,11 @@ static void signal_exit() mux_end_loop_p = 1; } -#include <sys/wait.h> -#include <sys/time.h> -#include <sys/resource.h> - /* clean up ALL the waiting children, in case we get hit with multiple SIGCHLD's at once, and don't process in time. */ -static void signal_child() +static RETSIGTYPE signal_child() { -#ifdef POSIX +#ifdef HAVE_WAITPID int status; #else union wait status; @@ -364,7 +373,7 @@ static void signal_child() int pid, old_errno = errno; do { -#ifdef POSIX +#ifdef HAVE_WAITPID pid = waitpid(-1, &status, WNOHANG); #else pid = wait3(&status, WNOHANG, (struct rusage *)0); @@ -376,7 +385,7 @@ static void signal_child() static void setup_signals(dofork) int dofork; { -#ifdef POSIX +#ifdef _POSIX_VERSION struct sigaction sa; sigemptyset(&sa.sa_mask); @@ -433,7 +442,7 @@ static void detach() register int i; /* to try to get SIGHUP on user logout */ -#if defined(POSIX) && !defined(ultrix) +#if defined(_POSIX_VERSION) && !defined(ultrix) (void) setpgid(0, tcgetpgrp(1)); #else (void) setpgrp(0, getpgrp(getppid())); diff --git a/zwgc/main.h b/zwgc/main.h index 73b49eb..0af201e 100644 --- a/zwgc/main.h +++ b/zwgc/main.h @@ -19,6 +19,7 @@ #ifndef main_MODULE #define main_MODULE +extern char *progname; extern char *subscriptions_filename_override; /* @@ -34,10 +35,11 @@ extern void usage(); #define USRDESC ".zwgc.desc" -/* DEFDESC points to where the system default description is stored */ +/* DEFDESC points to a file (relative to the data directory) which has the + * system default description file */ #ifndef DEFDESC -#define DEFDESC "/usr/athena/lib/zephyr/zwgc.desc" +#define DEFDESC "zwgc.desc" #endif #endif @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_mux_c[] = "$Id$"; +static const char rcsid_mux_c[] = "$Id$"; #endif /****************************************************************************/ @@ -22,12 +24,6 @@ static char rcsid_mux_c[] = "$Id$"; /* */ /****************************************************************************/ -#include <sys/types.h> -#include <sys/time.h> -#include <sys/file.h> -#include <fcntl.h> -#include <errno.h> -#include <stdio.h> #include <zephyr/zephyr.h> #include "mux.h" #include "error.h" @@ -201,7 +197,7 @@ static int check_tty() if (tty < 0) return 0; -#if defined(POSIX) || defined(SUNOS) +#if defined(_POSIX_VERSION) result = ( ((pgrp = tcgetpgrp(tty)) < 0) ? 0 : 1 ); #else result = ( (ioctl(tty, TIOCGPGRP, &pgrp) < 0) ? 0 : 1 ); diff --git a/zwgc/Memory/new_memory.c b/zwgc/new_memory.c index 7fb2732..541712a 100644 --- a/zwgc/Memory/new_memory.c +++ b/zwgc/new_memory.c @@ -12,12 +12,14 @@ * "mit-copyright.h". */ -#if !defined(SABER) && (defined(DEBUG) || defined(MEMORY_DEBUG)) +#include <sysdep.h> #if (!defined(lint) && !defined(SABER)) -static char rcsid_new_memory_c[] = "$Id$"; +static const char rcsid_new_memory_c[] = "$Id$"; #endif +#if !defined(SABER) && (defined(DEBUG) || defined(MEMORY_DEBUG)) + /* * memory - module wrapping debugging code around normal malloc/free/etc. * routines. @@ -33,14 +35,6 @@ static char rcsid_new_memory_c[] = "$Id$"; /* * */ -extern char *malloc(); -extern char *realloc(); -char *calloc(); -extern int free(); - -/* - * - */ #ifdef DEBUG #define assert(x) if (!(x)) abort() #else @@ -52,8 +46,6 @@ extern int free(); */ #ifdef DEBUG_MEMORY -#include <stdio.h> - extern void record_request(); char *current_module = 0; int current_line = -1; @@ -165,7 +157,7 @@ void memory__free(ptr) #ifdef DEBUG_MEMORY -#include "../Dictionary/int_dictionary.h" +#include "int_dictionary.h" static int request_off = 0; static int_dictionary requests = 0; diff --git a/zwgc/Memory/new_memory.h b/zwgc/new_memory.h index 5c213b7..5c213b7 100644 --- a/zwgc/Memory/new_memory.h +++ b/zwgc/new_memory.h diff --git a/zwgc/String/new_string.c b/zwgc/new_string.c index aca7746..6c3896b 100644 --- a/zwgc/String/new_string.c +++ b/zwgc/new_string.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_new_string_c[] = "$Id$"; +static const char rcsid_new_string_c[] = "$Id$"; #endif /* @@ -40,11 +42,8 @@ static char rcsid_new_string_c[] = "$Id$"; #define assert(x) #endif -#include <ctype.h> #include "new_memory.h" -#include <string.h> - #define string_Length(s) strlen(s) typedef char *string; diff --git a/zwgc/String/new_string.h b/zwgc/new_string.h index 3b5eae9..3b5eae9 100644 --- a/zwgc/String/new_string.h +++ b/zwgc/new_string.h diff --git a/zwgc/node.c b/zwgc/node.c index ede0187..b44aacf 100644 --- a/zwgc/node.c +++ b/zwgc/node.c @@ -12,13 +12,14 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_node_c[] = "$Id$"; +static const char rcsid_node_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> -#include <stdio.h> #include "new_memory.h" #include "node.h" @@ -267,6 +268,7 @@ static string how_to_print[] = { "substitute(%1)", "protect(%1)", "verbatim(%1)", + "stylestrip(%1)", "getenv(%1)", "upcase(%1)", "downcase(%1)", diff --git a/zwgc/node.h b/zwgc/node.h index 35ac013..c98433d 100644 --- a/zwgc/node.h +++ b/zwgc/node.h @@ -40,52 +40,53 @@ #define SUBSTITUTE_OPCODE 12 #define PROTECT_OPCODE 13 #define VERBATIM_OPCODE 14 -#define GETENV_OPCODE 15 -#define UPCASE_OPCODE 16 -#define DOWNCASE_OPCODE 17 -#define ZVAR_OPCODE 18 -#define GET_OPCODE 19 - -#define LANY_OPCODE 20 -#define RANY_OPCODE 21 -#define LBREAK_OPCODE 22 -#define RBREAK_OPCODE 23 -#define LSPAN_OPCODE 24 -#define RSPAN_OPCODE 25 - -#define LAST_EXPR_OPCODE 25 - -#define NOOP_OPCODE 26 -#define SET_OPCODE 27 -#define FIELDS_OPCODE 28 - -#define PRINT_OPCODE 29 -#define CLEARBUF_OPCODE 30 - -#define APPENDPORT_OPCODE 31 -#define EXECPORT_OPCODE 32 -#define INPUTPORT_OPCODE 33 -#define OUTPUTPORT_OPCODE 34 -#define PUT_OPCODE 35 -#define CLOSEINPUT_OPCODE 36 -#define CLOSEOUTPUT_OPCODE 37 -#define CLOSEPORT_OPCODE 38 - -#define EXEC_OPCODE 39 - -#define IF_STMT_OPCODE 40 -#define CASE_OPCODE 41 -#define WHILE_OPCODE 42 -#define BREAK_OPCODE 43 -#define EXIT_OPCODE 44 - -#define IF_OPCODE 45 -#define ELSEIF_OPCODE 46 -#define ELSE_OPCODE 47 -#define MATCHLIST_OPCODE 48 -#define DEFAULT_OPCODE 49 - -#define NUMBER_OF_OPCODES 50 +#define STYLESTRIP_OPCODE 15 +#define GETENV_OPCODE 16 +#define UPCASE_OPCODE 17 +#define DOWNCASE_OPCODE 18 +#define ZVAR_OPCODE 19 +#define GET_OPCODE 20 + +#define LANY_OPCODE 21 +#define RANY_OPCODE 22 +#define LBREAK_OPCODE 23 +#define RBREAK_OPCODE 24 +#define LSPAN_OPCODE 25 +#define RSPAN_OPCODE 26 + +#define LAST_EXPR_OPCODE 26 + +#define NOOP_OPCODE 27 +#define SET_OPCODE 28 +#define FIELDS_OPCODE 29 + +#define PRINT_OPCODE 30 +#define CLEARBUF_OPCODE 31 + +#define APPENDPORT_OPCODE 32 +#define EXECPORT_OPCODE 33 +#define INPUTPORT_OPCODE 34 +#define OUTPUTPORT_OPCODE 35 +#define PUT_OPCODE 36 +#define CLOSEINPUT_OPCODE 37 +#define CLOSEOUTPUT_OPCODE 38 +#define CLOSEPORT_OPCODE 39 + +#define EXEC_OPCODE 40 + +#define IF_STMT_OPCODE 41 +#define CASE_OPCODE 42 +#define WHILE_OPCODE 43 +#define BREAK_OPCODE 44 +#define EXIT_OPCODE 45 + +#define IF_OPCODE 46 +#define ELSEIF_OPCODE 47 +#define ELSE_OPCODE 48 +#define MATCHLIST_OPCODE 49 +#define DEFAULT_OPCODE 50 + +#define NUMBER_OF_OPCODES 51 typedef struct _Node { int opcode; /* Read-only */ diff --git a/zwgc/notice.c b/zwgc/notice.c index 543f272..4e14946 100644 --- a/zwgc/notice.c +++ b/zwgc/notice.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_notice_c[] = "$Id$"; +static const char rcsid_notice_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -308,7 +310,7 @@ char *decode_notice(notice) * Convert host notice sent from to ascii: */ if (notice->z_sender_addr.s_addr) { - fromhost = gethostbyaddr(&(notice->z_sender_addr), + fromhost = gethostbyaddr((char *) &(notice->z_sender_addr), sizeof(struct in_addr), AF_INET); var_set_variable("fromhost", fromhost ? fromhost->h_name : inet_ntoa(notice->z_sender_addr)); diff --git a/zwgc/parser.y b/zwgc/parser.y index 31d21db..22b8a47 100644 --- a/zwgc/parser.y +++ b/zwgc/parser.y @@ -13,8 +13,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_parser_y[] = "$Id$"; +static const char rcsid_parser_y[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -56,7 +58,7 @@ static Node *the_program; %token ELSE ELSEIF ENDCASE ENDIF ENDWHILE EXEC EXECPORT EXIT %token FIELDS GET GETENV IF INPUTPORT LANY LBREAK LSPAN %token MATCH NOOP NOT OUTPUTPORT PRINT PROTECT VERBATIM PUT RANY RBREAK -%token RSPAN SET SHOW SUBSTITUTE THEN UPCASE WHILE ZVAR +%token RSPAN SET SUBSTITUTE THEN UPCASE WHILE ZVAR STYLESTRIP %type <node> expr varname string %type <node> exprlist comma_exprlist varnamelist @@ -132,6 +134,8 @@ expr : '(' expr ')' { $$ = node_create_unary(ZVAR_OPCODE, $3); } | GET '(' expr ')' { $$ = node_create_unary(GET_OPCODE, $3); } + | STYLESTRIP '(' expr ')' + { $$ = node_create_unary(STYLESTRIP_OPCODE, $3); } | LANY '(' expr ',' expr ')' { $$ = node_create_binary(LANY_OPCODE, $3, $5 ); } diff --git a/zwgc/port.c b/zwgc/port.c index c30bfad..6ed3919 100644 --- a/zwgc/port.c +++ b/zwgc/port.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_port_c[] = "$Id$"; +static const char rcsid_port_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -24,41 +26,12 @@ static char rcsid_port_c[] = "$Id$"; /* */ /****************************************************************************/ -#include <stdio.h> -#include <fcntl.h> #include "new_string.h" #include "port_dictionary.h" #include "port.h" #include "notice.h" #include "variables.h" -/* - * <<<>>> - */ - -#if defined(SUNOS) || defined(vax) -extern int errno, sys_nerr; -extern char *sys_errlist[]; - -string perror_to_string(errno) - int errno; -{ - if (errno>=0 && errno<sys_nerr) - return(sys_errlist[errno]); - - /* <<<>>> */ - return("illegal error number returned in errno!"); -} -#else -#include <errno.h> - -string perror_to_string(errno) - int errno; -{ - return(strerror(errno)); -} -#endif - /****************************************************************************/ /* */ /* Port methods (internal): */ @@ -369,7 +342,7 @@ static string get_file(p, error_p) errno = 0; if (!fgets(buffer, 9999, p->data.file.input_connector)) { if (errno) - *error_p = perror_to_string(errno); + *error_p = strerror(errno); else *error_p = "Attempt to read past end of file"; @@ -393,7 +366,7 @@ static char *put_file(p, text, length) fflush(p->data.file.output_connector); if (errno) - return(perror_to_string(errno)); + return(strerror(errno)); return(NULL); } @@ -408,7 +381,7 @@ static char *close_file_input(p) } if (errno) - return(perror_to_string(errno)); + return(strerror(errno)); return(NULL); } @@ -423,7 +396,7 @@ static char *close_file_output(p) } if (errno) - return(perror_to_string(errno)); + return(strerror(errno)); return(NULL); } @@ -518,7 +491,7 @@ void create_file_append_port(name, filename) out = fopen(filename, "a"); (void) umask(oumask); if (out == NULL) { - var_set_variable("error", perror_to_string(errno)); + var_set_variable("error", strerror(errno)); return; } @@ -534,7 +507,7 @@ void create_file_input_port(name, filename) errno = 0; in = fopen(filename, "r"); if (in == NULL) { - var_set_variable("error", perror_to_string(errno)); + var_set_variable("error", strerror(errno)); return; } @@ -554,7 +527,7 @@ void create_file_output_port(name, filename) out = fopen(filename, "w"); (void) umask(oumask); if (out == NULL) { - var_set_variable("error", perror_to_string(errno)); + var_set_variable("error", strerror(errno)); return; } diff --git a/zwgc/regexp.c b/zwgc/regexp.c index f6f5854..f874e45 100644 --- a/zwgc/regexp.c +++ b/zwgc/regexp.c @@ -12,19 +12,19 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_regexp_c[] = "$Id$"; +static const char rcsid_regexp_c[] = "$Id$"; #endif -#include <stdio.h> -#include "regexp.h" - #ifdef SOLARIS #include <libgen.h> #endif -#ifdef POSIX_REGEXP -#include <sys/types.h> +#include "regexp.h" + +#ifdef HAVE_REGCOMP #include <regex.h> int ed_regexp_match_p(test_string, pattern) @@ -35,13 +35,14 @@ int ed_regexp_match_p(test_string, pattern) int retval; char errbuf[512]; - if (retval = regcomp(&RE, pattern, REG_EXTENDED|REG_NOSUB)) { + retval = regcomp(&RE, pattern, REG_NOSUB); + if (retval != 0) { regerror(retval, &RE, errbuf, sizeof(errbuf)); fprintf(stderr,"%s in regcomp %s\n",errbuf,pattern); return(0); } retval = regexec(&RE, test_string, 0, NULL, 0); - if (retval && retval != REG_NOMATCH) { + if (retval != 0 && retval != REG_NOMATCH) { regerror(retval, &RE, errbuf, sizeof(errbuf)); fprintf(stderr,"%s in regexec %s\n",errbuf,pattern); regfree(&RE); @@ -52,8 +53,8 @@ int ed_regexp_match_p(test_string, pattern) } #else -extern char *re_comp(); -extern int re_exec(); +char *re_comp(); +int re_exec(); int ed_regexp_match_p(test_string, pattern) string test_string; @@ -75,12 +76,11 @@ int ed_regexp_match_p(test_string, pattern) } #endif -/* - * This is for AUX. - * It is a wrapper around the C library regexp functions. - */ +#if !defined(HAVE_RE_COMP) && !defined(HAVE_REGCOMP) -#if defined(_AUX_SOURCE) || defined(SOLARIS) +#ifdef HAVE_LIBGEN_H +#include <libgen.h> +#endif static char *re; diff --git a/zwgc/standard_ports.c b/zwgc/standard_ports.c index 72c6206..d0664dd 100644 --- a/zwgc/standard_ports.c +++ b/zwgc/standard_ports.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_standard_ports_c[] = "$Id$"; +static const char rcsid_standard_ports_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -24,22 +26,20 @@ static char rcsid_standard_ports_c[] = "$Id$"; /* */ /****************************************************************************/ -#include <stdio.h> #include "new_memory.h" #include "port.h" #include "variables.h" #include "error.h" +#include "main.h" #include <zephyr/zephyr.h> -#ifndef ZWGCPATH -#define ZWGCPATH "/usr/etc/zwgc" -#endif - extern string tty_filter(); -extern char *X_driver(); +extern int tty_filter_init(); +#ifndef X_DISPLAY_MISSING +extern char *X_driver(); extern int X_driver_init(); -extern int tty_filter_init(); +#endif extern void usage(); @@ -128,8 +128,12 @@ static struct standard_port_info { char *(*function)(); int setup_arg; } standard_port_info_table[] = { +#ifndef X_DISPLAY_MISSING { "X", DEFAULT_OK, X_driver_init, OUTPUT_PROC, X_driver, 0}, { "tty", DEFAULT_NOTOK, tty_filter_init, OUTPUT_PROC, tty_driver, 0}, +#else +{ "tty", DEFAULT_OK, tty_filter_init, OUTPUT_PROC, tty_driver, 0}, +#endif { "plain", DEFAULT_NOTOK, tty_filter_init, OUTPUT_PROC, plain_driver, 0}, { "stdout", DEFAULT_NOTOK, NULL, OUTPUT_DESC, NULL, 1}, { "stderr", DEFAULT_NOTOK, NULL, OUTPUT_DESC, NULL, 2}, @@ -281,7 +285,7 @@ void init_standard_ports(pargc, argv) if (fallback == -1) /* complain, since indeterminate */ ERROR2( "To receive Zephyrgrams, (type `%s -ttymode').\n", - ZWGCPATH); + progname); exit(1); } } else diff --git a/zwgc/Dictionary/string_dictionary_aux.c b/zwgc/string_dictionary_aux.c index c17c157..b257397 100644 --- a/zwgc/Dictionary/string_dictionary_aux.c +++ b/zwgc/string_dictionary_aux.c @@ -32,6 +32,7 @@ static char rcsid_string_dictionary_aux_c[] = "$Id$"; * in a string_dictionary. */ +#include <sysdep.h> #include "new_memory.h" #include "string_dictionary.h" diff --git a/zwgc/Dictionary/string_dictionary_aux.h b/zwgc/string_dictionary_aux.h index 2098095..2098095 100644 --- a/zwgc/Dictionary/string_dictionary_aux.h +++ b/zwgc/string_dictionary_aux.h diff --git a/zwgc/subscriptions.c b/zwgc/subscriptions.c index ff18c06..c3d8c10 100644 --- a/zwgc/subscriptions.c +++ b/zwgc/subscriptions.c @@ -22,9 +22,8 @@ static char rcsid_subscriptions_c[] = "$Id$"; /* */ /****************************************************************************/ -#include <stdio.h> +#include <sysdep.h> #include <zephyr/zephyr.h> -#include <sys/param.h> #include <netdb.h> #include "new_memory.h" #include "new_string.h" diff --git a/zwgc/substitute.c b/zwgc/substitute.c index 92805d9..03d619e 100644 --- a/zwgc/substitute.c +++ b/zwgc/substitute.c @@ -18,6 +18,7 @@ static char rcsid_substitute_c[] = "$Id$"; #include <zephyr/mit-copyright.h> +#include <sysdep.h> #include "new_memory.h" #include "lexer.h" #include "substitute.h" diff --git a/zwgc/text_operations.c b/zwgc/text_operations.c index 2ebd170..7eba386 100644 --- a/zwgc/text_operations.c +++ b/zwgc/text_operations.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_text_operations_c[] = "$Id$"; +static const char rcsid_text_operations_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> diff --git a/zwgc/tty_filter.c b/zwgc/tty_filter.c index 25221f8..a75f082 100644 --- a/zwgc/tty_filter.c +++ b/zwgc/tty_filter.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_tty_filter_c[] = "$Id$"; +static const char rcsid_tty_filter_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -24,9 +26,6 @@ static char rcsid_tty_filter_c[] = "$Id$"; /* */ /****************************************************************************/ -#include <stdio.h> -#include <ctype.h> -#include <termios.h> #include "new_memory.h" #include "new_string.h" #include "string_dictionary_aux.h" @@ -68,11 +67,14 @@ static char code_buf[10240], *code_buf_pos = code_buf, *code; @u "us"/"ue" termcap entry. */ -#define TD_SET(k,v) (string_dictionary_Define(termcap_dict,(k),&ex)->value = (v)) -#define EAT_PADDING(var) (code = code_buf_pos, tputs(var, 1, tty_outc), *code_buf_pos++ = 0, var = code) +#define TD_SET(k,v) (string_dictionary_Define(termcap_dict, (k), &ex)->value \ + = (v)) +#define EXPAND(k) (code = code_buf_pos, tputs(tmp, 1, tty_outc), \ + *code_buf_pos++ = 0, TD_SET(k, code)) -static int tty_outc(c) -int c; +static int +tty_outc(c) + int c; { *code_buf_pos++ = c; return 0; @@ -90,9 +92,15 @@ char **argv; int ex; string_dictionary_binding *b; int isrealtty = string_Eq(drivername, "tty"); +#ifdef HAVE_TERMIOS_H struct termios tbuf; - ospeed = (tcgetattr(0, &tbuf) == 0) ? cfgetospeed(&tbuf) : 2400; + ospeed = (tcgetattr(STDIN_FILENO, &tbuf) == 0) ? cfgetospeed(&tbuf) : 2400; +#else + struct sgttyb sgttyb; + + ospeed = (ioctl(0, TIOCGETP, &sgttyb) == 0) ? sgttyb.sg_ospeed : 2400; +#endif if (termcap_dict == (string_dictionary) NULL) termcap_dict = string_dictionary_Create(7); @@ -119,46 +127,39 @@ char **argv; /* Step 1: get all of {rv,bold,u,bell,blink} that are available. */ + /* We cheat here, and ignore the padding (if any) specified for + the mode-change strings (it's a real pain to do "right") */ + tmp = tgetstr("pc", &p); PC = (tmp) ? *tmp : 0; if (tmp = tgetstr("md",&p)) { /* bold ? */ - EAT_PADDING(tmp); - TD_SET("B.bold",tmp); + EXPAND("B.bold"); tmp = tgetstr("me",&p); - EAT_PADDING(tmp); - TD_SET("E.bold",tmp); + EXPAND("E.bold"); } if (tmp = tgetstr("mr",&p)) { /* reverse video? */ - EAT_PADDING(tmp); - TD_SET("B.rv",tmp); + EXPAND("B.rw"); tmp = tgetstr("me",&p); - EAT_PADDING(tmp); - TD_SET("E.rv",tmp); + EXPAND("E.rw"); } if (tmp = tgetstr("bl",&p)) { /* Bell ? */ - TD_SET("B.bell",tmp); - TD_SET("E.bell",NULL); + EXPAND("B.bell"); + TD_SET("E.bell", NULL); } if (tmp = tgetstr("mb",&p)) { /* Blink ? */ - EAT_PADDING(tmp); - TD_SET("B.blink",tmp); + EXPAND("B.blink"); tmp = tgetstr("me",&p); - EAT_PADDING(tmp); - TD_SET("E.blink",tmp); + EXPAND("E.blink"); } if (tmp = tgetstr("us",&p)) { /* Underline ? */ - EAT_PADDING(tmp); - TD_SET("B.u",tmp); + EXPAND("B.u"); tmp = tgetstr("ue",&p); - EAT_PADDING(tmp); - TD_SET("E.u", tmp); + EXPAND("E.u"); } if (tmp = tgetstr("so",&p)) { /* Standout ? */ - EAT_PADDING(tmp); - TD_SET("B.so",tmp); + EXPAND("B.so"); tmp = tgetstr("se",&p); - EAT_PADDING(tmp); - TD_SET("E.so", tmp); + EXPAND("E.so"); } } /* Step 2: alias others to the nearest substitute */ @@ -388,6 +389,8 @@ static int calc_max_line_width(info) int right = 0; for (; info; info=info->next) { + if (info->ignore) + continue; switch (info->alignment) { case 'l': left += info->len; @@ -434,11 +437,11 @@ string tty_filter(text, use_fonts) desctype *desc; int number_of_strs; int number_of_lines; - tty_str_info *info; + tty_str_info *info, *info_head; int max_line_width; desc = disp_get_cmds(text_copy, &number_of_strs, &number_of_lines); - info = convert_desc_to_tty_str_info(desc); + info_head = info = convert_desc_to_tty_str_info(desc); free_desc(desc); #ifdef DEBUG @@ -537,7 +540,7 @@ string tty_filter(text, use_fonts) } } - free_info(info); + free_info(info_head); free(text_copy); if (number_of_lines && (result_so_far[string_Length(result_so_far)-1] != '\n')) diff --git a/zwgc/ulong.h b/zwgc/ulong.h deleted file mode 100644 index 95269a5..0000000 --- a/zwgc/ulong.h +++ /dev/null @@ -1,24 +0,0 @@ -/* This file is part of the Project Athena Zephyr Notification System. - * It is one of the source files comprising zwgc, the Zephyr WindowGram - * client. - * - * Created by: Marc Horowitz <marc@athena.mit.edu> - * - * $Source$ - * $Author$ - * $Id$ - * - * Copyright (c) 1989 by the Massachusetts Institute of Technology. - * For copying and distribution information, see the file - * "mit-copyright.h". - */ -#ifndef ulong_MODULE -#define ulong_MODULE - -#include <sys/types.h> - -#if defined(ultrix) || defined(vax) || defined(SUNOS) || defined(__NetBSD__) -typedef unsigned long ulong; -#endif - -#endif diff --git a/zwgc/unsigned_long.h b/zwgc/unsigned_long.h new file mode 100644 index 0000000..a9a74f1 --- /dev/null +++ b/zwgc/unsigned_long.h @@ -0,0 +1,5 @@ +/* $Id$ + * $Source$ + */ + +#define unsigned_long unsigned long diff --git a/zwgc/variables.c b/zwgc/variables.c index 2f9f13c..99b18d0 100644 --- a/zwgc/variables.c +++ b/zwgc/variables.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_variables_c[] = "$Id$"; +static const char rcsid_variables_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -24,8 +26,6 @@ static char rcsid_variables_c[] = "$Id$"; /* */ /****************************************************************************/ -#include <stdio.h> -#include <ctype.h> #include "new_memory.h" #include "notice.h" #include "string_dictionary_aux.h" diff --git a/zwgc/xcut.c b/zwgc/xcut.c index 50893d6..aee164e 100644 --- a/zwgc/xcut.c +++ b/zwgc/xcut.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_xcut_c[] = "$Id$"; +static const char rcsid_xcut_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -24,13 +26,13 @@ static char rcsid_xcut_c[] = "$Id$"; /* */ /****************************************************************************/ +#ifndef X_DISPLAY_MISSING + #include <X11/Xlib.h> #include <X11/Xutil.h> -#include <sys/time.h> #include "new_memory.h" #include "new_string.h" #include "X_gram.h" -#include <stdio.h> #include "zwgc.h" #include "xselect.h" #include "xmark.h" @@ -362,3 +364,6 @@ void xcut(dpy,event,desc_context) XFlush(dpy); } + +#endif + diff --git a/zwgc/xerror.c b/zwgc/xerror.c index 58283a8..d40f986 100644 --- a/zwgc/xerror.c +++ b/zwgc/xerror.c @@ -12,14 +12,17 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_xerror_c[] = "$Id$"; +static const char rcsid_xerror_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> +#ifndef X_DISPLAY_MISSING + #include <X11/Xlib.h> -#include <stdio.h> #include "mux.h" int xerror_happened; @@ -46,3 +49,6 @@ void end_xerror_trap(dpy) XSync(dpy,False); XSetErrorHandler(NULL); } + +#endif + diff --git a/zwgc/xerror.h b/zwgc/xerror.h index 0e17936..c6e801a 100644 --- a/zwgc/xerror.h +++ b/zwgc/xerror.h @@ -16,7 +16,7 @@ #define _XERROR_H_ #if (!defined(lint) && !defined(SABER)) -static char rcsid_xerror_h[] = "$Id$"; +static const char rcsid_xerror_h[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> diff --git a/zwgc/xmark.c b/zwgc/xmark.c index 7b32a80..a6e68f3 100644 --- a/zwgc/xmark.c +++ b/zwgc/xmark.c @@ -18,13 +18,16 @@ static char rcsid_xmark_c[] = "$Id$"; #include <zephyr/mit-copyright.h> +#include <sysdep.h> + +#ifndef X_DISPLAY_MISSING + #include <X11/X.h> #include <X11/Xlib.h> #include "X_gram.h" #include "X_fonts.h" #include "xmark.h" #include "new_string.h" -#include <stdio.h> int markblock[3] = { -1 , -1 , -1 }; int markchar[3] = { -1 , -1 , -1 }; @@ -383,3 +386,6 @@ char *xmarkGetText() return(text_so_far); } + +#endif /* X_DISPLAY_MISSING */ + diff --git a/zwgc/xrevstack.c b/zwgc/xrevstack.c index ae22da7..d594b6e 100644 --- a/zwgc/xrevstack.c +++ b/zwgc/xrevstack.c @@ -12,15 +12,18 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_xrevstack_c[] = "$Id$"; +static const char rcsid_xrevstack_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> -#ifdef REVSTACK +#ifndef X_DISPLAY_MISSING + +#ifndef TRUEREVSTACK #include "X_gram.h" -#include <stdio.h> x_gram *bottom_gram = NULL; x_gram *unlinked = NULL; @@ -260,3 +263,6 @@ x_gram *gram; } #endif /* TRUEREVSTACK */ + +#endif /* X_DISPLAY_MISSING */ + diff --git a/zwgc/xselect.c b/zwgc/xselect.c index 59ed16c..2d12b4b 100644 --- a/zwgc/xselect.c +++ b/zwgc/xselect.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_xselect_c[] = "$Id$"; +static const char rcsid_xselect_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -21,7 +23,8 @@ static char rcsid_xselect_c[] = "$Id$"; /* xselect.c - ICCCM compliant cut-and-paste */ /* also includes some other ICCCMisms, such as the WM_PROTOCOL handling */ -#include <stdio.h> +#ifndef X_DISPLAY_MISSING + #include <X11/Xlib.h> #include <X11/Xproto.h> #include <X11/Xatom.h> @@ -204,3 +207,6 @@ void xselGiveUpOwnership(dpy,w) ownership_end=ownership_start; /* Is this right? what should I use? */ } + +#endif /* X_DISPLAY_MISSING */ + diff --git a/zwgc/xshow.c b/zwgc/xshow.c index 402368d..27a9df1 100644 --- a/zwgc/xshow.c +++ b/zwgc/xshow.c @@ -12,13 +12,16 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_xshow_c[] = "$Id$"; +static const char rcsid_xshow_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> -#include <stdio.h> +#ifndef X_DISPLAY_MISSING + #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xresource.h> @@ -572,3 +575,6 @@ void x_get_input(dpy) xhandleevent(dpy, event.xany.window, &event); } } + +#endif /* X_DISPLAY_MISSING */ + diff --git a/zwgc/zephyr.c b/zwgc/zephyr.c index f8d7389..ded5e01 100644 --- a/zwgc/zephyr.c +++ b/zwgc/zephyr.c @@ -12,8 +12,10 @@ * "mit-copyright.h". */ +#include <sysdep.h> + #if (!defined(lint) && !defined(SABER)) -static char rcsid_zephyr_c[] = "$Id$"; +static const char rcsid_zephyr_c[] = "$Id$"; #endif #include <zephyr/mit-copyright.h> @@ -24,7 +26,6 @@ static char rcsid_zephyr_c[] = "$Id$"; /* */ /****************************************************************************/ -#include <stdio.h> #include <zephyr/zephyr.h> #include <sys/socket.h> #include "new_string.h" @@ -34,6 +35,9 @@ static char rcsid_zephyr_c[] = "$Id$"; #include "subscriptions.h" #include "variables.h" #include "pointer.h" +#ifndef X_DISPLAY_MISSING +#include "X_driver.h" +#endif #ifdef DEBUG extern int zwgc_debug; @@ -42,37 +46,6 @@ extern int zwgc_debug; /* * Internal Routine: * - * char *parse_exposure_level(string text) - * Effects: Compares text to each of the standard zephyr - * exposure levels ignoring case. If it matches, - * returns the corresponding magic constant for - * use with ZSetLocation. (i.e., returns EXPOSE_OPSTAFF - * for "opstaff", etc.) If it does not match, returns - * NULL. - */ - -static char *parse_exposure_level(text) - string text; -{ - if (!strcasecmp(text, EXPOSE_NONE)) - return (EXPOSE_NONE); - else if (!strcasecmp(text, EXPOSE_OPSTAFF)) - return (EXPOSE_OPSTAFF); - else if (!strcasecmp(text, EXPOSE_REALMVIS)) - return (EXPOSE_REALMVIS); - else if (!strcasecmp(text, EXPOSE_REALMANN)) - return (EXPOSE_REALMANN); - else if (!strcasecmp(text, EXPOSE_NETVIS)) - return (EXPOSE_NETVIS); - else if (!strcasecmp(text, EXPOSE_NETANN)) - return (EXPOSE_NETANN); - else - return(NULL); -} - -/* - * Internal Routine: - * * string get_zwgc_port_number_filename() * Effects: Returns the filename that the zwgc port # is/should be * stored in, based on the user's uid & the environment @@ -136,6 +109,7 @@ void zephyr_init(notice_handler) unsigned short port = 0; /* Use any old port */ char *temp; char *exposure; + char *tty = NULL; FILE *port_file; /* @@ -150,7 +124,14 @@ void zephyr_init(notice_handler) */ temp = get_zwgc_port_number_filename(); errno = 0; - port_file = fopen(temp, "w+"); + port_file = fopen(temp, "r"); + if (port_file) { + fprintf(stderr, "zwgc: windowgram file already exists. If you are\n"); + fprintf(stderr, "zwgc: not already running zwgc, delete %s\n", temp); + fprintf(stderr, "zwgc: and try again.\n"); + exit(1); + } + port_file = fopen(temp, "w"); if (port_file) { fprintf(port_file, "%d\n", port); fclose(port_file); @@ -159,6 +140,15 @@ void zephyr_init(notice_handler) perror(""); } + /* Set hostname and tty for locations. If we support X, use the + * display string for the tty name. */ +#ifndef X_DISPLAY_MISSING + if (dpy) + tty = DisplayString(dpy); +#endif + error_code = ZInitLocationInfo(NULL, tty); + TRAP( error_code, "while initializing location information" ); + /* * Retrieve the user's desired exposure level (from the zephyr variable * "exposure"), convert it to the proper internal form then @@ -167,7 +157,7 @@ void zephyr_init(notice_handler) * EXPOSE_NONE. */ if (temp = ZGetVariable("exposure")) { - if (!(exposure = parse_exposure_level(temp))) { + if (!(exposure = ZParseExposureLevel(temp))) { ERROR2("invalid exposure level %s, using exposure level none instead.\n", temp); exposure = EXPOSE_NONE; } diff --git a/zwgc/zephyr.vars b/zwgc/zephyr.vars.in index 75a0a72..c1a7fb9 100644 --- a/zwgc/zephyr.vars +++ b/zwgc/zephyr.vars.in @@ -20,4 +20,4 @@ exposure = realm-visible # Initialization programs. -initprogs = /etc/athena/zinit +initprogs = @INITPROGS@ diff --git a/zwgc/zwgc.1 b/zwgc/zwgc.1 index 233694e..379b13f 100644 --- a/zwgc/zwgc.1 +++ b/zwgc/zwgc.1 @@ -17,6 +17,14 @@ .el \\*(]X\h@|\\n()Iu+\\n()Ru@\c .}f .. +.de }N +.if \\n()E .br +.di +.if "\\n()E"0" .}f +.if "\\n()E"1" .}1 +.if "\\n()E"2" .}2 +.nr )E 0 +.. ' # tagged paragraph (paragraph with hanging label, but no para spacing) .de TQ .if !"\\$1"" .nr )I \\$1n @@ -314,6 +322,9 @@ Returns the value of \fIexpr\fR, converted to upper case. Returns a string that will be displayed exactly as \fIexpr\fR looks. Anything which could be mistaken for an environment is quoted. .TP +.BI stylestrip (expr) +Returns \fIexpr\fR with all environments stripped out. +.TP .BI zvar (expr) Returns the value of the zephyr variable \fIexpr\fR, or the empty @@ -333,7 +344,7 @@ String concatenation of .IB expr1 " == " expr2 True if the two expressions are equal, false otherwise. .TP -.IB expr " =~ " expr2 +.IB expr1 " =~ " expr2 True if the regular expression pattern .IR expr2 " matches " expr1. .TP @@ -821,15 +832,6 @@ WM_DELETE_WINDOW as contents. EnableDelete Secondary value to enable WM_DELETE_WINDOW protocol on zgrams [default False] .TP -global -(logical) If true, zwgc creates a _SGI_DESKS_HINTS property on all zgrams, with -_SGI_DESKS_ALWAYS_GLOBAL as contents. This results in zgrams appearing -on all desks in SGI's 4Dwm window manager. Otherwise, zgrams appear and -remain on whatever desk is in use at the time. -.TP -Global -Secondary value to set _SGI_DESKS_HINTS property on zgrams [default True] -.TP minTimeToLive Primary value which specifies the minimum amount of time (``minimum time to live'') a WindowGram must be on-screen (in milliseconds) until it can @@ -1000,7 +1002,14 @@ For an example of X resources, see The X selection code can highlight the wrong portions of messages containing formatted text placed with the @center() or @right() directives. - +.PP +If you are using Kerberos support and get new tickets (using +``kinit''), you must send a subscription notice to the server (using a +command such as ``zctl load /dev/null'') or all received Zephyr +notices will appear to be unauthentic. (If all received Zephyr +notices appear to be forged, your tickets have probably expired, in +which case you must get new tickets and then run ``zctl load +/dev/null''.) .SH FILES .TQ 15 $HOME/.zwgc.desc diff --git a/zwgc/zwgc.desc b/zwgc/zwgc.desc index 01a2e62..796eaf0 100644 --- a/zwgc/zwgc.desc +++ b/zwgc/zwgc.desc @@ -87,14 +87,18 @@ match "WG_CTL_CLASS" # put # exit match "message" - case $instance - match "PERSONAL" - set type = "Personal" - match "URGENT" - set type = "Urgent" - default + if (downcase($recipient) == downcase($user)) then + case $instance + match "PERSONAL" + set type = "Personal" + match "URGENT" + set type = "Urgent" + default + set type = $instance + endcase + else set type = "Instance "+$instance - endcase + endif fields signature body if ($body == "") then |