]> asedeno.scripts.mit.edu Git - 1ts-debian.git/commitdiff
undo merge disaster
authorkcr <kcr@cbed1d16-5ef5-0310-b6a1-d4a37b08ba1f>
Sat, 28 Feb 2009 23:30:45 +0000 (23:30 +0000)
committerkcr <kcr@cbed1d16-5ef5-0310-b6a1-d4a37b08ba1f>
Sat, 28 Feb 2009 23:30:45 +0000 (23:30 +0000)
git-svn-id: svn://svn.1ts.org/debian/trunk@404 cbed1d16-5ef5-0310-b6a1-d4a37b08ba1f

205 files changed:
zephyr/acconfig.h
zephyr/clients/Makefile.in
zephyr/clients/xzwrite/GetString.c [new file with mode: 0644]
zephyr/clients/xzwrite/GetString.h [new file with mode: 0644]
zephyr/clients/xzwrite/Makefile.in [new file with mode: 0644]
zephyr/clients/xzwrite/Popup.c [new file with mode: 0644]
zephyr/clients/xzwrite/XZwrite.in [new file with mode: 0644]
zephyr/clients/xzwrite/associate.c [new file with mode: 0644]
zephyr/clients/xzwrite/associate.h [new file with mode: 0644]
zephyr/clients/xzwrite/bfgets.c [new file with mode: 0644]
zephyr/clients/xzwrite/dest_window.c [new file with mode: 0644]
zephyr/clients/xzwrite/destlist.c [new file with mode: 0644]
zephyr/clients/xzwrite/edit_window.c [new file with mode: 0644]
zephyr/clients/xzwrite/gethomedir.c [new file with mode: 0644]
zephyr/clients/xzwrite/interface.c [new file with mode: 0644]
zephyr/clients/xzwrite/logins.c [new file with mode: 0644]
zephyr/clients/xzwrite/menu_window.c [new file with mode: 0644]
zephyr/clients/xzwrite/resource.c [new file with mode: 0644]
zephyr/clients/xzwrite/util.c [new file with mode: 0644]
zephyr/clients/xzwrite/xzwrite-proto.h [new file with mode: 0644]
zephyr/clients/xzwrite/xzwrite.1 [new file with mode: 0644]
zephyr/clients/xzwrite/xzwrite.bitmap [new file with mode: 0644]
zephyr/clients/xzwrite/xzwrite.c [new file with mode: 0644]
zephyr/clients/xzwrite/xzwrite.h [new file with mode: 0644]
zephyr/clients/xzwrite/yank.c [new file with mode: 0644]
zephyr/clients/xzwrite/zephyr.c [new file with mode: 0644]
zephyr/clients/zaway/zaway.c
zephyr/clients/zctl/zctl.c
zephyr/clients/zleave/zleave.c
zephyr/clients/zlocate/zlocate.c
zephyr/clients/zmailnotify/Makefile.in [new file with mode: 0644]
zephyr/clients/zmailnotify/zmailnotify.1 [new file with mode: 0644]
zephyr/clients/zmailnotify/zmailnotify.c [new file with mode: 0644]
zephyr/clients/znol/znol.c
zephyr/clients/zpopnotify/Makefile.in [new file with mode: 0644]
zephyr/clients/zpopnotify/zpopnotify.8 [new file with mode: 0644]
zephyr/clients/zpopnotify/zpopnotify.c [new file with mode: 0644]
zephyr/clients/zshutdown_notify/zshutdown_notify.c
zephyr/clients/zstat/zstat.c
zephyr/clients/zwrite/zwrite.c
zephyr/configure
zephyr/configure.in
zephyr/debian/changelog
zephyr/debian/control
zephyr/debian/rules
zephyr/debian/zephyr-clients.config
zephyr/debian/zephyr-clients.postinst
zephyr/debian/zephyr-server.config
zephyr/debian/zephyr-server.postinst
zephyr/h/config.h.in
zephyr/h/internal.h
zephyr/h/sysdep.h
zephyr/h/zephyr/zephyr.h
zephyr/h/zephyr/zephyr_err.h [new file with mode: 0644]
zephyr/lib/Makefile.in
zephyr/lib/ZAsyncLocate.c
zephyr/lib/ZCkAuth.c
zephyr/lib/ZCkIfNot.c
zephyr/lib/ZCkZAut.c [deleted file]
zephyr/lib/ZClosePort.c
zephyr/lib/ZCmpUID.c
zephyr/lib/ZCmpUIDP.c
zephyr/lib/ZFlsLocs.c
zephyr/lib/ZFlsSubs.c
zephyr/lib/ZFmtAuth.c
zephyr/lib/ZFmtList.c
zephyr/lib/ZFmtNotice.c
zephyr/lib/ZFmtRaw.c
zephyr/lib/ZFmtRawLst.c
zephyr/lib/ZFmtSmRLst.c
zephyr/lib/ZFmtSmRaw.c
zephyr/lib/ZFreeNot.c
zephyr/lib/ZGetLocs.c
zephyr/lib/ZGetSender.c
zephyr/lib/ZGetSubs.c
zephyr/lib/ZGetWGPort.c
zephyr/lib/ZIfNotice.c
zephyr/lib/ZInit.c
zephyr/lib/ZLocations.c
zephyr/lib/ZMakeAscii.c
zephyr/lib/ZMakeZcode.c [deleted file]
zephyr/lib/ZMkAuth.c
zephyr/lib/ZNewLocU.c
zephyr/lib/ZOpenPort.c
zephyr/lib/ZParseNot.c
zephyr/lib/ZPeekIfNot.c
zephyr/lib/ZPeekNot.c
zephyr/lib/ZPeekPkt.c
zephyr/lib/ZPending.c
zephyr/lib/ZReadAscii.c
zephyr/lib/ZReadZcode.c [deleted file]
zephyr/lib/ZRecvNot.c
zephyr/lib/ZRecvPkt.c
zephyr/lib/ZRetSubs.c
zephyr/lib/ZSendList.c
zephyr/lib/ZSendNot.c
zephyr/lib/ZSendPkt.c
zephyr/lib/ZSendRLst.c
zephyr/lib/ZSendRaw.c
zephyr/lib/ZSetDest.c
zephyr/lib/ZSetFD.c
zephyr/lib/ZSetSrv.c
zephyr/lib/ZSubs.c
zephyr/lib/ZVariables.c
zephyr/lib/ZWait4Not.c
zephyr/lib/ZhmStat.c
zephyr/lib/Zinternal.c
zephyr/libdyn/dyn_append.c
zephyr/libdyn/dyn_create.c
zephyr/libdyn/dyn_debug.c
zephyr/libdyn/dyn_delete.c
zephyr/libdyn/dyn_insert.c
zephyr/libdyn/dyn_paranoid.c
zephyr/libdyn/dyn_put.c
zephyr/libdyn/dyn_realloc.c
zephyr/libdyn/dyn_size.c
zephyr/libdyn/dyntest.c
zephyr/server/access.c
zephyr/server/acl_files.c
zephyr/server/bdump.c
zephyr/server/class.c
zephyr/server/client.c
zephyr/server/common.c
zephyr/server/dispatch.c
zephyr/server/kstuff.c
zephyr/server/main.c
zephyr/server/realm.c
zephyr/server/server.c
zephyr/server/subscr.c
zephyr/server/timer.c
zephyr/server/uloc.c
zephyr/server/version.c
zephyr/server/zserver.h
zephyr/server/zsrv_conf.h
zephyr/server/zsrv_err.et
zephyr/server/zstring.c
zephyr/zhm/queue.c
zephyr/zhm/timer.c
zephyr/zhm/zhm.c
zephyr/zhm/zhm.h
zephyr/zhm/zhm_client.c
zephyr/zhm/zhm_server.c
zephyr/zwgc/Makefile.in
zephyr/zwgc/X_driver.c
zephyr/zwgc/X_driver.h
zephyr/zwgc/X_fonts.c
zephyr/zwgc/X_fonts.h
zephyr/zwgc/X_gram.c
zephyr/zwgc/X_gram.h
zephyr/zwgc/buffer.c
zephyr/zwgc/buffer.h
zephyr/zwgc/character_class.c
zephyr/zwgc/character_class.h
zephyr/zwgc/dictionary.c
zephyr/zwgc/dictionary.h
zephyr/zwgc/eval.c
zephyr/zwgc/eval.h
zephyr/zwgc/exec.c
zephyr/zwgc/exec.h
zephyr/zwgc/file.c
zephyr/zwgc/file.h
zephyr/zwgc/formatter.c
zephyr/zwgc/formatter.h
zephyr/zwgc/lexer.c
zephyr/zwgc/lexer.h
zephyr/zwgc/main.c
zephyr/zwgc/main.h
zephyr/zwgc/mux.c
zephyr/zwgc/mux.h
zephyr/zwgc/new_string.c
zephyr/zwgc/new_string.h
zephyr/zwgc/node.c
zephyr/zwgc/node.h
zephyr/zwgc/notice.c
zephyr/zwgc/notice.h
zephyr/zwgc/parser.h
zephyr/zwgc/parser.y
zephyr/zwgc/port.c
zephyr/zwgc/port.h
zephyr/zwgc/regexp.c
zephyr/zwgc/regexp.h
zephyr/zwgc/standard_ports.c
zephyr/zwgc/string_dictionary_aux.c
zephyr/zwgc/string_dictionary_aux.h
zephyr/zwgc/subscriptions.c
zephyr/zwgc/subscriptions.h
zephyr/zwgc/substitute.c
zephyr/zwgc/substitute.h
zephyr/zwgc/text_operations.c
zephyr/zwgc/text_operations.h
zephyr/zwgc/tty_filter.c
zephyr/zwgc/variables.c
zephyr/zwgc/variables.h
zephyr/zwgc/xcut.c
zephyr/zwgc/xerror.c
zephyr/zwgc/xerror.h
zephyr/zwgc/xmark.c
zephyr/zwgc/xmark.h
zephyr/zwgc/xrevstack.c
zephyr/zwgc/xrevstack.h
zephyr/zwgc/xselect.c
zephyr/zwgc/xselect.h
zephyr/zwgc/xshow.c
zephyr/zwgc/zephyr.c
zephyr/zwgc/zephyr.h

index b4ec8279002f00450b1eac7790cdf4bccd385ae1..96eb3d12a23a01381ad252847270c16d9aee30ac 100644 (file)
@@ -4,39 +4,6 @@
 /* Define to compile with Kerberos support. */
 #undef HAVE_KRB4
 
-/* Define to compile with Kerberos v5 support. */
-#undef HAVE_KRB5
-
-/* Define to 1 if `enc_part2' is member of `krb5_ticket'. */
-#undef HAVE_KRB5_TICKET_ENC_PART2
-
-/* Define to 1 if `keyblock.enctype' is member of `krb5_creds'. */
-#undef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
-
-/* Define to 1 if you have the `krb5_c_make_checksum' function. */
-#undef HAVE_KRB5_C_MAKE_CHECKSUM
-
-/* Define to 1 if you have the `krb5_cc_set_default_name' function. */
-#undef HAVE_KRB5_CC_SET_DEFAULT_NAME
-
-/* Define to 1 if `krb5_auth_con_getauthenticator' takes a double pointer third arg. */
-#undef KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER
-
-/* Define to 1 if you have the <krb5_err.h> header file. */
-#undef HAVE_KRB5_ERR_H
-
-/* Define to 1 if you have the `krb5_free_data' function. */
-#undef HAVE_KRB5_FREE_DATA
-
-/* Define to 1 if you have the <krb5/ss.h> header file. */
-#undef HAVE_KRB5_SS_H
-
-/* Define to 1 if you have the `krb_get_err_text' function. */
-#undef HAVE_KRB_GET_ERR_TEXT
-
-/* Define to 1 if you have the `krb_log' function. */
-#undef HAVE_KRB_LOG
-
 /* Define to compile with ares support. */
 #undef HAVE_ARES
 
index 2ae46142ff03392f8de4d0b94fca6710a2eaabf8..42732e92db076d357678e1a7fdded5547edfbbe2 100644 (file)
@@ -1,7 +1,7 @@
 SHELL = /bin/sh
 
-SUBDIRS=zaway zctl zleave zlocate znol \
-       zshutdown_notify zstat zwrite
+SUBDIRS=@XCLIENTS@ zaway zctl zleave zlocate zmailnotify znol \
+       zpopnotify zshutdown_notify zstat zwrite
 
 all:
        for i in ${SUBDIRS}; do (cd $$i; ${MAKE} $@) || exit 1; done
diff --git a/zephyr/clients/xzwrite/GetString.c b/zephyr/clients/xzwrite/GetString.c
new file mode 100644 (file)
index 0000000..85e3463
--- /dev/null
@@ -0,0 +1,125 @@
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Command.h>
+
+#include "GetString.h"
+
+#define XVCMW XtVaCreateManagedWidget
+
+static int accepted, cancelled;
+static void Accept(), Cancel(), Focus();
+
+extern void Popup();
+
+static XtActionsRec actionTable[] = {
+     {"Accept", (XtActionProc) Accept},
+     {"Cancel", (XtActionProc) Cancel},
+     {"Focus", (XtActionProc) Focus},
+};
+     
+Widget InitGetString(parent, name)
+   Widget parent;
+   char *name;
+{
+     static int first_time = 1;
+     Widget getStringWindow, form, title, edit, accept, cancel;
+
+     if (first_time) {
+         XtAppAddActions(XtWidgetToApplicationContext(parent), actionTable,
+                         XtNumber(actionTable));
+         first_time = 0;
+     };
+
+     getStringWindow = XtVaCreatePopupShell(name, transientShellWidgetClass,
+                                           parent,
+                                           XtNinput, True,
+                                           NULL);
+     form = XVCMW("getStringForm", formWidgetClass, getStringWindow, NULL);
+     title = XVCMW("getStringTitle", labelWidgetClass, form, NULL);
+     edit = XVCMW("getStringEdit", asciiTextWidgetClass, form, NULL);
+     accept = XVCMW("getStringAccept", commandWidgetClass, form, NULL);
+     cancel = XVCMW("getStringCancel", commandWidgetClass, form, NULL);
+     XtSetKeyboardFocus(form, edit);
+
+     return getStringWindow;
+}
+
+int GetString(getStringWindow, label, value, pop_type, buf, len)
+   Widget getStringWindow;
+   String label, value;
+   int pop_type;
+   char *buf;
+   int len;
+{
+     XtAppContext app_con;
+     Widget title, edit;
+     XEvent event;
+
+     app_con = XtWidgetToApplicationContext(getStringWindow);
+     title = XtNameToWidget(getStringWindow, "getStringForm.getStringTitle");
+     edit = XtNameToWidget(getStringWindow, "getStringForm.getStringEdit");
+
+     XtVaSetValues(title, XtNlabel, label, NULL);
+     XtVaSetValues(edit, XtNstring, value, NULL);
+
+     XtRealizeWidget(getStringWindow);
+     Popup(getStringWindow, XtGrabExclusive, pop_type);
+
+     accepted = cancelled = 0;
+     while (! accepted && ! cancelled) {
+         XtAppNextEvent(app_con, &event);
+         XtDispatchEvent(&event);
+     }
+
+     XtPopdown(getStringWindow);
+
+     if (accepted) {
+         char *s;
+         Widget text_source;
+
+         XtVaGetValues(edit, XtNstring, (XtArgVal) &s, XtNtextSource,
+                       (XtArgVal) &text_source, NULL);
+         strncpy(buf, s, len-2);
+         buf[len-1] = '\0';
+         XawAsciiSourceFreeString(text_source);
+         
+         return GETSTRING_ACCEPT;
+     }
+     else
+         return GETSTRING_CANCEL;
+}
+
+/* ARGSUSED */
+static void Accept(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     accepted = 1;
+}
+
+/* ARGSUSED */
+static void Cancel(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     cancelled = 1;
+}
+
+/* ARGSUSED */
+static void Focus(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     XSetInputFocus(XtDisplay(w), XtWindow(w), RevertToPointerRoot,
+                   CurrentTime);
+}
diff --git a/zephyr/clients/xzwrite/GetString.h b/zephyr/clients/xzwrite/GetString.h
new file mode 100644 (file)
index 0000000..562485d
--- /dev/null
@@ -0,0 +1,9 @@
+#include <X11/Intrinsic.h>
+
+#define GETSTRING_ACCEPT       -1000
+#define GETSTRING_CANCEL       -1001
+
+Widget InitGetString();
+int GetString();
+
+
diff --git a/zephyr/clients/xzwrite/Makefile.in b/zephyr/clients/xzwrite/Makefile.in
new file mode 100644 (file)
index 0000000..7ece4a9
--- /dev/null
@@ -0,0 +1,70 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+sysconfdir=@sysconfdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+top_builddir=../..
+
+includedir=${prefix}/include
+mandir=@mandir@
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+LIBTOOL=@LIBTOOL@
+CC=@CC@
+INSTALL=@INSTALL@
+at=@
+
+LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la
+LIBDYN=${BUILDTOP}/libdyn/libdyn.a
+CPPFLAGS=@CPPFLAGS@
+CFLAGS=@CFLAGS@
+ALL_CFLAGS=${CFLAGS} -DDATADIR=\"${datadir}\" -I${top_srcdir}/h \
+       -I${BUILDTOP}/h @X_CFLAGS@ ${CPPFLAGS}
+LDFLAGS=@X_LIBS@ @LDFLAGS@
+LIBS=${LIBZEPHYR} ${LIBDYN} -lXaw -lXmu -lXt @X_PRE_LIBS@ -lX11 -lXext \
+       @X_EXTRA_LIBS@ @LIBS@ -lcom_err
+
+OBJS=  interface.o resource.o destlist.o util.o bfgets.o gethomedir.o \
+       dest_window.o xzwrite.o edit_window.o zephyr.o GetString.o Popup.o \
+       yank.o menu_window.o logins.o
+
+all: xzwrite XZwrite
+
+xzwrite: ${OBJS} ${LIBZEPHYR} ${LIBDYN}
+       ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+.c.o:
+       ${CC} -c ${ALL_CFLAGS} $<
+
+XZwrite: XZwrite.in
+       rm -f XZwrite
+       sed -e 's,$(at)datadir$(at),$(datadir),' < ${srcdir}/XZwrite.in \
+               > XZwrite
+
+check:
+
+install: xzwrite XZwrite
+       ${LIBTOOL} --mode=install ${INSTALL} -m 755 xzwrite ${DESTDIR}${bindir}
+       ${INSTALL} -m 644 ${srcdir}/xzwrite.1 ${DESTDIR}${mandir}/man1
+       ${INSTALL} -m 644 XZwrite ${DESTDIR}${datadir}/zephyr
+       ${INSTALL} -m 644 ${srcdir}/xzwrite.bitmap ${DESTDIR}${datadir}/zephyr
+
+clean:
+       ${LIBTOOL} --mode=clean rm -f xzwrite
+       rm -f ${OBJS}
+
+${OBJS}: xzwrite.h xzwrite-proto.h ${top_srcdir}/h/sysdep.h
+${OBJS}: ${BUILDTOP}/h/config.h ${BUILDTOP}/h/zephyr/zephyr.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr_err.h
+destlist.o logins.o xzwrite.o zephyr.o: ${top_srcdir}/h/dyn.h
+
+.PHONY: all check install clean
+
diff --git a/zephyr/clients/xzwrite/Popup.c b/zephyr/clients/xzwrite/Popup.c
new file mode 100644 (file)
index 0000000..616f594
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * This code has gone back and forth between myself and Jon Kamens
+ * so many times that neither really knows who wrote it..
+ */
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+static void _initPopup();
+void Popup(), PopupSafe(), PopupAtPointer();
+
+static int     display_height, display_width;
+
+static void _initPopup(w)
+   Widget      w;
+{
+     Display   *dpy;
+     int       screen;
+
+     dpy = XtDisplay(w);
+     screen = DefaultScreen(dpy);
+     display_height = DisplayHeight(dpy, screen);
+     display_width = DisplayWidth(dpy, screen);
+}
+
+/* ARGSUSED */
+void Popup(shell, GrabType, pop_type)
+   Widget shell;
+   XtGrabKind GrabType;
+   int pop_type;
+{
+     PopupAtPointer(shell, GrabType);
+}
+
+void PopupSafe(w, x, y, GrabType)
+   Widget w;
+   Dimension x, y;
+   XtGrabKind GrabType;
+{
+     static int first_time = 1;
+     Dimension width, height, border;
+
+     if (first_time) {
+         _initPopup(w);
+         first_time = 0;
+     }
+
+     XtVaGetValues(w,
+                  XtNwidth, &width,
+                  XtNheight, &height,
+                  XtNborderWidth, &border,
+                  NULL);
+     
+     if (x + width + 2 * border > display_width)
+         x = display_width - width - 2 * border;
+     if (y + height + 2 * border > display_height)
+         y = display_height - height - 2 * border;
+     
+     XtVaSetValues(w,
+                  XtNx, x,
+                  XtNy, y,
+                  NULL);
+     
+     XtPopup(w, GrabType);
+}
+
+void PopupAtPointer(w, GrabType)
+   Widget      w;
+   XtGrabKind  GrabType;
+{
+     Window garbage1, garbage2, window;
+     int root_x, root_y, x2, y2;
+     unsigned int mask;
+     Dimension width, height, border;
+     Display *dpy;
+
+     dpy = XtDisplay(w);
+     window = XtWindow(XtParent(w));
+
+     if (XQueryPointer(dpy, window, &garbage1, &garbage2,
+                      &root_x, &root_y, &x2, &y2, &mask)) {
+
+         XtVaGetValues(w,
+                       XtNwidth, &width,
+                       XtNheight, &height,
+                       XtNborderWidth, &border,
+                       NULL);
+         
+         if (root_x >= width / 2 + border)
+              root_x -= width / 2 + border;
+         else
+              root_x = 0;
+         if (root_y >= height / 2 + border)
+              root_y -= height / 2 + border;
+         else
+              root_y = 0;
+
+         PopupSafe(w, (Dimension) root_x, (Dimension) root_y, GrabType);
+     }
+}
diff --git a/zephyr/clients/xzwrite/XZwrite.in b/zephyr/clients/xzwrite/XZwrite.in
new file mode 100644 (file)
index 0000000..691cc1c
--- /dev/null
@@ -0,0 +1,249 @@
+! @configure_input@
+
+*resize: on
+*allowShellResize: on
+
+*reverseVideo:         on
+*maxYanks:             25
+*ping:                 on
+*verbose:              on
+*auth:                 on
+*yankDest:             off
+*addGlobals:           on
+*classInst:            on
+*closeOnSend:          off
+*trackLogins:          on
+*pongScan:             off
+*readAnyone:           on
+*readXzwrite:          on
+
+*icon.bitmap:          @datadir@/zephyr/xzwrite.bitmap
+*icon.translations:    #override\
+       <BtnDown>:      set() \n\
+       <Btn1Up>:       OpenSend() unset() \n\
+       Ctrl<Btn2Up>:   Quit() \n\
+       <Btn3Up>:       OpenMenu() unset()
+
+*sendForm.defaultDistance: -1
+*sendForm.borderWidth: 0
+
+*sendClose.label:      Close Window
+*sendClose.top:                ChainTop
+*sendClose.bottom:     ChainTop
+*sendClose.left:       ChainLeft
+*sendClose.right:      ChainRight
+*sendClose.translations:#override\
+       <BtnDown>:      set() \n\
+       <BtnUp>:        CloseSend() unset() \n\
+
+*editPane.fromVert:    sendClose
+*editPane.top:         ChainTop
+*editPane.bottom:      ChainBottom
+*editPane.left:                ChainLeft
+
+*editTitle.showGrip:   false
+*editTitle.borderWidth:        0
+
+*editForm.showGrip:    false
+*editForm.borderWidth: 2
+*editForm.borderColor: black
+
+*editSend.label:       Send Message
+*editSend.left:                ChainLeft
+*editSend.translations:#override\
+       <BtnDown>:      set() \n\
+       <BtnUp>:        YankStore() SendMessage() unset() \n\
+
+*editClear.label:      Clear Editor
+*editClear.fromHoriz:  editSend
+*editClear.translations:#override\
+       <BtnDown>:      set() \n\
+       <BtnUp>:        ClearEditor() unset() \n\
+
+*editPrev.label:       Yank-Prev
+*editPrev.fromHoriz:   editClear
+*editPrev.translations:#override\
+       <BtnDown>:      set() \n\
+       <BtnUp>:        YankPrev() unset() \n\
+
+*editNext.label:       Yank-Next
+*editNext.fromHoriz:   editPrev
+*editNext.right:       ChainRight
+*editNext.translations:#override\
+       <BtnDown>:      set() \n\
+       <BtnUp>:        YankNext() unset() \n\
+
+*editor.height:                130
+*editor*editType:      edit
+*editor*wrap:          never
+*editor*autoFill:      true
+*editor*useStringInPlace: false
+*editor.translations:  #override\
+       Ctrl<Key>Return: YankStore() SendMessage() ClearEditor() \n\
+       Ctrl<Key>Y:     YankStore() YankPrev() \n\
+       Meta<Key>O:     YankStore() YankPrev() \n\
+       Meta<Key>P:     YankPrev() \n\
+       Meta<Key>N:     YankNext()
+
+*destForm.borderWidth: 0
+*destForm.defaultDistance: 0
+*destForm.fromVert:    sendClose
+*destForm.top:         ChainTop
+*destForm.bottom:      ChainBottom
+*destForm.right:       ChainRight
+*destForm.fromHoriz:   editPane
+
+*destScroll.top:       ChainTop
+*destScroll.bottom:    ChainBottom
+*destScroll.left:      ChainLeft
+*destScroll.right:     ChainRight
+*destScroll.height:    178
+*destScroll.resizable: false
+*destScroll.allowVert: true
+*destScroll.allowHoriz: false
+*destScroll.forceBars:  true
+
+*destList.forceColumns:        on
+*destList.defaultColumns: 1
+*destList.translations: #override\
+       <Motion>:       Set() \n\
+       <Btn1Up>:       Set() SelectDest() Unset() \n\
+       <Btn2Up>:       CreateDest() \n\
+       <Btn3Up>:       Set() DeleteDest() Unset() \n\
+       <LeaveWindow>:  Unset()
+
+*menuClose.label:      Close Window
+*menuClose.top:                ChainTop
+*menuClose.left:       ChainLeft
+*menuClose.right:      ChainRight
+*menuClose.width:      200
+*menuClose.translations:#override\
+       <BtnDown>:      set() \n\
+       <BtnUp>:        CloseMenu() unset() \n\
+
+*signature.label:      Change Signature
+*signature.fromVert:   menuClose
+*signature.left:       ChainLeft
+*signature.right:      ChainRight
+*signature.width:      200
+*signature.translations: #override\
+       <BtnDown>:      set() \n\
+       <BtnUp>:        Signature()
+
+*clearOnSend.label:    Clear On Send
+*clearOnSend.fromVert: signature
+*clearOnSend.left:     ChainLeft
+*clearOnSend.right:    ChainRight
+*clearOnSend.width:    200
+*clearOnSend.translations: #override\
+       <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*closeOnSend.label:    Close On Send
+*closeOnSend.fromVert: clearOnSend
+*closeOnSend.left:     ChainLeft
+*closeOnSend.right:    ChainRight
+*closeOnSend.width:    200
+*closeOnSend.translations: #override\
+       <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*pings.label:          Pings
+*pings.fromVert:       closeOnSend
+*pings.left:           ChainLeft
+*pings.right:          ChainRight
+*pings.width:          200
+*pings.translations: #override\
+       <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*verbose.label:                Verbose
+*verbose.fromVert:     pings
+*verbose.left:         ChainLeft
+*verbose.right:                ChainRight
+*verbose.width:                200
+*verbose.translations: #override\
+       <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*authentic.label:      Authenticate
+*authentic.fromVert:   verbose
+*authentic.left:       ChainLeft
+*authentic.right:      ChainRight
+
+*authentic.width:      200
+*authentic.translations: #override\
+       <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*yankDest.label:       Yank Destinations
+*yankDest.fromVert:    authentic
+*yankDest.left:                ChainLeft
+*yankDest.right:       ChainRight
+*yankDest.width:       200
+*yankDest.translations: #override\
+       <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*addGlobals.label:     Add Globals
+*addGlobals.fromVert:  yankDest
+*addGlobals.left:      ChainLeft
+*addGlobals.right:     ChainRight
+*addGlobals.width:     200
+*addGlobals.translations: #override\
+       <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*classInst.label:      Class/Inst
+*classInst.fromVert:   addGlobals
+*classInst.left:       ChainLeft
+*classInst.right:      ChainRight
+*classInst.width:      200
+*classInst.translations: #override\
+       <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*exitProgram.label:    Quit XZWRITE
+*exitProgram.fromVert: classInst
+*exitProgram.left:     ChainLeft
+*exitProgram.right:    ChainRight
+*exitProgram.width:    200
+*exitProgram.translations:#override\
+       <BtnDown>:      set() \n\
+       <BtnUp>:        Quit()
+
+*getStringWindow.resize: true
+
+*getStringTitle.borderWidth: 0
+*getStringTitle.top:    ChainTop
+*getStringTitle.bottom: ChainTop
+*getStringTitle.left:   ChainLeft
+*getStringTitle.right:  ChainRight
+
+*getStringForm.width:   210
+
+*getStringEdit*editType: edit
+*getStringEdit.resize:  width
+*getStringEdit.resizable: true
+*getStringEdit.top:     ChainTop
+*getStringEdit.bottom:  ChainTop
+*getStringEdit.left:    ChainLeft
+*getStringEdit.right:   ChainRight
+*getStringEdit.fromVert: getStringTitle
+*getStringEdit.translations:   #override\
+       <Key>Return:    Accept() \n\
+
+*getStringAccept.width: 105
+*getStringAccept.label: Accept
+*getStringAccept.fromVert: getStringEdit
+*getStringAccept.top:   ChainTop
+*getStringAccept.bottom: ChainTop
+*getStringAccept.left:  ChainRight
+*getStringAccept.right: ChainRight
+*getStringAccept.translations: #override\
+       <BtnDown>:      set() \n\
+       <BtnUp>:        Accept() unset()
+
+*getStringCancel.width: 105
+*getStringCancel.label: Cancel
+*getStringCancel.fromVert: getStringEdit
+*getStringCancel.fromHoriz: getStringAccept
+*getStringCancel.top:   ChainTop
+*getStringCancel.bottom: ChainTop
+*getStringCancel.left: ChainRight
+*getStringCancel.right: ChainRight
+*getStringCancel.translations: #override\
+       <BtnDown>:      set() \n\
+       <BtnUp>:        Cancel() unset()
diff --git a/zephyr/clients/xzwrite/associate.c b/zephyr/clients/xzwrite/associate.c
new file mode 100644 (file)
index 0000000..db51e0b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * This is a string-associative array abstraction with really lousy
+ * semantics.  But it does what I need at the moment.
+ */
+
+#include "associate.h"
+
+AArray AACreate()
+{
+     return (DynCreate(sizeof(AElementRec), 0));
+}
+
+void AADestroy(array)
+   AArray array;
+{
+     DynDestroy(array);
+}
+
+int AAInsert(array, index, value)
+   AArray array;
+   char *index, *value;
+{
+     AElementRec temp;
+     int ret;
+
+     temp.index = index;
+     temp.value = value;
+
+     ret = DynAdd(array, &temp);
+     if (ret != DYN_OK)
+         return AA_FAILED;
+     else
+         return AA_OK;
+}
+
+char *AALookup(array, index)
+   AArray array;
+   char *index;
+{
+     AElementRec *a;
+     int i;
+
+     a = (AElementRec *) DynGet((char *) array, 0);
+     for (i=0; i < DynSize(array); i++)
+         if (strcmp(a[i].index, index) == 0)
+              return (a[i].value);
+
+     return NULL;
+}
+
+     
diff --git a/zephyr/clients/xzwrite/associate.h b/zephyr/clients/xzwrite/associate.h
new file mode 100644 (file)
index 0000000..a6ff2dc
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef _Associate_h
+#define _Associate_h
+
+#include <stdio.h>
+#include <dyn.h>
+
+#define AA_OK          -1000
+#define AA_FAILED      -1001
+#define AA_NOTFOUND    -1002
+
+typedef struct _array_elements {
+     char *index;
+     char *value;
+} AElementRec, *AElement;
+
+typedef DynObject AArray;
+
+#endif /* _Associate_h */
diff --git a/zephyr/clients/xzwrite/bfgets.c b/zephyr/clients/xzwrite/bfgets.c
new file mode 100644 (file)
index 0000000..96636f9
--- /dev/null
@@ -0,0 +1,33 @@
+/* bfgets.c
+ *
+ * declaration:
+ *   char *bfgets(s, n, iop)
+ *      char *s;
+ *      int  n;
+ *      FILE *iop;
+ *
+ * Reads n-1 characters or until a newline from iop.  The terminating newline
+ * is NOT RETURNED.
+ *
+ * Written by Barr3y Jaspan (bjaspan@athena.mit.edu)
+ */
+
+#include <stdio.h>
+
+char *bfgets();
+
+char *bfgets(s, n, iop)
+   char *s;
+   int  n;
+   FILE *iop;
+{
+     register int c = 0;
+     register char *cs;
+
+     cs = s;
+     while ((--n > 0) && ((c = getc(iop)) !=EOF) && (c != '\n'))
+         *cs++ = c;
+
+     *cs = '\0';
+     return (c == EOF && cs == s) ? NULL : s;
+}
diff --git a/zephyr/clients/xzwrite/dest_window.c b/zephyr/clients/xzwrite/dest_window.c
new file mode 100644 (file)
index 0000000..82831c3
--- /dev/null
@@ -0,0 +1,120 @@
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Toggle.h>
+#include <X11/Xaw/List.h>
+
+#include "xzwrite.h"
+#include "GetString.h"
+
+extern Widget toplevel, getString, destList;
+extern DestRec current_dest;
+extern Defaults defs;
+
+void display_dest()
+{
+     XawListChange(destList, (String *) dest_text(), dest_num(), 0, True);
+}
+
+void delete_dest()
+{
+     XawListReturnStruct *item;
+
+     item = XawListShowCurrent(destList);
+     if (item->list_index == XAW_LIST_NONE)
+         return;
+
+     dest_delete_string(item->string);
+     display_dest();
+}
+
+void create_dest()
+{
+     char buf[ZLEN*3+2], *s;
+     int ret;
+
+     ret = GetString(getString, "Enter new <class,instance,recipient> triple:",
+                    "", 0, buf, ZLEN*3+2);
+     if (ret == GETSTRING_ACCEPT) {
+         s = (char *) malloc(strlen(buf)+1);
+         strcpy(s, buf);
+         if (dest_add_string(s) == NULL) {
+              XBell(XtDisplay(toplevel), 0);
+              free(s);
+         }
+         else
+              display_dest();
+     }
+}
+
+void select_dest()
+{
+     DestRec dest;
+     XawListReturnStruct *item;
+     int ret, used_global = 0;
+
+     item = XawListShowCurrent(destList);
+     if (item->list_index == XAW_LIST_NONE)
+         return;
+     
+     parse_into_dest(&dest, item->string);
+
+     if (! strcmp(dest.zclass, "...")) {
+         ret = GetString(getString, "Enter CLASS to send to:", "", 0,
+                         dest.zclass, ZLEN);
+         if (ret != GETSTRING_ACCEPT) return;
+         used_global = 1;
+     }
+
+     if (! strcmp(dest.zinst, "...")) {
+         ret = GetString(getString, "Enter INSTANCE to send to:", "", 0,
+                         dest.zinst, ZLEN);
+         if (ret != GETSTRING_ACCEPT) return;
+         used_global = 1;
+     }
+
+     if (! strcmp(dest.zrecip, "...")) {
+         ret = GetString(getString, "Enter RECIPIENT to send to:", "", 0,
+                         dest.zrecip, ZLEN);
+         if (ret != GETSTRING_ACCEPT) return;
+         used_global = 1;
+     }
+
+     if (defs.add_globals && used_global) {
+         /* A hack so using "..." looks pretty */
+         if (! strcmp(dest.zclass, DEFAULT_CLASS) &&
+             ! strcmp(dest.zinst, DEFAULT_INST)) {
+              char *temp;
+
+              temp = (char *) malloc(strlen(dest.zrecip) + 1);
+              strcpy(temp, dest.zrecip);
+              dest_add_string(temp);
+         }
+         else
+              dest_add(&dest);
+         display_dest();
+     }
+
+     if (defs.ping && *dest.zrecip) {
+         ret = zeph_ping(&dest);
+         switch (ret) {
+         case SEND_OK:
+              edit_set_title(&dest);
+              (void) memcpy((char *) &current_dest, (char *) &dest,
+                             sizeof(DestRec));
+              break;
+         case SENDFAIL_SEND:
+         case SENDFAIL_RECV:
+         case SENDFAIL_ACK:
+              XBell(XtDisplay(toplevel), 0);
+              return;
+         }
+     }
+     else {
+         edit_set_title(&dest);
+         (void) memcpy((char *) &current_dest, (char *) &dest,
+                        sizeof(DestRec));
+     }
+}
diff --git a/zephyr/clients/xzwrite/destlist.c b/zephyr/clients/xzwrite/destlist.c
new file mode 100644 (file)
index 0000000..8621922
--- /dev/null
@@ -0,0 +1,414 @@
+#include <sysdep.h>
+#include <dyn.h>
+
+#include "xzwrite.h"
+
+/*
+ * The following code extracts keypressed from an X event:
+ * 
+ * keyevent = event->xkey;
+ * XLookupString(&keyevent, buffer, 1, NULL, NULL);
+ */
+
+/*
+ * This entire file could easily be changes so that multiple destination
+ * lists could be used.  But I don't know that that's necessary for this
+ * program.
+ */
+
+/* Globals */
+DestRec current_dest;
+
+static DynObject       dests;
+extern Defaults                defs;
+
+static void get_dest_from_file(), _get_default_dest();
+static int sort_dest_func(const void *, const void *);
+
+/* A function for debugging */
+void dest_print()
+{
+     char **d;
+     int i;
+
+     d = (char **) DynGet(dests, 0);
+     for (i=0; i<DynSize(dests); i++)
+         printf("%d %s\n", i, d[i]);
+}
+
+char **dest_text()
+{
+     return ((char **) DynGet(dests, 0));
+}
+
+int dest_num()
+{
+     return (DynSize(dests));
+}
+
+void dest_set_current_dest(dest)
+   Dest       dest;
+{
+     (void) memcpy((char *) &current_dest, (char *) dest, sizeof(DestRec));
+}
+
+void dest_init()
+{
+     dests = DynCreate(sizeof(char *), 0);
+     if (! dests)
+         Error("Out of memory reading destinations", NULL);
+
+     strcpy(current_dest.zclass, DEFAULT_CLASS);
+     strcpy(current_dest.zinst, DEFAULT_INST);
+     strcpy(current_dest.zrecip, get_username());
+}
+
+char **load_default_dest()
+{
+     char      *get_home_dir();
+
+     if (! *get_home_dir())
+         Error("Cannot find your home directory.", NULL);
+
+     if (defs.read_xzwrite)
+         _get_default_dest(XZWRITE_DEST_FILE);
+     if (defs.read_zephyr)
+         _get_default_dest(ZEPHYR_FILE);
+     if (defs.read_anyone)
+         _get_default_dest(ANYONE_FILE);
+
+     if (DynSize(dests) == 0) {
+         char *def;
+         
+         Warning("XZwrite: No destinations specified, using default.",
+                 NULL);
+
+         def = (char *) Malloc(strlen("...") + 1, "adding default dests",
+                               NULL);
+         strcpy(def, "...");
+         if (DynAdd(dests, (char *) &def) == DYN_NOMEM)
+              Error("Out of memory adding default destinations.", NULL);
+     }
+
+     sort_destinations();
+     return ((char **) DynGet(dests, 0));
+}
+
+static void _get_default_dest(s)
+   char *s;
+{
+     char      *filename;
+     
+     filename = (char *) Malloc(strlen(get_home_dir()) + strlen(s) + 1,
+                               "While reading file ", s, NULL);
+     sprintf(filename, "%s%s", get_home_dir(), s);
+     get_dest_from_file(dests, filename);
+     free(filename);
+}
+
+static void get_dest_from_file(dests, f)
+   DynObject   dests;
+   char                *f;
+{
+     FILE      *file;
+     char      *line, buf[BUFSIZ];
+     DestRec   dest;
+
+     if ((file = fopen(f, "r")) == NULL) {
+         Warning("Cannot find destinations file ", f, NULL);
+         return;
+     }
+     
+     while (bfgets(buf, 80, file)) {
+         if (buf[0] == '#' || buf[0] == '\0') {
+              if (defs.debug)
+                   printf("xzwrite: skipping comment or blank line\n");
+              continue;
+         }
+         
+         if (! parse_into_dest(&dest, buf)) {
+              Warning("Ignoring incorrect destination: ", buf, NULL);
+              continue;
+         }
+
+         line = (char *) Malloc(strlen(buf) + 1, "parsing file ", f, NULL);
+         strcpy(line, buf);
+         if (DynAdd(dests, (char *) &line) == DYN_NOMEM)
+              Error("Out of memory parsing file ", f, NULL);
+     }
+     
+     fclose(file);
+}
+
+char **dest_add(dest)
+   Dest dest;
+{
+     char *buf;
+
+     /* Two extra bytes if instance or recipient are "" */
+     buf = (char *) Malloc(strlen(dest->zclass) + strlen(dest->zinst) +
+                          strlen(dest->zrecip) + 5,
+                          "while adding destination ", NULL);
+     sprintf(buf, "%s,%s,%s", dest->zclass,
+            *dest->zinst ? dest->zinst : "*",
+            *dest->zrecip ? dest->zrecip : "*");
+
+     if (DynAdd(dests, (DynPtr) &buf) == DYN_NOMEM) {
+         Warning("Out of memory adding destination ", buf, ".  Skipping.",
+                 NULL);
+         free(buf);
+     }
+
+     sort_destinations();
+     return ((char **) DynGet(dests, 0));
+}
+
+/* XXX The return/output semantics of this function are not good */
+char **dest_add_string(s)
+   char *s;
+{
+     DestRec   dest;
+     
+     if (! parse_into_dest(&dest, s))
+         return NULL;
+     
+     if (DynAdd(dests, (DynPtr) &s) == DYN_NOMEM)
+         Warning("Out of memory adding destination ", s, ".  Skipping.",
+                 NULL);
+
+     sort_destinations();
+     return ((char **) DynGet(dests, 0));
+}
+
+char **dest_delete_string(s)
+   char        *s;
+{
+     int       i;
+     char      **d;
+
+     d = (char **) DynGet(dests, 0);
+     for (i=0; i<DynSize(dests); i++) {
+         if (! strcmp(s, d[i])) {
+              DynDelete(dests, i);
+              break;
+         }
+     }
+
+     return ((char **) DynGet(dests, 0));
+}
+
+char **delete_dest_index(i)
+   int i;
+{
+     int       ret;
+
+     ret = DynDelete(dests, i);
+     if (ret != DYN_OK)
+         return NULL;
+
+     return ((char **) DynGet(dests, 0));
+}
+
+     
+static int sort_dest_func(a1, a2)
+   const void *a1, *a2;
+{
+     char      **c1 = (char **) a1, **c2 = (char **) a2;
+     char      *s1, *s2, *i1, *i2;
+
+     /* A string with a , in it is always less than one without */
+     s1 = *c1; s2 = *c2;
+     i1 = strchr(s1, ',');
+     i2 = strchr(s2, ',');
+     if (i1 == NULL && i2 != NULL)
+         return 1;
+     else if (i1 != NULL && i2 == NULL)
+         return -1;
+     else
+         return strcmp(s1, s2);
+}
+
+static int
+binary_find_dest(key)
+char *key;
+{
+    register int low = 0, high = DynHigh(dests), mid;
+    register int val;
+    register char **d;
+
+    d = (char **) DynGet(dests, 0);
+
+    /* do binary search */
+    while (low <= high) {
+       mid = (low + high) / 2;
+       val = sort_dest_func(&key, &d[mid]);
+       if (val < 0) {
+           high = mid - 1;
+       } else if (val > 0) {
+           low = mid + 1;
+       } else {
+           return (mid);
+       }
+    }
+
+    return -1;
+}
+
+char **sort_destinations()
+{
+     register char **d;
+     register int idx, idx2;
+     int dsiz = DynSize(dests);
+
+     d = (char **) DynGet(dests, 0);
+     qsort(d, dsiz, sizeof(char *), sort_dest_func);
+     
+     for (idx = 0; idx < DynSize(dests);) {
+       if (d[idx][0] == '!') {
+           /* unsubscription */
+           char *next = d[idx];
+           next++;
+           while ((idx2 = binary_find_dest(next)) >= 0) {
+               /* found one to nuke */
+               DynDelete(dests, idx2);
+               if (idx2 <= idx) {
+                   /* indexes shifted, so restart this pass. */
+                   idx--;
+                   if (idx <= 0)
+                       idx = 0;
+                   continue;
+               }
+           }
+           /* ok, no more to nuke from this one, so delete it and
+              move on. */
+           DynDelete(dests, idx);
+           continue;
+       }
+       /* nope, continue on to next unsub */
+       idx++;
+     }
+     return d;
+}
+
+/* Fills in dest from s */
+int parse_into_dest(dest, s)
+   Dest        dest;
+   char        *s;
+{
+     char      *a, *b;
+     int       x, y;
+
+     /* Check for just recipient */
+     if ((a=strchr(s, ','))==0) {
+         if (strlen(s) > ZLEN)
+              return 0;
+         strcpy(dest->zclass, DEFAULT_CLASS);
+         strcpy(dest->zinst, DEFAULT_INST);
+         strcpy(dest->zrecip, s);
+     }
+
+     /* Check for just class,instance or instace,recipient */
+     else if ((b=strchr((++a), ','))==0) {
+         if (defs.class_inst) {
+              x = a - 1 - s;
+              if (x >= ZLEN)
+                   return 0;
+
+              strncpy(dest->zclass, s, x);
+              dest->zclass[x] = '\0';
+              strcpy(dest->zinst, a);
+              strcpy(dest->zrecip, "*"); }
+         else {
+              x = a - 1 - s;
+              if (x >= ZLEN)
+                   return 0;
+              
+              strcpy(dest->zclass, DEFAULT_CLASS);
+              strncpy(dest->zinst, s, x);
+              dest->zinst[x] = '\0';
+              strcpy(dest->zrecip, a); }
+     }
+
+     /* Otherwise, deal with class,instance,recipent */
+     else {
+         ++b;
+         x = a - 1 - s;
+         y = b - 1 - a;
+         if (x >= ZLEN || y >= ZLEN)
+              return 0;
+         
+         strncpy(dest->zclass, s, x);
+         dest->zclass[x] = '\0';
+         strncpy(dest->zinst, a, y);
+         dest->zinst[y] = '\0';
+         strcpy(dest->zrecip, b);
+     }
+     if (!strcmp(dest->zrecip,"*")) *(dest->zrecip) = '\0';
+     if (!strcmp(dest->zinst,"*")) *(dest->zinst) = '\0';
+
+     return 1;
+}
+
+/*
+ * notice is from <MESSAGE,inst,sender>.  If inst is "PERSONAL", add
+ * destination string "<sender>" if
+ *     1) MESSAGE,PERSONAL,<sender> is not in list, and
+ *     2) <sender> is not in list.
+ * If inst is not "PERSONAL", add destination string
+ * "<MESSAGE,<inst>,<sender>>" if it is not in the list.
+ */
+void dest_add_reply(notice)
+   ZNotice_t *notice;
+{
+     char **list, *newdest, buf[ZLEN*3+2];
+     int i, num;
+
+     list = dest_text();
+     num = dest_num();
+
+         
+     /* A hack so local-realm is less annoying */
+     {
+         char *r;
+
+         r = strchr(notice->z_sender, '@');
+         if (r && ! strcmp(r+1, ZGetRealm()))
+              *r = '\0';
+     }
+     
+     if (! strcasecmp(notice->z_class_inst, DEFAULT_INST)) {
+         sprintf(buf, "message,personal,%s", notice->z_sender);
+         for (i=0; i < num; i++) {
+              if (! strcasecmp(list[i], buf) ||
+                  ! strcasecmp(list[i], notice->z_sender))
+                   return;
+         }
+
+         newdest = (char *) Malloc(strlen(notice->z_sender) + 1,
+                               "while adding reply destination", NULL);
+         sprintf(newdest, "%s", notice->z_sender);
+     }
+     else {
+         sprintf(buf, "message,%s,%s", notice->z_class_inst,
+                 notice->z_sender);
+         for (i=0; i < num; i++) {
+              if (! strcasecmp(list[i], buf))
+                   return;
+         }
+
+         newdest = (char *) Malloc(strlen(notice->z_class) +
+                                   strlen(notice->z_class_inst) +
+                                   strlen(notice->z_sender) + 3,
+                                   "while adding reply destintion",
+                                   NULL);
+         sprintf(newdest, "%s,%s,%s", notice->z_class,
+                 notice->z_class_inst, notice->z_sender);
+     }
+
+     dest_add_string(newdest);
+     display_dest();
+
+     if (defs.track_logins)
+         zeph_subto_logins(&notice->z_sender, 1);
+}
+
diff --git a/zephyr/clients/xzwrite/edit_window.c b/zephyr/clients/xzwrite/edit_window.c
new file mode 100644 (file)
index 0000000..8c77bb0
--- /dev/null
@@ -0,0 +1,126 @@
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/Paned.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/AsciiText.h>
+
+#include "xzwrite.h"
+
+extern Widget toplevel, editor, editTitle;
+extern Defaults defs;
+extern DestRec current_dest;
+
+void edit_win_init()
+{
+     edit_set_title(&current_dest);
+}
+
+void send_message()
+{
+     char      *buf;
+     int       ret;
+     Widget    text_source;
+
+     /* I should do more interesting things with these error conditions */
+
+     XtVaGetValues(editor, XtNstring, (XtArgVal) &buf,
+                  XtNtextSource, (XtArgVal) &text_source, NULL);
+
+     ret = zeph_send_message(&current_dest, buf);
+     XawAsciiSourceFreeString(text_source);
+
+     switch (ret) {
+     case SEND_OK:
+         break;
+     case SENDFAIL_SEND:
+     case SENDFAIL_RECV:
+     case SENDFAIL_ACK:
+         if (defs.verbose)
+              XBell(XtDisplay(toplevel), 0);
+         break;
+     }
+
+     /* Only the second argument matters */
+     if (defs.close_on_send)
+         XtCallActionProc(toplevel, "CloseSend", NULL, NULL, 0);
+
+     if (defs.clear_on_send)
+         XtCallActionProc(toplevel, "ClearEditor", NULL, NULL, 0);
+}
+
+void edit_set_title(dest)
+   Dest        dest;
+{
+     char      *title;
+
+     /* alloc two extra bytes  for * in case zinst or zrecip are "" */
+     title = (char *) Malloc( strlen(dest->zclass) + strlen(dest->zinst) +
+                            strlen(dest->zrecip) + 20, "while setting title",
+                            NULL);
+     sprintf(title, "Sending to <%s, %s, %s>", dest->zclass,
+            *dest->zinst ? dest->zinst : "*",
+            *dest->zrecip ? dest->zrecip : "*");
+
+     XtVaSetValues(editTitle,
+                  XtNlabel, title,
+                  NULL);
+
+     free(title);
+}
+
+void edit_clear()
+{
+     XtVaSetValues(editor,
+                  XtNstring, "",
+                  NULL);
+}
+
+void edit_yank_prev()
+{
+     Yank     yank;
+
+     yank = yank_prev();
+     if (! yank)
+         return;
+     
+     XtVaSetValues(editor,
+                 XtNstring, (XtArgVal) yank->msg,
+                 NULL);
+     if (defs.yank_dest) {
+        dest_set_current_dest(&yank->dest);
+       edit_set_title(&yank->dest);
+   }
+}
+
+void edit_yank_next()
+{
+     Yank     yank;
+
+     yank = yank_next();
+     if (! yank)
+         return;
+     
+     XtVaSetValues(editor,
+                 XtNstring, (XtArgVal) yank->msg,
+                 NULL);
+     if (defs.yank_dest) {
+         dest_set_current_dest(&yank->dest);
+         edit_set_title(&yank->dest);
+     }
+}
+
+void edit_yank_store()
+{
+     char *buf;
+     Widget text_source;
+
+     XtVaGetValues(editor, XtNstring, (XtArgVal) &buf,
+                  XtNtextSource, (XtArgVal) &text_source, NULL);
+
+     if (buf != NULL && *buf != '\0')
+         yank_store(&current_dest, buf);
+
+     XawAsciiSourceFreeString(text_source);
+}
diff --git a/zephyr/clients/xzwrite/gethomedir.c b/zephyr/clients/xzwrite/gethomedir.c
new file mode 100644 (file)
index 0000000..ffd25bf
--- /dev/null
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <pwd.h>
+#include "xzwrite.h"
+
+char *get_home_dir()
+{
+     struct passwd    *pwuid;
+     static char      *h = NULL;
+
+     if (h) return h;
+     
+     if ((h = getenv("HOME")) != NULL) return h;
+     
+     pwuid = getpwuid(getuid());
+     return (pwuid->pw_dir);
+}
diff --git a/zephyr/clients/xzwrite/interface.c b/zephyr/clients/xzwrite/interface.c
new file mode 100644 (file)
index 0000000..716e0e3
--- /dev/null
@@ -0,0 +1,421 @@
+/*
+ * The xzwrite interface structure.  All top level widgets except toplevel
+ * are popup shells.
+ *
+ * toplevel - the top level shell
+ *     icon - the top level "Z" icon
+ * 
+ * sendWindow - the popup shell for the editor/destlist
+ *     sendForm - the form holding the edit tree and dest tree
+ *     sendClose - button to close sendWindow
+ * 
+ *     editPane - the pane holding editor widgets
+ *             editTitle - the label holding the zephyr triple
+ *             editForm - the box holding editor command buttons
+ *                     editSend - button to send message
+ *                     editClear - button to clear editor
+ *                     editPrev - button to yank previous
+ *                     editNext - button to yank next
+ *             editor - the text editor
+ * 
+ *     destForm - the form holding the destinations list/button
+ *             destScroll - the scrollbar holding the list
+ *                     destList - the destination list
+ * 
+ * menuWindow - the popup shell for the menu
+ *     menuForm - the form holding the menu list/button
+ *             menuClose - the Close Window button for the dest list
+ *             signature - button to change signature
+ *              clearOnSend
+ *             closeOnSend
+ *             pings
+ *             verbose
+ *             authentic
+ *             yankDest
+ *             addGlobals
+ *             classInst
+ *             exitProgram
+ *
+ * getStringWindow - the popup shell for dialog boxes (GetString.c)
+ *     getStringForm - the form containing the dialog widgets
+ *             getStringTitle - the title label width
+ *             getStringEdit - the text editor
+ *             getStringAccept - the accept button
+ *             getStringCancel - the cancel button
+ */
+
+#include "xzwrite.h"
+#include "GetString.h"
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/Paned.h>
+#include <X11/Xaw/List.h>
+#include <X11/Xaw/Box.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Toggle.h>
+#include <X11/Xaw/Viewport.h>
+
+#include <zephyr/zephyr.h>     /* for ZGetFD() */
+
+#define XVCMW XtVaCreateManagedWidget
+
+/* Action Procedure declarations */
+static void Quit(), SendMessage(), OpenSend(), CloseSend(),
+     ClearEditor(), YankPrev(), YankNext(), YankStore(), AlignParagraph(),
+     DeleteDest(), HighlightDest(), SelectDest(), OpenMenu(),
+     ToggleOption(), Signature(), CloseMenu(), CreateDest();
+
+static void set_editor_width(), set_sendclose_width();
+
+static XtActionsRec actionTable[] = {
+     /* sendWindow actions */
+     {"OpenSend", (XtActionProc) OpenSend},
+     {"CloseSend", (XtActionProc) CloseSend},
+     
+     /* Editor actions */
+     {"Quit", (XtActionProc) Quit},
+     {"SendMessage", (XtActionProc) SendMessage},
+     {"ClearEditor", (XtActionProc) ClearEditor},
+     {"YankStore", (XtActionProc) YankStore},
+     {"YankPrev", (XtActionProc) YankPrev},
+     {"YankNext", (XtActionProc) YankNext},
+     {"AlignParagraph", (XtActionProc) AlignParagraph},
+
+     /* Destination list actions */
+     {"SelectDest", (XtActionProc) SelectDest},
+     {"DeleteDest", (XtActionProc) DeleteDest},
+     {"CreateDest", (XtActionProc) CreateDest},
+     {"HighlightDest", (XtActionProc) HighlightDest},
+
+     /* Menu actions */
+     {"OpenMenu", (XtActionProc) OpenMenu},
+     {"ToggleOption", (XtActionProc) ToggleOption},
+     {"Signature", (XtActionProc) Signature},
+     {"CloseMenu", (XtActionProc) CloseMenu},
+};
+
+extern unsigned int num_options, num_resources;
+extern String fallback_resources[];
+extern XrmOptionDescRec app_options[];
+extern XtResource app_resources[];
+
+XtAppContext app_con;
+Defaults defs;
+
+/* Widgets */
+Widget toplevel, icon, getString;
+Widget sendWindow, sendForm, sendClose;
+Widget destForm, destScroll, destList;
+Widget editPane, editTitle, editForm, editSend, editClear,
+     editPrev, editNext, editor;
+Widget menuWindow, menuForm, menuClose, signature, 
+     clearOnSend, closeOnSend, pings, verbose, authentic,
+     yankDest, addGlobals, classInst, commandMask, exitProgram;
+
+void go()
+{
+     XtAppMainLoop(app_con);
+}
+
+void build_interface(argc, argv)
+   int *argc;
+   char **argv;
+{
+     /* Set XFILESEARCHPATH to find xzwrite's resource file */
+     /* XXX This is gross XXX */
+     {
+         char *path1, *path2;
+         
+         path1 = (char *) getenv("XFILESEARCHPATH");
+         if (! path1) path1 = "";
+         path2 = (char *) malloc(strlen(path1) +
+#ifdef HAVE_PUTENV
+                                 strlen("XFILESEARCHPATH=") +
+#endif
+                                 strlen(DATADIR) + 12);
+         if (path2 != NULL) {
+#ifdef HAVE_PUTENV
+              sprintf(path2, "XFILESEARCHPATH=%s:%s/zephyr/%%N", path1,
+                      DATADIR);
+              putenv(path2);
+#else
+              sprintf(path2, "%s:%s/zephyr/%%N", path1, DATADIR);
+              setenv("XFILESEARCHPATH", path2, 1);
+              free(path2);
+#endif
+         }
+     }
+     
+     toplevel = XtVaAppInitialize(&app_con, "XZwrite", app_options,
+#if XtSpecificationRelease > 4
+                                 num_options, argc, argv,
+#else
+                                 num_options, (Cardinal *) argc, argv,
+#endif
+                                 fallback_resources, NULL);
+
+     XtVaGetApplicationResources(toplevel, (XtPointer) &defs, app_resources,
+                                num_resources, NULL);
+
+     XtAppAddActions(app_con, actionTable, XtNumber(actionTable));
+
+     /* Create the icon */
+     icon = XVCMW("icon", commandWidgetClass, toplevel, NULL);
+
+     /* Create the menu */
+     menuWindow = XtVaCreatePopupShell("menuWindow", transientShellWidgetClass,
+                                      toplevel, NULL);
+     menuForm = XVCMW("menuForm", formWidgetClass, menuWindow, NULL);
+     menuClose = XVCMW("menuClose", commandWidgetClass, menuForm, NULL);
+     signature = XVCMW("signature", commandWidgetClass, menuForm, NULL);
+     clearOnSend = XVCMW("clearOnSend", toggleWidgetClass, menuForm, NULL);
+     closeOnSend = XVCMW("closeOnSend", toggleWidgetClass, menuForm, NULL);
+     pings = XVCMW("pings", toggleWidgetClass, menuForm, NULL);
+     verbose = XVCMW("verbose", toggleWidgetClass, menuForm, NULL);
+     authentic = XVCMW("authentic", toggleWidgetClass, menuForm, NULL);
+     yankDest = XVCMW("yankDest", toggleWidgetClass, menuForm, NULL);
+     addGlobals = XVCMW("addGlobals", toggleWidgetClass, menuForm, NULL);
+     classInst = XVCMW("classInst", toggleWidgetClass, menuForm, NULL);
+     exitProgram = XVCMW("exitProgram", commandWidgetClass, menuForm, NULL);
+
+     /* Create the editor/destination list */
+     sendWindow = XtVaCreatePopupShell("sendWindow", transientShellWidgetClass,
+                                      toplevel, NULL);
+     sendForm = XVCMW("sendForm", formWidgetClass, sendWindow, NULL);
+     sendClose = XVCMW("sendClose", commandWidgetClass, sendForm, NULL);
+     
+     editPane = XVCMW("editPane", panedWidgetClass, sendForm, NULL);
+     editTitle = XVCMW("editTitle", labelWidgetClass, editPane, NULL);
+     editForm = XVCMW("editForm", formWidgetClass, editPane, NULL);
+     editSend = XVCMW("editSend", commandWidgetClass, editForm, NULL);
+     editClear = XVCMW("editClear", commandWidgetClass, editForm, NULL);
+     editPrev = XVCMW("editPrev", commandWidgetClass, editForm, NULL);
+     editNext = XVCMW("editNext", commandWidgetClass, editForm, NULL);
+     editor = XVCMW("editor", asciiTextWidgetClass, editPane, NULL);
+
+     destForm = XVCMW("destForm", formWidgetClass, sendForm, NULL);
+     destScroll = XVCMW("destScroll", viewportWidgetClass, destForm, NULL);
+     destList = XVCMW("destList", listWidgetClass, destScroll, NULL);
+
+     XtSetKeyboardFocus(sendForm, editor);
+     getString = InitGetString(toplevel, "getStringWindow");
+
+     XtAppAddInput(app_con, ZGetFD(), (XtPointer)XtInputReadMask, zeph_dispatch, NULL);
+
+     if (defs.track_logins) {
+         XtAppAddWorkProc(app_con, (XtWorkProc)login_scan_work, NULL);
+     }
+
+     set_editor_width();
+     set_sendclose_width();
+     XtRealizeWidget(toplevel);
+}
+
+/* Action Procedures */     
+     
+/* ARGSUSED */
+static void Quit(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     XtDestroyApplicationContext(app_con);
+     ZCancelSubscriptions(0);
+     exit(0);
+}
+
+/* ARGSUSED */
+static void OpenSend(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     XtPopup(sendWindow, XtGrabNone);
+}
+
+/* ARGSUSED */
+static void CloseSend(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     XtPopdown(sendWindow);
+}
+
+/* ARGSUSED */
+static void SendMessage(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     send_message();
+}
+
+/* ARGSUSED */
+static void ClearEditor(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     edit_clear();
+}
+
+/* ARGSUSED */
+static void YankStore(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     edit_yank_store();
+}
+
+/* ARGSUSED */
+static void YankPrev(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     edit_yank_prev();
+}
+
+/* ARGSUSED */
+static void YankNext(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     edit_yank_next();
+}
+
+/* ARGSUSED */
+static void AlignParagraph(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+}
+
+/* ARGSUSED */
+static void SelectDest(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     select_dest();
+}
+
+/* ARGSUSED */
+static void DeleteDest(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     delete_dest();
+}
+
+/* ARGSUSED */
+static void HighlightDest(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+}
+
+/* ARGSUSED */
+static void CreateDest(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     create_dest();
+}
+
+/* ARGSUSED */
+static void OpenMenu(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     XtPopup(menuWindow, XtGrabNone);
+}
+
+/* ARGSUSED */
+static void ToggleOption(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     menu_toggle(w);
+}
+
+/* ARGSUSED */
+static void Signature(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     menu_signature();
+}
+
+/* ARGSUSED */
+static void CloseMenu(w, e, p, n)
+   Widget w;
+   XEvent *e;
+   String *p;
+   Cardinal *n;
+{
+     XtPopdown(menuWindow);
+}
+
+static void set_editor_width ()
+{
+  int w, c; char m = 'm';
+  XFontStruct *fs = (XFontStruct *) NULL;
+
+  c = defs.columns;
+  /* get the font structure. */
+  XtVaGetValues(editor, XtNfont, &fs, NULL);
+  if (c < 1 || fs == (XFontStruct *) NULL) return;
+
+  /* set the editor width */
+  w = c * XTextWidth(fs, &m, 1);
+  XtVaSetValues(editor, XtNwidth, (Dimension)w, NULL);
+  
+  /* set the destList to have 3/8ths the width of the editor */
+  /* an other idea would be to make it have 3/8ths as many characters,
+     which makes a difference when the editor and destList are in
+     different fonts.
+     however, I prefer this way. */
+  XtVaSetValues(destForm, XtNwidth, (Dimension)(w*3/8), NULL);
+}
+
+static void set_sendclose_width ()
+{
+  /* make the Close Window button the width of the form */
+  Dimension wi = 0;
+  XtRealizeWidget (sendWindow);
+  XtVaGetValues(sendForm, XtNwidth, &wi, NULL);
+  XtUnrealizeWidget (sendWindow);
+  XtVaSetValues(sendClose, XtNwidth, wi, NULL);
+}
diff --git a/zephyr/clients/xzwrite/logins.c b/zephyr/clients/xzwrite/logins.c
new file mode 100644 (file)
index 0000000..66fe825
--- /dev/null
@@ -0,0 +1,97 @@
+#include "xzwrite.h"
+
+#include <X11/Intrinsic.h>   /* for Boolean */
+#include <dyn.h>
+#include <zephyr/zephyr.h>
+
+extern Defaults defs;
+
+void logins_deal(notice)
+   ZNotice_t *notice;
+{
+     char              *newdest, *p;
+     int               d;
+
+     p = strchr(notice->z_class_inst, '@');
+     d = (p) ? p - notice->z_class_inst : strlen(notice->z_class_inst);
+     newdest = (char *) Malloc(d+1, "while dealing with login/logout notice",
+                              NULL);
+     strncpy(newdest, notice->z_class_inst, d);
+     newdest[d] = '\0';
+     
+     if (! strcmp(notice->z_opcode, "USER_LOGIN")) {
+         dest_add_string(newdest);
+         display_dest();
+     }
+     else if (! strcmp(notice->z_opcode, "USER_LOGOUT")) {
+         dest_delete_string(newdest);
+         display_dest();
+     }
+     else {
+         Warning("Invalid login/logout notice.  Opcode: ",
+                 notice->z_opcode, "\n", NULL);
+         free(newdest);
+     }
+}
+
+/* Considers a destination with a , and without a . in to be a username */
+void logins_subscribe()
+{
+     DestRec dest;
+     DynObject users;
+     char **list;
+     int num;
+
+     users = DynCreate(sizeof(char *), 0);
+     if (! users)
+         Error("Out of memory subscribing to logins", NULL);
+
+     list = dest_text();
+     num = dest_num();
+     while (--num) {
+         parse_into_dest(&dest, list[num]);
+         if (*dest.zrecip)
+              if (DynAdd(users, (DynPtr)(list + num)) != DYN_OK)
+                   Error("Out of memory subscribing to logins", NULL);
+     }
+
+     zeph_subto_logins((char **) DynGet(users, 0), DynSize(users));
+
+     DynDestroy(users);
+}
+
+/* ARGSUSED */
+Boolean login_scan_work(client_data)
+   caddr_t     client_data;
+{
+     static int        i, num, first = 1;
+     static DestRec dest = {"MESSAGE", "PERSONAL", ""};
+     static char **text;
+
+     if (first) {
+         text = dest_text();
+         num = dest_num();
+         i = first = 0;
+     }
+
+     if (i >= num)
+         return True;
+
+     if (strchr(text[i], ',') || strchr(text[i], '.')) {
+         i += 1;
+         return False; }
+
+     strcpy(dest.zrecip, text[i]);
+     if ((defs.pong_scan && zeph_pong(&dest) != SEND_OK) ||
+        (! defs.pong_scan && ! zeph_locateable(text[i]))) {
+         dest_delete_string(text[i]);
+         i -= 1;
+         num -= 1;
+         display_dest();
+     }
+     
+     i += 1;
+
+     return False;
+}
+
diff --git a/zephyr/clients/xzwrite/menu_window.c b/zephyr/clients/xzwrite/menu_window.c
new file mode 100644 (file)
index 0000000..2e11c90
--- /dev/null
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+#include <X11/Xaw/Toggle.h>
+
+#include "xzwrite.h"
+#include "GetString.h"
+
+extern Widget getString, clearOnSend, closeOnSend, pings, verbose,
+     authentic, yankDest, addGlobals, classInst;
+extern Defaults defs;
+
+#define toggle(v)      (v = !v)
+void menu_toggle(w)
+   Widget w;
+{
+     if (w == clearOnSend)
+         toggle(defs.clear_on_send);
+     else if (w == closeOnSend)
+         toggle(defs.close_on_send);
+     else if (w == pings)
+         toggle(defs.ping);
+     else if (w == verbose)
+         toggle(defs.verbose);
+     else if (w == authentic)
+         toggle(defs.auth);
+     else if (w == yankDest)
+         toggle(defs.yank_dest);
+     else if (w == addGlobals)
+         toggle(defs.add_globals);
+     else if (w == classInst)
+         toggle(defs.class_inst);
+     else
+         Warning("Unknown toggle widget, ignoring.", NULL);
+}
+#undef toggle
+
+#define set(w, i) XtVaSetValues(w, XtNstate, i ? True : False, NULL)
+void menu_match_defs()
+{
+     set(clearOnSend, defs.clear_on_send);
+     set(closeOnSend, defs.close_on_send);
+     set(pings, defs.ping);
+     set(verbose, defs.verbose);
+     set(authentic, defs.auth);
+     set(yankDest, defs.yank_dest);
+     set(addGlobals, defs.add_globals);
+     set(classInst, defs.class_inst);
+}
+#undef set
+
+void menu_signature()
+{
+     char buf[BUFSIZ];
+     int ret;
+
+     ret = GetString(getString, "Enter new signature:", defs.signature,
+                    0, buf, BUFSIZ);
+
+     if (ret != GETSTRING_ACCEPT)
+         return;
+     
+     /* XXX Is this safe? */
+     free(defs.signature);
+     defs.signature = (char *) Malloc(strlen(buf) + 1,
+                                     "while setting signature", NULL);
+     strcpy(defs.signature, buf);
+
+     /* Set the zephyr variable. */
+     ZSetVariable("zwrite-signature", buf);
+}
diff --git a/zephyr/clients/xzwrite/resource.c b/zephyr/clients/xzwrite/resource.c
new file mode 100644 (file)
index 0000000..2c9d64f
--- /dev/null
@@ -0,0 +1,129 @@
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+#include "xzwrite.h"
+
+String fallback_resources[] = {
+     "*icon.label: Cannot find xzwrite resource file.  Click to exit.",
+     "*icon.translations: #override \n <BtnDown>: Set() \n <BtnUp>: Quit()",
+     NULL,
+};
+
+XrmOptionDescRec app_options[] = {
+     {"+d","*auth", XrmoptionNoArg, (caddr_t) "true"},
+     {"-d","*auth", XrmoptionNoArg, (caddr_t) "false"},
+     {"-s","*signature", XrmoptionSepArg, (caddr_t) NULL},
+     {"+v","*verbose", XrmoptionNoArg, (caddr_t) "true"},
+     {"-v","*verbose", XrmoptionNoArg, (caddr_t) "false"},
+     {"-close","*closeOnSend", XrmoptionNoArg, (caddr_t) "false"},
+     {"+close","*closeOnSend", XrmoptionNoArg, (caddr_t) "true"},
+     {"-clear","*clearOnSend", XrmoptionNoArg, (caddr_t) "false"},
+     {"+clear","*clearOnSend", XrmoptionNoArg, (caddr_t) "true"},
+     {"+n","*ping", XrmoptionNoArg, (caddr_t) "true"},
+     {"-n","*ping", XrmoptionNoArg, (caddr_t) "false"},
+     {"+yd","*yankDest", XrmoptionNoArg, (caddr_t) "true"},
+     {"-yd","*yankDest", XrmoptionNoArg, (caddr_t) "false"},
+     {"+av","*addVars", XrmoptionNoArg, (caddr_t) "true"},
+     {"-av","*addVars", XrmoptionNoArg, (caddr_t) "false"},
+     {"+ci","*classInst", XrmoptionNoArg, (caddr_t) "true"},
+     {"-ci","*classInst", XrmoptionNoArg, (caddr_t) "false"},
+     {"-my","*maxYanks", XrmoptionSepArg, 0},
+     {"+l","*trackLogins", XrmoptionNoArg, (caddr_t) "true"},
+     {"-l","*trackLogins", XrmoptionNoArg, (caddr_t) "false"},
+     {"+x","*readXzwrite", XrmoptionNoArg, (caddr_t) "true"},
+     {"+z","*readZephyr", XrmoptionNoArg, (caddr_t) "true"},
+     {"+a","*readAnyone", XrmoptionNoArg, (caddr_t) "true"},
+     {"-x","*readXzwrite", XrmoptionNoArg, (caddr_t) "false"},
+     {"-z","*readZephyr", XrmoptionNoArg, (caddr_t) "false"},
+     {"-a","*readAnyone", XrmoptionNoArg, (caddr_t) "false"},
+     {"+pac", "*popupAtCursor", XrmoptionNoArg, (caddr_t) "true"},
+     {"-pac", "*popupAtCursor", XrmoptionNoArg, (caddr_t) "false"},
+     {"-mask", "*commandMask", XrmoptionSepArg, (caddr_t) 0},
+     {"-debug", "*debug", XrmoptionNoArg, (caddr_t) "true"},
+     {"-opcode", "*opcode", XrmoptionSepArg, (caddr_t) ""},
+     {"+pong", "*pongScan", XrmoptionNoArg, (caddr_t) "true"},
+     {"-pong", "*pongScan", XrmoptionNoArg, (caddr_t) "false"},
+     {"+reply", "*autoReply", XrmoptionNoArg, (caddr_t) "true"},
+     {"-reply", "*autoReply", XrmoptionNoArg, (caddr_t) "false"},
+     {"-columns", "*columns", XrmoptionSepArg, (caddr_t) 80},
+     {"-zsigs", "*randomZsigFile", XrmoptionSepArg, (caddr_t) "*"},
+     {"-logfile", "*logFile", XrmoptionSepArg, (caddr_t) "*"},
+};
+
+#define offset(field) XtOffset(Defaults *, field)
+XtResource app_resources[] = {
+     {"auth", "Auth", XtRBoolean, sizeof(Boolean), 
+      offset(auth), XtRString, "true"}, 
+
+     {"yankDest", "YankDest", XtRBoolean, sizeof(Boolean), 
+      offset(yank_dest), XtRString, "false"}, 
+
+     {"addGlobals", "AddGlobals", XtRBoolean, sizeof(Boolean), 
+      offset(add_globals), XtRString, "false"}, 
+
+     {"signature", "Signature", XtRString, sizeof(String), 
+      offset(signature), XtRString, ""}, 
+
+     {"verbose", "Verbose", XtRBoolean, sizeof(Boolean), 
+      offset(verbose), XtRString, "false"}, 
+
+     {"closeOnSend", "Close", XtRBoolean, sizeof(Boolean), 
+      offset(close_on_send), XtRString, "false"}, 
+
+     {"clearOnSend", "Close", XtRBoolean, sizeof(Boolean), 
+      offset(clear_on_send), XtRString, "false"}, 
+
+     {"ping", "Ping", XtRBoolean, sizeof(Boolean), 
+      offset(ping), XtRString, "true"}, 
+
+     {"classInst", "ClassInst", XtRBoolean, sizeof(Boolean), 
+      offset(class_inst), XtRString, "true"}, 
+
+     {"maxYanks", "MaxYanks", XtRInt, sizeof(int), 
+      offset(max_yanks), XtRString, "25"}, 
+
+     {"trackLogins", "TrackLogins", XtRBoolean, sizeof(Boolean), 
+      offset(track_logins), XtRString, "false"}, 
+
+     {"readZephyr", "ReadFile", XtRBoolean, sizeof(Boolean), 
+      offset(read_zephyr), XtRString, "false"}, 
+
+     {"readAnyone", "ReadFile", XtRBoolean, sizeof(Boolean), 
+      offset(read_anyone), XtRString, "false"}, 
+
+     {"readXzwrite", "ReadFile", XtRBoolean, sizeof(Boolean), 
+      offset(read_xzwrite), XtRString, "false"}, 
+
+     {"popupAtCursor", "PopupAtCursor", XtRBoolean, sizeof(Boolean), 
+      offset(popup_cursor), XtRString, "false"}, 
+
+     {"commandMask", "CommandMask", XtRInt, sizeof(int), 
+      offset(command_mask), XtRString, "0"}, 
+
+     {"debug", "Debug", XtRBoolean, sizeof(Boolean), 
+      offset(debug), XtRString, "false"},
+
+     {"opcode", "Opcode", XtRString, sizeof(String),
+      offset(opcode), XtRString, ""},
+
+     {"pongScan", "PongScan", XtRBoolean, sizeof(Boolean),
+      offset(pong_scan), XtRString, "true"},
+
+     {"autoReply", "AutoReply", XtRBoolean, sizeof(Boolean),
+      offset(auto_reply), XtRString, "false"},
+
+     {"columns", "Columns", XtRInt, sizeof(int),
+       offset(columns), XtRString, "80"},
+     
+     {"randomZsigFile", "RandomZsigFile", XtRString, sizeof(String),
+       offset(zsigfile), XtRString, "*"},
+
+     {"logFile", "LogFile", XtRString, sizeof(String),
+       offset(logfile), XtRString, "*"},
+};
+#undef offset
+
+/* These are necessary because XtNumber uses sizeof, and these arrays
+ * are declared as extern in interface.c */
+unsigned int num_options = XtNumber(app_options);
+unsigned int num_resources = XtNumber(app_resources);
diff --git a/zephyr/clients/xzwrite/util.c b/zephyr/clients/xzwrite/util.c
new file mode 100644 (file)
index 0000000..f52ee7e
--- /dev/null
@@ -0,0 +1,91 @@
+#include <stdio.h>
+#include <pwd.h>
+
+#include "xzwrite.h"
+
+#ifdef __STDC__
+void Warning(const char *first, ...)
+#else
+/*VARARGS*/
+void Warning(first, va_alist)
+   const char  *first;
+   va_dcl
+#endif
+{
+     va_list   vp;
+     char      *s;
+     
+     fputs(first, stderr);
+
+     VA_START(vp, first);
+     while ((s = va_arg(vp, char *)) != NULL)
+         fputs(s, stderr);
+     va_end(vp);
+     putc('\n', stderr);
+}
+
+#ifdef __STDC__
+void Error(const char *first, ...)
+#else
+/*VARARGS*/
+void Error(first, va_alist)
+   const char *first;
+   va_dcl
+#endif
+{
+     va_list   vp;
+     char      *s;
+     
+     fputs(first, stderr);
+
+     VA_START(vp, first);
+     while ((s = va_arg(vp, char *)) != NULL)
+         fputs(s, stderr);
+     va_end(vp);
+     putc('\n', stderr);
+
+     exit(1);
+}
+
+#ifdef __STDC__
+char *Malloc(int n, ...)
+#else
+/*VARARGS*/
+char *Malloc(n, va_alist)
+   int n;
+   va_dcl
+#endif
+{
+     va_list   vp;
+     char      *ptr, *s;
+
+     ptr = (char *) malloc((unsigned) n);
+     if (ptr)
+         return ptr;
+
+     fputs("Out of memory: ", stderr);
+
+     VA_START(vp, n);
+     while ((s = va_arg(vp, char *)) != NULL)
+         fputs(s, stderr);
+     va_end(vp);
+     putc('\n', stderr);
+
+     exit(1);
+}
+
+char *get_username()
+{
+     struct passwd *pwuid;
+     static char *u = NULL;
+
+     if (u) return u;
+
+     if ((u = getenv("USER")) != NULL) return u;
+
+     pwuid = getpwuid(getuid());
+     if (pwuid)
+       return u = pwuid->pw_name;
+     else
+       return NULL;
+}
diff --git a/zephyr/clients/xzwrite/xzwrite-proto.h b/zephyr/clients/xzwrite/xzwrite-proto.h
new file mode 100644 (file)
index 0000000..baeccca
--- /dev/null
@@ -0,0 +1,104 @@
+#ifndef __P
+#ifdef __STDC__
+# define       __P(s) s
+#else
+# define __P(s) ()
+#endif
+#endif
+
+
+/* interface.c */
+void go __P((void ));
+void build_interface __P((int *argc , char **argv ));
+
+/* resource.c */
+
+/* destlist.c */
+void dest_print __P((void ));
+char **dest_text __P((void ));
+int dest_num __P((void ));
+void dest_set_current_dest __P((Dest dest ));
+void dest_init __P((void ));
+char **load_default_dest __P((void ));
+char **dest_add __P((Dest dest ));
+char **dest_add_string __P((char *s ));
+char **dest_delete_string __P((char *s ));
+char **delete_dest_index __P((int i ));
+char **sort_destinations __P((void ));
+int parse_into_dest __P((Dest dest , char *s ));
+void dest_add_reply __P((ZNotice_t *notice ));
+
+/* util.c */
+void Warning __P((const char *first, ...));
+void Error __P((const char *first, ...));
+char *Malloc __P((int n, ...));
+char *get_username __P((void ));
+
+/* bfgets.c */
+char *bfgets __P((char *s , int n , FILE *iop ));
+
+/* gethomedir.c */
+char *get_home_dir __P((void ));
+
+/* dest_window.c */
+void dest_add_reply __P((ZNotice_t *notice ));
+void display_dest __P((void ));
+void delete_dest __P((void ));
+void create_dest __P((void ));
+void select_dest __P((void ));
+
+/* xzwrite.c */
+int main __P((int argc , char **argv ));
+void usage __P((void ));
+
+/* edit_window.c */
+void edit_win_init __P((void ));
+void send_message __P((void ));
+void edit_set_title __P((Dest dest ));
+void edit_clear __P((void ));
+void edit_yank_prev __P((void ));
+void edit_yank_next __P((void ));
+void edit_yank_store __P((void ));
+
+/* zephyr.c */
+void zeph_dispatch __P((XtPointer client_data , int *source , XtInputId *input_id ));
+void zeph_init __P((void ));
+int zeph_locateable __P((char *user ));
+void zeph_subto_logins __P((char **users , int num ));
+void zeph_subto_replies __P((void ));
+int zeph_send_message __P((Dest dest , char *msg ));
+int zeph_ping __P((Dest dest ));
+int zeph_pong __P((Dest dest ));
+char *zeph_get_signature __P((void ));
+void log_message __P((Dest dest , char *msg ));
+
+/* GetString.c */
+Widget InitGetString __P((Widget parent , char *name ));
+int GetString __P((Widget getStringWindow , String label , String value , int pop_type , char *buf , int len ));
+
+/* Popup.c */
+void Popup __P((Widget shell , XtGrabKind GrabType , int pop_type ));
+void PopupSafe __P((Widget w , Dimension x , Dimension y , XtGrabKind GrabType ));
+void PopupAtPointer __P((Widget w , XtGrabKind GrabType ));
+
+/* yank.c */
+void yank_init __P((void ));
+Yank yank_prev __P((void ));
+Yank yank_next __P((void ));
+void yank_store __P((Dest dest , char *msg ));
+
+/* menu_window.c */
+void menu_toggle __P((Widget w ));
+void menu_match_defs __P((void ));
+void menu_signature __P((void ));
+
+/* logins.c */
+void logins_deal __P((ZNotice_t *notice ));
+void logins_subscribe __P((void ));
+Boolean login_scan_work __P((caddr_t client_data ));
+
+/* xzwrite.h */
+
+/* GetString.h */
+
+#undef P
diff --git a/zephyr/clients/xzwrite/xzwrite.1 b/zephyr/clients/xzwrite/xzwrite.1
new file mode 100644 (file)
index 0000000..20f3cd8
--- /dev/null
@@ -0,0 +1,407 @@
+.TH XZWRITE 1 "7 February 1989"
+.SH NAME
+xzwrite \- X application to write to another user via Zephyr
+.SH SYNOPSIS
+.B xzwrite 
+[ -toolkitoption ... ] [-s signature] [+d | -d] [+n | -n] [+v | -v]
+[+yd | -yd] [+av | -av] [+ci | -ci] [-my yanks] [+l | -l] [+a | -a]
+[+x | -x] [+z | -z] [+pong | -pong] [+reply | -reply]
+
+.SH DESCRIPTION
+.I Xzwrite
+is an X application that sends messages to other users
+through the 
+.IR Zephyr (1)
+notification service.  It puts an icon on the
+screen that allows the user to send a message, select the destination
+of a message, or exit.  The program remains active until explicity
+told to exit, thus eliminating the need to run a program every time
+the user wants to send a zephyr message.
+.SH USING THE DESTINATION LIST
+.PP
+.I Xzwrite 
+maintains a list of 'destinations'; that is, a list of
+<class, instance, recipient> triples that a user can send messages to.
+When a user selects a destination, all subsequent messages will be
+sent to that triple, until a new destination is selected.  
+.I Xzwrite
+can get its list of destinations from the files .xzwrite.dest,
+.anyone, or .zephyr.vars in the
+user's home directory.  These files must consist of a list of lines, and
+each is interpreted in the following way: a line containing no commas
+is taken to mean <MESSAGE,PERSONAL,string>; a line with one comma is
+taken to be either <class,instance,*> or <MESSAGE,instance,recipient>
+depending on the value of the classInst resource (see below); a line
+with two commas is taken to be <class,instance,recipient>.  A line
+that begins with an exclamation point (!) is treated as an
+"unsubscription" and has the effect of removing destinations read
+from any other file that match the destination on that line.  The lines
+must appear
+.B WITHOUT WHITESPACE 
+between the fields and with a linefeed between each line.  Blank lines
+and lines beginning with an octothorpe (#) are ignored.
+.PP
+
+Clicking the left button in the 
+.I xzwrite 
+icon pops up the editor and
+destination list.  Clicking with the left button in the destination
+list selects the highlighted destination; clicking with the right
+button deletes the highlighed destination.  Clicking the middle button
+invokes the action CreateDest (see ACTIONS below) that prompts the
+user for a new <class,instance,recipient> triple to be added to the list.
+
+.PP
+
+If the user specifies a destination in the .xzwrite.dest file
+with an instance or recipient of "...", 
+.I xzwrite 
+will prompt the user to enter an instance or recipient when the
+message editor is popped up.  Setting both instance and recipient to
+"..." (ie: <MESSAGE,...,...>) works.  The new
+<class,instance,recipient> triple formed each time a destination with
+"..." is used may or may not be added to the destination list, depending
+on the addVars resource (see below.)
+
+.PP
+
+While the mouse pointer is inside the 
+.I xzwrite 
+icon, the mouse buttons have the following effect:
+.TP
+.B Left button:        
+Pops up the editor and destination list so the user can create and 
+send messages.
+.TP
+.B Right button:
+Pops up a list of things that can be changed while xzwrite is running.
+Clicking the "Change Signature" box causes
+.I xzwrite
+to prompt for a new signature, to be used in future messages.  All the
+others toggle options which are initially set by resources or
+command-line arguments.  The "Quit XZWRITE" causes 
+.I xzwrite
+to exit.
+.TP
+.B Ctrl-Right button:
+Exits
+.IR xzwrite .
+
+.SH USING THE MESSAGE EDITOR
+There are four buttons in the message editor.  The Send button
+sends the text currently in the message editor to the current
+destination, optionally clearing the message editor at the same time.
+The Clear Editor button clears the message editor.  The Yank-Prev button yanks
+the previous message, along with its destination, into the message
+editor.  The Yank-Next button yanks the next message (or the first
+message in the yank buffer, if Yank-Prev has not been called) into the
+message editor.  The yank buffer is circular, so old messages are
+periodically overwritten by new ones, and stores the previous (by
+default) 25 messages.
+.PP
+The following key sequences have been defined for convenience:
+.PP
+.nf
+       Ctrl-Return             Send message
+       Meta-O                  Store current message, yank previous
+       Meta-P                  Yank Previous
+       Meta-N                  Yank Next
+
+.SH OPTIONS
+
+.I Xzwrite 
+will accept all X Toolkit command-line options and
+resource database specifications, under the name 'XZwrite'; for more
+information, see 
+.IR X (1). 
+The instance names of the different parts of
+.I xzwrite 
+are as follows (each should be preceded by XZwrite* in the
+user's .Xresources file.  For examples of how to use these resource
+names, look in /usr/athena/lib/zephyr/XZwrite.) 
+
+.nf
+ toplevel - the top level shell
+      icon - the top level "Z" icon
+
+ sendWindow - the popup shell for the editor/destlist
+      sendForm - the form holding the edit tree and dest tree
+      sendClose - button to close sendWindow
+
+      editPane - the pane holding editor widgets
+              editTitle - the label holding the zephyr triple
+              editForm - the box holding editor command buttons
+                      editSend - button to send message
+                      editClear - button to clear editor
+                      editPrev - button to yank previous
+                      editNext - button to yank next
+              editor - the text editor
+
+      destForm - the form holding the destinations list/button
+              destScroll - the scrollbar holding the list
+                      destList - the destination list
+
+ menuWindow - the popup shell for the menu
+      menuForm - the form holding the menu list/button
+              menuClose - the Close Window button for the dest list
+              signature - button to change signature
+              closeOnSend
+              pings
+              verbose
+              authentic
+              yankDest
+              addGlobals
+              classInst
+              exitProgram
+
+ getStringWindow - the popup shell for dialog boxes (GetString.c)
+      getStringForm - the form containing the dialog widgets
+              getStringTitle - the title label width
+              getStringEdit - the text editor
+              getStringAccept - the accept button
+              getStringCancel - the cancel button
+
+.fi
+
+.PP
+In addition, 
+.I xzwrite 
+will accept the following command-line options
+(or resource database specifications).  Each should be preceded by
+XZwrite* in the user's .Xresources file.  When a command-lie
+.TP
+.B +d (auth = true)
+.br
+.ns
+.HP 5
+.B -d (auth = false)
+.br
+When true, Zephyr messages to be sent authentic.  When false, Zephyr
+messages are sent unauthentic.
+.TP
+.B +v (verbose = true)
+.br
+.ns
+.HP 5
+.B -v (verbose = false)
+.br
+When true, causes
+.I xzwrite
+to inform the user no one received a sent message by beeping.  This
+is useful if the user wants to know if someone logged out between
+the time when the editor is popped up (when a PING is sent) and when
+the message is actually sent. 
+.TP
+.B +z (readZephyr = true)
+.br
+.ns
+.HP 5
+.B -z (readZephyr = false)
+.br
+When true, causes 
+.I xzwrite 
+to include the .zephyr.subs file for its initial list of destinations. 
+.TP
+.B +a (readAnyone = true)
+.br
+.ns
+.HP 5
+.B -a (readAnyone = false)
+.br
+When true, causes
+.I xzwrite
+to include the user's .anyone file for its initial list of destinations.
+.TP
+.B +x (readXzwrite = true)
+.br
+.ns
+.HP 5
+.B -x (readXzwrite = false)
+.br
+When true, causes
+.I xzwrite
+to include the user's .xzwrite.dest file for its initial list of destinations.
+.TP
+.B +l (trackLogins = true)
+.br
+.ns
+.HP 5
+.B -l (trackLogins = false)
+.br
+When true, 
+.I xzwrite 
+determines (at startup) if each username on the destination
+list is logged on and removes those usernames that are not.  It then
+subscribes to login and logout messages for each
+username on the list, and keeps the destination list up to date with
+respect to which users are zwrite-able.
+.TP
+.B +pong (pongScan = true)
+.br
+.ns
+.HP 5
+.B -pong (pongScan = false)
+.br
+Controls the method
+.I xzwrite
+uses determine whether a certain user is logged in.  If true, 
+.I xzwrite
+sends a notice with an opcode of PING (and a message body of PONG) and
+awaits a response; if false,
+.I xzwrite
+performs a "zlocate".  Note that this resource is only used when
+trackLogins is true.
+.TP
+.B -s (signature)
+Specifies the 'signature' for all messages sent.  The signature will
+appear as the first field in every message sent.
+.I Xzwrite
+will also look in the user's .zephyr.vars file to a signature, first
+for the variable xzwrite-signature and then for the variable
+zwrite-signature.  If neither is found, 
+.I Xzwrite
+will look in the /etc/passwd file for the user's name.
+.TP
+.B +n (ping = true)
+.br
+.ns
+.HP 5
+.B -n (ping = false)
+.br
+When ping is set to true,
+.I xzwrite
+sends a PING to the destination when it is initially selected.
+.I Xzwrite
+uses the PING to determine if anyone will actually receive a message
+sent to that destination, and will not allow it to be selected if not.
+.TP
+.B +ci (classInst = true)
+.br
+.ns
+.HP 5
+.B -ci (classInst = false)
+.br
+When ci is set to true, a destination that contains two strings
+separated by a comma is interpreted as a class and instance, with
+a recipient of "*".  When it is false, the same string is interpreted
+as an instance and recipient, with a class of MESSAGE.
+.TP
+.B +yd (yankDest = true)
+.br
+.ns
+.HP 5
+.B -yd (yankDest = false)
+.br
+When yd is set to true, yanking a previous message in the message editor
+also restores the original destination of the message.  When set to false,
+only the message text is yanked, and the current destination remains
+unchanged.
+.TP
+.B +av (addVars = true)
+.br
+.ns
+.HP 5
+.B -av (addVars = false)
+.br
+When av is set to true, destinations that are specified as the result
+of a recipient or instance of "..." are added to the destinations list
+so they can be selected again.
+.TP
+.B +reply (autoReply = true)
+.br
+.ns
+.HP 5
+.B -reply (autoReply = false)
+.br
+When autoReply is set to true, xzwrite subscribes to <MESSAGE,*,%me%>
+(in other words, all messages sent directly to the user).  Each time
+such a message is received, a destination that will reply to the
+sender on the same instance is added to the destination list, if it is
+not already there.
+
+.SH ACTIONS
+
+Every useful action that 
+.I xzwrite
+can perform can be bound to any sequence of X events through the
+mechanism of translation tables.  The following action procedures
+available to the user.
+.PP
+.nf
+  OpenSend
+  CloseSend
+     Pops up/Pops down the message editor/destination list.  
+
+  SendMessage
+     Sends the message in the editor to the current destination.
+
+  ClearEditor
+     Clears the editor.
+
+  YankStore
+     Stores the contents in the message editor in the Yank buffer.
+
+  YankPrev
+  YankNext
+     Puts the previous/next item in the yank buffer into the editor,
+     optionally restoring the destination as well.
+
+  SelectDest
+  DeleteDest
+     Selects/deletes the hightlighed destination.
+
+  CreateDest
+     Prompts the user for a <class,instance,recipient> triple to
+     be added to the destinations list.
+
+  OpenMenu
+  CloseMenu
+     Pops up/Pops down the options menu.
+
+  ToggleOption
+     Toggles the option corresponding to the hightlighed item on the
+     options menu.
+
+  Signature
+     Pops up a dialog box and changes the Zephyr signature to whatever
+     is typed into it.
+
+For examples on how to use these action procedures, look in
+/usr/athena/lib/zephyr/XZwrite.
+
+.SH FILES
+.TP
+/usr/athena/lib/zephyr/xzwrite.bitmap
+Default icon bitmap
+.TP
+/usr/athena/lib/zephyr/XZwrite
+Xzwrite program defaults
+.TP
+/etc/passwd
+Signature field (from gecos information)
+.TP
+~/.Xresources
+user X resources database file
+.TP
+~/.xzwrite.dest
+The user's xzwrite destinations list.
+~/.anyone
+The user's .anyone file.
+~/.zephyr.subs
+The user's zephyr subscription file.
+.SH SEE ALSO
+X(1), zephyr(1)
+
+.SH BUGS
+
+.I xzwrite
+occasionally decided to ignore the state of the "Pings" and
+"Authentic" menu options, unless you happen to be running the program
+under a debugger.
+
+This man page contains many errors and omissions.
+
+.SH AUTHOR
+
+Written by Barry Jaspan (bjaspan@mit.edu), MIT Project Athena
+and MIT Student Information Processing Board.
diff --git a/zephyr/clients/xzwrite/xzwrite.bitmap b/zephyr/clients/xzwrite/xzwrite.bitmap
new file mode 100644 (file)
index 0000000..2accd67
--- /dev/null
@@ -0,0 +1,6 @@
+#define z_width 16
+#define z_height 16
+static char z_bits[] = {
+   0xff, 0xff, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c, 0x00, 0x0e, 0x00, 0x07,
+   0x80, 0x03, 0xc0, 0x01, 0xe0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1c, 0x00,
+   0x0e, 0x00, 0x07, 0x00, 0xff, 0xff, 0xff, 0xff};
diff --git a/zephyr/clients/xzwrite/xzwrite.c b/zephyr/clients/xzwrite/xzwrite.c
new file mode 100644 (file)
index 0000000..318e5e9
--- /dev/null
@@ -0,0 +1,122 @@
+#include <stdio.h>
+#include <string.h>
+#include <pwd.h>
+#include <dyn.h>
+
+#include "xzwrite.h"
+
+extern Defaults defs;
+DynObject zsigs = NULL;
+
+static void set_signature __P((void));
+static Boolean set_random_zsigs __P((void));
+
+int main(argc, argv)
+   int argc;
+   char        **argv;
+{
+     zeph_init();
+
+     build_interface(&argc, argv);
+
+     if (argc > 1) usage();
+
+     set_signature();
+     dest_init();
+     yank_init();
+     edit_win_init();
+     menu_match_defs();
+     (void) load_default_dest();
+     display_dest();
+
+     if (defs.track_logins)
+         logins_subscribe();
+     if (defs.auto_reply)
+         zeph_subto_replies();
+
+     go();
+     return 0;
+}
+
+static void set_signature()
+{
+     char *sig, sigbfr[BUFSIZ];
+     
+     /* Do magic with signature */
+     if (defs.zsigfile)
+       if (strcmp(defs.zsigfile, "*"))
+        if (set_random_zsigs()) return;
+
+     if (*defs.signature)
+         return;
+
+     sig = (char *) zeph_get_signature();
+     if (!sig) {
+         /* try to find name in the password file */
+         register struct passwd *pwd;
+         register char *cp = sigbfr;
+         register char *cp2, *pp;
+         
+         pwd = getpwuid(getuid());
+         if (pwd) {
+              cp2 = pwd->pw_gecos;
+              for (; *cp2 && *cp2 != ',' ; cp2++) {
+                   if (*cp2 == '&') {
+                        pp = pwd->pw_name;
+                        *cp++ = islower(*pp) ? toupper(*pp) : *pp;
+                        pp++;
+                        while (*pp)
+                             *cp++ = *pp++;
+                   } else
+                        *cp++ = *cp2;
+              }
+              *cp = '\0';
+              sig = sigbfr;
+         }
+     } 
+     
+     if (sig) {
+         defs.signature = (char *) Malloc(strlen(sig) + 1,
+                                          "getting signature",
+                                          NULL);
+         strcpy(defs.signature, sig);
+     }
+}
+        
+
+
+void usage()
+{
+     fprintf(stderr, "Usage:  xzwrite [ -toolkitoption ... ] [-s signature] [+d | -d] [+n | -n]\n\t[+v | -v] [+yd | -yd] [+av | -av] [+ci | -ci] [-my yanks]\n\t[+l | -l] [+a | -a] [+x | -x] [+z | -z] [+pong | -pong] [+reply | -reply]\n");
+     exit(1);
+}
+
+#define BUF_SIZE 1024
+
+static Boolean set_random_zsigs()
+{ int x, n;
+  char z[BUF_SIZE], *z2;
+  FILE *fp;
+
+  fp = fopen(defs.zsigfile, "r");
+  if (!fp) {
+    fprintf(stderr, "xzwrite: cant open file \"%s\".\n", defs.zsigfile);
+    return False; }
+  
+  zsigs = DynCreate(sizeof(char*), 5);
+  
+  while ( fgets(z, BUF_SIZE, fp) != NULL) {
+    if (z[0] == '#' || z[0] == 0) continue;
+    n = strlen(z);
+    z2 = (char *) calloc (sizeof(char), n);
+    if (!z2) {
+      fprintf(stderr, "xzwrite: out of memory.\n"); exit(1); }
+    if (z[n-1] == '\n') { n--; z[n] = 0; }
+    for (x = 0; x <= n; x++) {
+      if (z[x] != '\\') z2[x] = z[x];
+      else z2[x] = '\n'; }
+    DynAdd(zsigs, (DynPtr) &z2); }
+
+  fclose(fp);
+  return True;
+}
diff --git a/zephyr/clients/xzwrite/xzwrite.h b/zephyr/clients/xzwrite/xzwrite.h
new file mode 100644 (file)
index 0000000..a9b020b
--- /dev/null
@@ -0,0 +1,52 @@
+#include <sysdep.h>
+#include <X11/Intrinsic.h>     /* for String and Boolean */
+
+#define ZLEN           60
+#define DEFAULT_CLASS  "MESSAGE"
+#define DEFAULT_INST   "PERSONAL"
+#define XZWRITE_DEST_FILE "/.xzwrite.dest"
+#define ZEPHYR_FILE    "/.zephyr.subs"
+#define ANYONE_FILE    "/.anyone"
+
+#define SEND_OK                -1000
+#define SENDFAIL_RECV  -1001
+#define SENDFAIL_SEND  -1002
+#define SENDFAIL_ACK   -1003
+
+/* Structure to contains values from the resource database */
+typedef struct _defaults {
+     String signature, opcode;
+     Boolean auth;
+     Boolean close_on_send;
+     Boolean clear_on_send;
+     Boolean ping;
+     Boolean verbose;
+     Boolean yank_dest;
+     Boolean add_globals;
+     Boolean read_xzwrite;
+     Boolean read_zephyr;
+     Boolean read_anyone;
+     Boolean class_inst;
+     Boolean track_logins;
+     Boolean popup_cursor;
+     Boolean debug;
+     Boolean pong_scan;
+     Boolean auto_reply;
+     int max_yanks, command_mask, columns;
+     String  zsigfile;
+     String  logfile;
+} Defaults;
+
+/* Structure to contain a legal zephyr triple */
+typedef struct _destination {
+     char zclass[ZLEN], zinst[ZLEN], zrecip[ZLEN];
+} DestRec, *Dest;
+
+/* Structure to contain a yank */
+typedef struct _yank {
+     DestRec dest;
+     char *msg;
+} YankRec, *Yank;
+
+#include <zephyr/zephyr.h>
+#include "xzwrite-proto.h"
diff --git a/zephyr/clients/xzwrite/yank.c b/zephyr/clients/xzwrite/yank.c
new file mode 100644 (file)
index 0000000..bb580f1
--- /dev/null
@@ -0,0 +1,58 @@
+#include "xzwrite.h"
+
+static Yank yank_buffer;
+extern Defaults defs;
+
+static int read_index, write_index, highest;
+
+void yank_init()
+{
+     yank_buffer = (Yank) Malloc(defs.max_yanks*sizeof(YankRec),
+                                  "while allocating yank buffer", NULL);
+     (void) memset((char *) yank_buffer, 0, defs.max_yanks*sizeof(YankRec));
+
+     read_index = write_index = 0;
+     highest = -1;
+}
+
+Yank yank_prev()
+{
+     if (highest == -1)
+         return NULL;
+     
+     if (--read_index < 0) read_index = highest;
+     return &yank_buffer[read_index];
+}
+
+Yank yank_next()
+{
+     if (highest == -1)
+         return NULL;
+     
+     if (++read_index > highest) read_index = 0;
+     return &yank_buffer[read_index];
+}
+
+void yank_store(dest, msg)
+   Dest dest;
+   char *msg;
+{
+     yank_buffer[write_index].dest = *dest;
+     if (yank_buffer[write_index].msg)
+        free(yank_buffer[write_index].msg);
+     yank_buffer[write_index].msg = (char *) Malloc(strlen(msg) + 1,
+                                                   "while yanking message",
+                                                   NULL);
+     strcpy(yank_buffer[write_index].msg, msg);
+
+     /*
+      * read_index  = write_index + 1 so that if I follow the store by
+      * a yank_prev I will get the message just stored (since
+      * read_index is decremented before being used).  If I do a
+      * yank_next, then read_index will be > highest and reset to zero.
+      */
+     read_index = write_index + 1;
+     if (write_index > highest)
+         highest = write_index;
+     write_index = (write_index + 1) % defs.max_yanks;
+}
diff --git a/zephyr/clients/xzwrite/zephyr.c b/zephyr/clients/xzwrite/zephyr.c
new file mode 100644 (file)
index 0000000..6e25dd5
--- /dev/null
@@ -0,0 +1,285 @@
+#include "xzwrite.h"
+#include <string.h>
+#include <dyn.h>
+#include <com_err.h>
+
+#include <zephyr/zephyr.h>
+
+static int zeph_send_notice();
+extern Defaults defs;
+extern DynObject zsigs;
+
+/* ARGSUSED */
+void zeph_dispatch(client_data, source, input_id)
+   XtPointer client_data;
+   int *source;
+   XtInputId *input_id;
+{
+     ZNotice_t notice;
+     struct sockaddr_in from;
+     int ret;
+
+     while (ZPending() > 0) {
+         ret = ZReceiveNotice(&notice, &from);
+         if (ret != ZERR_NONE) {
+              Warning(error_message(ret), " while receiving Zephyr notice.",
+                      NULL);
+              continue;
+         }
+
+         if (defs.track_logins &&
+             (! strcmp(notice.z_opcode, "USER_LOGIN") ||
+              ! strcmp(notice.z_opcode, "USER_LOGOUT")))
+              logins_deal(&notice);
+
+         else if (defs.auto_reply &&
+                  ! strcasecmp(notice.z_class, DEFAULT_CLASS) &&
+                  ! strcasecmp(notice.z_recipient, ZGetSender()))
+              dest_add_reply(&notice);
+         
+         /* Handle the zlocating bug the Zephyr library explicitly. */
+         /* Only display bogon zlocate packets in debug mode */
+         else if (strcmp(notice.z_class, LOCATE_CLASS) || defs.debug) {
+              Warning("XZwrite: Unexpected notice received.  ",
+                      "You can probably ignore this.\n",
+                      "To: <", notice.z_class, ", ",
+                      notice.z_class_inst, ", ", (*notice.z_recipient) ?
+                      notice.z_recipient : "*", ">\n",
+                      "From: ", notice.z_sender, "\nOpcode: ",
+                      notice.z_opcode, "\nMessage: ", notice.z_message,
+                      "\n", NULL);
+         }
+         
+         ZFreeNotice(&notice);
+     }
+}
+
+void zeph_init()
+{
+     int       retval;
+     
+     retval = ZInitialize();
+     if (retval != ZERR_NONE)
+         Error("Cannot initialize the Zephyr library.", NULL);
+
+     retval = ZOpenPort(NULL);
+     if (retval != ZERR_NONE)
+         Error("Cannot open Zephyr port.", NULL);
+}
+
+int zeph_locateable(user)
+   char *user;
+{
+     char      buf[BUFSIZ];
+     int   n;
+
+     if (strchr(user, '@') == NULL)
+         sprintf(buf, "%s@%s", user, ZGetRealm());
+     ZLocateUser(buf, &n, ZAUTH);
+     return (!! n);
+}
+
+/* XXX This will break on interrealm zephyr */
+void zeph_subto_logins(users, num)
+   char **users;
+   int num;
+{
+     ZSubscription_t   *sublist;
+     char              *name, *realm;
+     int               rlen, c = 0;
+
+     realm = ZGetRealm();
+     rlen = strlen(realm);
+     sublist = (ZSubscription_t *) Malloc(num*sizeof(ZSubscription_t),
+                                         "while subscribing to logins", NULL);
+
+     while (c < num) {
+         sublist[c].zsub_class = "login";
+         sublist[c].zsub_recipient = "";
+         name = (char *) Malloc(strlen(users[c])+rlen+2,
+                                "while subscribing to login, ", users[c],
+                                NULL);
+         if (strchr(users[c], '@'))
+              sprintf(name, "%s", users[c]);
+         else
+              sprintf(name, "%s@%s", users[c], realm);
+         sublist[c].zsub_classinst = name;
+         c += 1;
+     }
+
+     ZSubscribeToSansDefaults(sublist, c, (unsigned short) 0);
+     for(; c; --c)
+         free(sublist[c-1].zsub_classinst);
+     free(sublist);
+}
+
+void zeph_subto_replies()
+{
+     ZSubscription_t sub;
+
+     sub.zsub_class = "message";
+     sub.zsub_classinst = "*";
+     sub.zsub_recipient = ZGetSender();
+
+     ZSubscribeToSansDefaults(&sub, 1, (unsigned short) 0);
+}
+
+int zeph_send_message(dest, msg)
+   Dest        dest;
+   char        *msg;
+{
+     ZNotice_t notice;
+     int       msglen, siglen, ret;
+     char      *sig_msg, *sig;
+
+     if (!zsigs) sig = defs.signature;
+     else {
+       char **tmp;
+       tmp = (char **) DynGet (zsigs, rand() % DynSize(zsigs));
+       sig = *tmp; }
+
+     msglen = strlen(msg);
+     siglen = strlen(sig);
+     sig_msg = (char *) Malloc(msglen + siglen + 2, "while sending message",
+                              NULL);
+     sprintf(sig_msg, "%s%c%s", sig, '\0', msg);
+          
+     memset((char *) &notice, 0, sizeof(ZNotice_t));
+     notice.z_kind = ACKED;
+     notice.z_class = dest->zclass;
+     notice.z_class_inst = dest->zinst;
+     notice.z_recipient = dest->zrecip;
+     notice.z_sender = 0;
+     notice.z_opcode = defs.opcode;
+     notice.z_port = 0;
+     notice.z_message = sig_msg;
+     notice.z_message_len = msglen + siglen + 1;
+
+     /* This really gross looking mess is brought to you by zwrite.c */
+     if (defs.auth) {
+         if (*sig)
+              notice.z_default_format = "Class $class, Instance $instance:\nTo: @bold($recipient)\n@bold($1) <$sender>\n\n$2";
+         else
+              notice.z_default_format = "Class $class, Instance $instance:\nTo: @bold($recipient)\n$message";
+     }
+     else {
+         if (*sig)
+              notice.z_default_format = "@bold(UNAUTHENTIC) Class $class, Instance $instance:\n@bold($1) <$sender>\n\n$2";
+         else
+              notice.z_default_format = "@bold(UNAUTHENTIC) Class $class, Instance $instance:\n$message";
+     }
+     
+     ret = zeph_send_notice(&notice, (defs.auth) ? ZAUTH : ZNOAUTH);
+     free(sig_msg);
+
+     /* log to file */
+     if (defs.logfile)
+       if (strcmp(defs.logfile, "*"))
+        log_message (dest, msg);
+
+     return ret;
+}
+
+int zeph_ping(dest)
+   Dest        dest;
+{
+     ZNotice_t         notice;
+
+     (void) memset((char *) &notice, 0, sizeof(ZNotice_t));
+     notice.z_kind = ACKED;
+     notice.z_class = dest->zclass;
+     notice.z_class_inst = dest->zinst;
+     notice.z_recipient = dest->zrecip;
+     notice.z_opcode = "PING";
+
+     /* Should a PING ever be authenticated? */
+     return (zeph_send_notice(&notice, ZNOAUTH));
+}
+
+int zeph_pong(dest)
+   Dest dest;
+{
+     ZNotice_t         notice;
+
+     (void) memset((char *) &notice, 0, sizeof(ZNotice_t));
+     notice.z_kind = ACKED;
+     notice.z_class = dest->zclass;
+     notice.z_class_inst = dest->zinst;
+     notice.z_recipient = dest->zrecip;
+     notice.z_opcode = "PING";
+     notice.z_message = "PONG";
+     notice.z_message_len = 4;
+
+     /* Should a PING ever be authenticated? */
+     return (zeph_send_notice(&notice, ZNOAUTH));
+}
+
+char *zeph_get_signature()
+{
+     char *sig;
+         
+     sig = ZGetVariable("xzwrite-signature");
+     if (! sig) sig = ZGetVariable("zwrite-signature");
+     return sig;
+}
+
+static int zeph_send_notice(notice, auth)
+   ZNotice_t   *notice;
+   int         (*auth)();
+{
+     int       retval;
+     ZNotice_t retnotice;
+
+     /* Send message with appropriate authentication */
+     retval = ZSendNotice(notice, auth);
+     if (retval != ZERR_NONE) {
+         if (defs.debug)
+              Warning(error_message(retval), " while sending message.", NULL);
+         return SENDFAIL_SEND;
+     }
+
+     /* Wait for server acknowledgement */
+     retval = ZIfNotice(&retnotice, (struct sockaddr_in *) 0,
+                       ZCompareUIDPred, (char *) &notice->z_uid);
+
+     if (retval != ZERR_NONE) {
+         if (defs.debug)
+              Warning(error_message(retval),
+                      " while waiting for acknowledgement.", NULL);
+         return SENDFAIL_ACK;
+     }
+
+     /* Make sure someone receives it */
+     if (strcmp(retnotice.z_message, ZSRVACK_NOTSENT)==0)
+         return SENDFAIL_RECV;
+
+     return SEND_OK;
+}
+
+void log_message(dest, msg)
+   Dest        dest;
+   char        *msg;
+{
+  FILE *fp;
+  int i;
+  time_t now;
+
+  fp = fopen(defs.logfile, "a");
+  if (!fp) {
+    fp = fopen(defs.logfile, "w");
+    if (!fp) {
+      fprintf(stderr, "xzwrite: could not open log file \"%s\".\n",
+             defs.logfile);
+      return; }
+  }
+
+  now = time (NULL);
+  fprintf(fp, "To: %s, %s, %s\n", dest->zclass, dest->zinst, dest->zrecip);
+  fprintf(fp, "Date: %s\n", ctime (&now));
+
+  i = strlen(msg)-1;
+  while (msg[i] == '\n' && i > 0) i--;
+  if (msg[i] != '\n') i++; msg[i] = 0;
+  fputs(msg, fp); fprintf(fp, "\n\n");
+  fclose(fp);
+}
index 67ff10a3f5019c15ef81c38a852e96807e160ad5..c8a5f58b1443fdff17acfd7a2adbcc0cdc11f0da 100644 (file)
@@ -24,11 +24,11 @@ static const char rcsid_zaway_c[] = "$Id$";
 #define DEFAULT_MSG "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
 #define RESPONSE_OPCODE ""
 
-RETSIGTYPE cleanup(int);
+RETSIGTYPE cleanup();
 u_short port;
 
-void
-usage(char *name)
+void usage(name)
+       char *name;
 {
        printf("Usage: %s [OPTIONS] [FILE]\n"
               "\n"
@@ -38,9 +38,9 @@ usage(char *name)
               name);
 }
 
-int
-main(int argc,
-     char *argv[])
+int main(argc,argv)
+       int argc;
+       char *argv[];
 {
        FILE *fp;
        ZNotice_t notice;
@@ -52,7 +52,7 @@ main(int argc,
        int optchar, watch_location;
        char *cmdline_msg;
        int nlocs;
-       char *find_message(ZNotice_t *, FILE *);
+       char *find_message();
 #ifdef _POSIX_VERSION
        struct sigaction sa;
 #endif
@@ -203,11 +203,11 @@ main(int argc,
        }
 }
 
-char *
-find_message(ZNotice_t *notice,
-            FILE *fp)
+char *find_message(notice,fp)
+       ZNotice_t *notice;
+       register FILE *fp;
 {
-       char *ptr,*ptr2;
+       register char *ptr,*ptr2;
        char bfr[BUFSIZ],sender[BUFSIZ];
        int gotone,lastwasnt;
        
@@ -253,8 +253,7 @@ find_message(ZNotice_t *notice,
        return (ptr);
 }
 
-RETSIGTYPE
-cleanup(int ignored)
+RETSIGTYPE cleanup()
 {
     ZCancelSubscriptions(port);
     exit(1);
index e48a6512865f974a2a322a25f8071128157d68d3..b1359be1075bc2e7f0dd5e6791624eddb3be4ff8 100644 (file)
@@ -17,7 +17,7 @@
 #include <pwd.h>
 #include <netdb.h>
 #ifndef lint
-static const char rcsid_zctl_c[] = "$Id$";
+static const char *rcsid_zctl_c = "$Id$";
 #endif
 
 #define SUBSATONCE 7
@@ -40,6 +40,7 @@ static const char rcsid_zctl_c[] = "$Id$";
 #define        ERR             (-1)
 #define        NOT_REMOVED     0
 #define        REMOVED         1
+int purge_subs();
 
 int sci_idx;
 char subsname[BUFSIZ];
@@ -47,16 +48,11 @@ char ourhost[MAXHOSTNAMELEN],ourhostcanon[MAXHOSTNAMELEN];
 
 extern ss_request_table zctl_cmds;
 
-int purge_subs(register ZSubscription_t *, int);
-void add_file(short, ZSubscription_t *, int);
-void del_file(short, ZSubscription_t *, int);
-void fix_macros(ZSubscription_t *, ZSubscription_t *, int);
-void fix_macros2(char *, char **);
-int make_exist(char *);
+void add_file(), del_file(), fix_macros(), fix_macros2();
 
-int
-main(int argc,
-     char *argv[])
+main(argc,argv)
+       int argc;
+       char *argv[];
 {
        struct passwd *pwd;
        struct hostent *hent;
@@ -150,8 +146,9 @@ main(int argc,
 }
 
 void
-set_file(int argc,
-        char *argv[])
+set_file(argc,argv)
+       int argc;
+       char *argv[];
 {
        if (argc > 2) {
                fprintf(stderr,"Usage: %s filename\n",argv[0]);
@@ -165,8 +162,9 @@ set_file(int argc,
 }
 
 void
-flush_locations(int argc,
-               char *argv[])
+flush_locations(argc,argv)
+       int argc;
+       char *argv[];
 {
        int retval;
        
@@ -180,8 +178,9 @@ flush_locations(int argc,
 }
 
 void
-wgc_control(int argc,
-           char *argv[])
+wgc_control(argc,argv)
+       int argc;
+       register char **argv;
 {
        int retval;
        short newport;
@@ -240,8 +239,9 @@ wgc_control(int argc,
 } 
 
 void
-hm_control(int argc,
-          char *argv[])
+hm_control(argc,argv)
+       int argc;
+       char *argv[];
 {
        int retval;
        ZNotice_t notice;
@@ -276,8 +276,9 @@ hm_control(int argc,
 } 
 
 void
-show_var(int argc,
-        char *argv[])
+show_var(argc,argv)
+       int argc;
+       char *argv[];
 {
        int i;
        char *value;
@@ -297,7 +298,9 @@ show_var(int argc,
 }
 
 void
-set_var(int argc, char *argv[])
+set_var(argc,argv)
+       int argc;
+       register char **argv;
 {
        int retval,setting_exp,i;
        char *exp_level,*newargv[1];
@@ -375,8 +378,9 @@ set_var(int argc, char *argv[])
 }
 
 void
-do_hide(int argc,
-       char *argv[])
+do_hide(argc,argv)
+       int argc;
+       char *argv[];
 {
        char *exp_level = NULL;
        Code_t retval;
@@ -395,8 +399,9 @@ do_hide(int argc,
 }
 
 void
-unset_var(int argc,
-         char *argv[])
+unset_var(argc,argv)
+       int argc;
+       char *argv[];
 {
        int retval,i;
        
@@ -413,8 +418,9 @@ unset_var(int argc,
 }
 
 void
-cancel_subs(int argc,
-           char *argv[])
+cancel_subs(argc,argv)
+       int argc;
+       char *argv[];
 {
        int retval;
        short wgport;
@@ -433,8 +439,9 @@ cancel_subs(int argc,
 }
 
 void
-subscribe(int argc,
-         char *argv[])
+subscribe(argc,argv)
+       int argc;
+       char *argv[];
 {
        int retval;
        short wgport;
@@ -465,8 +472,9 @@ subscribe(int argc,
 } 
 
 void
-sub_file(int argc,
-        char *argv[])
+sub_file(argc,argv)
+       int argc;
+       char *argv[];
 {
        ZSubscription_t sub;
        short wgport;
@@ -515,9 +523,10 @@ sub_file(int argc,
 }
 
 void
-add_file(short wgport,
-        ZSubscription_t *subs,
-        int unsub)
+add_file(wgport,subs,unsub)
+short wgport;
+ZSubscription_t *subs;
+int unsub;
 {
        FILE *fp;
        char errbuf[BUFSIZ];
@@ -539,10 +548,8 @@ add_file(short wgport,
                return;
        }
        fix_macros(subs,&sub2,1);
-       retval = (unsub
-                 ? ZUnsubscribeTo(&sub2,1,(u_short)wgport)
-                 : ZSubscribeToSansDefaults(&sub2,1,(u_short)wgport));
-       if (retval)
+       if (retval = (unsub ? ZUnsubscribeTo(&sub2,1,(u_short)wgport) :
+                      ZSubscribeToSansDefaults(&sub2,1,(u_short)wgport)))
                ss_perror(sci_idx,retval,
                          unsub ? "while unsubscribing" :
                          "while subscribing");
@@ -550,9 +557,10 @@ add_file(short wgport,
 }
 
 void
-del_file(short wgport,
-        register ZSubscription_t *subs,
-        int unsub)
+del_file(wgport,subs,unsub)
+short wgport;
+register ZSubscription_t *subs;
+int unsub;
 {
        ZSubscription_t sub2;
        int retval;
@@ -574,8 +582,9 @@ del_file(short wgport,
 }
 
 int
-purge_subs(register ZSubscription_t *subs,
-          int which)
+purge_subs(subs,which)
+register ZSubscription_t *subs;
+int which;
 {
        FILE *fp,*fpout;
        char errbuf[BUFSIZ],subline[BUFSIZ];
@@ -656,8 +665,9 @@ purge_subs(register ZSubscription_t *subs,
 }
 
 void
-load_subs(int argc,
-         char *argv[])
+load_subs(argc,argv)
+       int argc;
+       char *argv[];
 {
        ZSubscription_t subs[SUBSATONCE],subs2[SUBSATONCE],unsubs[SUBSATONCE];
        FILE *fp;
@@ -833,8 +843,9 @@ cleanup:
 }
 
 void
-current(int argc,
-       char *argv[])
+current(argc,argv)
+       int argc;
+       char *argv[];
 {
        FILE *fp;
        char errbuf[BUFSIZ];
@@ -929,7 +940,8 @@ current(int argc,
 }
 
 int
-make_exist(char *filename)
+make_exist(filename)
+       char *filename;
 {
        char errbuf[BUFSIZ];
        FILE *fpout;
@@ -952,9 +964,9 @@ make_exist(char *filename)
 }
 
 void
-fix_macros(ZSubscription_t *subs,
-          ZSubscription_t *subs2,
-          int num)
+fix_macros(subs,subs2,num)
+       ZSubscription_t *subs,*subs2;
+       int num;
 {
        int i;
 
@@ -967,7 +979,9 @@ fix_macros(ZSubscription_t *subs,
 }
 
 void
-fix_macros2(char *src, char **dest)
+fix_macros2(src,dest)
+       register char *src;
+       char **dest;
 {
        if (!strcmp(src,TOKEN_HOSTNAME)) {
                *dest = ourhost;
index e7ce4b6c189fcfc8d46ed8082d9c24c84b951a96..91e8c143bb30c93c08eef85f5ce758dc5e80c1b6 100644 (file)
@@ -17,7 +17,7 @@
 #include <com_err.h>
 
 #ifndef lint
-static const char rcsid_zlocate_c[] = "$Id$";
+static char rcsid_zlocate_c[] = "$Id$";
 #endif /* lint */
 
 /*
@@ -52,27 +52,23 @@ char copyright[] =
  */
 char origlogin[20];
 char tempfile[40];
+char *getlogin();
 char *whenleave;
 char *reminder_message = NULL;
 char buff[100];
 int use_zephyr=1, oldpid;
 
-void usage(void);
-void doalarm(long);
-void bother(long, char *);
-void delay(long);
-int gethm(char *, int *, int*);
+void usage(), doalarm(), bother(), delay();
 
-int
-main(int argc,
-     char **argv)
+main(argc, argv)
+char **argv;
 {
        time_t now;
-       long when, diff;
-       int hours, minutes;
+       long when, diff, hours, minutes;
        char *cp;
        FILE *fp;
        struct tm *nv;
+       int gethm();
        int port, c;
        ZSubscription_t sub;
        
@@ -184,7 +180,7 @@ main(int argc,
 }
 
 void
-usage(void)
+usage()
 {
        fprintf(stderr, "usage: zleave [[+]hhmm [-m \"Reminder Message\"]]\n\
 \tor: zleave can[cel]\n");
@@ -192,12 +188,12 @@ usage(void)
 }
 
 int
-gethm(char *cp,
-      int *hp,
-      int *mp)
+gethm(cp, hp, mp)
+register char *cp;
+int *hp, *mp;
 {
-       char c;
-       int tod;
+       register char c;
+       register int tod;
 
        tod = 0;
        while ((c = *cp++) != '\0') {
@@ -211,7 +207,8 @@ gethm(char *cp,
 }
 
 void
-doalarm(long nmins)
+doalarm(nmins)
+long nmins;
 {
        time_t daytime;
        char *msg1, *msg2, *msg3, *msg4;
@@ -254,8 +251,7 @@ doalarm(long nmins)
        daytime += gseconds;
        whenleave = ctime(&daytime);
 
-       fp = fopen(tempfile,"r");
-       if (fp) {
+       if (fp = fopen(tempfile,"r")) {
              if (fscanf(fp, "%d", &oldpid) == 1)
                      if (!kill(oldpid,9))
                              printf("Old zleave process killed.\n");
@@ -313,8 +309,9 @@ doalarm(long nmins)
 }
 
 void
-bother(long slp,
-       char *msg)
+bother(slp, msg)
+long slp;
+char *msg;
 {
       ZNotice_t notice;
       ZNotice_t retnotice;
@@ -387,7 +384,8 @@ bother(long slp,
  * knows what zero means.
  */
 void
-delay(long secs)
+delay(secs)
+long secs;
 {
        long n;
        register char *l;
index 9f048f322e3de79549d479770bd90e969164da9b..446956502ed897dc7fe39691b2ca7d6928de4de1 100644 (file)
@@ -21,23 +21,21 @@ static const char rcsid_zlocate_c[] = "$Id$";
 int numusers=0, numleft=0, parallel=0, oneline=0;
 char *whoami;
 
-RETSIGTYPE
-timeout(int sig)
+RETSIGTYPE timeout(sig)
 {
   fprintf (stderr, "%s: no response from server\n", whoami);
   exit(1);
 }
 
-void
-usage(void)
+void usage()
 {
    printf("Usage: %s [ -a | -d ] [ -p ] [ -1 ] user ... \n",whoami);
    exit(1);
 }
 
-void
-print_locs(char *user,
-          int nlocs)
+void print_locs(user,nlocs)
+     char *user;
+     int nlocs;
 {
    int one = 1, retval;
    ZLocations_t locations;
@@ -67,9 +65,9 @@ print_locs(char *user,
 }
 
 /*ARGSUSED*/
-int
-main(int argc,
-     char *argv[])
+main(argc,argv)
+       int argc;
+       char *argv[];
 {
     char user[BUFSIZ],*whichuser;
     ZAsyncLocateData_t ald;
diff --git a/zephyr/clients/zmailnotify/Makefile.in b/zephyr/clients/zmailnotify/Makefile.in
new file mode 100644 (file)
index 0000000..fc38fea
--- /dev/null
@@ -0,0 +1,56 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+sysconfdir=@sysconfdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=@mandir@
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+top_builddir=../..
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+LIBTOOL=@LIBTOOL@
+CC=@CC@
+INSTALL=@INSTALL@
+
+LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la
+CPPFLAGS=@CPPFLAGS@
+CFLAGS=@CFLAGS@
+ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h -DKPOP ${CPPFLAGS}
+LDFLAGS=@LDFLAGS@
+LIBS=${LIBZEPHYR} @LIBS@ -lcom_err
+
+OBJS=  zmailnotify.o
+
+all: zmailnotify
+
+zmailnotify: ${OBJS} ${LIBZEPHYR}
+       ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+.c.o:
+       ${CC} -c ${ALL_CFLAGS} $<
+
+check:
+
+install: zmailnotify
+       ${LIBTOOL} --mode=install ${INSTALL} -m 755 zmailnotify \
+         ${DESTDIR}${bindir}
+       ${INSTALL} -m 644 ${srcdir}/zmailnotify.1 ${DESTDIR}${mandir}/man1
+
+clean:
+       ${LIBTOOL} --mode=clean rm -f zmailnotify
+       rm -f ${OBJS}
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/zephyr/clients/zmailnotify/zmailnotify.1 b/zephyr/clients/zmailnotify/zmailnotify.1
new file mode 100644 (file)
index 0000000..3c6be20
--- /dev/null
@@ -0,0 +1,77 @@
+.\"    $Id$
+.\"
+.\" Copyright 1988 by the Massachusetts Institute of Technology
+.\" All rights reserved.  The file /usr/include/zephyr/mit-copyright.h
+.\" specifies the terms and conditions for redistribution.
+.\"
+.TH ZMAILNOTIFY 1 "July 8, 1988" "MIT Project Athena"
+.ds ]W MIT Project Athena
+.SH NAME
+zmailnotify \- retrieve mail headers from post office and transmit via Zephyr
+.SH SYNOPSIS
+.B zmailnotify
+.SH DESCRIPTION
+.I zmailnotify
+connects to the invoking user's POP post office and retrieves the From,
+To, and Subject fields of waiting messages, and then sends one Zephyr
+notice per message to class MAIL, instance POPRET, recipient 
+.I <user@realm>,
+where <user@realm> is the invoking user's username concatenated with the
+local Zephyr realm (e.g. jruser@ATHENA.MIT.EDU).
+.PP
+.I zmailnotify
+is intended to be executed by
+.I zwgc(1)
+when notifications of spooled mail (such
+as those generated by \fIzpopnotify(8)\fR) are delivered.
+By default, these notifications are not delivered, nor are they acted
+upon.  To receive the notices, you must subscribe to class MAIL,
+instance POP, recipient username@realm  (see \fIzctl\fR(1)).
+Once you subscribe to these notices, by default they will be simply
+displayed on your display or terminal by
+.I zwgc(1).
+To have 
+.I zmailnotify
+executed when they are delivered, you must copy the system default
+windowgram description file (\fI/usr/athena/lib/zephyr/zwgc.desc\fR) to your home
+directory as filename 
+.I ~/.zwgc.desc
+and follow the directions contained in that file pertaining to
+.B MAIL NOTIFICATION.
+.PP
+.I zmailnotify
+only retrieves four headers at one time in order to reduce the
+competition for the mailbox lock on the post office.  If more than four mail
+messages are waiting,
+.I zmailnotify 
+will only retrieve the four most recent mail headers.
+.PP
+To check for mail already waiting when you log in, use the standard MH
+program
+.I msgchk(1).
+.SH BUGS
+.I zmailnotify
+only sends notification of mail which appears to be unique.
+Uniqueness is determined by comparing the To:, From:, and Subject:
+fields of the message with the last checked mail message; if the
+three fields match exactly, the new message is
+not considered unique.  The To:, From:, and Subject: fields of the last
+message are stored in the file 
+.IR $HOME/.maillock .
+.SH FILES
+$HOME/.maillock
+.SH SEE ALSO
+msgchk(1), zctl(1), zephyr(1), zwgc(1), zhm(8), zephyrd(8),
+zpopnotify(8), popd(8)
+.br
+Project Athena Technical Plan Section E.4.1, `Zephyr Notification
+Service'
+.SH AUTHOR
+.PP
+Robert S. French (MIT-Project Athena)
+.SH RESTRICTIONS
+Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
+All Rights Reserved.
+.br
+.I zephyr(1)
+specifies the terms and conditions for redistribution.
diff --git a/zephyr/clients/zmailnotify/zmailnotify.c b/zephyr/clients/zmailnotify/zmailnotify.c
new file mode 100644 (file)
index 0000000..5b1ed06
--- /dev/null
@@ -0,0 +1,644 @@
+/* This file is part of the Project Athena Zephyr Notification System.
+ * It contains code for the "zmailnotify" command.
+ *
+ *     Created by:     Robert French
+ *
+ *     $Id$
+ *
+ *     Copyright (c) 1987,1993 by the Massachusetts Institute of Technology.
+ *     For copying and distribution information, see the file
+ *     "mit-copyright.h". 
+ */
+
+#include <sysdep.h>
+#include <zephyr/mit-copyright.h>
+#include <zephyr/zephyr.h>
+
+#ifndef lint
+static const char rcsid_zmailnotify_c[] =
+    "$Id$";
+#endif
+
+#include <sys/socket.h>
+#include <pwd.h>
+#include <netdb.h>
+#ifdef HAVE_HESIOD
+#include <hesiod.h>
+#endif
+
+#ifndef HAVE_KRB4
+#undef KPOP
+#endif
+
+#ifdef KPOP
+#include <krb.h>
+#endif
+
+#define NOTOK (-1)
+#define OK 0
+#define DONE 1
+
+FILE *sfi;
+FILE *sfo;
+char Errmsg[80];
+
+#ifdef KPOP
+char *PrincipalHostname();
+#endif
+
+void get_message(), pop_close(), mail_notify(), fatal_pop_err ();
+int pop_command __P((char *, ...));
+#define MAXMAIL 4
+
+struct _mail {
+       char *from;
+       char *to;
+       char *subj;
+} maillist[MAXMAIL];
+
+char *mailptr = NULL;
+char *prog = "zmailnotify";
+
+/* This entire program is a kludge - beware! */
+
+main(argc, argv)
+    char *argv[];
+{
+    FILE *lock;
+    int nmsgs;
+    char *user,response[512],lockfile[100];
+    char *host,*dir;
+    char *auth_cmd;
+    int i,nbytes,retval,uselock;
+    struct passwd *pwd;
+    struct _mail mymail;
+#ifdef HAVE_HESIOD
+    struct hes_postoffice *p;
+#endif
+
+    if (argv[0] && *argv[0])
+       prog = argv[0];
+       
+    if ((retval = ZInitialize()) != ZERR_NONE) {
+       com_err(prog,retval,"while initializing");
+       exit(1);
+    }
+
+    dir = (char *)getenv("HOME");
+    user = (char *)getenv("USER");
+    if (!user || !dir) {
+       pwd = (struct passwd *)getpwuid((int) getuid());
+       if (!pwd) {
+           fprintf(stderr,"%s: Can't figure out who you are!\n",
+                   prog);
+           exit(1);
+       }
+       if (!user)
+           user = pwd->pw_name;
+       if (!dir)
+           dir = pwd->pw_dir;
+    }
+    if (argc > 1)
+       user = argv[1];
+
+    (void) sprintf(lockfile,"%s/.maillock",dir);
+       
+    host = (char *)getenv("MAILHOST");
+#ifdef HAVE_HESIOD
+    if (host == NULL) {
+       p = hes_getmailhost(user);
+       if (p != NULL && strcmp(p->po_type, "POP") == 0)
+           host = p->po_host;
+       else {
+           fprintf(stderr,
+                   "%s: no POP server listed in Hesiod for %s\n",
+                   prog, user);
+           exit(1);
+       } 
+    }
+#endif
+    if (host == NULL) {
+       fprintf(stderr,"%s: no MAILHOST defined\n", prog);
+       exit(1);
+    }
+
+    lock = fopen(lockfile,"r+");
+#ifdef _POSIX_VERSION
+    if (lock) {
+       struct flock fl;
+
+       /* lock the whole file exclusively */
+       fl.l_type = F_WRLCK;
+       fl.l_whence = SEEK_SET;
+       fl.l_start = 0;
+       fl.l_len = 0;
+       (void) fcntl(fileno(lock),F_SETLKW,&fl);
+    }
+#else
+    if (lock)
+       (void) flock(fileno(lock),LOCK_EX);
+#endif
+
+    if (pop_init(host) == NOTOK) {
+       fprintf(stderr,"%s: %s\n",prog, Errmsg);
+       exit(1);
+    }
+
+    if ((getline(response, sizeof response, sfi) != OK) ||
+       (*response != '+')) {
+       fprintf(stderr,"%s: %s\n",prog,response);
+       exit(1);
+    }
+
+#ifdef KPOP
+    auth_cmd = "PASS %s";
+#else
+    auth_cmd = "RPOP %s";
+#endif
+    if (pop_command("USER %s", user) == NOTOK
+       || pop_command(auth_cmd, user) == NOTOK)
+       fatal_pop_err ();
+
+    if (pop_stat(&nmsgs, &nbytes) == NOTOK)
+       fatal_pop_err ();
+
+    if (!nmsgs) {
+       if (lock) {
+#ifdef _POSIX_VERSION
+           struct flock fl;
+
+           /* unlock the whole file */
+           fl.l_type = F_UNLCK;
+           fl.l_whence = SEEK_SET;
+           fl.l_start = 0;
+           fl.l_len = 0;
+           (void) fcntl(fileno(lock),F_SETLKW,&fl);
+#else
+           (void) flock(fileno(lock),LOCK_UN);
+#endif
+           (void) fclose(lock);
+       } 
+       (void) unlink(lockfile);
+       (void) pop_command("QUIT");
+       pop_close();
+       exit (0);
+    }
+
+    uselock = 0;
+    if (lock) {
+       uselock = 1;
+       mymail.to = (char *)malloc(BUFSIZ);
+       mymail.from = (char *)malloc(BUFSIZ);
+       mymail.subj = (char *)malloc(BUFSIZ);
+       if (fgets(mymail.from,BUFSIZ,lock) != NULL)
+           mymail.from[strlen(mymail.from)-1] = 0;
+       else
+           mymail.from[0]=0;
+       if (fgets(mymail.to,BUFSIZ,lock) != NULL)
+           mymail.to[strlen(mymail.to)-1] = 0;
+       else
+           mymail.to[0] = 0;
+       if (fgets(mymail.subj,BUFSIZ,lock) != NULL)
+           mymail.subj[strlen(mymail.subj)-1] = 0;
+       else
+           mymail.subj[0] = 0;
+    }
+    else {
+       lock = fopen(lockfile,"w");
+#ifdef _POSIX_VERSION
+       if (lock) {
+           struct flock fl;
+
+           /* lock the whole file exclusively */
+           fl.l_type = F_WRLCK;
+           fl.l_whence = SEEK_SET;
+           fl.l_start = 0;
+           fl.l_len = 0;
+           (void) fcntl(fileno(lock),F_SETLKW,&fl);
+       }
+#else
+       if (lock)
+           (void) flock(fileno(lock),LOCK_EX);
+#endif
+       uselock = 0;
+    }
+       
+    for (i=nmsgs;i>0;i--) {
+       if (nmsgs-i == MAXMAIL)
+           break;
+       if (get_mail(i,&maillist[nmsgs-i]))
+           exit (1);
+       if (uselock && (!strcmp(maillist[nmsgs-i].to,mymail.to) &&
+                       !strcmp(maillist[nmsgs-i].from,mymail.from) &&
+                       !strcmp(maillist[nmsgs-i].subj,mymail.subj)))
+           break;
+    }
+
+    (void) pop_command("QUIT");
+    pop_close();
+
+    i++;
+    for (;i<=nmsgs;i++)
+       mail_notify(&maillist[nmsgs-i]);
+    i--;
+    if (lock) {
+#ifdef _POSIX_VERSION
+       struct flock fl;
+
+       /* unlock the whole file */
+       fl.l_type = F_UNLCK;
+       fl.l_whence = SEEK_SET;
+       fl.l_start = 0;
+       fl.l_len = 0;
+       (void) fcntl(fileno(lock),F_SETLKW,&fl);
+#else
+       (void) flock(fileno(lock),LOCK_UN);
+#endif
+       (void) fclose(lock);
+    } 
+    lock = fopen(lockfile,"w");
+    if (!lock)
+       exit (1);
+    fprintf(lock,"%s\n%s\n%s\n",
+           maillist[nmsgs-i].from,
+           maillist[nmsgs-i].to,
+           maillist[nmsgs-i].subj);
+    (void) fclose(lock);
+
+    exit(0);
+}
+
+void fatal_pop_err ()
+{
+    fprintf (stderr, "%s: %s\n", prog, Errmsg);
+    (void) pop_command ("QUIT");
+    pop_close ();
+    exit (1);
+}
+
+void get_message(i)
+       int i;
+{
+       int mbx_write();
+       if (pop_scan(i, mbx_write, 0) != OK)
+           fatal_pop_err ();
+}
+
+/* Pop stuff */
+
+void pop_close()
+{
+       if (sfi)
+               (void) fclose(sfi);
+       if (sfo)
+               (void) fclose(sfo);
+}
+
+get_mail(i,mail)
+       int i;
+       struct _mail *mail;
+{
+       char from[512],to[512],subj[512];
+       char *c,*ptr,*ptr2;
+       
+       *from = 0;
+       *to = 0;
+       *subj = 0;
+
+       if (mailptr)
+               free(mailptr);
+
+       mailptr = 0;
+       
+       get_message(i);
+
+       ptr = mailptr;
+       while (ptr) {
+               ptr2 = strchr(ptr,'\n');
+               if (ptr2)
+                       *ptr2++ = 0;
+               if (*ptr == '\0')
+                       break;
+               if (!strncmp(ptr, "From: ", 6))
+                       (void) strcpy(from, ptr+6);
+               else if (!strncmp(ptr, "To: ", 4))
+                       (void) strcpy(to, ptr+4);
+               else if (!strncmp(ptr, "Subject: ", 9))
+                       (void) strcpy(subj, ptr+9);
+               ptr = ptr2;
+       }
+
+       /* add elipsis at end of "To:" field if it continues onto */
+       /* more than one line */
+       i = strlen(to) - 2;
+       c = to+i;
+       if (*c++ == ',') {
+               *c++ = ' ';
+               *c++ = '.';
+               *c++ = '.';
+               *c++ = '.';
+               *c++ = '\n';
+               *c = 0;
+       }
+
+       mail->from = (char *)malloc((unsigned)(strlen(from)+1));
+       (void) strcpy(mail->from,from);
+       mail->to = (char *)malloc((unsigned)(strlen(to)+1));
+       (void) strcpy(mail->to,to);
+       mail->subj = (char *)malloc((unsigned)(strlen(subj)+1));
+       (void) strcpy(mail->subj,subj);
+
+       return (0);
+}
+
+void
+mail_notify(mail)
+       struct _mail *mail;
+{
+       int retval;
+       char *fields[3];
+       ZNotice_t notice;
+
+       (void) memset((char *)&notice, 0, sizeof(notice));
+       notice.z_kind = UNACKED;
+       notice.z_port = 0;
+       notice.z_class = "MAIL";
+       notice.z_class_inst = "POPRET";
+       notice.z_opcode = "NEW_MAIL";
+       notice.z_sender = 0;
+       notice.z_recipient = ZGetSender();
+       notice.z_default_format = "You have new mail:\n\nFrom: $1\nTo: $2\nSubject: $3";
+
+       fields[0] = mail->from;
+       fields[1] = mail->to;
+       fields[2] = mail->subj;
+      
+       if ((retval = ZSendList(&notice,fields,3,ZNOAUTH)) != ZERR_NONE)
+               com_err(prog,retval,"while sending notice");
+}
+
+/*
+ * These are the necessary KPOP routines snarfed from
+ * the GNU movemail program.
+ */
+
+pop_init(host)
+char *host;
+{
+    register struct hostent *hp;
+    register struct servent *sp;
+    int lport = IPPORT_RESERVED - 1;
+    struct sockaddr_in sin;
+    register int s;
+#ifdef KPOP
+    KTEXT ticket = (KTEXT)NULL;
+    int rem;
+    long authopts;
+    char *host_save;
+#endif
+    char *svc_name;
+
+    hp = gethostbyname(host);
+    if (hp == NULL) {
+       (void) sprintf(Errmsg, "MAILHOST unknown: %s", host);
+       return(NOTOK);
+    }
+
+
+#ifdef KPOP
+#ifdef ATHENA_COMPAT
+    svc_name = "knetd";
+#else
+    svc_name = "kpop";
+#endif
+#else
+    svc_name = "pop";
+#endif
+
+    sp = getservbyname (svc_name, "tcp");
+    if (sp == 0) {
+       (void) sprintf (Errmsg, "%s/tcp: unknown service", svc_name);
+       return NOTOK;
+    }
+    sin.sin_family = hp->h_addrtype;
+    (void) memcpy((char *)&sin.sin_addr, hp->h_addr, hp->h_length);
+    sin.sin_port = sp->s_port;
+#ifdef KPOP
+    s = socket(AF_INET, SOCK_STREAM, 0);
+#else
+    s = rresvport(&lport);
+#endif
+    if (s < 0) {
+       (void) sprintf(Errmsg, "error creating socket: %s", strerror(errno));
+       return(NOTOK);
+    }
+
+    if (connect(s, (struct sockaddr *)&sin, sizeof sin) < 0) {
+       (void) sprintf(Errmsg, "error during connect: %s", strerror(errno));
+       (void) close(s);
+       return(NOTOK);
+    }
+#ifdef KPOP
+    ticket = (KTEXT)malloc( sizeof(KTEXT_ST) );
+    rem=KSUCCESS;
+#ifdef ATHENA_COMPAT
+    authopts = KOPT_DO_OLDSTYLE;
+    rem = krb_sendsvc(s,"pop");
+    if (rem != KSUCCESS) {
+       (void) sprintf(Errmsg, "kerberos error: %s", krb_get_err_text(rem));
+       (void) close(s);
+       return(NOTOK);
+    }
+#else
+    authopts = 0L;
+#endif
+    host_save = malloc(strlen(hp->h_name) + 1);
+    if (!host_save) {
+       sprintf(Errmsg, "Out of memory.");
+       return(NOTOK);
+    }
+    strcpy(host_save, hp->h_name);
+    rem = krb_sendauth(authopts, s, ticket, "pop", host_save, (char *)0,
+                      0, (MSG_DAT *) 0, (CREDENTIALS *) 0,
+                      (bit_64 *) 0, (struct sockaddr_in *)0,
+                      (struct sockaddr_in *)0,"ZMAIL0.0");
+    free(host_save);
+    free(ticket);
+    if (rem != KSUCCESS) {
+       (void) sprintf(Errmsg, "kerberos error: %s",krb_get_err_text(rem));
+       (void) close(s);
+       return(NOTOK);
+    }
+#endif
+
+    sfi = fdopen(s, "r");
+    sfo = fdopen(s, "w");
+    if (sfi == NULL || sfo == NULL) {
+       (void) sprintf(Errmsg, "error in fdopen: %s", strerror(errno));
+       (void) close(s);
+       return(NOTOK);
+    }
+
+    return(OK);
+}
+
+#ifdef __STDC__
+pop_command(char *fmt, ...)
+#else
+pop_command(fmt, va_alist)
+    va_dcl
+#endif
+{
+    va_list args;
+    char buf[4096];
+
+    VA_START(args, fmt);
+    (void) vsprintf(buf, fmt, args);
+    va_end(args);
+
+    if (putline(buf, Errmsg, sfo) == NOTOK) return(NOTOK);
+
+    if (getline(buf, sizeof buf, sfi) != OK) {
+       (void) strcpy(Errmsg, buf);
+       return(NOTOK);
+    }
+
+    if (*buf != '+') {
+       (void) strcpy(Errmsg, buf);
+       return(NOTOK);
+    } else {
+       return(OK);
+    }
+}
+
+    
+pop_stat(nmsgs, nbytes)
+int *nmsgs, *nbytes;
+{
+    char buf[4096];
+
+    if (putline("STAT", Errmsg, sfo) == NOTOK) return(NOTOK);
+
+    if (getline(buf, sizeof buf, sfi) != OK) {
+       (void) strcpy(Errmsg, buf);
+       return(NOTOK);
+    }
+
+    if (*buf != '+') {
+       (void) strcpy(Errmsg, buf);
+       return(NOTOK);
+    } else {
+       if (sscanf(buf, "+OK %d %d", nmsgs, nbytes) != 2)
+           return(NOTOK);
+       return(OK);
+    }
+}
+
+pop_scan(msgno, action, arg)
+int (*action)();
+{
+    char buf[4096];
+
+#ifdef HAVE_POP3_TOP
+    (void) sprintf(buf, "TOP %d 0", msgno);
+#else
+    (void) sprintf(buf, "RETR %d", msgno);
+#endif
+    if (putline(buf, Errmsg, sfo) == NOTOK) return(NOTOK);
+
+    if (getline(buf, sizeof buf, sfi) != OK) {
+       (void) strcpy(Errmsg, buf);
+       return(NOTOK);
+    }
+
+    while (1) {
+       switch (multiline(buf, sizeof buf, sfi)) {
+       case OK:
+           (*action)(buf, arg);
+           break;
+       case DONE:
+           return (OK);
+       case NOTOK:
+           (void) strcpy(Errmsg, buf);
+           return (NOTOK);
+       }
+    }
+}
+
+getline(buf, n, f)
+char *buf;
+register int n;
+FILE *f;
+{
+    register char *p;
+
+    p = fgets(buf, n, f);
+
+    if (ferror(f)) {
+       (void) strcpy(buf, "error on connection");
+       return (NOTOK);
+    }
+
+    if (p == NULL) {
+       (void) strcpy(buf, "connection closed by foreign host\n");
+       return (DONE);
+    }
+
+    p = buf + strlen(buf);
+    if (*--p == '\n') *p = '\0';
+    if (*--p == '\r') *p = '\0';
+    return(OK);
+}
+
+multiline(buf, n, f)
+char *buf;
+register int n;
+FILE *f;
+{
+    if (getline(buf, n, f) != OK) return (NOTOK);
+    if (*buf == '.') {
+       if (*(buf+1) == '\0') {
+           return (DONE);
+       } else {
+           (void) strcpy(buf, buf+1);
+       }
+    } else if (*buf == '\0') {
+      /* suck up all future lines, since this is after all only for headers */
+       while(! ((buf[0]=='.') && (buf[1] == '\0')) ) {
+           if (getline(buf, n, f) != OK) return (NOTOK);
+       }
+       return DONE;
+    }
+    return(OK);
+}
+
+putline(buf, err, f)
+char *buf;
+char *err;
+FILE *f;
+{
+    fprintf(f, "%s\r\n", buf);
+    (void) fflush(f);
+    if (ferror(f)) {
+       (void) strcpy(err, "lost connection");
+       return(NOTOK);
+    }
+    return(OK);
+}
+
+/*ARGSUSED*/
+mbx_write(line, dummy)
+char *line;
+int dummy;                             /* for consistency with pop_scan */
+{
+       if (mailptr) {
+               mailptr = (char *)realloc(mailptr,(unsigned)(strlen(mailptr)+strlen(line)+2));
+               (void) strcat(mailptr,line);
+       } 
+       else {
+               mailptr = (char *)malloc((unsigned)(strlen(line)+2));
+               (void) strcpy(mailptr,line);
+       }
+       (void) strcat(mailptr,"\n");
+       return(0);
+}
index 33f5096b35624a3d2f0d6ee89cd97a5f0a3c5738..53fd47ca96603464493531c16a73df199cf7e380 100644 (file)
@@ -23,9 +23,9 @@ static const char rcsid_znol_c[] = "$Id$";
 #define ON 1
 #define OFF 0
 
-int
-main(int argc,
-     char *argv[])
+main(argc,argv)
+       int argc;
+       register char *argv[];
 {
        register char *cp;
        ZSubscription_t subs[SUBSATONCE];
@@ -137,8 +137,7 @@ main(int argc,
                    if (cleanname[0] == '#' || cleanname[0] == '\0' ||
                        cleanname[0] == '\n')
                        continue;       /* ignore comment and empty lines */
-                   comment_ptr = strchr(cleanname, '#');
-                   if (comment_ptr)
+                   if (comment_ptr = strchr(cleanname, '#'))
                        *comment_ptr = '\0'; /* Ignore from # onwards */
                    /* Get rid of old-style nol entries, just in case */
                    cp = cleanname + strlen(cleanname) - 1;
diff --git a/zephyr/clients/zpopnotify/Makefile.in b/zephyr/clients/zpopnotify/Makefile.in
new file mode 100644 (file)
index 0000000..55c63b6
--- /dev/null
@@ -0,0 +1,56 @@
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+sysconfdir=@sysconfdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=@mandir@
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+top_builddir=../..
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+LIBTOOL=@LIBTOOL@
+CC=@CC@
+INSTALL=@INSTALL@
+
+LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la
+CPPFLAGS=@CPPFLAGS@
+CFLAGS=@CFLAGS@
+ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS}
+LDFLAGS=@LDFLAGS@
+LIBS=${LIBZEPHYR} @LIBS@ -lcom_err
+
+OBJS=  zpopnotify.o
+
+all: zpopnotify
+
+zpopnotify: ${OBJS} ${LIBZEPHYR}
+       ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+.c.o:
+       ${CC} -c ${ALL_CFLAGS} $<
+
+check:
+
+install: zpopnotify
+       ${LIBTOOL} --mode=install ${INSTALL} -m 755 zpopnotify \
+         ${DESTDIR}${sbindir}
+       ${INSTALL} -m 644 ${srcdir}/zpopnotify.8 ${DESTDIR}${mandir}/man8
+
+clean:
+       ${LIBTOOL} --mode=clean rm -f zpopnotify
+       rm -f ${OBJS}
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
diff --git a/zephyr/clients/zpopnotify/zpopnotify.8 b/zephyr/clients/zpopnotify/zpopnotify.8
new file mode 100644 (file)
index 0000000..0d01923
--- /dev/null
@@ -0,0 +1,38 @@
+.\"    $Id$
+.\"
+.\" Copyright 1988 by the Massachusetts Institute of Technology
+.\" All rights reserved.  The file /usr/include/zephyr/mit-copyright.h
+.\" specifies the terms and conditions for redistribution.
+.\"
+.TH ZPOPNOTIFY 8 "July 8, 1988" "MIT Project Athena"
+.ds ]W MIT Project Athena
+.SH NAME
+zpopnotify \- notify users of newly spooled mail via Zephyr
+.SH SYNOPSIS
+.B zpopnotify
+.BI username
+.SH DESCRIPTION
+.I zpopnotify
+sends a Zephyr notice announcing the delivery of new mail to class MAIL,
+instance POP, recipient
+.I <user@realm>,
+where <user@realm> is the command-line specified
+.BI username
+concatenated with the local Zephyr realm (e.g. "zpopnotify jruser" would
+send to recipient jruser@ATHENA.MIT.EDU at Project Athena).
+The body of the message contains the official hostname of the sending
+host.
+.SH SEE ALSO
+zephyr(1), zwgc(1), zmailnotify(1), zhm(8), zephyrd(8), popd(8), spop(8)
+.br
+Project Athena Technical Plan Section E.4.1, `Zephyr Notification
+Service'
+.SH AUTHOR
+.PP
+Robert S. French (MIT-Project Athena)
+.SH RESTRICTIONS
+Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
+All Rights Reserved.
+.br
+.I zephyr(1)
+specifies the terms and conditions for redistribution.
diff --git a/zephyr/clients/zpopnotify/zpopnotify.c b/zephyr/clients/zpopnotify/zpopnotify.c
new file mode 100644 (file)
index 0000000..b2f79e3
--- /dev/null
@@ -0,0 +1,104 @@
+/* This file is part of the Project Athena Zephyr Notification System.
+ * It contains code for the "zpopnotify" command.
+ *
+ *     Created by:     Robert French
+ *
+ *     $Id$
+ *
+ *     Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
+ *     For copying and distribution information, see the file
+ *     "mit-copyright.h". 
+ */
+
+
+#include <sysdep.h>
+#include <zephyr/mit-copyright.h>
+#include <zephyr/zephyr.h>
+#include <stdio.h>
+#include <netdb.h>
+#include <string.h>
+#include <sys/param.h>                 /* for MAXHOSTNAMELEN */
+#include <com_err.h>
+#include <errno.h>
+
+#ifndef lint
+static char rcsid_zpopnotify_c[] = "$Id$";
+#endif /* lint */
+
+#define MAIL_CLASS "MAIL"
+#define MAIL_INSTANCE "POP"
+
+void usage();
+
+main(argc,argv)
+       int argc;
+       char *argv[];
+{
+       ZNotice_t notice;
+       struct hostent *hent;
+       int retval;
+       register int i;
+       char *whoami,myhost[MAXHOSTNAMELEN],mysender[BUFSIZ];
+       char *lines[2];
+       
+       whoami = argv[0];
+
+       if ((retval = ZInitialize()) != ZERR_NONE) {
+               com_err(whoami,retval,"while initializing");
+               exit(1);
+       } 
+
+       if (argc < 2) {
+               usage(whoami);
+               exit(1);
+       }
+
+       if (gethostname(myhost,MAXHOSTNAMELEN) == -1) {
+               com_err(whoami,errno,"Can't get hostname");
+               exit(1);
+       }
+       myhost[MAXHOSTNAMELEN-1] = '\0';
+
+       if (!(hent = gethostbyname(myhost))) {
+               com_err(whoami,errno,"Can't get canonical hostname");
+               exit(1);
+       }
+
+       (void) strncpy(myhost,hent->h_name,MAXHOSTNAMELEN);
+       myhost[MAXHOSTNAMELEN-1] = '\0';
+
+       lines[0] = myhost;
+       lines[1] = "You have new mail.";
+       
+       (void) strcpy(mysender,"pop@");
+       (void) strcat(mysender,ZGetRealm());
+
+       for (i = 1; i < argc; i++) {
+           (void) memset((char *)&notice, 0, sizeof(notice));
+           notice.z_kind = UNSAFE;
+           notice.z_class = MAIL_CLASS;
+           notice.z_class_inst = MAIL_INSTANCE;
+           notice.z_opcode = "";
+           notice.z_sender = mysender;
+           notice.z_default_format = "From Post Office $1:\n$2";
+
+           /* in case it's a mailbox name (pathname), strip to username */
+           notice.z_recipient = (char *)strrchr(argv[i],'/');
+           if (notice.z_recipient)
+               notice.z_recipient++;
+           else
+               notice.z_recipient = argv[i];
+
+           if ((retval = ZSendList(&notice,lines,2,ZNOAUTH)) != ZERR_NONE) {
+               com_err(whoami,retval,"while sending notice");
+               exit(1);
+           } 
+       }
+}
+
+void
+usage(whoami)
+       char *whoami;
+{
+       printf("Usage: %s username [ username ... ]\n",whoami);
+}
index 4e2eaa0bf6d6c15619ee9fd3b433789596c5945d..4db5a32b61921c8956a215e080193b311f1fbb7f 100644 (file)
@@ -19,7 +19,7 @@
 #include <netdb.h>
 
 #ifndef lint
-static const char rcsid_zshutdown_notify_c[] =
+static const char *rcsid_zshutdown_notify_c =
     "$Id$";
 #endif
 
@@ -41,9 +41,9 @@ static const char rcsid_zshutdown_notify_c[] =
 static char warning[] = "Please detach any filesystems you may have\nattached from this host by typing detach -host %s";
 
 /*ARGSUSED*/
-int
-main(int argc,
-     char *argv[])
+main(argc,argv)
+    int argc;
+    char *argv[];
 {
     ZNotice_t notice;
     struct hostent *hp;
@@ -57,6 +57,7 @@ main(int argc,
     char rlm[REALM_SZ];
     char hn2[MAXHOSTNAMELEN];
     char *cp;
+    extern char *krb_get_phost();
 #endif
 
     if (gethostname(hostname, MAXHOSTNAMELEN) < 0) {
@@ -83,16 +84,14 @@ main(int argc,
        fprintf(stderr, "%s: can't figure out canonical hostname\n",argv[0]);
        exit(1);
     }
-    retval = krb_get_lrealm(rlm, 1);
-    if (retval) {
+    if (retval = krb_get_lrealm(rlm, 1)) {
        fprintf(stderr, "%s: can't get local realm: %s\n",
                argv[0], krb_get_err_text(retval));
        exit(1);
     }
-    retval = krb_get_svc_in_tkt(SVC_NAME, hn2, rlm,
-                               SERVER_SERVICE, SERVER_INSTANCE, 1,
-                               KEYFILE);
-    if (retval) {
+    if (retval = krb_get_svc_in_tkt(SVC_NAME, hn2, rlm,
+                                   SERVER_SERVICE, SERVER_INSTANCE, 1,
+                                   KEYFILE)) {
        fprintf(stderr, "%s: can't get tickets: %s\n",
                argv[0], krb_get_err_text(retval));
        exit(1);
index 2e0be612571a6dff2e9752e096ec484bb0a3fab5..0c034f9c8fb0483c0d0c16e00f9638f5ecd8d854 100644 (file)
@@ -15,8 +15,6 @@
 #include <internal.h>
 
 #include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
 #include "zserver.h"
 
 #if !defined(lint) && !defined(SABER)
@@ -49,20 +47,16 @@ int outoftime = 0;
 int serveronly = 0,hmonly = 0;
 u_short srv_port;
 
-void usage(char *);
-void do_stat(char *);
-int srv_stat(char *);
-int hm_stat(char *, char *);
+void usage(), do_stat();
 
-RETSIGTYPE
-timeout(int ignored)
+RETSIGTYPE timeout()
 {
        outoftime = 1;
 }
 
-int
-main(int argc,
-     char *argv[])
+main(argc, argv)
+       int argc;
+       char *argv[];
 {
        Code_t ret;
        char hostname[MAXHOSTNAMELEN];
@@ -120,7 +114,8 @@ main(int argc,
 }
 
 void
-do_stat(char *host)
+do_stat(host)
+       char *host;
 {
        char srv_host[MAXHOSTNAMELEN];
        
@@ -137,8 +132,8 @@ do_stat(char *host)
 }
 
 int
-hm_stat(char *host,
-       char *server)
+hm_stat(host,server)
+       char *host,*server;
 {
        struct in_addr inaddr;
        Code_t code;
@@ -149,6 +144,9 @@ hm_stat(char *host,
        time_t runtime;
        struct tm *tim;
        ZNotice_t notice;
+#ifdef _POSIX_VERSION
+       struct sigaction sa;
+#endif
        
        if ((inaddr.s_addr = inet_addr(host)) == (unsigned)(-1)) {
            if ((hp = gethostbyname(host)) == NULL) {
@@ -198,7 +196,8 @@ hm_stat(char *host,
 }
 
 int
-srv_stat(char *host)
+srv_stat(host)
+       char *host;
 {
        char *line[20],*mp;
        int sock,i,nf,ret;
@@ -309,7 +308,8 @@ srv_stat(char *host)
 }
 
 void
-usage(char *s)
+usage(s)
+       char *s;
 {
        fprintf(stderr,"usage: %s [-s] [-h] [host ...]\n",s);
        exit(1);
index 1774aafdbd2f8bc9fc571569977ba2b6b484c015..f5dba368a23c88cb449d97eeb7ae23b4c1d10f7c 100644 (file)
@@ -31,15 +31,14 @@ static const char rcsid_zwrite_c[] = "$Id$";
 int nrecips, msgarg, verbose, quiet, nodot, cc;
 char *whoami, *inst, *class, *opcode, *realm, *recips[MAXRECIPS];
 Z_AuthProc auth;
-void un_tabify(char **, int *);
+void un_tabify();
 
-char *fix_filsrv_inst(char *);
-void usage(char *);
-void send_off(ZNotice_t *, int);
+char *fix_filsrv_inst();
+void usage(), send_off();
 
-int
-main(int argc,
-     char *argv[])
+main(argc, argv)
+    int argc;
+    char *argv[];
 {
     int retval, arg, nocheck, nchars, msgsize, filsys, tabexpand;
     char *message, *signature = NULL, *format = NULL;
@@ -61,23 +60,20 @@ main(int argc,
     verbose = quiet = msgarg = nrecips = nocheck = filsys = nodot = 0;
     tabexpand = 1;
 
-    class = ZGetVariable("zwrite-class");
-    if (class) {
+    if (class = ZGetVariable("zwrite-class")) {
        (void) strcpy(classbfr, class);
        class = classbfr;
     }
     else
        class = DEFAULT_CLASS;
-    inst = ZGetVariable("zwrite-inst");
-    if (inst) {
+    if (inst = ZGetVariable("zwrite-inst")) {
        (void) strcpy(instbfr, inst);
        inst = instbfr;
     }
     else
        inst = DEFAULT_INSTANCE;
 
-    opcode = ZGetVariable("zwrite-opcode");
-    if (opcode)
+    if (opcode = ZGetVariable("zwrite-opcode"))
       opcode = strcpy(opbfr, opcode);
     else
       opcode = DEFAULT_OPCODE;
@@ -246,12 +242,11 @@ main(int argc,
     if (!nocheck && nrecips)
        send_off(&notice, 0);
        
-    if (!msgarg && isatty(0)) {
+    if (!msgarg && isatty(0))
        if (nodot)
            printf("Type your message now.  End with the end-of-file character.\n");
        else
            printf("Type your message now.  End with control-D or a dot on a line by itself.\n");
-    }
        
     message = NULL;
     msgsize = 0;
@@ -318,7 +313,7 @@ main(int argc,
            message = realloc(message, (unsigned)(msgsize+1));
        }
        else {  /* Use read so you can send binary messages... */
-           while ((nchars = read(fileno(stdin), bfr, sizeof bfr))) {
+           while (nchars = read(fileno(stdin), bfr, sizeof bfr)) {
                if (nchars == -1) {
                    fprintf(stderr, "Read error from stdin!  Can't continue!\n");
                    exit(1);
@@ -343,11 +338,12 @@ main(int argc,
 }
 
 void
-send_off(ZNotice_t *notice,
-        int real)
+send_off(notice, real)
+    ZNotice_t *notice;
+    int real;
 {
     int i, success, retval;
-    char bfr[BUFSIZ], realm_recip[BUFSIZ], dest[3 * BUFSIZ];
+    char bfr[BUFSIZ], realm_recip[BUFSIZ], dest[3 * BUFSIZ], *cp;
     ZNotice_t retnotice;
 
     success = 0;
@@ -449,7 +445,8 @@ send_off(ZNotice_t *notice,
 } 
 
 void
-usage(char *s)
+usage(s)
+    char *s;
 {
     fprintf(stderr,
            "Usage: %s [-a] [-o] [-d] [-v] [-q] [-n] [-t] [-u] [-l]\n\
@@ -469,8 +466,8 @@ usage(char *s)
   name returned by gethostbyname(hostname)
  */
 
-char *
-fix_filsrv_inst(char *str)
+char *fix_filsrv_inst(str)
+char *str;
 {
        static char fsinst[BUFSIZ];
        char *ptr;
@@ -503,8 +500,9 @@ fix_filsrv_inst(char *str)
 #endif /* ! TABSTOP */
 
 void
-un_tabify(char **bufp,
-         int *sizep)
+un_tabify(bufp, sizep)
+char **bufp;
+register int *sizep;
 {
     register char *cp, *cp2;
     char *cp3;
index 4466d3ba86fe48a54cfef7831f6636a8c87e430a..fac8b0f0ef9ed1b3415f7a3ffda03941c14fb420 100755 (executable)
@@ -860,7 +860,6 @@ TLIB
 RLIB
 SLIB
 KRB4_LIBS
-KRB5_LIBS
 HESIOD_LIBS
 REGEX_LIBS
 ARES_LIBS
@@ -1477,7 +1476,6 @@ Optional Packages:
   --with-tags[=TAGS]      include additional configurations [automatic]
   --with-x                use the X Window System
   --with-krb4=PREFIX      Use Kerberos 4
-  --with-krb5=PREFIX      Use Kerberos 5
   --with-hesiod=PREFIX    Use Hesiod
   --with-regex=PREFIX     Use installed regex library
   --with-ares=PREFIX      Use libares
@@ -4141,7 +4139,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 4144 "configure"' > conftest.$ac_ext
+  echo '#line 4142 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -6707,11 +6705,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6710: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6708: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:6714: \$? = $ac_status" >&5
+   echo "$as_me:6712: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -6940,11 +6938,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6943: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6941: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:6947: \$? = $ac_status" >&5
+   echo "$as_me:6945: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -7000,11 +6998,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7003: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7001: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:7007: \$? = $ac_status" >&5
+   echo "$as_me:7005: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -8330,7 +8328,7 @@ linux*)
   libsuff=
   case "$host_cpu" in
   x86_64*|s390x*|powerpc64*)
-    echo '#line 8333 "configure"' > conftest.$ac_ext
+    echo '#line 8331 "configure"' > conftest.$ac_ext
     if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -9168,7 +9166,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 9171 "configure"
+#line 9169 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -9266,7 +9264,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 9269 "configure"
+#line 9267 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11445,11 +11443,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:11448: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:11446: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:11452: \$? = $ac_status" >&5
+   echo "$as_me:11450: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -11505,11 +11503,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:11508: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:11506: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:11512: \$? = $ac_status" >&5
+   echo "$as_me:11510: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -12016,7 +12014,7 @@ linux*)
   libsuff=
   case "$host_cpu" in
   x86_64*|s390x*|powerpc64*)
-    echo '#line 12019 "configure"' > conftest.$ac_ext
+    echo '#line 12017 "configure"' > conftest.$ac_ext
     if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -12854,7 +12852,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12857 "configure"
+#line 12855 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12952,7 +12950,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12955 "configure"
+#line 12953 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13779,11 +13777,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13782: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13780: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:13786: \$? = $ac_status" >&5
+   echo "$as_me:13784: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -13839,11 +13837,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13842: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13840: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:13846: \$? = $ac_status" >&5
+   echo "$as_me:13844: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -15149,7 +15147,7 @@ linux*)
   libsuff=
   case "$host_cpu" in
   x86_64*|s390x*|powerpc64*)
-    echo '#line 15152 "configure"' > conftest.$ac_ext
+    echo '#line 15150 "configure"' > conftest.$ac_ext
     if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -15893,11 +15891,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15896: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15894: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:15900: \$? = $ac_status" >&5
+   echo "$as_me:15898: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -16126,11 +16124,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16129: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16127: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16133: \$? = $ac_status" >&5
+   echo "$as_me:16131: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -16186,11 +16184,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16189: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16187: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:16193: \$? = $ac_status" >&5
+   echo "$as_me:16191: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -17516,7 +17514,7 @@ linux*)
   libsuff=
   case "$host_cpu" in
   x86_64*|s390x*|powerpc64*)
-    echo '#line 17519 "configure"' > conftest.$ac_ext
+    echo '#line 17517 "configure"' > conftest.$ac_ext
     if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -18354,7 +18352,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 18357 "configure"
+#line 18355 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18452,7 +18450,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 18455 "configure"
+#line 18453 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -21043,8 +21041,7 @@ fi
 
 
 
-
-for ac_header in fcntl.h paths.h termios.h sgtty.h unistd.h malloc.h term.h
+for ac_header in fcntl.h paths.h termios.h sgtty.h unistd.h malloc.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -21330,9 +21327,7 @@ done
 
 
 
-
-
-for ac_header in sys/select.h sys/msgbuf.h sys/cdefs.h krb5_err.h termcap.h
+for ac_header in sys/select.h sys/msgbuf.h sys/cdefs.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -21473,6 +21468,7 @@ done
 
 
 if test "$no_x" != "yes"; then
+       XCLIENTS=xzwrite
        ZWGC_LIBX11=-lX11
 fi
 
@@ -24017,26 +24013,41 @@ _ACEOF
 fi
 
 
-# Check whether --with-krb5 was given.
-if test "${with_krb5+set}" = set; then
-  withval=$with_krb5; krb5="$withval"
+# Check whether --with-hesiod was given.
+if test "${with_hesiod+set}" = set; then
+  withval=$with_hesiod; hesiod="$withval"
 else
-  krb5=no
+  hesiod=no
 fi
 
-if test "$krb5" != no; then
-       { echo "$as_me:$LINENO: checking for library containing gethostbyname" >&5
-echo $ECHO_N "checking for library containing gethostbyname... $ECHO_C" >&6; }
-if test "${ac_cv_search_gethostbyname+set}" = set; then
+if test "$hesiod" != no; then
+       { echo "$as_me:$LINENO: checking for res_send" >&5
+echo $ECHO_N "checking for res_send... $ECHO_C" >&6; }
+if test "${ac_cv_func_res_send+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_func_search_save_LIBS=$LIBS
-cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
+/* Define res_send to an innocuous variant, in case <limits.h> declares res_send.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define res_send innocuous_res_send
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char res_send (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef res_send
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
@@ -24044,23 +24055,23 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef __cplusplus
 extern "C"
 #endif
-char gethostbyname ();
+char res_send ();
+/* 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_res_send || defined __stub___res_send
+choke me
+#endif
+
 int
 main ()
 {
-return gethostbyname ();
+return res_send ();
   ;
   return 0;
 }
 _ACEOF
-for ac_lib in '' nsl; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  rm -f conftest.$ac_objext conftest$ac_exeext
+rm -f conftest.$ac_objext conftest$ac_exeext
 if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
@@ -24078,42 +24089,30 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_search_gethostbyname=$ac_res
+  ac_cv_func_res_send=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
+       ac_cv_func_res_send=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext
-  if test "${ac_cv_search_gethostbyname+set}" = set; then
-  break
+      conftest$ac_exeext conftest.$ac_ext
 fi
-done
-if test "${ac_cv_search_gethostbyname+set}" = set; then
+{ echo "$as_me:$LINENO: result: $ac_cv_func_res_send" >&5
+echo "${ECHO_T}$ac_cv_func_res_send" >&6; }
+if test $ac_cv_func_res_send = yes; then
   :
 else
-  ac_cv_search_gethostbyname=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyname" >&5
-echo "${ECHO_T}$ac_cv_search_gethostbyname" >&6; }
-ac_res=$ac_cv_search_gethostbyname
-if test "$ac_res" != no; then
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
 
-{ echo "$as_me:$LINENO: checking for library containing socket" >&5
-echo $ECHO_N "checking for library containing socket... $ECHO_C" >&6; }
-if test "${ac_cv_search_socket+set}" = set; then
+{ echo "$as_me:$LINENO: checking for res_send in -lresolv" >&5
+echo $ECHO_N "checking for res_send in -lresolv... $ECHO_C" >&6; }
+if test "${ac_cv_lib_resolv_res_send+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_func_search_save_LIBS=$LIBS
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lresolv  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -24127,23 +24126,16 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef __cplusplus
 extern "C"
 #endif
-char socket ();
+char res_send ();
 int
 main ()
 {
-return socket ();
+return res_send ();
   ;
   return 0;
 }
 _ACEOF
-for ac_lib in '' socket; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  rm -f conftest.$ac_objext conftest$ac_exeext
+rm -f conftest.$ac_objext conftest$ac_exeext
 if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
@@ -24161,44 +24153,42 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_search_socket=$ac_res
+  ac_cv_lib_resolv_res_send=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
+       ac_cv_lib_resolv_res_send=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext
-  if test "${ac_cv_search_socket+set}" = set; then
-  break
-fi
-done
-if test "${ac_cv_search_socket+set}" = set; then
-  :
-else
-  ac_cv_search_socket=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_search_socket" >&5
-echo "${ECHO_T}$ac_cv_search_socket" >&6; }
-ac_res=$ac_cv_search_socket
-if test "$ac_res" != no; then
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_resolv_res_send" >&5
+echo "${ECHO_T}$ac_cv_lib_resolv_res_send" >&6; }
+if test $ac_cv_lib_resolv_res_send = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBRESOLV 1
+_ACEOF
+
+  LIBS="-lresolv $LIBS"
 
 fi
 
+fi
 
-{ echo "$as_me:$LINENO: checking for compile in -lgen" >&5
-echo $ECHO_N "checking for compile in -lgen... $ECHO_C" >&6; }
-if test "${ac_cv_lib_gen_compile+set}" = set; then
+if test "$hesiod" != yes; then
+       CPPFLAGS="$CPPFLAGS -I$hesiod/include"
+       LDFLAGS="$LDFLAGS -L$hesiod/lib"
+fi
+{ echo "$as_me:$LINENO: checking for hes_resolve in -lhesiod" >&5
+echo $ECHO_N "checking for hes_resolve in -lhesiod... $ECHO_C" >&6; }
+if test "${ac_cv_lib_hesiod_hes_resolve+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgen  $LIBS"
+LIBS="-lhesiod $LIBS $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -24212,11 +24202,11 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef __cplusplus
 extern "C"
 #endif
-char compile ();
+char hes_resolve ();
 int
 main ()
 {
-return compile ();
+return hes_resolve ();
   ;
   return 0;
 }
@@ -24239,40 +24229,55 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_gen_compile=yes
+  ac_cv_lib_hesiod_hes_resolve=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_lib_gen_compile=no
+       ac_cv_lib_hesiod_hes_resolve=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_gen_compile" >&5
-echo "${ECHO_T}$ac_cv_lib_gen_compile" >&6; }
-if test $ac_cv_lib_gen_compile = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBGEN 1
-_ACEOF
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_hesiod_hes_resolve" >&5
+echo "${ECHO_T}$ac_cv_lib_hesiod_hes_resolve" >&6; }
+if test $ac_cv_lib_hesiod_hes_resolve = yes; then
+  :
+else
+  { { echo "$as_me:$LINENO: error: Hesiod library not found" >&5
+echo "$as_me: error: Hesiod library not found" >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
-  LIBS="-lgen $LIBS"
+       HESIOD_LIBS="-lhesiod"
+       cat >>confdefs.h <<\_ACEOF
+#define HAVE_HESIOD 1
+_ACEOF
 
 fi
 
-if test "$krb5" != yes; then
-       CPPFLAGS="$CPPFLAGS -I$krb5/include"
-       LDFLAGS="$LDFLAGS -L$krb5/lib"
+
+# Check whether --with-regex was given.
+if test "${with_regex+set}" = set; then
+  withval=$with_regex; regex="$withval"
+else
+  regex=no
 fi
-{ echo "$as_me:$LINENO: checking for krb5_init_context in -lkrb5" >&5
-echo $ECHO_N "checking for krb5_init_context in -lkrb5... $ECHO_C" >&6; }
-if test "${ac_cv_lib_krb5_krb5_init_context+set}" = set; then
+
+if test "$regex" != no; then
+       if test "$regex" != yes; then
+               CPPFLAGS="$CPPFLAGS -I$regex/include"
+               LDFLAGS="$LDFLAGS -L$regex/lib"
+       fi
+       { echo "$as_me:$LINENO: checking for regcomp in -lregex" >&5
+echo $ECHO_N "checking for regcomp in -lregex... $ECHO_C" >&6; }
+if test "${ac_cv_lib_regex_regcomp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lkrb5 -lk5crypto -lcom_err $LIBS"
+LIBS="-lregex  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -24286,11 +24291,11 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef __cplusplus
 extern "C"
 #endif
-char krb5_init_context ();
+char regcomp ();
 int
 main ()
 {
-return krb5_init_context ();
+return regcomp ();
   ;
   return 0;
 }
@@ -24313,47 +24318,32 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_krb5_krb5_init_context=yes
+  ac_cv_lib_regex_regcomp=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_lib_krb5_krb5_init_context=no
+       ac_cv_lib_regex_regcomp=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_krb5_krb5_init_context" >&5
-echo "${ECHO_T}$ac_cv_lib_krb5_krb5_init_context" >&6; }
-if test $ac_cv_lib_krb5_krb5_init_context = yes; then
-  :
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_regex_regcomp" >&5
+echo "${ECHO_T}$ac_cv_lib_regex_regcomp" >&6; }
+if test $ac_cv_lib_regex_regcomp = yes; then
+  REGEX_LIBS=-lregex
 else
-  { { echo "$as_me:$LINENO: error: Kerberos 5 libraries not found" >&5
-echo "$as_me: error: Kerberos 5 libraries not found" >&2;}
+  { { echo "$as_me:$LINENO: error: regex library not found" >&5
+echo "$as_me: error: regex library not found" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
-       KRB5_LIBS="-lkrb5 -lk5crypto -lcom_err"
-       cat >>confdefs.h <<\_ACEOF
-#define HAVE_KRB5 1
-_ACEOF
-
-fi
-
-
-# Check whether --with-hesiod was given.
-if test "${with_hesiod+set}" = set; then
-  withval=$with_hesiod; hesiod="$withval"
 else
-  hesiod=no
-fi
-
-if test "$hesiod" != no; then
-       { echo "$as_me:$LINENO: checking for res_send" >&5
-echo $ECHO_N "checking for res_send... $ECHO_C" >&6; }
-if test "${ac_cv_func_res_send+set}" = set; then
+       { echo "$as_me:$LINENO: checking for regcomp" >&5
+echo $ECHO_N "checking for regcomp... $ECHO_C" >&6; }
+if test "${ac_cv_func_regcomp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
@@ -24362,12 +24352,12 @@ _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-/* Define res_send to an innocuous variant, in case <limits.h> declares res_send.
+/* Define regcomp to an innocuous variant, in case <limits.h> declares regcomp.
    For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define res_send innocuous_res_send
+#define regcomp innocuous_regcomp
 
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char res_send (); below.
+    which can conflict with char regcomp (); below.
     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
     <limits.h> exists even on freestanding compilers.  */
 
@@ -24377,7 +24367,7 @@ cat >>conftest.$ac_ext <<_ACEOF
 # include <assert.h>
 #endif
 
-#undef res_send
+#undef regcomp
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
@@ -24385,18 +24375,18 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef __cplusplus
 extern "C"
 #endif
-char res_send ();
+char regcomp ();
 /* 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_res_send || defined __stub___res_send
+#if defined __stub_regcomp || defined __stub___regcomp
 choke me
 #endif
 
 int
 main ()
 {
-return res_send ();
+return regcomp ();
   ;
   return 0;
 }
@@ -24419,353 +24409,33 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_func_res_send=yes
+  ac_cv_func_regcomp=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_func_res_send=no
+       ac_cv_func_regcomp=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_func_res_send" >&5
-echo "${ECHO_T}$ac_cv_func_res_send" >&6; }
-if test $ac_cv_func_res_send = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_func_regcomp" >&5
+echo "${ECHO_T}$ac_cv_func_regcomp" >&6; }
+if test $ac_cv_func_regcomp = yes; then
   :
 else
+  { { echo "$as_me:$LINENO: error: can't find POSIX regexp support" >&5
+echo "$as_me: error: can't find POSIX regexp support" >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
-{ echo "$as_me:$LINENO: checking for res_send in -lresolv" >&5
-echo $ECHO_N "checking for res_send in -lresolv... $ECHO_C" >&6; }
-if test "${ac_cv_lib_resolv_res_send+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lresolv  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char res_send ();
-int
-main ()
-{
-return res_send ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_resolv_res_send=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_cv_lib_resolv_res_send=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_resolv_res_send" >&5
-echo "${ECHO_T}$ac_cv_lib_resolv_res_send" >&6; }
-if test $ac_cv_lib_resolv_res_send = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBRESOLV 1
-_ACEOF
-
-  LIBS="-lresolv $LIBS"
-
-fi
-
-fi
-
-if test "$hesiod" != yes; then
-       CPPFLAGS="$CPPFLAGS -I$hesiod/include"
-       LDFLAGS="$LDFLAGS -L$hesiod/lib"
-fi
-{ echo "$as_me:$LINENO: checking for hes_resolve in -lhesiod" >&5
-echo $ECHO_N "checking for hes_resolve in -lhesiod... $ECHO_C" >&6; }
-if test "${ac_cv_lib_hesiod_hes_resolve+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lhesiod $LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char hes_resolve ();
-int
-main ()
-{
-return hes_resolve ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_hesiod_hes_resolve=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_cv_lib_hesiod_hes_resolve=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_hesiod_hes_resolve" >&5
-echo "${ECHO_T}$ac_cv_lib_hesiod_hes_resolve" >&6; }
-if test $ac_cv_lib_hesiod_hes_resolve = yes; then
-  :
-else
-  { { echo "$as_me:$LINENO: error: Hesiod library not found" >&5
-echo "$as_me: error: Hesiod library not found" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-       HESIOD_LIBS="-lhesiod"
-       cat >>confdefs.h <<\_ACEOF
-#define HAVE_HESIOD 1
-_ACEOF
-
-fi
-
-
-# Check whether --with-regex was given.
-if test "${with_regex+set}" = set; then
-  withval=$with_regex; regex="$withval"
-else
-  regex=no
-fi
-
-if test "$regex" != no; then
-       if test "$regex" != yes; then
-               CPPFLAGS="$CPPFLAGS -I$regex/include"
-               LDFLAGS="$LDFLAGS -L$regex/lib"
-       fi
-       { echo "$as_me:$LINENO: checking for regcomp in -lregex" >&5
-echo $ECHO_N "checking for regcomp in -lregex... $ECHO_C" >&6; }
-if test "${ac_cv_lib_regex_regcomp+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lregex  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char regcomp ();
-int
-main ()
-{
-return regcomp ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_regex_regcomp=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_cv_lib_regex_regcomp=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_regex_regcomp" >&5
-echo "${ECHO_T}$ac_cv_lib_regex_regcomp" >&6; }
-if test $ac_cv_lib_regex_regcomp = yes; then
-  REGEX_LIBS=-lregex
-else
-  { { echo "$as_me:$LINENO: error: regex library not found" >&5
-echo "$as_me: error: regex library not found" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-else
-       { echo "$as_me:$LINENO: checking for regcomp" >&5
-echo $ECHO_N "checking for regcomp... $ECHO_C" >&6; }
-if test "${ac_cv_func_regcomp+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define regcomp to an innocuous variant, in case <limits.h> declares regcomp.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define regcomp innocuous_regcomp
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char regcomp (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef regcomp
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char regcomp ();
-/* 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_regcomp || defined __stub___regcomp
-choke me
-#endif
-
-int
-main ()
-{
-return regcomp ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_func_regcomp=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_cv_func_regcomp=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_func_regcomp" >&5
-echo "${ECHO_T}$ac_cv_func_regcomp" >&6; }
-if test $ac_cv_func_regcomp = yes; then
-  :
-else
-  { { echo "$as_me:$LINENO: error: can't find POSIX regexp support" >&5
-echo "$as_me: error: can't find POSIX regexp support" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-fi
-
-
-# Check whether --with-ares was given.
-if test "${with_ares+set}" = set; then
-  withval=$with_ares; ares="$withval"
+fi
+
+
+# Check whether --with-ares was given.
+if test "${with_ares+set}" = set; then
+  withval=$with_ares; ares="$withval"
 else
   ares=no
 fi
@@ -25324,7 +24994,7 @@ else
 echo "$as_me: error: This package requires ss." >&2;}
    { (exit 1); exit 1; }; }
 fi
-LIBS="$KRB5_LIBS $KRB4_LIBS $HESIOD_LIBS $LIBS"
+LIBS="$KRB4_LIBS $HESIOD_LIBS $LIBS"
 
 if test $ac_cv_c_compiler_gnu = yes; then
     { echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5
 done
 
 
-
-
-for ac_func in krb5_free_data krb5_c_make_checksum krb5_cc_set_default_name
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
-if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char $ac_func ();
-/* 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_$ac_func || defined __stub___$ac_func
-choke me
-#endif
-
-int
-main ()
-{
-return $ac_func ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  eval "$as_ac_var=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       eval "$as_ac_var=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-ac_res=`eval echo '${'$as_ac_var'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
-{ echo "$as_me:$LINENO: checking for krb5_auth_con_getauthenticator taking double pointer" >&5
-echo $ECHO_N "checking for krb5_auth_con_getauthenticator taking double pointer... $ECHO_C" >&6; }
-if test "${ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-local_save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#define socklen_t int
-#define ssize_t int
-#include <krb5.h>
-krb5_error_code
-krb5_auth_con_getauthenticator(krb5_context context,
-                           krb5_auth_context auth_context,
-                           krb5_authenticator *authenticator);
-int
-main ()
-{
-krb5_error_code foo = krb5_auth_con_getauthenticator(0, 0, 0);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer=no
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer=yes
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-
-CPPFLAGS="${local_save_CPPFLAGS}"
-if test "$ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer" = yes; then
-        cat >>confdefs.h <<\_ACEOF
-#define KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER 1
-_ACEOF
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer" >&5
-echo "${ECHO_T}$ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer" >&6; }
-
-{ echo "$as_me:$LINENO: checking for enc_part2 in struct krb5_ticket" >&5
-echo $ECHO_N "checking for enc_part2 in struct krb5_ticket... $ECHO_C" >&6; }
-if test "${ac_cv_have_krb5_ticket_enc_part2+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-local_save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <krb5.h>
-int
-main ()
-{
-krb5_ticket _tkt; _tkt.enc_part2;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_have_krb5_ticket_enc_part2=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_cv_have_krb5_ticket_enc_part2=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-
-CPPFLAGS="${local_save_CPPFLAGS}"
-if test "$ac_cv_have_krb5_ticket_enc_part2" = yes; then
-       cat >>confdefs.h <<\_ACEOF
-#define HAVE_KRB5_TICKET_ENC_PART2 1
-_ACEOF
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_have_krb5_ticket_enc_part2" >&5
-echo "${ECHO_T}$ac_cv_have_krb5_ticket_enc_part2" >&6; }
-
-{ echo "$as_me:$LINENO: checking for enctype in struct krb5_keyblock" >&5
-echo $ECHO_N "checking for enctype in struct krb5_keyblock... $ECHO_C" >&6; }
-if test "${ac_cv_have_krb5_creds_keyblock_enctype+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-local_save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <krb5.h>
-int
-main ()
-{
-krb5_creds _creds; _creds.keyblock.enctype;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_have_krb5_creds_keyblock_enctype=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_cv_have_krb5_creds_keyblock_enctype=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-
-CPPFLAGS="${local_save_CPPFLAGS}"
-if test "$ac_cv_have_krb5_creds_keyblock_enctype" = yes; then
-       cat >>confdefs.h <<\_ACEOF
-#define HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE 1
-_ACEOF
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_have_krb5_creds_keyblock_enctype" >&5
-echo "${ECHO_T}$ac_cv_have_krb5_creds_keyblock_enctype" >&6; }
-
 ac_config_headers="$ac_config_headers h/config.h"
 
-ac_config_files="$ac_config_files Makefile clients/Makefile clients/zaway/Makefile clients/zctl/Makefile clients/zleave/Makefile clients/zlocate/Makefile clients/znol/Makefile clients/zshutdown_notify/Makefile clients/zstat/Makefile clients/zwrite/Makefile lib/Makefile libdyn/Makefile server/Makefile zhm/Makefile zwgc/Makefile"
+ac_config_files="$ac_config_files Makefile clients/Makefile clients/xzwrite/Makefile clients/zaway/Makefile clients/zctl/Makefile clients/zleave/Makefile clients/zlocate/Makefile clients/zmailnotify/Makefile clients/znol/Makefile clients/zpopnotify/Makefile clients/zshutdown_notify/Makefile clients/zstat/Makefile clients/zwrite/Makefile lib/Makefile libdyn/Makefile server/Makefile zhm/Makefile zwgc/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
     "h/config.h") CONFIG_HEADERS="$CONFIG_HEADERS h/config.h" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "clients/Makefile") CONFIG_FILES="$CONFIG_FILES clients/Makefile" ;;
+    "clients/xzwrite/Makefile") CONFIG_FILES="$CONFIG_FILES clients/xzwrite/Makefile" ;;
     "clients/zaway/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zaway/Makefile" ;;
     "clients/zctl/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zctl/Makefile" ;;
     "clients/zleave/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zleave/Makefile" ;;
     "clients/zlocate/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zlocate/Makefile" ;;
+    "clients/zmailnotify/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zmailnotify/Makefile" ;;
     "clients/znol/Makefile") CONFIG_FILES="$CONFIG_FILES clients/znol/Makefile" ;;
+    "clients/zpopnotify/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zpopnotify/Makefile" ;;
     "clients/zshutdown_notify/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zshutdown_notify/Makefile" ;;
     "clients/zstat/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zstat/Makefile" ;;
     "clients/zwrite/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zwrite/Makefile" ;;
@@ -26904,10 +26292,10 @@ TLIB!$TLIB$ac_delim
 RLIB!$RLIB$ac_delim
 SLIB!$SLIB$ac_delim
 KRB4_LIBS!$KRB4_LIBS$ac_delim
-KRB5_LIBS!$KRB5_LIBS$ac_delim
 HESIOD_LIBS!$HESIOD_LIBS$ac_delim
 REGEX_LIBS!$REGEX_LIBS$ac_delim
 ARES_LIBS!$ARES_LIBS$ac_delim
+LIBOBJS!$LIBOBJS$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -26949,11 +26337,10 @@ _ACEOF
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
-LIBOBJS!$LIBOBJS$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 2; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 1; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
index 57b97df9b28728e35102a138df0cdbdefa9d88ec..c894ab82df8760e44057f1ad57c5ce31d51841e6 100644 (file)
@@ -35,11 +35,12 @@ dnl Checks for header files.
 AC_PATH_XTRA
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(fcntl.h paths.h termios.h sgtty.h unistd.h malloc.h term.h)
+AC_CHECK_HEADERS(fcntl.h paths.h termios.h sgtty.h unistd.h malloc.h)
 AC_CHECK_HEADERS(sys/filio.h sys/ioctl.h sys/time.h sys/file.h sys/utsname.h)
-AC_CHECK_HEADERS(sys/select.h sys/msgbuf.h sys/cdefs.h krb5_err.h termcap.h)
+AC_CHECK_HEADERS(sys/select.h sys/msgbuf.h sys/cdefs.h)
 
 if test "$no_x" != "yes"; then
+       XCLIENTS=xzwrite
        ZWGC_LIBX11=-lX11
 fi
 AC_SUBST(XCLIENTS)
@@ -85,13 +86,12 @@ AC_SUBST(RLIB)
 AC_SUBST(SLIB)
 
 ATHENA_KRB4
-ATHENA_KRB5
 ATHENA_HESIOD
 ATHENA_REGEXP
 ATHENA_ARES
 ATHENA_UTIL_COM_ERR
 ATHENA_UTIL_SS
-LIBS="$KRB5_LIBS $KRB4_LIBS $HESIOD_LIBS $LIBS"
+LIBS="$KRB4_LIBS $HESIOD_LIBS $LIBS"
 
 dnl Checks for library functions.
 AC_PROG_GCC_TRADITIONAL
@@ -100,64 +100,12 @@ AC_FUNC_GETPGRP
 AC_FUNC_SETPGRP
 AC_CHECK_FUNCS(putenv strchr memcpy memmove waitpid getlogin strerror random)
 AC_CHECK_FUNCS(lrand48 gethostid getsid getpgid krb_get_err_text krb_log)
-AC_CHECK_FUNCS(krb5_free_data krb5_c_make_checksum krb5_cc_set_default_name)
-
-AC_MSG_CHECKING(for krb5_auth_con_getauthenticator taking double pointer)
-AC_CACHE_VAL(ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer, [
-local_save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
-AC_TRY_COMPILE(
-[#define socklen_t int
-#define ssize_t int
-#include <krb5.h>
-krb5_error_code
-krb5_auth_con_getauthenticator(krb5_context context,
-                           krb5_auth_context auth_context,
-                           krb5_authenticator *authenticator);],
-[krb5_error_code foo = krb5_auth_con_getauthenticator(0, 0, 0);],
-ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer=no,
-ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer=yes)
-])
-CPPFLAGS="${local_save_CPPFLAGS}"
-if test "$ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer" = yes; then
-        AC_DEFINE(KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER)dnl
-fi
-AC_MSG_RESULT($ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer)
-
-AC_MSG_CHECKING(for enc_part2 in struct krb5_ticket)
-AC_CACHE_VAL(ac_cv_have_krb5_ticket_enc_part2, [
-local_save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
-AC_TRY_COMPILE(
-[#include <krb5.h>], [krb5_ticket _tkt; _tkt.enc_part2;],
-ac_cv_have_krb5_ticket_enc_part2=yes,
-ac_cv_have_krb5_ticket_enc_part2=no)
-])
-CPPFLAGS="${local_save_CPPFLAGS}"
-if test "$ac_cv_have_krb5_ticket_enc_part2" = yes; then
-       AC_DEFINE(HAVE_KRB5_TICKET_ENC_PART2)dnl
-fi
-AC_MSG_RESULT($ac_cv_have_krb5_ticket_enc_part2)
-
-AC_MSG_CHECKING(for enctype in struct krb5_keyblock)
-AC_CACHE_VAL(ac_cv_have_krb5_creds_keyblock_enctype, [
-local_save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
-AC_TRY_COMPILE(
-[#include <krb5.h>], [krb5_creds _creds; _creds.keyblock.enctype;],
-ac_cv_have_krb5_creds_keyblock_enctype=yes,
-ac_cv_have_krb5_creds_keyblock_enctype=no)
-])
-CPPFLAGS="${local_save_CPPFLAGS}"
-if test "$ac_cv_have_krb5_creds_keyblock_enctype" = yes; then
-       AC_DEFINE(HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE)dnl
-fi
-AC_MSG_RESULT($ac_cv_have_krb5_creds_keyblock_enctype)
 
 AC_CONFIG_HEADER(h/config.h)
-AC_OUTPUT(Makefile clients/Makefile clients/zaway/Makefile
-          clients/zctl/Makefile clients/zleave/Makefile
-          clients/zlocate/Makefile clients/znol/Makefile
-          clients/zshutdown_notify/Makefile clients/zstat/Makefile
-          clients/zwrite/Makefile lib/Makefile libdyn/Makefile
-          server/Makefile zhm/Makefile zwgc/Makefile)
+AC_OUTPUT(Makefile clients/Makefile clients/xzwrite/Makefile
+         clients/zaway/Makefile clients/zctl/Makefile
+         clients/zleave/Makefile clients/zlocate/Makefile
+         clients/zmailnotify/Makefile clients/znol/Makefile
+         clients/zpopnotify/Makefile clients/zshutdown_notify/Makefile
+         clients/zstat/Makefile clients/zwrite/Makefile lib/Makefile
+         libdyn/Makefile server/Makefile zhm/Makefile zwgc/Makefile)
index 4c1bc24f2add36994f8aba5d3909737190c57403..a4a5c4fbc6caa52df269d106ea15e6a3680844f0 100644 (file)
@@ -1,9 +1,3 @@
-zephyr (3.0~a1) unstable; urgency=low
-
-  * Kerberos 5 client support; new upstream?
-
- -- Karl Ramm <kcr@1ts.org>  Tue, 25 Dec 2007 00:01:24 -0500
-
 zephyr (2.1.20070719.SNAPSHOT-2) unstable; urgency=low
 
   * Z_SendLocation could be fooled by the USER_LOGIN message (which has
index df8502e3347cd1c40649ff5883b84307a3c5de84..a7d50583a02a8155b1f47135314dd1d805c7b2c8 100644 (file)
@@ -20,7 +20,7 @@ Description: The original "Instant Message" system libraries without Kerberos
 Package: libzephyr3-krb
 Section: libs
 Architecture: any
-Depends: ${shlibs:Depends}, krb5-config
+Depends: ${shlibs:Depends}, krb4-config
 Conflicts: libzephyr3
 Provides: libzephyr3
 Description: The original "Instant Message" system libraries with Kerberos 
index 47f6af068568a7f71e8727b4d3d47ae89aa93d5a..ffab8801b025944e4e085adff04dbf60e44fc497 100755 (executable)
@@ -51,9 +51,9 @@ configure-stamp:
        dh_testdir
        # Add here commands to configure the package.
        -mkdir krb
-       cd krb&& CFLAGS="-g -Wall" ../configure --with-krb4=/usr --with-krb5=/usr $(CONFIGURE_ROOT)
+       cd krb&&../configure --with-krb4=/usr $(CONFIGURE_ROOT)
        -mkdir no-krb
-       cd no-krb&& CFLAGS=-g ../configure $(CONFIGURE_ROOT)
+       cd no-krb&&../configure $(CONFIGURE_ROOT)
        touch configure-stamp
 
 build: configure-stamp build-stamp
@@ -126,11 +126,20 @@ binary-arch: build install
        dh_movefiles --sourcedir=debian/tmp-krb -plibzephyr3-krb -pzephyr-server-krb
        dh_installdebconf 
        dh_installdocs
+#      dh_installexamples
+#      dh_installmenu
+#      dh_installemacsen
+#      dh_installpam
        dh_installinit -pzephyr-clients --init-script=zhm --no-start
        dh_installinit -pzephyr-server-krb --init-script=zephyrd
        dh_installinit -pzephyr-server --init-script=zephyrd
+#      dh_installcron
+#      dh_installmanpages
+#      dh_installinfo
+#      dh_undocumented
        dh_installchangelogs 
        dh_strip
+#      dh_link
        dh_compress
        dh_fixperms
        # You may want to make some executables suid here.
@@ -139,6 +148,7 @@ binary-arch: build install
        cp debian/libzephyr3/DEBIAN/shlibs debian/libzephyr3-krb/DEBIAN/shlibs
        dh_shlibdeps
        dh_installdeb
+#      dh_perl
        dh_gencontrol
        dh_md5sums
        dh_builddeb
index 5ed8da9ae8a8b86932e91541b8940c4798bab60d..643eb7f62249473b04acccd94866a60321d0a7d7 100644 (file)
@@ -39,4 +39,4 @@ fi
 
 db_input high zephyr-clients/servers || true
 
-db_go || true
+db_go
index e358728eefcc50dcdacdd6b493c85db752507000..40ff3c242565157cf765759b20c36d3662f98ad5 100644 (file)
@@ -40,7 +40,7 @@ case "$1" in
 
        # if /etc/default/zephyr-clients already exists and has a zhm_args
         # line, the config script should have sucked it into debconf
-       db_get zephyr-clients/servers || true
+       db_get zephyr-clients/servers
 
        tmpfile=/etc/default/zephyr-client.dpkg-new
        if test -f /etc/default/zephyr-clients
index 3d38e3e6dd6b30132d12f53910387ebfee4095eb..0b9cccbedd6b709517f4f177e372ab761df2c7a2 100644 (file)
@@ -3,18 +3,6 @@
 . /usr/share/debconf/confmodule
 db_version 2.0
 
-db_get zephyr-server/read_conf
-if test -f /etc/zephyr/server.list -a \( "$RET" = true \)
-then
-       z="`cat /etc/zephyr/server.list`"
-       
-       if test -n "$z"
-       then
-               db_set zephyr-server/read_conf false
-               db_set zephyr-server/servers "$z"
-       fi
-fi
-
 db_get zephyr-server/servers || true
 if test -z "$RET"
 then
@@ -29,5 +17,17 @@ then
        db_set zephyr-server/servers "$z"
 fi
 
+db_get zephyr-server/read_conf
+if test -f /etc/zephyr/server.list -a \( "$RET" = true \)
+then
+       z="`cat /etc/zephyr/server.list`"
+       
+       if test -n "$z"
+       then
+               db_set zephyr-server/read_conf false
+               db_set zephyr-server/servers "$z"
+       fi
+fi
+
 db_input high zephyr-server/servers || true
-db_go || true
+db_go
index 014ab5edcce8229525e93e5a17fa3a53447ba3e9..3157084d29c45bc29729ec14feeb40d15722f70a 100644 (file)
@@ -24,21 +24,19 @@ set -e
 
 case "$1" in
     configure)
-       if test ! -f /etc/zephyr/server.list; then
-           # if there's a server.list file, don't mess with it
-           . /usr/share/debconf/confmodule
-
-           db_version 2.0
-           
-           db_set zephyr-server/read_conf true
-           
-           db_get zephyr-server/servers || true
-           : > /etc/zephyr/server.list
-           for i in $RET
-           do
+
+       . /usr/share/debconf/confmodule
+       db_version 2.0
+
+       db_set zephyr-server/read_conf true
+
+       db_get zephyr-server/servers
+       : > /etc/zephyr/server.list
+       for i in $RET
+       do
                echo $i >> /etc/zephyr/server.list
-           done
-       fi
+       done
+
     ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)
index 40c0a3e4ebd8c05a70c118bb2ea1b7d149f3438f..1a3dd61b5c8518999b5bb9e925bd7cab4422e981 100644 (file)
@@ -1,42 +1,40 @@
-/* h/config.h.in.  Generated from configure.in by autoheader.  */
-/* Define to compile with Hesiod support. */
-#undef HAVE_HESIOD
+/* h/config.h.in.  Generated automatically from configure.in by autoheader.  */
 
-/* Define to compile with Kerberos support. */
-#undef HAVE_KRB4
+/* Define if the `getpgrp' function takes no argument.  */
+#undef GETPGRP_VOID
 
-/* Define to compile with Kerberos v5 support. */
-#undef HAVE_KRB5
+/* Define to `int' if <sys/types.h> doesn't define.  */
+#undef gid_t
 
-/* Define to 1 if `enc_part2' is member of `krb5_ticket'. */
-#undef HAVE_KRB5_TICKET_ENC_PART2
+/* Define if you don't have vprintf but do have _doprnt.  */
+#undef HAVE_DOPRNT
 
-/* Define to 1 if `keyblock.enctype' is member of `krb5_creds'. */
-#undef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
+/* Define if you have <sys/wait.h> that is POSIX.1 compatible.  */
+#undef HAVE_SYS_WAIT_H
 
-/* Define to 1 if you have the `krb5_c_make_checksum' function. */
-#undef HAVE_KRB5_C_MAKE_CHECKSUM
+/* Define if you have the vprintf function.  */
+#undef HAVE_VPRINTF
 
-/* Define to 1 if you have the `krb5_cc_set_default_name' function. */
-#undef HAVE_KRB5_CC_SET_DEFAULT_NAME
+/* Define as the return type of signal handlers (int or void).  */
+#undef RETSIGTYPE
 
-/* Define to 1 if `krb5_auth_con_getauthenticator' takes a double pointer third arg. */
-#undef KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER
+/* Define if the `setpgrp' function takes no argument.  */
+#undef SETPGRP_VOID
 
-/* Define to 1 if you have the <krb5_err.h> header file. */
-#undef HAVE_KRB5_ERR_H
+/* Define if you have the ANSI C header files.  */
+#undef STDC_HEADERS
 
-/* Define to 1 if you have the `krb5_free_data' function. */
-#undef HAVE_KRB5_FREE_DATA
+/* Define to `int' if <sys/types.h> doesn't define.  */
+#undef uid_t
 
-/* Define to 1 if you have the <krb5/ss.h> header file. */
-#undef HAVE_KRB5_SS_H
+/* Define if the X Window System is missing or not being used.  */
+#undef X_DISPLAY_MISSING
 
-/* Define to 1 if you have the `krb_get_err_text' function. */
-#undef HAVE_KRB_GET_ERR_TEXT
+/* Define to compile with Hesiod support. */
+#undef HAVE_HESIOD
 
-/* Define to 1 if you have the `krb_log' function. */
-#undef HAVE_KRB_LOG
+/* Define to compile with Kerberos support. */
+#undef HAVE_KRB4
 
 /* Define to compile with ares support. */
 #undef HAVE_ARES
 /* Define if you have the System Resource Controller library. */
 #undef HAVE_SRC
 
-/* Define to "unsigned long" if your system headers don't. */
-#undef ulong
-
 /* Define to a temporary directory on your system. */
 #define FOUND_TMP "/var/tmp"
 
 /* Define to the type of the host system. */
 #define MACHINE_TYPE "unknown"
 
-/* Define if `regcomp' exists and works. */
-#undef HAVE_REGCOMP
-
-
-/* Define to 1 if the `getpgrp' function requires zero arguments. */
-#undef GETPGRP_VOID
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
+/* The number of bytes in a int.  */
+#undef SIZEOF_INT
 
-/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
-#undef HAVE_DOPRNT
+/* The number of bytes in a long.  */
+#undef SIZEOF_LONG
 
-/* Define to 1 if you have the <fcntl.h> header file. */
-#undef HAVE_FCNTL_H
+/* The number of bytes in a short.  */
+#undef SIZEOF_SHORT
 
-/* Define to 1 if you have the `gethostid' function. */
+/* Define if you have the gethostid function.  */
 #undef HAVE_GETHOSTID
 
-/* Define to 1 if you have the `getlogin' function. */
+/* Define if you have the getlogin function.  */
 #undef HAVE_GETLOGIN
 
-/* Define to 1 if you have the `getpgid' function. */
+/* Define if you have the getpgid function.  */
 #undef HAVE_GETPGID
 
-/* Define to 1 if you have the `getsid' function. */
+/* Define if you have the getsid function.  */
 #undef HAVE_GETSID
 
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `krb5_cc_set_default_name' function. */
-#undef HAVE_KRB5_CC_SET_DEFAULT_NAME
-
-/* Define to 1 if you have the `krb5_c_make_checksum' function. */
-#undef HAVE_KRB5_C_MAKE_CHECKSUM
-
-/* Define to 1 if you have the <krb5_err.h> header file. */
-#undef HAVE_KRB5_ERR_H
-
-/* Define to 1 if you have the `krb5_free_data' function. */
-#undef HAVE_KRB5_FREE_DATA
-
-/* Define to 1 if you have the `krb_get_err_text' function. */
+/* Define if you have the krb_get_err_text function.  */
 #undef HAVE_KRB_GET_ERR_TEXT
 
-/* Define to 1 if you have the `krb_log' function. */
+/* Define if you have the krb_log function.  */
 #undef HAVE_KRB_LOG
 
-/* Define to 1 if you have the `44bsd' library (-l44bsd). */
-#undef HAVE_LIB44BSD
-
-/* Define to 1 if you have the `curses' library (-lcurses). */
-#undef HAVE_LIBCURSES
-
-/* Define to 1 if you have the `dl' library (-ldl). */
-#undef HAVE_LIBDL
-
-/* Define to 1 if you have the `gen' library (-lgen). */
-#undef HAVE_LIBGEN
-
-/* Define to 1 if you have the `nsl' library (-lnsl). */
-#undef HAVE_LIBNSL
-
-/* Define to 1 if you have the `readline' library (-lreadline). */
-#undef HAVE_LIBREADLINE
-
-/* Define to 1 if you have the `resolv' library (-lresolv). */
-#undef HAVE_LIBRESOLV
-
-/* Define to 1 if you have the `socket' library (-lsocket). */
-#undef HAVE_LIBSOCKET
-
-/* Define to 1 if you have the `w' library (-lw). */
-#undef HAVE_LIBW
-
-/* Define to 1 if you have the `lrand48' function. */
+/* Define if you have the lrand48 function.  */
 #undef HAVE_LRAND48
 
-/* Define to 1 if you have the <malloc.h> header file. */
-#undef HAVE_MALLOC_H
-
-/* Define to 1 if you have the `memcpy' function. */
+/* Define if you have the memcpy function.  */
 #undef HAVE_MEMCPY
 
-/* Define to 1 if you have the `memmove' function. */
+/* Define if you have the memmove function.  */
 #undef HAVE_MEMMOVE
 
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <paths.h> header file. */
-#undef HAVE_PATHS_H
-
-/* Define to 1 if you have the `putenv' function. */
+/* Define if you have the putenv function.  */
 #undef HAVE_PUTENV
 
-/* Define to 1 if you have the `random' function. */
+/* Define if you have the random function.  */
 #undef HAVE_RANDOM
 
-/* Define to 1 if you have the <sgtty.h> header file. */
-#undef HAVE_SGTTY_H
+/* Define if you have the strchr function.  */
+#undef HAVE_STRCHR
 
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
+/* Define if you have the strerror function.  */
+#undef HAVE_STRERROR
 
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
+/* Define if you have the waitpid function.  */
+#undef HAVE_WAITPID
 
-/* Define to 1 if you have the `strchr' function. */
-#undef HAVE_STRCHR
+/* Define if you have the <fcntl.h> header file.  */
+#undef HAVE_FCNTL_H
 
-/* Define to 1 if you have the `strerror' function. */
-#undef HAVE_STRERROR
+/* Define if you have the <malloc.h> header file.  */
+#undef HAVE_MALLOC_H
 
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
+/* Define if you have the <paths.h> header file.  */
+#undef HAVE_PATHS_H
 
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
+/* Define if you have the <sgtty.h> header file.  */
+#undef HAVE_SGTTY_H
 
-/* Define to 1 if you have the <sys/cdefs.h> header file. */
+/* Define if you have the <sys/cdefs.h> header file.  */
 #undef HAVE_SYS_CDEFS_H
 
-/* Define to 1 if you have the <sys/file.h> header file. */
+/* Define if you have the <sys/file.h> header file.  */
 #undef HAVE_SYS_FILE_H
 
-/* Define to 1 if you have the <sys/filio.h> header file. */
+/* Define if you have the <sys/filio.h> header file.  */
 #undef HAVE_SYS_FILIO_H
 
-/* Define to 1 if you have the <sys/ioctl.h> header file. */
+/* Define if you have the <sys/ioctl.h> header file.  */
 #undef HAVE_SYS_IOCTL_H
 
-/* Define to 1 if you have the <sys/msgbuf.h> header file. */
+/* Define if you have the <sys/msgbuf.h> header file.  */
 #undef HAVE_SYS_MSGBUF_H
 
-/* Define to 1 if you have the <sys/select.h> header file. */
+/* Define if you have the <sys/select.h> header file.  */
 #undef HAVE_SYS_SELECT_H
 
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/time.h> header file. */
+/* Define if you have the <sys/time.h> header file.  */
 #undef HAVE_SYS_TIME_H
 
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <sys/utsname.h> header file. */
+/* Define if you have the <sys/utsname.h> header file.  */
 #undef HAVE_SYS_UTSNAME_H
 
-/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
-#undef HAVE_SYS_WAIT_H
-
-/* Define to 1 if you have the <termcap.h> header file. */
-#undef HAVE_TERMCAP_H
-
-/* Define to 1 if you have the <termios.h> header file. */
+/* Define if you have the <termios.h> header file.  */
 #undef HAVE_TERMIOS_H
 
-/* Define to 1 if you have the <term.h> header file. */
-#undef HAVE_TERM_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
+/* Define if you have the <unistd.h> header file.  */
 #undef HAVE_UNISTD_H
 
-/* Define to 1 if you have the `vprintf' function. */
-#undef HAVE_VPRINTF
-
-/* Define to 1 if you have the `waitpid' function. */
-#undef HAVE_WAITPID
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define as the return type of signal handlers (`int' or `void'). */
-#undef RETSIGTYPE
-
-/* Define to 1 if the `setpgrp' function takes no argument. */
-#undef SETPGRP_VOID
-
-/* The size of `int', as computed by sizeof. */
-#undef SIZEOF_INT
-
-/* The size of `long', as computed by sizeof. */
-#undef SIZEOF_LONG
+/* Define if you have the 44bsd library (-l44bsd).  */
+#undef HAVE_LIB44BSD
 
-/* The size of `short', as computed by sizeof. */
-#undef SIZEOF_SHORT
+/* Define if you have the dl library (-ldl).  */
+#undef HAVE_LIBDL
 
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
+/* Define if you have the gen library (-lgen).  */
+#undef HAVE_LIBGEN
 
-/* Define to 1 if the X Window System is missing or not being used. */
-#undef X_DISPLAY_MISSING
+/* Define if you have the nsl library (-lnsl).  */
+#undef HAVE_LIBNSL
 
-/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
-   `char[]'. */
-#undef YYTEXT_POINTER
+/* Define if you have the resolv library (-lresolv).  */
+#undef HAVE_LIBRESOLV
 
-/* Define to `int' if <sys/types.h> doesn't define. */
-#undef gid_t
+/* Define if you have the socket library (-lsocket).  */
+#undef HAVE_LIBSOCKET
 
-/* Define to `int' if <sys/types.h> doesn't define. */
-#undef uid_t
+/* Define if you have the w library (-lw).  */
+#undef HAVE_LIBW
index ac0709987bd4f807987dc33495bcce64b5022a5f..f0b482c921613ea2c9efb9788bf88940e8e0b6c6 100644 (file)
 #include <krb_err.h>
 #endif
 
-#ifdef HAVE_KRB5
-#include <krb5.h>
-#endif
-
 #ifdef HAVE_HESIOD
 #include <hesiod.h>
 #endif
 #define Z_NOTICETIMELIMIT      30      /* Time to wait for fragments */
 #define Z_INITFILTERSIZE       30      /* Starting size of uid filter */
 
-#define Z_AUTHMODE_NONE          0      /* no authentication */
-#define Z_AUTHMODE_KRB4          1      /* authenticate using Kerberos V4 */
-#define Z_AUTHMODE_KRB5          2      /* authenticate using Kerberos V5 */
-
-#define Z_KEYUSAGE_CLT_CKSUM  1027    /* client->server notice checksum */
-#define Z_KEYUSAGE_SRV_CKSUM  1029    /* server->client notice checksum */
-
 struct _Z_Hole {
     struct _Z_Hole     *next;
     int                        first;
@@ -75,11 +64,6 @@ extern int __Zephyr_open;    /* 0 if FD opened, 1 otherwise */
 extern int __HM_set;           /* 0 if dest addr set, 1 otherwise */
 extern int __Zephyr_server;    /* 0 if normal client, 1 if server or zhm */
 
-#ifdef HAVE_KRB5
-extern krb5_context Z_krb5_ctx;
-Code_t Z_krb5_lookup_cksumtype(krb5_enctype, krb5_cksumtype *);
-#endif
-
 extern ZLocations_t *__locate_list;
 extern int __locate_num;
 extern int __locate_next;
@@ -113,48 +97,6 @@ Code_t Z_WaitForNotice __P((ZNotice_t *notice,
                            int (*pred) __P((ZNotice_t *, void *)), void *arg,
                            int timeout));
 
-
-Code_t Z_NewFormatHeader __P((ZNotice_t *, char *, int, int *, Z_AuthProc));
-Code_t Z_NewFormatAuthHeader __P((ZNotice_t *, char *, int, int *, Z_AuthProc));
-Code_t Z_NewFormatRawHeader __P((ZNotice_t *, char *, int, int *, char **, 
-                                 int *, char **, char **));
-Code_t Z_AsciiFormatRawHeader __P((ZNotice_t *, char *, int, int *, char **, 
-                                 int *, char **, char **));
-
 void Z_gettimeofday(struct _ZTimeval *ztv, struct timezone *tz);
-
-#ifdef HAVE_KRB5
-int ZGetCreds(krb5_creds **creds_out);
-int ZGetCredsRealm(krb5_creds **creds_out, char *realm);
-Code_t Z_Checksum(krb5_data *cksumbuf, krb5_keyblock *keyblock, krb5_cksumtype cksumtype, char **asn1_data, unsigned int *asn1_len);
-Code_t Z_ExtractEncCksum(krb5_keyblock *keyblock, krb5_enctype *enctype, krb5_cksumtype *cksumtype);
-int Z_krb5_verify_cksum(krb5_keyblock *keyblock, krb5_data *cksumbuf, krb5_cksumtype cksumtype, unsigned char *asn1_data, int asn1_len);
-Code_t Z_InsertZcodeChecksum(krb5_keyblock *keyblock, ZNotice_t *notice, 
-                             char *buffer,
-                             char *cksum_start, int cksum_len, 
-                             char *cstart, char *cend, int buffer_len,
-                             int *length_ajdust);
-#endif
-
-#ifdef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
-#define Z_keydata(keyblock)    ((keyblock)->contents)
-#define Z_keylen(keyblock)     ((keyblock)->length)
-#define Z_credskey(creds)      (&(creds)->keyblock)
-#define Z_enctype(keyblock)    ((keyblock)->enctype)
-#else
-#define Z_keydata(keyblock)    ((keyblock)->keyvalue.data)
-#define Z_keylen(keyblock)     ((keyblock)->keyvalue.length)
-#define Z_credskey(creds)      (&(creds)->session)
-#define Z_enctype(keyblock)    ((keyblock)->keytype)
-#endif
-
-#ifdef HAVE_KRB5_TICKET_ENC_PART2
-#define Z_tktprincp(tkt)       ((tkt)->enc_part2 != 0)
-#define Z_tktprinc(tkt)                ((tkt)->enc_part2->client)
-#else
-#define        Z_tktprincp(tkt)        ((tkt)->client != 0)
-#define Z_tktprinc(tkt)                ((tkt)->client)
-#endif
-
 #endif /* __INTERNAL_H__ */
 
index 81accf8fb724ca403077a258e90cb12e862bffc4..bdd4e6ccc9fded984d28ac123e7cd81878ccece0 100644 (file)
 #include <time.h>
 #include <signal.h>
 #include <syslog.h>
-#ifdef HAVE_UNISTD_H
-#ifdef HAVE_GETSID
-#define __USE_XOPEN_EXTENDED
-#endif
-#include <unistd.h>
-#ifdef __USE_XOPEN_EXTENDED
-#undef __USE_XOPEN_EXTENDED
-#endif
-#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/param.h>
index 45971fb1418221ff2f0110718b61a267b4506324..713e261a9a101dd3bac7481ab842b4f592fa5b62 100644 (file)
 #include <netinet/in.h>
 #endif
 
-#include <stdarg.h>
+/* Use __STDC__ to guess whether we can use stdarg, prototypes, and const.
+ * This is a public header file, so autoconf can't help us here. */
+#ifdef __STDC__
+# include <stdarg.h>
+# define ZP(x) x
+# define ZCONST const
+#else
+# define ZP(x) ()
+# define ZCONST
+#endif
 
 /* Service names */
 #define        HM_SVCNAME              "zephyr-hm"
@@ -30,7 +39,6 @@
 #define        SERVER_SVCNAME          "zephyr-clt"
 #define SERVER_SERVICE         "zephyr"
 #define SERVER_INSTANCE                "zephyr"
-#define SERVER_KRB5_SERVICE     "zephyr"
 
 #define ZVERSIONHDR    "ZEPH"
 #define ZVERSIONMAJOR  0
@@ -52,7 +60,7 @@ typedef char ZPacket_t[Z_MAXPKTLEN];
 typedef enum {
     UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT
 } ZNotice_Kind_t;
-extern const char *ZNoticeKinds[9];
+extern ZCONST char *ZNoticeKinds[9];
 
 struct _ZTimeval {
        int tv_sec;
@@ -90,7 +98,6 @@ typedef struct _ZNotice_t {
     char               *z_multinotice;
     ZUnique_Id_t       z_multiuid;
     ZChecksum_t                z_checksum;
-    char                *z_ascii_checksum;
     int                        z_num_other_fields;
     char               *z_other_fields[Z_MAXOTHERFIELDS];
     caddr_t            z_message;
@@ -122,105 +129,94 @@ typedef struct _ZAsyncLocateData_t {
 
 /* for ZSetDebug */
 #ifdef Z_DEBUG
-void (*__Z_debug_print)(const char *fmt, va_list args, void *closure);
+void (*__Z_debug_print) ZP((ZCONST char *fmt, va_list args, void *closure));
 void *__Z_debug_print_closure;
 #endif
 
-int ZCompareUIDPred(ZNotice_t *, void *);
-int ZCompareMultiUIDPred(ZNotice_t *, void *);
+int ZCompareUIDPred ZP((ZNotice_t *, void *));
+int ZCompareMultiUIDPred ZP((ZNotice_t *, void *));
 
 /* Defines for ZFormatNotice, et al. */
-typedef Code_t (*Z_AuthProc)(ZNotice_t*, char *, int, int *);
-Code_t ZMakeAuthentication(ZNotice_t*, char *,int, int*);
-Code_t ZMakeZcodeAuthentication(ZNotice_t*, char *,int, int*);
-Code_t ZMakeZcodeRealmAuthentication(ZNotice_t*, char *,int, int*, char*);
-
-char *ZGetSender(void);
-char *ZGetVariable(char *);
-Code_t ZSetVariable(char *var, char *value);
-Code_t ZUnsetVariable(char *var);
-int ZGetWGPort(void);
-Code_t ZSetDestAddr(struct sockaddr_in *);
-Code_t ZFormatNoticeList(ZNotice_t*, char**, int,
-                        char **, int*, Z_AuthProc);
-Code_t ZParseNotice(char*, int, ZNotice_t *);
-Code_t ZReadAscii(char*, int, unsigned char*, int);
-Code_t ZReadAscii32(char *, int, unsigned long *);
-Code_t ZReadAscii16(char *, int, unsigned short *);
-Code_t ZReadZcode(unsigned char*, unsigned char*, int, int *);
-Code_t ZSendPacket(char*, int, int);
-Code_t ZSendList(ZNotice_t*, char *[], int, Z_AuthProc);
-Code_t ZSrvSendList(ZNotice_t*, char*[], int, Z_AuthProc,
-                   Code_t (*)(ZNotice_t *, char *, int, int));
-Code_t ZSendNotice(ZNotice_t *, Z_AuthProc);
-Code_t ZSrvSendNotice(ZNotice_t*, Z_AuthProc,
-                     Code_t (*)(ZNotice_t *, char *, int, int));
-Code_t ZFormatNotice(ZNotice_t*, char**, int*, Z_AuthProc);
-Code_t ZFormatSmallNotice(ZNotice_t*, ZPacket_t, int*, Z_AuthProc);
-Code_t ZFormatRawNoticeList(ZNotice_t *, char *[], int, char **, int *);
-Code_t ZFormatSmallRawNotice(ZNotice_t *, ZPacket_t, int *);
-Code_t ZNewFormatSmallRawNotice(ZNotice_t *, ZPacket_t, int *);
-Code_t ZLocateUser(char *, int *, Z_AuthProc);
-Code_t ZRequestLocations(char *, ZAsyncLocateData_t *,
-                        ZNotice_Kind_t, Z_AuthProc);
-Code_t ZhmStat(struct in_addr *, ZNotice_t *);
-Code_t ZInitialize(void);
-Code_t ZSetServerState(int);
-Code_t ZSetFD(int);
-Code_t ZFormatSmallRawNotice(ZNotice_t*, ZPacket_t, int*);
-int ZCompareUID(ZUnique_Id_t*, ZUnique_Id_t*);
-Code_t ZSrvSendRawList(ZNotice_t*, char*[], int,
-                      Code_t (*)(ZNotice_t *, char *, int, int));
-Code_t ZMakeAscii(char*, int, unsigned char*, int);
-Code_t ZMakeAscii32(char *, int, unsigned long);
-Code_t ZMakeAscii16(char *, int, unsigned int);
-Code_t ZMakeZcode(char*, int, unsigned char*, int);
-Code_t ZMakeZcode32(char *, int, unsigned long);
-Code_t ZReceivePacket(ZPacket_t, int*, struct sockaddr_in*);
-Code_t ZCheckAuthentication(ZNotice_t*, struct sockaddr_in*);
-Code_t ZCheckZcodeAuthentication(ZNotice_t*, struct sockaddr_in*);
-Code_t ZCheckZcodeRealmAuthentication(ZNotice_t*, struct sockaddr_in*, char *realm);
-Code_t ZInitLocationInfo(char *hostname, char *tty);
-Code_t ZSetLocation(char *exposure);
-Code_t ZUnsetLocation(void);
-Code_t ZFlushMyLocations(void);
-char *ZParseExposureLevel(char *text);
-Code_t ZFormatRawNotice(ZNotice_t *, char**, int *);
-Code_t ZRetrieveSubscriptions(unsigned short, int*);
-Code_t ZRetrieveDefaultSubscriptions(int *);
-Code_t ZGetSubscriptions(ZSubscription_t *, int *);
-Code_t ZOpenPort(unsigned short *port);
-Code_t ZClosePort(void);
-Code_t ZFlushLocations(void);
-Code_t ZFlushSubscriptions(void);
-Code_t ZFreeNotice(ZNotice_t *notice);
-Code_t ZGetLocations(ZLocations_t *, int *);
-Code_t ZParseLocations(register ZNotice_t *notice,
-                      register ZAsyncLocateData_t *zald, int *nlocs,
-                      char **user);
-int ZCompareALDPred(ZNotice_t *notice, void *zald);
-void ZFreeALD(register ZAsyncLocateData_t *zald);
-Code_t ZCheckIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
-                     register int (*predicate)(ZNotice_t *,void *),
-                     void *args);
-Code_t ZPeekPacket(char **buffer, int *ret_len,
-                  struct sockaddr_in *from);
-Code_t ZPeekNotice(ZNotice_t *notice, struct sockaddr_in *from);
-Code_t ZIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
-                int (*predicate)(ZNotice_t *, void *), void *args);
-Code_t ZSubscribeTo(ZSubscription_t *sublist, int nitems,
-                   unsigned int port);
-Code_t ZSubscribeToSansDefaults(ZSubscription_t *sublist, int nitems,
-                               unsigned int port);
-Code_t ZUnsubscribeTo(ZSubscription_t *sublist, int nitems,
-                     unsigned int port);
-Code_t ZCancelSubscriptions(unsigned int port);
-int ZPending(void);
-Code_t ZReceiveNotice(ZNotice_t *notice, struct sockaddr_in *from);
+typedef Code_t (*Z_AuthProc) ZP((ZNotice_t*, char *, int, int *));
+Code_t ZMakeAuthentication ZP((ZNotice_t*, char *,int, int*));
+
+char *ZGetSender ZP((void));
+char *ZGetVariable ZP((char *));
+Code_t ZSetVariable ZP((char *var, char *value));
+Code_t ZUnsetVariable ZP((char *var));
+int ZGetWGPort ZP((void));
+Code_t ZSetDestAddr ZP((struct sockaddr_in *));
+Code_t ZFormatNoticeList ZP((ZNotice_t*, char**, int,
+                            char **, int*, Z_AuthProc));
+Code_t ZParseNotice ZP((char*, int, ZNotice_t *));
+Code_t ZReadAscii ZP((char*, int, unsigned char*, int));
+Code_t ZReadAscii32 ZP((char *, int, unsigned long *));
+Code_t ZReadAscii16 ZP((char *, int, unsigned short *));
+Code_t ZSendPacket ZP((char*, int, int));
+Code_t ZSendList ZP((ZNotice_t*, char *[], int, Z_AuthProc));
+Code_t ZSrvSendList ZP((ZNotice_t*, char*[], int, Z_AuthProc, Code_t (*)()));
+Code_t ZSendNotice ZP((ZNotice_t *, Z_AuthProc));
+Code_t ZSrvSendNotice ZP((ZNotice_t*, Z_AuthProc, Code_t (*)()));
+Code_t ZFormatNotice ZP((ZNotice_t*, char**, int*, Z_AuthProc));
+Code_t ZFormatSmallNotice ZP((ZNotice_t*, ZPacket_t, int*, Z_AuthProc));
+Code_t ZFormatRawNoticeList ZP((ZNotice_t *notice, char *list[], int nitems,
+                               char **buffer, int *ret_len));
+Code_t ZLocateUser ZP((char *, int *, Z_AuthProc));
+Code_t ZRequestLocations ZP((char *, ZAsyncLocateData_t *,
+                            ZNotice_Kind_t, Z_AuthProc));
+Code_t ZhmStat ZP((struct in_addr *, ZNotice_t *));
+Code_t ZInitialize ZP((void));
+Code_t ZSetServerState ZP((int));
+Code_t ZSetFD ZP((int));
+Code_t ZFormatSmallRawNotice ZP((ZNotice_t*, ZPacket_t, int*));
+int ZCompareUID ZP((ZUnique_Id_t*, ZUnique_Id_t*));
+Code_t ZSrvSendRawList ZP((ZNotice_t*, char*[], int,
+                          Code_t (*)(ZNotice_t *, char *, int, int)));
+Code_t ZMakeAscii ZP((char*, int, unsigned char*, int));
+Code_t ZMakeAscii32 ZP((char *, int, unsigned long));
+Code_t ZMakeAscii16 ZP((char *, int, unsigned int));
+Code_t ZReceivePacket ZP((ZPacket_t, int*, struct sockaddr_in*));
+Code_t ZCheckAuthentication ZP((ZNotice_t*, struct sockaddr_in*));
+Code_t ZInitLocationInfo ZP((char *hostname, char *tty));
+Code_t ZSetLocation ZP((char *exposure));
+Code_t ZUnsetLocation ZP((void));
+Code_t ZFlushMyLocations ZP((void));
+char *ZParseExposureLevel ZP((char *text));
+Code_t ZFormatRawNotice ZP((ZNotice_t *, char**, int *));
+Code_t ZRetrieveSubscriptions ZP((unsigned short, int*));
+Code_t ZOpenPort ZP((unsigned short *port));
+Code_t ZClosePort ZP((void));
+Code_t ZFlushLocations ZP((void));
+Code_t ZFlushSubscriptions ZP((void));
+Code_t ZFreeNotice ZP((ZNotice_t *notice));
+Code_t ZParseLocations ZP((register ZNotice_t *notice,
+                          register ZAsyncLocateData_t *zald, int *nlocs,
+                          char **user));
+int ZCompareALDPred ZP((ZNotice_t *notice, void *zald));
+void ZFreeALD ZP((register ZAsyncLocateData_t *zald));
+Code_t ZCheckIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from,
+                         register int (*predicate) ZP((ZNotice_t *,void *)),
+                         void *args));
+Code_t ZPeekPacket ZP((char **buffer, int *ret_len,
+                      struct sockaddr_in *from));
+Code_t ZPeekNotice ZP((ZNotice_t *notice, struct sockaddr_in *from));
+Code_t ZIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from,
+                    int (*predicate) ZP((ZNotice_t *, void *)), void *args));
+Code_t ZSubscribeTo ZP((ZSubscription_t *sublist, int nitems,
+                       unsigned int port));
+Code_t ZSubscribeToSansDefaults ZP((ZSubscription_t *sublist, int nitems,
+                                   unsigned int port));
+Code_t ZUnsubscribeTo ZP((ZSubscription_t *sublist, int nitems,
+                         unsigned int port));
+Code_t ZCancelSubscriptions ZP((unsigned int port));
+int ZPending ZP((void));
+Code_t ZReceiveNotice ZP((ZNotice_t *notice, struct sockaddr_in *from));
 #ifdef Z_DEBUG
-void Z_debug(const char *, ...);
+void Z_debug ZP((ZCONST char *, ...));
 #endif
 
+#undef ZP
+
 /* Compatibility */
 #define        ZNewLocateUser ZLocateUser
 
@@ -236,7 +232,7 @@ extern char __Zephyr_realm[];
 
 
 #ifdef Z_DEBUG
-void ZSetDebug ZP((void (*)(const char *, va_list, void *), void *));
+void ZSetDebug ZP((void (*)(ZCONST char *, va_list, void *), void *));
 #define ZSetDebug(proc,closure)    (__Z_debug_print=(proc), \
                                    __Z_debug_print_closure=(closure), \
                                    (void) 0)
@@ -257,7 +253,6 @@ void ZSetDebug ZP((void (*)(const char *, va_list, void *), void *));
 #define        SRV_TIMEOUT             30
 
 #define ZAUTH (ZMakeAuthentication)
-#define ZCAUTH (ZMakeZcodeAuthentication)
 #define ZNOAUTH ((Z_AuthProc)0)
 
 /* Packet strings */
diff --git a/zephyr/h/zephyr/zephyr_err.h b/zephyr/h/zephyr/zephyr_err.h
new file mode 100644 (file)
index 0000000..3fd16e9
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * zephyr_err.h:
+ * This file is automatically generated; please do not edit it.
+ */
+
+#define ZERR_PKTLEN                              (-772103680L)
+#define ZERR_HEADERLEN                           (-772103679L)
+#define ZERR_ILLVAL                              (-772103678L)
+#define ZERR_HMPORT                              (-772103677L)
+#define ZERR_PORTINUSE                           (-772103676L)
+#define ZERR_BADPKT                              (-772103675L)
+#define ZERR_VERS                                (-772103674L)
+#define ZERR_NOPORT                              (-772103673L)
+#define ZERR_NONOTICE                            (-772103672L)
+#define ZERR_QLEN                                (-772103671L)
+#define ZERR_HMDEAD                              (-772103670L)
+#define ZERR_INTERNAL                            (-772103669L)
+#define ZERR_NOLOCATIONS                         (-772103668L)
+#define ZERR_NOMORELOCS                          (-772103667L)
+#define ZERR_FIELDLEN                            (-772103666L)
+#define ZERR_BADFIELD                            (-772103665L)
+#define ZERR_SERVNAK                             (-772103664L)
+#define ZERR_AUTHFAIL                            (-772103663L)
+#define ZERR_LOGINFAIL                           (-772103662L)
+#define ZERR_NOSUBSCRIPTIONS                     (-772103661L)
+#define ZERR_NOMORESUBSCRIPTIONS                 (-772103660L)
+#define ZERR_TOOMANYSUBS                         (-772103659L)
+#define ZERR_EOF                                 (-772103658L)
+extern void initialize_zeph_error_table(void);
+#define ERROR_TABLE_BASE_zeph (-772103680L)
+
+/* for compatibility with older versions... */
+#define init_zeph_err_tbl initialize_zeph_error_table
+#define zeph_err_base ERROR_TABLE_BASE_zeph
index 843d8cf3c019c088da5795bb32b9745558ae6cdf..5415797e1f9cfc209f1422c34e6a338c0bfb9781 100644 (file)
@@ -39,8 +39,7 @@ OBJS =        zephyr_err.lo ZAsyncLocate.lo ZCkAuth.lo ZCkIfNot.lo ZClosePort.lo \
        ZPeekIfNot.lo ZPeekNot.lo ZPeekPkt.lo ZPending.lo ZReadAscii.lo \
        ZRecvNot.lo ZRecvPkt.lo ZRetSubs.lo ZSendList.lo ZSendNot.lo \
        ZSendPkt.lo ZSendRaw.lo ZSendRLst.lo ZSetDest.lo ZSetFD.lo ZSetSrv.lo \
-       ZSubs.lo ZVariables.lo ZWait4Not.lo Zinternal.lo ZMakeZcode.lo \
-       ZReadZcode.lo ZCkZAut.lo
+       ZSubs.lo ZVariables.lo ZWait4Not.lo Zinternal.lo
 
 .SUFFIXES: .lo
 
@@ -52,7 +51,7 @@ libzephyr.la: ${OBJS}
 
 zephyr_err.c ${BUILDTOP}/h/zephyr/zephyr_err.h: zephyr_err.et
        compile_et ${srcdir}/zephyr_err.et
-       mv -f zephyr_err.h ${BUILDTOP}/h/zephyr
+       mv zephyr_err.h ${BUILDTOP}/h/zephyr
 
 .c.lo:
        ${LIBTOOL} --mode=compile ${CC} -c -o $@ ${ALL_CFLAGS} $<
index 41ecffbc7184ebb1b49433a59b201b88313299aa..d248064805d5039a6b0d8ec1c7d3b9091209338f 100644 (file)
 static const char rcsid_ZAsyncLocate_c[] = "$Id$";
 #endif
 
-Code_t
-ZRequestLocations(char *user,
-                 register ZAsyncLocateData_t *zald,
-                 ZNotice_Kind_t kind,                /* UNSAFE, UNACKED, or ACKED */
-                 Z_AuthProc auth)
+Code_t ZRequestLocations(user, zald, kind, auth)
+     char *user;
+     register ZAsyncLocateData_t *zald;
+     ZNotice_Kind_t kind;      /* UNSAFE, UNACKED, or ACKED */
+     Z_AuthProc auth;
 {
     int retval;
     ZNotice_t notice;
@@ -57,11 +57,11 @@ ZRequestLocations(char *user,
     return(ZERR_NONE);
 }
 
-Code_t
-ZParseLocations(register ZNotice_t *notice,
-               register ZAsyncLocateData_t *zald,
-               int *nlocs,
-               char **user)
+Code_t ZParseLocations(notice,zald,nlocs,user)
+     register ZNotice_t *notice;
+     register ZAsyncLocateData_t *zald;
+     int *nlocs;
+     char **user;
 {
     char *ptr, *end;
     int i;
@@ -149,16 +149,16 @@ ZParseLocations(register ZNotice_t *notice,
     return (ZERR_NONE);
 }
 
-int
-ZCompareALDPred(ZNotice_t *notice,
-               void *zald)
+int ZCompareALDPred(notice, zald)
+     ZNotice_t *notice;
+     void *zald;
 {
     return(ZCompareUID(&(notice->z_multiuid),
                       &(((ZAsyncLocateData_t *) zald)->uid)));
 }
 
-void
-ZFreeALD(register ZAsyncLocateData_t *zald)
+void ZFreeALD(zald)
+     register ZAsyncLocateData_t *zald;
 {
    if (!zald) return;
 
index 94de79322cc906b934214408d0131358906fadbc..17fdc2b6e270678184525825970669c33df60c8e 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZCheckAuthentication_c[] =
+static char rcsid_ZCheckAuthentication_c[] =
     "$Zephyr: /mit/zephyr/src/lib/RCS/ZCheckAuthentication.c,v 1.14 89/03/24 14:17:38 jtkohl Exp Locker: raeburn $";
 #endif
 
 #include <internal.h>
 
-#if defined(HAVE_KRB5) && !HAVE_KRB5_FREE_DATA
-#define krb5_free_data(ctx, dat) free((dat)->data)
-#endif
-
 /* Check authentication of the notice.
    If it looks authentic but fails the Kerberos check, return -1.
    If it looks authentic and passes the Kerberos check, return 1.
@@ -29,14 +25,13 @@ static const char rcsid_ZCheckAuthentication_c[] =
    When not using Kerberos, return true if the notice claims to be authentic.
    Only used by clients; the server uses its own routine.
  */
-Code_t
-ZCheckAuthentication(ZNotice_t *notice,
-                    struct sockaddr_in *from)
-{
-#if defined(HAVE_KRB4) && !defined(HAVE_KRB5)
+Code_t ZCheckAuthentication(notice, from)
+    ZNotice_t *notice;
+    struct sockaddr_in *from;
+{      
+#ifdef HAVE_KRB4
     int result;
     ZChecksum_t our_checksum;
-    C_Block *session;
     CREDENTIALS cred;
 
     /* If the value is already known, return it. */
@@ -45,21 +40,23 @@ ZCheckAuthentication(ZNotice_t *notice,
 
     if (!notice->z_auth)
        return (ZAUTH_NO);
-
+       
     if ((result = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, 
                               __Zephyr_realm, &cred)) != 0)
        return (ZAUTH_NO);
 
-    session = (C_Block *)cred.session;
-
+#ifdef NOENCRYPTION
+    our_checksum = 0;
+#else
     our_checksum = des_quad_cksum(notice->z_packet, NULL, 
                                  notice->z_default_format+
                                  strlen(notice->z_default_format)+1-
-                                 notice->z_packet, 0, session);
-
+                                 notice->z_packet, 0, cred.session);
+#endif
     /* if mismatched checksum, then the packet was corrupted */
     return ((our_checksum == notice->z_checksum) ? ZAUTH_YES : ZAUTH_FAILED);
+
 #else
-    return ZCheckZcodeAuthentication(notice, from);
+    return (notice->z_auth ? ZAUTH_YES : ZAUTH_NO);
 #endif
 } 
index e8fcaf21f2c8e4f80becde8533c43ee6ccd772da..fcc9546ae1c6217841a570b2bc622ed047631d85 100644 (file)
 static const char rcsid_ZCheckIfNotice_c[] = "$Id$";
 #endif
 
-Code_t
-ZCheckIfNotice(ZNotice_t *notice,
-              struct sockaddr_in *from,
-              register int (*predicate)(ZNotice_t *, void *),
-              void *args)
+Code_t ZCheckIfNotice(notice, from, predicate, args)
+    ZNotice_t *notice;
+    struct sockaddr_in *from;
+    register int (*predicate) __P((ZNotice_t *, void *));
+    void *args;
 {
     ZNotice_t tmpnotice;
     Code_t retval;
diff --git a/zephyr/lib/ZCkZAut.c b/zephyr/lib/ZCkZAut.c
deleted file mode 100644 (file)
index 7411bd6..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/* This file is part of the Project Athena Zephyr Notification System.
- * It contains source for the ZCheckAuthentication function.
- *
- *     Created by:     Robert French
- *
- *     $Source$
- *     $Author$
- *
- *     Copyright (c) 1987,1991 by the Massachusetts Institute of Technology.
- *     For copying and distribution information, see the file
- *     "mit-copyright.h". 
- */
-/* $Header$ */
-
-#ifndef lint
-static const char rcsid_ZCheckAuthentication_c[] =
-    "$Zephyr: /mit/zephyr/src/lib/RCS/ZCheckAuthentication.c,v 1.14 89/03/24 14:17:38 jtkohl Exp Locker: raeburn $";
-#endif
-
-#include <internal.h>
-
-#if defined(HAVE_KRB5) && !HAVE_KRB5_FREE_DATA
-#define krb5_free_data(ctx, dat) free((dat)->data)
-#endif
-
-/* Check authentication of the notice.
-   If it looks authentic but fails the Kerberos check, return -1.
-   If it looks authentic and passes the Kerberos check, return 1.
-   If it doesn't look authentic, return 0
-
-   When not using Kerberos, return true if the notice claims to be authentic.
-   Only used by clients; the server uses its own routine.
- */
-Code_t ZCheckZcodeAuthentication(ZNotice_t *notice,
-                                struct sockaddr_in *from)
-{      
-    /* If the value is already known, return it. */
-    if (notice->z_checked_auth != ZAUTH_UNSET)
-        return (notice->z_checked_auth);
-
-    if (!notice->z_auth)
-        return (ZAUTH_NO);
-
-    if (!notice->z_ascii_checksum)
-        return (ZAUTH_NO);
-
-#ifdef HAVE_KRB5
-    {
-        krb5_error_code result;
-        krb5_creds *creds;
-        krb5_keyblock *keyblock;
-        krb5_enctype enctype;
-        krb5_cksumtype cksumtype;
-        krb5_data cksumbuf;
-       int valid;
-        char *cksum0_base, *cksum1_base, *cksum2_base;
-        char *x;
-        unsigned char *asn1_data, *key_data;
-        int asn1_len, key_len, cksum0_len, cksum1_len, cksum2_len;
-
-       result = ZGetCreds(&creds);
-
-        if (result)
-            return (ZAUTH_NO);
-        /* HOLDING: creds */
-
-        /* Figure out what checksum type to use */
-       keyblock = Z_credskey(creds);
-       key_data = Z_keydata(keyblock);
-       key_len = Z_keylen(keyblock);
-       result = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
-        if (result) {
-           krb5_free_creds(Z_krb5_ctx, creds);
-           return (ZAUTH_FAILED);
-        }
-        /* HOLDING: creds */
-
-        /* Assemble the things to be checksummed */
-        /* first part is from start of packet through z_default_format:
-         * - z_version
-         * - z_num_other_fields
-         * - z_kind
-         * - z_uid
-         * - z_port
-         * - z_auth
-         * - z_authent_len
-         * - z_ascii_authent
-         * - z_class
-         * - z_class_inst
-         * - z_opcode
-         * - z_sender
-         * - z_recipient
-         * - z_default_format
-         */
-        cksum0_base = notice->z_packet;
-        x           = notice->z_default_format;
-        cksum0_len  = x + strlen(x) + 1 - cksum0_base;
-        /* second part is from z_multinotice through other fields:
-         * - z_multinotice
-         * - z_multiuid
-         * - z_other_fields[]
-         */
-        cksum1_base = notice->z_multinotice;
-        if (notice->z_num_other_fields)
-          x = notice->z_other_fields[notice->z_num_other_fields];
-        else
-          x = cksum1_base + strlen(cksum1_base) + 1; /* multiuid */
-        cksum1_len  = x + strlen(x) + 1 - cksum1_base;
-
-        /* last part is the message body */
-        cksum2_base = notice->z_message;
-        cksum2_len  = notice->z_message_len;
-
-        if ((!notice->z_ascii_checksum || *notice->z_ascii_checksum != 'Z') &&
-            key_len == 8 &&
-            (enctype == ENCTYPE_DES_CBC_CRC ||
-             enctype == ENCTYPE_DES_CBC_MD4 ||
-             enctype == ENCTYPE_DES_CBC_MD5)) {
-         /* try old-format checksum (covers cksum0 only) */
-
-            ZChecksum_t our_checksum;
-
-            our_checksum = des_quad_cksum((unsigned char *)cksum0_base, NULL, cksum0_len, 0,
-                                          (C_Block *)key_data);
-            if (our_checksum == notice->z_checksum) {
-                krb5_free_creds(Z_krb5_ctx, creds);
-                return ZAUTH_YES;
-            }
-        }
-        /* HOLDING: creds */
-
-        cksumbuf.length = cksum0_len + cksum1_len + cksum2_len;
-        cksumbuf.data = malloc(cksumbuf.length);
-        if (!cksumbuf.data) {
-           krb5_free_creds(Z_krb5_ctx, creds);
-           return ZAUTH_NO;
-        }
-        /* HOLDING: creds, cksumbuf.data */
-
-        memcpy(cksumbuf.data, cksum0_base, cksum0_len);
-        memcpy(cksumbuf.data + cksum0_len, cksum1_base, cksum1_len);
-        memcpy(cksumbuf.data + cksum0_len + cksum1_len,
-               cksum2_base, cksum2_len);
-
-        /* decode zcoded checksum */
-        /* The encoded form is always longer than the original */
-        asn1_len = strlen(notice->z_ascii_checksum) + 1;
-        asn1_data = malloc(asn1_len);
-        if (!asn1_data) {
-            krb5_free_creds(Z_krb5_ctx, creds);
-            free(cksumbuf.data);
-            return ZAUTH_FAILED;
-        }
-        /* HOLDING: creds, asn1_data, cksumbuf.data */
-        result = ZReadZcode((unsigned char *)notice->z_ascii_checksum,
-                            asn1_data, asn1_len, &asn1_len);
-        if (result != ZERR_NONE) {
-            krb5_free_creds(Z_krb5_ctx, creds);
-            free(asn1_data);
-            free(cksumbuf.data);
-            return ZAUTH_FAILED;
-        }
-        /* HOLDING: creds, asn1_data, cksumbuf.data */
-
-       valid = Z_krb5_verify_cksum(keyblock, &cksumbuf, cksumtype,
-                                   asn1_data, asn1_len);
-
-        free(asn1_data);
-        krb5_free_creds(Z_krb5_ctx, creds);
-        free(cksumbuf.data);
-
-       if (valid)
-         return ZAUTH_YES;
-       else
-         return ZAUTH_FAILED;
-    }
-#endif /* HAVE_KRB5 */
-    return (notice->z_auth ? ZAUTH_YES : ZAUTH_NO);
-}
index bd212b4844a52b73d9c0e06ec6e736f67f548759..f2498692c444ce75e3c5cd7b21e37c087e5542bc 100644 (file)
@@ -16,8 +16,7 @@
 static const char rcsid_ZClosePort_c[] = "$Id$";
 #endif
 
-Code_t
-ZClosePort(void)
+Code_t ZClosePort()
 {
     if (__Zephyr_fd >= 0 && __Zephyr_open)
        (void) close(__Zephyr_fd);
index a448deb11f2b554a98bf53242f578626e0eb3da5..96ad9783c2dad1dc846c7c654c9ea1531ac0a0b5 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZCompareUID_c[] = "$Id$";
+static char rcsid_ZCompareUID_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-int
-ZCompareUID(ZUnique_Id_t *uid1,
-           ZUnique_Id_t *uid2)
+int ZCompareUID(uid1, uid2)
+    ZUnique_Id_t *uid1, *uid2;
 {
     return (!memcmp((char *)uid1, (char *)uid2, sizeof (*uid1)));
 }
index abb05a40b5c1f680da2b3d0a9ff5a7d9fe8053f2..19cbc167606ebaf9f6042c0eafddb200d7b5af04 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZCompareUIDPred_c[] = "$Id$";
+static char rcsid_ZCompareUIDPred_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-int
-ZCompareUIDPred(ZNotice_t *notice,
-               void *uid)
+int ZCompareUIDPred(notice, uid)
+    ZNotice_t *notice;
+    void *uid;
 {
     return (ZCompareUID(&notice->z_uid, (ZUnique_Id_t *) uid));
 }
 
-int
-ZCompareMultiUIDPred(ZNotice_t *notice,
-                    void *uid)
+int ZCompareMultiUIDPred(notice, uid)
+    ZNotice_t *notice;
+    void *uid;
 {
     return (ZCompareUID(&notice->z_multiuid, (ZUnique_Id_t *) uid));
 }
index 3708b2472da1841bade6944245fd5b0546657018..58c33465975008036889a6b6dfcbbe4656455906 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZFlushLocations_c[] = "$Id$";
+static char rcsid_ZFlushLocations_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZFlushLocations(void)
+Code_t ZFlushLocations()
 {
        int i;
        
index ae379494655f71a699aae79217c102f489f7e32b..7ea5ef4a8f6fc511f6da71bd9d710f6b0d2f4745 100644 (file)
@@ -16,8 +16,7 @@
 static const char rcsid_ZFlushSubscriptions_c[] = "$Id$";
 #endif
 
-Code_t
-ZFlushSubscriptions(void)
+Code_t ZFlushSubscriptions()
 {
        register int i;
        
index 92fb3c612af34453cb0badd4a5918ccb019eae49..c2d8a002391f6cc906a28c63018870f251b7b98b 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZFormatAuthenticNotice_c[] = "$Id$";
+static char rcsid_ZFormatAuthenticNotice_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
 #ifdef HAVE_KRB4
-Code_t
-ZFormatAuthenticNotice(ZNotice_t *notice,
-                      char *buffer,
-                      int buffer_len,
-                      int *len,
-                      C_Block session)
+Code_t ZFormatAuthenticNotice(notice, buffer, buffer_len, len, session)
+    ZNotice_t *notice;
+    register char *buffer;
+    register int buffer_len;
+    int *len;
+    C_Block session;
 {
     ZNotice_t newnotice;
     char *ptr;
@@ -37,9 +37,12 @@ ZFormatAuthenticNotice(ZNotice_t *notice,
                                    &hdrlen, &ptr, NULL)) != ZERR_NONE)
        return (retval);
 
+#ifdef NOENCRYPTION
+    newnotice.z_checksum = 0;
+#else
     newnotice.z_checksum =
-       (ZChecksum_t)des_quad_cksum((unsigned char *)buffer, NULL, ptr - buffer, 0, (C_Block *)session);
-
+       (ZChecksum_t)des_quad_cksum(buffer, NULL, ptr - buffer, 0, session);
+#endif
     if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len,
                                    &hdrlen, NULL, NULL)) != ZERR_NONE)
        return (retval);
@@ -59,71 +62,3 @@ ZFormatAuthenticNotice(ZNotice_t *notice,
     return (ZERR_NONE);
 }
 #endif
-
-#ifdef HAVE_KRB5
-Code_t
-ZFormatAuthenticNoticeV5(ZNotice_t *notice,
-                        register char *buffer,
-                        register int buffer_len,
-                        int *len,
-                        krb5_keyblock *keyblock)
-{
-    ZNotice_t newnotice;
-    char *ptr;
-    int retval, hdrlen, hdr_adj;
-    krb5_enctype enctype;
-    krb5_cksumtype cksumtype;
-    int key_len;
-    char *cksum_start, *cstart, *cend;
-    int cksum_len;
-    
-    key_len = Z_keylen(keyblock);
-    retval = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
-    if (retval)
-         return (ZAUTH_FAILED);
-
-#ifdef HAVE_KRB4
-    if (key_len == 8 && (enctype == ENCTYPE_DES_CBC_CRC || 
-                         enctype == ENCTYPE_DES_CBC_MD4 ||
-                         enctype == ENCTYPE_DES_CBC_MD5)) {
-         C_Block tmp;
-         memcpy(&tmp, Z_keydata(keyblock), key_len);
-         return ZFormatAuthenticNotice(notice, buffer, buffer_len, len,
-                                       tmp);
-    }
-#endif
-         
-    newnotice = *notice;
-    newnotice.z_auth = 1;
-    newnotice.z_authent_len = 0;
-    newnotice.z_ascii_authent = "";
-
-    if ((retval = Z_NewFormatRawHeader(&newnotice, buffer, buffer_len,
-                                       &hdrlen, 
-                                       &cksum_start, &cksum_len, &cstart, 
-                                       &cend)) != ZERR_NONE)
-       return (retval);
-     
-    retval = Z_InsertZcodeChecksum(keyblock, &newnotice, buffer, 
-                                   cksum_start, cksum_len, cstart, cend, 
-                                   buffer_len, &hdr_adj);
-     if (retval)
-          return retval;
-     
-     hdrlen += hdr_adj;
-     
-     ptr = buffer+hdrlen;
-
-     if (newnotice.z_message_len+hdrlen > buffer_len)
-          return (ZERR_PKTLEN);
-     
-     (void) memcpy(ptr, newnotice.z_message, newnotice.z_message_len);
-     
-     *len = hdrlen+newnotice.z_message_len;
-     
-     if (*len > Z_MAXPKTLEN)
-          return (ZERR_PKTLEN);
-     
-     return (ZERR_NONE);
-}
-#endif
index adad0fba1b88f0af439b635b5bcf9455aa8dfe60..d0adbdc8df50be32a9c5d053983dab70d299f789 100644 (file)
@@ -17,13 +17,14 @@ static const char rcsid_ZFormatNoticeList_c[] =
     "$Id$";
 #endif
 
-Code_t
-ZFormatNoticeList(ZNotice_t *notice,
-                 register char **list,
-                 int nitems,
-                 char **buffer,
-                 int *ret_len, 
-                 Z_AuthProc cert_routine)
+Code_t ZFormatNoticeList(notice, list, nitems, buffer, ret_len, 
+                        cert_routine)
+    ZNotice_t *notice;
+    register char **list;
+    int nitems;
+    char **buffer;
+    int *ret_len;
+    Z_AuthProc cert_routine;
 {
     char header[Z_MAXHEADERLEN];
     register int i;
index 0f914f31c686003b3b85066885ad2175936357bd..d7876d79dc93396d552d544c3f0abf844d57f3a1 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZFormatNotice_c[] = "$Id$";
+static char rcsid_ZFormatNotice_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZFormatNotice(register ZNotice_t *notice,
-             char **buffer,
-             int *ret_len,
-             Z_AuthProc cert_routine)
+Code_t ZFormatNotice(notice, buffer, ret_len, cert_routine)
+    register ZNotice_t *notice;
+    char **buffer;
+    int *ret_len;
+    Z_AuthProc cert_routine;
 {
     char header[Z_MAXHEADERLEN];
     int hdrlen;
@@ -41,29 +41,3 @@ ZFormatNotice(register ZNotice_t *notice,
 
     return (ZERR_NONE);
 }
-
-Code_t
-ZNewFormatNotice(register ZNotice_t *notice,
-                char **buffer,
-                int *ret_len,
-                Z_AuthProc cert_routine)
-{
-    char header[Z_MAXHEADERLEN];
-    int hdrlen;
-    Code_t retval;
-
-    if ((retval = Z_NewFormatHeader(notice, header, sizeof(header), &hdrlen, 
-                                cert_routine)) != ZERR_NONE)
-       return (retval);
-
-    *ret_len = hdrlen+notice->z_message_len;
-
-    /* Length can never be zero, don't have to worry about malloc(0). */
-    if (!(*buffer = (char *) malloc((unsigned)*ret_len)))
-       return (ENOMEM);
-
-    (void) memcpy(*buffer, header, hdrlen);
-    (void) memcpy(*buffer+hdrlen, notice->z_message, notice->z_message_len);
-
-    return (ZERR_NONE);
-}
index 691ded0fca1816af75813103a26cb4d963ef50ff..2940f98f30647668db9d65969dc01a5e0c948828 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZFormatRawNotice_c[] = "$Id$";
+static char rcsid_ZFormatRawNotice_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZFormatRawNotice(register ZNotice_t *notice,
-                char **buffer,
-                int *ret_len)
+Code_t ZFormatRawNotice(notice, buffer, ret_len)
+    register ZNotice_t *notice;
+    char **buffer;
+    int *ret_len;
 {
     char header[Z_MAXHEADERLEN];
     int hdrlen;
index f08040ebe50424be1bca807f39a1cd776b6e6dc7..7d83f71149186950946187188253c813d800a813 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZFormatRawNoticeList_c[] = "$Id$";
+static char rcsid_ZFormatRawNoticeList_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZFormatRawNoticeList(ZNotice_t *notice,
-                    char *list[],
-                    int nitems,
-                    char **buffer,
-                    int *ret_len)
+Code_t ZFormatRawNoticeList(notice, list, nitems, buffer, ret_len)
+    ZNotice_t *notice;
+    char *list[];
+    int nitems;
+    char **buffer;
+    int *ret_len;
 {
     char header[Z_MAXHEADERLEN];
     int hdrlen, i, size;
index 6b60097c7f59ad6496afeb2ddb17aebbbd49248a..6e412853129450f35f3a77f1375c99f505d812e2 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZFormatRawNoticeList_c[] = "$Id$";
+static char rcsid_ZFormatRawNoticeList_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZFormatSmallRawNoticeList(ZNotice_t *notice,
-                         char *list[],
-                         int nitems,
-                         ZPacket_t buffer,
-                         int *ret_len)
+Code_t ZFormatSmallRawNoticeList(notice, list, nitems, buffer, ret_len)
+    ZNotice_t *notice;
+    char *list[];
+    int nitems;
+    ZPacket_t buffer;
+    int *ret_len;
 {
     Code_t retval;
     int hdrlen, i, size;
index 3de04ad8ce47b3b2002c637ff975b2184bcecac0..a9ce79d1465f26a1073a131a83c0d368d4843a5f 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZFormatRawNotice_c[] = "$Id$";
+static char rcsid_ZFormatRawNotice_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZFormatSmallRawNotice(ZNotice_t *notice,
-                     ZPacket_t buffer,
-                     int *ret_len)
+Code_t ZFormatSmallRawNotice(notice, buffer, ret_len)
+    ZNotice_t *notice;
+    ZPacket_t buffer;
+    int *ret_len;
 {
     Code_t retval;
     int hdrlen;
@@ -37,26 +37,3 @@ ZFormatSmallRawNotice(ZNotice_t *notice,
 
     return (ZERR_NONE);
 }
-
-Code_t
-ZNewFormatSmallRawNotice(ZNotice_t *notice,
-                        ZPacket_t buffer,
-                        int *ret_len)
-{
-  Code_t retval;
-  int hdrlen;
-  
-  if ((retval = Z_AsciiFormatRawHeader(notice, buffer, Z_MAXHEADERLEN,
-                                       &hdrlen, NULL, NULL, NULL, NULL)) 
-      != ZERR_NONE)
-    return (retval);
-  
-  *ret_len = hdrlen+notice->z_message_len;
-  
-  if (*ret_len > Z_MAXPKTLEN)
-    return (ZERR_PKTLEN);
-  
-  (void) memcpy(buffer+hdrlen, notice->z_message, notice->z_message_len);
-  
-  return (ZERR_NONE);
-}
index 663dbf8fbc5b3a1ced1232af935fd95e82c92c6d..f5ce36098ed22791a3bbf6fd86bed1032690f1c9 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZFreeNotice_c[] = "$Id$";
+static char rcsid_ZFreeNotice_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZFreeNotice(ZNotice_t *notice)
+Code_t ZFreeNotice(notice)
+    ZNotice_t *notice;
 {
     free(notice->z_packet);
     return 0;
index 1c018da5904c3eafb946fc7418974dc156151566..d32d53cae35a758beafcfd0bdb3e011e5cd062a9 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZGetLocations_c[] = "$Id$";
+static char rcsid_ZGetLocations_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
 #define min(a,b) ((a)<(b)?(a):(b))
        
-Code_t
-ZGetLocations(ZLocations_t *location,
-             int *numlocs)
+Code_t ZGetLocations(location, numlocs)
+    ZLocations_t *location;
+    int *numlocs;
 {
     int i;
        
index 953d4f909670142edbfa6a5bb6809f170ff6e307..df5f3e2e5979b69d724d6c24f709f29766e20bda 100644 (file)
@@ -19,49 +19,27 @@ static const char rcsid_ZGetSender_c[] =
 
 #include <pwd.h>
 
-char *
-ZGetSender(void)
+char *ZGetSender()
 {
     struct passwd *pw;
-    static char *sender = NULL;
-#ifdef HAVE_KRB5
-    krb5_ccache ccache;
-    krb5_principal principal;
-    char *prname;
-    int result;
-#else    
 #ifdef HAVE_KRB4
     char pname[ANAME_SZ], pinst[INST_SZ], prealm[REALM_SZ];
-#endif 
+    static char sender[ANAME_SZ+INST_SZ+REALM_SZ+3] = "";
+#else
+    static char sender[128] = "";
 #endif
 
     /* Return it if already cached */
-    if (sender)
+    if (*sender)
        return (sender);
 
-#ifdef HAVE_KRB5
-    result = krb5_cc_default(Z_krb5_ctx, &ccache);
-    if (!result) {
-      result = krb5_cc_get_principal(Z_krb5_ctx, ccache, &principal);
-      if (!result) {
-       krb5_unparse_name(Z_krb5_ctx, principal, &prname);
-       sender = strdup(prname);
-       krb5_free_principal(Z_krb5_ctx, principal);
-       return sender;
-      }
-      krb5_cc_close(Z_krb5_ctx, ccache);
-    } 
-#else
 #ifdef HAVE_KRB4
     if (krb_get_tf_fullname((char *)TKT_FILE, pname, pinst, prealm) == KSUCCESS)
     {
-        sender = malloc(ANAME_SZ+INST_SZ+REALM_SZ+3);
-       if (sender)
-         (void) sprintf(sender, "%s%s%s@%s", pname, (pinst[0]?".":""),
-                        pinst, prealm);
+       (void) sprintf(sender, "%s%s%s@%s", pname, (pinst[0]?".":""),
+                      pinst, prealm);
        return (sender);
     }
-#endif
 #endif
 
     /* XXX a uid_t is a u_short (now),  but getpwuid
@@ -69,8 +47,6 @@ ZGetSender(void)
     pw = getpwuid((int) getuid());
     if (!pw)
        return ("unknown");
-    sender = malloc(strlen(pw->pw_name) + strlen(__Zephyr_realm) + 2);
-    if (sender)
-      (void) sprintf(sender, "%s@%s", pw->pw_name, __Zephyr_realm);
+    (void) sprintf(sender, "%s@%s", pw->pw_name, __Zephyr_realm);
     return (sender);
 }
index 465461a91886675212d7d2ad2b5549a7ac95ea59..b0c29b1305404bc57273850851cf5aa572ad73ae 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZGetSubscriptions_c[] = "$Id$";
+static char rcsid_ZGetSubscriptions_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
 #define min(a,b) ((a)<(b)?(a):(b))
        
-Code_t
-ZGetSubscriptions(ZSubscription_t *subscription,
-                 int *numsubs)
+Code_t ZGetSubscriptions(subscription, numsubs)
+    ZSubscription_t *subscription;
+    int *numsubs;
 {
     int i;
        
index b3ef17ceb40c40e5ea563e46861894fc150407bf..8f8fcc9db9794dc22ebe02a3effa4dc052710de3 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZGetWGPort_c[] = "$Id$";
+static char rcsid_ZGetWGPort_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-int
-ZGetWGPort(void)
+int ZGetWGPort()
 {
     char *envptr, name[128];
     FILE *fp;
index a3652b5610abefdc58f42c96b898d0562516bd04..b42138ec5e1d113e08dc4da63f9ff4d7105f4aab 100644 (file)
 static const char rcsid_ZIfNotice_c[] = "$Id$";
 #endif
 
-Code_t
-ZIfNotice(ZNotice_t *notice,
-         struct sockaddr_in *from,
-         int (*predicate)(ZNotice_t *, void *),
-         void *args)
+Code_t ZIfNotice(notice, from, predicate, args)
+    ZNotice_t *notice;
+    struct sockaddr_in *from;
+    int (*predicate) __P((ZNotice_t *, void *));
+    void *args;
 {
     ZNotice_t tmpnotice;
     Code_t retval;
index 8b26f8aa8c4c222e0ad6adbb2aba003c648d3857..401f6db53b430f49c05ffa043e488280e5eb4d4e 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #ifndef lint
-static const char rcsid_ZInitialize_c[] =
+static char rcsid_ZInitialize_c[] =
     "$Zephyr: /afs/athena.mit.edu/astaff/project/zephyr/src/lib/RCS/ZInitialize.c,v 1.17 89/05/30 18:11:25 jtkohl Exp $";
 #endif
 
@@ -21,44 +21,28 @@ static const char rcsid_ZInitialize_c[] =
 #ifdef HAVE_KRB4
 #include <krb_err.h>
 #endif
-#ifdef HAVE_KRB5
-#include <krb5.h>
-#endif
-#ifdef HAVE_KRB5_ERR_H
-#include <krb5_err.h>
-#endif
 
 #ifndef INADDR_NONE
 #define INADDR_NONE 0xffffffff
 #endif
 
-Code_t
-ZInitialize(void)
+Code_t ZInitialize()
 {
     struct servent *hmserv;
     struct hostent *hostent;
     char addr[4], hostname[MAXHOSTNAMELEN];
     struct in_addr servaddr;
     struct sockaddr_in sin;
-    unsigned int s, sinsize = sizeof(sin);
+    int s, sinsize = sizeof(sin);
     Code_t code;
     ZNotice_t notice;
-#ifdef HAVE_KRB5
-    char **krealms = NULL;
-#else
 #ifdef HAVE_KRB4
     char *krealm = NULL;
     int krbval;
     char d1[ANAME_SZ], d2[INST_SZ];
-#endif
-#endif
 
-#ifdef HAVE_KRB4
     initialize_krb_error_table();
 #endif
-#ifdef HAVE_KRB5
-    initialize_krb5_error_table();
-#endif
 
     initialize_zeph_error_table();
     
@@ -83,11 +67,6 @@ ZInitialize(void)
     __Q_Tail = NULL;
     __Q_Head = NULL;
     
-#ifdef HAVE_KRB5
-    if ((code = krb5_init_context(&Z_krb5_ctx)))
-        return(code);
-#endif
-
     /* if the application is a server, there might not be a zhm.  The
        code will fall back to something which might not be "right",
        but this is is ok, since none of the servers call krb_rd_req. */
@@ -106,14 +85,8 @@ ZInitialize(void)
          If this code ever support a multiplexing zhm, this will have to
          be made smarter, and probably per-message */
 
-#ifdef HAVE_KRB5
-       code = krb5_get_host_realm(Z_krb5_ctx, notice.z_message, &krealms);
-       if (code)
-        return(code);
-#else
 #ifdef HAVE_KRB4
        krealm = krb_realmofhost(notice.z_message);
-#endif
 #endif
        hostent = gethostbyname(notice.z_message);
        if (hostent && hostent->h_addrtype == AF_INET)
@@ -122,24 +95,6 @@ ZInitialize(void)
        ZFreeNotice(&notice);
     }
 
-#ifdef HAVE_KRB5
-    if (krealms) {
-      strcpy(__Zephyr_realm, krealms[0]);
-      krb5_free_host_realm(Z_krb5_ctx, krealms);
-    } else {
-      char *p; /* XXX define this somewhere portable */
-      /* XXX check ticket file here */
-      code = krb5_get_default_realm(Z_krb5_ctx, &p);
-      strcpy(__Zephyr_realm, p);
-#ifdef HAVE_KRB5_FREE_DEFAULT_REALM
-      krb5_free_default_realm(Z_krb5_ctx, p);
-#else
-      free(p);
-#endif
-      if (code)
-       return code;
-    }
-#else
 #ifdef HAVE_KRB4
     if (krealm) {
        strcpy(__Zephyr_realm, krealm);
@@ -150,7 +105,6 @@ ZInitialize(void)
     }
 #else
     strcpy(__Zephyr_realm, "local-realm");
-#endif
 #endif
 
     __My_addr.s_addr = INADDR_NONE;
index 0f507c3ed57bc75670279ad9294419c746bc1e0e..11e4a7a9ab4d1bbe3caa155111a6bc2c0073fa67 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #ifndef lint
-static const char rcsid_ZLocations_c[] =
+static char rcsid_ZLocations_c[] =
     "$Zephyr: /afs/athena.mit.edu/astaff/project/zephyr/src/lib/RCS/ZLocations.c,v 1.30 90/12/20 03:04:39 raeburn Exp $";
 #endif
 
@@ -23,9 +23,9 @@ static const char rcsid_ZLocations_c[] =
 static char host[MAXHOSTNAMELEN], mytty[MAXPATHLEN];
 static int location_info_set = 0;
 
-Code_t
-ZInitLocationInfo(char *hostname,
-                 char *tty)
+Code_t ZInitLocationInfo(hostname, tty)
+    char *hostname;
+    char *tty;
 {
     char *ttyp, *p;
     struct hostent *hent;
@@ -56,28 +56,26 @@ ZInitLocationInfo(char *hostname,
     return (ZERR_NONE);
 }
 
-Code_t
-ZSetLocation(char *exposure)
+Code_t ZSetLocation(exposure)
+    char *exposure;
 {
     return (Z_SendLocation(LOGIN_CLASS, exposure, ZAUTH, 
                           "$sender logged in to $1 on $3 at $2"));
 }
 
-Code_t
-ZUnsetLocation(void)
+Code_t ZUnsetLocation()
 {
     return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH, 
                           "$sender logged out of $1 on $3 at $2"));
 }
 
-Code_t
-ZFlushMyLocations(void)
+Code_t ZFlushMyLocations()
 {
     return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, ""));
 }
 
-char *
-ZParseExposureLevel(char *text)
+char *ZParseExposureLevel(text)
+     char *text;
 {
     if (!strcasecmp(text, EXPOSE_NONE))
        return (EXPOSE_NONE);
@@ -96,23 +94,24 @@ ZParseExposureLevel(char *text)
 }
 
 /* lifted from lib/ZSendPkt.c wait_for_hmack, but waits for SERVACK instead */
-static int
-wait_for_srvack(ZNotice_t *notice, 
-                ZUnique_id_t *uid)
+static int wait_for_srvack(notice, uid)
+    ZNotice_t *notice;
+    ZUnique_Id_t *uid;
 {
     return (notice->z_kind == SERVACK && ZCompareUID(&notice->z_uid, uid));
 }
 
-Code_t
-Z_SendLocation(char *class,
-              char *opcode,
-              Z_AuthProc auth,
-              char *format)
+Code_t Z_SendLocation(class, opcode, auth, format)
+    char *class;
+    char *opcode;
+    Z_AuthProc auth;
+    char *format;
 {
     int retval;
     time_t ourtime;
     ZNotice_t notice, retnotice;
     char *bptr[3];
+    struct hostent *hent;
     short wg_port = ZGetWGPort();
 
     if (!location_info_set)
index cd0e24bef69e2df443cdfca9f69ef479b00c1e7e..d188536c6a81807ac6f98669de4e3ab4b4181ffc 100644 (file)
@@ -19,11 +19,11 @@ static const char rcsid_ZMakeAscii_c[] = "$Id$";
 
 static char *itox_chars = "0123456789ABCDEF";
 
-Code_t
-ZMakeAscii(register char *ptr,
-          int len,
-          unsigned char *field,
-          int num)
+Code_t ZMakeAscii(ptr, len, field, num)
+    register char *ptr;
+    int len;
+    unsigned char *field;
+    int num;
 {
     int i;
 
@@ -52,10 +52,10 @@ ZMakeAscii(register char *ptr,
     return ZERR_NONE;
 }
 
-Code_t
-ZMakeAscii32(register char *ptr,
-            int len,
-            unsigned long value)
+Code_t ZMakeAscii32(ptr, len, value)
+    register char *ptr;
+    int len;
+    unsigned long value;
 {
     if (len < 11)
        return ZERR_FIELDLEN;
@@ -73,10 +73,10 @@ ZMakeAscii32(register char *ptr,
     return ZERR_NONE;
 }
 
-Code_t
-ZMakeAscii16(register char *ptr,
-            int len,
-            unsigned int value)
+Code_t ZMakeAscii16(ptr, len, value)
+    register char *ptr;
+    int len;
+    unsigned int value;
 {
     if (len < 7)
        return ZERR_FIELDLEN;
diff --git a/zephyr/lib/ZMakeZcode.c b/zephyr/lib/ZMakeZcode.c
deleted file mode 100644 (file)
index 85c6f9d..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/* This file is part of the Project Athena Zephyr Notification System.
- * It contains source for the ZMakeZcode function.
- *
- *     Created by:     Jeffrey Hutzelman
- *
- *     $Id$
- *
- *     Copyright (c) 1987, 2002 by the Massachusetts Institute of Technology.
- *     For copying and distribution information, see the file
- *     "mit-copyright.h". 
- */
-
-#include <internal.h>
-#include <assert.h>
-
-#ifndef lint
-static const char rcsid_ZMakeZcode_c[] = "$Id$";
-#endif
-
-Code_t
-ZMakeZcode32(char *ptr,
-            int len,
-            unsigned long val)
-{
-    unsigned char buf[4];
-    buf[0] = (val >> 24) & 0xff;
-    buf[1] = (val >> 16) & 0xff;
-    buf[2] = (val >>  8) & 0xff;
-    buf[3] =  val        & 0xff;
-    return ZMakeZcode(ptr, len, buf, 4);
-}
-
-Code_t
-ZMakeZcode(register char *ptr,
-          int len,
-          unsigned char *field,
-          int num)
-{
-    int i;
-
-    /*
-     * This optimistic check lets us discover quickly if the buffer
-     * is not even large enough to hold the field without escapes.
-     * It also insures we'll have space for the leading 'Z' and the
-     * trailing NUL.  Note that this does _not_ remove the need for
-     * checking length as we encode.
-     */
-    if (len < num + 2)
-      return ZERR_FIELDLEN;
-    *ptr++ = 'Z';
-    --len;
-    for (i=0;i<num;i++) {
-        switch (field[i]) {
-            case 0x00:
-                if (len < 3)
-                    return ZERR_FIELDLEN;
-                *ptr++ = 0xff;
-                *ptr++ = 0xf0;
-                len -= 2;
-                continue;
-
-            case 0xff:
-                if (len < 3)
-                    return ZERR_FIELDLEN;
-                *ptr++ = 0xff;
-                *ptr++ = 0xf1;
-                len -= 2;
-                continue;
-
-            default:
-                if (len < 2)
-                    return ZERR_FIELDLEN;
-                *ptr++ = field[i];
-                len--;
-        }
-    }
-
-    *ptr = '\0';
-    return ZERR_NONE;
-}
index 121f81306b5ec50727921784f110024046b7d42f..5a6749c2defdb8e12b8a95c2760f8c2a826c54f2 100644 (file)
@@ -7,7 +7,7 @@
  *
  *     Copyright (c) 1987 by the Massachusetts Institute of Technology.
  *     For copying and distribution information, see the file
- *     "mit-copyright.h".
+ *     "mit-copyright.h". 
  */
 
 #include <internal.h>
@@ -20,25 +20,16 @@ static const char rcsid_ZMakeAuthentication_c[] = "$Id$";
 #include <krb_err.h>
 #endif
 
-#if defined(HAVE_KRB5) && !HAVE_KRB5_FREE_DATA
-#define krb5_free_data(ctx, dat) free((dat)->data)
-#endif
-
-Code_t
-ZResetAuthentication(void)
-{
+Code_t ZResetAuthentication () {
     return ZERR_NONE;
 }
 
-Code_t
-ZMakeAuthentication(register ZNotice_t *notice,
-                   char *buffer,
-                   int buffer_len,
-                   int *len)
+Code_t ZMakeAuthentication(notice, buffer, buffer_len, len)
+    register ZNotice_t *notice;
+    char *buffer;
+    int buffer_len;
+    int *len;
 {
-#ifdef HAVE_KRB5
-    return ZMakeZcodeAuthentication(notice, buffer, buffer_len, len/*?XXX*/);
-#else
 #ifdef HAVE_KRB4
     int result;
     time_t now;
@@ -46,9 +37,9 @@ ZMakeAuthentication(register ZNotice_t *notice,
     char *cstart, *cend;
     ZChecksum_t checksum;
     CREDENTIALS cred;
-    C_Block *session;
+    extern unsigned long des_quad_cksum();
 
-    result = krb_mk_req(&authent, SERVER_SERVICE,
+    result = krb_mk_req(&authent, SERVER_SERVICE, 
                        SERVER_INSTANCE, __Zephyr_realm, 0);
     if (result != MK_AP_OK)
        return (result+krb_err_base);
@@ -57,17 +48,15 @@ ZMakeAuthentication(register ZNotice_t *notice,
     if (result != KSUCCESS)
        return (result+krb_err_base);
 
-    session = (C_Block *)cred.session;
-
     notice->z_auth = 1;
     notice->z_authent_len = authent.length;
     notice->z_ascii_authent = (char *)malloc((unsigned)authent.length*3);
     /* zero length authent is an error, so malloc(0) is not a problem */
     if (!notice->z_ascii_authent)
        return (ENOMEM);
-    if ((result = ZMakeAscii(notice->z_ascii_authent,
-                            authent.length*3,
-                            authent.dat,
+    if ((result = ZMakeAscii(notice->z_ascii_authent, 
+                            authent.length*3, 
+                            authent.dat, 
                             authent.length)) != ZERR_NONE) {
        free(notice->z_ascii_authent);
        return (result);
@@ -80,11 +69,11 @@ ZMakeAuthentication(register ZNotice_t *notice,
        return(result);
 
     /* Compute a checksum over the header and message. */
-    checksum = des_quad_cksum(buffer, NULL, cstart - buffer, 0, session);
+    checksum = des_quad_cksum(buffer, NULL, cstart - buffer, 0, cred.session);
     checksum ^= des_quad_cksum(cend, NULL, buffer + *len - cend, 0,
-                              session);
+                              cred.session);
     checksum ^= des_quad_cksum(notice->z_message, NULL, notice->z_message_len,
-                              0, session);
+                              0, cred.session);
     notice->z_checksum = checksum;
     ZMakeAscii32(cstart, buffer + buffer_len - cstart, checksum);
 
@@ -96,152 +85,4 @@ ZMakeAuthentication(register ZNotice_t *notice,
     notice->z_ascii_authent = "";
     return (Z_FormatRawHeader(notice, buffer, buffer_len, len, NULL, NULL));
 #endif
-#endif
 }
-
-Code_t
-ZMakeZcodeAuthentication(register ZNotice_t *notice,
-                        char *buffer,
-                        int buffer_len,
-                        int *phdr_len)
-{
-    return ZMakeZcodeRealmAuthentication(notice, buffer, buffer_len, phdr_len,
-                                        __Zephyr_realm);
-}
-
-Code_t
-ZMakeZcodeRealmAuthentication(register ZNotice_t *notice,
-                             char *buffer,
-                             int buffer_len,
-                             int *phdr_len,
-                             char *realm)
-{
-#ifdef HAVE_KRB5
-    krb5_error_code result;
-    krb5_creds *creds;
-    krb5_keyblock *keyblock;
-    krb5_auth_context authctx;
-    krb5_data *authent;
-    char *cksum_start, *cstart, *cend;
-    int cksum_len, zcode_len, phdr_adj;
-
-    result = ZGetCredsRealm(&creds, realm);
-    if (result)
-       return result;
-    /* HOLDING: creds */
-
-    /* Figure out what checksum type to use */
-    keyblock = Z_credskey(creds);
-    /* HOLDING: creds */
-
-    /* Create the authenticator */
-    result = krb5_auth_con_init(Z_krb5_ctx, &authctx);
-    if (result) {
-       krb5_free_creds(Z_krb5_ctx, creds);
-       return (result);
-    }
-
-    authent = (krb5_data *)malloc(sizeof(krb5_data));
-
-    /* HOLDING: creds, authctx */
-    result = krb5_mk_req_extended(Z_krb5_ctx, &authctx, 0 /* options */,
-                                 0 /* in_data */, creds, authent);
-    krb5_auth_con_free(Z_krb5_ctx, authctx);
-    if (result) {
-       krb5_free_creds(Z_krb5_ctx, creds);
-       return (result);
-    }
-    /* HOLDING: creds, authent */
-
-    /* Encode the authenticator */
-    notice->z_auth = 1;
-    notice->z_authent_len = authent->length;
-    zcode_len = authent->length * 2 + 2; /* 2x growth plus Z and null */
-    notice->z_ascii_authent = (char *)malloc(zcode_len);
-    if (!notice->z_ascii_authent) {
-       krb5_free_data(Z_krb5_ctx, authent);
-       krb5_free_creds(Z_krb5_ctx, creds);
-       return (ENOMEM);
-    }
-    /* HOLDING: creds, authent, notice->z_ascii_authent */
-    result = ZMakeZcode(notice->z_ascii_authent, zcode_len,
-                       (unsigned char *)authent->data, authent->length);
-    krb5_free_data(Z_krb5_ctx, authent);
-    if (result) {
-       free(notice->z_ascii_authent);
-       krb5_free_creds(Z_krb5_ctx, creds);
-       return (result);
-    }
-    /* HOLDING: creds, notice->z_ascii_authent */
-
-    /* format the notice header, with a zero checksum */
-    result = Z_NewFormatRawHeader(notice, buffer, buffer_len, phdr_len,
-                                 &cksum_start, &cksum_len, &cstart, &cend);
-    free(notice->z_ascii_authent);
-    notice->z_authent_len = 0;
-    if (result) {
-       krb5_free_creds(Z_krb5_ctx, creds);
-       return (result);
-    }
-    result = Z_InsertZcodeChecksum(keyblock, notice, buffer, cksum_start,
-                                   cksum_len, cstart, cend, buffer_len,
-                                   &phdr_adj);
-    krb5_free_creds(Z_krb5_ctx, creds);
-    if (result) {
-         return result;
-    }
-    *phdr_len += phdr_adj;
-
-    return (result);
-#endif /* HAVE_KRB5 */
-}
-
-#ifdef HAVE_KRB5
-int
-ZGetCreds(krb5_creds **creds_out)
-{
-  return ZGetCredsRealm(creds_out, __Zephyr_realm);
-}
-
-int
-ZGetCredsRealm(krb5_creds **creds_out,
-              char *realm)
-{
-  krb5_creds creds_in;
-  krb5_ccache ccache; /* XXX make this a global or static?*/
-  int result;
-
-  result = krb5_cc_default(Z_krb5_ctx, &ccache);
-  if (result)
-    return result;
-
-  memset((char *)&creds_in, 0, sizeof(creds_in));
-  result = krb5_build_principal(Z_krb5_ctx, &creds_in.server,
-                               strlen(realm),
-                               realm,
-                               SERVER_SERVICE, SERVER_INSTANCE, 0);
-  if (result) {
-    krb5_cc_close(Z_krb5_ctx, ccache);
-    return result;
-  }
-
-  result = krb5_cc_get_principal(Z_krb5_ctx, ccache, &creds_in.client);
-  if (result) {
-    krb5_free_cred_contents(Z_krb5_ctx, &creds_in); /* I also hope this is ok */
-    krb5_cc_close(Z_krb5_ctx, ccache);
-    return result;
-  }
-
-#ifdef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
-  creds_in.keyblock.enctype = ENCTYPE_DES_CBC_CRC; /* XXX? */
-#else
-  creds_in.session.keytype = KEYTYPE_DES; /* XXX? */
-#endif
-
-  result = krb5_get_credentials(Z_krb5_ctx, 0, ccache, &creds_in, creds_out);
-  krb5_cc_close(Z_krb5_ctx, ccache);
-  krb5_free_cred_contents(Z_krb5_ctx, &creds_in); /* I also hope this is ok */
-
-  return result;
-}
-#endif
index c598c2695f2b222984e96492be9ea9a795d8d7b0..9ad620d5ce734d8ec16dab0c9c6b272797e3bb07 100644 (file)
@@ -17,10 +17,10 @@ static const char rcsid_ZNewLocateUser_c[] =
     "$Id$";
 #endif
 
-Code_t
-ZLocateUser(char *user,
-           int *nlocs,
-           Z_AuthProc auth)
+Code_t ZLocateUser(user, nlocs, auth)
+    char *user;
+    int *nlocs;
+    Z_AuthProc auth;
 {
     Code_t retval;
     ZNotice_t notice;
index 3116e9b0f1aec1f5fe3d66a942f435b8355a67d3..75cec22736c6e301cea699e58c2884609a0cf45f 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZOpenPort_c[] = "$Id$";
+static char rcsid_ZOpenPort_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 #include <sys/socket.h>
 
-Code_t
-ZOpenPort(u_short *port)
+Code_t ZOpenPort(port)
+    u_short *port;
 {
     struct sockaddr_in bindin;
-    unsigned int len;
+    int len;
     
     (void) ZClosePort();
 
index 72a75872db7ee27396ae0d205460287271d4ad62..7950e9641df6b76b8db8ab2ffc14bbb50100bc95 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZParseNotice_c[] =
+static char rcsid_ZParseNotice_c[] =
     "$Zephyr: /mit/zephyr/src/lib/RCS/ZParseNotice.c,v 1.22 91/03/29 03:34:46 raeburn Exp $";
 #endif
 
 #include <internal.h>
 
 /* Skip to the next NUL-terminated field in the packet. */
-static char *
-next_field(char *ptr,
-          char *end)
+static char *next_field(ptr, end)
+    char *ptr, *end;
 {
     while (ptr < end && *ptr != '\0')
        ptr++;
@@ -29,10 +28,10 @@ next_field(char *ptr,
     return (ptr);
 }
 
-Code_t
-ZParseNotice(char *buffer,
-            int len,
-            ZNotice_t *notice)
+Code_t ZParseNotice(buffer, len, notice)
+    char *buffer;
+    int len;
+    ZNotice_t *notice;
 {
     char *ptr, *end;
     unsigned long temp;
@@ -210,22 +209,11 @@ ZParseNotice(char *buffer,
     else
        notice->z_default_format = "";
        
-    if (numfields && ptr < end) {
-      notice->z_ascii_checksum = ptr;
-
-      if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD)
-       notice->z_checksum = 0;
-      else
-       notice->z_checksum = temp;
-
-      numfields--;
-      ptr = next_field (ptr, end);
-    }
-    else 
-      {
-       notice->z_ascii_checksum = "";
-       notice->z_checksum = 0;
-      }
+    if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD)
+       BAD_PACKET;
+    notice->z_checksum = temp;
+    numfields--;
+    ptr = next_field(ptr, end);
 
     if (numfields && ptr < end) {
        notice->z_multinotice = ptr;
index 3bc3e90485a570dd0acf75be51488bf6dc4aed24..b63b57c9e5ba96bc65d26e27a079adec7678ef0a 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZPeekIfNotice_c[] = "$Id$";
+static char rcsid_ZPeekIfNotice_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZPeekIfNotice(ZNotice_t *notice,
-             struct sockaddr_in *from,
-             int (*predicate)(ZNotice_t *, char *),
-             char *args)
+Code_t ZPeekIfNotice(notice, from, predicate, args)
+    ZNotice_t *notice;
+    struct sockaddr_in *from;
+    int (*predicate)();
+    char *args;
 {
     ZNotice_t tmpnotice;
     Code_t retval;
index 18c2026e2f62452e1170a232d15f16b3e1630620..f97e8553e0e6d32eeb897e3c0ca9e207dfd3c7c9 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZPeekNotice_c[] = "$Id$";
+static char rcsid_ZPeekNotice_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZPeekNotice(ZNotice_t *notice,
-           struct sockaddr_in *from)
+Code_t ZPeekNotice(notice, from)
+    ZNotice_t *notice;
+    struct sockaddr_in *from;
 {
     char *buffer;
     int len;
index 53c5dd7834f569383f3fc2224ac46e9047c2e8b3..2d9375891331aeb773c6661351d91203be2c2bad 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZPeekPacket_c[] = "$Id$";
+static char rcsid_ZPeekPacket_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZPeekPacket(char **buffer,
-           int *ret_len,
-           struct sockaddr_in *from)
+Code_t ZPeekPacket(buffer, ret_len, from)
+    char **buffer;
+    int *ret_len;
+    struct sockaddr_in *from;
 {
     Code_t retval;
     struct _Z_InputQ *nextq;
index 6053c6971455ad3d415ec0d8419ee6032184a558..05c8ba0c199d210cfaeb9ec4207b699ee83aea86 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZPending_c[] = "$Id$";
+static char rcsid_ZPending_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-int
-ZPending(void)
+int ZPending()
 {
        int retval;
        
index 49aaa5866a2bf35a17488de465a6324e8d57a7a5..53037cb86428bae165232a6b8f6488b612cd6866 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZReadAscii_c[] = "$Id$";
+static char rcsid_ZReadAscii_c[] = "$Id$";
 #endif /* lint */
 
 #include <internal.h>
 #include <assert.h>
 
+#if 0
+static __inline__
+int
+Z_cnvt_xtoi (char c)
+{
+    c -= '0';
+    if (c < 10)
+       return c;
+    c -= 'A'-'9'-1;
+    if (c < 16)
+       return c;
+    return -1;
+}
+#endif
+
 #define Z_cnvt_xtoi(c)  ((temp=(c)-'0'),(temp<10)?temp:((temp-='A'-'9'-1),(temp<16)?temp:-1))
 
-Code_t
-ZReadAscii(char *ptr,
-          int len,
-          unsigned char *field,
-          int num)
+Code_t ZReadAscii(ptr, len, field, num)
+    char *ptr;
+    int len;
+    unsigned char *field;
+    int num;
 {
     int i;
     unsigned int hexbyte;
@@ -56,10 +71,10 @@ ZReadAscii(char *ptr,
     return *ptr ? ZERR_BADFIELD : ZERR_NONE;
 }
 
-Code_t
-ZReadAscii32(char *ptr,
-            int len,
-            unsigned long *value_ptr)
+Code_t ZReadAscii32(ptr, len, value_ptr)
+    char *ptr;
+    int len;
+    unsigned long *value_ptr;
 {
     unsigned char buf[4];
     Code_t retval;
@@ -71,10 +86,10 @@ ZReadAscii32(char *ptr,
     return ZERR_NONE;
 }
 
-Code_t
-ZReadAscii16(char *ptr,
-            int len,
-            unsigned short *value_ptr)
+Code_t ZReadAscii16(ptr, len, value_ptr)
+    char *ptr;
+    int len;
+    unsigned short *value_ptr;
 {
     unsigned char buf[2];
     Code_t retval;
diff --git a/zephyr/lib/ZReadZcode.c b/zephyr/lib/ZReadZcode.c
deleted file mode 100644 (file)
index dc97990..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/* This file is part of the Project Athena Zephyr Notification System.
- * It contains source for the ZReadZcode function.
- *
- *     Created by:     Jeffrey Hutzelman
- *
- *     $Id$
- *
- *     Copyright (c) 1987, 1990, 2002 by the Massachusetts Institute of Technology.
- *     For copying and distribution information, see the file
- *     "mit-copyright.h". 
- */
-
-#ifndef lint
-static const char rcsid_ZReadZcode_c[] = "$Id$";
-#endif /* lint */
-
-#include <internal.h>
-#include <assert.h>
-
-
-Code_t
-ZReadZcode(unsigned char *ptr,
-          unsigned char *field,
-          int max,
-          int *len)
-{
-    int n = 0;
-
-    if (*ptr++ != 'Z')
-        return ZERR_BADFIELD;
-
-    while (*ptr && n < max) {
-        if (*ptr == 0xff) {
-            ptr++;
-            switch (*ptr++) {
-                case 0xf0: field[n++] = 0x00; continue;
-                case 0xf1: field[n++] = 0xff; continue;
-                default:   return ZERR_BADFIELD;
-            }
-        } else {
-            field[n++] = *ptr++;
-        }
-    }
-    if (*ptr)
-        return (ZERR_BADFIELD);
-    *len = n;
-    return (ZERR_NONE);
-}
index fbb288af4d0846136a996fc40bc10e16c87812c6..27cba29605a0f85d1bba22bc82b6c5cdac9e9a03 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZReceiveNotice_c[] = "$Id$";
+static char rcsid_ZReceiveNotice_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZReceiveNotice(ZNotice_t *notice,
-              struct sockaddr_in *from)
+Code_t ZReceiveNotice(notice, from)
+    ZNotice_t *notice;
+    struct sockaddr_in *from;
 {
     char *buffer;
     struct _Z_InputQ *nextq;
index 3f36ddcb8373ec1e15a8e3fde0f4cb8a8e74c4aa..593793428bf8b9e096c427e03aa9952fc29ba2f9 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZReceivePacket_c[] = "$Id$";
+static char rcsid_ZReceivePacket_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZReceivePacket(ZPacket_t buffer,
-              int *ret_len,
-              struct sockaddr_in *from)
+Code_t ZReceivePacket(buffer, ret_len, from)
+    ZPacket_t buffer;
+    int *ret_len;
+    struct sockaddr_in *from;
 {
     Code_t retval;
     struct _Z_InputQ *nextq;
index 9926171bf584393b59032a281f2dc0be10e36756..bd2cf5d89b600aabeeeab90f756eb796284aa19d 100644 (file)
@@ -18,12 +18,16 @@ static const char rcsid_ZRetrieveSubscriptions_c[] =
     "$Id$";
 #endif
 
-static Code_t Z_RetSubs (register ZNotice_t *, int *, Z_AuthProc);
+static Code_t Z_RetSubs ();
 
 /* Need STDC definition when possible for unsigned short argument. */
-Code_t
-ZRetrieveSubscriptions(unsigned short port,
-                      int *nsubs)
+#ifdef __STDC__
+Code_t ZRetrieveSubscriptions(unsigned short port, int *nsubs)
+#else
+Code_t ZRetrieveSubscriptions(port,nsubs)
+       unsigned short port;
+       int *nsubs;
+#endif
 {
        int retval;
        ZNotice_t notice;
@@ -44,8 +48,8 @@ ZRetrieveSubscriptions(unsigned short port,
        return(Z_RetSubs(&notice, nsubs, ZAUTH));
 }
 
-Code_t
-ZRetrieveDefaultSubscriptions(int *nsubs)
+Code_t ZRetrieveDefaultSubscriptions(nsubs)
+       int *nsubs;
 {
        ZNotice_t notice;
 
@@ -58,10 +62,10 @@ ZRetrieveDefaultSubscriptions(int *nsubs)
 
 }
 
-static Code_t
-Z_RetSubs(register ZNotice_t *notice,
-         int *nsubs,
-         Z_AuthProc auth_routine)
+static Code_t Z_RetSubs(notice, nsubs, auth_routine)
+       register ZNotice_t *notice;
+       int *nsubs;
+       Z_AuthProc auth_routine;
 {
        register int i;
        int retval,nrecv,gimmeack;
index e5d9baa4dbd11c7ec40ac3e76e174dfeb688eca9..323bb5d19ad5bd87049cc1ccf00d3d8f5f3c3254 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZSendList_c[] = "$Id$";
+static char rcsid_ZSendList_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t ZSendList(ZNotice_t *notice,
-                char *list[],
-                int nitems,
-                Z_AuthProc cert_routine)
+Code_t ZSendList(notice, list, nitems, cert_routine)
+    ZNotice_t *notice;
+    char *list[];
+    int nitems;
+    Z_AuthProc cert_routine;
 {
     return(ZSrvSendList(notice, list, nitems, cert_routine, Z_XmitFragment));
 }
 
-Code_t
-ZSrvSendList(ZNotice_t *notice,
-            char *list[],
-            int nitems,
-            Z_AuthProc cert_routine,
-            Code_t (*send_routine)(ZNotice_t *, char *, int, int))
+Code_t ZSrvSendList(notice, list, nitems, cert_routine, send_routine)
+    ZNotice_t *notice;
+    char *list[];
+    int nitems;
+    Z_AuthProc cert_routine;
+    Code_t (*send_routine)();
 {
     Code_t retval;
     ZNotice_t newnotice;
index be23d5ad1d5c194f87ba81aa7f2e93b41df24e14..4f3b996e3ad73ffab9290dfb91348435edf05e45 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZSendNotice_c[] = "$Id$";
+static char rcsid_ZSendNotice_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZSendNotice(ZNotice_t *notice,
-           Z_AuthProc cert_routine)
+Code_t ZSendNotice(notice, cert_routine)
+    ZNotice_t *notice;
+    Z_AuthProc cert_routine;
 {
     return(ZSrvSendNotice(notice, cert_routine, Z_XmitFragment));
 }
 
-Code_t
-ZSrvSendNotice(ZNotice_t *notice,
-              Z_AuthProc cert_routine,
-              Code_t (*send_routine)(ZNotice_t *, char *, int, int))
+Code_t ZSrvSendNotice(notice, cert_routine, send_routine)
+    ZNotice_t *notice;
+    Z_AuthProc cert_routine;
+    Code_t (*send_routine)();
 {    
     Code_t retval;
     ZNotice_t newnotice;
index ef1eb6bc62b9afdf213114f5282ec1aef6e9215a..66a25729662b8218874c6ced88d1ab5ef1dfe735 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZSendPacket_c[] =
+static char rcsid_ZSendPacket_c[] =
     "$Zephyr: /mit/zephyr/src/lib/RCS/ZSendPacket.c,v 1.29 91/03/21 11:57:08 raeburn Exp $";
 #endif
 
 #include <internal.h>
 #include <sys/socket.h>
 
-static int wait_for_hmack(ZNotice_t *, void *);
+static int wait_for_hmack();
 
-Code_t
-ZSendPacket(char *packet,
-           int len,
-           int waitforack)
+Code_t ZSendPacket(packet, len, waitforack)
+    char *packet;
+    int len;
+    int waitforack;
 {
     Code_t retval;
     struct sockaddr_in dest;
@@ -51,8 +51,8 @@ ZSendPacket(char *packet,
     if ((retval = ZParseNotice(packet, len, &notice)) != ZERR_NONE)
        return (retval);
     
-    retval = Z_WaitForNotice(&acknotice, wait_for_hmack, &notice.z_uid,
-                            HM_TIMEOUT);
+    retval = Z_WaitForNotice (&acknotice, wait_for_hmack, &notice.z_uid,
+                             HM_TIMEOUT);
     if (retval == ETIMEDOUT)
       return ZERR_HMDEAD;
     if (retval == ZERR_NONE)
@@ -60,9 +60,9 @@ ZSendPacket(char *packet,
     return retval;
 }
 
-static int
-wait_for_hmack(ZNotice_t *notice,
-              void *uid)
+static int wait_for_hmack(notice, uid)
+    ZNotice_t *notice;
+    ZUnique_Id_t *uid;
 {
-    return (notice->z_kind == HMACK && ZCompareUID(&notice->z_uid, (ZUnique_Id_t *)uid));
+    return (notice->z_kind == HMACK && ZCompareUID(&notice->z_uid, uid));
 }
index 3cb4c636f03d98622abc436265ba1a8a7742b24f..56f282ee18db52d233ac86f66af36cb74a85162a 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZSendRawList_c[] = "$Id$";
+static char rcsid_ZSendRawList_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t ZSendRawList(ZNotice_t *notice,
-                   char *list[],
-                   int nitems)
+Code_t ZSendRawList(notice, list, nitems)
+    ZNotice_t *notice;
+    char *list[];
+    int nitems;
 {
     return(ZSrvSendRawList(notice, list, nitems, Z_XmitFragment));
 }
 
-Code_t ZSrvSendRawList(ZNotice_t *notice,
-                      char *list[],
-                      int nitems,
-                      Code_t (*send_routine)(ZNotice_t *, char *, int, int))
+Code_t ZSrvSendRawList(notice, list, nitems, send_routine)
+    ZNotice_t *notice;
+    char *list[];
+    int nitems;
+    Code_t (*send_routine)();
 {
     Code_t retval;
     ZNotice_t newnotice;
index b4eadc35924024aeafc012fba2fb7d3e2b80e2f8..2ea95d14cf18b332ce9bcf6e8dbd96f222f80b9d 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZSendRawNotice_c[] = "$Id$";
+static char rcsid_ZSendRawNotice_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZSendRawNotice(ZNotice_t *notice)
+Code_t ZSendRawNotice(notice)
+    ZNotice_t *notice;
 {
     Code_t retval;
     ZNotice_t newnotice;
index 4869fbfde1d9c2ae9be477a2c2ba3842ac48ad16..7190dcd3e8894db1f6077a70fa8a4fe24d743de0 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZSetDestAddr_c[] = "$Id$";
+static char rcsid_ZSetDestAddr_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZSetDestAddr(struct sockaddr_in *addr)
+Code_t ZSetDestAddr(addr)
+       struct  sockaddr_in *addr;
 {
        __HM_addr = *addr;
 
index b0f3df71ad5b8ac3db224ebc66a7a8dde0c01a8e..c22f66faf1f8ceb3ee63514b58d52781d4772a2d 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZSetFD_c[] = "$Id$";
+static char rcsid_ZSetFD_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZSetFD(int fd)
+Code_t ZSetFD(fd)
+       int     fd;
 {
        (void) ZClosePort();
 
index a3c67c0bcae0667a3e11c010d5f69e52490a5bd9..3f7d873f80f451795b526c0672f93e93edc09690 100644 (file)
  */
 
 #ifndef lint
-static const char rcsid_ZSetServerState_c[] = "$Id$";
+static char rcsid_ZSetServerState_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 
-Code_t
-ZSetServerState(int state)
+Code_t ZSetServerState(state)
+       int     state;
 {
        __Zephyr_server = state;
        
index e8519fe69a7a054185498d2db431385768f275a7..15a5a91a8382a86c270080e959c06694971661b8 100644 (file)
 static const char rcsid_ZSubscriptions_c[] = "$Id$";
 #endif
 
-static Code_t Z_Subscriptions(register ZSubscription_t *sublist,
-                             int nitems, unsigned int port,
-                             char *opcode, int authit);
-static Code_t subscr_sendoff(ZNotice_t *notice, char **lyst, int num,
-                            int authit);
-
-Code_t
-ZSubscribeTo(ZSubscription_t *sublist,
-            int nitems,
-            unsigned int port)
+static Code_t Z_Subscriptions __P((register ZSubscription_t *sublist,
+                                  int nitems, unsigned int port,
+                                  char *opcode, int authit));
+static Code_t subscr_sendoff __P((ZNotice_t *notice, char **lyst, int num,
+                                 int authit));
+
+Code_t ZSubscribeTo(sublist, nitems, port)
+    ZSubscription_t *sublist;
+    int nitems;
+    unsigned int port;
 {
     return (Z_Subscriptions(sublist, nitems, port, CLIENT_SUBSCRIBE, 1));
 }
 
-Code_t
-ZSubscribeToSansDefaults(ZSubscription_t *sublist,
-                        int nitems,
-                        unsigned int port)
+Code_t ZSubscribeToSansDefaults(sublist, nitems, port)
+    ZSubscription_t *sublist;
+    int nitems;
+    unsigned int port;
 {
     return (Z_Subscriptions(sublist, nitems, port, CLIENT_SUBSCRIBE_NODEFS,
                            1));
 }
 
-Code_t
-ZUnsubscribeTo(ZSubscription_t *sublist,
-              int nitems,
-              unsigned int port)
+Code_t ZUnsubscribeTo(sublist, nitems, port)
+    ZSubscription_t *sublist;
+    int nitems;
+    unsigned int port;
 {
     return (Z_Subscriptions(sublist, nitems, port, CLIENT_UNSUBSCRIBE, 1));
 }
 
-Code_t
-ZCancelSubscriptions(unsigned int port)
+Code_t ZCancelSubscriptions(port)
+    unsigned int port;
 {
     return (Z_Subscriptions((ZSubscription_t *)0, 0, port,
                            CLIENT_CANCELSUB, 0));
@@ -62,11 +62,12 @@ ZCancelSubscriptions(unsigned int port)
  */
 
 static Code_t
-Z_Subscriptions(register ZSubscription_t *sublist,
-               int nitems,
-               unsigned int port,
-               char *opcode,
-               int authit)
+Z_Subscriptions(sublist, nitems, port, opcode, authit)
+    register ZSubscription_t *sublist;
+    int nitems;
+    unsigned int port;
+    char *opcode;
+    int authit;
 {
     register int i, j;
     int retval;
@@ -166,10 +167,11 @@ Z_Subscriptions(register ZSubscription_t *sublist,
 }
 
 static Code_t
-subscr_sendoff(ZNotice_t *notice,
-              char **lyst,
-              int num,
-              int authit)
+subscr_sendoff(notice, lyst, num, authit)
+ZNotice_t *notice;
+char **lyst;
+int num;
+int authit;
 {
     register Code_t retval;
     ZNotice_t retnotice;
index 6f0aec9e8d703d5e1e14ebc390acbcc8fb2f2b3f..735286020b15511ccd793422d735060183557203 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #ifndef lint
-static const char rcsid_ZVariables_c[] = "$Id$";
+static char rcsid_ZVariables_c[] = "$Id$";
 #endif
 
 #include <internal.h>
@@ -20,14 +20,15 @@ static const char rcsid_ZVariables_c[] = "$Id$";
 #include <ctype.h>
 #include <pwd.h>
 
-static int get_localvarfile(char *bfr);
-static char *get_varval(char *fn, char *val);
-static int varline(char *bfr, char *var);
+static int get_localvarfile __P((char *bfr));
+static char *get_varval __P((char *fn, char *val));
+static int varline __P((char *bfr, char *var));
 
-char *
-ZGetVariable(char *var)
+char *ZGetVariable(var)
+    char *var;
 {
     char varfile[128], *ret;
+    char *get_varval();
 
     if (get_localvarfile(varfile))
        return ((char *)0);
@@ -39,8 +40,9 @@ ZGetVariable(char *var)
     return (get_varval(varfile, var));
 }
 
-Code_t
-ZSetVariable(char *var, char *value)
+Code_t ZSetVariable(var, value)
+    char *var;
+    char *value;
 {
     int written;
     FILE *fpin, *fpout;
@@ -78,8 +80,8 @@ ZSetVariable(char *var, char *value)
     return (ZERR_NONE);
 }      
 
-Code_t
-ZUnsetVariable(char *var)
+Code_t ZUnsetVariable(var)
+    char *var;
 {
     FILE *fpin, *fpout;
     char varfile[128], varfilebackup[128], varbfr[512];
@@ -108,8 +110,8 @@ ZUnsetVariable(char *var)
     return (ZERR_NONE);
 }      
 
-static int
-get_localvarfile(char *bfr)
+static int get_localvarfile(bfr)
+    char *bfr;
 {
     char *envptr;
     struct passwd *pwd;
@@ -135,8 +137,9 @@ get_localvarfile(char *bfr)
     return (0);
 } 
        
-static char *
-get_varval(char *fn, char *var)
+static char *get_varval(fn, var)
+    char *fn;
+    char *var;
 {
     FILE *fp;
     static char varbfr[512];
@@ -160,8 +163,9 @@ get_varval(char *fn, char *var)
 
 /* If the variable in the line bfr[] is the same as var, return index to
    the variable value, else return 0. */
-static int
-varline(char *bfr, char *var)
+static int varline(bfr, var)
+    char *bfr;
+    char *var;
 {
     register char *cp;
        
index d6c54096576de467508c875ef2001f1a66a04868..2313e2e58b4d818bcc8bbfc16630d744c40cbb43 100644 (file)
 #include "mit-copyright.h"
 
 #ifndef lint
-static const char rcsid_ZWaitForNotice_c[] = "$Id$";
+static char rcsid_ZWaitForNotice_c[] = "$Id$";
 #endif
 
 #include <internal.h>
 #include <sys/socket.h>
 
-Code_t
-Z_WaitForNotice(ZNotice_t *notice,
-               int (*pred) __P((ZNotice_t *, void *)),
-               void *arg,
-               int timeout)
+Code_t Z_WaitForNotice (notice, pred, arg, timeout)
+     ZNotice_t *notice;
+     int (*pred) __P((ZNotice_t *, void *));
+     void *arg;
+     int timeout;
 {
   Code_t retval;
   struct timeval tv, t0;
index f6e764cd4d4a41779d1fc9d5e52408edb126910c..916db54bf61c455b28b1250b4e8331fea76ceb4f 100644 (file)
@@ -17,9 +17,9 @@
 #define INADDR_LOOPBACK 0x7f000001
 #endif
 
-Code_t
-ZhmStat(struct in_addr *hostaddr,
-       ZNotice_t *notice)
+Code_t ZhmStat(hostaddr, notice)
+    struct in_addr *hostaddr;
+    ZNotice_t *notice;
 {
     struct servent *sp;
     struct sockaddr_in sin;
index 7b4b1c0ca0d23764d67670749964d6f19bf13e62..0efcc56f4700502bfa69071109e98d7a8727b8d4 100644 (file)
@@ -23,6 +23,8 @@ static const char copyright[] =
   "Copyright (c) 1987,1988,1991 by the Massachusetts Institute of Technology.";
 #endif
 
+extern char *inet_ntoa ();
+
 int __Zephyr_fd = -1;
 int __Zephyr_open;
 int __Zephyr_port = -1;
@@ -42,84 +44,29 @@ int __subscriptions_num;
 int __subscriptions_next;
 int Z_discarded_packets = 0;
 
-#ifdef HAVE_KRB5
-/* This context is used throughout */
-krb5_context Z_krb5_ctx;
-
-static struct cksum_map_s {
-  krb5_enctype e;
-  krb5_cksumtype c;
-} cksum_map[] = {
-  /* per RFC1510 and draft-ietf-krb-wg-crypto-02.txt */
-  { ENCTYPE_NULL,                     CKSUMTYPE_RSA_MD5 },
-  { ENCTYPE_DES_CBC_CRC,              CKSUMTYPE_RSA_MD5_DES },
-  { ENCTYPE_DES_CBC_MD4,              CKSUMTYPE_RSA_MD4_DES },
-  { ENCTYPE_DES_CBC_MD5,              CKSUMTYPE_RSA_MD5_DES },
-
-  /* 
-   * The implementors hate us, and are inconsistent with names for
-   * most things defined after RFC1510.  Note that des3-cbc-sha1
-   * and des3-cbc-sha1-kd are listed by number to avoid confusion 
-   * caused by inconsistency between the names used in the specs
-   * and those used by implementations.
-   * -- jhutz, 30-Nov-2002
-   */
-
-  /* source lost in history (an expired internet-draft) */
-  { 5 /* des3-cbc-md5 */,             9  /* rsa-md5-des3 */ },
-  { 7 /* des3-cbc-sha1 */,            13 /* hmac-sha1-des3 */ },
-
-  /* per draft-ietf-krb-wg-crypto-02.txt */
-  { 16 /* des3-cbc-sha1-kd */,        12 /* hmac-sha1-des3-kd */ },
-
-  /* per draft-raeburn-krb-rijndael-krb-02.txt */
-  { 17 /* aes128-cts-hmac-sha1-96 */, 15 /* hmac-sha1-96-aes128 */ },
-  { 18 /* aes256-cts-hmac-sha1-96 */, 16 /* hmac-sha1-96-aes256 */ },
-
-  /* per draft-brezak-win2k-krb-rc4-hmac-04.txt */
-  { 23 /* rc4-hmac */,                -138 /* hmac-md5 */ },
-  { 24 /* rc4-hmac-exp */,            -138 /* hmac-md5 */ },
-};
-#define N_CKSUM_MAP (sizeof(cksum_map) / sizeof(struct cksum_map_s))
-
-Code_t
-Z_krb5_lookup_cksumtype(krb5_enctype e,
-                       krb5_cksumtype *c)
-{
-  int i;
-
-  for (i = 0; i < N_CKSUM_MAP; i++) {
-    if (cksum_map[i].e == e) {
-      *c = cksum_map[i].c;
-      return ZERR_NONE;
-    }
-  }
-  return KRB5_PROG_ETYPE_NOSUPP;
-}
-#endif /* HAVE_KRB5 */
-
+#ifdef HAVE_KRB4
+C_Block __Zephyr_session;
+#endif
 char __Zephyr_realm[REALM_SZ];
 
 #ifdef Z_DEBUG
-void (*__Z_debug_print)(const char *fmt, va_list args, void *closure);
+void (*__Z_debug_print) __P((const char *fmt, va_list args, void *closure));
 void *__Z_debug_print_closure;
 #endif
 
 #define min(a,b) ((a)<(b)?(a):(b))
 
-static int Z_AddField(char **ptr, char *field, char *end);
-static int find_or_insert_uid(ZUnique_Id_t *uid, ZNotice_Kind_t kind);
-static Code_t Z_ZcodeFormatRawHeader(ZNotice_t *, char *, int, int *, char **, 
-                                    int *, char **, char **, int cksumtype);
+static int Z_AddField __P((char **ptr, char *field, char *end));
+static int find_or_insert_uid __P((ZUnique_Id_t *uid, ZNotice_Kind_t kind));
 
 /* Find or insert uid in the old uids buffer.  The buffer is a sorted
  * circular queue.  We make the assumption that most packets arrive in
  * order, so we can usually search for a uid or insert it into the buffer
  * by looking back just a few entries from the end.  Since this code is
  * only executed by the client, the implementation isn't microoptimized. */
-static int
-find_or_insert_uid(ZUnique_Id_t *uid,
-                  ZNotice_Kind_t kind)
+static int find_or_insert_uid(uid, kind)
+    ZUnique_Id_t *uid;
+    ZNotice_Kind_t kind;
 {
     static struct _filter {
        ZUnique_Id_t    uid;
@@ -187,8 +134,7 @@ find_or_insert_uid(ZUnique_Id_t *uid,
 
 /* Return 1 if there is a packet waiting, 0 otherwise */
 
-int
-Z_PacketWaiting(void)
+int Z_PacketWaiting()
 {
     struct timeval tv;
     fd_set read;
@@ -202,8 +148,7 @@ Z_PacketWaiting(void)
 
 /* Wait for a complete notice to become available */
 
-Code_t
-Z_WaitForComplete(void)
+Code_t Z_WaitForComplete()
 {
     Code_t retval;
 
@@ -220,8 +165,7 @@ Z_WaitForComplete(void)
 
 /* Read any available packets and enqueue them */
 
-Code_t
-Z_ReadEnqueue(void)
+Code_t Z_ReadEnqueue()
 {
     Code_t retval;
 
@@ -241,9 +185,9 @@ Z_ReadEnqueue(void)
  * notices that haven't been touched in a while
  */
 
-struct _Z_InputQ *
-Z_SearchQueue(ZUnique_Id_t *uid,
-             ZNotice_Kind_t kind)
+struct _Z_InputQ *Z_SearchQueue(uid, kind)
+    ZUnique_Id_t *uid;
+    ZNotice_Kind_t kind;
 {
     register struct _Z_InputQ *qptr;
     struct _Z_InputQ *next;
@@ -273,15 +217,13 @@ Z_SearchQueue(ZUnique_Id_t *uid,
  * returns.
  */
 
-Code_t
-Z_ReadWait(void)
+Code_t Z_ReadWait()
 {
     register struct _Z_InputQ *qptr;
     ZNotice_t notice;
     ZPacket_t packet;
     struct sockaddr_in olddest, from;
-    unsigned int from_len;
-    int packet_len, zvlen, part, partof;
+    int from_len, packet_len, zvlen, part, partof;
     char *slash;
     Code_t retval;
     fd_set fds;
@@ -520,10 +462,10 @@ Z_ReadWait(void)
 
 /* Fragment management routines - compliments, more or less, of RFC815 */
 
-Code_t
-Z_AddNoticeToEntry(struct _Z_InputQ *qptr,
-                  ZNotice_t *notice,
-                  int part)
+Code_t Z_AddNoticeToEntry(qptr, notice, part)
+    struct _Z_InputQ *qptr;
+    ZNotice_t *notice;
+    int part;
 {
     int last, oldfirst, oldlast;
     struct _Z_Hole *hole, *lasthole;
@@ -638,9 +580,7 @@ Z_AddNoticeToEntry(struct _Z_InputQ *qptr,
     return (ZERR_NONE);
 }
 
-void
-Z_gettimeofday(struct _ZTimeval *ztv,
-              struct timezone *tz)
+void Z_gettimeofday(struct _ZTimeval *ztv, struct timezone *tz)
 {
         struct timeval tv;
         (void) gettimeofday(&tv, tz); /* yeah, yeah, I know */
@@ -648,17 +588,17 @@ Z_gettimeofday(struct _ZTimeval *ztv,
         ztv->tv_usec=tv.tv_usec;
 }
 
-Code_t
-Z_FormatHeader(ZNotice_t *notice,
-              char *buffer,
-              int buffer_len,
-              int *len,
-              Z_AuthProc cert_routine)
+Code_t Z_FormatHeader(notice, buffer, buffer_len, len, cert_routine)
+    ZNotice_t *notice;
+    char *buffer;
+    int buffer_len;
+    int *len;
+    Z_AuthProc cert_routine;
 {
     Code_t retval;
     static char version[BUFSIZ]; /* default init should be all \0 */
     struct sockaddr_in name;
-    unsigned int namelen = sizeof(name);
+    int namelen = sizeof(name);
 
     if (!notice->z_sender)
        notice->z_sender = ZGetSender();
@@ -693,77 +633,12 @@ Z_FormatHeader(ZNotice_t *notice,
     return Z_FormatAuthHeader(notice, buffer, buffer_len, len, cert_routine);
 }
 
-Code_t
-Z_NewFormatHeader(ZNotice_t *notice,
-                 char *buffer,
-                 int buffer_len,
-                 int *len,
-                 Z_AuthProc cert_routine)
-{
-    Code_t retval;
-    static char version[BUFSIZ]; /* default init should be all \0 */
-    struct sockaddr_in name;
-    struct timeval tv;
-    unsigned int namelen = sizeof(name);
-
-    if (!notice->z_sender)
-       notice->z_sender = ZGetSender();
-
-    if (notice->z_port == 0) {
-       if (ZGetFD() < 0) {
-           retval = ZOpenPort((u_short *)0);
-           if (retval != ZERR_NONE)
-               return (retval);
-       }
-       retval = getsockname(ZGetFD(), (struct sockaddr *) &name, &namelen);
-       if (retval != 0)
-           return (retval);
-       notice->z_port = name.sin_port;
-    }
-
-    notice->z_multinotice = "";
-    
-    (void) gettimeofday(&tv, (struct timezone *)0);
-    notice->z_uid.tv.tv_sec = htonl((u_long) tv.tv_sec);
-    notice->z_uid.tv.tv_usec = htonl((u_long) tv.tv_usec);
-    
-    (void) memcpy(&notice->z_uid.zuid_addr, &__My_addr, sizeof(__My_addr));
-
-    notice->z_multiuid = notice->z_uid;
-
-    if (!version[0])
-           (void) sprintf(version, "%s%d.%d", ZVERSIONHDR, ZVERSIONMAJOR,
-                          ZVERSIONMINOR);
-    notice->z_version = version;
-
-    return Z_NewFormatAuthHeader(notice, buffer, buffer_len, len, cert_routine);
-}
-
-Code_t
-Z_FormatAuthHeader(ZNotice_t *notice,
-                  char *buffer,
-                  int buffer_len,
-                  int *len,
-                  Z_AuthProc cert_routine)
-{
-    if (!cert_routine) {
-       notice->z_auth = 0;
-       notice->z_authent_len = 0;
-       notice->z_ascii_authent = "";
-       notice->z_checksum = 0;
-       return (Z_FormatRawHeader(notice, buffer, buffer_len,
-                                 len, NULL, NULL));
-    }
-    
-    return ((*cert_routine)(notice, buffer, buffer_len, len));
-}
-
-Code_t
-Z_NewFormatAuthHeader(ZNotice_t *notice,
-                     char *buffer,
-                     int buffer_len,
-                     int *len,
-                     Z_AuthProc cert_routine)
+Code_t Z_FormatAuthHeader(notice, buffer, buffer_len, len, cert_routine)
+    ZNotice_t *notice;
+    char *buffer;
+    int buffer_len;
+    int *len;
+    Z_AuthProc cert_routine;
 {
     if (!cert_routine) {
        notice->z_auth = 0;
@@ -777,177 +652,12 @@ Z_NewFormatAuthHeader(ZNotice_t *notice,
     return ((*cert_routine)(notice, buffer, buffer_len, len));
 } 
        
-Code_t
-Z_NewFormatRawHeader(ZNotice_t *notice,
-                    char *buffer,
-                    int buffer_len,
-                    int *hdr_len,
-                    char **cksum_start,
-                    int *cksum_len,
-                    char **cstart,
-                    char **cend)
-{
-   return(Z_ZcodeFormatRawHeader(notice, buffer, buffer_len, hdr_len,
-                                cksum_start, cksum_len, cstart, cend, 0));
-}
-
-Code_t
-Z_AsciiFormatRawHeader(ZNotice_t *notice,
-                      char *buffer,
-                      int buffer_len,
-                      int *hdr_len,
-                      char **cksum_start,
-                      int *cksum_len,
-                      char **cstart,
-                      char **cend)
-{
-   return(Z_ZcodeFormatRawHeader(notice, buffer, buffer_len, hdr_len,
-                                cksum_start, cksum_len, cstart, cend, 1));
-}
-
-static Code_t
-Z_ZcodeFormatRawHeader(ZNotice_t *notice,
-                      char *buffer,
-                      int buffer_len,
-                      int *hdr_len,
-                      char **cksum_start,
-                      int *cksum_len,
-                      char **cstart,
-                      char **cend,
-                      int cksumstyle)
-{
-    static char version_nogalaxy[BUFSIZ]; /* default init should be all \0 */
-    char newrecip[BUFSIZ];
-    char *ptr, *end;
-    int i;
-
-    if (!notice->z_class)
-            notice->z_class = "";
-
-    if (!notice->z_class_inst)
-            notice->z_class_inst = "";
-
-    if (!notice->z_opcode)
-            notice->z_opcode = "";
-
-    if (!notice->z_recipient)
-            notice->z_recipient = "";
-
-    if (!notice->z_default_format)
-            notice->z_default_format = "";
-
-    ptr = buffer;
-    end = buffer+buffer_len;
-
-    if (cksum_start)
-        *cksum_start = ptr;
-
-    (void) sprintf(version_nogalaxy, "%s%d.%d", ZVERSIONHDR,
-                  ZVERSIONMAJOR, ZVERSIONMINOR);
-
-    notice->z_version = version_nogalaxy;
-
-    if (Z_AddField(&ptr, version_nogalaxy, end))
-        return (ZERR_HEADERLEN);
-
-    if (ZMakeAscii32(ptr, end-ptr,
-                     Z_NUMFIELDS + notice->z_num_other_fields)
-        == ZERR_FIELDLEN)
-        return (ZERR_HEADERLEN);
-    ptr += strlen(ptr)+1;
-
-    if (ZMakeAscii32(ptr, end-ptr, notice->z_kind) == ZERR_FIELDLEN)
-        return (ZERR_HEADERLEN);
-    ptr += strlen(ptr)+1;
-
-    if (ZMakeAscii(ptr, end-ptr, (unsigned char *)&notice->z_uid, 
-                   sizeof(ZUnique_Id_t)) == ZERR_FIELDLEN)
-        return (ZERR_HEADERLEN);
-    ptr += strlen(ptr)+1;
-
-    if (ZMakeAscii16(ptr, end-ptr, ntohs(notice->z_port)) == ZERR_FIELDLEN)
-        return (ZERR_HEADERLEN);
-    ptr += strlen(ptr)+1;
-
-    if (ZMakeAscii32(ptr, end-ptr, notice->z_auth) == ZERR_FIELDLEN)
-        return (ZERR_HEADERLEN);
-    ptr += strlen(ptr)+1;
-
-    if (ZMakeAscii32(ptr, end-ptr, notice->z_authent_len) == ZERR_FIELDLEN)
-        return (ZERR_HEADERLEN);
-    ptr += strlen(ptr)+1;
-
-    if (Z_AddField(&ptr, notice->z_ascii_authent, end))
-        return (ZERR_HEADERLEN);
-    if (Z_AddField(&ptr, notice->z_class, end))
-        return (ZERR_HEADERLEN);
-    if (Z_AddField(&ptr, notice->z_class_inst, end))
-        return (ZERR_HEADERLEN);
-    if (Z_AddField(&ptr, notice->z_opcode, end))
-        return (ZERR_HEADERLEN);
-    if (Z_AddField(&ptr, notice->z_sender, end))
-        return (ZERR_HEADERLEN);
-    if (strchr(notice->z_recipient, '@') || !*notice->z_recipient) {
-        if (Z_AddField(&ptr, notice->z_recipient, end))
-            return (ZERR_HEADERLEN);
-    }
-    else {
-       if (strlen(notice->z_recipient) + strlen(__Zephyr_realm) + 2 >
-            sizeof(newrecip))
-            return (ZERR_HEADERLEN);
-        (void) sprintf(newrecip, "%s@%s", notice->z_recipient, __Zephyr_realm);
-        if (Z_AddField(&ptr, newrecip, end))
-            return (ZERR_HEADERLEN);
-    }           
-    if (Z_AddField(&ptr, notice->z_default_format, end))
-        return (ZERR_HEADERLEN);
-
-    /* copy back the end pointer location for crypto checksum */
-    if (cstart)
-        *cstart = ptr;
-    if (cksumstyle == 1) {
-      if (Z_AddField(&ptr, notice->z_ascii_checksum, end))
-        return (ZERR_HEADERLEN);
-    } else {
-#ifdef xZCODE_K4SUM
-    if (ZMakeZcode32(ptr, end-ptr, notice->z_checksum) == ZERR_FIELDLEN)
-        return ZERR_HEADERLEN;
-#else
-    if (ZMakeAscii32(ptr, end-ptr, notice->z_checksum) == ZERR_FIELDLEN)
-        return (ZERR_HEADERLEN);
-#endif
-    ptr += strlen(ptr)+1;
-    }
-    if (cend)
-        *cend = ptr;
-
-    if (Z_AddField(&ptr, notice->z_multinotice, end))
-        return (ZERR_HEADERLEN);
-
-    if (ZMakeAscii(ptr, end-ptr, (unsigned char *)&notice->z_multiuid, 
-                   sizeof(ZUnique_Id_t)) == ZERR_FIELDLEN)
-        return (ZERR_HEADERLEN);
-    ptr += strlen(ptr)+1;
-        
-    for (i=0;i<notice->z_num_other_fields;i++)
-        if (Z_AddField(&ptr, notice->z_other_fields[i], end))
-            return (ZERR_HEADERLEN);
-    
-    if (cksum_len)
-        *cksum_len = ptr-*cksum_start;
-
-    *hdr_len = ptr-buffer;
-
-    return (ZERR_NONE);
-}
-
-Code_t
-Z_FormatRawHeader(ZNotice_t *notice,
-                 char *buffer,
-                 int buffer_len,
-                 int *len,
-                 char **cstart,
-                 char **cend)
+Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, cstart, cend)
+    ZNotice_t *notice;
+    char *buffer;
+    int buffer_len;
+    int *len;
+    char **cstart, **cend;
 {
     char newrecip[BUFSIZ];
     char *ptr, *end;
@@ -1032,7 +742,7 @@ Z_FormatRawHeader(ZNotice_t *notice,
     if (cstart)
        *cstart = ptr;
     if (ZMakeAscii32(ptr, end-ptr, notice->z_checksum) == ZERR_FIELDLEN)
-        return (ZERR_HEADERLEN);
+       return (ZERR_HEADERLEN);
     ptr += strlen(ptr)+1;
     if (cend)
        *cend = ptr;
@@ -1055,9 +765,8 @@ Z_FormatRawHeader(ZNotice_t *notice,
 }
 
 static int
-Z_AddField(char **ptr,
-          char *field,
-          char *end)
+Z_AddField(ptr, field, end)
+    char **ptr, *field, *end;
 {
     register int len;
 
@@ -1074,8 +783,7 @@ Z_AddField(char **ptr,
     return 0;
 }
 
-struct _Z_InputQ *
-Z_GetFirstComplete(void)
+struct _Z_InputQ *Z_GetFirstComplete()
 {
     struct _Z_InputQ *qptr;
 
@@ -1090,8 +798,8 @@ Z_GetFirstComplete(void)
     return ((struct _Z_InputQ *)0);
 }
 
-struct _Z_InputQ *
-Z_GetNextComplete(struct _Z_InputQ *qptr)
+struct _Z_InputQ *Z_GetNextComplete(qptr)
+    struct _Z_InputQ *qptr;
 {
     qptr = qptr->next;
     while (qptr) {
@@ -1103,8 +811,8 @@ Z_GetNextComplete(struct _Z_InputQ *qptr)
     return ((struct _Z_InputQ *)0);
 }
 
-void
-Z_RemQueue(struct _Z_InputQ *qptr)
+void Z_RemQueue(qptr)
+    struct _Z_InputQ *qptr;
 {
     struct _Z_Hole *hole, *nexthole;
     
@@ -1152,11 +860,11 @@ Z_RemQueue(struct _Z_InputQ *qptr)
     return;
 }
 
-Code_t
-Z_SendFragmentedNotice(ZNotice_t *notice,
-                      int len,
-                      Z_AuthProc cert_func,
-                      Z_SendProc send_func)
+Code_t Z_SendFragmentedNotice(notice, len, cert_func, send_func)
+    ZNotice_t *notice;
+    int len;
+    Z_AuthProc cert_func;
+    Z_SendProc send_func;
 {
     ZNotice_t partnotice;
     ZPacket_t buffer;
@@ -1208,12 +916,13 @@ Z_SendFragmentedNotice(ZNotice_t *notice,
 }
 
 /*ARGSUSED*/
-Code_t Z_XmitFragment(ZNotice_t *notice,
-                     char *buf,
-                     int len,
-                     int wait)
+Code_t Z_XmitFragment(notice, buf, len, wait)
+ZNotice_t *notice;
+char *buf;
+int len;
+int wait;
 {
-    return(ZSendPacket(buf, len, wait));
+       return(ZSendPacket(buf, len, wait));
 }
 
 #ifdef Z_DEBUG
@@ -1227,8 +936,8 @@ const char *const ZNoticeKinds[] = {
 #ifdef Z_DEBUG
 
 #undef Z_debug
-void
-Z_debug(const char *format, ...)
+#ifdef HAVE_STDARG_H
+void Z_debug (const char *format, ...)
 {
     va_list pvar;
     if (!__Z_debug_print)
@@ -1237,11 +946,24 @@ Z_debug(const char *format, ...)
     (*__Z_debug_print) (format, pvar, __Z_debug_print_closure);
     va_end (pvar);
 }
+#else /* stdarg */
+void Z_debug (va_alist) va_dcl
+{
+    va_list pvar;
+    char *format;
+    if (!__Z_debug_print)
+      return;
+    va_start (pvar);
+    format = va_arg (pvar, char *);
+    (*__Z_debug_print) (format, pvar, __Z_debug_print_closure);
+    va_end (pvar);
+}
+#endif
 
-void
-Z_debug_stderr(const char *format,
-              va_list args,
-              void *closure)
+void Z_debug_stderr (format, args, closure)
+     const char *format;
+     va_list args;
+     void *closure;
 {
 #ifdef HAVE_VPRINTF
     vfprintf (stderr, format, args);
@@ -1252,221 +974,24 @@ Z_debug_stderr(const char *format,
 }
 
 #undef ZGetFD
-int ZGetFD (void) { return __Zephyr_fd; }
+int ZGetFD () { return __Zephyr_fd; }
 
 #undef ZQLength
-int ZQLength (void) { return __Q_CompleteLength; }
+int ZQLength () { return __Q_CompleteLength; }
 
 #undef ZGetDestAddr
-struct sockaddr_in ZGetDestAddr (void) { return __HM_addr; }
+struct sockaddr_in ZGetDestAddr () { return __HM_addr; }
 
 #undef ZGetRealm
-Zconst char * ZGetRealm (void) { return __Zephyr_realm; }
+Zconst char * ZGetRealm () { return __Zephyr_realm; }
 
 #undef ZSetDebug
-void
-ZSetDebug(void (*proc) __P((const char *, va_list, void *)),
-         char *arg)
+void ZSetDebug(proc, arg)
+    void (*proc) __P((const char *, va_list, void *));
+    char *arg;
 {
     __Z_debug_print = proc;
     __Z_debug_print_closure = arg;
 }
 #endif /* Z_DEBUG */
 
-#ifdef HAVE_KRB5
-Code_t
-Z_Checksum(krb5_data *cksumbuf,
-          krb5_keyblock *keyblock, 
-          krb5_cksumtype cksumtype, 
-          char **asn1_data,
-          unsigned int *asn1_len)
-{
-    krb5_error_code result;
-    unsigned char *data;
-    int len;
-#if HAVE_KRB5_C_MAKE_CHECKSUM
-    krb5_checksum checksum;
-#else
-    Checksum checksum;
-    krb5_crypto cryptctx;
-#endif
-    
-#if HAVE_KRB5_C_MAKE_CHECKSUM
-    /* Create the checksum -- MIT crypto API */
-    result = krb5_c_make_checksum(Z_krb5_ctx, cksumtype,
-                                 keyblock, Z_KEYUSAGE_CLT_CKSUM,
-                                 cksumbuf, &checksum);
-    if (result)
-       return result;
-    /* HOLDING: checksum */
-
-    data = checksum.contents;
-    len = checksum.length;
-#else
-    /* Create the checksum -- heimdal crypto API */
-    result = krb5_crypto_init(Z_krb5_ctx, keyblock, keyblock->keytype, 
-                              &cryptctx);
-    if (result)
-       return result;
-
-    /* HOLDING: cryptctx */
-    result = krb5_create_checksum(Z_krb5_ctx, cryptctx,
-                                 Z_KEYUSAGE_CLT_CKSUM, cksumtype,
-                                 cksumbuf->data, cksumbuf->length,
-                                 &checksum);
-    krb5_crypto_destroy(Z_krb5_ctx, cryptctx);
-    if (result)
-       return result;
-
-    len = checksum.checksum.length;
-    data = checksum.checksum.data;
-    /* HOLDING: checksum */
-#endif
-
-    *asn1_data = malloc(len);
-    if (*asn1_data == NULL)
-       return errno;
-    memcpy(*asn1_data, data, len);
-    *asn1_len = len;
-
-#if HAVE_KRB5_C_MAKE_CHECKSUM
-    krb5_free_checksum_contents(Z_krb5_ctx, &checksum);
-#else
-    free_Checksum(&checksum);
-#endif
-
-    return 0;
-}
-
-Code_t
-Z_InsertZcodeChecksum(krb5_keyblock *keyblock,
-                     ZNotice_t *notice, 
-                      char *buffer,
-                     char *cksum_start,
-                     int cksum_len, 
-                      char *cstart,
-                     char *cend,
-                     int buffer_len, 
-                      int *length_adjust)
-{
-     int plain_len;   /* length of part not to be checksummed */
-     int cksum0_len;  /* length of part before checksum */
-     int cksum1_len;  /* length of part after checksum */
-     krb5_data cksumbuf;
-     krb5_data cksum;
-     unsigned char *key_data;
-     int key_len;
-     krb5_enctype enctype;
-     krb5_cksumtype cksumtype;
-     Code_t result;
-     
-     key_data = Z_keydata(keyblock);
-     key_len = Z_keylen(keyblock);
-     result = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
-     if (result)
-          return (ZAUTH_FAILED);
-     
-     /* Assemble the things to be checksummed */
-     plain_len  = cksum_start - buffer;
-     cksum0_len = cstart - cksum_start;
-     cksum1_len = (cksum_start + cksum_len) - cend;
-     memset(&cksumbuf, 0, sizeof(cksumbuf));
-     cksumbuf.length = cksum0_len + cksum1_len + notice->z_message_len;
-     cksumbuf.data = malloc(cksumbuf.length);
-     if (!cksumbuf.data)
-          return ENOMEM;
-     memcpy(cksumbuf.data, cksum_start, cksum0_len);
-     memcpy(cksumbuf.data + cksum0_len, cend, cksum1_len);
-     memcpy(cksumbuf.data + cksum0_len + cksum1_len,
-            notice->z_message, notice->z_message_len);
-     /* compute the checksum */
-     result = Z_Checksum(&cksumbuf, keyblock, cksumtype, 
-                        (char **)&cksum.data, &cksum.length);
-     if (result) {
-          free(cksumbuf.data);
-          return result;
-     }
-     
-     /*
-      * OK....  we can zcode to a space starting at 'cstart',
-      * with a length of buffer_len - (plain_len + cksum_len).
-      * Then we tack on the end part, which is located at
-      * cksumbuf.data + cksum0_len and has length cksum1_len
-      */
-     
-     result = ZMakeZcode(cstart, buffer_len - (plain_len + cksum_len),
-                         (unsigned char *)cksum.data, cksum.length);
-     free(cksum.data);
-     if (!result) {
-          int zcode_len = strlen(cstart) + 1;
-          memcpy(cstart + zcode_len, cksumbuf.data + cksum0_len, cksum1_len);
-          *length_adjust = zcode_len - cksum_len + (cksum0_len + cksum1_len);
-     }
-     free(cksumbuf.data);
-     return result;
-}
-
-Code_t
-Z_ExtractEncCksum(krb5_keyblock *keyblock,
-                 krb5_enctype *enctype, 
-                  krb5_cksumtype *cksumtype)
-{
-    *enctype  = Z_enctype(keyblock); 
-    return Z_krb5_lookup_cksumtype(*enctype, cksumtype); 
-}
-#endif
-
-#ifdef HAVE_KRB5
-/* returns 0 if invalid or losing, 1 if valid, *sigh* */
-int
-Z_krb5_verify_cksum(krb5_keyblock *keyblock,
-                   krb5_data *cksumbuf, 
-                    krb5_cksumtype cksumtype,
-                   unsigned char *asn1_data, 
-                    int asn1_len)
-{
-    krb5_error_code result;
-#if HAVE_KRB5_C_MAKE_CHECKSUM
-    krb5_checksum checksum;
-    krb5_boolean valid;
-#else
-    krb5_crypto cryptctx;
-    Checksum checksum;
-    size_t xlen;
-#endif
-
-    memset(&checksum, 0, sizeof(checksum));
-#if HAVE_KRB5_C_MAKE_CHECKSUM
-    /* Verify the checksum -- MIT crypto API */
-    checksum.length = asn1_len;
-    checksum.contents = asn1_data;
-    checksum.checksum_type = cksumtype;
-    result = krb5_c_verify_checksum(Z_krb5_ctx,
-                                   keyblock, Z_KEYUSAGE_SRV_CKSUM,
-                                   cksumbuf, &checksum, &valid);
-    if (!result && valid)
-       return 1;
-    else
-       return 0;
-#else
-    checksum.checksum.length = asn1_len;
-    checksum.checksum.data = asn1_data;
-    checksum.cksumtype = cksumtype;
-
-    result = krb5_crypto_init(Z_krb5_ctx, keyblock, keyblock->keytype, &cryptctx);
-    if (result)
-       return result;
-    
-    /* HOLDING: cryptctx */
-    result = krb5_verify_checksum(Z_krb5_ctx, cryptctx,
-                                 Z_KEYUSAGE_SRV_CKSUM,
-                                 cksumbuf->data, cksumbuf->length,
-                                 &checksum);
-    krb5_crypto_destroy(Z_krb5_ctx, cryptctx);
-    if (result)
-       return 0;
-    else
-       return 1;
-#endif
-}
-#endif
index 541aa0cd542d01358a96e8e309f828cbaa302690..fc19172b2140f20adc5806c6d4eb55d910e0bf3f 100644 (file)
 
 #include "dynP.h"
 
-int
-DynAppend(DynObject obj,
-         DynPtr els,
-         int num)
+int DynAppend(obj, els, num)
+   DynObject obj;
+   DynPtr els;
+   int num;
 {
      if (obj->debug)
          fprintf(stderr, "dyn: append: Writing %d bytes from %p to %p + %d\n",
index e5bce995c98839f2b955d48cfd189b80f49d9e7e..88623964a0a3944e916434f1d17abe3f84e90427 100644 (file)
@@ -21,9 +21,8 @@
 
 static int default_increment = DEFAULT_INC;
 
-DynObject
-DynCreate(int el_size,
-         int inc)
+DynObject DynCreate(el_size, inc)
+   int el_size, inc;
 {
      DynObject obj;
 
@@ -40,8 +39,8 @@ DynCreate(int el_size,
      return obj;
 }
 
-int
-DynDestroy(DynObject obj)
+int DynDestroy(obj)
+   DynObject obj;
 {
      free(obj->array);
      free(obj);
index 95440bef5331c107f40348acc372958953ad4503..53178d296af83fadbb925e72e2cdde9822d6c13f 100644 (file)
@@ -14,9 +14,9 @@
 
 #include "dynP.h"
 
-int
-DynDebug(DynObject obj,
-        int state)
+int DynDebug(obj, state)
+   DynObject obj;
+   int state;
 {
      obj->debug = state;
 
index 256f49e0f8c20c21f9093e733e84d836b7d6b9bf..1dd39c1a511db7f98a222b0930dc754c8bdc7817 100644 (file)
@@ -18,9 +18,9 @@
  * Checkers!  Get away from that "hard disk erase" button!
  *    (Stupid dog.  He almost did it to me again ...)
  */                                 
-int
-DynDelete(DynObject obj,
-         int idx)
+int DynDelete(obj, idx)
+   DynObject obj;
+   int idx;
 {
      if (idx < 0) {
          if (obj->debug)
index 4445e0252534938a608e5ee9d07b4d91e20116db..7e205953ae62d472b9f3eaf6147016e50daf5c4b 100644 (file)
 
 #include "dynP.h"
 
-int
-DynInsert(DynObject obj,
-         int idx,
-         DynPtr els,
-         int num)
-     
+int DynInsert(obj, idx, els, num)
+   DynObject obj;
+   DynPtr els;
+   int idx, num;
 {
      int ret;
      
index 1c7b81c20cab358e83dc62dee74d172735a6eeb9..d2de3c48f5f1a7123ccdfd74cd0eb2297fb25c66 100644 (file)
@@ -14,8 +14,9 @@
 
 #include "dynP.h"
 
-int
-DynParanoid(DynObject obj, int state)
+int DynParanoid(obj, state)
+   DynObject obj;
+   int state;
 {
      obj->paranoid = state;
 
index addeadd0db6fd304bf1715eb84f385c5df2c13f7..8427d5b7e86ba6ff6dabd551c9e4b453cfee7dea 100644 (file)
@@ -14,9 +14,9 @@
 
 static int DynPut __P((DynObject obj, DynPtr el, int index));
 
-DynPtr
-DynGet(DynObject obj,
-       int num)
+DynPtr DynGet(obj, num)
+   DynObject obj;
+   int num;
 {
      if (num < 0) {
          if (obj->debug)
@@ -38,9 +38,9 @@ DynGet(DynObject obj,
      return (DynPtr) obj->array + obj->el_size*num;
 }
 
-int
-DynAdd(DynObject obj,
-       DynPtr el)
+int DynAdd(obj, el)
+   DynObject obj;
+   DynPtr el;
 {
      int       ret;
 
@@ -60,10 +60,10 @@ DynAdd(DynObject obj,
  * obj->num_el) will not be updated properly and many other functions
  * in the library will lose.  Have a nice day.
  */
-static int
-DynPut(DynObject obj,
-       DynPtr el,
-       int index)
+static int DynPut(obj, el, index)
+   DynObject obj;
+   DynPtr el;
+   int index;
 {
      int ret;
      
index 25cf20d564f4fa1a66ea5a24becdb807187c94ef..4dedd72d52b10aafcd9873c745bccea72f683002 100644 (file)
@@ -18,9 +18,9 @@
  * Ideally, this function should not be called from outside the
  * library.  However, nothing will break if it is.
  */
-int
-_DynRealloc(DynObject obj,
-           int num_incs)
+int _DynRealloc(obj, num_incs)
+   DynObject obj;
+   int num_incs;
 {
      DynPtr temp;
      int new_size_in_bytes;
index ea1cc3879efc79fb3c9dcc443d9c77736674f6fe..4d1445dcd26f13780e364f6e174b511709a2fc4c 100644 (file)
@@ -14,8 +14,8 @@
 
 #include "dynP.h"
 
-int
-DynSize(DynObject obj)
+int DynSize(obj)
+   DynObject obj;
 {
      if (obj->debug)
          fprintf(stderr, "dyn: size: returning size %d.\n", obj->num_el);
index 009a3d9545a8ece890b7b59c9f1cd1db760503c6..9f9172076377348cbf7c3a54edb5d74092b535c0 100644 (file)
@@ -21,9 +21,9 @@ static char insert1[] = "This will be put at the beginning.";
 static char insert2[] = "(parenthetical remark!) ";
 static char insert3[] = "  This follows the random string.";
 
-int
-main(int argc,
-     char **argv)
+int main(argc, argv)
+   int argc;
+   char        **argv;
 {
      DynObject obj;
      int       i, s;
index cbe6416f4bc15681b35babe1e9f959d559238b75..8fcfe441976f42fa0270c5c74cc78be70f2679d6 100644 (file)
@@ -58,9 +58,10 @@ static void access_setup __P((int first));
  */
 
 int
-access_check(char *sender,
-            Acl *acl,
-            Access accesstype)
+access_check(sender, acl, accesstype)
+    char *sender;
+    Acl *acl;
+    Access accesstype;
 {
     char buf[MAXPATHLEN];      /* holds the real acl name */
     char *prefix;
@@ -95,6 +96,10 @@ access_check(char *sender,
      * If we can't load it (because it probably doesn't exist),
      * we deny access.
      */
+#if 0
+    zdbug ((LOG_DEBUG, "checking %s for %s", buf, sender));
+#endif
+       
     retval = acl_load(buf);
     if (retval < 0) {
        syslog(LOG_DEBUG, "Error in acl_load of %s for %s", buf, sender);
@@ -104,7 +109,8 @@ access_check(char *sender,
 }
 
 static void
-check_acl(Acl *acl)
+check_acl(acl)
+    Acl *acl;
 {
     acl->acl_types = 0;
     check_acl_type(acl, TRANSMIT, ACL_XMT);
@@ -114,9 +120,10 @@ check_acl(Acl *acl)
 }
 
 static void
-check_acl_type(Acl *acl,
-              Access accesstype,
-              int typeflag)
+check_acl_type(acl, accesstype, typeflag)
+    Acl *acl;
+    Access accesstype;
+    int typeflag;
 {
     char       buf[MAXPATHLEN]; /* holds the real acl name */
     char       *prefix;
@@ -154,7 +161,8 @@ check_acl_type(Acl *acl,
  * acl files for the (non-)restricted class.
  */
 static void
-access_setup(int first)
+access_setup(first)
+    int first;
 {
     char buf[MAXPATHLEN];
     char class_name[512];      /* assume class names <= 511 bytes */
@@ -213,13 +221,13 @@ access_setup(int first)
 }
 
 void
-access_init(void)
+access_init()
 {
     access_setup(1);
 }
 
 void
-access_reinit(void)
+access_reinit()
 {
     acl_cache_reset();
     access_setup(0);
index df0885b642dcef32da179478f2d7c1420b7eb66b..4c44402fb51a8c012d111da0361059cb54c8d89b 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 /* Define this if you really want the ACL-writing code included.  */
+/* #define WRITE_ACL */
 
 /*
  * Stolen from lib/acl_files.c because acl_load needs to be externally
@@ -47,13 +48,18 @@ static const char rcsid_acl_files_c[] = "$Id$";
 
 #define COR(a,b) ((a!=NULL)?(a):(b))
 
+extern int errno;
+
+extern time_t time();
+
 /* Canonicalize a principal name */
 /* If instance is missing, it becomes "" */
 /* If realm is missing, it becomes the local realm */
 /* Canonicalized form is put in canon, which must be big enough to hold
    MAX_PRINCIPAL_SIZE characters */
-void acl_canonicalize_principal(char *principal,
-                               char *canon)
+void acl_canonicalize_principal(principal, canon)
+    char *principal;
+    char *canon;
 {
     char *end;
     char *dot, *atsign;
@@ -114,10 +120,143 @@ void acl_canonicalize_principal(char *principal,
 #endif
 }
 
+#ifdef notdef
+/* Get a lock to modify acl_file */
+/* Return new FILE pointer */
+/* or NULL if file cannot be modified */
+/* REQUIRES WRITE PERMISSION TO CONTAINING DIRECTORY */
+static FILE *acl_lock_file(acl_file)
+    char *acl_file;
+{
+    struct stat s;
+    char new[LINESIZE];
+    int nfd;
+    FILE *nf;
+    int mode;
+
+    if (stat(acl_file, &s) < 0) return(NULL);
+    mode = s.st_mode;
+    sprintf(new, NEW_FILE, acl_file);
+    for (;;) {
+       /* Open the new file */
+       if ((nfd = open(new, O_WRONLY|O_CREAT|O_EXCL, mode)) < 0) {
+           if (errno == EEXIST) {
+               /* Maybe somebody got here already, maybe it's just old */
+               if (stat(new, &s) < 0) return(NULL);
+               if (time(0) - s.st_ctime > WAIT_TIME) {
+                   /* File is stale, kill it */
+                   unlink(new);
+                   continue;
+               } else {
+                   /* Wait and try again */
+                   sleep(1);
+                   continue;
+               }
+           } else {
+               /* Some other error, we lose */
+               return(NULL);
+           }
+       }
+
+       /* If we got to here, the lock file is ours and ok */
+       /* Reopen it under stdio */
+       if ((nf = fdopen(nfd, "w")) == NULL) {
+           /* Oops, clean up */
+           unlink(new);
+       }
+       return(nf);
+    }
+}
+
+/* Commit changes to acl_file written onto FILE *f */
+/* Returns zero if successful */
+/* Returns > 0 if lock was broken */
+/* Returns < 0 if some other error occurs */
+/* Closes f */
+static int acl_commit(acl_file, f)
+    char *acl_file;
+    FILE *f;     
+{
+#ifdef WRITE_ACL
+    char new[LINESIZE];
+    int ret;
+    struct stat s;
+
+    sprintf(new, NEW_FILE, acl_file);
+    if (fflush(f) < 0
+       || fstat(fileno(f), &s) < 0
+       || s.st_nlink == 0) {
+       acl_abort(acl_file, f);
+       return(-1);
+    }
+
+    ret = rename(new, acl_file);
+    fclose(f);
+    return(ret);
+#else
+    abort ();
+#endif
+}
+
+/* Abort changes to acl_file written onto FILE *f */
+/* Returns 0 if successful, < 0 otherwise */
+/* Closes f */
+static int acl_abort(acl_file, f)
+    char *acl_file;
+    FILE *f;     
+{
+#ifdef WRITE_ACL
+    char new[LINESIZE];
+    int ret;
+    struct stat s;
+
+    /* make sure we aren't nuking someone else's file */
+    if (fstat(fileno(f), &s) < 0 || s.st_nlink == 0) {
+       fclose(f);
+       return(-1);
+    } else {
+       sprintf(new, NEW_FILE, acl_file);
+       ret = unlink(new);
+       fclose(f);
+       return(ret);
+    }
+#else
+    abort ();
+#endif
+}
+
+/* Initialize an acl_file */
+/* Creates the file with permissions perm if it does not exist */
+/* Erases it if it does */
+/* Returns return value of acl_commit */
+int
+acl_initialize(acl_file, perm)
+    char *acl_file;
+    int perm;
+{
+    FILE *new;
+    int fd;
+
+    /* Check if the file exists already */
+    if ((new = acl_lock_file(acl_file)) != NULL) {
+       return(acl_commit(acl_file, new));
+    } else {
+       /* File must be readable and writable by owner */
+       if ((fd = open(acl_file, O_CREAT|O_EXCL, perm|0600)) < 0) {
+           return(-1);
+       } else {
+           close(fd);
+           return(0);
+       }
+    }
+}
+
+#endif /* notdef */
+
 /* Eliminate all whitespace character in buf */
 /* Modifies its argument */
-static void
-nuke_whitespace(char *buf)
+static void nuke_whitespace(buf)
+    char *buf;
 {
     char *pin, *pout;
 
@@ -135,8 +274,8 @@ struct hashtbl {
 };
 
 /* Make an empty hash table of size s */
-static struct hashtbl *
-make_hash(int size)
+static struct hashtbl *make_hash(size)
+    int size;
 {
     struct hashtbl *h;
 
@@ -150,7 +289,8 @@ make_hash(int size)
 
 /* Destroy a hash table */
 static void
-destroy_hash(struct hashtbl *h)
+destroy_hash(h)
+    struct hashtbl *h;
 {
     int i;
 
@@ -163,7 +303,8 @@ destroy_hash(struct hashtbl *h)
 
 /* Compute hash value for a string */
 static unsigned int
-hashval(char *s)
+hashval(s)
+    char *s;
 {
     unsigned hv;
 
@@ -174,15 +315,18 @@ hashval(char *s)
 }
 
 /* Add an element to a hash table */
-static void
-add_hash(struct hashtbl *h,
-        char *el)
+static void add_hash(h, el)
+    struct hashtbl *h;
+    char *el;
 {
     unsigned hv;
     char *s;
     char **old;
     int i;
 
+#if 0
+    fprintf (stderr, "adding %s to acl hash %08X\n", el, h);
+#endif
     /* Make space if it isn't there already */
     if (h->entries + 1 > (h->size >> 1)) {
        old = h->tbl;
@@ -208,16 +352,29 @@ add_hash(struct hashtbl *h,
 
 /* Returns nonzero if el is in h */
 static int
-check_hash(struct hashtbl *h,
-          char *el)
+check_hash(h, el)
+    struct hashtbl *h;
+    char *el;
 {
     unsigned hv;
 
+#if 0
+    fprintf (stderr, "looking for %s in acl %08X\n", el, h);
+#endif
     for (hv = hashval(el) % h->size; h->tbl[hv]; hv = (hv + 1) % h->size) {
+#if 0
+       fprintf (stderr, "\tstrcmp (%s,...)\n", h->tbl[hv]);
+#endif
        if (!strcmp(h->tbl[hv], el)) {
+#if 0
+           fprintf (stderr, "success!\n");
+#endif
            return 1;
        }
     }
+#if 0
+    fprintf (stderr, "failure\n");
+#endif
     return 0;
 }
 
@@ -234,7 +391,8 @@ static int acl_cache_next = 0;
 /* Returns < 0 if unsuccessful in loading acl */
 /* Returns index into acl_cache otherwise */
 /* Note that if acl is already loaded, this is just a lookup */
-int acl_load(char *name)
+int acl_load(name)
+    char *name;
 {
     int i;
     FILE *f;
@@ -272,8 +430,13 @@ int acl_load(char *name)
      */
     if (acl_cache[i].acl == (struct hashtbl *) 0) {
        /* Gotta reload */
+#if 0
+       fprintf (stderr, "attempting to load %s\n", name);
+#endif
        if ((f = fopen(name, "r")) == NULL) {
-           syslog(LOG_ERR, "Error loading acl file %s: %m", name);
+#if 0
+           perror (name);
+#endif
            return -1;
        }
        if (acl_cache[i].acl) destroy_hash(acl_cache[i].acl);
@@ -293,7 +456,7 @@ int acl_load(char *name)
  * the next time they are requested.
  */
 void
-acl_cache_reset(void)
+acl_cache_reset()
 {
        int     i;
        
@@ -310,12 +473,15 @@ acl_cache_reset(void)
 
 /* Returns nonzero if it can be determined that acl contains principal */
 /* Principal is not canonicalized, and no wildcarding is done */
-int
-acl_exact_match(char *acl,
-               char *principal)
+acl_exact_match(acl, principal)
+    char *acl;
+    char *principal;
 {
     int idx;
 
+#if 0
+    fprintf (stderr, "checking for %s in %s\n", principal, acl);
+#endif
     return((idx = acl_load(acl)) >= 0
           && check_hash(acl_cache[idx].acl, principal));
 }
@@ -323,8 +489,9 @@ acl_exact_match(char *acl,
 /* Returns nonzero if it can be determined that acl contains principal */
 /* Recognizes wildcards in acl. */
 int
-acl_check(char *acl,
-         char *principal)
+acl_check(acl, principal)
+    char *acl;
+    char *principal;
 {
     char buf[MAX_PRINCIPAL_SIZE];
     char canon[MAX_PRINCIPAL_SIZE];
@@ -351,3 +518,71 @@ acl_check(char *acl,
        
     return(0);
 }
+
+#ifdef notdef
+/* Adds principal to acl */
+/* Wildcards are interpreted literally */
+int
+acl_add(acl, principal)
+    char *acl;
+    char *principal;
+{
+    int idx;
+    int i;
+    FILE *new;
+    char canon[MAX_PRINCIPAL_SIZE];
+
+    acl_canonicalize_principal(principal, canon);
+
+    if ((new = acl_lock_file(acl)) == NULL) return(-1);
+    if ((acl_exact_match(acl, canon))
+       || (idx = acl_load(acl)) < 0) {
+       acl_abort(acl, new);
+       return(-1);
+    }
+    /* It isn't there yet, copy the file and put it in */
+    for (i = 0; i < acl_cache[idx].acl->size; i++) {
+       if (acl_cache[idx].acl->tbl[i] != NULL) {
+           if (fputs(acl_cache[idx].acl->tbl[i], new) == NULL
+              || putc('\n', new) != '\n') {
+               acl_abort(acl, new);
+               return(-1);
+           }
+       }
+    }
+    fputs(canon, new);
+    putc('\n', new);
+    return(acl_commit(acl, new));
+}
+
+/* Removes principal from acl */
+/* Wildcards are interpreted literally */
+int
+acl_delete(acl, principal)
+    char *acl;
+    char *principal;
+{
+    int idx;
+    int i;
+    FILE *new;
+    char canon[MAX_PRINCIPAL_SIZE];
+
+    acl_canonicalize_principal(principal, canon);
+
+    if ((new = acl_lock_file(acl)) == NULL) return(-1);
+    if ((!acl_exact_match(acl, canon))
+       || (idx = acl_load(acl)) < 0) {
+       acl_abort(acl, new);
+       return(-1);
+    }
+    /* It isn't there yet, copy the file and put it in */
+    for (i = 0; i < acl_cache[idx].acl->size; i++) {
+       if (acl_cache[idx].acl->tbl[i] != NULL
+          && strcmp(acl_cache[idx].acl->tbl[i], canon)) {
+           fputs(acl_cache[idx].acl->tbl[i], new);
+           putc('\n', new);
+       }
+    }
+    return(acl_commit(acl, new));
+}
+#endif /* notdef */
index acddc7e3a25f55d6173fb40230b2a853bac0d8af..b45d0ad3553311a3b8e135917e071d6eefa0a462 100644 (file)
@@ -44,69 +44,27 @@ static const char rcsid_bdump_c[] = "$Id$";
  *     int num;
  */
 
-#if defined(HAVE_KRB5) && 0
-int krb5_init_keyblock(krb5_context context,
-        krb5_enctype type,
-        size_t size,
-        krb5_keyblock **akey)
-{
-krb5_error_code ret;
-size_t len;
-krb5_keyblock *key;
-
-*akey=NULL;
-key=malloc(sizeof(*key));
-memset(key, 0, sizeof(*key));
-ret = krb5_enctype_keysize(context, type, &len);
-if (ret)
-return ret;
-
-if (len != size) {
-krb5_set_error_string(context, "Encryption key %d is %lu bytes "
-"long, %lu was passed in",
-type, (unsigned long)len, (unsigned long)size);
-return KRB5_PROG_ETYPE_NOSUPP;
-}
-
-ret = krb5_data_alloc(&key->keyvalue, len);
-if(ret) {
-krb5_set_error_string(context, "malloc failed: %lu",
-(unsigned long)len);
-return ret;
-}
-key->keytype = type;
-*akey=key;
-return 0;
-}
-#endif
-
-
-static void close_bdump(void* arg);
-static Code_t bdump_send_loop(Server *server);
-static Code_t bdump_recv_loop(Server *server);
-static void bdump_get_v12(ZNotice_t *, int, struct sockaddr_in *,
-                              Server *);
-static Code_t get_packet(void *packet, int len, int *retlen);
-static Code_t extract_sin(ZNotice_t *notice, struct sockaddr_in *target);
-static Code_t send_done(void);
-static Code_t send_list(ZNotice_Kind_t kind, int port, char *class_name,
+static void close_bdump __P((void* arg));
+static Code_t bdump_send_loop __P((Server *server)),
+bdump_ask_for __P((char *inst)),
+bdump_recv_loop __P((Server *server));
+static void bdump_get_v12 __P((ZNotice_t *, int, struct sockaddr_in *,
+                              Server *));
+static Code_t get_packet __P((void *packet, int len, int *retlen));
+static Code_t extract_sin __P((ZNotice_t *notice, struct sockaddr_in *target));
+static Code_t send_done __P((void));
+static Code_t send_list __P((ZNotice_Kind_t kind, int port, char *class_name,
                             char *inst, char *opcode, char *sender,
-                            char *recip, char **lyst, int num);
-static Code_t send_normal_tcp(ZNotice_Kind_t kind, int port,
+                            char *recip, char **lyst, int num));
+static Code_t send_normal_tcp __P((ZNotice_Kind_t kind, int port,
                                   char *class_name,
                                   char *inst, char *opcode, char *sender,
-                                  char *recip, char *message, int len);
-static int net_read(FILE *f, char *buf, int len);
-static int net_write(FILE *f, char *buf, int len);
-static int setup_file_pointers(void);
-static void shutdown_file_pointers(void);
-static void cleanup(Server *server);
-
-#ifdef HAVE_KRB5
-static long ticket5_time;
-#define TKT5LIFETIME 8*60*60
-#define tkt5_lifetime(val) (val)
-#endif
+                                  char *recip, char *message, int len));
+static int net_read __P((FILE *f, char *buf, int len));
+static int net_write __P((FILE *f, char *buf, int len));
+static int setup_file_pointers __P((void));
+static void shutdown_file_pointers __P((void));
+static void cleanup __P((Server *server));
 
 #ifdef HAVE_KRB4
 static long ticket_time;
@@ -114,22 +72,23 @@ static long ticket_time;
 #define TKTLIFETIME    120
 #define tkt_lifetime(val) ((long) val * 5L * 60L)
 
+#ifndef NOENCRYPTION
 extern C_Block serv_key;
 extern Sched   serv_ksched;
+#endif
 #endif /* HAVE_KRB4 */
 
 static Timer *bdump_timer;
 static int live_socket = -1;
 static FILE *input, *output;
 static struct sockaddr_in bdump_sin;
-#ifdef HAVE_KRB5
-static krb5_auth_context bdump_ac;
+#ifdef notdef
+static int cancel_outgoing_dump;
 #endif
 
 int bdumping;
 int bdump_concurrent;
 extern char *bdump_version;
-extern int bdump_auth_proto;
 
 /*
  * Functions for performing a brain dump between servers.
@@ -140,19 +99,20 @@ extern int bdump_auth_proto;
  */
 
 void
-bdump_offer(struct sockaddr_in *who)
+bdump_offer(who)
+    struct sockaddr_in *who;
 {
     Code_t retval;
     char buf[512], *addr, *lyst[2];
 #ifndef HAVE_KRB4
     int bdump_port = IPPORT_RESERVED - 1;
 #endif /* !HAVE_KRB4 */
-
+#if 1
     zdbug((LOG_DEBUG, "bdump_offer"));
-
-#if defined(HAVE_KRB4) || defined(HAVE_KRB5)
+#endif
+#ifdef HAVE_KRB4
     /* 
-     * when using kerberos server-server authentication, we can
+     * when using HAVE_KRB4 server-server authentication, we can
      * use any random local address 
      */
     bdump_socket = socket(AF_INET, SOCK_STREAM, 0);
@@ -177,7 +137,7 @@ bdump_offer(struct sockaddr_in *who)
        return;
     }
     if (!bdump_sin.sin_port) {
-       unsigned int len = sizeof(bdump_sin);
+       int len = sizeof(bdump_sin);
 
        if (getsockname(bdump_socket,
                        (struct sockaddr *) &bdump_sin, &len) < 0) {
@@ -228,9 +188,11 @@ bdump_offer(struct sockaddr_in *who)
     send_list(ACKED, srv_addr.sin_port, ZEPHYR_ADMIN_CLASS, bdump_version,
              ADMIN_BDUMP, myname, "", lyst, 2);
        
+#if 1
     zdbug((LOG_DEBUG,"bdump_offer: address is %s/%d\n",
           inet_ntoa(bdump_sin.sin_addr),
           ntohs(bdump_sin.sin_port)));
+#endif
     return;
 }
 
@@ -239,39 +201,27 @@ bdump_offer(struct sockaddr_in *who)
  */
 
 void
-bdump_send(void)
+bdump_send()
 {
     struct sockaddr_in from;
     Server *server;
     Code_t retval;
-    unsigned int fromlen = sizeof(from);
+    int fromlen = sizeof(from);
     int on = 1;
 #ifdef _POSIX_VERSION
     struct sigaction action;
 #endif
-#if defined(HAVE_KRB4) || defined(HAVE_KRB5)
-    char *data = NULL;
-    int len = 0;
-    int proto = 0;
-#endif
+
 #ifdef HAVE_KRB4
     KTEXT_ST ticket;
     AUTH_DAT kdata;
-    /* may be moved into kstuff.c */
-    char instance [INST_SZ];
-#endif
-#ifdef HAVE_KRB5
-    /* may be moved into kstuff.c */
-    krb5_principal principal;
-    krb5_data k5data;
-    krb5_keytab kt;
-#endif
-#if !defined(HAVE_KRB4) && !defined(HAVE_KRB5)
+#else
     unsigned short fromport;
 #endif /* HAVE_KRB4 */
  
+#if 1
     zdbug((LOG_DEBUG, "bdump_send"));
-
+#endif
     /* accept the connection, and send the brain dump */
     live_socket = accept(bdump_socket, (struct sockaddr *) &from, &fromlen);
     if (live_socket < 0) {
@@ -304,9 +254,10 @@ bdump_send(void)
        syslog(LOG_ERR, "bdump_send: unknown server?");
        server = limbo_server;
     }
-
+#if 1
     zdbug((LOG_DEBUG, "bdump_send: connection from %s/%d",
           inet_ntoa(from.sin_addr), ntohs(from.sin_port)));
+#endif
 
     bdumping = 1;
     server->dumping = 1;
@@ -319,164 +270,48 @@ bdump_send(void)
        bdump_socket = -1;
        timer_reset(bdump_timer);
     }
-
     /* Now begin the brain dump. */
-#if defined(HAVE_KRB5) || defined(HAVE_KRB4)
-    retval = ReadKerberosData(live_socket, &len, &data, &proto);
-
-    if (retval != 0) {
-       syslog(LOG_ERR, "bdump_send: ReadKerberosData: %s",
+#ifdef HAVE_KRB4
+    /* receive the authenticator */
+    retval = GetKerberosData(live_socket, from.sin_addr, &kdata,
+                            SERVER_SERVICE, srvtab_file);
+    if (retval != KSUCCESS) {
+       syslog(LOG_ERR, "bdump_send: getkdata: %s",
               krb_get_err_text(retval));
        cleanup(server);
        return;
     }
-
-    syslog(LOG_INFO, "bdump_send: got %d bytes of authenticator for protocol %d", len, proto);
-
     if (get_tgt()) {
-       syslog(LOG_ERR, "bdump_send: get_tgt failed");
        cleanup(server);
        return;
     }
-    switch(proto) {
-#ifdef HAVE_KRB5
-    case 5:
-       /* "server" side */
-       retval = krb5_build_principal(Z_krb5_ctx, &principal, 
-                                     strlen(ZGetRealm()),
-                                     ZGetRealm(),
-                                     SERVER_KRB5_SERVICE, SERVER_INSTANCE,
-                                     0); 
-       if (retval) {
-           syslog(LOG_ERR, "bdump_send: krb5_build_principal: %s", error_message(retval));
-           cleanup(server);
-           return;
-       }
-       
-
-       retval = krb5_auth_con_init(Z_krb5_ctx, &bdump_ac);
-       if (retval) {
-           syslog(LOG_ERR, "bdump_send: krb5_auth_con_init: %s", error_message(retval));
-           cleanup(server);
-           return;
-       }
-
-       retval = krb5_auth_con_setflags(Z_krb5_ctx, bdump_ac, KRB5_AUTH_CONTEXT_DO_SEQUENCE);
-       if (retval) {
-           syslog(LOG_ERR, "bdump_send: krb5_auth_con_setflags: %s", error_message(retval));
-           cleanup(server);
-           return;
-       }
-
-       retval = krb5_auth_con_genaddrs(Z_krb5_ctx, bdump_ac, live_socket,
-                                       KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR|KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR);
-       if (retval) {
-           syslog(LOG_ERR, "bdump_send: krb5_auth_con_genaddrs: %s", error_message(retval));
-           cleanup(server);
-           return;
-       }
-
-       /* Get the "client" krb_ap_req */
-
-       memset((char *)&k5data, 0, sizeof(krb5_data));
-       k5data.length = len;
-       k5data.data = data;
-       if (retval) {
-            syslog(LOG_ERR, "bdump_send: cannot get auth response: %s",
-                   error_message(retval)); 
-            cleanup(server);
-            return;
-       }
-
-       /* resolve keytab */
-       retval = krb5_kt_resolve(Z_krb5_ctx, keytab_file, &kt);
-       if (retval) {
-           syslog(LOG_ERR, "bdump_send: cannot resolve keytab: %s", 
-                  error_message(retval));
-           krb5_kt_close(Z_krb5_ctx, kt);
-           cleanup(server);
-           return;
-       }
-
-       retval = krb5_rd_req(Z_krb5_ctx, &bdump_ac, &k5data, principal, kt, NULL, NULL);
-       krb5_free_principal(Z_krb5_ctx, principal);
-       krb5_kt_close(Z_krb5_ctx, kt);
-       free(k5data.data);
-       memset((char *)&k5data, 0, sizeof(krb5_data));
-       if (retval) {
-            syslog(LOG_ERR, "bdump_send: mutual authentication failed: %s",
-                   error_message(retval));
-            cleanup(server);
-            return;
-       }
-
-       /* Now send back our auth packet */
-
-       retval = krb5_mk_rep(Z_krb5_ctx, bdump_ac, &k5data);
-       if (retval) {
-           syslog(LOG_ERR, "bdump_send: krb5_mk_rep: %s", error_message(retval));
-           cleanup(server);
-           return;
-       }
-       retval = SendKrb5Data(live_socket, &k5data);
-       if (retval) {
-            syslog(LOG_ERR, "bdump_send: cannot send authenticator: %s",
-                   error_message(retval));
-            krb5_free_data_contents(Z_krb5_ctx, &k5data);
-            cleanup(server);
-            return;
-       }    
-       krb5_free_data_contents(Z_krb5_ctx, &k5data);
-       break;
-#endif  /* HAVE_KRB5 */  
-#ifdef HAVE_KRB4
-    case 4:
-       /* here to krb_rd_req from GetKerberosData candidate for refactoring
-          back into kstuff.c */
-       (void) strcpy(instance, "*");           /* let Kerberos fill it in */
-
-       ticket.length = len;
-       memcpy(&ticket.dat, data, MIN(len, sizeof(ticket.dat)));
-       retval = krb_rd_req(&ticket, SERVER_SERVICE, instance,
-                           from.sin_addr.s_addr, &kdata, srvtab_file);
-       /*
-       retval = GetKerberosData(live_socket, from.sin_addr, &kdata,
-                                SERVER_SERVICE, srvtab_file);
-       */
-       if (retval != KSUCCESS) {
-           syslog(LOG_ERR, "bdump_send: getkdata: %s",
-                  krb_get_err_text(retval));
-           cleanup(server);
-           return;
-       }
-       if (strcmp(kdata.pname, SERVER_SERVICE) ||
-           strcmp(kdata.pinst, SERVER_INSTANCE) ||
-           strcmp(kdata.prealm, ZGetRealm())) {
-           syslog(LOG_ERR, "bdump_send: peer not zephyr: %s.%s@%s",
-                  kdata.pname, kdata.pinst, kdata.prealm);
-           cleanup(server);
-           return;
-       }
-       /* authenticate back */
-       retval = SendKerberosData(live_socket, &ticket, SERVER_SERVICE,
-                                 SERVER_INSTANCE);
-       if (retval != 0) {
-           syslog(LOG_ERR,"bdump_send: SendKerberosData: %s",
-                  error_message (retval));
-           cleanup(server);
-           return;
-       }
-       break;
-#endif /* HAVE_KRB4 */
+    if (strcmp(kdata.pname, SERVER_SERVICE) ||
+       strcmp(kdata.pinst, SERVER_INSTANCE) ||
+       strcmp(kdata.prealm, ZGetRealm())) {
+       syslog(LOG_ERR, "bdump_send: peer not zephyr: %s.%s@%s",
+              kdata.pname, kdata.pinst, kdata.prealm);
+       cleanup(server);
+       return;
+    }
+    /* authenticate back */
+    retval = SendKerberosData(live_socket, &ticket, SERVER_SERVICE,
+                             SERVER_INSTANCE);
+    if (retval != 0) {
+       syslog(LOG_ERR,"bdump_send: SendKerberosData: %s",
+              error_message (retval));
+       cleanup(server);
+       return;
     }
-#else /* HAVE_KRB4 || HAVE_KRB5 */
+#else  /* !HAVE_KRB4 */
     if (fromport > IPPORT_RESERVED || fromport < IPPORT_RESERVED / 2) {
        syslog(LOG_ERR, "bdump_send: bad port from peer: %d", fromport);
        cleanup(server);
        return;
     }
-#endif /* HAVE_KRB4 || HAVE_KRB5 */
+#endif /* HAVE_KRB4 */
+
     retval = setup_file_pointers();
     if (retval != 0) {
        syslog (LOG_WARNING, "bdump_send: can't set up file pointers: %s",
@@ -498,16 +333,18 @@ bdump_send(void)
        cleanup(server);
        return;
     }
-
+#if 1
     zdbug((LOG_DEBUG, "bdump_send: finished"));
-
+#endif
     if (server != limbo_server) {
        /* set this guy to be up, and schedule a hello */
        server->state = SERV_UP;
        timer_reset(server->timer);
        server->timer = timer_set_rel(0L, server_timo, server);
     }
-
+#if 0
+    zdbug((LOG_DEBUG,"cleanup sbd"));
+#endif
     shutdown_file_pointers();
 
 #ifdef _POSIX_VERSION
@@ -525,10 +362,11 @@ bdump_send(void)
 
 /*ARGSUSED*/
 static void
-bdump_get_v12 (ZNotice_t *notice,
-              int auth,
-              struct sockaddr_in *who,
-              Server *server)
+bdump_get_v12 (notice, auth, who, server)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Server *server;
 {
     struct sockaddr_in from;
     Code_t retval;
@@ -536,21 +374,12 @@ bdump_get_v12 (ZNotice_t *notice,
 #ifdef _POSIX_VERSION
     struct sigaction action;
 #endif
-#if defined(HAVE_KRB4) || defined(HAVE_KRB5)
-#ifdef HAVE_KRB5
-    krb5_creds creds;
-    krb5_creds *credsp;
-    krb5_principal principal;
-    krb5_data data;
-    krb5_ap_rep_enc_part *rep;
-#endif
 #ifdef HAVE_KRB4
     KTEXT_ST ticket;
     AUTH_DAT kdata;
-#endif
-#else  /* !HAVE_KRB4 && !HAVE_KRB5 */
+#else  /* !HAVE_KRB4 */
     int reserved_port = IPPORT_RESERVED - 1;
-#endif /* !HAVE_KRB4 && !HAVE_KRB5 */
+#endif /* HAVE_KRB4 */
     
     bdumping = 1;
     server->dumping = 1;
@@ -590,7 +419,7 @@ bdump_get_v12 (ZNotice_t *notice,
        server->dumping = 0;
        return;
     }
-#if !defined(HAVE_KRB4) && !defined(HAVE_KRB5)
+#ifndef HAVE_KRB4
     if (ntohs(from.sin_port) > IPPORT_RESERVED ||
        ntohs(from.sin_port) < IPPORT_RESERVED / 2) {
        syslog(LOG_ERR, "bdump_get: port not reserved: %d",
@@ -599,9 +428,9 @@ bdump_get_v12 (ZNotice_t *notice,
        return;
     }
     live_socket = rresvport(&reserved_port);
-#else  /* !HAVE_KRB4 && !HAVE_KRB5 */
+#else  /* !HAVE_KRB4 */
     live_socket = socket(AF_INET, SOCK_STREAM, 0);
-#endif /* !HAVE_KRB4 && !HAVE_KRB5 */
+#endif /* HAVE_KRB4 */
     if (live_socket < 0) {
        syslog(LOG_ERR, "bdump_get: socket: %m");
        cleanup(server);
@@ -615,154 +444,47 @@ bdump_get_v12 (ZNotice_t *notice,
     if (setsockopt(live_socket, SOL_SOCKET, SO_KEEPALIVE, (char *)&on,
                   sizeof(on)) < 0)
        syslog(LOG_WARNING, "bdump_get: setsockopt (SO_KEEPALIVE): %m");
-
+#if 1
     zdbug((LOG_DEBUG, "bdump_get: connected"));
+#endif
  
     /* Now begin the brain dump. */
-#if defined(HAVE_KRB4) || defined(HAVE_KRB5)
+
+#ifdef HAVE_KRB4
+    /* send an authenticator */
     if (get_tgt()) {
-       syslog(LOG_ERR, "bdump_get: get_tgt failed"); 
        cleanup(server);
        return;
     }
-    switch(bdump_auth_proto) {
-#ifdef HAVE_KRB5
-    case 5: /* "client" side */
-       memset((char *)&creds, 0, sizeof(creds));
-
-       retval = krb5_build_principal(Z_krb5_ctx, &principal, 
-                                     strlen(ZGetRealm()),
-                                     ZGetRealm(),
-                                     SERVER_KRB5_SERVICE, SERVER_INSTANCE,
-                                     0); 
-       if (retval) {
-           syslog(LOG_ERR, "bdump_get: krb5_build_principal: %s", error_message(retval));
-           cleanup(server);
-           return;
-       }
-
-       retval = krb5_copy_principal(Z_krb5_ctx, principal, &creds.server);
-       if (retval) {
-           syslog(LOG_ERR, "bdump_get: krb5_copy_principal (server): %s", error_message(retval));
-           krb5_free_principal(Z_krb5_ctx, principal);
-           cleanup(server);
-           return;
-       }
-       
-       retval = krb5_copy_principal(Z_krb5_ctx, principal, &creds.client);
-       krb5_free_principal(Z_krb5_ctx, principal);
-       if (retval) {
-           syslog(LOG_ERR, "bdump_get: krb5_copy_principal (client): %s", error_message(retval));
-           krb5_free_cred_contents(Z_krb5_ctx, &creds);
-           cleanup(server);
-           return;
-       }
-
-       retval = krb5_get_credentials(Z_krb5_ctx, 0, Z_krb5_ccache,
-                                     &creds, &credsp);
-       krb5_free_cred_contents(Z_krb5_ctx, &creds);
-       if (retval) {
-           syslog(LOG_ERR, "bdump_get: krb5_get_credentials: %s", error_message(retval));
-           cleanup(server);
-           return;
-       }
-
-       retval = krb5_auth_con_init(Z_krb5_ctx, &bdump_ac);
-       if (retval) {
-           syslog(LOG_ERR, "bdump_get: krb5_auth_con_init: %s", error_message(retval));
-           krb5_free_creds(Z_krb5_ctx, credsp);
-           cleanup(server);
-           return;
-       }
-
-       retval = krb5_auth_con_setflags(Z_krb5_ctx, bdump_ac, KRB5_AUTH_CONTEXT_DO_SEQUENCE);
-       if (retval) {
-           syslog(LOG_ERR, "bdump_get: krb5_auth_con_setflags: %s", error_message(retval));
-           krb5_free_creds(Z_krb5_ctx, credsp);
-           cleanup(server);
-           return;
-       }
-
-       retval = krb5_auth_con_genaddrs(Z_krb5_ctx, bdump_ac, live_socket,
-               KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR|KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR);
-       if (retval) {
-           syslog(LOG_ERR, "bdump_get: krb5_auth_con_genaddrs: %s", error_message(retval));
-           krb5_free_creds(Z_krb5_ctx, credsp);
-           cleanup(server);
-           return;
-       }
-
-       memset((char *)&data, 0, sizeof(krb5_data));
-       retval = krb5_mk_req_extended(Z_krb5_ctx, &bdump_ac, AP_OPTS_MUTUAL_REQUIRED|AP_OPTS_USE_SUBKEY,
-                                NULL, credsp, &data);
-       if (retval) {
-           syslog(LOG_ERR, "bdump_get: krb5_mk_req_ext: %s", error_message(retval));
-           krb5_free_creds(Z_krb5_ctx, credsp);
-           cleanup(server);
-           return;
-       }
-        retval = SendKrb5Data(live_socket, &data);
-        krb5_free_creds(Z_krb5_ctx, credsp);
-        if (retval) {
-             syslog(LOG_ERR, "bdump_get: cannot send authenticator: %s",
-                    error_message(retval));
-             krb5_free_data_contents(Z_krb5_ctx, &data);
-             cleanup(server);
-             return;
-        }    
-        krb5_free_data_contents(Z_krb5_ctx, &data);
-       memset((char *)&data, 0, sizeof(krb5_data));
-        retval = GetKrb5Data(live_socket, &data);
-        if (retval) {
-             syslog(LOG_ERR, "bdump_get: cannot get auth response: %s",
-                    error_message(retval));
-             cleanup(server);
-             return;
-        }    
-        retval = krb5_rd_rep(Z_krb5_ctx, bdump_ac, &data, &rep);
-        free(data.data);
-        memset((char *)&data, 0, sizeof(krb5_data));
-        if (retval) {
-             syslog(LOG_ERR, "bdump_get: mutual authentication failed: %s",
-                    error_message(retval));
-             cleanup(server);
-             return;
-        }    
-       break;
+    retval = SendKerberosData(live_socket, &ticket, SERVER_SERVICE,
+                             SERVER_INSTANCE);
+    if (retval != 0) {
+       syslog(LOG_ERR,"bdump_get: %s", error_message(retval));
+       cleanup(server);
+       return;
+    }
+#if 1
+    zdbug((LOG_DEBUG, "bdump_get: SendKerberosData ok"));
 #endif
-#ifdef HAVE_KRB4
-    case 4:
-       /* send an authenticator */
-       retval = SendKerberosData(live_socket, &ticket, SERVER_SERVICE,
-                                 SERVER_INSTANCE);
-       if (retval != 0) {
-           syslog(LOG_ERR,"bdump_get: %s", error_message(retval));
-           cleanup(server);
-           return;
-       }
-       zdbug((LOG_DEBUG, "bdump_get: SendKerberosData ok"));
-       
-       /* get his authenticator */
-       retval = GetKerberosData(live_socket, from.sin_addr, &kdata,
-                                SERVER_SERVICE, srvtab_file);
-       if (retval != KSUCCESS) {
-           syslog(LOG_ERR, "bdump_get getkdata: %s",krb_get_err_text(retval));
-           cleanup(server);
-           return;
-       }
+    /* get his authenticator */
+    retval = GetKerberosData(live_socket, from.sin_addr, &kdata,
+                            SERVER_SERVICE, srvtab_file);
+    if (retval != KSUCCESS) {
+       syslog(LOG_ERR, "bdump_get getkdata: %s",krb_get_err_text(retval));
+       cleanup(server);
+       return;
+    }
 
-       if (strcmp(kdata.pname, SERVER_SERVICE) ||
-           strcmp(kdata.pinst, SERVER_INSTANCE) ||
-           strcmp(kdata.prealm, ZGetRealm())) {
-           syslog(LOG_ERR, "bdump_get: peer not zephyr in lrealm: %s.%s@%s",
-                  kdata.pname, kdata.pinst,kdata.prealm);
-           cleanup(server);
-           return;
-       }
-       break;
-#endif /* HAVE_KRB4 */
+    if (strcmp(kdata.pname, SERVER_SERVICE) ||
+       strcmp(kdata.pinst, SERVER_INSTANCE) ||
+       strcmp(kdata.prealm, ZGetRealm())) {
+       syslog(LOG_ERR, "bdump_get: peer not zephyr in lrealm: %s.%s@%s",
+              kdata.pname, kdata.pinst,kdata.prealm);
+       cleanup(server);
+       return;
     }
-#endif /* defined(HAVE_KRB4) || defined(HAVE_KRB5) */   
+#endif /* HAVE_KRB4 */
     retval = setup_file_pointers();
     if (retval != 0) {
        syslog(LOG_WARNING, "bdump_get: can't set up file pointers: %s",
@@ -777,7 +499,9 @@ bdump_get_v12 (ZNotice_t *notice,
        cleanup(server);
        return;
     }
+#if 1
     zdbug((LOG_DEBUG,"bdump_get: gbdl ok"));
+#endif
     retval = bdump_send_loop(server);
     if (retval != ZERR_NONE) {
        syslog(LOG_WARNING, "bdump_send_loop failed: %s",
@@ -785,17 +509,17 @@ bdump_get_v12 (ZNotice_t *notice,
        cleanup(server);
        return;
     }
-
+#if 1
     zdbug((LOG_DEBUG, "bdump_get: gbd finished"));
-
+#endif
     /* set this guy to be up, and schedule a hello */
     server->state = SERV_UP;
     timer_reset(server->timer);
     server->timer = timer_set_rel(0L, server_timo, server);
 
-
+#if 1
     zdbug((LOG_DEBUG,"cleanup gbd"));
-
+#endif
     shutdown_file_pointers();
 #ifdef _POSIX_VERSION
     action.sa_handler = SIG_DFL;
@@ -812,20 +536,22 @@ bdump_get_v12 (ZNotice_t *notice,
 }
 
 void
-bdump_get(ZNotice_t *notice,
-         int auth,
-         struct sockaddr_in *who,
-         Server *server)
+bdump_get(notice, auth, who, server)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Server *server;
 {
-    void (*proc)(ZNotice_t *, int, struct sockaddr_in *, Server *);
+    void (*proc) __P((ZNotice_t *, int, struct sockaddr_in *, Server *));
 
     proc = NULL;
 
+#if 1
     if (zdebug) {
        syslog(LOG_DEBUG, "bdump_get: bdump v%s avail %s",
               notice->z_class_inst, inet_ntoa(who->sin_addr));
     }
-
+#endif
     if (strcmp (notice->z_class_inst, "1.2") == 0)
        proc = bdump_get_v12;
 
@@ -844,15 +570,12 @@ bdump_get(ZNotice_t *notice,
  */
 
 Code_t
-bdump_send_list_tcp(ZNotice_Kind_t kind,
-                   struct sockaddr_in *addr,
-                   char *class_name,
-                   char *inst,
-                   char *opcode,
-                   char *sender,
-                   char *recip,
-                   char **lyst,
-                   int num)
+bdump_send_list_tcp(kind, addr, class_name, inst, opcode, sender, recip, lyst,
+                   num)
+    ZNotice_Kind_t kind;
+    struct sockaddr_in *addr;
+    int num;
+    char *class_name, *inst, *opcode, *sender, *recip, **lyst;
 {
     ZNotice_t notice;
     char *pack, addrbuf[100];
@@ -882,30 +605,7 @@ bdump_send_list_tcp(ZNotice_Kind_t kind,
     retval = ZFormatNoticeList(&notice, lyst, num, &pack, &packlen, ZNOAUTH);
     if (retval != ZERR_NONE)
        return retval;
-
-#ifdef HAVE_KRB5
-    if (bdump_ac) {
-        krb5_data indata, outmsg;
-        indata.length=packlen;
-        indata.data=pack;
-        memset(&outmsg, 0, sizeof(krb5_data));
-        retval = krb5_mk_priv(Z_krb5_ctx, bdump_ac, &indata, &outmsg, NULL);
-        if (retval != ZERR_NONE)
-           return retval;
-        if (outmsg.length > Z_MAXPKTLEN) {
-           syslog(LOG_ERR, "bsl: encrypted packet is too large");
-            return ZERR_PKTLEN;
-        }
-        packlen = outmsg.length;
-        free(pack);
-        pack=malloc(packlen);
-        if (!pack)
-           return ENOMEM;
-        memcpy(pack, outmsg.data, packlen);
-        krb5_free_data_contents(Z_krb5_ctx, &outmsg);
-    }
-#endif
-
+       
     length = htons((u_short) packlen);
  
     count = net_write(output, (char *) &length, sizeof(length));
@@ -938,8 +638,7 @@ bdump_send_list_tcp(ZNotice_Kind_t kind,
 }
 
 static void
-shutdown_file_pointers(void)
-{
+shutdown_file_pointers() {
     if (input) {
        fclose(input);
        input = 0;
@@ -951,23 +650,20 @@ shutdown_file_pointers(void)
     if (live_socket >= 0) {
        close(live_socket);
        live_socket = -1;
-#ifdef HAVE_KRB5
-       if (bdump_ac)
-               krb5_auth_con_free(Z_krb5_ctx, bdump_ac);
-       bdump_ac = NULL;
-#endif
     }
 }
 
 static void
-cleanup(Server *server)
+cleanup(server)
+    Server *server;
 {
 #ifdef _POSIX_VERSION
     struct sigaction action;
 #endif
 
+#if 1
     zdbug((LOG_DEBUG, "bdump cleanup"));
-
+#endif
     if (server != limbo_server) {
        server->state = SERV_DEAD;
        timer_reset(server->timer);
@@ -988,20 +684,24 @@ cleanup(Server *server)
 
 #ifdef HAVE_KRB4
 int
-get_tgt(void)
+get_tgt()
 {
     /* MIT Kerberos 4 get_svc_in_tkt() requires instance to be writable and
      * at least INST_SZ bytes long. */
     static char buf[INST_SZ + 1] = SERVER_INSTANCE;
     int retval = 0;
-    
+    CREDENTIALS cred;
+#ifndef NOENCRYPTION
+    Sched *s;
+#endif
+       
     /* have they expired ? */
     if (ticket_time < NOW - tkt_lifetime(TKTLIFETIME) + (15L * 60L)) {
        /* +15 for leeway */
-
+#if 0
        zdbug((LOG_DEBUG,"get new tickets: %d %d %d", ticket_time, NOW,
               NOW - tkt_lifetime(TKTLIFETIME) + 15L));
-
+#endif
        dest_tkt();
 
        retval = krb_get_svc_in_tkt(SERVER_SERVICE, buf, ZGetRealm(),
@@ -1016,64 +716,18 @@ get_tgt(void)
            ticket_time = NOW;
        }
 
+#ifndef NOENCRYPTION
        retval = read_service_key(SERVER_SERVICE, SERVER_INSTANCE,
                                  ZGetRealm(), 0 /*kvno*/,
-                                 srvtab_file, (char *)serv_key);
+                                 srvtab_file, serv_key);
        if (retval != KSUCCESS) {
            syslog(LOG_ERR, "get_tgt: read_service_key: %s",
                   krb_get_err_text(retval));
            return 1;
        }
        des_key_sched(serv_key, serv_ksched.s);
+#endif /* !NOENCRYPTION */
     }
-#ifdef HAVE_KRB5       
-    /* XXX */
-    if (ticket5_time < NOW - tkt5_lifetime(TKT5LIFETIME) + (15L * 60L)) {
-       krb5_keytab kt;
-       krb5_get_init_creds_opt opt;
-       krb5_creds cred;
-       krb5_principal principal;
-
-       memset(&cred, 0, sizeof(cred));
-
-       retval = krb5_build_principal(Z_krb5_ctx, &principal, 
-                                     strlen(ZGetRealm()),
-                                     ZGetRealm(),
-                                     SERVER_KRB5_SERVICE, SERVER_INSTANCE,
-                                     0); 
-       if (retval) {
-         krb5_free_principal(Z_krb5_ctx, principal);
-         return(1);
-       }
-
-       krb5_get_init_creds_opt_init (&opt);
-       krb5_get_init_creds_opt_set_tkt_life (&opt, TKT5LIFETIME);
-
-       retval = krb5_kt_resolve(Z_krb5_ctx, keytab_file, &kt);
-       if (retval) return(1);
-       
-       retval = krb5_get_init_creds_keytab (Z_krb5_ctx,
-                                            &cred,
-                                            principal,
-                                            kt,
-                                            0,
-                                            NULL,
-                                            &opt);
-       krb5_free_principal(Z_krb5_ctx, principal);
-       krb5_kt_close(Z_krb5_ctx, kt);
-       if (retval) return(1);
-
-       retval = krb5_cc_initialize (Z_krb5_ctx, Z_krb5_ccache, cred.client);
-       if (retval) return(1);
-    
-       retval = krb5_cc_store_cred (Z_krb5_ctx, Z_krb5_ccache, &cred);
-       if (retval) return(1);
-
-       ticket5_time = NOW;
-
-       krb5_free_cred_contents (Z_krb5_ctx, &cred);
-    }
-#endif
     return(0);
 }
 #endif /* HAVE_KRB4 */
@@ -1084,17 +738,21 @@ get_tgt(void)
  
 /*ARGSUSED*/
 static void
-close_bdump(void *arg)
+close_bdump(arg)
+    void * arg;
 {
     if (bdump_socket >= 0) {
        FD_CLR(bdump_socket, &interesting);
        close(bdump_socket);
        nfds = srv_socket + 1;
        bdump_socket = -1;
-
+#if 1
        zdbug((LOG_DEBUG, "bdump not used"));
+#endif
     } else {
+#if 1
        zdbug((LOG_DEBUG, "bdump not open"));
+#endif
     }
     return;
 }
@@ -1104,7 +762,8 @@ close_bdump(void *arg)
  */
  
 static Code_t
-bdump_recv_loop(Server *server)
+bdump_recv_loop(server)
+    Server *server;
 {
     ZNotice_t notice;
     ZPacket_t packet;
@@ -1112,19 +771,15 @@ bdump_recv_loop(Server *server)
     Code_t retval;
     Client *client = NULL;
     struct sockaddr_in who;
-#ifdef HAVE_KRB5
-    unsigned char buf[512];
-    int blen;
-#endif
-#if defined(HAVE_KRB4) || defined(HAVE_KRB5)    
-    char *cp;
-#endif
 #ifdef HAVE_KRB4
+    char *cp;
     C_Block cblock;
 #endif /* HAVE_KRB4 */
-    ZRealm *realm = NULL;
+    Realm *realm = NULL;
  
+#if 1
     zdbug((LOG_DEBUG, "bdump recv loop"));
+#endif
        
     /* do the inverse of bdump_send_loop, registering stuff on the fly */
     while (1) {
@@ -1143,23 +798,6 @@ bdump_recv_loop(Server *server)
            return retval;
        }
 
-#if HAVE_KRB5
-       if (bdump_ac) {
-           krb5_data in, out;
-           in.length = len;
-           in.data = packet;
-           memset(&out, 0, sizeof(krb5_data));
-           retval = krb5_rd_priv(Z_krb5_ctx, bdump_ac, &in, &out, NULL);
-           if (retval != ZERR_NONE) {
-               syslog(LOG_ERR, "brl krb5 rd priv: %s", error_message(retval));
-               return retval;
-           }
-           memcpy(packet, out.data, out.length);
-           len = out.length;
-           krb5_free_data_contents(Z_krb5_ctx, &out);
-       }
-#endif
-
        retval = ZParseNotice(packet, len, &notice);
        if (retval != ZERR_NONE) {
            syslog(LOG_ERR, "brl notice parse: %s", error_message(retval));
@@ -1215,52 +853,6 @@ bdump_recv_loop(Server *server)
                syslog(LOG_ERR,"brl failed: %s", error_message(retval));
                return retval;
            }
-#ifdef HAVE_KRB5
-           client->session_keyblock = NULL;
-           if (*notice.z_class_inst) {
-               /* check out this session key I found */
-               cp = notice.z_message + strlen(notice.z_message) + 1;
-               if (*cp == '0') {
-                   /* ****ing netascii; this is an encrypted DES keyblock
-                      XXX this code should be conditionalized for server
-                      transitions   */
-                   retval = Z_krb5_init_keyblock(Z_krb5_ctx, ENCTYPE_DES_CBC_CRC,
-                                               sizeof(C_Block),
-                                               &client->session_keyblock);
-                   if (retval) {
-                       syslog(LOG_ERR, "brl failed to allocate DES keyblock: %s",
-                              error_message(retval));
-                       return retval;
-                   }
-                   retval = ZReadAscii(cp, strlen(cp), cblock, sizeof(C_Block));
-                   if (retval != ZERR_NONE) {
-                       syslog(LOG_ERR,"brl bad cblk read: %s (%s)",
-                              error_message(retval), cp);
-                   } else {
-                       des_ecb_encrypt((C_Block *)cblock, (C_Block *)Z_keydata(client->session_keyblock),
-                                       serv_ksched.s, DES_DECRYPT);
-                   }
-               } else if (*cp == 'Z') { /* Zcode! Long live the new flesh! */
-                   retval = ZReadZcode((unsigned char *)cp, buf, sizeof(buf), &blen);
-                   if (retval != ZERR_NONE) {
-                       syslog(LOG_ERR,"brl bad cblk read: %s (%s)",
-                              error_message(retval), cp);
-                   } else {
-                       retval = Z_krb5_init_keyblock(Z_krb5_ctx,
-                                                   ntohl(*(krb5_enctype *)&buf[0]),
-                                                   ntohl(*(u_int32_t *)&buf[4]),
-                                                   &client->session_keyblock);
-                       if (retval) {
-                           syslog(LOG_ERR, "brl failed to allocate keyblock: %s",
-                                  error_message(retval));
-                           return retval;
-                       }
-                       memcpy(Z_keydata(client->session_keyblock), &buf[8],
-                              Z_keylen(client->session_keyblock));
-                   }
-               }
-           }
-#else
 #ifdef HAVE_KRB4
            memset(client->session_key, 0, sizeof(C_Block));
            if (*notice.z_class_inst) {
@@ -1271,12 +863,15 @@ bdump_recv_loop(Server *server)
                    syslog(LOG_ERR,"brl bad cblk read: %s (%s)",
                           error_message(retval), cp);
                } else {
+#ifdef NOENCRYPTION
+                   memcpy(cblock, client->session_key, sizeof(C_Block));
+#else
                    des_ecb_encrypt(cblock, client->session_key, serv_ksched.s,
                                    DES_DECRYPT);
+#endif
                }
            }
 #endif /* HAVE_KRB4 */
-#endif
        } else if (strcmp(notice.z_opcode, CLIENT_SUBSCRIBE) == 0) { 
            /* a subscription packet */
            if (!client) {
@@ -1298,7 +893,7 @@ bdump_recv_loop(Server *server)
                           error_message(retval));
                    return retval;
                }
-           } /* else */
+           } /* else 
                 /* Other side tried to send us subs for a realm we didn't
                    know about, and so we drop them silently */
        
@@ -1314,11 +909,14 @@ bdump_recv_loop(Server *server)
  */
 
 static Code_t
-bdump_send_loop(Server *server)
+bdump_send_loop(server)
+    Server *server;
 {
     Code_t retval;
 
+#if 1
     zdbug((LOG_DEBUG, "bdump send loop"));
+#endif
 
     retval = uloc_send_locations();
     if (retval != ZERR_NONE)
@@ -1337,12 +935,13 @@ bdump_send_loop(Server *server)
  */
 
 static Code_t
-send_done(void)
+send_done()
 {
     Code_t retval;
  
+#if 1
     zdbug((LOG_DEBUG, "send_done"));
-
+#endif
     retval = send_normal_tcp(SERVACK, bdump_sin.sin_port, ZEPHYR_ADMIN_CLASS,
                             "", ADMIN_DONE, myname, "", NULL, 0);
     return retval;
@@ -1354,15 +953,10 @@ send_done(void)
  */
 
 static Code_t
-send_list(ZNotice_Kind_t kind,
-         int port,
-         char *class_name,
-         char *inst,
-         char *opcode,
-         char *sender,
-         char *recip,
-         char **lyst,
-         int num)
+send_list(kind, port, class_name, inst, opcode, sender, recip, lyst, num)
+    ZNotice_Kind_t kind;
+    int port, num;
+    char *class_name, *inst, *opcode, *sender, *recip, **lyst;
 {
     ZNotice_t notice;
     char *pack;
@@ -1399,15 +993,11 @@ send_list(ZNotice_Kind_t kind,
  */
 
 static Code_t
-send_normal_tcp(ZNotice_Kind_t kind,
-               int port,
-               char *class_name,
-               char *inst,
-               char *opcode,
-               char *sender,
-               char *recip,
-               char *message,
-               int len)
+send_normal_tcp(kind, port, class_name, inst, opcode, sender, recip,
+               message, len)
+    ZNotice_Kind_t kind;
+    int port, len;
+    char *class_name, *inst, *opcode, *sender, *recip, *message;
 {
     ZNotice_t notice;
     char *pack;
@@ -1435,29 +1025,6 @@ send_normal_tcp(ZNotice_Kind_t kind,
        return retval;
     }
  
-#ifdef HAVE_KRB5
-    if (bdump_ac) {
-        krb5_data indata, outmsg;
-        indata.length=packlen;
-        indata.data=pack;
-        memset(&outmsg, 0, sizeof(krb5_data));
-        retval = krb5_mk_priv(Z_krb5_ctx, bdump_ac, &indata, &outmsg, NULL);
-        if (retval != ZERR_NONE)
-           return retval;
-        if (outmsg.length > Z_MAXPKTLEN) {
-           syslog(LOG_ERR, "sn: encrypted packet is too large");
-            return ZERR_PKTLEN;
-        }
-        packlen = outmsg.length;
-        free(pack);
-        pack=malloc(packlen);
-        if (!pack)
-           return ENOMEM;
-        memcpy(pack, outmsg.data, packlen);
-        krb5_free_data_contents(Z_krb5_ctx, &outmsg);
-    }
-#endif
-
     length = htons((u_short) packlen);
  
     count = net_write(output, (char *) &length, sizeof(length));
@@ -1494,7 +1061,10 @@ send_normal_tcp(ZNotice_Kind_t kind,
  */
 
 static Code_t
-get_packet(void *packet, int len, int *retlen)
+get_packet(packet, len, retlen)
+    void *packet;
+    int len;
+    int *retlen;
 {
     u_short length;
     int result;
@@ -1527,19 +1097,27 @@ get_packet(void *packet, int len, int *retlen)
 }
 
 static Code_t
-extract_sin(ZNotice_t *notice, struct sockaddr_in *target)
+extract_sin(notice, target)
+    ZNotice_t *notice;
+    struct sockaddr_in *target;
 {
     char *cp = notice->z_message;
     char *buf;
 
     buf = cp;
     if (!notice->z_message_len || *buf == '\0') {
+#if 0
+       zdbug((LOG_DEBUG,"no addr"));
+#endif
        return ZSRV_PKSHORT;
     }
     target->sin_addr.s_addr = inet_addr(cp);
  
     cp += (strlen(cp) + 1);    /* past the null */
     if ((cp >= notice->z_message + notice->z_message_len) || (*cp == '\0')) {
+#if 0
+       zdbug((LOG_DEBUG, "no port"));
+#endif
        return(ZSRV_PKSHORT);
     }
     target->sin_port = htons((u_short) atoi(cp));
@@ -1548,7 +1126,10 @@ extract_sin(ZNotice_t *notice, struct sockaddr_in *target)
 }
 
 static int
-net_read(FILE *f, char *buf, int len)
+net_read(f, buf, len)
+    FILE *f;
+    char *buf;
+    int len;
 {
     int cc, len2 = 0;
  
@@ -1557,13 +1138,7 @@ net_read(FILE *f, char *buf, int len)
        errno = 0;
        cc = fread(buf, 1, len, f);
        if (cc == 0)
-         {
-           if (feof(f))
-             return len2;
-           if (errno == 0)
-             errno = EIO;
            return -1;
-         }
        buf += cc;
        len2 += cc;
        len -= cc;
@@ -1572,7 +1147,10 @@ net_read(FILE *f, char *buf, int len)
 }
 
 static int
-net_write(FILE *f, char *buf, int len)
+net_write(f, buf, len)
+    FILE *f;
+    char *buf;
+    int len;
 {
     int cc;
     int wrlen = len;
@@ -1587,7 +1165,7 @@ net_write(FILE *f, char *buf, int len)
 }
 
 static int
-setup_file_pointers (void)
+setup_file_pointers ()
 {
     int fd;
 
index 0a974e49f7385f85d8e22f76210c000872477bda..c7f02e7bfe3c5914b5aa690da6a0c44e93d03e9c 100644 (file)
@@ -81,9 +81,9 @@ static const char rcsid_class_c[] =
 static Triplet *triplet_bucket[HASHSIZE]; /* the hash table of pointers */
 
 static Code_t remove_client __P((Triplet *triplet, Client *client,
-                                ZRealm *realm));
+                                Realm *realm));
 static Code_t insert_client __P((Triplet *triplet, Client *client,
-                                ZRealm *realm));
+                                Realm *realm));
 static Triplet *triplet_alloc __P((String *classname, String *inst,
                                   String *recipient));
 static void free_triplet __P((Triplet *));
@@ -101,9 +101,8 @@ static void free_triplet __P((Triplet *));
  * shouldn't affect performance.
  */
 
-int
-ZDest_eq(Destination *d1,
-        Destination *d2)
+int ZDest_eq(d1, d2)
+    Destination *d1, *d2;
 {
     return((d1->classname == d2->classname) &&
           (d1->inst == d2->inst) &&
@@ -115,9 +114,10 @@ ZDest_eq(Destination *d1,
 /* the client as interested in a triplet */
 
 Code_t
-triplet_register(Client *client,
-                Destination *dest,
-                ZRealm *realm)
+triplet_register(client, dest, realm)
+    Client *client;
+    Destination *dest;
+    Realm *realm;
 {
     Triplet *triplet;
     unsigned long hashval;
@@ -130,21 +130,26 @@ triplet_register(Client *client,
 
     /* Triplet not present in hash table, insert it. */
     triplet = triplet_alloc(dest->classname, dest->inst, dest->recip);
-    Triplet_insert(&triplet_bucket[hashval], triplet);
+    LIST_INSERT(&triplet_bucket[hashval], triplet);
     return insert_client(triplet, client, realm);
 }
 
 /* dissociate client from the class, garbage collecting if appropriate */
 
 Code_t
-triplet_deregister(Client *client,
-                  Destination *dest,
-                  ZRealm *realm)
+triplet_deregister(client, dest, realm)
+    Client *client;
+    Destination *dest;
+    Realm *realm;
 {
     Triplet *triplet;
     int retval;
     unsigned long hashval;
 
+#if 0
+    zdbug((LOG_DEBUG, "class_dereg: %s %s", dest->classname->string,
+          dest->inst->string));
+#endif
     hashval = DEST_HASHVAL(*dest);
     for (triplet = triplet_bucket[hashval]; triplet; triplet = triplet->next) {
        if (ZDest_eq(&triplet->dest, dest)) {
@@ -152,7 +157,7 @@ triplet_deregister(Client *client,
            if (retval != ZERR_NONE)
                return retval;
            if (*triplet->clients == NULL && !triplet->acl) {
-               Triplet_delete(triplet);
+               LIST_DELETE(triplet);
                free_triplet(triplet);
                return ZSRV_EMPTYCLASS;
            }
@@ -165,7 +170,8 @@ triplet_deregister(Client *client,
 /* return a linked list of what clients are interested in this triplet */
 
 Client **
-triplet_lookup(Destination *dest)
+triplet_lookup(dest)
+    Destination *dest;
 {
     Triplet *triplet;
     unsigned long hashval;
@@ -184,7 +190,8 @@ triplet_lookup(Destination *dest)
  */
 
 Acl *
-class_get_acl(String *class_name)
+class_get_acl(class_name)
+    String *class_name;
 {
     Triplet *triplet;
     unsigned long hashval;
@@ -207,8 +214,9 @@ class_get_acl(String *class_name)
  */
 
 Code_t
-class_restrict(char *class_name,
-              Acl *acl)
+class_restrict(class_name, acl)
+    char *class_name;
+    Acl *acl;
 {
     Triplet *triplet;
     String *d;
@@ -238,8 +246,9 @@ class_restrict(char *class_name,
  */
 
 Code_t
-class_setup_restricted(char *class_name,
-                      Acl *acl)
+class_setup_restricted(class_name, acl)
+    char *class_name;
+    Acl *acl;
 {
     Triplet *triplet;
     String *d;
@@ -261,7 +270,7 @@ class_setup_restricted(char *class_name,
     if (!triplet)
        return ENOMEM;
     triplet->acl = acl;
-    Triplet_insert(&triplet_bucket[hashval], triplet);
+    LIST_INSERT(&triplet_bucket[hashval], triplet);
     return ZERR_NONE;
 }
 
@@ -270,11 +279,11 @@ class_setup_restricted(char *class_name,
 /* allocate space for a class structure */
 
 static Triplet *
-triplet_alloc(String *classname,
-             String *inst,
-             String *recipient)
+triplet_alloc(classname,inst,recipient)
+    String *classname, *inst, *recipient;
 {
     Triplet *triplet;
+    Client *clist;
 
     triplet = (Triplet *) malloc(sizeof(Triplet));
     if (!triplet)
@@ -292,9 +301,10 @@ triplet_alloc(String *classname,
 /* insert a client into the list associated with the class *ptr */
 
 static Code_t
-insert_client(Triplet *triplet,
-             Client *client,
-             ZRealm *realm)
+insert_client(triplet, client, realm)
+    Triplet *triplet;
+    Client *client;
+    Realm *realm;
 {
     Client **clientp, **newclients;
     int new_size;
@@ -335,10 +345,10 @@ insert_client(Triplet *triplet,
  * collecting if appropriate
  */
 
-static Code_t
-remove_client(Triplet *triplet,
-             Client *client,
-             ZRealm *realm)
+static Code_t remove_client(triplet, client, realm)
+    Triplet *triplet;
+    Client *client;
+    Realm *realm;
 {
     Client **clientp;
 
@@ -353,8 +363,8 @@ remove_client(Triplet *triplet,
     return ZSRV_BADASSOC;
 }
 
-static void
-free_triplet(Triplet *triplet)
+static void free_triplet(triplet)
+    Triplet *triplet;
 {
     if (triplet->clients)
        free(triplet->clients);
@@ -364,8 +374,8 @@ free_triplet(Triplet *triplet)
     free(triplet);
 }
 
-void
-triplet_dump_subs(FILE *fp)
+void triplet_dump_subs(fp)
+    FILE *fp;
 {
     int i;
     Triplet *triplet;
index 56c5190ee5e99f682ad6e20a753866dd7fe07be8..85918e7927b6965c382ee0691efd788523656e1e 100644 (file)
@@ -59,17 +59,21 @@ static Client *client_bucket[HASHSIZE];
                                htons((unsigned short) (port))) % HASHSIZE)
 
 Code_t
-client_register(ZNotice_t *notice,
-               struct in_addr *host,
-               Client **client_p,
-               int wantdefaults)
+client_register(notice, host, client_p, wantdefaults)
+    ZNotice_t *notice;
+    struct in_addr *host;
+    Client **client_p;
+    int wantdefaults;
 {
     Client *client;
+    Code_t retval;
 
     /* chain the client's host onto this server's host list */
 
+#if 1
     zdbug((LOG_DEBUG, "client_register: adding %s at %s/%d",
           notice->z_sender, inet_ntoa(*host), ntohs(notice->z_port)));
+#endif
 
     if (!notice->z_port)
        return ZSRV_BADSUBPORT;
@@ -80,12 +84,8 @@ client_register(ZNotice_t *notice,
        if (!client)
            return ENOMEM;
        memset(&client->addr, 0, sizeof(struct sockaddr_in));
-#ifdef HAVE_KRB5
-        client->session_keyblock = NULL;
-#else
-#ifdef HAVE_KRB4
+#ifdef KERBEROS
        memset(&client->session_key, 0, sizeof(client->session_key));
-#endif
 #endif
        client->last_send = 0;
        client->last_ack = NOW;
@@ -95,8 +95,8 @@ client_register(ZNotice_t *notice,
        client->subs = NULL;
        client->realm = NULL;
        client->principal = make_string(notice->z_sender, 0);
-       Client_insert(&client_bucket[INET_HASH(&client->addr.sin_addr,
-                                              notice->z_port)], client);
+       LIST_INSERT(&client_bucket[INET_HASH(&client->addr.sin_addr,
+                                            notice->z_port)], client);
     }
 
     /* Add default subscriptions only if this is not resulting from a brain
@@ -114,24 +114,22 @@ client_register(ZNotice_t *notice,
  */
 
 void
-client_deregister(Client *client,
-                 int flush)
+client_deregister(client, flush)
+    Client *client;
+    int flush;
 {
-    Client_delete(client);
+    LIST_DELETE(client);
     nack_release(client);
     subscr_cancel_client(client);
     free_string(client->principal);
-#ifdef HAVE_KRB5
-    if (client->session_keyblock)
-         krb5_free_keyblock(Z_krb5_ctx, client->session_keyblock);
-#endif
     if (flush)
        uloc_flush_client(&client->addr);
     free(client);
 }
 
 void
-client_flush_host(struct in_addr *host)
+client_flush_host(host)
+    struct in_addr *host;
 {
     int i;
     Client *client, *next;
@@ -147,7 +145,7 @@ client_flush_host(struct in_addr *host)
 }
 
 Code_t
-client_send_clients(void)
+client_send_clients()
 {
     int i;
     Client *client;
@@ -180,7 +178,8 @@ client_send_clients(void)
  */
 
 void
-client_dump_clients(FILE *fp)
+client_dump_clients(fp)
+    FILE *fp;
 {
     Client *client;
     int i;
@@ -199,8 +198,9 @@ client_dump_clients(FILE *fp)
  */
 
 Client *
-client_find(struct in_addr *host,
-           unsigned int port)
+client_find(host, port)
+    struct in_addr *host;
+    unsigned int port;
 {
     Client *client;
     long hashval;
index fd44f38a9759599ee9ec0bb1f5b0c24957cf7808..b668ef8e7052dd91ad7c672866a5b5e1dfe6f751 100644 (file)
@@ -25,22 +25,25 @@ static const char rcsid_common_c[] =
 /* copy a string into a newly allocated area */
 
 char *
-strsave (const char *sp)
+strsave (sp)
+    const char *sp;
 {
     char *ret;
 
-    ret = strdup(sp);
+    ret = (char *) malloc(strlen(sp) + 1);
     if (!ret) {
        syslog(LOG_CRIT, "no mem strdup'ing");
        abort();
     }
+    strcpy(ret, sp);
     return ret;
 }
 
 /* The "& 0x5f" provides case-insensitivity for ASCII. */
 
 unsigned long
-hash(const char *string)
+hash(string)
+    const char *string;
 {
     unsigned long hval = 0;
     char cp;
@@ -79,7 +82,9 @@ hash(const char *string)
 }
 
 /* Output a name, replacing newlines with \n and single quotes with \q. */
-void dump_quote(char *p, FILE *fp)
+void dump_quote(p, fp)
+    char *p;
+    FILE *fp;
 {
     for (; *p; p++) {
        if (*p == '\'') {
index cd7ac7948a3a1b32d29ae07f322e9fbed97158e9..fa8f2ce2dca1c3cb17802b0f6cc5f4cde66d85de 100644 (file)
@@ -14,7 +14,6 @@
 #include <zephyr/mit-copyright.h>
 #include "zserver.h"
 #include <sys/socket.h>
-#include <com_err.h>
 
 #ifndef lint
 #ifndef SABER
@@ -32,7 +31,7 @@ static const char rcsid_dispatch_c[] =
 #define HOSTS_SIZE_INIT                        256
 
 #ifdef DEBUG
-const char *ZNoticeKinds[9] = {"UNSAFE", "UNACKED", "ACKED", "HMACK",
+ZCONST char *ZNoticeKinds[9] = {"UNSAFE", "UNACKED", "ACKED", "HMACK",
                                    "HMCTL", "SERVACK", "SERVNAK", "CLIENTACK",
                                    "STAT"};
 #endif
@@ -95,7 +94,8 @@ static struct in_addr *hosts;
 static int hosts_size = 0, num_hosts = 0;
 
 static void
-dump_stats (void *arg)
+dump_stats (arg)
+    void *arg;
 {
     syslog(LOG_INFO, "stats: %s: %d", hm_packets.str, hm_packets.val);
     syslog(LOG_INFO, "stats: %s: %d", control_notices.str,
@@ -123,7 +123,7 @@ dump_stats (void *arg)
  */
 
 void
-handle_packet(void)
+handle_packet()
 {
     Code_t status;
     ZPacket_t input_packet;    /* from the network */
@@ -134,7 +134,7 @@ handle_packet(void)
     int authentic;             /* authentic flag */
     Pending *pending;          /* pending packet */
     int from_server;           /* packet is from another server */
-    ZRealm *realm;             /* foreign realm ptr */
+    Realm *realm;              /* foreign realm ptr */
 #ifdef DEBUG
     static int first_time = 1;
 #endif
@@ -150,7 +150,9 @@ handle_packet(void)
 
     if (otherservers[me_server_idx].queue) {
        /* something here for me; take care of it */
+#if 1
        zdbug((LOG_DEBUG, "internal queue process"));
+#endif
 
        pending = server_dequeue(me_server);
 
@@ -197,11 +199,10 @@ handle_packet(void)
         if (new_notice.z_kind == SERVACK || new_notice.z_kind == SERVNAK) {
           authentic = ZAUTH_YES;
         } else {
-         realm = realm_which_realm(&input_sin);
-          if (realm) {
+          if (realm = realm_which_realm(&input_sin)) {
             authentic = ZCheckRealmAuthentication(&new_notice,
-                                                      &input_sin,
-                                                      realm->name);
+                                                  &input_sin,
+                                                  realm->name);
           } else 
            authentic = ZCheckAuthentication(&new_notice, &input_sin);
        }
@@ -213,8 +214,7 @@ handle_packet(void)
         if (new_notice.z_kind == SERVACK || new_notice.z_kind == SERVNAK) {
           authentic = ZAUTH_YES;
         } else {
-         realm = realm_which_realm(&whoisit);
-          if (realm) {
+          if (realm = realm_which_realm(&whoisit)) {
             authentic = ZCheckRealmAuthentication(&new_notice,
                                                   &whoisit,
                                                   realm->name);
@@ -223,6 +223,15 @@ handle_packet(void)
        }
     }
 
+    if (whoisit.sin_port != hm_port && whoisit.sin_port != hm_srv_port &&
+       strcasecmp(new_notice.z_class, ZEPHYR_ADMIN_CLASS) != 0 &&
+       whoisit.sin_port != srv_addr.sin_port &&
+       new_notice.z_kind != CLIENTACK) {
+       syslog(LOG_ERR, "bad port %s/%d", inet_ntoa(whoisit.sin_addr),
+              ntohs(whoisit.sin_port));
+       return;
+    }
+
     message_notices.val++;
     dispatch(&new_notice, authentic, &whoisit, from_server);
     return;
@@ -232,16 +241,17 @@ handle_packet(void)
  */
 
 static void
-dispatch(ZNotice_t *notice,
-        int auth,
-        struct sockaddr_in *who,
-        int from_server)
+dispatch(notice, auth, who, from_server)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    int from_server;
 {
     Code_t status;
     String *notice_class;
     struct sockaddr_in who2;
     int authflag;
-    ZRealm *realm;
+    Realm *realm;
     char *cp;
 #ifdef DEBUG
     char dbg_buf[BUFSIZ];
@@ -255,6 +265,16 @@ dispatch(ZNotice_t *notice,
               inet_ntoa(who->sin_addr));
        return;
     }
+#if 0
+    if (zdebug) {
+       syslog(LOG_DEBUG,
+               "disp:%s '%s' '%s' '%s' notice to '%s' from '%s' %s/%d/%d",
+               ZNoticeKinds[(int) notice->z_kind], notice->z_class,
+               notice->z_class_inst, notice->z_opcode, notice->z_recipient,
+               notice->z_sender, inet_ntoa(who->sin_addr),
+               ntohs(who->sin_port), ntohs(notice->z_port));
+    }
+#endif
 
     if (notice->z_kind == CLIENTACK) {
        nack_cancel(notice, who);
@@ -262,7 +282,11 @@ dispatch(ZNotice_t *notice,
     }
 
     who2 = *who;
-
+#if 0
+    if (0 && from_server) {
+       /* incorporate server_dispatch here */
+    }
+#endif
     notice_class = make_string(notice->z_class,1);
 
     if (from_server) {
@@ -314,10 +338,11 @@ dispatch(ZNotice_t *notice,
  */
 
 void
-sendit(ZNotice_t *notice,
-       int auth,
-       struct sockaddr_in *who,
-       int external)
+sendit(notice, auth, who, external)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    int external;
 {
     static int send_counter = 0;
     char recipbuf[ANAME_SZ + INST_SZ + REALM_SZ + 3], *recipp;
@@ -328,7 +353,7 @@ sendit(ZNotice_t *notice,
 
     class = make_string(notice->z_class, 1);
     if (realm_bound_for_realm(ZGetRealm(), notice->z_recipient)) {
-      ZRealm *rlm;
+      Realm *rlm;
 
       acl = class_get_acl(class);
       if (acl != NULL) {
@@ -370,6 +395,34 @@ sendit(ZNotice_t *notice,
        }
       }
     }
+    if (!realm_which_realm(who)) {
+       if (memcmp(&notice->z_sender_addr.s_addr, &who->sin_addr.s_addr,
+                  sizeof(notice->z_sender_addr.s_addr))) {
+           /* someone is playing games... */
+           /* inet_ntoa returns pointer to static area */
+           /* max size is 255.255.255.255 */
+           char buffer[16];
+           strcpy(buffer, inet_ntoa(who->sin_addr));
+           if (!auth) {
+               syslog(LOG_WARNING,
+                      "sendit unauthentic fake packet: claimed %s, real %s",
+                      inet_ntoa(notice->z_sender_addr), buffer);
+               clt_ack(notice, who, AUTH_FAILED);
+               free_string(class);
+               return;
+           }
+           if (ntohl(notice->z_sender_addr.s_addr) != 0) {
+               syslog(LOG_WARNING,
+                      "sendit invalid address: claimed %s, real %s",
+                      inet_ntoa(notice->z_sender_addr), buffer);
+               clt_ack(notice, who, AUTH_FAILED);
+               free_string(class);
+               return;
+           }
+           syslog(LOG_WARNING, "sendit addr mismatch: claimed %s, real %s",
+                  inet_ntoa(notice->z_sender_addr), buffer);
+       }
+    }
 
     /* Increment the send counter, used to prevent duplicate sends to
      * clients.  On the off-chance that we wrap around to 0, skip over
@@ -418,11 +471,12 @@ sendit(ZNotice_t *notice,
  */
 
 static int
-send_to_dest(ZNotice_t *notice,
-            int auth,
-            Destination *dest,
-            int send_counter,
-            int external)
+send_to_dest(notice, auth, dest, send_counter, external)
+    ZNotice_t *notice;
+    int auth;
+    Destination *dest;
+    int send_counter;
+    int external;
 {
     Client **clientp;
     int any = 0;
@@ -455,7 +509,8 @@ send_to_dest(ZNotice_t *notice,
  */
 
 void
-nack_release(Client *client)
+nack_release(client)
+    Client *client;
 {
     int i;
     Unacked *nacked, *next;
@@ -465,7 +520,7 @@ nack_release(Client *client)
            next = nacked->next;
            if (nacked->client == client) {
                timer_reset(nacked->timer);
-               Unacked_delete(nacked);
+               LIST_DELETE(nacked);
                free(nacked->packet);
                free(nacked);
            }
@@ -481,16 +536,17 @@ nack_release(Client *client)
 /* the arguments must be the same as the arguments to Z_XmitFragment */
 /*ARGSUSED*/
 Code_t
-xmit_frag(ZNotice_t *notice,
-         char *buf,
-         int len,
-         int waitforack)
+xmit_frag(notice, buf, len, waitforack)
+    ZNotice_t *notice;
+    char *buf;
+    int len;
+    int waitforack;
 {
     struct sockaddr_in sin;
     char *savebuf;
     Unacked *nacked;
     Code_t retval;
-    int sendfail = 0;
+    int hashval, sendfail = 0;
 
     retval = ZSendPacket(buf, len, 0);
     if (retval != ZERR_NONE) {
@@ -526,27 +582,31 @@ xmit_frag(ZNotice_t *notice,
     nacked->packsz = len;
     nacked->uid = notice->z_uid;
     nacked->timer = timer_set_rel(rexmit_times[0], rexmit, nacked);
-    Unacked_insert(&nacktab[NACKTAB_HASHVAL(sin, nacked->uid)], nacked);
+    LIST_INSERT(&nacktab[NACKTAB_HASHVAL(sin, nacked->uid)], nacked);
     return(ZERR_NONE);
 }
 
-
 /*
  * Send the notice to the client.  After transmitting, put it onto the
  * not ack'ed list.
  */
 
 void
-xmit(ZNotice_t *notice,
-     struct sockaddr_in *dest,
-     int auth,
-     Client *client)
+xmit(notice, dest, auth, client)
+    ZNotice_t *notice;
+    struct sockaddr_in *dest;
+    int auth;
+    Client *client;
 {
     char *noticepack;
     Unacked *nacked;
     int packlen, sendfail = 0;
     Code_t retval;
 
+#if 0
+    zdbug((LOG_DEBUG,"xmit"));
+#endif
+
     noticepack = (char *) malloc(sizeof(ZPacket_t));
     if (!noticepack) {
        syslog(LOG_ERR, "xmit malloc");
@@ -559,23 +619,14 @@ xmit(ZNotice_t *notice,
                                   we are distributing authentic and
                                   we have a pointer to auth info
                                   */
-#ifdef HAVE_KRB5
-         retval = ZFormatAuthenticNoticeV5(notice, noticepack, packlen,
-                                           &packlen, client->session_keyblock);
-         if (retval != ZERR_NONE) {
-              syslog(LOG_ERR, "xmit auth format: %s", error_message(retval));
-              free(noticepack);
-              return;
-         }
-#else
-#if defined(HAVE_KRB4)
-         retval = ZFormatAuthenticNotice(notice, noticepack, packlen,
-                                           &packlen, client->session_key);
-         if (retval != ZERR_NONE) {
-              syslog(LOG_ERR, "xmit auth format: %s", error_message(retval));
-              free(noticepack);
-              return;
-         }
+#ifdef HAVE_KRB4
+       retval = ZFormatAuthenticNotice(notice, noticepack, packlen, &packlen,
+                                       client->session_key);
+       if (retval != ZERR_NONE) {
+           syslog(LOG_ERR, "xmit auth format: %s", error_message(retval));
+           free(noticepack);
+           return;
+       }
 #else /* !HAVE_KRB4 */
        notice->z_auth = 1;
        retval = ZFormatSmallRawNotice(notice, noticepack, &packlen);
@@ -585,7 +636,6 @@ xmit(ZNotice_t *notice,
            return;
        }
 #endif /* HAVE_KRB4 */
-#endif /* HAVE_KRB5 */
     } else {
        notice->z_auth = 0;
        notice->z_authent_len = 0;
@@ -597,10 +647,10 @@ xmit(ZNotice_t *notice,
          * same thing with authentic Zephyrs.
          */
         if (retval == ZERR_PKTLEN) {
-          ZNotice_t partnotice;
+          ZNotice_t partnotice, newnotice;
           char multi[64];
           char *buffer, *ptr;
-          int buffer_len, hdrlen, offset, fragsize, message_len;
+          int buffer_len, hdrlen, offset, fragsize, ret_len, message_len;
           int origoffset, origlen;
 
           free(noticepack);
@@ -650,7 +700,7 @@ xmit(ZNotice_t *notice,
             (void) sprintf(multi, "%d/%d", offset+origoffset, origlen);
             partnotice.z_multinotice = multi;
             if (offset > 0) {
-              (void) Z_gettimeofday(&partnotice.z_uid.tv, (struct timezone *)0);
+              (void) gettimeofday(&partnotice.z_uid.tv, (struct timezone *)0);
               partnotice.z_uid.tv.tv_sec = htonl((u_long)
                                                  partnotice.z_uid.tv.tv_sec);
               partnotice.z_uid.tv.tv_usec = htonl((u_long)
@@ -695,6 +745,10 @@ xmit(ZNotice_t *notice,
            return;                     /* DON'T put on nack list */
        }
     }
+#if 0
+    zdbug((LOG_DEBUG," to %s/%d", inet_ntoa(dest->sin_addr),
+          ntohs(dest->sin_port)));
+#endif
     retval = ZSetDestAddr(dest);
     if (retval != ZERR_NONE) {
        syslog(LOG_WARNING, "xmit set addr: %s", error_message(retval));
@@ -729,7 +783,7 @@ xmit(ZNotice_t *notice,
     nacked->packsz = packlen;
     nacked->uid = notice->z_uid;
     nacked->timer = timer_set_rel(rexmit_times[0], rexmit, nacked);
-    Unacked_insert(&nacktab[NACKTAB_HASHVAL(*dest, nacked->uid)], nacked);
+    LIST_INSERT(&nacktab[NACKTAB_HASHVAL(*dest, nacked->uid)], nacked);
 }
 
 /*
@@ -739,14 +793,17 @@ xmit(ZNotice_t *notice,
  */
 
 void
-rexmit(void *arg)
+rexmit(arg)
+    void *arg;
 {
     Unacked *nacked = (Unacked *) arg;
     int retval;
 
+#if 1
     syslog(LOG_DEBUG, "rexmit %s/%d #%d time %d",
           inet_ntoa(nacked->dest.addr.sin_addr),
-          ntohs(nacked->dest.addr.sin_port), nacked->rexmits + 1, (int)NOW);
+          ntohs(nacked->dest.addr.sin_port), nacked->rexmits + 1, NOW);
+#endif
 
     nacked->rexmits++;
     if (rexmit_times[nacked->rexmits] == -1) {
@@ -758,7 +815,7 @@ rexmit(void *arg)
             * nack list before calling client_deregister(), which
             * scans the nack list.)
             */
-           Unacked_delete(nacked);
+           LIST_DELETE(nacked);
            if (nacked->client) {
                server_kill_clt(nacked->client);
                client_deregister(nacked->client, 1);
@@ -774,6 +831,10 @@ rexmit(void *arg)
     }
 
     /* retransmit the packet */
+#if 0
+    zdbug((LOG_DEBUG," to %s/%d", inet_ntoa(nacked->dest.addr.sin_addr),
+          ntohs(nacked->dest.addr.sin_port)));
+#endif
     retval = ZSetDestAddr(&nacked->dest.addr);
     if (retval != ZERR_NONE) {
        syslog(LOG_WARNING, "rexmit set addr: %s", error_message(retval));
@@ -799,18 +860,22 @@ rexmit(void *arg)
  */
 
 void
-clt_ack(ZNotice_t *notice,
-       struct sockaddr_in *who,
-       Sent_type sent)
+clt_ack(notice, who, sent)
+    ZNotice_t *notice;
+    struct sockaddr_in *who;
+    Sent_type sent;
 {
     ZNotice_t acknotice;
     ZPacket_t ackpack;
     int packlen;
+    int notme = 0;
     char *sent_name;
     Code_t retval;
 
     if (bdumping) {            /* don't ack while dumping */
+#if 1
        zdbug((LOG_DEBUG,"bdumping, no ack"));
+#endif
        return;
     }
 
@@ -840,6 +905,12 @@ clt_ack(ZNotice_t *notice,
        abort ();
     }
 
+#if 0
+    zdbug((LOG_DEBUG,"clt_ack type %s for %d to %s/%d", sent_name,
+          ntohs(notice->z_port), inet_ntoa(who->sin_addr),
+          ntohs(who->sin_port)));
+#endif
+
     acknotice.z_multinotice = "";
 
     /* leave room for the trailing null */
@@ -885,13 +956,19 @@ clt_ack(ZNotice_t *notice,
  */
 
 static void
-nack_cancel(ZNotice_t *notice,
-           struct sockaddr_in *who)
+nack_cancel(notice, who)
+    ZNotice_t *notice;
+    struct sockaddr_in *who;
 {
     Unacked *nacked;
     int hashval;
 
     /* search the not-yet-acked table for this packet, and flush it. */
+#if 0
+    zdbug((LOG_DEBUG, "nack_cancel: %s:%08X,%08X",
+          inet_ntoa(notice->z_uid.zuid_addr),
+          notice->z_uid.tv.tv_sec, notice->z_uid.tv.tv_usec));
+#endif
     hashval = NACKTAB_HASHVAL(*who, notice->z_uid);
     for (nacked = nacktab[hashval]; nacked; nacked = nacked->next) {
        if (nacked->dest.addr.sin_addr.s_addr == who->sin_addr.s_addr
@@ -901,15 +978,17 @@ nack_cancel(ZNotice_t *notice,
                nacked->client->last_ack = NOW;
            timer_reset(nacked->timer);
            free(nacked->packet);
-           Unacked_delete(nacked);
+           LIST_DELETE(nacked);
            free(nacked);
            return;
        }
     }
 
+#if 1
     zdbug((LOG_DEBUG,"nack_cancel: nack not found %s:%08X,%08X",
           inet_ntoa (notice->z_uid.zuid_addr),
           notice->z_uid.tv.tv_sec, notice->z_uid.tv.tv_usec));
+#endif
 }
 
 /* for compatibility when sending subscription information to old clients */
@@ -920,18 +999,28 @@ nack_cancel(ZNotice_t *notice,
 /* Dispatch an HM_CTL notice. */
 
 Code_t
-hostm_dispatch(ZNotice_t *notice,
-              int auth,
-              struct sockaddr_in *who,
-              Server *server)
+hostm_dispatch(notice, auth, who, server)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Server *server;
 {
+    Server *owner;
     char *opcode = notice->z_opcode;
+    Code_t retval;
     int i, add = 0, remove = 0;
 
+#if 0
+    zdbug((LOG_DEBUG,"hm_disp"));
+#endif
+
     if (notice->z_kind == HMACK) {
        /* Ignore. */
        ;
     } else if (notice->z_kind != HMCTL) {
+#if 0
+       zdbug((LOG_DEBUG, "bogus HM packet"));
+#endif
        clt_ack(notice, who, AUTH_FAILED);
     } else if (strcmp(opcode, HM_FLUSH) == 0) {
        client_flush_host(&who->sin_addr);
@@ -996,16 +1085,17 @@ hostm_dispatch(ZNotice_t *notice,
  */
 
 Code_t
-control_dispatch(ZNotice_t *notice,
-                int auth,
-                struct sockaddr_in *who,
-                Server *server)
+control_dispatch(notice, auth, who, server)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Server *server;
 {
     char *opcode = notice->z_opcode;
     Client *client;
     Code_t retval;
     int wantdefs;
-    ZRealm *realm;
+    Realm *realm;
     struct sockaddr_in newwho;
 
     /*
@@ -1043,6 +1133,9 @@ control_dispatch(ZNotice_t *notice,
        subscr_sendlist(notice, auth, who);
        return ZERR_NONE;
     } else if (!auth) {
+#if 0
+       zdbug((LOG_DEBUG,"unauth ctrl_disp"));
+#endif
        if (server == me_server)
            clt_ack(notice, who, AUTH_FAILED);
        return ZERR_NONE;
@@ -1070,27 +1163,9 @@ control_dispatch(ZNotice_t *notice,
                clt_ack(notice, who, AUTH_FAILED);
            return ZERR_NONE;
        }
-#ifdef HAVE_KRB5
-        if (client->session_keyblock) {
-             krb5_free_keyblock_contents(Z_krb5_ctx, client->session_keyblock);
-             retval = krb5_copy_keyblock_contents(Z_krb5_ctx, ZGetSession(),
-                                         client->session_keyblock);
-        } else {
-             retval = krb5_copy_keyblock(Z_krb5_ctx, ZGetSession(), 
-                                &client->session_keyblock);
-        }
-        if (retval) {
-             syslog(LOG_WARNING, "keyblock copy failed in subscr: %s",
-                    error_message(retval));
-             if (server == me_server)
-                  nack(notice, who);
-             return ZERR_NONE;
-        }
-#else
 #ifdef HAVE_KRB4
        /* in case it's changed */
        memcpy(client->session_key, ZGetSession(), sizeof(C_Block));
-#endif
 #endif
        retval = subscr_subscribe(client, notice, server);
        if (retval != ZERR_NONE) {
@@ -1108,6 +1183,19 @@ control_dispatch(ZNotice_t *notice,
                    clt_ack(notice, who, AUTH_FAILED);
                return ZERR_NONE;
            }
+#if 0
+           if (zdebug) {
+               if (server == me_server) {
+                   syslog(LOG_DEBUG, "subscription cancel for %s/%d\n",
+                          inet_ntoa(who->sin_addr), ntohs(who->sin_port));
+               } else {
+                   syslog(LOG_DEBUG,
+                          "subscription cancel for %s/%d from %s\n",
+                          inet_ntoa(who->sin_addr), ntohs(who->sin_port),
+                          server->addr_str);
+               }
+           }
+#endif
            subscr_cancel(who, notice);
        } else {
            nack(notice, who);
@@ -1117,6 +1205,9 @@ control_dispatch(ZNotice_t *notice,
        /* canceling subscriptions implies I can punt info about this client */
        client = client_find(&who->sin_addr, notice->z_port);
        if (client == NULL) {
+#if 0
+           zdbug((LOG_DEBUG,"can_sub not found client"));
+#endif
            if (server == me_server)
                nack(notice, who);
            return ZERR_NONE;
@@ -1128,6 +1219,10 @@ control_dispatch(ZNotice_t *notice,
            return ZERR_NONE;
        }
        /* don't flush locations here, let him do it explicitly */
+#if 0
+       zdbug((LOG_DEBUG, "cancelsub clt_dereg %s/%d",
+              inet_ntoa(who->sin_addr), ntohs(who->sin_port)));
+#endif
        client_deregister(client, 0);
     } else {
        syslog(LOG_WARNING, "unknown ctl opcode %s", opcode); 
@@ -1146,7 +1241,7 @@ control_dispatch(ZNotice_t *notice,
 }
 
 void
-hostm_shutdown(void)
+hostm_shutdown()
 {
     int i, s, newserver;
     struct sockaddr_in sin;
@@ -1173,9 +1268,10 @@ hostm_shutdown(void)
 }
 
 void
-realm_shutdown(void)
+realm_shutdown()
 {
     int i, s, newserver;
+    struct sockaddr_in sin;
 
     for (i = 0; i < nservers; i++) {
         if (i != me_server_idx && otherservers[i].state == SERV_UP)
@@ -1197,8 +1293,9 @@ realm_shutdown(void)
 }
 
 static void
-hostm_deathgram(struct sockaddr_in *sin,
-               Server *server)
+hostm_deathgram(sin, server)
+    struct sockaddr_in *sin;
+    Server *server;
 {
     Code_t retval;
     int shutlen;
@@ -1237,7 +1334,7 @@ hostm_deathgram(struct sockaddr_in *sin,
 }
 
 static char *
-hm_recipient(void)
+hm_recipient()
 {
     static char *recipient;
     char *realm;
index 7a8932b619c2cee2baff6de296bff8cc1757ae5e..cd57faae87ecd07389e2da81cc306212edde28e3 100644 (file)
@@ -22,9 +22,32 @@ static const char rcsid_kstuff_c[] = "$Id$";
 
 #ifdef HAVE_KRB4
 
-static ZChecksum_t compute_checksum(ZNotice_t *, C_Block);
-static ZChecksum_t compute_rlm_checksum(ZNotice_t *, C_Block);
-static Code_t ZCheckAuthentication4(ZNotice_t *notice, struct sockaddr_in *from);
+/* Keep a hash table mapping tickets to session keys, so we can do a fast
+ * check of the cryptographic checksum without doing and DES decryptions.
+ * Also remember the expiry time of the ticket, so that we can sweep the
+ * table periodically. */
+
+#define HASHTAB_SIZE 4091
+
+typedef struct hash_entry Hash_entry;
+
+/* The ticket comes at the end, in a variable-length array. */
+struct hash_entry {
+    C_Block session_key;
+    time_t expires;
+    char srcprincipal[ANAME_SZ+INST_SZ+REALM_SZ+4];
+    Hash_entry *next;
+    int ticket_len;
+    unsigned char ticket[1];
+};
+
+Hash_entry *hashtab[HASHTAB_SIZE];
+
+static int hash_ticket __P((unsigned char *, int));
+static void add_session_key __P((KTEXT, C_Block, char *, time_t));
+static int find_session_key __P((KTEXT, C_Block, char *));
+static ZChecksum_t compute_checksum __P((ZNotice_t *, C_Block));
+static ZChecksum_t compute_rlm_checksum __P((ZNotice_t *, C_Block));
 
 /*
  * GetKerberosData
@@ -34,11 +57,12 @@ static Code_t ZCheckAuthentication4(ZNotice_t *notice, struct sockaddr_in *from)
  * the value of rd_ap_req() applied to the ticket.
  */
 int
-GetKerberosData(int fd, /* file descr. to read from */
-               struct in_addr haddr, /* address of foreign host on fd */
-               AUTH_DAT *kdata,        /* kerberos data (returned) */
-               char *service, /* service principal desired */
-               char *srvtab) /* file to get keys from */
+GetKerberosData(fd, haddr, kdata, service, srvtab)
+     int fd; /* file descr. to read from */
+     struct in_addr haddr; /* address of foreign host on fd */
+     AUTH_DAT *kdata;  /* kerberos data (returned) */
+     char *service; /* service principal desired */
+     char *srvtab; /* file to get keys from */
 {
     char p[20];
     KTEXT_ST ticket;           /* will get Kerberos ticket from client */
@@ -89,16 +113,12 @@ GetKerberosData(int fd, /* file descr. to read from */
  * get the ticket and write it to the file descriptor
  */
 
-#if !defined(krb_err_base) && defined(ERROR_TABLE_BASE_krb)
-#define krb_err_base ERROR_TABLE_BASE_krb
-#endif
-
 Code_t
-SendKerberosData(int fd,       /* file descriptor to write onto */
-                KTEXT ticket,  /* where to put ticket (return) */
-                char *service, /* service name, foreign host */
-                char *host)
-                
+SendKerberosData(fd, ticket, service, host)
+     int fd;           /* file descriptor to write onto */
+     KTEXT ticket;     /* where to put ticket (return) */
+     char *service;    /* service name, foreign host */
+     char *host;
 {
     int rem;
     char p[32];
@@ -122,155 +142,21 @@ SendKerberosData(int fd, /* file descriptor to write onto */
 
 #endif /* HAVE_KRB4 */
 
-#if defined(HAVE_KRB5) || defined(HAVE_KRB4)
 Code_t
-ReadKerberosData(int fd, int *size, char **data, int *proto) {
-    char p[20];
-    int i;
-    char *dst;
-    int len = 0;
-
-    for (i=0; i<20; i++) {
-       if (read(fd, &p[i], 1) != 1) {
-           p[i] = 0;
-           syslog(LOG_WARNING,"ReadKerberosData: bad read reply len @%d (got \"%s\"", i, p);
-           return(KFAILURE);
-       }
-       if (p[i] == ' ') {
-           p[i] = '\0';
-           break;
-       }
-    }
-
-    if (i == 20) {
-       syslog(LOG_WARNING, "ReadKerberosData: read reply len exceeds buffer");
-           return KFAILURE;
-    }
-
-    if (!strncmp(p, "V5-", 3) && (len = atoi(p+3)) > 0)
-       *proto = 5;
-    else if ((len = atoi(p)) > 0)
-       *proto = 4;
-
-    if ((*proto < 4) | (*proto > 5)) {
-       syslog(LOG_WARNING, "ReadKerberosData: error parsing authenticator length (\"%s\")", p);
-       return KFAILURE;
-    }
-
-    if (len <= 0) {
-       syslog(LOG_WARNING, "ReadKerberosData: read reply len = %d", len);
-       return KFAILURE;
-    }
-
-    *data = malloc(len);
-    if (! *data) {
-       syslog(LOG_WARNING, "ReadKerberosData: failure allocating %d bytes: %m", len);
-       return errno;
-    }
-    
-    dst=*data;
-    for (i=0; i < len; i++) {
-       if (read(fd, dst++, 1) != 1) {
-            free(*data);
-           *data = NULL;
-           *size = 0;
-            syslog(LOG_WARNING,"ReadKerberosData: bad read reply string");
-            return ZSRV_PKSHORT;
-        }
-    }
-    *size = len;
-    return 0;
-}
-#endif
-
-#ifdef HAVE_KRB5
-Code_t
-GetKrb5Data(int fd, krb5_data *data) {
-    char p[20];
-    int i;
-    char *dst;
-
-    for (i=0; i<20; i++) {
-       if (read(fd, &p[i], 1) != 1) {
-           p[i] = 0;
-           syslog(LOG_WARNING,"bad read reply len @%d (got \"%s\")", i, p);
-           return(KFAILURE);
-       }
-       if (p[i] == ' ') {
-           p[i] = '\0';
-           break;
-       }
-    }
-    if (i == 20 || strncmp(p, "V5-", 3) || !atoi(p+3)) {
-        syslog(LOG_WARNING,"bad reply len");
-        return ZSRV_PKSHORT;
-    }
-    data->length = atoi(p+3);
-    data->data = malloc(data->length);
-    if (! data->data) {
-       data->length = 0;
-       return errno;
-    }
-    dst=data->data;
-    for (i=0; i < data->length; i++) {
-       if (read(fd, dst++, 1) != 1) {
-            free(data->data);
-            memset((char *)data, 0, sizeof(krb5_data));
-            syslog(LOG_WARNING,"bad read reply string");
-            return ZSRV_PKSHORT;
-        }
-    }
-    return 0;
-}
-
-Code_t
-SendKrb5Data(int fd, krb5_data *data) {
-    char p[32];
-    int written, size_to_write;
-    sprintf(p, "V5-%d ", data->length);
-    size_to_write = strlen (p);
-    if (size_to_write != (written = write(fd, p, size_to_write)) ||
-        data->length != (written = write(fd, data->data, data->length))) {
-        return (written < 0) ? errno : ZSRV_PKSHORT; 
-    }    
-    return 0;
-}
-#endif
-
-Code_t
-ZCheckRealmAuthentication(ZNotice_t *notice,
-                         struct sockaddr_in *from,
-                         char *realm)
+ZCheckRealmAuthentication(notice, from, realm)
+    ZNotice_t *notice;
+    struct sockaddr_in *from;
+    char *realm;
 {       
-#ifdef HAVE_KRB5
-    char *authbuf;
-    char rlmprincipal[ANAME_SZ+INST_SZ+REALM_SZ+4+1024];
-    krb5_principal princ;
-    krb5_data packet;
-    krb5_ticket *tkt;
-    char *name;
-    krb5_error_code result;
-    krb5_principal server;
-    krb5_keytab keytabid = 0;
-    krb5_auth_context authctx;
-    krb5_keyblock *keyblock; 
-    krb5_enctype enctype; 
-    krb5_cksumtype cksumtype; 
-    krb5_data cksumbuf;
-    int valid;
-    char *cksum0_base, *cksum1_base, *cksum2_base; 
-    char *x; 
-    unsigned char *asn1_data;
-    unsigned char *key_data; 
-    int asn1_len, key_len, cksum0_len, cksum1_len, cksum2_len; 
-#ifdef KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER
-    krb5_authenticator *authenticator;
-#define KRB5AUTHENT authenticator
-#else
-    krb5_authenticator authenticator;
-#define KRB5AUTHENT &authenticator
-#endif
-    int len;
+#ifdef HAVE_KRB4
+    int result;
+    char rlmprincipal[ANAME_SZ+INST_SZ+REALM_SZ+4];
+    char srcprincipal[ANAME_SZ+INST_SZ+REALM_SZ+4];
+    KTEXT_ST authent, ticket;
+    AUTH_DAT dat;
+    ZChecksum_t checksum;
+    CREDENTIALS cred;
+    C_Block session_key;
 
     if (!notice->z_auth)
         return ZAUTH_NO;
@@ -279,545 +165,62 @@ ZCheckRealmAuthentication(ZNotice_t *notice,
     if (notice->z_authent_len <= 0)
         return ZAUTH_FAILED;
 
-    len = strlen(notice->z_ascii_authent)+1;
-    authbuf = malloc(len);
-
     /* Read in the authentication data. */
-    if (ZReadZcode((unsigned char *)notice->z_ascii_authent, 
-                   (unsigned char *)authbuf,
-                   len, &len) == ZERR_BADFIELD) {
+    if (ZReadAscii(notice->z_ascii_authent, 
+                   strlen(notice->z_ascii_authent)+1, 
+                   (unsigned char *)authent.dat, 
+                   notice->z_authent_len) == ZERR_BADFIELD) {
         return ZAUTH_FAILED;
     }
+    authent.length = notice->z_authent_len;
 
-    (void) sprintf(rlmprincipal, "%s/%s@%s", SERVER_SERVICE,
+    (void) sprintf(rlmprincipal, "%s.%s@%s", SERVER_SERVICE,
                    SERVER_INSTANCE, realm);
 
-    packet.length = len;
-    packet.data = authbuf;
-
-    result = krb5_kt_resolve(Z_krb5_ctx, 
-                        keytab_file, &keytabid);
-    if (result) {
-      free(authbuf);
-      return (result);
-    }
-
-    /* HOLDING: authbuf, keytabid */
-    /* Create the auth context */
-    result = krb5_auth_con_init(Z_krb5_ctx, &authctx);
-    if (result) {
-        krb5_kt_close(Z_krb5_ctx, keytabid);
-        free(authbuf);
-        return (result);
-    }
-
-    /* HOLDING: authbuf, authctx */
-    result = krb5_build_principal(Z_krb5_ctx, &server, strlen(__Zephyr_realm), 
-                                 __Zephyr_realm, SERVER_SERVICE, 
-                                 SERVER_INSTANCE, NULL);
-    if (!result) {
-        result = krb5_rd_req(Z_krb5_ctx, &authctx, &packet, server, 
-                             keytabid, 0, &tkt);
-       krb5_free_principal(Z_krb5_ctx, server);
-    }
-    krb5_kt_close(Z_krb5_ctx, keytabid);
-
-    if (result) {
-      if (result == KRB5KRB_AP_ERR_REPEAT)
-       syslog(LOG_DEBUG, "ZCheckRealmAuthentication: k5 auth failed: %s", error_message(result));
-      else
-        syslog(LOG_WARNING,"ZCheckRealmAuthentication: k5 auth failed: %s", error_message(result));
-        free(authbuf);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        return ZAUTH_FAILED;
-    }
-
-    /* HOLDING: authbuf, authctx, tkt */
-    
-    if (tkt == 0 || !Z_tktprincp(tkt)) {
-       if (tkt)
-           krb5_free_ticket(Z_krb5_ctx, tkt);
-       free(authbuf);
-       krb5_auth_con_free(Z_krb5_ctx, authctx);
-       return ZAUTH_FAILED;
-    }
-
-    princ = Z_tktprinc(tkt);
-
-    if (princ == 0) {
-        krb5_free_ticket(Z_krb5_ctx, tkt);
-        free(authbuf);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        return ZAUTH_FAILED;
-    }
-
-    /* HOLDING: authbuf, authctx, tkt */
-    result = krb5_unparse_name(Z_krb5_ctx, princ, &name);
-    if (result) {
-        syslog(LOG_WARNING, "k5 unparse_name failed: %s",
-               error_message(result));
-        free(authbuf);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        krb5_free_ticket(Z_krb5_ctx, tkt);
-        return ZAUTH_FAILED;
-    }
-
-    krb5_free_ticket(Z_krb5_ctx, tkt);
-
-    /* HOLDING: authbuf, authctx, name */
-    if (strcmp(name, rlmprincipal)) {
-        syslog(LOG_WARNING, "k5 name mismatch: '%s' vs '%s'",
-               name, rlmprincipal);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        free(name);
-        free(authbuf);
-        return ZAUTH_FAILED;
-    }
-    free(name);
-    free(authbuf);
-
-    /* HOLDING: authctx */
-    /* Get an authenticator so we can get the keyblock */
-    result = krb5_auth_con_getauthenticator (Z_krb5_ctx, authctx,
-                                            &authenticator);
-    if(result) {
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        return result;
-    }
-
-    /* HOLDING: authctx, authenticator */
-    result = krb5_auth_con_getkey(Z_krb5_ctx, authctx, &keyblock);
-    if (result) {
-      krb5_auth_con_free(Z_krb5_ctx, authctx);
-      krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-      return (ZAUTH_FAILED);
-    }
-    
-    /* HOLDING: authctx, authenticator, keyblock */
-    /* Figure out what checksum type to use */
-    key_data = Z_keydata(keyblock);
-    key_len = Z_keylen(keyblock);
-    result = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
-    if (result) {
-       krb5_free_keyblock(Z_krb5_ctx, keyblock);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-        return (ZAUTH_FAILED);
+    result = krb_rd_req(&authent, SERVER_SERVICE, SERVER_INSTANCE,
+                        from->sin_addr.s_addr, &dat, srvtab_file);
+    if (result == RD_AP_OK) {
+        sprintf(srcprincipal, "%s%s%s@%s", dat.pname, dat.pinst[0] ? "." : "",
+               dat.pinst, dat.prealm);
+        if (strcmp(rlmprincipal, srcprincipal))
+            return ZAUTH_FAILED;
+    } else {
+        return ZAUTH_FAILED;    /* didn't decode correctly */
     }
-    /* HOLDING: authctx, authenticator, keyblock */
-    /* Assemble the things to be checksummed */ 
-    /* first part is from start of packet through z_default_format: 
-     * - z_version 
-     * - z_num_other_fields 
-     * - z_kind 
-     * - z_uid 
-     * - z_port 
-     * - z_auth 
-     * - z_authent_len 
-     * - z_ascii_authent 
-     * - z_class 
-     * - z_class_inst 
-     * - z_opcode 
-     * - z_sender 
-     * - z_recipient 
-     * - z_default_format 
-     */ 
-    cksum0_base = notice->z_packet; 
-    x           = notice->z_default_format; 
-    cksum0_len  = x + strlen(x) + 1 - cksum0_base; 
-    /* second part is from z_multinotice through other fields: 
-     * - z_multinotice 
-     * - z_multiuid 
-     * - z_other_fields[] 
-     */ 
-    cksum1_base = notice->z_multinotice; 
-    if (notice->z_num_other_fields) 
-        x = notice->z_other_fields[notice->z_num_other_fields]; 
-    else 
-        x = cksum1_base + strlen(cksum1_base) + 1; /* multiuid */ 
-    cksum1_len  = x + strlen(x) + 1 - cksum1_base; 
-    /* last part is the message body */ 
-    cksum2_base = notice->z_message; 
-    cksum2_len  = notice->z_message_len; 
-    if ((!notice->z_ascii_checksum || *notice->z_ascii_checksum != 'Z') && 
-        key_len == 8 && 
-        (enctype == ENCTYPE_DES_CBC_CRC || 
-         enctype == ENCTYPE_DES_CBC_MD4 || 
-         enctype == ENCTYPE_DES_CBC_MD5)) { 
-      /* try old-format checksum (covers cksum0 only) */ 
-      ZChecksum_t our_checksum; 
-
-      our_checksum = compute_rlm_checksum(notice, key_data);
-
-      krb5_free_keyblock(Z_krb5_ctx, keyblock);
-      krb5_auth_con_free(Z_krb5_ctx, authctx);
-      krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-      
-      if (our_checksum == notice->z_checksum) { 
-          return ZAUTH_YES; 
-      } else
-         return ZAUTH_FAILED;
-    } 
-
-    /* HOLDING: authctx, authenticator */
-    cksumbuf.length = cksum0_len + cksum1_len + cksum2_len; 
-    cksumbuf.data = malloc(cksumbuf.length); 
-    if (!cksumbuf.data) { 
-        krb5_free_keyblock(Z_krb5_ctx, keyblock);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-        return ZAUTH_FAILED; 
-    } 
-    /* HOLDING: authctx, authenticator, cksumbuf.data */ 
-    memcpy(cksumbuf.data, cksum0_base, cksum0_len); 
-    memcpy(cksumbuf.data + cksum0_len, cksum1_base, cksum1_len); 
-    memcpy(cksumbuf.data + cksum0_len + cksum1_len, 
-           cksum2_base, cksum2_len); 
-    /* decode zcoded checksum */ 
-    /* The encoded form is always longer than the original */ 
-    asn1_len = strlen(notice->z_ascii_checksum) + 1; 
-    asn1_data = malloc(asn1_len); 
-    if (!asn1_data) { 
-        krb5_free_keyblock(Z_krb5_ctx, keyblock);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-        free(cksumbuf.data); 
-        return ZAUTH_FAILED; 
-    } 
-    /* HOLDING: authctx, authenticator, cksumbuf.data, asn1_data */ 
-    result = ZReadZcode((unsigned char *)notice->z_ascii_checksum, 
-                        asn1_data, asn1_len, &asn1_len); 
-    if (result != ZERR_NONE) { 
-        krb5_free_keyblock(Z_krb5_ctx, keyblock);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-        free(asn1_data); 
-        free(cksumbuf.data); 
-        return ZAUTH_FAILED; 
-    } 
-    /* HOLDING: asn1_data, cksumbuf.data */ 
-
-    valid = Z_krb5_verify_cksum(keyblock, &cksumbuf, cksumtype, asn1_data, asn1_len);
-
-    free(asn1_data); 
-    krb5_auth_con_free(Z_krb5_ctx, authctx);
-    krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-    krb5_free_keyblock(Z_krb5_ctx, keyblock);
-    free(cksumbuf.data); 
-    
-    if (valid) 
-        return (ZAUTH_YES); 
-    else 
-        return (ZAUTH_FAILED); 
-#else
-    return (notice->z_auth) ? ZAUTH_YES : ZAUTH_NO;
-#endif
-}
 
-Code_t
-ZCheckAuthentication(ZNotice_t *notice,
-                    struct sockaddr_in *from)
-{       
-#ifdef HAVE_KRB5
-    unsigned char *authbuf;
-    krb5_principal princ;
-    krb5_data packet;
-    krb5_ticket *tkt;
-    char *name;
-    krb5_error_code result;
-    krb5_principal server;
-    krb5_keytab keytabid = 0;
-    krb5_auth_context authctx;
-    krb5_keyblock *keyblock; 
-    krb5_enctype enctype; 
-    krb5_cksumtype cksumtype; 
-    krb5_data cksumbuf;
-    int valid;
-    char *cksum0_base, *cksum1_base, *cksum2_base; 
-    char *x; 
-    unsigned char *asn1_data, *key_data; 
-    int asn1_len, key_len, cksum0_len, cksum1_len, cksum2_len; 
-#ifdef KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER
-    krb5_authenticator *authenticator;
-#define KRB5AUTHENT authenticator
+    /* Check the cryptographic checksum. */
+#ifdef NOENCRYPTION
+    checksum = 0;
 #else
-    krb5_authenticator authenticator;
-#define KRB5AUTHENT &authenticator
+    checksum = compute_rlm_checksum(notice, dat.session);
 #endif
-    int len;
-
-    if (!notice->z_auth)
-        return ZAUTH_NO;
-
-    /* Check for bogus authentication data length. */
-    if (notice->z_authent_len <= 1)
-        return ZAUTH_FAILED;
-
-#ifdef HAVE_KRB4
-    if (notice->z_ascii_authent[0] != 'Z')
-      return ZCheckAuthentication4(notice, from);
+    if (checksum != notice->z_checksum) {
+#ifndef NOENCRYPTION
+      checksum = compute_checksum(notice, dat.session);
+      if (checksum != notice->z_checksum)
 #endif
-    
-    len = strlen(notice->z_ascii_authent)+1;
-    authbuf = malloc(len);
-
-    /* Read in the authentication data. */
-    if (ZReadZcode((unsigned char *)notice->z_ascii_authent, 
-                   authbuf,
-                   len, &len) == ZERR_BADFIELD) {
         return ZAUTH_FAILED;
     }
 
-    packet.length = len;
-    packet.data = (char *)authbuf;
-
-    result = krb5_kt_resolve(Z_krb5_ctx, 
-                        keytab_file, &keytabid);
-    if (result) {
-      free(authbuf);
-      return (result);
-    }
-
-    /* HOLDING: authbuf, keytabid */
-    /* Create the auth context */
-    result = krb5_auth_con_init(Z_krb5_ctx, &authctx);
-    if (result) {
-        krb5_kt_close(Z_krb5_ctx, keytabid);
-        free(authbuf);
-        return (result);
-    }
-
-    /* HOLDING: authbuf, authctx */
-    result = krb5_build_principal(Z_krb5_ctx, &server, strlen(__Zephyr_realm), 
-                                 __Zephyr_realm, SERVER_SERVICE, 
-                                 SERVER_INSTANCE, NULL);
-    if (!result) {
-        result = krb5_rd_req(Z_krb5_ctx, &authctx, &packet, server, 
-                             keytabid, 0, &tkt);
-       krb5_free_principal(Z_krb5_ctx, server);
-    }
-    krb5_kt_close(Z_krb5_ctx, keytabid);
-
-    if (result) {
-      if (result == KRB5KRB_AP_ERR_REPEAT)
-       syslog(LOG_DEBUG, "ZCheckAuthentication: k5 auth failed: %s", error_message(result));
-      else
-        syslog(LOG_WARNING,"ZCheckAuthentication: k5 auth failed: %s", error_message(result));
-        free(authbuf);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        return ZAUTH_FAILED;
-    }
-
-    /* HOLDING: authbuf, authctx, tkt */
-
-    if (tkt == 0 || !Z_tktprincp(tkt)) {
-       if (tkt)
-          krb5_free_ticket(Z_krb5_ctx, tkt);
-       free(authbuf);
-       krb5_auth_con_free(Z_krb5_ctx, authctx);
-       return ZAUTH_FAILED;
-    }
-    princ = Z_tktprinc(tkt);
-
-    if (princ == 0) {
-        krb5_free_ticket(Z_krb5_ctx, tkt);
-        free(authbuf);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        return ZAUTH_FAILED;
-    }
-
-    /* HOLDING: authbuf, authctx, tkt */
-    result = krb5_unparse_name(Z_krb5_ctx, princ, &name);
-    if (result) {
-        syslog(LOG_WARNING, "k5 unparse_name failed: %s",
-               error_message(result));
-        free(authbuf);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        krb5_free_ticket(Z_krb5_ctx, tkt);
-        return ZAUTH_FAILED;
-    }
-
-    krb5_free_ticket(Z_krb5_ctx, tkt);
-
-    /* HOLDING: authbuf, authctx, name */
-    if (strcmp(name, notice->z_sender)) {
-        syslog(LOG_WARNING, "k5 name mismatch: '%s' vs '%s'",
-               name, notice->z_sender);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        free(name);
-        free(authbuf);
-        return ZAUTH_FAILED;
-    }
-    free(name);
-    free(authbuf);
-
-    /* HOLDING: authctx */
-    /* Get an authenticator so we can get the keyblock */
-    result = krb5_auth_con_getauthenticator (Z_krb5_ctx, authctx,
-                                            &authenticator);
-    if(result) {
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        return result;
-    }
+    return ZAUTH_YES;
 
-    /* HOLDING: authctx, authenticator */
-    result = krb5_auth_con_getkey(Z_krb5_ctx, authctx, &keyblock);
-    if (result) {
-      krb5_auth_con_free(Z_krb5_ctx, authctx);
-      krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-      return (ZAUTH_FAILED);
-    }
-    
-    /* HOLDING: authctx, authenticator, keyblock */
-    /* Figure out what checksum type to use */
-    key_data = Z_keydata(keyblock);
-    key_len = Z_keylen(keyblock);
-    result = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
-    if (result) { 
-        krb5_free_keyblock(Z_krb5_ctx, keyblock);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-        return (ZAUTH_FAILED); 
-    } 
-    /* HOLDING: authctx, authenticator, keyblock */
-
-    ZSetSession(keyblock);
-    /* Assemble the things to be checksummed */ 
-    /* first part is from start of packet through z_default_format: 
-     * - z_version 
-     * - z_num_other_fields 
-     * - z_kind 
-     * - z_uid 
-     * - z_port 
-     * - z_auth 
-     * - z_authent_len 
-     * - z_ascii_authent 
-     * - z_class 
-     * - z_class_inst 
-     * - z_opcode 
-     * - z_sender 
-     * - z_recipient 
-     * - z_default_format 
-     */ 
-    cksum0_base = notice->z_packet; 
-    x           = notice->z_default_format; 
-    cksum0_len  = x + strlen(x) + 1 - cksum0_base; 
-    /* second part is from z_multinotice through other fields: 
-     * - z_multinotice 
-     * - z_multiuid 
-     * - z_other_fields[] 
-     */ 
-    cksum1_base = notice->z_multinotice; 
-    if (notice->z_num_other_fields) 
-        x = notice->z_other_fields[notice->z_num_other_fields]; 
-    else 
-        x = cksum1_base + strlen(cksum1_base) + 1; /* multiuid */ 
-    cksum1_len  = x + strlen(x) + 1 - cksum1_base; 
-    /* last part is the message body */ 
-    cksum2_base = notice->z_message; 
-    cksum2_len  = notice->z_message_len; 
-    if ((!notice->z_ascii_checksum || *notice->z_ascii_checksum != 'Z') && 
-        key_len == 8 && 
-        (enctype == ENCTYPE_DES_CBC_CRC || 
-         enctype == ENCTYPE_DES_CBC_MD4 || 
-         enctype == ENCTYPE_DES_CBC_MD5)) { 
-      /* try old-format checksum (covers cksum0 only) */ 
-      ZChecksum_t our_checksum; 
-      our_checksum = compute_checksum(notice, key_data);
-      
-      krb5_free_keyblock(Z_krb5_ctx, keyblock);
-      krb5_auth_con_free(Z_krb5_ctx, authctx);
-      krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-
-      if (our_checksum == notice->z_checksum)
-       return ZAUTH_YES; 
-      else
-       return ZAUTH_FAILED;
-    } 
-
-    /* HOLDING: authctx, authenticator */
-    cksumbuf.length = cksum0_len + cksum1_len + cksum2_len; 
-    cksumbuf.data = malloc(cksumbuf.length); 
-    if (!cksumbuf.data) { 
-        krb5_free_keyblock(Z_krb5_ctx, keyblock);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-        return ZAUTH_FAILED; 
-    } 
-    /* HOLDING: authctx, authenticator, cksumbuf.data */ 
-    memcpy(cksumbuf.data, cksum0_base, cksum0_len); 
-    memcpy(cksumbuf.data + cksum0_len, cksum1_base, cksum1_len); 
-    memcpy(cksumbuf.data + cksum0_len + cksum1_len, 
-           cksum2_base, cksum2_len); 
-    /* decode zcoded checksum */ 
-    /* The encoded form is always longer than the original */ 
-    asn1_len = strlen(notice->z_ascii_checksum) + 1; 
-    asn1_data = malloc(asn1_len); 
-    if (!asn1_data) { 
-        krb5_free_keyblock(Z_krb5_ctx, keyblock);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-        free(cksumbuf.data); 
-        return ZAUTH_FAILED; 
-    } 
-    /* HOLDING: authctx, authenticator, cksumbuf.data, asn1_data */ 
-    result = ZReadZcode((unsigned char *)notice->z_ascii_checksum, 
-                        asn1_data, asn1_len, &asn1_len); 
-    if (result != ZERR_NONE) { 
-        krb5_free_keyblock(Z_krb5_ctx, keyblock);
-        krb5_auth_con_free(Z_krb5_ctx, authctx);
-        krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-        free(asn1_data); 
-        free(cksumbuf.data); 
-        return ZAUTH_FAILED; 
-    } 
-    /* HOLDING: asn1_data, cksumbuf.data, authctx, authenticator */ 
-
-    valid = Z_krb5_verify_cksum(keyblock, &cksumbuf, cksumtype, asn1_data, asn1_len);
-
-    free(asn1_data); 
-    krb5_auth_con_free(Z_krb5_ctx, authctx);
-    krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-    krb5_free_keyblock(Z_krb5_ctx, keyblock);
-    free(cksumbuf.data); 
-    
-    if (valid) 
-        return (ZAUTH_YES); 
-    else 
-        return (ZAUTH_FAILED); 
-#else
+#else /* !HAVE_KRB4 */
     return (notice->z_auth) ? ZAUTH_YES : ZAUTH_NO;
 #endif
 }
 
-#undef KRB5AUTHENT
-
-static Code_t
-ZCheckAuthentication4(ZNotice_t *notice,
-                     struct sockaddr_in *from)
+Code_t
+ZCheckAuthentication(notice, from)
+    ZNotice_t *notice;
+    struct sockaddr_in *from;
 {      
 #ifdef HAVE_KRB4
     int result;
     char srcprincipal[ANAME_SZ+INST_SZ+REALM_SZ+4];
-    KTEXT_ST authent;
+    KTEXT_ST authent, ticket;
     AUTH_DAT dat;
     ZChecksum_t checksum;
-    char instance[INST_SZ+1];
+    C_Block session_key;
 
     if (!notice->z_auth)
        return ZAUTH_NO;
@@ -835,13 +238,10 @@ ZCheckAuthentication4(ZNotice_t *notice,
     }
     authent.length = notice->z_authent_len;
 
-    strcpy(instance, SERVER_INSTANCE);
-
-    /* We don't have the session key cached; do it the long way. */
-    result = krb_rd_req(&authent, SERVER_SERVICE, instance,
+    result = krb_rd_req(&authent, SERVER_SERVICE, SERVER_INSTANCE,
                        from->sin_addr.s_addr, &dat, srvtab_file);
     if (result == RD_AP_OK) {
-       ZSetSessionDES(&dat.session);
+       memcpy(__Zephyr_session, dat.session, sizeof(C_Block));
        sprintf(srcprincipal, "%s%s%s@%s", dat.pname, dat.pinst[0] ? "." : "",
                dat.pinst, dat.prealm);
        if (strcmp(srcprincipal, notice->z_sender))
@@ -851,8 +251,11 @@ ZCheckAuthentication4(ZNotice_t *notice,
     }
 
     /* Check the cryptographic checksum. */
+#ifdef NOENCRYPTION
+    checksum = 0;
+#else
     checksum = compute_checksum(notice, dat.session);
-
+#endif
     if (checksum != notice->z_checksum)
        return ZAUTH_FAILED;
 
@@ -863,99 +266,133 @@ ZCheckAuthentication4(ZNotice_t *notice,
 #endif
 }
 
-
 #ifdef HAVE_KRB4
-static ZChecksum_t
-compute_checksum(ZNotice_t *notice,
-                C_Block session_key)
+
+static int hash_ticket(p, len)
+    unsigned char *p;
+    int len;
+{
+    unsigned long hashval = 0, g;
+
+    for (; len > 0; p++, len--) {
+       hashval = (hashval << 4) + *p;
+       g = hashval & 0xf0000000;
+       if (g) {
+           hashval ^= g >> 24;
+           hashval ^= g;
+       }
+    }
+    return hashval % HASHTAB_SIZE;
+}
+
+static void add_session_key(ticket, session_key, srcprincipal, expires)
+    KTEXT ticket;
+    C_Block session_key;
+    char *srcprincipal;
+    time_t expires;
+{
+    Hash_entry *entry;
+    int hashval;
+
+    /* If we can't allocate memory for the hash table entry, just forget
+     * about it. */
+    entry = (Hash_entry *) malloc(sizeof(Hash_entry) - 1 + ticket->length);
+    if (!entry)
+       return;
+
+    /* Initialize the new entry. */
+    memcpy(entry->session_key, session_key, sizeof(entry->session_key));
+    strcpy(entry->srcprincipal, srcprincipal);
+    entry->expires = expires;
+    entry->ticket_len = ticket->length;
+    memcpy(entry->ticket, ticket->dat, ticket->length * sizeof(unsigned char));
+
+    /* Insert the new entry in the hash table. */
+    hashval = hash_ticket(ticket->dat, ticket->length);
+    entry->next = hashtab[hashval];
+    hashtab[hashval] = entry;
+}
+
+static int find_session_key(ticket, key, srcprincipal)
+    KTEXT ticket;
+    C_Block key;
+    char *srcprincipal;
+{
+    unsigned char *dat;
+    int hashval, len;
+    Hash_entry *entry;
+
+    dat = ticket->dat;
+    len = ticket->length;
+    hashval = hash_ticket(dat, len);
+
+    for (entry = hashtab[hashval]; entry; entry = entry->next) {
+       if (entry->ticket_len == len && memcmp(entry->ticket, dat, len) == 0) {
+           memcpy(key, entry->session_key, sizeof(entry->session_key));
+           strcpy(srcprincipal, entry->srcprincipal);
+           return 0;
+       }
+    }
+    return -1;
+}
+
+static ZChecksum_t compute_checksum(notice, session_key)
+    ZNotice_t *notice;
+    C_Block session_key;
 {
+#ifdef NOENCRYPTION
+    return 0;
+#else
     ZChecksum_t checksum;
     char *cstart, *cend, *hstart = notice->z_packet, *hend = notice->z_message;
 
     cstart = notice->z_default_format + strlen(notice->z_default_format) + 1;
     cend = cstart + strlen(cstart) + 1;
-    checksum = des_quad_cksum((unsigned char *)hstart, NULL, cstart - hstart, 0, (C_Block *)session_key);
-    checksum ^= des_quad_cksum((unsigned char *)cend, NULL, hend - cend, 0, (C_Block *)session_key);
-    checksum ^= des_quad_cksum((unsigned char *)notice->z_message, NULL, notice->z_message_len,
-                              0, (C_Block *)session_key);
+    checksum = des_quad_cksum(hstart, NULL, cstart - hstart, 0, session_key);
+    checksum ^= des_quad_cksum(cend, NULL, hend - cend, 0, session_key);
+    checksum ^= des_quad_cksum(notice->z_message, NULL, notice->z_message_len,
+                              0, session_key);
     return checksum;
+#endif
 }
 
-static ZChecksum_t compute_rlm_checksum(ZNotice_t *notice,
-                                       C_Block session_key)
+static ZChecksum_t compute_rlm_checksum(notice, session_key)
+    ZNotice_t *notice;
+    C_Block session_key;
 {
+#ifdef NOENCRYPTION
+    return 0;
+#else
     ZChecksum_t checksum;
-    char *cstart, *cend, *hstart = notice->z_packet;
+    char *cstart, *cend, *hstart = notice->z_packet, *hend = notice->z_message;
 
     cstart = notice->z_default_format + strlen(notice->z_default_format) + 1;
     cend = cstart + strlen(cstart) + 1;
-    checksum = des_quad_cksum((unsigned char *)hstart, NULL, cstart - hstart, 0, (C_Block *)session_key);
-
+    checksum = des_quad_cksum(hstart, NULL, cstart - hstart, 0, session_key);
     return checksum;
-}
-
-#ifdef HAVE_KRB5
-krb5_error_code 
-Z_krb5_init_keyblock(krb5_context context,
-       krb5_enctype type,
-       size_t size,
-       krb5_keyblock **key)
-{
-#ifdef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
-       return krb5_init_keyblock(context, type, size, key);
-#else
-       krb5_error_code ret;
-       krb5_keyblock *tmp, tmp_ss;
-       tmp = &tmp_ss;
-
-       *key = NULL;
-       Z_enctype(tmp) = type;
-       Z_keylen(tmp) = size;
-       Z_keydata(tmp) = malloc(size);
-       if (!Z_keydata(tmp))
-               return ENOMEM;
-       ret =  krb5_copy_keyblock(context, tmp, key);
-       free(Z_keydata(tmp));
-       return ret;
 #endif
 }
 
-void
-ZSetSession(krb5_keyblock *keyblock) {
-    krb5_error_code result;
-
-    if (__Zephyr_keyblock) {
-         krb5_free_keyblock_contents(Z_krb5_ctx, __Zephyr_keyblock);
-         result = krb5_copy_keyblock_contents(Z_krb5_ctx, keyblock, __Zephyr_keyblock);
-    } else {
-         result = krb5_copy_keyblock(Z_krb5_ctx, keyblock, &__Zephyr_keyblock);
+void sweep_ticket_hash_table(arg)
+    void *arg;
+{
+    int i;
+    Hash_entry **ptr, *entry;
+
+    for (i = 0; i < HASHTAB_SIZE; i++) {
+       ptr = &hashtab[i];
+       while (*ptr) {
+           entry = *ptr;
+           if (entry->expires < NOW) {
+               *ptr = entry->next;
+               free(entry);
+           } else {
+               ptr = &(*ptr)->next;
+           }
+       }
     }
-    
-    if (result) /*XXX we're out of memory? */
-       ;
-}
-#endif
-#ifdef HAVE_KRB4
-void
-ZSetSessionDES(C_Block *key) {
-#ifdef HAVE_KRB5
-     Code_t result;
-     if (__Zephyr_keyblock) {
-          krb5_free_keyblock(Z_krb5_ctx, __Zephyr_keyblock);
-          __Zephyr_keyblock=NULL;
-     }
-     result = Z_krb5_init_keyblock(Z_krb5_ctx, ENCTYPE_DES_CBC_CRC, 
-                                 sizeof(C_Block),
-                                 &__Zephyr_keyblock);
-     if (result) /*XXX we're out of memory? */
-       return;
-
-     memcpy(Z_keydata(__Zephyr_keyblock), key, sizeof(C_Block));
-#else
-    memcpy(__Zephyr_session, key, sizeof(C_Block));
-#endif
+    timer_set_rel(SWEEP_INTERVAL, sweep_ticket_hash_table, NULL);
 }
-#endif
 
 #endif /* HAVE_KRB4 */
 
index 9396a2bfa40374cdda1c8f4632b4c70178df7329..118eb025931785ac25111617a6ab793dc55aa4dd 100644 (file)
@@ -52,22 +52,23 @@ static const char rcsid_main_c[] =
 
 #define        EVER            (;;)            /* don't stop looping */
 
-static int do_net_setup(void);
-static int initialize(void);
-static void usage(void);
-static void do_reset(void);
-static RETSIGTYPE bye(int);
-static RETSIGTYPE dbug_on(int);
-static RETSIGTYPE dbug_off(int);
-static RETSIGTYPE sig_dump_db(int);
-static RETSIGTYPE reset(int);
-static RETSIGTYPE reap(int);
-static void read_from_dump(char *dumpfile);
-static void dump_db(void);
-static void dump_strings(void);
+static int do_net_setup __P((void));
+static int initialize __P((void));
+static void usage __P((void));
+static void do_reset __P((void));
+static RETSIGTYPE bye __P((int));
+static RETSIGTYPE dbug_on __P((int));
+static RETSIGTYPE dbug_off __P((int));
+static RETSIGTYPE sig_dump_db __P((int));
+static RETSIGTYPE sig_dump_strings __P((int));
+static RETSIGTYPE reset __P((int));
+static RETSIGTYPE reap __P((int));
+static void read_from_dump __P((char *dumpfile));
+static void dump_db __P((void));
+static void dump_strings __P((void));
 
 #ifndef DEBUG
-static void detach(void);
+static void detach __P((void));
 #endif
 
 static short doreset = 0;              /* if it becomes 1, perform
@@ -91,10 +92,6 @@ char *programname;                   /* set to the basename of argv[0] */
 char myname[MAXHOSTNAMELEN];           /* my host name */
 
 char list_file[128];
-#ifdef HAVE_KRB5
-char keytab_file[128];
-static char tkt5_file[256];
-#endif
 #ifdef HAVE_KRB4
 char srvtab_file[128];
 char my_realm[REALM_SZ];
@@ -123,28 +120,10 @@ static int nofork;
 struct in_addr my_addr;
 char *bdump_version = "1.2";
 
-#ifdef HAVE_KRB5
-int bdump_auth_proto = 5;
-#else /* HAVE_KRB5 */
-#ifdef HAVE_KRB4
-int bdump_auth_proto = 4;
-#else /* HAVE_KRB4 */
-int bdump_auth_proto = 0;
-#endif /* HAVE_KRB4 */
-#endif /* HAVE_KRB5 */
-
-#ifdef HAVE_KRB5
-krb5_ccache Z_krb5_ccache;
-krb5_keyblock *__Zephyr_keyblock;
-#else
-#ifdef HAVE_KRB4
-C_Block __Zephyr_session;
-#endif
-#endif
-
 int
-main(int argc,
-     char **argv)
+main(argc, argv)
+    int argc;
+    char **argv;
 {
     int nfound;                        /* #fildes ready on select */
     fd_set readable;
@@ -162,10 +141,6 @@ main(int argc,
 #ifdef HAVE_KRB4
     sprintf(srvtab_file, "%s/zephyr/%s", SYSCONFDIR, ZEPHYR_SRVTAB);
     sprintf(tkt_file, "%s/zephyr/%s", SYSCONFDIR, ZEPHYR_TKFILE);
-#endif
-#ifdef HAVE_KRB5
-    sprintf(keytab_file, "%s/zephyr/%s", SYSCONFDIR, ZEPHYR_KEYTAB);
-    sprintf(tkt5_file, "FILE:%s/zephyr/%s", SYSCONFDIR, ZEPHYR_TK5FILE);
 #endif
     sprintf(acl_dir, "%s/zephyr/%s", SYSCONFDIR, ZEPHYR_ACL_DIR);
     sprintf(subs_file, "%s/zephyr/%s", SYSCONFDIR, DEFAULT_SUBS_FILE);
@@ -175,7 +150,7 @@ main(int argc,
     programname = (programname) ? programname + 1 : argv[0];
 
     /* process arguments */
-    while ((optchar = getopt(argc, argv, "dsnv4f:k:")) != EOF) {
+    while ((optchar = getopt(argc, argv, "dsnv:f:k:")) != EOF) {
        switch(optchar) {
          case 'd':
            zdebug = 1;
@@ -200,9 +175,6 @@ main(int argc,
            init_from_dump = 0;
            dumpfile = optarg;
            break;
-       case '4':
-           bdump_auth_proto = 4;
-           break;
          case '?':
          default:
            usage();
@@ -244,8 +216,10 @@ main(int argc,
     if (zalone)
        syslog(LOG_DEBUG, "standalone operation");
 #endif
+#if 0
     if (zdebug)
        syslog(LOG_DEBUG, "debugging on");
+#endif
 
     /* set up sockets & my_addr and myname, 
        find other servers and set up server table, initialize queues
@@ -319,6 +293,9 @@ main(int argc,
     /* Reinitialize t_local now that initialization is done. */
     gettimeofday(&t_local, NULL);
     uptime = NOW;
+#ifdef HAVE_KRB4
+    timer_set_rel(SWEEP_INTERVAL, sweep_ticket_hash_table, NULL);
+#endif
 
     realm_wakeup();
 #ifdef DEBUG_MALLOC
@@ -390,7 +367,7 @@ main(int argc,
    */
 
 static int
-initialize(void)
+initialize()
 {
     if (do_net_setup())
        return(1);
@@ -404,20 +381,6 @@ initialize(void)
     
     ZSetServerState(1);
     ZInitialize();             /* set up the library */
-#ifdef HAVE_KRB5
-    krb5_cc_resolve(Z_krb5_ctx, tkt5_file, &Z_krb5_ccache);
-#ifdef HAVE_KRB5_CC_SET_DEFAULT_NAME
-    krb5_cc_set_default_name(Z_krb5_ctx, tkt5_file);
-#else
-    {
-       /* Hack to make krb5_cc_default do something reasonable */
-       char *env=(char *)malloc(strlen(tkt5_file)+12);
-       if (!env) return(1);
-       sprintf(env, "KRB5CCNAME=%s", tkt5_file);
-       putenv(env);
-    }
-#endif
-#endif
 #ifdef HAVE_KRB4
     /* Override what Zinitialize set for ZGetRealm() */
     if (*my_realm) 
@@ -447,7 +410,7 @@ initialize(void)
  */
 
 static int
-do_net_setup(void)
+do_net_setup()
 {
     struct servent *sp;
     struct hostent *hp;
@@ -484,13 +447,6 @@ do_net_setup(void)
     if (srv_socket < 0) {
        syslog(LOG_ERR, "client_sock failed: %m");
        return 1;
-    } else {
-#ifdef SO_BSDCOMPAT
-      int on = 1;
-
-      /* Prevent Linux from giving us socket errors we don't care about. */
-      setsockopt(srv_socket, SOL_SOCKET, SO_BSDCOMPAT, &on, sizeof(on));
-#endif
     }
     if (bind(srv_socket, (struct sockaddr *) &srv_addr,
             sizeof(srv_addr)) < 0) {
@@ -517,7 +473,7 @@ do_net_setup(void)
  */
 
 static void
-usage(void)
+usage()
 {
 #ifdef DEBUG
        fprintf(stderr, "Usage: %s [-d] [-s] [-n] [-k realm] [-f dumpfile]\n",
@@ -530,7 +486,7 @@ usage(void)
 }
 
 int
-packets_waiting(void)
+packets_waiting()
 {
     fd_set readable, initial;
     struct timeval tv;
@@ -545,7 +501,8 @@ packets_waiting(void)
 }
 
 static RETSIGTYPE
-bye(int sig)
+bye(sig)
+    int sig;
 {
     server_shutdown();         /* tell other servers */
 #ifdef REALM_MGMT
@@ -561,7 +518,8 @@ bye(int sig)
 }
 
 static RETSIGTYPE
-dbug_on(int sig)
+dbug_on(sig)
+    int sig;
 {
     syslog(LOG_DEBUG, "debugging turned on");
 #ifdef DEBUG_MALLOC
@@ -571,7 +529,8 @@ dbug_on(int sig)
 }
 
 static RETSIGTYPE
-dbug_off(int sig)
+dbug_off(sig)
+    int sig;
 {
     syslog(LOG_DEBUG, "debugging turned off");
 #ifdef DEBUG_MALLOC
@@ -582,7 +541,14 @@ dbug_off(int sig)
 
 int fork_for_dump = 0;
 
-static void dump_strings(void)
+static RETSIGTYPE
+sig_dump_strings(sig)
+    int sig;
+{
+    dump_strings_flag = 1;
+}
+
+static void dump_strings()
 {
     char filename[128];
 
@@ -609,13 +575,13 @@ static void dump_strings(void)
 }
 
 static RETSIGTYPE
-sig_dump_db(int sig)
+sig_dump_db(sig)
+    int sig;
 {
     dump_db_flag = 1;
 }
 
-static void
-dump_db(void)
+static void dump_db()
 {
     /* dump the in-core database to human-readable form on disk */
     FILE *fp;
@@ -652,25 +618,30 @@ dump_db(void)
 }
 
 static RETSIGTYPE
-reset(int sig)
+reset(sig)
+    int sig;
 {
+#if 1
     zdbug((LOG_DEBUG,"reset()"));
+#endif
     doreset = 1;
 }
 
 static RETSIGTYPE
-reap(int sig)
+reap(sig)
+    int sig;
 {
     int pid, i = 0;
     int oerrno = errno;
-    ZRealm *rlm;
+    Realm *rlm;
 #ifdef _POSIX_VERSION
     int waitb;
 #else
     union wait waitb;
 #endif
-
+#if 1
     zdbug((LOG_DEBUG,"reap()"));
+#endif
 #ifdef _POSIX_VERSION
     while ((pid = waitpid(-1, &waitb, WNOHANG)) == 0) 
       { i++; if (i > 10) break; }
@@ -700,7 +671,7 @@ reap(int sig)
 }
 
 static void
-do_reset(void)
+do_reset()
 {
     int oerrno = errno;
 #ifdef _POSIX_VERSION
@@ -708,6 +679,9 @@ do_reset(void)
 #else
     int omask;
 #endif
+#if 0
+    zdbug((LOG_DEBUG,"do_reset()"));
+#endif
 #ifdef _POSIX_VERSION
     sigemptyset(&mask);
     sigaddset(&mask, SIGHUP);
@@ -736,7 +710,7 @@ do_reset(void)
  */
 
 static void
-detach(void)
+detach()
 {
     /* detach from terminal and fork. */
     int i;
@@ -770,7 +744,8 @@ detach(void)
 #endif /* not DEBUG */
 
 static void
-read_from_dump(char *dumpfile)
+read_from_dump(dumpfile)
+    char *dumpfile;
 {
     /* Not yet implemented. */
     return;
index f6ff219b39750a7d2591810b91e15ce3735a5112..ecef9ebad892f0023f933f2c4e82835f85ae947e 100644 (file)
@@ -3,17 +3,17 @@
 
 Unacked *rlm_nacklist = NULL;   /* not acked list for realm-realm
                                    packets */
-ZRealm *otherrealms;             /* points to an array of the known
+Realm *otherrealms;             /* points to an array of the known
                                    servers */
 int nrealms = 0;                /* number of other realms */
 
 /*
  * External Routines:
  *
- * ZRealm *realm_which_realm(struct sockaddr_in *who)
+ * Realm *realm_which_realm(struct sockaddr_in *who)
  * figures out if this packet came from another realm's server
  *
- * ZRealm *realm_get_realm_by_pid(int pid)
+ * Realm *realm_get_realm_by_pid(int pid)
  * figures out which realm a child handler was for
  *
  * void kill_realm_pids()
@@ -31,7 +31,7 @@ int nrealms = 0;                /* number of other realms */
  * int realm_sender_in_realm(char *realm, char *sender)
  * figures out if sender is in realm
  * 
- * ZRealm *realm_get_realm_by_name(char *name)
+ * Realm *realm_get_realm_by_name(char *name)
  * finds a realm struct from the realm array by name, tries expansion
  *
  * Code_t realm_dispatch(ZNotice_t *notice, int auth, struct sockaddr_in *who,
@@ -49,36 +49,39 @@ int nrealms = 0;                /* number of other realms */
  *
  * Code_t realm_control_dispatch(ZNotice_t *notice, int auth,
  *                               struct sockaddr_in *who, Server *server,
- *                              ZRealm *realm)
+ *                              Realm *realm)
  * dispatches a foreign realm control message
  *
  * void realm_handoff(ZNotice_t *notice, int auth, struct sockaddr_in *who,
- *                    ZRealm *realm, int ack_to_sender)
+ *                    Realm *realm, int ack_to_sender)
  * hands off a message to another realm
  *
  * void realm_dump_realms(File *fp)
  * do a database dump of foreign realm info
  *
  */
-static void realm_sendit(ZNotice_t *notice, struct sockaddr_in *who, int auth, ZRealm *realm, int ack_to_sender);
-static Code_t realm_sendit_auth(ZNotice_t *notice, struct sockaddr_in *who, int auth, ZRealm *realm, int ack_to_sender);
-static void rlm_ack(ZNotice_t *notice, Unacked *nacked);
-static void rlm_nack_cancel(ZNotice_t *notice, struct sockaddr_in *who);
-static void rlm_rexmit(void *arg);
-static Code_t realm_ulocate_dispatch(ZNotice_t *notice,int auth,struct sockaddr_in *who,Server *server,ZRealm *realm);
-static Code_t realm_new_server(struct sockaddr_in *, ZNotice_t *, ZRealm *);
-static Code_t realm_set_server(struct sockaddr_in *, ZRealm *);
+static void realm_sendit __P((ZNotice_t *notice, struct sockaddr_in *who, int auth, Realm *realm, int ack_to_sender));
+static void realm_sendit_auth __P((ZNotice_t *notice, struct sockaddr_in *who, int auth, Realm *realm, int ack_to_sender));
+static void rlm_ack __P((ZNotice_t *notice, Unacked *nacked));
+static void rlm_nack_cancel __P((ZNotice_t *notice, struct sockaddr_in *who));
+static void rlm_new_ticket __P(());
+static void rlm_rexmit __P((void *arg));
+static Code_t realm_ulocate_dispatch __P((ZNotice_t *notice,int auth,struct sockaddr_in *who,Server *server,Realm *realm));
+static Code_t realm_new_server __P((struct sockaddr_in *, ZNotice_t *, Realm *));
+static Code_t realm_set_server __P((struct sockaddr_in *, Realm *));
 #ifdef HAVE_KRB4
-static Code_t ticket_retrieve(ZRealm *realm);
-static int ticket_lookup(char *realm);
+static Code_t ticket_retrieve __P((Realm *realm));
+static int ticket_lookup __P((char *realm));
+static int ticket_expired __P((CREDENTIALS *cred));
 #endif
 
 static int
-realm_get_idx_by_addr(ZRealm *realm,
-                     struct sockaddr_in *who)
+realm_get_idx_by_addr(realm, who) 
+    Realm *realm;
+    struct sockaddr_in *who;
 {
     struct sockaddr_in *addr;
-    int b;
+    int a, b;
 
     /* loop through the realms */
     for (addr = realm->addrs, b = 0; b < realm->count; b++, addr++)
@@ -89,9 +92,10 @@ realm_get_idx_by_addr(ZRealm *realm,
 }
 
 char *
-realm_expand_realm(char *realmname)
+realm_expand_realm(realmname)
+char *realmname;
 {
-    ZRealm *realm;
+    Realm *realm;
     int a;
 
     /* First, look for an exact match (case insensitive) */
@@ -116,10 +120,11 @@ realm_expand_realm(char *realmname)
     return(realmname);
 }
 
-ZRealm *
-realm_get_realm_by_pid(int pid)
+Realm *
+realm_get_realm_by_pid(pid)
+     int pid;
 {
-    ZRealm *realm;
+    Realm *realm;
     int a;
 
     for (realm = otherrealms, a = 0; a < nrealms; a++, realm++)
@@ -130,9 +135,9 @@ realm_get_realm_by_pid(int pid)
 }
 
 void
-kill_realm_pids(void)
+kill_realm_pids()
 {
-    ZRealm *realm;
+    Realm *realm;
     int a;
 
     for (realm = otherrealms, a = 0; a < nrealms; a++, realm++)
@@ -142,10 +147,11 @@ kill_realm_pids(void)
     return;
 }
 
-ZRealmname *
-get_realm_lists(char *file)
+Realmname *
+get_realm_lists(file)
+    char *file;
 {
-    ZRealmname *rlm_list, *rlm;
+    Realmname *rlm_list, *rlm;
     int ii, nused, ntotal;
     FILE *fp;
     char buf[REALM_SZ + MAXHOSTNAMELEN + 1]; /* one for newline */
@@ -153,11 +159,11 @@ get_realm_lists(char *file)
   
     nused = 0;
     if (!(fp = fopen(file, "r")))
-       return((ZRealmname *)0);
+       return((Realmname *)0);
   
     /* start with 16, realloc if necessary */
     ntotal = 16;
-    rlm_list = (ZRealmname *)malloc(ntotal * sizeof(ZRealmname));
+    rlm_list = (Realmname *)malloc(ntotal * sizeof(Realmname));
     if (!rlm_list) {
        syslog(LOG_CRIT, "get_realm_lists malloc");
        abort();
@@ -191,9 +197,9 @@ get_realm_lists(char *file)
            /* new realm */
            if (nused + 1 >= ntotal) {
                /* make more space */
-               rlm_list = (ZRealmname *)realloc((char *)rlm_list,
+               rlm_list = (Realmname *)realloc((char *)rlm_list,
                                                (unsigned)ntotal * 2 * 
-                                               sizeof(ZRealmname));
+                                               sizeof(Realmname));
                if (!rlm_list) {
                    syslog(LOG_CRIT, "get_realm_lists realloc");
                    abort();
@@ -213,9 +219,9 @@ get_realm_lists(char *file)
        }
     }
     if (nused + 1 >= ntotal) {
-       rlm_list = (ZRealmname *)realloc((char *)rlm_list,
+       rlm_list = (Realmname *)realloc((char *)rlm_list,
                                        (unsigned)(ntotal + 1) * 
-                                       sizeof(ZRealmname));
+                                       sizeof(Realmname));
        if (!rlm_list) {
            syslog(LOG_CRIT, "get_realm_lists realloc");
            abort();
@@ -223,24 +229,23 @@ get_realm_lists(char *file)
     }
     *rlm_list[nused].name = '\0';
   
-    fclose(fp);
     return(rlm_list);
 }
 
 Code_t 
-realm_send_realms(void)
+realm_send_realms()
 {
     int cnt, retval;
     for (cnt = 0; cnt < nrealms; cnt++) {
-       retval = subscr_send_realm_subs(&otherrealms[cnt]);
-       if (retval != ZERR_NONE)
+       if (retval = (subscr_send_realm_subs(&otherrealms[cnt])) != ZERR_NONE)
            return(retval);
     }
-    return ZERR_NONE;
 }
 
 int
-realm_bound_for_realm(char *realm, char *recip)
+realm_bound_for_realm(realm, recip)
+     char *realm;
+     char *recip;
 {
     char *rlm = NULL;
     int remote = strcmp(ZGetRealm(), realm);
@@ -258,7 +263,9 @@ realm_bound_for_realm(char *realm, char *recip)
 }
 
 int
-realm_sender_in_realm(char *realm, char *sender)
+realm_sender_in_realm(realm, sender)
+     char *realm;
+     char *sender;
 {
     char *rlm = NULL;
     int remote = strcmp(ZGetRealm(), realm);
@@ -275,7 +282,8 @@ realm_sender_in_realm(char *realm, char *sender)
     return 0;
 }
 
-int sender_in_realm(ZNotice_t *notice)
+sender_in_realm(notice)
+    ZNotice_t *notice;
 {
   char *realm;
 
@@ -287,10 +295,11 @@ int sender_in_realm(ZNotice_t *notice)
   return 0;
 }
 
-ZRealm *
-realm_which_realm(struct sockaddr_in *who)
+Realm *
+realm_which_realm(who)
+    struct sockaddr_in *who;
 {
-    ZRealm *realm;
+    Realm *realm;
     struct sockaddr_in *addr;
     int a, b;
 
@@ -307,11 +316,12 @@ realm_which_realm(struct sockaddr_in *who)
     return 0;
 }
 
-ZRealm *
-realm_get_realm_by_name(char *name)
+Realm *
+realm_get_realm_by_name(name)
+    char *name;
 {
     int a;
-    ZRealm *realm;
+    Realm *realm;
 
     /* First, look for an exact match (case insensitive) */
     for (realm = otherrealms, a = 0; a < nrealms; a++, realm++)
@@ -327,16 +337,19 @@ realm_get_realm_by_name(char *name)
 }
 
 static void
-rlm_nack_cancel(register ZNotice_t *notice,
-               struct sockaddr_in *who)
+rlm_nack_cancel(notice, who)
+    register ZNotice_t *notice;
+    struct sockaddr_in *who;
 {
-    register ZRealm *which = realm_which_realm(who);
-    register Unacked *nacked;
+    register Realm *which = realm_which_realm(who);
+    register Unacked *nacked, *next;
+    ZPacket_t retval;
   
+#if 1
     zdbug((LOG_DEBUG, "rlm_nack_cancel: %s:%08X,%08X",
            inet_ntoa(notice->z_uid.zuid_addr),
            notice->z_uid.tv.tv_sec, notice->z_uid.tv.tv_usec));
-
+#endif
     if (!which) {
        syslog(LOG_ERR, "non-realm ack?");
        return;
@@ -354,18 +367,24 @@ rlm_nack_cancel(register ZNotice_t *notice,
         
                /* free the data */
                free(nacked->packet);
-               Unacked_delete(nacked);
+               LIST_DELETE(nacked);
                free(nacked);
                return;
            }
        }
     }
+#if 0
+    zdbug((LOG_DEBUG,"nack_cancel: nack not found %s:%08X,%08X",
+           inet_ntoa (notice->z_uid.zuid_addr),
+           notice->z_uid.tv.tv_sec, notice->z_uid.tv.tv_usec));
+#endif
     return;
 }
 
 static void
-rlm_ack(ZNotice_t *notice,
-       Unacked *nacked)
+rlm_ack(notice, nacked)
+    ZNotice_t *notice;
+    Unacked *nacked;
 {
     ZNotice_t acknotice;
     ZPacket_t ackpack;
@@ -399,12 +418,13 @@ rlm_ack(ZNotice_t *notice,
 }
 
 Code_t
-realm_dispatch(ZNotice_t *notice,
-              int auth,
-              struct sockaddr_in *who,
-              Server *server)
+realm_dispatch(notice, auth, who, server)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Server *server;
 {
-    ZRealm *realm;
+    Realm *realm;
     struct sockaddr_in newwho;
     Code_t status = ZERR_NONE;
     char rlm_recipient[REALM_SZ + 1];
@@ -467,11 +487,11 @@ realm_dispatch(ZNotice_t *notice,
 }
 
 void
-realm_init(void)
+realm_init()
 {
     Client *client;
-    ZRealmname *rlmnames;
-    ZRealm *rlm;
+    Realmname *rlmnames;
+    Realm *rlm;
     int ii, jj, found;
     struct in_addr *addresses;
     struct hostent *hp;
@@ -488,7 +508,7 @@ realm_init(void)
     
     for (nrealms = 0; *rlmnames[nrealms].name; nrealms++);
     
-    otherrealms = (ZRealm *)malloc(nrealms * sizeof(ZRealm));
+    otherrealms = (Realm *)malloc(nrealms * sizeof(Realm));
     if (!otherrealms) {
        syslog(LOG_CRIT, "malloc failed in realm_init");
        abort();
@@ -537,12 +557,8 @@ realm_init(void)
            abort();
        }
        memset(&client->addr, 0, sizeof(struct sockaddr_in));
-#ifdef HAVE_KRB5
-        client->session_keyblock = NULL;
-#else
 #ifdef HAVE_KRB4
        memset(&client->session_key, 0, sizeof(client->session_key));
-#endif
 #endif
        sprintf(rlmprinc, "%s.%s@%s", SERVER_SERVICE, SERVER_INSTANCE, 
                rlm->name);
@@ -570,9 +586,11 @@ realm_init(void)
 }
 
 void
-realm_deathgram(Server *server)
+realm_deathgram(server)
+    Server *server;
 {
-    ZRealm *realm;
+    Realm *realm;
+    char rlm_recipient[REALM_SZ + 1];
     int jj = 0;
 
     /* Get it out once, and assume foreign servers will share */
@@ -601,7 +619,7 @@ realm_deathgram(Server *server)
        zdbug((LOG_DEBUG, "rlm_deathgram: suggesting %s to %s", 
               (server) ? server->addr_str : "nothing", realm->name));
 
-#ifdef HAVE_KRB5
+#ifdef HAVE_KRB4
        if (!ticket_lookup(realm->name))
            if ((retval = ticket_retrieve(realm)) != ZERR_NONE) {
                syslog(LOG_WARNING, "rlm_deathgram failed: %s", 
@@ -610,7 +628,7 @@ realm_deathgram(Server *server)
            }
 #endif
 
-       if ((retval = ZFormatNotice(&snotice, &pack, &packlen, ZCAUTH)) 
+       if ((retval = ZFormatNotice(&snotice, &pack, &packlen, ZAUTH)) 
            != ZERR_NONE) 
        {
            syslog(LOG_WARNING, "rlm_deathgram format: %s",
@@ -630,10 +648,11 @@ realm_deathgram(Server *server)
 }
 
 void
-realm_wakeup(void)
+realm_wakeup()
 {
     int jj, found = 0;
-    ZRealm *realm;
+    Realm *realm;
+    char rlm_recipient[REALM_SZ + 1];
     
     for (jj = 1; jj < nservers; jj++) {    /* skip limbo server */
        if (jj != me_server_idx && otherservers[jj].state == SERV_UP)
@@ -666,7 +685,7 @@ realm_wakeup(void)
            snotice.z_message = NULL;
            snotice.z_message_len = 0;
 
-#ifdef HAVE_KRB5
+#ifdef HAVE_KRB4
            if (!ticket_lookup(realm->name))
                if ((retval = ticket_retrieve(realm)) != ZERR_NONE) {
                    syslog(LOG_WARNING, "rlm_wakeup failed: %s", 
@@ -697,19 +716,25 @@ realm_wakeup(void)
 }
 
 static Code_t
-realm_ulocate_dispatch(ZNotice_t *notice,
-                      int auth,
-                      struct sockaddr_in *who,
-                      Server *server,
-                      ZRealm *realm)
+realm_ulocate_dispatch(notice, auth, who, server, realm)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Server *server;
+    Realm *realm;
 {
     register char *opcode = notice->z_opcode;
+    Code_t status;
   
     if (!auth) {
        syslog(LOG_WARNING, "unauth locate msg from %s (%s/%s/%s)",
               inet_ntoa(who->sin_addr), 
               notice->z_class, notice->z_class_inst, 
               notice->z_opcode); /* XXX */
+#if 0
+       syslog(LOG_WARNING, "unauth locate msg from %s",
+              inet_ntoa(who->sin_addr));
+#endif
        clt_ack(notice, who, AUTH_FAILED);
        return(ZERR_NONE);
     }
@@ -731,11 +756,12 @@ realm_ulocate_dispatch(ZNotice_t *notice,
 
 
 Code_t
-realm_control_dispatch(ZNotice_t *notice,
-                      int auth,
-                      struct sockaddr_in *who,
-                      Server *server,
-                      ZRealm *realm)
+realm_control_dispatch(notice, auth, who, server, realm)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Server *server;
+    Realm *realm;
 {
     register char *opcode = notice->z_opcode;
     Code_t status;
@@ -745,6 +771,10 @@ realm_control_dispatch(ZNotice_t *notice,
               inet_ntoa(who->sin_addr), 
               notice->z_class, notice->z_class_inst, 
               notice->z_opcode); /* XXX */
+#if 0
+       syslog(LOG_WARNING, "unauth ctl msg from %s",
+              inet_ntoa(who->sin_addr));
+#endif
        if (server == me_server)
            clt_ack(notice, who, AUTH_FAILED);
        return(ZERR_NONE);
@@ -808,12 +838,15 @@ realm_control_dispatch(ZNotice_t *notice,
 }
 
 static Code_t
-realm_new_server(struct sockaddr_in *sin,
-                ZNotice_t *notice,
-                ZRealm *realm)
+realm_new_server(sin, notice, realm)
+    struct sockaddr_in *sin;
+    ZNotice_t *notice;
+    Realm *realm;
 {
+    struct hostent *hp;
+    char suggested_server[MAXHOSTNAMELEN];
     unsigned long addr;
-    ZRealm *rlm;
+    Realm *rlm;
     struct sockaddr_in sinaddr;
     int srvidx;
 
@@ -839,14 +872,14 @@ realm_new_server(struct sockaddr_in *sin,
     } else {
       zdbug((LOG_DEBUG, "rlm_new_srv: not switching servers (%s)", inet_ntoa((realm->addrs[realm->idx]).sin_addr)));
     }
-    return 0;
 }
 
 static Code_t
-realm_set_server(struct sockaddr_in *sin,
-                ZRealm *realm)
+realm_set_server(sin, realm)
+    struct sockaddr_in *sin;
+    Realm *realm;
 {
-    ZRealm *rlm;
+    Realm *rlm;
 
     rlm = realm_which_realm(sin);
     /* Not exactly */
@@ -854,18 +887,17 @@ realm_set_server(struct sockaddr_in *sin,
        return ZSRV_NORLM;
     realm->idx = realm_get_idx_by_addr(realm, sin);
     zdbug((LOG_DEBUG, "rlm_pick_srv: switched servers (%s)", inet_ntoa((realm->addrs[realm->idx]).sin_addr)));
-
-    return 0;
 }
 
 void
-realm_handoff(ZNotice_t *notice,
-             int auth,
-             struct sockaddr_in *who,
-             ZRealm *realm,
-             int ack_to_sender)
+realm_handoff(notice, auth, who, realm, ack_to_sender)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Realm *realm;
+    int ack_to_sender;
 {
-#ifdef HAVE_KRB5
+#ifdef HAVE_KRB4
     Code_t retval;
 
     if (!auth) {
@@ -885,18 +917,19 @@ realm_handoff(ZNotice_t *notice,
     
     zdbug((LOG_DEBUG, "realm_sendit to realm %s auth %d", realm->name, auth)); 
     /* valid ticket available now, send the message */
-    retval = realm_sendit_auth(notice, who, auth, realm, ack_to_sender);
+    realm_sendit_auth(notice, who, auth, realm, ack_to_sender);
 #else /* HAVE_KRB4 */
     realm_sendit(notice, who, auth, realm, ack_to_sender);
 #endif /* HAVE_KRB4 */
 }
 
 static void
-realm_sendit(ZNotice_t *notice,
-            struct sockaddr_in *who,
-            int auth,
-            ZRealm *realm,
-            int ack_to_sender)
+realm_sendit(notice, who, auth, realm, ack_to_sender)
+    ZNotice_t *notice;
+    struct sockaddr_in *who;
+    int auth;
+    Realm *realm;
+    int ack_to_sender;
 {
     caddr_t pack;
     int packlen;
@@ -949,12 +982,13 @@ realm_sendit(ZNotice_t *notice,
     /* set a timer to retransmit */
     nacked->timer = timer_set_rel(rexmit_times[0], rlm_rexmit, nacked);
     /* chain in */
-    Unacked_insert(&rlm_nacklist, nacked);
+    LIST_INSERT(&rlm_nacklist, nacked);
     return;
 }
 
 static void
-packet_ctl_nack(Unacked *nackpacket)
+packet_ctl_nack(nackpacket)
+    Unacked *nackpacket;
 {
     ZNotice_t notice;
 
@@ -962,17 +996,21 @@ packet_ctl_nack(Unacked *nackpacket)
     ZParseNotice(nackpacket->packet, nackpacket->packsz, &notice);
     if (nackpacket->ack_addr.sin_addr.s_addr != 0)
        nack(&notice, &nackpacket->ack_addr);
+#if 1
     else
        syslog(LOG_WARNING, "would have acked nobody (%s/%s/%s)",
               notice.z_class, notice.z_class_inst, notice.z_opcode); /* XXX */
+#endif
 }
 
 static void
-rlm_rexmit(void *arg)
+rlm_rexmit(arg)
+    void *arg;
 {
     Unacked *nackpacket = (Unacked *) arg;
     Code_t retval;
-    register ZRealm *realm;
+    register Realm *realm;
+    int new_srv_idx;
 
     zdbug((LOG_DEBUG,"rlm_rexmit"));
 
@@ -988,7 +1026,7 @@ rlm_rexmit(void *arg)
     if (nackpacket->rexmits >= (NUM_REXMIT_TIMES * realm->count)) {
        /* give a server ack that the packet is lost/realm dead */
        packet_ctl_nack(nackpacket);
-       Unacked_delete(nackpacket);
+       LIST_DELETE(nackpacket);
        
        zdbug((LOG_DEBUG, "rlm_rexmit: %s appears dead", realm->name));
        realm->state = REALM_DEAD;
@@ -1045,7 +1083,8 @@ rlm_rexmit(void *arg)
 }
 
 void
-realm_dump_realms(FILE *fp)
+realm_dump_realms(fp)
+    FILE *fp;
 {
     register int ii, jj;
   
@@ -1060,41 +1099,49 @@ realm_dump_realms(FILE *fp)
     }
 }
 
-#ifdef HAVE_KRB5
-static Code_t
-realm_sendit_auth(ZNotice_t *notice,
-                 struct sockaddr_in *who,
-                 int auth,
-                 ZRealm *realm,
-                 int ack_to_sender)
+#ifdef HAVE_KRB4
+static void
+realm_sendit_auth(notice, who, auth, realm, ack_to_sender)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Realm *realm;
+    int ack_to_sender;
 {
     char *buffer, *ptr;
-    int buffer_len, hdrlen, offset, fragsize, message_len;
+    caddr_t pack;
+    int buffer_len, hdrlen, offset, fragsize, ret_len, message_len;
     int origoffset, origlen;
     Code_t retval;
     Unacked *nacked;
-    char multi[64];
+    char buf[1024], multi[64];
+    CREDENTIALS cred;
+    KTEXT_ST authent;
     ZNotice_t partnotice, newnotice;
 
     offset = 0;
 
-    buffer = (char *) malloc(sizeof(ZPacket_t));
-    if (!buffer) {
-        syslog(LOG_ERR, "realm_sendit_auth malloc");
-        return ENOMEM;                 /* DON'T put on nack list */
+    /* build an authent. first, make sure we have the ticket available */
+    retval = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, realm->name, &cred);
+    if (retval != GC_OK) {
+       syslog(LOG_WARNING, "rlm_sendit_auth get_cred: %s",
+              error_message(retval+krb_err_base));
+       return;
     }
 
-    buffer_len = sizeof(ZPacket_t);
-
-    newnotice = *notice;
+    retval = krb_mk_req(&authent, SERVER_SERVICE, SERVER_INSTANCE, 
+                       realm->name, 1);
+    if (retval != MK_AP_OK) {
+       syslog(LOG_WARNING, "rlm_sendit_auth mk_req: %s",
+              error_message(retval+krb_err_base));
+       return;
+    }
 
-    hdrlen = 0;
-    retval = ZMakeZcodeRealmAuthentication(&newnotice, buffer, buffer_len,
-                                          &hdrlen, realm->name);
+    retval = ZMakeAscii(buf, sizeof(buf), authent.dat, authent.length);
     if (retval != ZERR_NONE) {
-       syslog(LOG_WARNING, "rlm_sendit_auth make zcksum: %s", 
+       syslog(LOG_WARNING, "rlm_sendit_auth mk_ascii: %s",
               error_message(retval));
-       return (retval);
+       return;
     }
 
     /* set the dest addr */
@@ -1102,7 +1149,45 @@ realm_sendit_auth(ZNotice_t *notice,
     if (retval != ZERR_NONE) {
        syslog(LOG_WARNING, "rlm_sendit_auth set addr: %s", 
               error_message(retval));
-       return (retval);
+       return;
+    }
+
+    /* now format the notice, refragmenting if needed */
+    newnotice = *notice;
+    newnotice.z_auth = 1;
+    newnotice.z_ascii_authent = buf;
+    newnotice.z_authent_len = authent.length;
+    
+    buffer = (char *) malloc(sizeof(ZPacket_t));
+    if (!buffer) {
+       syslog(LOG_ERR, "realm_sendit_auth malloc");
+       return;                 /* DON'T put on nack list */
+    }
+    
+    buffer_len = sizeof(ZPacket_t);
+    
+    retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len, &hdrlen, &ptr, 
+                              NULL);
+    if (retval != ZERR_NONE) {
+       syslog(LOG_WARNING, "rlm_sendit_auth raw: %s", error_message(retval));
+       free(buffer);
+       return;
+    }
+
+#ifdef NOENCRYPTION
+    newnotice.z_checksum = 0;
+#else
+    newnotice.z_checksum =
+       (ZChecksum_t)des_quad_cksum(buffer, NULL, ptr - buffer, 0, 
+                                   cred.session);
+#endif
+
+    retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len, &hdrlen, 
+                              NULL, NULL);
+    if (retval != ZERR_NONE) {
+       syslog(LOG_WARNING, "rlm_sendit_auth raw: %s", error_message(retval));
+       free(buffer);
+       return;
     }
   
     /* This is not terribly pretty, but it does do its job. 
@@ -1114,14 +1199,17 @@ realm_sendit_auth(ZNotice_t *notice,
      * but only the server uses it.
      */ 
 
-    if ((notice->z_message_len+hdrlen > buffer_len) || 
-       (notice->z_message_len+hdrlen > Z_MAXPKTLEN)) {
-
-       /* Reallocate buffers inside the refragmenter */
+    if ((newnotice.z_message_len+hdrlen > buffer_len) || 
+       (newnotice.z_message_len+hdrlen > Z_MAXPKTLEN)) {
+       /* Deallocate buffer, use a local one */
        free(buffer);
-
+    
        partnotice = *notice;
 
+       partnotice.z_auth = 1;
+       partnotice.z_ascii_authent = buf;
+       partnotice.z_authent_len = authent.length;
+
        origoffset = 0;
        origlen = notice->z_message_len;
 
@@ -1129,9 +1217,14 @@ realm_sendit_auth(ZNotice_t *notice,
            if (sscanf(notice->z_multinotice, "%d/%d", &origoffset, 
                       &origlen) != 2) {
                syslog(LOG_WARNING, "rlm_sendit_auth frag: parse failed");
-               return ZERR_BADFIELD;
+               return;
            }
 
+#if 0
+       zdbug((LOG_DEBUG,"rlm_send_auth: orig: %d-%d/%d", origoffset, 
+              notice->z_message_len, origlen));
+#endif
+
        fragsize = Z_MAXPKTLEN-hdrlen-Z_FRAGFUDGE;
 
        while (offset < notice->z_message_len || !notice->z_message_len) {
@@ -1151,22 +1244,41 @@ realm_sendit_auth(ZNotice_t *notice,
            partnotice.z_message = notice->z_message+offset;
            partnotice.z_message_len = message_len;
 
+#if 0
+           zdbug((LOG_DEBUG,"rlm_send_auth: new: %d-%d/%d", 
+                  origoffset+offset, message_len, origlen));
+#endif
+
            buffer = (char *) malloc(sizeof(ZPacket_t));
            if (!buffer) {
                syslog(LOG_ERR, "realm_sendit_auth malloc");
-               return ENOMEM;                 /* DON'T put on nack list */
+               return;                 /* DON'T put on nack list */
            }
-
-           buffer_len = sizeof(ZPacket_t);
            
-           retval = ZMakeZcodeRealmAuthentication(&partnotice, buffer, 
-                                                  buffer_len, &hdrlen, 
-                                                  realm->name);
+           retval = Z_FormatRawHeader(&partnotice, buffer, buffer_len, 
+                                      &hdrlen, &ptr, NULL);
            if (retval != ZERR_NONE) {
-               syslog(LOG_WARNING, "rlm_sendit_auth set addr: %s", 
+               syslog(LOG_WARNING, "rlm_sendit_auth raw: %s", 
                       error_message(retval));
                free(buffer);
-               return (retval);
+               return;
+           }
+
+#ifdef NOENCRYPTION
+           partnotice.z_checksum = 0;
+#else
+           partnotice.z_checksum =
+               (ZChecksum_t)des_quad_cksum(buffer, NULL, ptr - buffer, 0, 
+                                           cred.session);
+#endif
+
+           retval = Z_FormatRawHeader(&partnotice, buffer, buffer_len, 
+                                      &hdrlen, NULL, NULL);
+           if (retval != ZERR_NONE) {
+               syslog(LOG_WARNING, "rlm_sendit_auth raw: %s", 
+                      error_message(retval));
+               free(buffer);
+               return;
            }
 
            ptr = buffer+hdrlen;
@@ -1180,14 +1292,14 @@ realm_sendit_auth(ZNotice_t *notice,
                syslog(LOG_WARNING, "rlm_sendit_auth xmit: %s", 
                       error_message(retval));
                free(buffer);
-               return(retval);
+               return;
            }
 
            if (!(nacked = (Unacked *)malloc(sizeof(Unacked)))) {
                /* no space: just punt */
                syslog(LOG_ERR, "rlm_sendit_auth nack malloc");
                free(buffer);
-               return ENOMEM;
+               return;
            }
 
            nacked->rexmits = 0;
@@ -1207,37 +1319,42 @@ realm_sendit_auth(ZNotice_t *notice,
            nacked->timer = timer_set_rel(rexmit_times[0], rlm_rexmit, nacked);
 
            /* chain in */
-           Unacked_insert(&rlm_nacklist, nacked);
+           LIST_INSERT(&rlm_nacklist, nacked);
 
            offset += fragsize;
            
            if (!notice->z_message_len)
                break;
        }
-    }
-    else {
+#if 0
+       zdbug((LOG_DEBUG, "rlm_sendit_auth frag message sent"));
+#endif
+    } else {
        /* This is easy, no further fragmentation needed */
        ptr = buffer+hdrlen;
 
        (void) memcpy(ptr, newnotice.z_message, newnotice.z_message_len);
 
-        buffer_len = hdrlen+newnotice.z_message_len;
+       buffer_len = hdrlen+newnotice.z_message_len;
     
        /* now send */
        if ((retval = ZSendPacket(buffer, buffer_len, 0)) != ZERR_NONE) {
            syslog(LOG_WARNING, "rlm_sendit_auth xmit: %s", 
                   error_message(retval));
            free(buffer);
-           return(retval);
+           return;
        }
 
+#if 0
+       zdbug((LOG_DEBUG, "rlm_sendit_auth message sent"));
+#endif
        /* now we've sent it, mark it as not ack'ed */
     
        if (!(nacked = (Unacked *)malloc(sizeof(Unacked)))) {
            /* no space: just punt */
            syslog(LOG_ERR, "rlm_sendit_auth nack malloc");
            free(buffer);
-           return 0;
+           return;
        }
 
        nacked->rexmits = 0;
@@ -1256,102 +1373,63 @@ realm_sendit_auth(ZNotice_t *notice,
        /* set a timer to retransmit */
        nacked->timer = timer_set_rel(rexmit_times[0], rlm_rexmit, nacked);
        /* chain in */
-       Unacked_insert(&rlm_nacklist, nacked);
+       LIST_INSERT(&rlm_nacklist, nacked);
     }
-    return 0;
+    return;
 }
 
 static int
-ticket_lookup(char *realm)
+ticket_expired(cred)
+CREDENTIALS *cred;
 {
-    krb5_error_code result;
-    krb5_timestamp sec;
-    krb5_ccache ccache; 
-    krb5_creds creds_in, *creds; 
-
-    result = krb5_cc_default(Z_krb5_ctx, &ccache); 
-    if (result) 
-      return 0;
-
-    memset(&creds_in, 0, sizeof(creds_in)); 
-    result = krb5_cc_get_principal(Z_krb5_ctx, ccache, &creds_in.client); 
-    if (result) {
-      krb5_cc_close(Z_krb5_ctx, ccache);
-      return 0;
-    }
-
-    result = krb5_build_principal(Z_krb5_ctx, &creds_in.server, 
-                                  strlen(realm), 
-                                  realm, 
-                                  SERVER_KRB5_SERVICE, SERVER_INSTANCE, 0); 
-    if (result) {
-      krb5_cc_close(Z_krb5_ctx, ccache);
-      return 0;
-    }
+#ifdef HAVE_KRB_LIFE_TO_TIME
+    return (krb_life_to_time(cred->issue_date, cred->lifetime) < NOW);
+#else /* HAVE_KRB_LIFE_TO_TIME */
+    return (cred->issue_date + cred->lifetime*5*60 < NOW);
+#endif /* HAVE_KRB_LIFE_TO_TIME */
+}
 
-    result = krb5_get_credentials(Z_krb5_ctx, 0 /* flags */, ccache, 
-                                  &creds_in, &creds); 
-    krb5_cc_close(Z_krb5_ctx, ccache);
-    /* good ticket? */
+static int
+ticket_lookup(realm)
+char *realm;
+{
+    CREDENTIALS cred;
+    KTEXT_ST authent;
+    int retval;
 
-    krb5_timeofday (Z_krb5_ctx, &sec);
-    krb5_free_cred_contents(Z_krb5_ctx, &creds_in); /* hope this is OK */ 
-    if ((result == 0) && (sec < creds->times.endtime)) {
-      krb5_free_creds(Z_krb5_ctx, creds);
-      return (1);
-    }
-    if (!result) krb5_free_creds(Z_krb5_ctx, creds);
+    retval = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, realm, &cred);
+    if (retval == GC_OK && !ticket_expired(&cred))
+       /* good ticket */
+       return(1);
 
     return (0);
 }
 
 static Code_t
-ticket_retrieve(ZRealm *realm)
+ticket_retrieve(realm)
+    Realm *realm;
 {
-    int pid;
-    krb5_ccache ccache;
-    krb5_error_code result; 
-    krb5_creds creds_in, *creds; 
+    int pid, retval = 0;
+    KTEXT_ST authent;
     
     get_tgt();
 
     if (realm->child_pid) 
        /* Right idea. Basically, we haven't gotten it yet */
-       return KRB5KRB_AP_ERR_TKT_EXPIRED;
+       return KRBET_KDC_AUTH_EXP;
 
-    if (realm->have_tkt) {
-       /* Get a pointer to the default ccache. We don't need to free this. */ 
-       result = krb5_cc_default(Z_krb5_ctx, &ccache); 
+    /* For Putrify */
+    memset(&authent.dat,0,MAX_KTXT_LEN);
+    authent.mbz=0;
 
-       /* GRRR.  There's no allocator or constructor for krb5_creds */ 
-       /* GRRR.  It would be nice if this API were documented at all */ 
-       memset(&creds_in, 0, sizeof(creds_in)); 
-       if (!result) 
-           result = krb5_cc_get_principal(Z_krb5_ctx, ccache, &creds_in.client); 
-       /* construct the service principal */ 
-       if (!result)  
-           result = krb5_build_principal(Z_krb5_ctx, &creds_in.server, 
-                                         strlen(realm->name), realm->name, 
-                                         SERVER_KRB5_SERVICE, SERVER_INSTANCE, 
-                                         0); 
-
-       /* HOLDING: creds_in.server */ 
-     
-       /* look up or get the credentials we need */ 
-       if (!result) 
-           result = krb5_get_credentials(Z_krb5_ctx, 0 /* flags */, ccache, 
-                                         &creds_in, &creds); 
-       krb5_cc_close(Z_krb5_ctx, ccache);
-       krb5_free_cred_contents(Z_krb5_ctx, &creds_in); /* hope this is OK */ 
-       if (!result) {
-           krb5_free_creds(Z_krb5_ctx, creds); 
-           return 0; 
+    if (realm->have_tkt) {
+       retval = krb_mk_req(&authent, SERVER_SERVICE, SERVER_INSTANCE,
+                           realm->name, 0);
+       if (retval == KSUCCESS) {
+           return retval;
        }
     } else {
        syslog(LOG_ERR, "tkt_rtrv: don't have ticket, but have no child");
-        result = KRB5KRB_AP_ERR_TKT_EXPIRED;
     }
  
     pid = fork();
@@ -1389,37 +1467,11 @@ ticket_retrieve(ZRealm *realm)
 #endif
 #endif
 
-       syslog(LOG_INFO, "tkt_rtrv running for %s", realm->name);
        while (1) {
-           /* Get a pointer to the default ccache. We don't need to free this. */ 
-           result = krb5_cc_default(Z_krb5_ctx, &ccache); 
-
-           /* GRRR.  There's no allocator or constructor for krb5_creds */ 
-           /* GRRR.  It would be nice if this API were documented at all */ 
-           memset(&creds_in, 0, sizeof(creds_in)); 
-           if (!result) 
-               result = krb5_cc_get_principal(Z_krb5_ctx, ccache, &creds_in.client); 
-           /* construct the service principal */ 
-           if (!result)  
-               result = krb5_build_principal(Z_krb5_ctx, &creds_in.server, 
-                                             strlen(realm->name), realm->name, 
-                                             SERVER_KRB5_SERVICE, SERVER_INSTANCE, 
-                                             0); 
-
-           /* HOLDING: creds_in.server */ 
-           
-           /* look up or get the credentials we need */ 
-           if (!result) 
-               result = krb5_get_credentials(Z_krb5_ctx, 0 /* flags */, ccache, 
-                                             &creds_in, &creds); 
-           krb5_cc_close(Z_krb5_ctx, ccache);
-           krb5_free_cred_contents(Z_krb5_ctx, &creds_in); /* hope this is OK */ 
-           if (!result) {
-               krb5_free_creds(Z_krb5_ctx, creds); 
-               syslog(LOG_INFO, "tkt_rtrv succeeded for %s", realm->name);
+           retval = krb_mk_req(&authent, SERVER_SERVICE, SERVER_INSTANCE,
+                               realm->name, 0);
+           if (retval == KSUCCESS)
                exit(0);
-           }
       
            /* Sleep a little while before retrying */
            sleep(30);
@@ -1427,11 +1479,11 @@ ticket_retrieve(ZRealm *realm)
     } else {
        realm->child_pid = pid;
        realm->have_tkt = 0;
-
-       syslog(LOG_WARNING, "tkt_rtrv: %s: %d", realm->name,
-              result);
-       return (result);
+       
+       syslog(LOG_WARNING, "tkt_rtrv: %s: %s", realm->name,
+              krb_err_txt[retval]);
+       return (retval+krb_err_base);
     }
 }
-#endif /* HAVE_KRB5 */
+#endif /* HAVE_KRB4 */
 
index 99fc59a81be68c35576fd2ef106e0a7c6075016b..1849018403b637f1739a60012b58f63fcdc880b1 100644 (file)
@@ -87,9 +87,12 @@ static Code_t admin_dispatch __P((ZNotice_t *, int, struct sockaddr_in *,
 static Code_t kill_clt __P((ZNotice_t *, Server *));
 static Code_t extract_addr __P((ZNotice_t *, struct sockaddr_in *));
 
+#ifdef notdef
+static Code_t server_register();
+#endif
+
 static struct in_addr *get_server_addrs __P((int *number));
 static char **get_server_list __P((char *file));
-static char **get_single_server __P((void));
 static void free_server_list __P((char **list));
 
 static Unacked *srv_nacktab[SRV_NACKTAB_HASHSIZE];
@@ -129,7 +132,7 @@ int zalone;
  */
 
 void
-server_init(void)
+server_init()
 {
     int i;
     struct in_addr *serv_addr, *server_addrs, limbo_addr;
@@ -173,6 +176,9 @@ server_init(void)
            otherservers[i].timer = NULL;
            otherservers[i].queue = NULL;
            otherservers[i].dumping = 0;
+#if 0
+           zdbug((LOG_DEBUG,"found myself"));
+#endif
        }
     }
 
@@ -222,7 +228,7 @@ server_init(void)
  * handle on a particular server other than by indexing on otherservers[].
  */
 void
-server_reset(void)
+server_reset()
 {
     int num_servers;
     struct in_addr *server_addrs;
@@ -232,6 +238,9 @@ server_reset(void)
     int *ok_list_new, *ok_list_old;
     int num_ok, new_num;
 
+#if 0
+    zdbug((LOG_DEBUG, "server_reset"));
+#endif
 #ifdef DEBUG
     if (zalone) {
        syslog(LOG_INFO, "server_reset while alone, punt");
@@ -387,11 +396,18 @@ server_reset(void)
        if (i != me_server_idx && !otherservers[i].timer) {
            otherservers[i].timer =
                timer_set_rel(0L, server_timo, &otherservers[i]);
+#if 0
+           zdbug((LOG_DEBUG, "reset timer for %s",
+                  otherservers[i].addr_str));
+#endif 
        }
     }
     free(ok_list_old);
     free(ok_list_new);
 
+#if 0
+    zdbug((LOG_DEBUG, "server_reset: %d servers now", nservers));
+#endif
 }
 
 /* note: these must match the order given in zserver.h */
@@ -420,11 +436,15 @@ rlm_states[] = {
  */
 
 void
-server_timo(void *arg)
+server_timo(arg)
+    void *arg;
 {
     Server *which = (Server *) arg;
     int auth = 0;
 
+#if 0
+    zdbug((LOG_DEBUG,"srv_timo: %s", which->addr_str));
+#endif
     /* change state and reset if appropriate */
     switch(which->state) {
       case SERV_DEAD:                  /* leave him dead */
@@ -451,11 +471,15 @@ server_timo(void *arg)
        auth = 0;
        break;
       default:
-       syslog(LOG_ERR,"Bad server state, server 0x%x\n", (int)which);
+       syslog(LOG_ERR,"Bad server state, server 0x%x\n",which);
        abort();
     }
     /* now he's either TARDY, STARTING, or DEAD
        We send a "hello," which increments the counter */
+#if 0
+    zdbug((LOG_DEBUG, "srv %s is %s", which->addr_str,
+          srv_states[which->state]));
+#endif
     server_hello(which, auth);
     /* reschedule the timer */
     which->timer = timer_set_rel(which->timeout, server_timo, which);
@@ -467,15 +491,19 @@ server_timo(void *arg)
 
 /*ARGSUSED*/
 Code_t
-server_dispatch(ZNotice_t *notice,
-               int auth,
-               struct sockaddr_in *who)
+server_dispatch(notice, auth, who)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
 {
     Server *server;
     struct sockaddr_in newwho;
     Code_t status;
     String *notice_class;
 
+#if 0
+    zdbug((LOG_DEBUG, "server_dispatch"));
+#endif
 
     if (notice->z_kind == SERVACK) {
        srv_nack_cancel(notice, who);
@@ -524,12 +552,80 @@ server_dispatch(ZNotice_t *notice,
     return status;
 }
 
+#ifdef notdef
+/*
+ * Register a new server (one not in our list).  This MUST be authenticated.
+ */
+
+/*ARGSUSED*/
+static Code_t
+server_register(notice, auth, who)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+{
+    Server *temp;
+    int i;
+    long timerval;
+
+    if (who->sin_port != srv_addr.sin_port) {
+#if 0
+       zdbug((LOG_DEBUG, "srv_wrong port %d", ntohs(who->sin_port)));
+#endif
+       return 1;
+    }
+    /* Not yet... talk to ken about authenticators */
+#ifdef notdef
+    if (!auth) {
+#if 0
+       zdbug((LOG_DEBUG, "srv_unauth"));
+#endif
+       return 1;
+    }
+#endif /* notdef */
+    /* OK, go ahead and set him up. */
+    temp = (Server *) malloc((nservers + 1) * sizeof(Server));
+    if (!temp) {
+       syslog(LOG_CRIT, "srv_reg malloc");
+       return 1;
+    }
+
+    memcpy(temp, otherservers, nservers * sizeof(Server));
+    free(otherservers);
+    otherservers = temp;
+    /* don't reschedule limbo's timer, so start i=1 */
+    for (i = 1; i < nservers; i++) {
+       if (i == me_server_idx) /* don't reset myself */
+           continue;
+       /* reschedule the timers--we moved otherservers */
+       timerval = timer_when(otherservers[i].timer);
+       timer_reset(otherservers[i].timer);
+       otherservers[i].timer = timer_set_abs(timerval, server_timo,
+                                             &otherservers[i]);
+    }
+    setup_server(&otherservers[nservers], &who->sin_addr);
+    otherservers[nservers].state = SERV_STARTING;
+    otherservers[nservers].timeout = timo_tardy;
+    otherservers[nservers].update_queue = NULL;
+    otherservers[nservers].dumping = 0;
+
+    nservers++;
+#if 0
+    zdbug((LOG_DEBUG, "srv %s is %s", otherservers[nservers].addr_str,
+          srv_states[otherservers[nservers].state]));
+#endif
+
+    return 0;
+}
+#endif
+
 /*
  * Tell the other servers that this client died.
  */
 
 void
-server_kill_clt(Client *client)
+server_kill_clt(client)
+    Client *client;
 {
     int i;
     char buf[512], *lyst[2];
@@ -543,6 +639,10 @@ server_kill_clt(Client *client)
     sprintf(buf, "%d", ntohs(client->addr.sin_port));
     lyst[1] = buf;
 
+#if 0
+    zdbug((LOG_DEBUG, "server kill clt %s/%s", lyst[0], lyst[1]));
+#endif
+
     pnotice = &notice;
 
     memset (&notice, 0, sizeof(notice));
@@ -583,12 +683,16 @@ server_kill_clt(Client *client)
  */
 
 static Code_t
-kill_clt(ZNotice_t *notice,
-        Server *server)
+kill_clt(notice, server)
+    ZNotice_t *notice;
+    Server *server;
 {
     struct sockaddr_in who;
     Client *client;
 
+#if 0
+    zdbug((LOG_DEBUG, "kill_clt"));
+#endif
     if (extract_addr(notice, &who) != ZERR_NONE)
        return ZERR_NONE;       /* XXX */
     client = client_find(&who.sin_addr, notice->z_port);
@@ -598,11 +702,12 @@ kill_clt(ZNotice_t *notice,
               server->addr_str);
        return ZERR_NONE;       /* XXX */
     }
-
-    if (zdebug) {
+#if 1
+    if (zdebug || 1) {
        syslog(LOG_DEBUG, "kill_clt clt_dereg %s/%d from %s",
               inet_ntoa(who.sin_addr), ntohs(who.sin_port), server->addr_str);
     }
+#endif
 
     /* remove the locations, too */
     client_deregister(client, 1);
@@ -614,8 +719,9 @@ kill_clt(ZNotice_t *notice,
  */
 
 static Code_t
-extract_addr(ZNotice_t *notice,
-            struct sockaddr_in *who)
+extract_addr(notice, who)
+    ZNotice_t *notice;
+    struct sockaddr_in *who;
 {
     char *cp = notice->z_message;
 
@@ -632,6 +738,10 @@ extract_addr(ZNotice_t *notice,
     }
     who->sin_port = notice->z_port = htons((u_short) atoi(cp));
     who->sin_family = AF_INET;
+#if 0
+    zdbug((LOG_DEBUG,"ext %s/%d", inet_ntoa(who->sin_addr),
+          ntohs(who->sin_port)));
+#endif
     return ZERR_NONE;
 }
 
@@ -640,8 +750,13 @@ extract_addr(ZNotice_t *notice,
  */
 
 static void
-server_flush(Server *which)
+server_flush(which)
+    Server *which;
 {
+#if 0
+    if (zdebug)
+       syslog(LOG_DEBUG, "server_flush %s", which->addr_str);
+#endif
     srv_nack_release(which);
 }
 
@@ -651,8 +766,9 @@ server_flush(Server *which)
  */
 
 static void
-server_hello(Server *which,
-            int auth)
+server_hello(which, auth)
+    Server *which;
+    int auth;
 {
     send_msg(&which->addr, ADMIN_HELLO, auth);
     which->num_hello_sent++;
@@ -664,26 +780,38 @@ server_hello(Server *which,
 
 /*ARGSUSED*/
 static Code_t
-admin_dispatch(ZNotice_t *notice,
-              int auth,
-              struct sockaddr_in *who,
-              Server *server)
+admin_dispatch(notice, auth, who, server)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Server *server;
 {
     char *opcode = notice->z_opcode;
     Code_t status = ZERR_NONE;
 
+#if 0
+    zdbug((LOG_DEBUG, "ADMIN received"));
+#endif
+
     if (strcmp(opcode, ADMIN_HELLO) == 0) {
        hello_respond(who, ADJUST, auth);
     } else if (strcmp(opcode, ADMIN_IMHERE) == 0) {
        srv_responded(who);
     } else if (strcmp(opcode, ADMIN_SHUTDOWN) == 0) {
+#if 0
+       zdbug((LOG_DEBUG, "server shutdown"));
+#endif
        if (server) {
            srv_nack_release(server);
            server->state = SERV_DEAD;
            server->timeout = timo_dead;
            /* don't worry about the timer, it will
               be set appropriately on the next send */
-       }
+#if 0
+           zdbug((LOG_DEBUG, "srv %s is %s", server->addr_str,
+                  srv_states[server->state]));
+#endif
+               }
     } else if (strcmp(opcode, ADMIN_BDUMP) == 0) {
        /* Ignore a brain dump request if this is a brain dump packet
          * or a packet being processed concurrently during a brain
@@ -710,10 +838,11 @@ admin_dispatch(ZNotice_t *notice,
 
 /*ARGSUSED*/
 Code_t
-server_adispatch(ZNotice_t *notice,
-                int auth,
-                struct sockaddr_in *who,
-                Server *server)
+server_adispatch(notice, auth, who, server)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Server *server;
 {
 
     /* this had better be a HELLO message--start of acquisition
@@ -725,21 +854,33 @@ server_adispatch(ZNotice_t *notice,
        return ZERR_NONE;
     }
 
+#ifdef notdef
+    syslog(LOG_INFO, "disp: new server?");
+    if (server_register(notice, auth, who) != ZERR_NONE) {
+       syslog(LOG_INFO, "new server failed");
+    } else {
+       syslog(LOG_INFO, "new server %s, %d", inet_ntoa(who->sin_addr),
+              ntohs(who->sin_port));
+       hello_respond(who, DONT_ADJUST, auth);
+    }
+#else
     syslog(LOG_INFO, "srv_adisp: server attempt from %s",
           inet_ntoa(who->sin_addr));
+#endif /* notdef */
 
     return ZERR_NONE;
 }
 
 static void
-send_stats(struct sockaddr_in *who)
+send_stats(who)
+    struct sockaddr_in *who;
 {
     int i;
     char buf[BUFSIZ];
     char **responses;
     int num_resp;
     char *vers, *pkts, *upt;
-    ZRealm *realm;
+    Realm *realm;
 
     int extrafields = 0;
 #define        NUM_FIXED 3                     /* 3 fixed fields, plus server info */
@@ -748,9 +889,9 @@ send_stats(struct sockaddr_in *who)
                                           do it this way. */
     vers = get_version();
 
-    sprintf(buf, "%lu pkts", npackets);
+    sprintf(buf, "%d pkts", npackets);
     pkts = strsave(buf);
-    sprintf(buf, "%ld seconds operational",NOW - uptime);
+    sprintf(buf, "%d seconds operational",NOW - uptime);
     upt = strsave(buf);
 
 #ifdef OLD_COMPAT
@@ -834,7 +975,8 @@ send_stats(struct sockaddr_in *who)
  */
 
 static struct in_addr *
-get_server_addrs(int *number)
+get_server_addrs(number)
+    int *number; /* RETURN */
 {
     int i;
     char **server_hosts = NULL;
@@ -848,12 +990,8 @@ get_server_addrs(int *number)
     server_hosts_free = server_hosts;
 #ifdef HAVE_HESIOD
     if (!server_hosts)
-       server_hosts = hes_resolve("zephyr","sloc");
+      server_hosts = hes_resolve("zephyr","sloc");
 #endif
-    if (!server_hosts) {
-       server_hosts = get_single_server();
-       server_hosts_free = server_hosts;
-    }
     if (!server_hosts)
        return NULL;
     /* count up */
@@ -887,7 +1025,8 @@ static int nhosts = 0;
  */
 
 static char **
-get_server_list(char *file)
+get_server_list(file)
+    char *file;
 {
     FILE *fp;
     char buf[MAXHOSTNAMELEN];
@@ -895,55 +1034,36 @@ get_server_list(char *file)
     int nused = 0;
     char *newline;
 
-    fp = fopen(file, "r");
-    if (!fp)
-       return NULL;
     /* start with 16, realloc if necessary */
     nhosts = 16;
     ret_list = (char **) malloc(nhosts * sizeof(char *));
-    if (!ret_list)
-       return NULL;
-
-    while (fgets(buf, MAXHOSTNAMELEN, fp)) {
-       /* nuke the newline, being careful not to overrun
-          the buffer searching for it with strlen() */
-       buf[MAXHOSTNAMELEN - 1] = '\0';
-       newline = strchr(buf, '\n');
-       if (newline)
-           *newline = '\0';
-
-       if (nused + 1 >= nhosts) {
-           /* get more pointer space if necessary */
-           /* +1 to leave room for null pointer */
-           ret_list = (char **) realloc(ret_list, nhosts * 2);
-           nhosts = nhosts * 2;
+
+    fp = fopen(file, "r");
+    if (fp) {
+       while (fgets(buf, MAXHOSTNAMELEN, fp)) {
+           /* nuke the newline, being careful not to overrun
+              the buffer searching for it with strlen() */
+           buf[MAXHOSTNAMELEN - 1] = '\0';
+           newline = strchr(buf, '\n');
+           if (newline)
+               *newline = '\0';
+
+           if (nused + 1 >= nhosts) {
+               /* get more pointer space if necessary */
+               /* +1 to leave room for null pointer */
+               ret_list = (char **) realloc(ret_list, nhosts * 2);
+               nhosts = nhosts * 2;
+           }
+           ret_list[nused++] = strsave(buf);
+       }
+       fclose(fp);
+    } else {
+       if (gethostname(buf, sizeof(buf)) < 0) {
+           free(ret_list);
+           return NULL;
        }
        ret_list[nused++] = strsave(buf);
     }
-    fclose(fp);
-    if (!nused) {
-       free(ret_list);
-       return NULL;
-    }
-    ret_list[nused] = NULL;
-    return ret_list;
-}
-
-static char **
-get_single_server(void)
-{
-    char buf[MAXHOSTNAMELEN];
-    char **ret_list;
-    int nused = 0;
-    nhosts = 2;
-    ret_list = (char **) malloc(nhosts * sizeof(char *));
-    if (!ret_list)
-       return NULL;
-    if (gethostname(buf, sizeof(buf)) < 0) {
-       free(ret_list);
-       return NULL;
-    }
-    ret_list[nused++] = strsave(buf);
     ret_list[nused] = NULL;
     return ret_list;
 }
@@ -952,7 +1072,8 @@ get_single_server(void)
  * free storage allocated by get_server_list
  */
 static void
-free_server_list(char **list)
+free_server_list(list)
+    char **list;
 {
     char **orig_list = list;
 
@@ -970,8 +1091,9 @@ free_server_list(char **list)
  */
 
 static void
-setup_server(Server *server,
-            struct in_addr *addr)
+setup_server(server, addr)
+    Server *server;
+    struct in_addr *addr;
 {
     server->state = SERV_DEAD;
     server->timeout = timo_dead;
@@ -991,12 +1113,17 @@ setup_server(Server *server,
  */
 
 static void
-hello_respond(struct sockaddr_in *who,
-             int adj,
-             int auth)
+hello_respond(who, adj, auth)
+    struct sockaddr_in *who;
+    int adj;
+    int auth;
 {
     Server *which;
 
+#if 0
+    zdbug((LOG_DEBUG, "hello from %s", inet_ntoa(who->sin_addr)));
+#endif
+
     send_msg(who, ADMIN_IMHERE, auth);
     if (adj != ADJUST)
        return;
@@ -1027,7 +1154,8 @@ hello_respond(struct sockaddr_in *who,
  */
 
 Server *
-server_which_server(struct sockaddr_in *who)
+server_which_server(who)
+    struct sockaddr_in *who;
 {
     Server *server;
     int i;
@@ -1048,10 +1176,15 @@ server_which_server(struct sockaddr_in *who)
  * appropriately.
  */
 static void
-srv_responded(struct sockaddr_in *who)
+srv_responded(who)
+    struct sockaddr_in *who;
 {
     Server *which = server_which_server(who);
 
+#if 0
+    zdbug((LOG_DEBUG, "srv_responded %s", inet_ntoa(who->sin_addr)));
+#endif
+
     if (!which) {
        syslog(LOG_ERR, "hello input from non-server?!");
        return;
@@ -1084,6 +1217,10 @@ srv_responded(struct sockaddr_in *who)
        which->timer = timer_set_rel(which->timeout, server_timo, which);
        break;
     }
+#if 0
+    zdbug((LOG_DEBUG, "srv %s is %s", which->addr_str,
+          srv_states[which->state]));
+#endif
 }
 
 /*
@@ -1091,7 +1228,7 @@ srv_responded(struct sockaddr_in *who)
  */
 
 void
-server_shutdown(void)
+server_shutdown()
 {
     int i;
 
@@ -1106,9 +1243,10 @@ server_shutdown(void)
  */
 
 static void
-send_msg(struct sockaddr_in *who,
-        char *opcode,
-        int auth)
+send_msg(who, opcode, auth)
+    struct sockaddr_in *who;
+    char *opcode;
+    int auth;
 {
     ZNotice_t notice;
     ZNotice_t *pnotice; /* speed hack */
@@ -1163,16 +1301,18 @@ send_msg(struct sockaddr_in *who,
  */
 
 static void
-send_msg_list(struct sockaddr_in *who,
-             char *opcode,
-             char **lyst,
-             int num,
-             int auth)
+send_msg_list(who, opcode, lyst, num, auth)
+    struct sockaddr_in *who;
+    char *opcode;
+    char **lyst;
+    int num;
+    int auth;
 {
     ZNotice_t notice;
     char *pack;
     int packlen;
     Code_t retval;
+    Unacked *nacked;
 
     memset (&notice, 0, sizeof(notice));
 
@@ -1212,15 +1352,19 @@ send_msg_list(struct sockaddr_in *who,
  */
 /*ARGSUSED*/
 void
-server_forward(ZNotice_t *notice,
-              int auth,
-              struct sockaddr_in *who)
+server_forward(notice, auth, who)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
 {
     int i;
     caddr_t pack;
     int packlen;
     Code_t retval;
 
+#if 0
+    zdbug((LOG_DEBUG, "srv_forw"));
+#endif
     /* don't send to limbo */
     for (i = 1; i < nservers; i++) {
        if (i == me_server_idx) /* don't xmit to myself */
@@ -1237,7 +1381,7 @@ server_forward(ZNotice_t *notice,
            syslog(LOG_CRIT, "srv_fwd malloc");
            abort();
        }
-       retval = ZNewFormatSmallRawNotice(notice, pack, &packlen);
+       retval = ZFormatSmallRawNotice(notice, pack, &packlen);
        if (retval != ZERR_NONE) {
            syslog(LOG_WARNING, "srv_fwd format: %s", error_message(retval));
            continue;
@@ -1251,10 +1395,11 @@ server_forward(ZNotice_t *notice,
 }
 
 static void
-server_forw_reliable(Server *server,
-                    caddr_t pack,
-                    int packlen,
-                    ZNotice_t *notice)
+server_forw_reliable(server, pack, packlen, notice)
+    Server *server;
+    caddr_t pack;
+    int packlen;
+    ZNotice_t *notice;
 {
     Code_t retval;
     Unacked *nacked;
@@ -1290,7 +1435,7 @@ server_forw_reliable(Server *server,
     nacked->uid = notice->z_uid;
     nacked->timer = timer_set_rel(rexmit_times[0], srv_rexmit, nacked);
     hashval = SRV_NACKTAB_HASHVAL(nacked->dest.srv_idx, nacked->uid);
-    Unacked_insert(&srv_nacktab[hashval], nacked);
+    LIST_INSERT(&srv_nacktab[hashval], nacked);
 }
 
 /*
@@ -1298,7 +1443,8 @@ server_forw_reliable(Server *server,
  */
 
 void
-server_send_queue(Server *server)
+server_send_queue(server)
+    Server *server;
 {
     Pending *pending;
     ZNotice_t notice;
@@ -1325,8 +1471,9 @@ server_send_queue(Server *server)
  */
 
 static void
-srv_nack_cancel(ZNotice_t *notice,
-               struct sockaddr_in *who)
+srv_nack_cancel(notice, who)
+    ZNotice_t *notice;
+    struct sockaddr_in *who;
 {
     Server *server = server_which_server(who);
     Unacked *nacked;
@@ -1342,11 +1489,14 @@ srv_nack_cancel(ZNotice_t *notice,
            && ZCompareUID(&nacked->uid, &notice->z_uid)) {
            timer_reset(nacked->timer);
            free(nacked->packet);
-           Unacked_delete(nacked);
+           LIST_DELETE(nacked);
            free(nacked);
            return;
        }
     }
+#if 0
+    zdbug((LOG_DEBUG, "srv_nack not found"));
+#endif
 }
 
 /*
@@ -1354,14 +1504,23 @@ srv_nack_cancel(ZNotice_t *notice,
  */
 
 static void
-srv_rexmit(void *arg)
+srv_rexmit(arg)
+    void *arg;
 {
     Unacked *packet = (Unacked *) arg;
     Code_t retval;
     /* retransmit the packet */
        
+#if 0
+    zdbug((LOG_DEBUG,"srv_rexmit to %s/%d",
+          otherservers[packet->dest.srv_idx].addr_str,
+          ntohs(otherservers[packet->dest.srv_idx].addr.sin_port)));
+#endif
     if (otherservers[packet->dest.srv_idx].state == SERV_DEAD) {
-       Unacked_delete(packet);
+#if 0
+       zdbug((LOG_DEBUG, "cancelling send to dead server"));
+#endif
+       LIST_DELETE(packet);
        free(packet->packet);
        srv_nack_release(&otherservers[packet->dest.srv_idx]);
        free(packet);
@@ -1390,7 +1549,8 @@ srv_rexmit(void *arg)
  */
 
 static void
-srv_nack_release(Server *server)
+srv_nack_release(server)
+    Server *server;
 {
     int i;
     Unacked *nacked, *next;
@@ -1400,7 +1560,7 @@ srv_nack_release(Server *server)
            next = nacked->next;
            if (nacked->dest.srv_idx == server - otherservers) {
                timer_reset(nacked->timer);
-               Unacked_delete(nacked);
+               LIST_DELETE(nacked);
                free(nacked->packet);
                free(nacked);
            }
@@ -1414,7 +1574,8 @@ srv_nack_release(Server *server)
  */
 
 static void
-srv_nack_renumber (int *new_idx)
+srv_nack_renumber (new_idx)
+    int *new_idx;
 {
     /* XXX release any private queue for this server */
     Unacked *nacked;
@@ -1439,11 +1600,12 @@ srv_nack_renumber (int *new_idx)
  * Queue this notice to be transmitted to the server when it is ready.
  */
 static void
-server_queue(Server *server,
-            int len,
-            void *pack,
-            int auth,
-            struct sockaddr_in *who)
+server_queue(server, len, pack, auth, who)
+    Server *server;
+    int len;
+    void *pack;
+    int auth;
+    struct sockaddr_in *who;
 {
     Pending *pending;
 
@@ -1470,7 +1632,8 @@ server_queue(Server *server,
  */
 
 Pending *
-server_dequeue(Server *server)
+server_dequeue(server)
+    Server *server;
 {
     Pending *pending;
        
@@ -1486,7 +1649,8 @@ server_dequeue(Server *server)
  */
 
 void
-server_pending_free(Pending *pending)
+server_pending_free(pending)
+    Pending *pending;
 {
     free(pending->packet);
     free(pending);
@@ -1498,9 +1662,10 @@ server_pending_free(Pending *pending)
  */
 
 void
-server_self_queue(ZNotice_t* notice,
-                 int auth,
-                 struct sockaddr_in * who)
+server_self_queue(notice, auth, who)
+    ZNotice_t* notice;
+    int auth;
+    struct sockaddr_in * who;
 {
     char *pack;
     int packlen;
@@ -1520,7 +1685,8 @@ server_self_queue(ZNotice_t* notice,
  * (true if called from signal handler)
  */
 void
-server_dump_servers(FILE *fp)
+server_dump_servers(fp)
+    FILE *fp;
 {
     int i;
 
index e71cc835166132dc726a8aea09cb41ce3be77c3a..9ac861d18acb39b54869a3f8c98155c5e4b1d2ce 100644 (file)
@@ -62,39 +62,44 @@ static const char rcsid_subscr_c[] = "$Id$";
  */
 
 #ifdef HAVE_KRB4
+#ifndef NOENCRYPTION
 C_Block        serv_key;
 Sched  serv_ksched;
 #endif
+#endif
 
 /* for compatibility when sending subscription information to old clients */
 
 #ifdef OLD_COMPAT
 #define        OLD_ZEPHYR_VERSION      "ZEPH0.0"
 #define        OLD_CLIENT_INCOMPSUBS   "INCOMP"
-static void old_compat_subscr_sendlist(ZNotice_t *notice, int auth,
-                                      struct sockaddr_in *who);
+static void old_compat_subscr_sendlist __P((ZNotice_t *notice, int auth,
+                                         struct sockaddr_in *who));
 extern int old_compat_count_subscr;    /* counter of old use */
 #endif /* OLD_COMPAT */
 #ifdef NEW_COMPAT
 #define NEW_OLD_ZEPHYR_VERSION "ZEPH0.1"
-static void new_old_compat_subscr_sendlist(ZNotice_t *notice, int auth,
-                                          struct sockaddr_in *who); 
+static void new_old_compat_subscr_sendlist __P((ZNotice_t *notice, int auth,
+                                             struct sockaddr_in *who)); 
 extern int new_compat_count_subscr;    /* counter of old use */
 #endif /* NEW_COMPAT */
 
-static Code_t add_subscriptions(Client *who, Destlist *subs_queue,
-                               ZNotice_t *notice, Server *server);
-static Destlist *extract_subscriptions(ZNotice_t *notice);
-static void free_subscriptions(Destlist *subs);
-static void free_subscription(Destlist *sub);
-static char **subscr_marshal_subs(ZNotice_t *notice, int auth,
-                                 struct sockaddr_in *who,
-                                 int *found);
-static Destlist *subscr_copy_def_subs(char *person);
-static Code_t subscr_realm_sendit(Client *who, Destlist *subs,
-                                 ZNotice_t *notice, ZRealm *realm);
-static void subscr_unsub_sendit(Client *who, Destlist *subs, 
-                               ZRealm *realm);
+extern char *re_comp(), *re_conv();
+static Code_t add_subscriptions __P((Client *who, Destlist *subs_queue,
+                                  ZNotice_t *notice, Server *server));
+static Destlist *extract_subscriptions __P((ZNotice_t *notice));
+static void free_subscriptions __P((Destlist *subs));
+static void free_subscription __P((Destlist *sub));
+static char **subscr_marshal_subs __P((ZNotice_t *notice, int auth,
+                                    struct sockaddr_in *who,
+                                    int *found));
+static Destlist *subscr_copy_def_subs __P((char *person));
+static Code_t subscr_realm_sendit __P((Client *who, Destlist *subs,
+                                      ZNotice_t *notice, Realm *realm));
+static void subscr_unsub_realms __P((Destlist *newsubs));
+static void subscr_unsub_sendit __P((Client *who, Destlist *subs, 
+                                    Realm *realm));
+static int cl_match  __P((Destlist*, Client *));
 
 static int defaults_read = 0;          /* set to 1 if the default subs
                                           are in memory */
@@ -113,9 +118,10 @@ String *empty;
  */
 
 Code_t
-subscr_subscribe(Client *who,
-                ZNotice_t *notice,
-                Server *server)
+subscr_subscribe(who, notice, server)
+    Client *who;
+    ZNotice_t *notice;
+    Server *server;
 {
     Destlist *subs;
 
@@ -124,16 +130,17 @@ subscr_subscribe(Client *who,
 }
 
 static Code_t
-add_subscriptions(Client *who,
-                 Destlist *subs,
-                 ZNotice_t *notice,
-                 Server *server)
+add_subscriptions(who, subs, notice, server)
+    Client *who;
+    Destlist *subs;
+    ZNotice_t *notice;
+    Server *server;
 {
     Destlist *next;
     Code_t retval;
     Acl *acl;
     String *sender;
-    ZRealm *realm = NULL;
+    Realm *realm = NULL;
 
     if (!subs)
        return ZERR_NONE;       /* no subscr -> no error */
@@ -143,6 +150,10 @@ add_subscriptions(Client *who,
     /* Loop over the new subscriptions. */
     for (; subs; subs = next) {
        next = subs->next;
+#if 0
+       zdbug ((LOG_DEBUG, "subscr: %s/%s/%s", subs->dest.classname->string,
+               subs->dest.inst->string, subs->dest.recip->string));
+#endif
        /* check the recipient for a realm which isn't ours */
        realm = NULL;
        if (subs->dest.recip->string[0] == '@' &&
@@ -176,14 +187,18 @@ add_subscriptions(Client *who,
            }
        }
        if (realm && !bdumping) {
+           if (server && server == me_server) {
                retval = subscr_realm_sendit(who, subs, notice, realm);
                if (retval != ZERR_NONE) {
+                   free_subscriptions(subs);
+                   free_string(sender);
+                   return(retval);
+               } else {
+                   /* free this one, will get from ADD */
                    free_subscription(subs);
-                   continue; /* the for loop */
+               }
            } else {
                    /* Indicates we leaked traffic back to our realm */
-                   free_subscription(subs); /* free this one, wil get from
-                                               ADD */
            }
        } else {
          retval = triplet_register(who, &subs->dest, NULL);
@@ -197,7 +212,7 @@ add_subscriptions(Client *who,
              }
          } else {
              /* If realm, let the REALM_ADD_SUBSCRIBE do insertion */
-             Destlist_insert(&who->subs, subs);
+             LIST_INSERT(&who->subs, subs);
          }
        }
     }
@@ -211,7 +226,8 @@ add_subscriptions(Client *who,
  */
 
 Code_t
-subscr_def_subs(Client *who)
+subscr_def_subs(who)
+    Client *who;
 {
     Destlist *subs;
 
@@ -220,15 +236,19 @@ subscr_def_subs(Client *who)
 }
 
 void
-subscr_reset(void)
+subscr_reset()
 {
+#if 0
+    zdbug((LOG_DEBUG, "subscr_reset()"));
+#endif
     free(default_notice.z_message);
     default_notice.z_message = NULL;
     defaults_read = 0;
 }
 
 static Destlist *
-subscr_copy_def_subs(char *person)
+subscr_copy_def_subs(person)
+    char *person;
 {
     int retval, fd;
     struct stat statbuf;
@@ -236,6 +256,9 @@ subscr_copy_def_subs(char *person)
     Destlist *subs, *sub;
 
     if (!defaults_read) {
+#if 0
+       zdbug((LOG_DEBUG, "reading default subscription file"));
+#endif
        fd = open(subs_file, O_RDONLY, 0666);
        if (fd < 0) {
            syslog(LOG_ERR, "can't open %s:%m", subs_file);
@@ -306,15 +329,20 @@ subscr_copy_def_subs(char *person)
  */
 
 Code_t
-subscr_cancel(struct sockaddr_in *sin,
-             ZNotice_t *notice)
+subscr_cancel(sin, notice)
+    struct sockaddr_in *sin;
+    ZNotice_t *notice;
 {
-    ZRealm *realm;
+    Realm *realm;
     Client *who;
     Destlist *cancel_subs, *subs, *cancel_next, *client_subs, *client_next;
     Code_t retval;
     int found = 0;
+    int relation;
 
+#if 0
+    zdbug((LOG_DEBUG,"subscr_cancel"));
+#endif
     who = client_find(&sin->sin_addr, notice->z_port);
     if (!who)
        return ZSRV_NOCLT;
@@ -331,7 +359,7 @@ subscr_cancel(struct sockaddr_in *sin,
        for (client_subs = who->subs; client_subs; client_subs = client_next) {
            client_next = client_subs->next;
            if (ZDest_eq(&client_subs->dest, &subs->dest)) {
-               Destlist_delete(client_subs);
+               LIST_DELETE(client_subs);
                retval = triplet_deregister(who, &client_subs->dest, NULL);
                if (retval == ZSRV_EMPTYCLASS &&
                    client_subs->dest.recip->string[0] == '@') {
@@ -352,17 +380,25 @@ subscr_cancel(struct sockaddr_in *sin,
     free_subscriptions(cancel_subs);
 
     if (found) {
+#if 0
+       zdbug((LOG_DEBUG, "found & removed"));
+#endif
        return ZERR_NONE;
     } else {
+#if 0
+       zdbug((LOG_DEBUG, "not found"));
+#endif
        return ZSRV_NOSUB;
     }
 }
 
 Code_t
-subscr_realm_cancel(struct sockaddr_in *sin,
-                   ZNotice_t *notice,
-                   ZRealm *realm)
+subscr_realm_cancel(sin, notice, realm)
+    struct sockaddr_in *sin;
+    ZNotice_t *notice;
+    Realm *realm;
 {
+    Client *who;
     Destlist *cancel_subs, *subs, *client_subs, *next, *next2;
     Code_t retval;
     int found = 0;
@@ -382,7 +418,7 @@ subscr_realm_cancel(struct sockaddr_in *sin,
         for (client_subs = realm->subs; client_subs; client_subs = next2) {
             next2 = client_subs->next;
             if (ZDest_eq(&client_subs->dest, &subs->dest)) {
-                Destlist_delete(client_subs);
+                LIST_DELETE(client_subs);
                 retval = triplet_deregister(realm->client, &client_subs->dest, realm);
                free_subscription(client_subs);
                 found = 1;
@@ -394,8 +430,14 @@ subscr_realm_cancel(struct sockaddr_in *sin,
     free_subscriptions(cancel_subs);
 
     if (found) {
+#if 0
+        zdbug((LOG_DEBUG, "found & removed"));
+#endif
         return ZERR_NONE;
     } else {
+#if 0
+        zdbug((LOG_DEBUG, "not found"));
+#endif
         return ZSRV_NOSUB;
     }
 }
@@ -405,17 +447,25 @@ subscr_realm_cancel(struct sockaddr_in *sin,
  */
 
 void
-subscr_cancel_client(Client *client)
+subscr_cancel_client(client)
+    Client *client;
 {
     Destlist *subs, *next;
     Code_t retval;
-    ZRealm *realm;
+    Realm *realm;
 
+#if 0
+    zdbug((LOG_DEBUG,"subscr_cancel_client %s",
+          inet_ntoa(client->addr.sin_addr)));
+#endif
     if (!client->subs)
        return;
 
     for (subs = client->subs; subs; subs = next) {
        next = subs->next;
+#if 0
+       zdbug((LOG_DEBUG,"sub_can %s", subs->dest.classname->string));
+#endif
        retval = triplet_deregister(client, &subs->dest, NULL);
        if (retval == ZSRV_EMPTYCLASS &&
            subs->dest.recip->string[0] == '@') {
@@ -435,9 +485,10 @@ subscr_cancel_client(Client *client)
  */
 
 void
-subscr_sendlist(ZNotice_t *notice,
-               int auth,
-               struct sockaddr_in *who)
+subscr_sendlist(notice, auth, who)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
 {
     char **answer;
     int found;
@@ -488,10 +539,11 @@ subscr_sendlist(ZNotice_t *notice,
 }
 
 static char **
-subscr_marshal_subs(ZNotice_t *notice,
-                   int auth,
-                   struct sockaddr_in *who,
-                   int *found)
+subscr_marshal_subs(notice, auth, who, found)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    int *found;
 {
     char **answer = NULL;
     unsigned short temp;
@@ -501,8 +553,11 @@ subscr_marshal_subs(ZNotice_t *notice,
     int i;
     int defsubs = 0;
 
+#if 0
+    zdbug((LOG_DEBUG, "subscr_marshal"));
+#endif
     *found = 0;
-    
+
     /* Note that the following code is an incredible crock! */
        
     /* We cannot send multiple packets as acknowledgements to the client,
@@ -530,6 +585,9 @@ subscr_marshal_subs(ZNotice_t *notice,
        if (client)
            subs = client->subs;
     } else if (strcmp(notice->z_opcode, CLIENT_GIMMEDEFS) == 0) {
+#if 0
+       zdbug((LOG_DEBUG, "gimmedefs"));
+#endif
        /* subscr_copy_def_subs allocates new pointer rings, so
           it must be freed when finished.
           the string areas pointed to are static, however.*/
@@ -632,6 +690,9 @@ new_old_compat_subscr_sendlist(notice, auth, who)
     /* send 5 at a time until we are finished */
     count = found?((found-1) / 5 + 1):1;       /* total # to be sent */
     i = 0;                                     /* pkt # counter */
+#if 0
+    zdbug((LOG_DEBUG,"Found %d subscriptions for %d packets", found, count));
+#endif
     initfound = found;
     zerofound = (found == 0);
     while (found > 0 || zerofound) {
@@ -662,6 +723,9 @@ new_old_compat_subscr_sendlist(notice, auth, who)
        found -= 5;
        zerofound = 0;
     }
+#if 0
+    zdbug((LOG_DEBUG,"subscr_sendlist acked"));
+#endif
     if (answer)
        free(answer);
 }
@@ -756,6 +820,9 @@ old_compat_subscr_sendlist(notice, auth, who)
            free(answer);
        return;
     }
+#if 0
+    zdbug((LOG_DEBUG,"subscr_sendlist acked"));
+#endif
     if (answer)
        free(answer);
 }
@@ -770,68 +837,46 @@ old_compat_subscr_sendlist(notice, auth, who)
 
 /*ARGSUSED*/
 Code_t
-subscr_send_subs(Client *client)
+subscr_send_subs(client)
+    Client *client;
 {
     int i = 0;
     Destlist *subs;
-#ifdef HAVE_KRB5
-    char buf[512];
-    unsigned char *bufp;
-#else
 #ifdef HAVE_KRB4
     char buf[512];
     C_Block cblock;
 #endif /* HAVE_KRB4 */
-#endif
     char buf2[512];
     char *list[7 * NUM_FIELDS];
     int num = 0;
     Code_t retval;
 
+#if 0
+    zdbug((LOG_DEBUG, "send_subs"));
+#endif
     sprintf(buf2, "%d",ntohs(client->addr.sin_port));
 
     list[num++] = buf2;
 
-#ifdef HAVE_KRB5
-#ifdef HAVE_KRB4 /* XXX make this optional for server transition time */
-    if (Z_enctype(client->session_keyblock) == ENCTYPE_DES_CBC_CRC) {
-       bufp = malloc(Z_keylen(client->session_keyblock));
-       if (bufp == NULL) {
-           syslog(LOG_WARNING, "subscr_send_subs: cannot allocate memory for DES keyblock: %m");
-           return errno;
-       }
-       des_ecb_encrypt((C_Block *)Z_keydata(client->session_keyblock), (C_Block *)bufp, serv_ksched.s, DES_ENCRYPT);
-       retval = ZMakeAscii(buf, sizeof(buf), bufp, Z_keylen(client->session_keyblock));
-    } else {
-#endif
-       bufp = malloc(Z_keylen(client->session_keyblock) + 8); /* + enctype
-                                                               + length */
-       if (bufp == NULL) {
-           syslog(LOG_WARNING, "subscr_send_subs: cannot allocate memory for keyblock: %m");
-           return errno;
-       }
-       *(krb5_enctype *)&bufp[0] = htonl(Z_enctype(client->session_keyblock));
-       *(u_int32_t *)&bufp[4] = htonl(Z_keylen(client->session_keyblock));
-       memcpy(&bufp[8], Z_keydata(client->session_keyblock), Z_keylen(client->session_keyblock));
-
-       retval = ZMakeZcode(buf, sizeof(buf), bufp, Z_keylen(client->session_keyblock) + 8);
-#ifdef HAVE_KRB4
-    }
-#endif /* HAVE_KRB4 */
-#else /* HAVE_KRB5 */
 #ifdef HAVE_KRB4
+#ifdef NOENCRYPTION
+    memcpy(cblock, client->session_key, sizeof(C_Block));
+#else
     des_ecb_encrypt(client->session_key, cblock, serv_ksched.s, DES_ENCRYPT);
+#endif
 
     retval = ZMakeAscii(buf, sizeof(buf), cblock, sizeof(C_Block));
-#endif /* HAVE_KRB4 */
-#endif /* HAVE_KRB5 */    
-
-#if defined(HAVE_KRB4) || defined(HAVE_KRB5)
     if (retval != ZERR_NONE) {
+#if 0
+       zdbug((LOG_DEBUG,"zmakeascii failed: %s", error_message(retval)));
+#endif
     } else {
        list[num++] = buf;
+#if 0
+       zdbug((LOG_DEBUG, "cblock %s", buf));
+#endif
     }          
-#endif /* HAVE_KRB4 || HAVE_KRB5*/
+#endif /* HAVE_KRB4 */
     retval = bdump_send_list_tcp(SERVACK, &client->addr, ZEPHYR_ADMIN_CLASS,
                                 num > 1 ? "CBLOCK" : "", ADMIN_NEWCLT,
                                 client->principal->string, "", list, num);
@@ -895,7 +940,8 @@ free_subscription(Destlist *sub)
 }
 
 static void
-free_subscriptions(Destlist *subs)
+free_subscriptions(subs)
+    Destlist *subs;
 {
     Destlist *next;
 
@@ -918,7 +964,8 @@ free_subscriptions(Destlist *subs)
  */
 
 static Destlist *
-extract_subscriptions(ZNotice_t *notice)
+extract_subscriptions(notice)
+    ZNotice_t *notice;
 {
     Destlist *subs = NULL, *sub;
     char *recip, *class_name, *classinst;
@@ -933,6 +980,10 @@ extract_subscriptions(ZNotice_t *notice)
        classinst = cp;
        ADVANCE(2);
        recip = cp;
+#if 0
+       zdbug((LOG_DEBUG, "ext_sub: CLS %s INST %s RCPT %s",
+              class_name, classinst, cp));
+#endif
        cp += (strlen(cp) + 1);
        if (cp > notice->z_message + notice->z_message_len) {
            syslog(LOG_WARNING, "malformed sub 3");
@@ -950,7 +1001,7 @@ extract_subscriptions(ZNotice_t *notice)
            sub->dest.recip = make_string("", 0);
        else
            sub->dest.recip = make_string(recip, 0);
-       Destlist_insert(&subs, sub);
+       LIST_INSERT(&subs, sub);
     }
     return subs;
 }
@@ -962,9 +1013,12 @@ extract_subscriptions(ZNotice_t *notice)
  */
 
 void
-subscr_dump_subs(FILE *fp,
-                Destlist *subs)
+subscr_dump_subs(fp, subs)
+    FILE *fp;
+    Destlist *subs;
 {
+    char *p;
+
     if (!subs)                 /* no subscriptions to dump */
        return;
 
@@ -989,19 +1043,26 @@ subscr_dump_subs(FILE *fp,
 /* As it exists, this function expects to take only the first sub from the 
  * Destlist. At some point, it and the calling code should be replaced */
 static Code_t
-subscr_realm_sendit(Client *who,
-                   Destlist *subs,
-                   ZNotice_t *notice,
-                   ZRealm *realm)
+subscr_realm_sendit(who, subs, notice, realm)
+    Client *who;
+    Destlist *subs;
+    ZNotice_t *notice;
+    Realm *realm;
 {
   ZNotice_t snotice;
   char *pack;
   int packlen;
+  int found = 0, i;
   char **text;
   Code_t retval;
   char addr[16];          /* xxx.xxx.xxx.xxx max */
   char port[16];
   
+#if 0
+  zdbug((LOG_DEBUG, "subscr_rlm_sendit"));
+#endif
+
+
   if ((text=(char **)malloc((NUM_FIELDS + 2)*sizeof(char *))) == (char **)0) {
       syslog(LOG_ERR, "subscr_rlm_sendit malloc");
       return(ENOMEM);
@@ -1058,6 +1119,9 @@ subscr_realm_sendit(Client *who,
     return(ZERR_NONE);
   }
   
+#if 0
+  zdbug((LOG_DEBUG,"subscr_rlm_sendit len: %d", snotice.z_message_len));
+#endif
   realm_handoff(&snotice, 1, &(who->addr), realm, 0);
   free(pack);
   
@@ -1066,13 +1130,17 @@ subscr_realm_sendit(Client *who,
 
 /* Called from subscr_realm and subscr_foreign_user */
 static Code_t
-subscr_add_raw(Client *client,
-              ZRealm *realm,
-              Destlist *newsubs)
+subscr_add_raw(client, realm, newsubs)
+    Client *client;
+    Realm *realm;
+    Destlist *newsubs;
 {
-  Destlist *subs, *subs2, **head;
+  Destlist *subs, *subs2, *subs3, **head;
   Code_t retval;
 
+#if 0
+  zdbug((LOG_DEBUG, "subscr_add_raw"));
+#endif
   head = (realm) ? &realm->subs : &client->subs;
 
   /* Loop over the new subscriptions. */
@@ -1094,7 +1162,7 @@ subscr_add_raw(Client *client,
        }
     } else {
       if (!realm) {
-       ZRealm *remrealm = 
+       Realm *remrealm = 
          realm_get_realm_by_name(subs->dest.recip->string + 1);
        if (remrealm) {
          Destlist *sub = (Destlist *) malloc(sizeof(Destlist));
@@ -1104,23 +1172,26 @@ subscr_add_raw(Client *client,
            sub->dest.classname = make_string(subs->dest.classname->string, 0);
            sub->dest.inst = make_string(subs->dest.inst->string, 0);
            sub->dest.recip = make_string(subs->dest.recip->string, 0);
+#if 1
            zdbug ((LOG_DEBUG, "subscr: add %s/%s/%s in %s",
                    sub->dest.classname->string, sub->dest.inst->string, 
                    sub->dest.recip->string, remrealm->name));
-           Destlist_insert(&remrealm->remsubs, sub);
+#endif
+           LIST_INSERT(&remrealm->remsubs, sub);
          }
        }
       }
     }
-    Destlist_insert(head, subs);
+    LIST_INSERT(head, subs);
   }
   return ZERR_NONE;
 }
 
 /* Called from bdump_recv_loop to decapsulate realm subs */
 Code_t
-subscr_realm(ZRealm *realm,
-            ZNotice_t *notice)
+subscr_realm(realm, notice)
+    Realm *realm;
+    ZNotice_t *notice;
 {
         Destlist  *newsubs;
 
@@ -1136,24 +1207,28 @@ subscr_realm(ZRealm *realm,
 
 /* Like realm_sendit, this only takes one item from subs */
 static void
-subscr_unsub_sendit(Client *who,
-                   Destlist *subs,
-                   ZRealm *realm)
+subscr_unsub_sendit(who, subs, realm)
+    Client *who;
+    Destlist *subs;
+    Realm *realm;
 {
   ZNotice_t unotice;
   Code_t retval;
   char **list;
   char *pack;
   int packlen;
+  int found = 0;
   Destlist *subsp, *subsn;
 
   for (subsp = realm->remsubs; subsp; subsp = subsn) {
     subsn = subsp->next;
     if (ZDest_eq(&subs->dest, &subsp->dest)) {
+#if 1
       zdbug ((LOG_DEBUG, "subscr: del %s/%s/%s in %s",
              subsp->dest.classname->string, subsp->dest.inst->string, 
              subsp->dest.recip->string, realm->name));
-      Destlist_delete(subsp);
+#endif
+      LIST_DELETE(subsp);
       free_subscription(subsp);
       break;
     }
@@ -1199,7 +1274,8 @@ subscr_unsub_sendit(Client *who,
 
 /* Called from bump_send_loop by way of realm_send_realms */
 Code_t
-subscr_send_realm_subs(ZRealm *realm)
+subscr_send_realm_subs(realm)
+    Realm *realm;
 {
   int i = 0;
   Destlist *subs, *next;
@@ -1208,6 +1284,10 @@ subscr_send_realm_subs(ZRealm *realm)
   int num = 0;
   Code_t retval;
 
+#if 0
+  zdbug((LOG_DEBUG, "send_realm_subs"));
+#endif
+
   strcpy(buf, realm->name);
   list[num++] = buf;
 
@@ -1261,9 +1341,12 @@ subscr_send_realm_subs(ZRealm *realm)
 }
 
 Code_t
-subscr_realm_subs(ZRealm *realm)
+subscr_realm_subs(realm)
+    Realm *realm;
 {
+  int i = 0;
   Destlist *subs, *next;
+  char buf[512];
   char *text[2 + NUM_FIELDS];
   unsigned short num = 0;
   Code_t retval;
@@ -1273,6 +1356,10 @@ subscr_realm_subs(ZRealm *realm)
   Client **clientp;
   char port[16];
 
+#if 0
+  zdbug((LOG_DEBUG, "realm_subs"));
+#endif
+
   if (!realm->remsubs)
     return ZERR_NONE;
 
@@ -1340,13 +1427,14 @@ subscr_realm_subs(ZRealm *realm)
 
 /* Called from subscr_foreign_user for REALM_REQ_SUBSCRIBE */
 static Code_t
-subscr_check_foreign_subs(ZNotice_t *notice,
-                         struct sockaddr_in *who,
-                         Server *server,
-                         ZRealm *realm,
-                         Destlist *newsubs)
+subscr_check_foreign_subs(notice, who, server, realm, newsubs)
+    ZNotice_t *notice;
+    struct sockaddr_in *who;
+    Server *server;
+    Realm *realm;
+    Destlist *newsubs;
 {
-    Destlist *subs, *next;
+    Destlist *subs, *subs2, *next;
     Acl *acl;
     char **text;
     int found = 0;
@@ -1382,7 +1470,7 @@ subscr_check_foreign_subs(ZNotice_t *notice,
 
     found = 0;
     for (subs = newsubs; subs; subs = next) {
-       ZRealm *rlm;
+       Realm *rlm;
        next=subs->next;
        if (subs->dest.recip->string[0] != '\0') {
          rlm = realm_which_realm(who);
@@ -1442,7 +1530,7 @@ subscr_check_foreign_subs(ZNotice_t *notice,
                return retval;
            }
        }
-       Destlist_insert(&realm->subs, subs);
+       LIST_INSERT(&realm->subs, subs);
     }
     /* don't send confirmation if we're not the initial server contacted */
     if (!(server_which_server(who) || found == 0)) {
@@ -1474,12 +1562,14 @@ subscr_check_foreign_subs(ZNotice_t *notice,
 }
 
 /* Called from realm_control_dispatch for REALM_REQ/ADD_SUBSCRIBE */
-Code_t subscr_foreign_user(ZNotice_t *notice,
-                          struct sockaddr_in *who,
-                          Server *server,
-                          ZRealm *realm)
+Code_t subscr_foreign_user(notice, who, server, realm)
+    ZNotice_t *notice;
+    struct sockaddr_in *who;
+    Server *server;
+    Realm *realm;
 {
   Destlist *newsubs, *temp;
+  Acl *acl;
   Code_t status;
   Client *client;
   ZNotice_t snotice;
@@ -1487,11 +1577,15 @@ Code_t subscr_foreign_user(ZNotice_t *notice,
   char *cp, *tp0, *tp1;
   char rlm_recipient[REALM_SZ + 1];
   
+#if 0
+  zdbug((LOG_DEBUG, "subscr_foreign_user"));
+#endif
+  
   tp0 = cp = notice->z_message;
   
   newwho.sin_addr.s_addr = inet_addr(cp);
   if (newwho.sin_addr.s_addr == -1) {
-    syslog(LOG_ERR, "malformed addr from %s", notice->z_sender);
+    syslog(LOG_ERR, "malformed addr from %s, notice->z_sender");
     return(ZERR_NONE);
   }
 
@@ -1540,10 +1634,13 @@ Code_t subscr_foreign_user(ZNotice_t *notice,
     /* translate the recipient to represent the foreign realm */
     sprintf(rlm_recipient, "@%s", realm->name);
     for (temp = newsubs; temp; temp = temp->next) {
+#if 0
+      syslog(LOG_DEBUG, "in foreign_user: class is %s", temp->dest.classname->string);
+#endif      
         temp->dest.recip = make_string(rlm_recipient, 0);
     }
     
-    status = subscr_add_raw(client, (ZRealm *)0, newsubs);
+    status = subscr_add_raw(client, (Realm *)0, newsubs);
   } else if (!strcmp(snotice.z_opcode, REALM_REQ_SUBSCRIBE)) {
     zdbug((LOG_DEBUG, "subscr_foreign_user REQ %s/%s", tp0, tp1));
     status = subscr_check_foreign_subs(notice, who, server, realm, newsubs);
index fe4b0647a27bf7be3b91835917e86add3c0088d5..b6cbf514c9611dff562d8184bdfdd62609c157a0 100644 (file)
@@ -114,13 +114,13 @@ static Timer **heap;
 static int num_timers = 0;
 static int heap_size = 0;
 
-static void timer_botch (void*);
-static Timer *add_timer (Timer *);
+static void timer_botch __P((void*));
+static Timer *add_timer __P((Timer *));
 
-Timer *
-timer_set_rel(long time_rel,
-             void (*proc)(void *),
-             void *arg)
+Timer *timer_set_rel(time_rel, proc, arg)
+    long time_rel;
+    void (*proc) __P((void *));
+    void *arg;
 {
     Timer *new_t;
 
@@ -134,7 +134,8 @@ timer_set_rel(long time_rel,
 }
 
 void
-timer_reset(Timer *tmr)
+timer_reset(tmr)
+    Timer *tmr;
 {
     int pos, min;
 
@@ -175,7 +176,8 @@ timer_reset(Timer *tmr)
 #define set_timeval(t,s) ((t).tv_sec=(s),(t).tv_usec=0,(t))
 
 static Timer *
-add_timer(Timer *new)
+add_timer(new)
+    Timer *new;
 {
     int pos;
 
@@ -205,11 +207,12 @@ add_timer(Timer *new)
 }
 
 void
-timer_process(void)
+timer_process()
 {
     Timer *t;
     timer_proc func;
     void *arg;
+    int valid = 0;
 
     if (num_timers == 0 || heap[0]->abstime > NOW)
        return;
@@ -228,7 +231,8 @@ timer_process(void)
 }
 
 struct timeval *
-timer_timeout(struct timeval *tvbuf)
+timer_timeout(tvbuf)
+    struct timeval *tvbuf;
 {
     if (num_timers > 0) {
        tvbuf->tv_sec = heap[0]->abstime - NOW;
@@ -242,7 +246,8 @@ timer_timeout(struct timeval *tvbuf)
 }
 
 static void
-timer_botch(void *arg)
+timer_botch(arg)
+    void *arg;
 {
     syslog(LOG_CRIT, "timer botch\n");
     abort();
index 57683764507dba9aaa5c36da55a8b769e0148a41..0d7ea8ee66767cf3b902af51186f2780ed9f1b1c 100644 (file)
@@ -102,9 +102,11 @@ static void login_sendit __P((ZNotice_t *notice, int auth,
 static char **ulogin_marshal_locs __P((ZNotice_t *notice, int *found,
                                       int auth));
 
+static int ul_equiv __P((Location *l1, Location *l2));
+
 static void free_loc __P((Location *loc));
 static void ulogin_locate_forward __P((ZNotice_t *notice,
-                                      struct sockaddr_in *who, ZRealm *realm));
+                                      struct sockaddr_in *who, Realm *realm));
 
 static Location *locations = NULL; /* ptr to first in array */
 static int num_locs = 0;       /* number in array */
@@ -114,10 +116,11 @@ static int num_locs = 0;  /* number in array */
  */
 
 Code_t
-ulogin_dispatch(ZNotice_t *notice,
-               int auth,
-               struct sockaddr_in *who,
-               Server *server)
+ulogin_dispatch(notice, auth, who, server)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Server *server;
 {
     Exposure_type retval;
     int err_ret;
@@ -238,12 +241,7 @@ ulogin_dispatch(ZNotice_t *notice,
                login_sendit(notice, auth, who, 1);
        }
     } else {
-       if (!strcmp(notice->z_opcode, LOGIN_USER_LOGIN)) {
-           zdbug((LOG_DEBUG, "ulog opcode from unknown foreign realm %s", 
-                  notice->z_opcode));
-       } else {
-           syslog(LOG_ERR, "unknown ulog opcode %s", notice->z_opcode);
-       }
+       syslog(LOG_ERR, "unknown ulog opcode %s", notice->z_opcode);
        if (server == me_server)
            nack(notice, who);
        return ZERR_NONE;
@@ -254,10 +252,11 @@ ulogin_dispatch(ZNotice_t *notice,
 }
 
 static void
-login_sendit(ZNotice_t *notice,
-            int auth,
-            struct sockaddr_in *who,
-            int external)
+login_sendit(notice, auth, who, external)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    int external;
 {
     ZNotice_t log_notice;
 
@@ -276,13 +275,14 @@ login_sendit(ZNotice_t *notice,
  * Dispatch a LOCATE notice.
  */
 Code_t
-ulocate_dispatch(ZNotice_t *notice,
-                int auth,
-                struct sockaddr_in *who,
-                Server *server)
+ulocate_dispatch(notice, auth, who, server)
+    ZNotice_t *notice;
+    int auth;
+    struct sockaddr_in *who;
+    Server *server;
 {
     char *cp;
-    ZRealm *realm;
+    Realm *realm;
 
     if (!strcmp(notice->z_opcode, LOCATE_LOCATE)) {
        /* we are talking to a current-rev client; send an ack */
@@ -294,7 +294,7 @@ ulocate_dispatch(ZNotice_t *notice,
            ulogin_locate(notice, who, auth);
        return ZERR_NONE;
     } else {
-        syslog(LOG_ERR, "unknown uloc opcode %s", notice->z_opcode);
+       syslog(LOG_ERR, "unknown uloc opcode %s", notice->z_opcode);
        if (server == me_server)
            nack(notice, who);
        return ZERR_NONE;
@@ -306,7 +306,8 @@ ulocate_dispatch(ZNotice_t *notice,
  */
 
 void
-uloc_hflush(struct in_addr *addr)
+uloc_hflush(addr)
+    struct in_addr *addr;
 {
     Location *loc;
     int i = 0, new_num = 0;
@@ -348,7 +349,8 @@ uloc_hflush(struct in_addr *addr)
 }
 
 void
-uloc_flush_client(struct sockaddr_in *sin)
+uloc_flush_client(sin)
+    struct sockaddr_in *sin;
 {
     Location *loc;
     int i = 0, new_num = 0;
@@ -407,7 +409,7 @@ uloc_flush_client(struct sockaddr_in *sin)
 
 /*ARGSUSED*/
 Code_t
-uloc_send_locations(void)
+uloc_send_locations()
 {
     Location *loc;
     int i;
@@ -439,7 +441,6 @@ uloc_send_locations(void)
          default:
            syslog(LOG_ERR,"broken location state %s/%d",
                   loc->user->string, (int) loc->exposure);
-           exposure_level = EXPOSE_OPSTAFF;
            break;
        }
        retval = bdump_send_list_tcp(ACKED, &loc->addr, LOGIN_CLASS,
@@ -458,9 +459,10 @@ uloc_send_locations(void)
  */
 
 static int
-ulogin_add_user(ZNotice_t *notice,
-               Exposure_type exposure,
-               struct sockaddr_in *who)
+ulogin_add_user(notice, exposure, who)
+    ZNotice_t *notice;
+    Exposure_type exposure;
+    struct sockaddr_in *who;
 {
     Location *loc, *oldlocs, newloc;
     int i;
@@ -535,10 +537,11 @@ ulogin_add_user(ZNotice_t *notice,
  */ 
 
 static int
-ulogin_setup(ZNotice_t *notice,
-            Location *locs,
-            Exposure_type exposure,
-            struct sockaddr_in *who)
+ulogin_setup(notice, locs, exposure, who)
+    ZNotice_t *notice;
+    Location *locs;
+    Exposure_type exposure;
+    struct sockaddr_in *who;
 {
     if (ulogin_parse(notice, locs))
        return 1;
@@ -555,8 +558,9 @@ ulogin_setup(ZNotice_t *notice,
  */
 
 static int
-ulogin_parse(ZNotice_t *notice,
-            Location *locs)
+ulogin_parse(notice, locs)
+    ZNotice_t *notice;
+    Location *locs;
 {
     char *cp, *base;
     int nulls = 0;
@@ -594,9 +598,10 @@ ulogin_parse(ZNotice_t *notice,
 
 
 static Location *
-ulogin_find(char *user,
-           struct in_addr *host,
-           unsigned int port)
+ulogin_find(user, host, port)
+    char *user;
+    struct in_addr *host;
+    unsigned int port;
 {
     Location *loc;
     String *str;
@@ -627,7 +632,8 @@ ulogin_find(char *user,
  */
 
 static Location *
-ulogin_find_user(char *user)
+ulogin_find_user(user)
+    char *user;
 {
     int i, rlo, rhi;
     int compar;
@@ -664,14 +670,26 @@ ulogin_find_user(char *user)
     return &locations[i];
 }
 
+static int
+ul_equiv(l1, l2)
+    Location *l1, *l2;
+{
+    if (l1->machine != l2->machine)
+       return 0;
+    if (l1->tty != l2->tty)
+       return 0;
+    return 1;
+}
+
 /*
  * remove the user specified in notice from the internal table
  */
 
 static Exposure_type
-ulogin_remove_user(ZNotice_t *notice,
-                  struct sockaddr_in *who,
-                  int *err_return)
+ulogin_remove_user(notice, who, err_return)
+    ZNotice_t *notice;
+    struct sockaddr_in *who;
+    int *err_return;
 {
     Location *new_locs, *loc;
     int i = 0;
@@ -728,7 +746,8 @@ ulogin_remove_user(ZNotice_t *notice,
  */
 
 static void
-ulogin_flush_user(ZNotice_t *notice)
+ulogin_flush_user(notice)
+    ZNotice_t *notice;
 {
     Location *loc, *loc2;
     int i, j, num_match, num_left;
@@ -799,9 +818,10 @@ ulogin_flush_user(ZNotice_t *notice)
 
 
 static void
-ulogin_locate(ZNotice_t *notice,
-             struct sockaddr_in *who,
-             int auth)
+ulogin_locate(notice, who, auth)
+    ZNotice_t *notice;
+    struct sockaddr_in *who;
+    int auth;
 {
     char **answer;
     int found;
@@ -839,9 +859,10 @@ ulogin_locate(ZNotice_t *notice,
  */
 
 static char **
-ulogin_marshal_locs(ZNotice_t *notice,
-                   int *found,
-                   int auth) 
+ulogin_marshal_locs(notice, found, auth)
+    ZNotice_t *notice;
+    int *found;
+    int auth;
 {
     Location **matches = (Location **) 0;
     Location *loc;
@@ -928,7 +949,8 @@ ulogin_marshal_locs(ZNotice_t *notice,
 }
 
 void
-uloc_dump_locs(FILE *fp)
+uloc_dump_locs(fp)
+    FILE *fp;
 {
     int i;
 
@@ -968,7 +990,8 @@ uloc_dump_locs(FILE *fp)
 }
 
 static void
-free_loc(Location *loc)
+free_loc(loc)
+    Location *loc;
 {
     free_string(loc->user);
     free_string(loc->machine);
@@ -978,9 +1001,10 @@ free_loc(Location *loc)
 }
 
 static void
-ulogin_locate_forward(ZNotice_t *notice,
-                     struct sockaddr_in *who,
-                     ZRealm *realm)
+ulogin_locate_forward(notice, who, realm)
+    ZNotice_t *notice;
+    struct sockaddr_in *who;
+    Realm *realm;
 {
     ZNotice_t lnotice;
 
@@ -991,9 +1015,10 @@ ulogin_locate_forward(ZNotice_t *notice,
 }
 
 void
-ulogin_realm_locate(ZNotice_t *notice,
-                   struct sockaddr_in *who,
-                   ZRealm *realm)
+ulogin_realm_locate(notice, who, realm)
+    ZNotice_t *notice;
+    struct sockaddr_in *who;
+    Realm *realm;
 {
   char **answer;
   int found;
@@ -1037,8 +1062,9 @@ ulogin_realm_locate(ZNotice_t *notice,
 }
 
 void
-ulogin_relay_locate(ZNotice_t *notice,
-                   struct sockaddr_in *who)
+ulogin_relay_locate(notice, who)
+    ZNotice_t *notice;
+    struct sockaddr_in *who;
 {
   ZNotice_t lnotice;
   Code_t retval;
@@ -1059,11 +1085,6 @@ ulogin_relay_locate(ZNotice_t *notice,
   lnotice = *notice;
   lnotice.z_opcode = LOCATE_LOCATE;
   lnotice.z_kind = ACKED;
-  lnotice.z_auth = 0;
-  lnotice.z_authent_len = 0;
-  lnotice.z_ascii_authent = "";
-  lnotice.z_checksum = 0;
-  lnotice.z_ascii_checksum = "";
   
   if ((retval = ZFormatRawNotice(&lnotice, &pack, &packlen)) != ZERR_NONE) {
     syslog(LOG_WARNING, "ulog_relay_loc format: %s",
index d2b23cef70c61b641bf092b5061b57761a959acd..230a66cc01aa3327b830e0f5206ec94e1006bea7 100644 (file)
@@ -12,8 +12,6 @@
 
 #include <zephyr/mit-copyright.h>
 
-#include <sys/utsname.h>
-
 #include "zserver.h"
 #include "version.h"
 
@@ -33,10 +31,9 @@ static const char copyright[] =
 #endif
 
 char *
-get_version(void)
+get_version()
 {
   static char vers_buf[256];
-  struct utsname un;
 
   if (vers_buf[0] == '\0') {
 #ifdef DEBUG
@@ -76,13 +73,11 @@ get_version(void)
 #ifdef NeXT
     (void) strcat(vers_buf, "NeXT");
 #endif /* NeXT */
-
-    if (vers_buf[strlen(vers_buf) - 1] == '/') {
-       uname(&un);
-       (void) strcat(vers_buf, un.machine);
-       (void) strcat(vers_buf, "-");
-       (void) strcat(vers_buf, un.sysname);
-    }
   }
   return(vers_buf);
 }
+
+
+
+
+
index a863641527ef238fd0f8b024d1f9d9a2cb0ec8b1..b901d4eb9a5fae4d1b92ada7fa36c99f88d98f37 100644 (file)
@@ -17,9 +17,6 @@
 #include <zephyr/mit-copyright.h>
 
 #include <internal.h>
-
-#include <com_err.h>
-
 #include <arpa/inet.h>
 
 #include "zsrv_err.h"
 #include "access.h"
 #include "acl.h"
 
-#if defined(HAVE_KRB5) || defined(HAVE_KRB4)
+#ifdef HAVE_KRB4
 /* Kerberos-specific library interfaces used only by the server. */
-#ifdef HAVE_KRB5
-extern krb5_keyblock *__Zephyr_keyblock;
-#define ZGetSession() (__Zephyr_keyblock)
-void ZSetSession(krb5_keyblock *keyblock);
-Code_t ZFormatAuthenticNoticeV5(ZNotice_t*, char*, int, int*, krb5_keyblock *);
-krb5_error_code Z_krb5_init_keyblock(krb5_context, krb5_enctype, size_t,
-        krb5_keyblock **);
-#else
 extern C_Block __Zephyr_session;
 #define ZGetSession() (__Zephyr_session)
-#endif
-void ZSetSessionDES(C_Block *key);
-
-Code_t ZFormatAuthenticNotice(ZNotice_t*, char*, int, int*, C_Block);
+Code_t ZFormatAuthenticNotice __P((ZNotice_t*, char*, int, int*, C_Block));
 #endif
 
 /* For krb_rd_req prototype and definition. */
@@ -54,21 +40,36 @@ Code_t ZFormatAuthenticNotice(ZNotice_t*, char*, int, int*, C_Block);
 #define KRB_INT32 ZEPHYR_INT32
 #endif
 
+/* 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))
+
 /* Current time as cached by main(); use instead of time(). */
 #define NOW t_local.tv_sec
 
 #ifdef HAVE_KRB4
+#ifndef NOENCRYPTION
 /* Kerberos shouldn't stick us with array types... */
 typedef struct {
     des_key_schedule s;
 } Sched;
 #endif
+#endif
 
 typedef struct _Destination Destination;
 typedef struct _Destlist Destlist;
-typedef struct _ZRealm ZRealm;
-typedef struct _ZRealmname ZRealmname;
-typedef enum _ZRealm_state ZRealm_state;
+typedef struct _Realm Realm;
+typedef struct _Realmname Realmname;
+typedef enum _Realm_state Realm_state;
 typedef struct _Client Client;
 typedef struct _Triplet Triplet;
 typedef enum _Server_state Server_state;
@@ -89,14 +90,14 @@ struct _Destlist {
     struct _Destlist   *next, **prev_p;
 };
 
-enum _ZRealm_state {
-    REALM_UP,                          /* ZRealm is up */
-    REALM_TARDY,                       /* ZRealm due for a hello XXX */
-    REALM_DEAD,                                /* ZRealm is considered dead */
-    REALM_STARTING                     /* ZRealm is between dead and up */
+enum _Realm_state {
+    REALM_UP,                          /* Realm is up */
+    REALM_TARDY,                       /* Realm due for a hello XXX */
+    REALM_DEAD,                                /* Realm is considered dead */
+    REALM_STARTING                     /* Realm is between dead and up */
 };
 
-struct _ZRealm {
+struct _Realm {
     char name[REALM_SZ];
     int count;
     struct sockaddr_in *addrs;
@@ -106,10 +107,10 @@ struct _ZRealm {
     Client *client;                     
     int child_pid;
     int have_tkt;
-    ZRealm_state state;
+    Realm_state state;
 };
 
-struct _ZRealmname {
+struct _Realmname {
     char name[REALM_SZ];
     char **servers;
     int nused;
@@ -119,17 +120,13 @@ struct _ZRealmname {
 struct _Client {
     struct sockaddr_in addr;           /* ipaddr/port of client */
     Destlist           *subs   ;       /* subscriptions */
-#ifdef HAVE_KRB5
-    krb5_keyblock       *session_keyblock;
-#else
 #ifdef HAVE_KRB4
     C_Block            session_key;    /* session key for this client */
 #endif /* HAVE_KRB4 */
-#endif
     String             *principal;     /* krb principal of user */
     int                        last_send;      /* Counter for last sent packet. */
     time_t             last_ack;       /* Time of last received ack */
-    ZRealm             *realm;
+    Realm              *realm;
     struct _Client     *next, **prev_p;
 };
 
@@ -202,183 +199,148 @@ struct _Statistic {
 };
 
 /* Function declarations */
-
-/* These macros instantiate inline functions that do the work of the formder
-   LIST_INSERT and LIST_DELETE functions, which unfortunately triggered gcc's
-   pedanticism.  The comment before the *former* macros was: */
-/* 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 MAKE_LIST_INSERT(type) inline static void type##_insert(type **head, type *elem) \
-    {\
-       (elem)->next = *(head);                                 \
-       if(*head) (*(head))->prev_p = &(elem)->next;            \
-       (*head) = (elem);                                       \
-       (elem)->prev_p = (head);                                \
-    }
        
-#define MAKE_LIST_DELETE(type) inline static void type##_delete(type *elem) \
-    {\
-       *(elem)->prev_p = (elem)->next;                         \
-       if((elem)->next) (elem)->next->prev_p = (elem)->prev_p; \
-    }
-
-MAKE_LIST_INSERT(Destlist);
-MAKE_LIST_DELETE(Destlist);
-MAKE_LIST_INSERT(Client);      
-MAKE_LIST_DELETE(Client);      
-MAKE_LIST_INSERT(Triplet);     
-MAKE_LIST_DELETE(Triplet);     
-MAKE_LIST_INSERT(Unacked);
-MAKE_LIST_DELETE(Unacked);
-
 /* found in bdump.c */
-void bdump_get(ZNotice_t *notice, int auth, struct sockaddr_in *who,
-                   Server *server);
-void bdump_send(void);
-void bdump_offer(struct sockaddr_in *who);
-Code_t bdump_send_list_tcp(ZNotice_Kind_t kind, struct sockaddr_in *addr,
+void bdump_get __P((ZNotice_t *notice, int auth, struct sockaddr_in *who,
+                   Server *server));
+void bdump_send __P((void));
+void bdump_offer __P((struct sockaddr_in *who));
+Code_t bdump_send_list_tcp __P((ZNotice_Kind_t kind, struct sockaddr_in *addr,
                                char *class_name, char *inst, char *opcode,
                                char *sender, char *recip, char **lyst,
-                               int num);
-int get_tgt(void);
+                               int num));
+int get_tgt __P((void));
 
 /* found in class.c */
 extern String *class_control, *class_admin, *class_hm;
 extern String *class_ulogin, *class_ulocate;
-int ZDest_eq(Destination *d1, Destination *d2);
-Code_t triplet_register(Client *client, Destination *dest, ZRealm *realm);
-Code_t triplet_deregister(Client *client, Destination *dest,
-                              ZRealm *realm);
-Code_t class_restrict(char *class, Acl *acl);
-Code_t class_setup_restricted(char *class, Acl *acl);
-Client **triplet_lookup(Destination *dest);
-Acl *class_get_acl(String *class);
-int dest_eq(Destination *d1, Destination *d2);
-int order_dest_strings(Destination *d1, Destination *d2);
-void triplet_dump_subs(FILE *fp);
+int ZDest_eq __P((Destination *d1, Destination *d2));
+Code_t triplet_register __P((Client *client, Destination *dest, Realm *realm));
+Code_t triplet_deregister __P((Client *client, Destination *dest,
+                              Realm *realm));
+Code_t class_restrict __P((char *class, Acl *acl));
+Code_t class_setup_restricted __P((char *class, Acl *acl));
+Client **triplet_lookup __P((Destination *dest));
+Acl *class_get_acl __P((String *class));
+int dest_eq __P((Destination *d1, Destination *d2));
+int order_dest_strings __P((Destination *d1, Destination *d2));
+void triplet_dump_subs __P((FILE *fp));
 
 /* found in client.c */
-Code_t client_register(ZNotice_t *notice, struct in_addr *host,
-                           Client **client_p, int wantdefaults);
-void client_deregister(Client *client, int flush);
-void client_flush_host(struct in_addr *host);
-void client_dump_clients(FILE *fp);
-Client *client_find(struct in_addr *host, unsigned int port);
-Code_t client_send_clients(void);
+Code_t client_register __P((ZNotice_t *notice, struct in_addr *host,
+                           Client **client_p, int wantdefaults));
+void client_deregister __P((Client *client, int flush)); 
+void client_flush_host __P((struct in_addr *host));
+void client_dump_clients __P((FILE *fp));
+Client *client_find __P((struct in_addr *host, unsigned int port));
+Code_t client_send_clients __P((void));
 
 /* found in common.c */
-char *strsave(const char *str);
-unsigned long hash (const char *);
-void dump_quote(char *p, FILE *fp);
+char *strsave __P((const char *str));
+unsigned long hash  __P((const char *));
+void dump_quote __P((char *p, FILE *fp));
 
 /* found in dispatch.c */
-void handle_packet(void);
-void clt_ack(ZNotice_t *notice, struct sockaddr_in *who, Sent_type sent);
-void nack_release(Client *client);
-void sendit(ZNotice_t *notice, int auth, struct sockaddr_in *who,
-                int external);
-void rexmit(void *);
-void xmit(ZNotice_t *notice, struct sockaddr_in *dest, int auth,
-              Client *client);
-Code_t hostm_dispatch(ZNotice_t *notice, int auth,
-                          struct sockaddr_in *who, Server *server);
-Code_t control_dispatch(ZNotice_t *notice, int auth,
-                            struct sockaddr_in *who, Server *server);
-Code_t xmit_frag(ZNotice_t *notice, char *buf, int len, int waitforack);
-void hostm_shutdown(void);
+void handle_packet __P((void));
+void clt_ack __P((ZNotice_t *notice, struct sockaddr_in *who, Sent_type sent));
+void nack_release __P((Client *client));
+void sendit __P((ZNotice_t *notice, int auth, struct sockaddr_in *who,
+                int external));
+void rexmit __P((void *));
+void xmit __P((ZNotice_t *notice, struct sockaddr_in *dest, int auth,
+              Client *client));
+Code_t hostm_dispatch __P((ZNotice_t *notice, int auth,
+                          struct sockaddr_in *who, Server *server));
+Code_t control_dispatch __P((ZNotice_t *notice, int auth,
+                            struct sockaddr_in *who, Server *server));
+Code_t xmit_frag __P((ZNotice_t *notice, char *buf, int len, int waitforack));
+void hostm_shutdown __P((void));
 
 /* found in kstuff.c */
 #ifdef HAVE_KRB4
-int GetKerberosData (int, struct in_addr, AUTH_DAT *, char *, char *);
-Code_t ReadKerberosData(int, int *, char **, int *);
-Code_t SendKerberosData (int, KTEXT, char *, char *);
-Code_t SendKrb5Data(int, krb5_data *);
-Code_t GetKrb5Data(int, krb5_data *);
-void sweep_ticket_hash_table(void *);
-Code_t ZCheckRealmAuthentication(ZNotice_t *, struct sockaddr_in *, char *);
+int GetKerberosData  __P((int, struct in_addr, AUTH_DAT *, char *, char *));
+Code_t SendKerberosData  __P((int, KTEXT, char *, char *));
+void sweep_ticket_hash_table __P((void *));
 #endif
-    
+
+/* found in kopt.c */
+#ifdef HAVE_KRB4
+#ifndef NOENCRYPTION
+Sched *check_key_sched_cache __P((des_cblock key));
+void add_to_key_sched_cache __P((des_cblock key, Sched *sched));
+int krb_set_key __P((char *key, int cvt));
+/* int krb_rd_req __P((KTEXT authent, char *service, char *instance,
+                   unsigned KRB_INT32 from_addr, AUTH_DAT *ad, char *fn)); */
+int krb_find_ticket __P((KTEXT authent, KTEXT ticket));
+int krb_get_lrealm __P((char *r, int n));
+#endif
+#endif
+
 /* found in server.c */
-void server_timo(void *which);
-void server_dump_servers(FILE *fp);
-void server_init(void);
-void server_shutdown(void);
-void server_forward(ZNotice_t *notice, int auth,
-                        struct sockaddr_in *who);
-void server_kill_clt(Client *client);
-void server_pending_free(Pending *pending);
-void server_self_queue(ZNotice_t *, int, struct sockaddr_in *);
-void server_send_queue(Server *);
-void server_reset(void);
-Server *server_which_server(struct sockaddr_in *who);
-Pending *server_dequeue(Server *server);
-Code_t server_dispatch(ZNotice_t *notice, int auth,
-                           struct sockaddr_in *who);
-Code_t server_adispatch(ZNotice_t *notice, int auth,
-                            struct sockaddr_in *who, Server *server);
+void server_timo __P((void *which));
+void server_dump_servers __P((FILE *fp));
+void server_init __P((void));
+void server_shutdown __P((void));
+void server_forward __P((ZNotice_t *notice, int auth,
+                        struct sockaddr_in *who));
+void server_kill_clt __P((Client *client));
+void server_pending_free __P((Pending *pending));
+void server_self_queue __P((ZNotice_t *, int, struct sockaddr_in *));
+void server_send_queue __P((Server *));
+void server_reset __P((void));
+int is_server();
+Server *server_which_server __P((struct sockaddr_in *who));
+Pending *server_dequeue __P((Server *server));
+Code_t server_dispatch __P((ZNotice_t *notice, int auth,
+                           struct sockaddr_in *who));
+Code_t server_adispatch __P((ZNotice_t *notice, int auth,
+                            struct sockaddr_in *who, Server *server));
 
 /* found in subscr.c */
-Code_t subscr_foreign_user(ZNotice_t *, struct sockaddr_in *, Server *, ZRealm *);
-Code_t subscr_cancel(struct sockaddr_in *sin, ZNotice_t *notice);
-Code_t subscr_subscribe(Client *who, ZNotice_t *notice, Server *server);
-Code_t subscr_send_subs(Client *client);
-void subscr_cancel_client(Client *client);
-void subscr_sendlist(ZNotice_t *notice, int auth,
-                         struct sockaddr_in *who);
-void subscr_dump_subs(FILE *fp, Destlist *subs);
-void subscr_reset(void);
-Code_t subscr_def_subs(Client *who);
-Code_t subscr_realm(ZRealm *, ZNotice_t *);
-Code_t subscr_send_realm_subs(ZRealm *);
-Code_t subscr_realm_cancel(struct sockaddr_in *, ZNotice_t *, ZRealm *);
+Code_t subscr_foreign_user __P((ZNotice_t *, struct sockaddr_in *, Server *, Realm *));
+Code_t subscr_cancel __P((struct sockaddr_in *sin, ZNotice_t *notice));
+Code_t subscr_subscribe __P((Client *who, ZNotice_t *notice, Server *server));
+Code_t subscr_send_subs __P((Client *client));
+void subscr_cancel_client __P((Client *client));
+void subscr_sendlist __P((ZNotice_t *notice, int auth,
+                         struct sockaddr_in *who));
+void subscr_dump_subs __P((FILE *fp, Destlist *subs));
+void subscr_reset __P((void));
+Code_t subscr_def_subs __P((Client *who));
 
 /* found in uloc.c */
-void uloc_hflush(struct in_addr *addr);
-void uloc_flush_client(struct sockaddr_in *sin);
-void uloc_dump_locs(FILE *fp);
-Code_t ulogin_dispatch(ZNotice_t *notice, int auth,
-                           struct sockaddr_in *who, Server *server);
-Code_t ulocate_dispatch(ZNotice_t *notice, int auth,
-                            struct sockaddr_in *who, Server *server);
-Code_t uloc_send_locations(void);
-void ulogin_relay_locate(ZNotice_t *, struct sockaddr_in *);
-void ulogin_realm_locate(ZNotice_t *, struct sockaddr_in *, ZRealm *);
+void uloc_hflush __P((struct in_addr *addr));
+void uloc_flush_client __P((struct sockaddr_in *sin));
+void uloc_dump_locs __P((FILE *fp));
+Code_t ulogin_dispatch __P((ZNotice_t *notice, int auth,
+                           struct sockaddr_in *who, Server *server));
+Code_t ulocate_dispatch __P((ZNotice_t *notice, int auth,
+                            struct sockaddr_in *who, Server *server));
+Code_t uloc_send_locations __P((void));
 
 /* found in realm.c */
-int realm_sender_in_realm(char *realm, char *sender);
-int realm_bound_for_realm(char *realm, char *recip);
-ZRealm *realm_which_realm(struct sockaddr_in *who);
-ZRealm *realm_get_realm_by_name(char *name);
-ZRealm *realm_get_realm_by_pid(int);
-void realm_handoff(ZNotice_t *, int, struct sockaddr_in *, ZRealm *, int);
+int realm_sender_in_realm __P((char *realm, char *sender));
+int realm_bound_for_realm __P((char *realm, char *recip));
+Realm *realm_which_realm __P((struct sockaddr_in *who));
+Realm *realm_get_realm_by_name __P((char *name));
+Realm *realm_get_realm_by_pid __P((int));
+void realm_handoff(ZNotice_t *, int, struct sockaddr_in *, Realm *, int);
 char *realm_expand_realm(char *);
-void realm_init(void);
-Code_t ZCheckZRealmAuthentication(ZNotice_t *, struct sockaddr_in *,
-                                     char *);
-Code_t realm_control_dispatch(ZNotice_t *, int, struct sockaddr_in *,
-                                  Server *, ZRealm *);
-void realm_shutdown(void);
-void realm_deathgram(Server *);
-Code_t realm_send_realms(void);
-Code_t realm_dispatch(ZNotice_t *, int, struct sockaddr_in *, Server *);
-void realm_wakeup(void);
-void kill_realm_pids(void);
-void realm_dump_realms(FILE *);
+void realm_init __P((void));
+Code_t ZCheckRealmAuthentication __P((ZNotice_t *, struct sockaddr_in *,
+                                     char *));
+Code_t realm_control_dispatch __P((ZNotice_t *, int, struct sockaddr_in *,
+                                  Server *, Realm *));
+void realm_shutdown __P((void));
+void realm_deathgram __P((Server *));
 
 /* found in version.c */
-char *get_version(void);
-
-/* found in access.c */
-int access_check(char *, Acl *, Access);
+char *get_version __P((void));
 
 /* global identifiers */
 
 /* found in main.c */
-int packets_waiting(void);
+int packets_waiting __P((void));
 extern struct sockaddr_in srv_addr;    /* server socket address */
 extern unsigned short hm_port;         /* host manager receiver port */
 extern unsigned short hm_srv_port;     /* host manager server sending port */
@@ -393,10 +355,6 @@ extern int nfds;                   /* number to look at in select() */
 extern int zdebug;
 extern char myname[];                  /* domain name of this host */
 extern char list_file[];
-#ifdef HAVE_KRB5
-extern char keytab_file[];
-extern krb5_ccache Z_krb5_ccache;
-#endif
 #ifdef HAVE_KRB4
 extern char srvtab_file[];
 extern char my_realm[];
@@ -427,7 +385,7 @@ extern int nservers;                        /* number of other servers*/
 extern String *empty;
 extern String *wildcard_instance;
 
-extern ZRealm *otherrealms;
+extern Realm *otherrealms;
 extern int nrealms;
 
 extern struct in_addr my_addr; /* my inet address */
index 5508e3afc349054477e3153124fc19f1dd96f92e..7b663da20f3d5db05635f933e47295c12bc7bcb4 100644 (file)
 
 #define SERVER_LIST_FILE       "server.list"
 #define REALM_LIST_FILE                "realm.list"
-#ifdef HAVE_KRB5
-#define ZEPHYR_KEYTAB          "krb5.keytab"
-#define ZEPHYR_TK5FILE         "z5tkts"
-#endif
 #ifdef HAVE_KRB4
 #define ZEPHYR_SRVTAB          "srvtab"
 #define ZEPHYR_TKFILE          "ztkts"
index 36d6a3f70ddbc372b98c0ae4a8ba81bf5f8cc51c..de48f21d43ab5b9608f14ff6dbec673fdbd5b37b 100644 (file)
@@ -13,7 +13,7 @@ ec ZSRV_NOCLT,
 ec ZSRV_NOSUB,
        "No such subscription"
 ec ZSRV_NOCLASS,
-       "Class unknown"
+       "Class unkown"
 ec ZSRV_CLASSXISTS,
        "Class already registered"
 ec ZSRV_CLASSRESTRICTED,
index 05cd41864b92b252da796ffa22ac87b1d2c0b9a1..e4e26b842345fe976166f6cdc83e5da79a9c378a 100644 (file)
@@ -23,8 +23,9 @@ static const char rcsid_zstring_c[] =
 static String *zhash[STRING_HASH_TABLE_SIZE];
 
 String *
-make_string(char *s,
-           int downcase)
+make_string(s, downcase)
+    char *s;
+    int downcase;
 {
     char *new_s,*p;
     String *new_z,*hp;
@@ -72,7 +73,8 @@ make_string(char *s,
 }
 
 void
-free_string(String *z)
+free_string(z)
+    String *z;
 {
     if (z == (String *) NULL)
        return;
@@ -95,8 +97,9 @@ free_string(String *z)
 }
 
 String *
-find_string(char *s,
-           int downcase)
+find_string(s,downcase)
+    char *s;
+    int downcase;
 {
     char *new_s,*p;
     String *z;
@@ -127,8 +130,8 @@ find_string(char *s,
 }
 
 int
-comp_string(String *a,
-           String *b)
+comp_string(a,b)
+    String *a, *b;
 {
     if (a->hash_val > b->hash_val)
        return 1;
@@ -138,7 +141,8 @@ comp_string(String *a,
 }
 
 void
-print_string_table(FILE *f)
+print_string_table(f)
+    FILE *f;
 {
     String *p;
     int i;
@@ -153,7 +157,8 @@ print_string_table(FILE *f)
 }
 
 String *
-dup_string(String *z)
+dup_string(z)
+    String *z;
 {
     z->ref_count++;
     return z;
index b028f7cc754d92944cd936eab9df818a4fd3b53c..5a072aabf32661b90d0f3d85592398cfe05f2088 100644 (file)
@@ -14,7 +14,7 @@
 
 #ifndef lint
 #ifndef SABER
-static const char rcsid_queue_c[] = "$Id$";
+static char rcsid_queue_c[] = "$Id$";
 #endif /* SABER */
 #endif /* lint */
 
@@ -30,19 +30,17 @@ typedef struct _Queue {
 static Queue *hm_queue;
 static int retransmits_enabled = 0;
 
-static Queue *find_notice_in_queue(ZNotice_t *notice);
-static void queue_timeout(void *arg);
-
-extern void new_server(char *);
+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 };
 
 #ifdef DEBUG
-Code_t dump_queue(void);
+Code_t dump_queue();
 #endif
 
-void
-init_queue(void)
+void init_queue()
 {
     Queue *q;
 
@@ -58,11 +56,11 @@ init_queue(void)
     DPR("Queue initialized and flushed.\n");
 }
 
-Code_t
-add_notice_to_queue(ZNotice_t *notice,
-                   char *packet,
-                   struct sockaddr_in *repl,
-                   int len)
+Code_t add_notice_to_queue(notice, packet, repl, len)
+    ZNotice_t *notice;
+    char * packet;
+    struct sockaddr_in *repl;
+    int len;
 {
     Queue *entry;
 
@@ -83,13 +81,7 @@ add_notice_to_queue(ZNotice_t *notice,
            free(entry->packet);
        } else {
            entry->reply = *repl;
-           /*LIST_INSERT(&hm_queue, entry);*/
-
-           (entry)->next = *(&hm_queue);
-           if (*&hm_queue) ((*(&hm_queue))->prev_p = &(entry)->next);
-           (*&hm_queue) = (entry);
-           (entry)->prev_p = (&hm_queue);
-               
+           LIST_INSERT(&hm_queue, entry);
        }
        entry->timer = (retransmits_enabled) ?
            timer_set_rel(rexmit_times[0], queue_timeout, entry) : NULL;
@@ -97,10 +89,10 @@ add_notice_to_queue(ZNotice_t *notice,
     return(ZERR_NONE);
 }
 
-Code_t
-remove_notice_from_queue(ZNotice_t *notice,
-                        ZNotice_Kind_t *kind,
-                        struct sockaddr_in *repl)
+Code_t remove_notice_from_queue(notice, kind, repl)
+    ZNotice_t *notice;
+    ZNotice_Kind_t *kind;
+    struct sockaddr_in *repl;
 {
     Queue *entry;
 
@@ -114,9 +106,7 @@ remove_notice_from_queue(ZNotice_t *notice,
     if (entry->timer)
        timer_reset(entry->timer);
     free(entry->packet);
-    /*LIST_DELETE(entry);*/
-    *(entry)->prev_p = (entry)->next;
-    if((entry)->next) ((entry)->next->prev_p = (entry)->prev_p);
+    LIST_DELETE(entry);
 #ifdef DEBUG
     dump_queue();
 #endif /* DEBUG */
@@ -125,8 +115,8 @@ remove_notice_from_queue(ZNotice_t *notice,
 }
 
 /* We have a server; transmit all of our packets. */
-void
-retransmit_queue(struct sockaddr_in *sin)
+void retransmit_queue(sin)
+    struct sockaddr_in *sin;
 {
     Queue *entry;
     Code_t ret;
@@ -158,8 +148,7 @@ retransmit_queue(struct sockaddr_in *sin)
 }
 
 /* We lost our server; nuke all of our timers. */
-void
-disable_queue_retransmits(void)
+void disable_queue_retransmits()
 {
     Queue *entry;
 
@@ -172,8 +161,7 @@ disable_queue_retransmits(void)
 }
 
 #ifdef DEBUG
-static Code_t
-dump_queue(void)
+static Code_t dump_queue()
 {
     Queue *entry;
     caddr_t mp;
@@ -205,8 +193,7 @@ dump_queue(void)
 }
 #endif /* DEBUG */
 
-int
-queue_len(void)
+int queue_len()
 {
     int length = 0;
     Queue *entry;
@@ -216,8 +203,8 @@ queue_len(void)
     return length;
 }
 
-static Queue *
-find_notice_in_queue(ZNotice_t *notice)
+static Queue *find_notice_in_queue(notice)
+    ZNotice_t *notice;
 {
     Queue *entry;
 
@@ -228,8 +215,8 @@ find_notice_in_queue(ZNotice_t *notice)
     return NULL;
 }
 
-static void
-queue_timeout(void *arg)
+static void queue_timeout(arg)
+    void *arg;
 {
     Queue *entry = (Queue *) arg;
     Code_t ret;
index 4fb764eb0817fbef10d2b37921414d9974f708de..1fe3d3931488b82543cd4d7fd345d25a487bfbb2 100644 (file)
@@ -115,13 +115,13 @@ static Timer **heap;
 static int num_timers = 0;
 static int heap_size = 0;
 
-static void timer_botch (void*);
-static Timer *add_timer (Timer *);
+static void timer_botch __P((void*));
+static Timer *add_timer __P((Timer *));
 
-Timer *
-timer_set_rel(long time_rel,
-             void (*proc)(void *),
-             void *arg)
+Timer *timer_set_rel(time_rel, proc, arg)
+    long time_rel;
+    void (*proc) __P((void *));
+    void *arg;
 {
     Timer *new_t;
 
@@ -135,7 +135,8 @@ timer_set_rel(long time_rel,
 }
 
 void
-timer_reset(Timer *tmr)
+timer_reset(tmr)
+    Timer *tmr;
 {
     int pos, min;
 
@@ -176,7 +177,8 @@ timer_reset(Timer *tmr)
 #define set_timeval(t,s) ((t).tv_sec=(s),(t).tv_usec=0,(t))
 
 static Timer *
-add_timer(Timer *new)
+add_timer(new)
+    Timer *new;
 {
     int pos;
 
@@ -206,11 +208,12 @@ add_timer(Timer *new)
 }
 
 void
-timer_process(void)
+timer_process()
 {
     Timer *t;
     timer_proc func;
     void *arg;
+    int valid = 0;
 
     if (num_timers == 0 || heap[0]->abstime > time(NULL))
        return;
@@ -229,7 +232,8 @@ timer_process(void)
 }
 
 struct timeval *
-timer_timeout(struct timeval *tvbuf)
+timer_timeout(tvbuf)
+    struct timeval *tvbuf;
 {
     if (num_timers > 0) {
        tvbuf->tv_sec = heap[0]->abstime - time(NULL);
@@ -243,7 +247,8 @@ timer_timeout(struct timeval *tvbuf)
 }
 
 static void
-timer_botch(void *arg)
+timer_botch(arg)
+    void *arg;
 {
     syslog(LOG_CRIT, "timer botch\n");
     abort();
index 8e1303d08481c9550485c9c876f79e48fbe145e1..4061c17d5c991950d7feef22a1cab71f7381fb3a 100644 (file)
@@ -42,40 +42,32 @@ struct hostent *hp;
 char hostname[MAXHOSTNAMELEN], loopback[4];
 char PidFile[128];
 
-static RETSIGTYPE deactivate(int);
-static RETSIGTYPE terminate(int);
-static void choose_server(void);
-static void init_hm(void);
-static void detach(void);
-static void send_stats(ZNotice_t *, struct sockaddr_in *);
-static char *strsave(const char *);
-
-extern void send_flush_notice(char *);
-extern void server_manager(ZNotice_t *);
-extern void send_boot_notice(char *);
-extern void find_next_server(char *);
+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(int ignored)
+static RETSIGTYPE deactivate()
 {
     deactivating = 1;
 }
 
-static RETSIGTYPE
-terminate(int ignored)
+static RETSIGTYPE terminate()
 {
     terminating = 1;
 }
 
-int
-main(int argc,
-     char *argv[])
+main(argc, argv)
+char *argv[];
 {
     ZNotice_t notice;
     ZPacket_t packet;
     Code_t ret;
-    int opt, pak_len, fd, count;
+    int opt, pak_len, i, j = 0, fd, count;
     fd_set readers;
     struct timeval tv;
 
@@ -254,8 +246,7 @@ main(int argc,
     }
 }
 
-static void
-choose_server(void)
+static void choose_server()
 {
     int i = 0;
     char **clust_info, **cpp;
@@ -362,8 +353,7 @@ choose_server(void)
     }
 }
 
-static void
-init_hm(void)
+static void init_hm()
 {
      struct servent *sp;
      Code_t ret;
@@ -464,15 +454,13 @@ init_hm(void)
 #endif
 }
 
-static void
-detach(void)
+static void detach()
 {
      /* detach from terminal and fork. */
      register int i, x = ZGetFD();
      register long size;
-
-     i = fork();
-     if (i) {
+  
+     if (i = fork()) {
          if (i < 0)
               perror("fork");
          exit(0);
@@ -506,9 +494,9 @@ detach(void)
 
 static char version[BUFSIZ];
 
-static void
-send_stats(ZNotice_t *notice,
-          struct sockaddr_in *sin)
+static void send_stats(notice, sin)
+     ZNotice_t *notice;
+     struct sockaddr_in *sin;
 {
      ZNotice_t newnotice;
      Code_t ret;
@@ -620,8 +608,7 @@ send_stats(ZNotice_t *notice,
          free(list[i]);
 }
 
-void
-die_gracefully(void)
+void die_gracefully()
 {
      syslog(LOG_INFO, "Terminate signal caught...");
      unlink(PidFile);
@@ -629,13 +616,14 @@ die_gracefully(void)
      exit(0);
 }
 
-static char *
-strsave(const char *sp)
+static char *strsave(sp)
+    const char *sp;
 {
     register char *ret;
 
-    if((ret = strdup(sp)) == NULL) {
+    if((ret = malloc((unsigned) strlen(sp)+1)) == NULL) {
            abort();
     }
+    strcpy(ret,sp);
     return(ret);
 }
index c93009855426cf19d1b0c95c912bd1749a70013d..3d6f1532daedf57147a1ed76cf473b32e5c1ad8a 100644 (file)
@@ -16,8 +16,6 @@
 #include <zephyr/mit-copyright.h>
 #include <internal.h>
 #include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
 #include <sys/time.h>
 #include "timer.h"
 
index 0c5b68efd505a0a26dd8c1d8af1d469e9fa46910..6ee448bc176dec026d7fcf634e144a3ba7165712 100644 (file)
 
 #ifndef lint
 #ifndef SABER
-static const char rcsid_hm_client_c[] = "$Id$";
+static char rcsid_hm_client_c[] = "$Id$";
 #endif /* SABER */
 #endif /* lint */
 
 extern int no_server, nclt, deactivated, noflushflag;
 extern struct sockaddr_in cli_sin, serv_sin, from;
 
-extern void send_flush_notice(char *);
-extern void new_server(char *sugg_serv);
-
-void transmission_tower(ZNotice_t *notice,
-                       char *packet,
-                       int pak_len)
+void transmission_tower(notice, packet, pak_len)
+     ZNotice_t *notice;
+     char *packet;
+     int pak_len;
 {
     ZNotice_t gack;
     Code_t ret;
@@ -76,7 +74,7 @@ void transmission_tower(ZNotice_t *notice,
            Zperr(ret);
            com_err("hm", ret, "setting destination");
        }
-       if ((ret = ZSendPacket(packet, pak_len, 0)) != ZERR_NONE) {
+       if ((ret = send_outgoing(notice)) != ZERR_NONE) {
            Zperr(ret);
            com_err("hm", ret, "while sending raw notice");
        }
@@ -86,7 +84,8 @@ void transmission_tower(ZNotice_t *notice,
 }
 
 Code_t
-send_outgoing(ZNotice_t *notice)
+send_outgoing(notice)
+ZNotice_t *notice;
 {
     Code_t retval;
     char *packet;
index 9d8157fa810a30569de3b62e3bc03ab1dbca94a9..50fa04f2cc9cd80367092ebfe5e22100bad22a0f 100644 (file)
@@ -14,7 +14,7 @@
 
 #ifndef lint
 #ifndef SABER
-static const char rcsid_hm_server_c[] = "$Id$";
+static char rcsid_hm_server_c[] = "$Id$";
 #endif /* SABER */
 #endif /* lint */
 
@@ -33,16 +33,15 @@ extern int deactivated, rebootflag;
 extern int numserv;
 extern char **serv_list;
 extern char cur_serv[], prim_serv[];
-extern void die_gracefully(void);
+extern void die_gracefully();
 
-void hm_control(ZNotice_t *);
-void send_back(ZNotice_t *);
-void new_server(char *);
+void hm_control(), send_back(), new_server();
 
 /* Argument is whether we are actually booting, or just attaching
  * after a server switch */
 void
-send_boot_notice(char *op)
+send_boot_notice(op)
+char *op;
 {
      ZNotice_t notice;
      Code_t ret;
@@ -73,7 +72,8 @@ send_boot_notice(char *op)
 
 /* Argument is whether we are detaching or really going down */
 void
-send_flush_notice(char *op)
+send_flush_notice(op)
+char *op;
 {
      ZNotice_t notice;
      Code_t ret;
@@ -102,7 +102,8 @@ send_flush_notice(char *op)
 }
 
 void
-find_next_server(char *sugg_serv)
+find_next_server(sugg_serv)
+char *sugg_serv;
 {
      struct hostent *hp;
      int done = 0;
@@ -175,7 +176,8 @@ find_next_server(char *sugg_serv)
 }
 
 void
-server_manager(ZNotice_t *notice)
+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)) {
@@ -206,7 +208,8 @@ server_manager(ZNotice_t *notice)
 }
 
 void
-hm_control(ZNotice_t *notice)
+hm_control(notice)
+ZNotice_t *notice;
 {
     Code_t ret;
     struct hostent *hp;
@@ -248,7 +251,8 @@ hm_control(ZNotice_t *notice)
 }
 
 void
-send_back(ZNotice_t *notice)
+send_back(notice)
+ZNotice_t *notice;
 {
     ZNotice_Kind_t kind;
     struct sockaddr_in repl;
@@ -286,7 +290,8 @@ send_back(ZNotice_t *notice)
 }
 
 void
-new_server(char *sugg_serv)
+new_server(sugg_serv)
+char *sugg_serv;
 {
     no_server = 1;
     syslog (LOG_INFO, "Server went down, finding new server.");
@@ -301,8 +306,8 @@ new_server(char *sugg_serv)
     disable_queue_retransmits();
 }
 
-static void
-boot_timeout(void *arg)
+static void boot_timeout(arg)
+void *arg;
 {
     serv_timeouts++;
     new_server(NULL);
index b0f1476b65c62c9f2975d2f0c96e0ba6bfa1c3f7..c752e0551bde4f8c8f233a3799bdc3dc856c61bf 100644 (file)
@@ -77,7 +77,7 @@ lexer.o: y.tab.h
 parser.o: y.tab.c y.tab.h
        ${CC} -c ${ALL_CFLAGS} -o $@ y.tab.c
 
-y.tab.c y.tab.h: ${srcdir}/parser.y
+y.tab.c y.tab.h: parser.y
        ${YACC} ${YFLAGS} ${srcdir}/parser.y
 
 .c.o:
index e969eb742b2354e28d4d83f91f1fa875a0a3bc99..925a05be13f6bef530b497c434afa4b2220fdf7b 100644 (file)
@@ -27,7 +27,6 @@ static const char rcsid_X_driver_c[] = "$Id$";
 
 #ifndef X_DISPLAY_MISSING
 
-#include "new_string.h"
 #include "X_driver.h"
 #include <X11/Xresource.h>
 #include "new_memory.h"
@@ -38,7 +37,6 @@ static const char rcsid_X_driver_c[] = "$Id$";
 #include "X_gram.h"
 #include "xselect.h"
 #include "unsigned_long_dictionary.h"
-#include "zephyr.h"
 
 char *app_instance;
 
@@ -86,8 +84,8 @@ static XrmDatabase x_resources = NULL;
  *                  returns -1.
  */
 
-static int
-convert_string_to_bool(string text)
+static int convert_string_to_bool(text)
+     string text;
 {
     if (!strcasecmp("yes", text) || !strcasecmp("y", text) ||
        !strcasecmp("true", text) || !strcasecmp("t", text) ||
@@ -105,9 +103,9 @@ convert_string_to_bool(string text)
  *
  */
 
-char *
-get_string_resource(string name,
-                   string class)
+char *get_string_resource(name, class)
+     string name;
+     string class;
 {
     string full_name, full_class;
     int status;
@@ -136,10 +134,10 @@ get_string_resource(string name,
  *
  */
 
-int
-get_bool_resource(string name,
-                 string class,
-                 int default_value)
+int get_bool_resource(name, class, default_value)
+     string name;
+     string class;
+     int default_value;
 {
     int result;
     char *temp;
@@ -167,9 +165,9 @@ static unsigned_long_dictionary color_dict = NULL;
  *     trip each time.
  */
 
-unsigned long
-x_string_to_color(char *name,
-                 unsigned long def)
+unsigned long x_string_to_color(name,def)
+     char *name;
+     unsigned long def;
 {
    unsigned_long_dictionary_binding *binding;
    int exists;
@@ -238,13 +236,14 @@ static XrmOptionDescRec cmd_options[] = {
  *
  */
 
-int
-open_display_and_load_resources(int *pargc,
-                               char **argv)
+int open_display_and_load_resources(pargc, argv)
+     int *pargc;
+     char **argv;
 {
     XrmDatabase temp_db1, temp_db2, temp_db3;
     char *filename, *res, *xdef;
     char dbasename[128];
+    extern char *getenv();
 
     /* Initialize X resource manager: */
     XrmInitialize();
@@ -295,8 +294,7 @@ open_display_and_load_resources(int *pargc,
     /*
      * Get XENVIRONMENT resources, if they exist, and merge
      */
-    filename = getenv("XENVIRONMENT");
-    if (filename)
+    if (filename = getenv("XENVIRONMENT"))
     {
        temp_db3 = XrmGetFileDatabase(filename);
        XrmMergeDatabases(temp_db3, &temp_db1);
@@ -318,9 +316,11 @@ open_display_and_load_resources(int *pargc,
  *
  */
 
-int
-X_driver_ioerror(Display *display)
+int X_driver_ioerror(display)
+Display *display;
 {
+    extern void finalize_zephyr();
+
     ERROR2("X IO error on display '%s'--exiting\n", DisplayString(display));
     finalize_zephyr();
     exit(1);
@@ -331,12 +331,14 @@ X_driver_ioerror(Display *display)
 /*                                                                          */
 /****************************************************************************/
 
+extern void x_get_input();
+
 /*ARGSUSED*/
-int
-X_driver_init(char *drivername,
-             char notfirst,
-             int *pargc,
-             char **argv)
+int X_driver_init(drivername, notfirst, pargc, argv)
+     char *drivername;
+     char notfirst;
+     int *pargc;
+     char **argv;
 {
     string temp;
     int sync;
@@ -356,11 +358,9 @@ X_driver_init(char *drivername,
     /*
      * For now, set some useful variables using resources:
      */
-    sync = get_bool_resource("synchronous", "Synchronous", 0);
-    if (sync)
-      XSynchronize(dpy, sync);
-    temp = get_string_resource("geometry", "Geometry");
-    if (temp)
+    if (sync=get_bool_resource("synchronous", "Synchronous", 0))
+      XSynchronize(dpy,sync);
+    if (temp = get_string_resource("geometry", "Geometry"))
       var_set_variable("default_X_geometry", temp);
 
     temp=strrchr(argv[0],'/');
@@ -373,13 +373,12 @@ X_driver_init(char *drivername,
     x_gram_init(dpy);
     xicccmInitAtoms(dpy);
     
-    mux_add_input_source(ConnectionNumber(dpy), (void(*)(void *))x_get_input, dpy);
+    mux_add_input_source(ConnectionNumber(dpy), x_get_input, dpy);
 
     return(0);
 }
 
-void
-X_driver_reset(void)
+void X_driver_reset()
 {
 }
 
@@ -389,8 +388,8 @@ X_driver_reset(void)
 /*                                                                          */
 /****************************************************************************/
 
-char *
-X_driver(string text)
+char *X_driver(text)
+     string text;
 {
     string text_copy;
     desctype *desc;
index b32562ece1a46f0fa3e0199e0dc0e4d1261247f3..ec2492f48bb99763624130b553590b57f8b0a582 100644 (file)
 
 #include <X11/Xlib.h>
 
-#include "new_string.h"
-
 extern Display *dpy;
 
-extern char *get_string_resource(string, string);
-extern int get_bool_resource(string, string, int);
-extern unsigned long x_string_to_color(char *, unsigned long);
+extern char *get_string_resource();
+extern int get_bool_resource();
 
 #endif
index 0d8e2b79ee84b8bbdabe3e76d97b6ec3a0e1ac10..93583838831338ebdce6f0a0681f09a7d4837656 100644 (file)
@@ -51,9 +51,11 @@ static pointer_dictionary fidst_dict = NULL;
 static string face_to_string[] = { "roman", "bold", "italic", "bolditalic" };
 static string size_to_string[] = { "small", "medium", "large" };
 
-static char *
-get_family(char *style,
-          char *substyle)
+extern char *get_string_resources();
+
+static char *get_family(style,substyle)
+     char *style;
+     char *substyle;
 {
    char *desc;
    pointer_dictionary_binding *binding;
@@ -85,10 +87,10 @@ get_family(char *style,
    }
 }
 
-static char *
-get_specific_fontname(char *family,
-                     int size,
-                     int face)
+static char *get_specific_fontname(family,size,face)
+     char *family;
+     int size;
+     int face;
 {
    char *desc;
    pointer_dictionary_binding *binding;
@@ -125,8 +127,8 @@ get_specific_fontname(char *family,
  * that I know that Font us really an unsigned long. */
 
 static char hexdigits[] = {"0123456789ABCDEF"};
-static char *
-Font_to_hex(Font num)
+static char *Font_to_hex(num)
+     Font num;
 {
    char *temp;
    int i;
@@ -140,8 +142,8 @@ Font_to_hex(Font num)
    return(temp);
 }
 
-void
-add_fid(XFontStruct *font)
+void add_fid(font)
+     XFontStruct *font;
 {
    
    char *fidstr;
@@ -159,8 +161,8 @@ add_fid(XFontStruct *font)
 }
 
 /* requires that the font already be cached. */
-XFontStruct *
-get_fontst_from_fid(Font fid)
+XFontStruct *get_fontst_from_fid(fid)
+     Font fid;
 {
    char *fidstr;
    pointer_dictionary_binding *binding;
@@ -182,9 +184,9 @@ get_fontst_from_fid(Font fid)
 #endif
 }
 
-static XFontStruct *
-get_fontst(Display *dpy,
-          char *fontname)
+static XFontStruct *get_fontst(dpy,fontname)
+     Display *dpy;
+     char *fontname;
 {
    pointer_dictionary_binding *binding;
    int exists;
@@ -207,10 +209,10 @@ get_fontst(Display *dpy,
    }
 }
 
-static char *
-get_fontname(char *family,
-            int size,
-            int face)
+static char *get_fontname(family,size,face)
+     char *family;
+     int size;
+     int face;
 {
    char *fontname;
 
@@ -221,19 +223,19 @@ get_fontname(char *family,
    return(fontname);
 }
 
-static XFontStruct *
-complete_get_fontst(Display *dpy,
-                   string style,
-                   string substyle,
-                   int size,
-                   int face)
+static XFontStruct *complete_get_fontst(dpy,style,substyle,size,face)
+     Display *dpy;
+     string style;
+     string substyle;
+     int size;
+     int face;
 {
    char *family,*fontname;
    XFontStruct *fontst;
 
-   if ((family=get_family(style,substyle)))
-     if ((fontname=get_fontname(family,size,face)))
-       if ((fontst=get_fontst(dpy,fontname)))
+   if (family=get_family(style,substyle))
+     if (fontname=get_fontname(family,size,face))
+       if (fontst=get_fontst(dpy,fontname))
         return(fontst);
    /* If any part fails, */
    return(NULL);
@@ -247,28 +249,28 @@ complete_get_fontst(Display *dpy,
  *          Effects: unknown
  */
 
-XFontStruct *
-get_font(Display *dpy,
-        string style,
-        string substyle,
-        int size,
-        int face)
+XFontStruct *get_font(dpy,style,substyle,size,face)
+     Display *dpy;
+     string style;
+     string substyle;
+     int size;
+     int face;
 {
    char *family,*fontname;
    XFontStruct *fontst;
 
    if (size == SPECIAL_SIZE) {
       /* attempt to process @font explicitly */
-      if ((fontst = get_fontst(dpy, substyle)))
+      if (fontst=get_fontst(dpy,substyle))
        return(fontst);
    } else {
-      if ((family = get_family(style, substyle))) {
-        if ((fontname = get_fontname(family, size,face)))
-          if ((fontst = get_fontst(dpy, fontname)))
+      if (family=get_family(style,substyle)) {
+        if (fontname=get_fontname(family,size,face))
+          if (fontst=get_fontst(dpy,fontname))
             return(fontst);
       } else {
-        if ((fontname = get_fontname(substyle, size, face)))
-          if ((fontst = get_fontst(dpy, fontname)))
+        if (fontname=get_fontname(substyle,size,face))
+          if (fontst=get_fontst(dpy,fontname))
             return(fontst);
       }
 
@@ -276,17 +278,17 @@ get_font(Display *dpy,
       of substyle being the fontfamily didn't happen, either. */
 
       fontst=NULL;
-      if (!(fontst = complete_get_fontst(dpy,style,"text",size,face)))
-       if (!(fontst = complete_get_fontst(dpy,"default",substyle,size,face)))
-         if (!(fontst = complete_get_fontst(dpy,"default","text",size,face)))
-           if ((fontname = get_fontname("default",size,face)))
-             fontst = get_fontst(dpy,fontname);
+      if (!(fontst=complete_get_fontst(dpy,style,"text",size,face)))
+       if (!(fontst=complete_get_fontst(dpy,"default",substyle,size,face)))
+         if (!(fontst=complete_get_fontst(dpy,"default","text",size,face)))
+           if (fontname=get_fontname("default",size,face))
+             fontst=get_fontst(dpy,fontname);
       if (fontst) return(fontst);
    }
 
    /* If all else fails, try fixed */
 
-   if ((fontst=get_fontst(dpy,"fixed"))) return(fontst);
+   if (fontst=get_fontst(dpy,"fixed")) return(fontst);
 
    /* No fonts available.  Die. */
 
index 62469c842ce7a991baa7993c2b8bc449ee472b4a..9a0a2f96b587e33f8a10f051f4e6862b22b8afe2 100644 (file)
@@ -41,7 +41,7 @@
  *                  specified by default.medium.roman is used. <<<>>>
  */
 
-extern XFontStruct *get_font(Display *, string, string, int, int);
-extern XFontStruct *get_fontst_from_fid(Font);
+extern XFontStruct *get_font();
+extern XFontStruct *get_fontst_from_fid();
 
 #endif
index 6ce4297b748f34c467b965d5e98aaa5bdbdf0935..d5879b3569ffe845a3c57e2b827b092ac51bf12c 100644 (file)
@@ -37,6 +37,8 @@ static const char rcsid_X_gram_c[] = "$Id$";
 
 extern XContext desc_context;
 extern char *app_instance;
+extern unsigned long x_string_to_color();
+extern char *getenv();
 
 /*
  *
@@ -87,14 +89,14 @@ static Atom net_wm_window_type_utility = None;
  */
 
 /*ARGSUSED*/
-void
-x_set_icccm_hints(Display *dpy,
-                 Window w,
-                 char *name,
-                 char *icon_name,
-                 XSizeHints *psizehints,
-                 XWMHints *pwmhints,
-                 Window main_window)
+void x_set_icccm_hints(dpy,w,name,icon_name,psizehints,pwmhints,main_window)
+     Display *dpy;
+     Window w;
+     char *name;
+     char *icon_name;
+     XSizeHints *psizehints;
+     XWMHints *pwmhints;
+     Window main_window;
 {
    XStoreName(dpy,w,name);
    XSetIconName(dpy,w,icon_name);
@@ -111,8 +113,8 @@ x_set_icccm_hints(Display *dpy,
       XSetWMProtocols(dpy,w,&XA_WM_DELETE_WINDOW,1);
 }
 
-void
-x_gram_init(Display *dpy)
+void x_gram_init(dpy)
+     Display *dpy;
 {
     char *temp;
     XSizeHints sizehints;
@@ -127,18 +129,15 @@ x_gram_init(Display *dpy)
        default_fgcolor = default_bgcolor;
        default_bgcolor = tc;
     }
-    temp = get_string_resource("foreground", "Foreground");
-    if (temp)
-      default_fgcolor = x_string_to_color(temp, default_fgcolor);
-    temp = get_string_resource("background", "Background");
-    if (temp)
-      default_bgcolor = x_string_to_color(temp, default_bgcolor);
+    if (temp = get_string_resource("foreground","Foreground"))
+      default_fgcolor = x_string_to_color(temp,default_fgcolor);
+    if (temp = get_string_resource("background","Background"))
+      default_bgcolor = x_string_to_color(temp,default_bgcolor);
     default_bordercolor = default_fgcolor;
-    temp = get_string_resource("borderColor", "BorderColor");
-    if (temp)
-      default_bordercolor = x_string_to_color(temp, default_bordercolor);
+    if (temp = get_string_resource("borderColor","BorderColor"))
+      default_bordercolor = x_string_to_color(temp,default_bordercolor);
 
-    temp = get_string_resource("minTimeToLive", "MinTimeToLive");
+    temp = get_string_resource("minTimeToLive","MinTimeToLive");
     if (temp && atoi(temp)>=0)
        ttl = atoi(temp);
 
@@ -262,9 +261,8 @@ x_gram_init(Display *dpy)
     }
 }
 
-int
-x_calc_gravity(int xalign,
-              int yalign)
+int x_calc_gravity(xalign, yalign)
+     int xalign, yalign;
 {
     if (yalign > 0) {                                  /* North */
        return (xalign > 0)  ? NorthWestGravity
@@ -281,22 +279,21 @@ x_calc_gravity(int xalign,
     }
 }
 
-void
-x_gram_create(Display *dpy,
-             x_gram *gram,
-             int xalign,
-             int yalign,
-             int xpos,
-             int ypos,
-             int xsize,
-             int ysize,
-             int beepcount)
+void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize,
+                  beepcount)
+     Display *dpy;
+     x_gram *gram;
+     int xalign, yalign;
+     int xpos, ypos;
+     int xsize, ysize;
+     int beepcount;
 {
     Window w;
     XSizeHints sizehints;
     XWMHints wmhints;
     XSetWindowAttributes attributes;
     unsigned long all_desktops = 0xFFFFFFFF;
+    extern void x_get_input();
 
     /*
      * Adjust xpos, ypos based on the alignments xalign, yalign and the sizes:
@@ -305,15 +302,15 @@ x_gram_create(Display *dpy,
       xpos = WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xpos - xsize
        - 2*border_width;
     else if (xalign == 0)
-      xpos = ((WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xsize
-              - 2*border_width)>>1) + xpos;
+      xpos = (WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xsize
+             - 2*border_width)>>1 + xpos;
 
     if (yalign<0)
       ypos = HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ypos - ysize
        - 2*border_width;
     else if (yalign == 0)
-      ypos = ((HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ysize
-              - 2*border_width)>>1) + ypos;
+      ypos = (HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ysize
+             - 2*border_width)>>1 + ypos;
 
     /*
      * Create the window:
@@ -400,11 +397,11 @@ x_gram_create(Display *dpy,
     x_get_input(dpy);
 }
 
-void
-x_gram_draw(Display *dpy,
-           Window w,
-           x_gram *gram,
-           Region region)
+void x_gram_draw(dpy, w, gram, region)
+     Display *dpy;
+     Window w;
+     x_gram *gram;
+     Region region;
 {
    int i;
    GC gc;
@@ -496,11 +493,11 @@ x_gram_draw(Display *dpy,
    XFreeGC(dpy,gc);
 }
 
-void
-x_gram_expose(Display *dpy,
-             Window w,
-             x_gram *gram,
-             XExposeEvent *event)
+void x_gram_expose(dpy,w,gram,event)
+     Display *dpy;
+     Window w;
+     x_gram *gram;
+     XExposeEvent *event;
 {
    static Region region;
    static int partregion;
index ed1adf725aee3e200c92fd1b23d127c015e306c3..33623f1b428f3c875dac07222cce87ddeff79ad4 100644 (file)
 #define x_gram_TYPE
 
 #include <X11/Xlib.h>
-#include <X11/Xutil.h>
 #include <sys/time.h>
 
-#include "formatter.h"
-
 typedef struct _xblock {
    unsigned long fgcolor;
    Font fid;
@@ -76,12 +73,10 @@ typedef struct _xlinedesc {
 #define CENTERALIGN 1
 #define RIGHTALIGN  2
 
-extern void x_gram_init(Display *);
-extern void x_gram_create(Display *, x_gram *, int, int, int, int, int, int, int);
-extern void x_gram_expose(Display *, Window, x_gram *, XExposeEvent *);
-extern void xshow(Display *, desctype *, int, int);
-extern void xcut(Display *, XEvent *, XContext);
-extern void x_get_input(Display *);
-extern void xshowinit(void);
+extern void x_gram_init();
+extern void x_gram_create();
+extern void x_gram_expose();
+extern void xshow();
+extern void xcut();
 
 #endif
index 8c047af1d76ad84bd24464629a87939f84229dc0..4b46c2240a87a184d65bacdde39d988dfac50a4b 100644 (file)
@@ -24,14 +24,12 @@ static const char rcsid_buffer_c[] = "$Id$";
 
 static char *buffer = 0;
 
-string
-buffer_to_string(void)
+string buffer_to_string()
 {
     return(buffer);
 }
 
-void
-clear_buffer(void)
+void clear_buffer()
 {
     if (buffer)
       free(buffer);
@@ -39,8 +37,8 @@ clear_buffer(void)
     buffer = string_Copy("");
 }
 
-void
-append_buffer(char *str)
+void append_buffer(str)
+     char *str;
 {
     buffer = string_Concat2(buffer, str);
 }
index db3f2ea28cdd4dff1c0d13f8c716aeac5ed85aa7..8b9e5b21ff98eb6728613191aae2db392fb472d1 100644 (file)
@@ -19,8 +19,8 @@
 
 #include "new_string.h"
 
-extern string buffer_to_string(void);
-extern void clear_buffer(void);
-extern void append_buffer(char *);
+extern string buffer_to_string();
+extern void clear_buffer();
+extern void append_buffer();
 
 #endif
index 2f3c433d4ca113c9febd9b217ee9681757b6210d..f14e600d8ca6a87bb4057acc6c1131e48f0c0ff1 100644 (file)
@@ -29,15 +29,15 @@ static const char rcsid_character_class_c[] = "$Id$";
 static character_class cache;
 
 /* character_class */
-char *
-string_to_character_class(string str)
+char * string_to_character_class(str)
+     string str;
 {
     int i;
 
     (void) memset(cache, 0, sizeof(cache));
 
     for (i=0; i<strlen(str); i++)
-       cache[(int)str[i]] = 1;
+      cache[str[i]] = 1;
 
     return(cache);
 }
index 050b282e0ffb8873419ba5a87a4e6a4798cb6e69..1ead477b7f3c70125bd20173132ba2da588ae0eb 100644 (file)
@@ -23,6 +23,6 @@
 
 typedef char character_class[NUMBER_OF_CHARACTERS];
 
-extern /* character_class */ char * string_to_character_class(string);
+extern /* character_class */ char * string_to_character_class();
 
 #endif
index f6a3c742d3c59d95d927bf3b339977b5901044f9..c30d73f2858b3e5264d627286a081011962cfe00 100644 (file)
@@ -66,8 +66,8 @@ static const char rcsid_dictionary_c[] = "$Id$";
  *                 that size is a prime number.
  */
 
-TYPE_T_dictionary
-TYPE_T_dictionary_Create(int size)
+TYPE_T_dictionary TYPE_T_dictionary_Create(size)
+     int size;
 {
     int i;
     TYPE_T_dictionary result;
@@ -94,8 +94,8 @@ TYPE_T_dictionary_Create(int size)
  *                 TYPE_T_dictionary_Enumerate.
  */
 
-void
-TYPE_T_dictionary_Destroy(TYPE_T_dictionary d)
+void TYPE_T_dictionary_Destroy(d)
+     TYPE_T_dictionary d;
 {
     int i;
     TYPE_T_dictionary_binding *binding_ptr, *new_binding_ptr;
@@ -124,8 +124,9 @@ TYPE_T_dictionary_Destroy(TYPE_T_dictionary d)
  *                 writable by proc.
  */
 
-void TYPE_T_dictionary_Enumerate(TYPE_T_dictionary d,
-                                void (*proc)(TYPE_T_dictionary_binding *))
+void TYPE_T_dictionary_Enumerate(d, proc)
+     TYPE_T_dictionary d;
+     void (*proc)(/* TYPE_T_dictionary_binding *b */);
 {
     int i;
     TYPE_T_dictionary_binding *binding_ptr;
@@ -148,8 +149,8 @@ void TYPE_T_dictionary_Enumerate(TYPE_T_dictionary d,
  *                 keys over the table's slots.
  */
 
-static unsigned int
-dictionary__hash(char *s)
+static unsigned int dictionary__hash(s)
+     char *s;
 {
     unsigned int result = 0;
 
@@ -173,9 +174,9 @@ dictionary__hash(char *s)
  *                 Note the access restrictions on bindings...
  */
 
-TYPE_T_dictionary_binding *
-TYPE_T_dictionary_Lookup(TYPE_T_dictionary d,
-                        char *key)
+TYPE_T_dictionary_binding *TYPE_T_dictionary_Lookup(d, key)
+     TYPE_T_dictionary d;
+     char *key;
 {
     TYPE_T_dictionary_binding *binding_ptr;
 
@@ -205,10 +206,10 @@ TYPE_T_dictionary_Lookup(TYPE_T_dictionary d,
  *                 in this case.
  */
 
-TYPE_T_dictionary_binding *
-TYPE_T_dictionary_Define(TYPE_T_dictionary d,
-                        char *key,
-                        int *already_existed)
+TYPE_T_dictionary_binding *TYPE_T_dictionary_Define(d, key, already_existed)
+     TYPE_T_dictionary d;
+     char *key;
+     int *already_existed;
 {
     TYPE_T_dictionary_binding **ptr_to_the_slot, *binding_ptr;
 
@@ -244,8 +245,9 @@ TYPE_T_dictionary_Define(TYPE_T_dictionary d,
  *                 before making this call.
  */
 
-void TYPE_T_dictionary_Delete(TYPE_T_dictionary d,
-                             TYPE_T_dictionary_binding *b)
+void TYPE_T_dictionary_Delete(d, b)
+     TYPE_T_dictionary d;
+     TYPE_T_dictionary_binding *b;
 {
     TYPE_T_dictionary_binding **ptr_to_binding_ptr;
 
index d3f77be9e06f476251858481a3914ffb79c8379b..b9d9312345c2159690170e4e9cc0af683dc079fb 100644 (file)
@@ -37,7 +37,7 @@ typedef struct _TYPE_T_dictionary {                /* PRIVATE */
  *                 that size is a prime number.
  */
 
-extern TYPE_T_dictionary TYPE_T_dictionary_Create(int);
+extern TYPE_T_dictionary TYPE_T_dictionary_Create(/* int size */);
 
 /*
  *    void TYPE_T_dictionary_Destroy(TYPE_T_dictionary d):
@@ -50,11 +50,10 @@ extern TYPE_T_dictionary TYPE_T_dictionary_Create(int);
  *                 TYPE_T_dictionary_Enumerate.
  */
 
-extern void TYPE_T_dictionary_Destroy(TYPE_T_dictionary);
+extern void TYPE_T_dictionary_Destroy(/* TYPE_T_dictionary d */);
 
 /*
- *    void TYPE_T_dictionary_Enumerate(TYPE_T_dictionary d;
- *                                     void (*proc)(TYPE_T_dictionary_binding *b)):
+ *    void TYPE_T_dictionary_Enumerate(TYPE_T_dictionary d; void (*proc)()):
  *        Requires: proc is a void procedure taking 1 argument, a
  *                  TYPE_T_dictionary_binding pointer, which does not
  *                  make any calls using dictionary d.
@@ -64,7 +63,8 @@ extern void TYPE_T_dictionary_Destroy(TYPE_T_dictionary);
  *                 writable by proc.
  */
 
-extern void TYPE_T_dictionary_Enumerate(TYPE_T_dictionary, void (*)(TYPE_T_dictionary_binding *));
+extern void TYPE_T_dictionary_Enumerate(/* TYPE_T_dictionary d, 
+                                          void (*proc)() */);
 
 /*
  *    TYPE_T_dictionary_binding *TYPE_T_dictionary_Lookup(TYPE_T_dictionary d,
@@ -74,8 +74,7 @@ extern void TYPE_T_dictionary_Enumerate(TYPE_T_dictionary, void (*)(TYPE_T_dicti
  *                 Note the access restrictions on bindings...
  */
 
-extern TYPE_T_dictionary_binding *TYPE_T_dictionary_Lookup(TYPE_T_dictionary,
-                                                          char *);
+extern TYPE_T_dictionary_binding *TYPE_T_dictionary_Lookup(/* d, key */);
 
 /*
  *    TYPE_T_dictionary_binding *TYPE_T_dictionary_Define(TYPE_T_dictionary d,
@@ -93,8 +92,7 @@ extern TYPE_T_dictionary_binding *TYPE_T_dictionary_Lookup(TYPE_T_dictionary,
  *                 in this case.
  */
 
-extern TYPE_T_dictionary_binding *TYPE_T_dictionary_Define(TYPE_T_dictionary,
-                                                          char *, int *);
+extern TYPE_T_dictionary_binding *TYPE_T_dictionary_Define();
 
 /*
  *    void TYPE_T_dictionary_Delete(TYPE_T_dictionary d,
@@ -106,7 +104,6 @@ extern TYPE_T_dictionary_binding *TYPE_T_dictionary_Define(TYPE_T_dictionary,
  *                 before making this call.
  */
 
-extern void TYPE_T_dictionary_Delete(TYPE_T_dictionary,
-                                    TYPE_T_dictionary_binding *);
+extern void TYPE_T_dictionary_Delete();
 
 #endif
index 33c4140f335f10706d403b3563876718e5d4d032..0bf8d1c78d5cfb1195142deed561eae7da4f85bf 100644 (file)
@@ -33,7 +33,6 @@ static const char rcsid_eval_c[] = "$Id$";
 #include "port.h"
 #include "buffer.h"
 #include "regexp.h"
-#include "formatter.h"
 #include "text_operations.h"
 #include "zwgc.h"
 #include "variables.h"
@@ -66,8 +65,8 @@ static const char rcsid_eval_c[] = "$Id$";
  *                eventually.
  */
 
-static string
-bool_to_string(int bool)
+static string bool_to_string(bool)
+     int bool;
 {
     return(bool ? string_Copy("TRUE") : string_Copy("FALSE"));
 }
@@ -80,8 +79,8 @@ bool_to_string(int bool)
  *                 NULL is defined to have the boolean value true.
  */
 
-int
-eval_bool_expr(Node *expr)
+int eval_bool_expr(expr)
+     Node *expr;
 {
     string temp;
     int result;
@@ -111,14 +110,15 @@ eval_bool_expr(Node *expr)
  *                 eventually.
  */
 
-string
-eval_expr(Node *expr)
+string eval_expr(expr)
+     Node *expr;
 {
     int opcode = expr->opcode;
     int bool_result;
     string first, second;
     char *result;
     string *text_ptr;
+    char *getenv();           /* UNIX get environment variable function */
 
     /*
      * Dispatch based on the opcode of the top node in the expression:
index 427f713c26174083e330842acebf278649be84f8..d664794bf898f7cc1a6fc9999cb1c86eb103bd2f 100644 (file)
@@ -28,7 +28,7 @@
  *                 eventually.
  */
 
-extern string eval_expr(Node *);
+extern string eval_expr();
 
 /*
  *    int eval_bool_expr(Node *expr)
@@ -38,6 +38,6 @@ extern string eval_expr(Node *);
  *                 NULL is defined to have the boolean value true.
  */
 
-extern int eval_bool_expr(Node *);
+extern int eval_bool_expr();
 
 #endif
index f24bcb83aa6d3f1cc6087cd07cefb26ccc5e8fe8..1bf8f724908fcfa5d7fbdbcc3ac0cfada63be623 100644 (file)
@@ -27,16 +27,15 @@ static const char rcsid_exec_c[] = "$Id$";
 
 #include <zephyr/zephyr.h>
 #include "new_memory.h"
-#include "node.h"
 #include "exec.h"
 #include "eval.h"
+#include "node.h"
 #include "buffer.h"
 #include "port.h"
 #include "variables.h"
 #include "notice.h"
 
-static int exec_subtree(Node *);
-static int exec_fields(Node *);
+static int exec_subtree(), exec_fields();
 
 /****************************************************************************/
 /*                                                                          */
@@ -44,8 +43,8 @@ static int exec_fields(Node *);
 /*                                                                          */
 /****************************************************************************/
 
-static string
-eval_exprlist_to_string(Node *exprlist)
+static string eval_exprlist_to_string(exprlist)
+     Node *exprlist;
 {
     string result = string_Copy("");
     string temp;
@@ -65,8 +64,8 @@ eval_exprlist_to_string(Node *exprlist)
     return(result);
 }
 
-static char **
-eval_exprlist_to_args(Node *exprlist)
+static char **eval_exprlist_to_args(exprlist)
+     Node *exprlist;
 {
     char **result = (char **)malloc(sizeof(char *));
     int argc = 0;
@@ -81,8 +80,8 @@ eval_exprlist_to_args(Node *exprlist)
     return(result);
 }
 
-static void
-free_args(char **args)
+static void free_args(args)
+     char **args;
 {
     char **p;
 
@@ -104,28 +103,28 @@ free_args(char **args)
 #define  EXIT      2
 
 /*ARGSUSED*/
-static int
-exec_noop(Node *node)
+static int exec_noop(node)
+     Node *node;
 {
     return(NOBREAK);
 }
 
 /*ARGSUSED*/
-static int
-exec_break(Node *node)
+static int exec_break(node)
+     Node *node;
 {
     return(BREAK);
 }
 
 /*ARGSUSED*/
-static int
-exec_exit(Node *node)
+static int exec_exit(node)
+     Node *node;
 {
     return(EXIT);
 }
 
-static int
-exec_set(Node *node)
+static int exec_set(node)
+     Node *node;
 {
     var_set_variable_then_free_value(node->d.nodes.first->d.string_constant,
                                     eval_expr(node->d.nodes.second));
@@ -133,8 +132,8 @@ exec_set(Node *node)
     return(NOBREAK);
 }
 
-static int
-exec_execport(Node *node)
+static int exec_execport(node)
+     Node *node;
 {
     string name = eval_expr(node->d.nodes.first);
     char **argv = eval_exprlist_to_args(node->d.nodes.second);
@@ -146,8 +145,8 @@ exec_execport(Node *node)
     return(NOBREAK);
 }
 
-static int
-exec_appendport(Node *node)
+static int exec_appendport(node)
+     Node *node;
 {
     string name, filename;
 
@@ -161,8 +160,8 @@ exec_appendport(Node *node)
     return(NOBREAK);
 }
 
-static int
-exec_inputport(Node *node)
+static int exec_inputport(node)
+     Node *node;
 {
     string name, filename;
 
@@ -176,8 +175,8 @@ exec_inputport(Node *node)
     return(NOBREAK);
 }
 
-static int
-exec_outputport(Node *node)
+static int exec_outputport(node)
+     Node *node;
 {
     string name, filename;
 
@@ -191,8 +190,8 @@ exec_outputport(Node *node)
     return(NOBREAK);
 }
 
-static int
-exec_closeinput(Node *node)
+static int exec_closeinput(node)
+     Node *node;
 {
     string name;
 
@@ -203,8 +202,8 @@ exec_closeinput(Node *node)
     return(NOBREAK);
 }
 
-static int
-exec_closeoutput(Node *node)
+static int exec_closeoutput(node)
+     Node *node;
 {
     string name;
 
@@ -215,8 +214,8 @@ exec_closeoutput(Node *node)
     return(NOBREAK);
 }
 
-static int
-exec_closeport(Node *node)
+static int exec_closeport(node)
+     Node *node;
 {
     string name;
 
@@ -228,8 +227,8 @@ exec_closeport(Node *node)
     return(NOBREAK);
 }
 
-static int
-exec_put(Node *node)
+static int exec_put(node)
+     Node *node;
 {
     string name, temp;
 
@@ -250,8 +249,8 @@ exec_put(Node *node)
     return(NOBREAK);
 }
 
-static int
-exec_print(Node *node)
+static int exec_print(node)
+     Node *node;
 {
     string temp;
 
@@ -263,16 +262,16 @@ exec_print(Node *node)
 }
 
 /*ARGSUSED*/
-static int
-exec_clearbuf(Node *node)
+static int exec_clearbuf(node)
+     Node *node;
 {
     clear_buffer();
 
     return(NOBREAK);
 }
 
-static int
-exec_case(Node *node)
+static int exec_case(node)
+     Node *node;
 {
     string constant,temp;
     Node *match, *cond;
@@ -301,8 +300,8 @@ exec_case(Node *node)
     return(NOBREAK);
 }
 
-static int
-exec_while(Node *node)
+static int exec_while(node)
+     Node *node;
 {
     int continue_code = NOBREAK;
 
@@ -318,8 +317,8 @@ exec_while(Node *node)
     return(continue_code);
 }
 
-static int
-exec_if(Node *node)
+static int exec_if(node)
+     Node *node;
 {
     Node *conds;
 
@@ -330,8 +329,8 @@ exec_if(Node *node)
     return(NOBREAK);
 }
 
-static int
-exec_exec(Node *node)
+static int exec_exec(node)
+     Node *node;
 {
     int pid;
     char **argv = eval_exprlist_to_args(node->d.nodes.first);
@@ -352,7 +351,7 @@ exec_exec(Node *node)
 }
 
 static struct _Opstuff {
-    int (*exec)(Node *);
+    int (*exec)();
 } const opstuff[] = {
     { exec_noop },                         /* string_constant */
     { exec_noop },                         /* varref */
@@ -413,8 +412,8 @@ static struct _Opstuff {
     { exec_noop },                           /* default */
 };
 
-static int
-exec_subtree(Node *node)
+static int exec_subtree(node)
+     Node *node;
 {
     int retval = NOBREAK;
     
@@ -433,8 +432,8 @@ static char *notice_fields;
 static int notice_fields_length = 0;
 static int number_of_fields = 0;
 
-static int
-exec_fields(Node *node)
+static int exec_fields(node)
+     Node *node;
 {
     for (node=node->d.nodes.first; node; node=node->next) {
        var_set_variable_then_free_value(node->d.string_constant,
@@ -449,9 +448,9 @@ exec_fields(Node *node)
     return(NOBREAK);
 }
 
-void
-exec_process_packet(Node *program,
-                   ZNotice_t *notice)
+void exec_process_packet(program, notice)
+     Node *program;
+     ZNotice_t *notice;
 {
     notice_fields = notice->z_message;
     notice_fields_length = notice->z_message_len;
index db691ddd61683dc7e5151867ac03731885a8e31b..7eebc20e17e45a8635879b2c08130477325133ee 100644 (file)
@@ -17,6 +17,6 @@
 #ifndef exec_MODULE
 #define exec_MODULE
 
-extern void exec_process_packet(Node *, ZNotice_t *);
+extern void exec_process_packet();
 
 #endif
index b448e5cfa787d910e37a3ef528eb514d3025e1d1..1f3fc62bb768a7238c8b12d51f91357718d2fc6f 100644 (file)
@@ -38,13 +38,13 @@ static const char rcsid_file_c[] = "$Id$";
  *               if necessary.
  */
 
-char *get_home_directory(void)
+char *get_home_directory()
 {
     char *result;
+    char *getenv();
     struct passwd *passwd_entry;
 
-    result = getenv("HOME");
-    if (result)
+    if (result = getenv("HOME"))
       return(result);
 
     if (!(passwd_entry = getpwuid(getuid())))
@@ -57,9 +57,10 @@ char *get_home_directory(void)
  *
  */
 
-FILE *locate_file(char *override_filename,
-                 char *home_dir_filename,
-                 char *fallback_filename)
+FILE *locate_file(override_filename, home_dir_filename, fallback_filename)
+     char *override_filename;
+     char *home_dir_filename;
+     char *fallback_filename;
 {
     char *filename;
     FILE *result;
@@ -81,8 +82,7 @@ FILE *locate_file(char *override_filename,
     }
 
     if (home_dir_filename) {
-       filename = get_home_directory();
-       if (filename) {
+       if (filename = get_home_directory()) {
            filename = string_Concat(filename, "/");
            filename = string_Concat2(filename, home_dir_filename);
            result = fopen(filename, "r");
index 3f185bf091473ad27b4654860f2b90d740302017..b0aff1f92345f18e8d99720fa7ae952a8237cbb6 100644 (file)
@@ -19,6 +19,6 @@
 
 #include <stdio.h>
 
-extern FILE *locate_file(char *, char *, char *);
+extern FILE *locate_file();
 
 #endif
index f5d3c876f617aecba84bda7419e6f596709f87a0..c900c9fa95cc11fd9d0b51856f4e255ca48fc05a 100644 (file)
@@ -30,8 +30,7 @@ static const char rcsid_formatter_c[] = "$Id$";
 #define const
 #endif
 
-static int pure_text_length(char *, char);
-static int env_length(char *);
+static int pure_text_length(), env_length();
 
 #ifdef notdef
 static character_class atsign_set = { /* '@' = 0x40 */
@@ -172,17 +171,17 @@ static char brackets[]="()<>[]{}@";
 static char *openbracket[]={"@<","@<","@[","@[","@{","@{","@(","@(","@("};
 static char *closebracket[]={">",">","]","]","}","}",")",")",")"};
 
-static int
-not_contains(string str,
-            const character_class set)
+static int not_contains(str, set)
+     string str;
+     const character_class set;
 {
-   while (*str && ! set[(int)*str]) str++;
+   while (*str && ! set[*str]) str++;
    return (! *str);
 }
 
-static int
-pure_text_length(char *text,
-                char terminator)
+static int pure_text_length(text,terminator)
+     char *text;
+     char terminator;
 {
    int len=0;
 
@@ -206,8 +205,8 @@ pure_text_length(char *text,
    }
 }
 
-static char
-otherside(char opener)
+static char otherside(opener)
+char opener;
 {
    switch (opener) {
     case '(':
@@ -223,14 +222,14 @@ otherside(char opener)
 #ifdef DEBUG
    abort();
 #endif
-   return 0;
 }
 
 /* the char * that str points to is free'd by this function.
  * if you want to keep it, save it yourself
  */
-string
-verbatim(string str, int bracketsonly)
+string verbatim(str, bracketsonly)
+     string str;
+     int bracketsonly;
 {
    char *temp,*temp2;
    int bracketnum,len;
@@ -307,8 +306,8 @@ verbatim(string str, int bracketsonly)
    or the default terminator \0.  The text will not be modified,
    and @@ will be counted twice */
 
-string
-protect(string str)
+string protect(str)
+     string str;
 {
    string temp,temp2,temp3;
    int len,templen;
@@ -329,7 +328,7 @@ protect(string str)
         temp[templen-2] = *str++;
         char_stack_pop(chs);
         temp[templen-1] = '\0';
-      } else if ((len = pure_text_length(str,tos))) {
+      } else if (len = pure_text_length(str,tos)) {
         if (tos) {
            /* if the block is text in an environment, just copy it */
 
@@ -376,8 +375,8 @@ protect(string str)
 
 /* str points to a string.  return value is another string
    which is the original with all styles removed. */
-string
-stylestrip(string str)
+string stylestrip(str)
+     string str;
 {
     int templen = 0, otherchar;
     char *temp = (char *) malloc(string_Length(str) + 1);
@@ -419,8 +418,8 @@ stylestrip(string str)
     return(temp);
 }
 
-void
-free_desc(desctype *desc)
+void free_desc(desc)
+     desctype *desc;
 {
     desctype *next_desc;
 
@@ -435,8 +434,8 @@ free_desc(desctype *desc)
 /* text points to beginning of possible env name.  return value is
    length of env name, not including @ or opener, or -1 if not a
    possible env name. */
-static int
-env_length(char *text)
+static int env_length(text)
+     char *text;
 {
    int len=0;
 
@@ -455,9 +454,9 @@ env_length(char *text)
    length of string, up to but not including the passed terminator
    or the default terminators \0 \n @.  This can modify text, and 0
    is a valid return value. */
-static int
-text_length(char *text,
-           char terminator)
+static int text_length(text,terminator)
+     char *text;
+     char terminator;
 {
    int len=0;
 
@@ -483,10 +482,9 @@ text_length(char *text,
 /* parses str into a desc linked list.  Returns number of strings and
    newlines in *pstr and *pnl */
 
-desctype *
-disp_get_cmds(char *str,
-             int *pstr,
-             int *pnl)
+desctype *disp_get_cmds(str,pstr,pnl)
+char *str;
+int *pstr,*pnl;
 {
    desctype *desc,*here;
    int len;
@@ -510,8 +508,8 @@ disp_get_cmds(char *str,
         terminator = char_stack_top(terminators);
         char_stack_pop(terminators);
         curstr++;
-      } else if ((len=text_length(curstr, terminator))) { /* if there is a text
-                                                            block here */
+      } else if (len=text_length(curstr,terminator)) { /* if there is a text
+                                                         block here */
         here->code=DT_STR;
         here->str=curstr;
         here->len=len;
index d2cf0f061eb6c4b0e52aa968e59b5fafd9c439e3..0a76687e8b2c77c3e9b03117e2d2ceded0c301cd 100644 (file)
@@ -14,8 +14,6 @@
 
 #include <zephyr/mit-copyright.h>
 
-#include "new_string.h"
-
 #ifndef formatter_MODULE
 #define formatter_MODULE
 
@@ -34,10 +32,7 @@ typedef struct _desctype {
                           ENV, STR, END.  Undefined for EOF */
 } desctype;
 
-extern desctype *disp_get_cmds(char *, int *, int *);
-extern void free_desc(desctype *);
+extern desctype *disp_get_cmds();
+extern void free_desc();
 
-extern string protect(string);
-extern string verbatim(string, int);
-extern string stylestrip(string);
 #endif
index e821eb9eb5a224249c51def7354662be1f878be6..16e04e61605215eefd9c76038d019e95b178728f 100644 (file)
@@ -64,8 +64,7 @@ static FILE *input_file;
 
 static int pushback = -1;
 
-static char
-input(void)
+static char input()
 {
     int c;
 
@@ -86,8 +85,8 @@ input(void)
     return(c);
 }
 
-static void
-unput(int c)
+static void unput(c)
+     int c;
 {
 #ifdef DEBUG
     if (pushback != -1) {
@@ -172,8 +171,8 @@ static struct keyword_info keywords[] =   {
  *            a file.  Resets current line # to 1.
  */
 
-void
-lex_open(FILE *file)
+void lex_open(file)
+     FILE *file;
 {
     /*
      * Initialize I/O:
@@ -220,8 +219,7 @@ lex_open(FILE *file)
 
 #define  is_octal_digit(c)           (((c)>='0') && ((c)<='7'))
 
-static char
-eat_escape_code(void)
+static char eat_escape_code()
 {
     int c, coded_char;
 
@@ -271,8 +269,8 @@ eat_escape_code(void)
  *              string we are eating started on.
  */
 
-static char *
-eat_string(int starting_line)
+static char *eat_string(starting_line)
+     int starting_line;
 {
     int c;
     char buffer[500];
@@ -345,8 +343,8 @@ eat_string(int starting_line)
  *    instead of doing the above, we just eat the "endshow" & return 0.
  */
 
-static char *
-eat_show_line(int test_for_endshow)
+static char *eat_show_line(test_for_endshow)
+     int test_for_endshow;
 {
     int c;
     int saw_escape_code = 0;
@@ -410,8 +408,8 @@ eat_show_line(int test_for_endshow)
  *                   messages.
  */
 
-static char *
-eat_til_endshow(int start_line_no)
+static char *eat_til_endshow(start_line_no)
+     int start_line_no;
 {
     register int c;
     string text_so_far = string_Copy("");
@@ -455,8 +453,7 @@ eat_til_endshow(int start_line_no)
  *               returned.
  */
 
-static int
-handle_show(void)
+static int handle_show()
 {
     int c;
     int start_line_no = yylineno;
@@ -470,8 +467,7 @@ handle_show(void)
     if (c!='\n')
       unput(c);
 
-    yylval.text = eat_til_endshow(start_line_no);
-    if (yylval.text)
+    if (yylval.text = eat_til_endshow(start_line_no))
       return(SHOW);
     else
       return(ERROR);
@@ -487,7 +483,7 @@ handle_show(void)
  * yylex - performs as per. the yacc manual's requirements
  */
 
-int yylex(void)
+int yylex()
 {
     register int c, last_char;
     register char *ptr;
@@ -657,8 +653,7 @@ int yylex(void)
             * Handle constant strings:
             */
          case '"':
-           yylval.text = eat_string(yylineno);
-           if (yylval.text)
+           if (yylval.text = eat_string(yylineno))
              return(STRING);
            else
              return(ERROR);
index 27c3e75fc9422fccef266dd648a00cf4674674c9..fd76e8f3d263263c6c6f03b1165a94200f779787 100644 (file)
@@ -48,12 +48,12 @@ extern int yylineno;
  *            a file.  Resets current line # to 1.
  */
 
-extern void lex_open(FILE *);
+extern void lex_open(/* FILE *file */);
 
 /*
  * yylex - performs as per. the yacc manual's requirements
  */
 
-extern int yylex(void);
+extern int yylex();
 
 #endif
index 8584eca7b172f74c92ed4566acb7f8e6f51acb87..52b9e7a3741bc22df86cf25feceadd3bef0738f6 100644 (file)
@@ -40,13 +40,10 @@ static const char rcsid_main_c[] = "$Id$";
 #include "variables.h"
 #include "main.h"
 
-void notice_handler(ZNotice_t *);
-static void process_notice(ZNotice_t *, char *);
-static void setup_signals(int);
-static void detach(void);
-static void signal_exit(int);
+extern void notice_handler();
+static void process_notice(), setup_signals(), detach(), signal_exit();
 #ifdef HAVE_ARES
-static void notice_callback(void *, int, struct hostent *);
+static void notice_callback();
 #endif
 
 /*
@@ -108,13 +105,11 @@ static struct _Node *program = NULL;
  * <<<>>>
  */
 
-static void
-fake_startup_packet(void)
+static void fake_startup_packet()
 {
     ZNotice_t notice;
     struct timezone tz;
     char msgbuf[BUFSIZ];
-    extern void Z_gettimeofday(struct _ZTimeval *, struct timezone *);
 
     var_set_variable("version", zwgc_version_string);
 
@@ -127,7 +122,7 @@ fake_startup_packet(void)
     notice.z_default_format = "Zwgc mark II version $version now running...\n";
     notice.z_recipient = "";
     notice.z_sender = "ZWGC";
-    Z_gettimeofday(&notice.z_time, &tz);
+    gettimeofday(&notice.z_time,&tz);
     notice.z_port = 0;
     notice.z_kind = ACKED;
     notice.z_auth = ZAUTH_YES;
@@ -139,8 +134,7 @@ fake_startup_packet(void)
     process_notice(&notice, NULL);
 }
 
-static void
-read_in_description_file(void)
+static void read_in_description_file()
 {
     FILE *input_file;
     char defdesc[128];
@@ -169,8 +163,7 @@ read_in_description_file(void)
  *                 program with error code 1.
  */
 
-void
-usage(void)
+void usage()
 {
 #ifdef DEBUG
     fprintf(stderr, "\
@@ -192,8 +185,7 @@ zwgc: usage: zwgc [-f <filename>] [-subfile <filename>]\n\
  * <<<>>>
  */
 
-static void
-run_initprogs(void)
+static void run_initprogs()
 {
     /*
      * This code stolen from old zwgc: yuck.  Clean up & fix.  <<<>>>
@@ -222,9 +214,9 @@ run_initprogs(void)
  * main -- the program entry point.  Does parsing & top level control.
  */
 
-int
-main(int argc,
-     char **argv)
+int main(argc, argv)
+     int argc;
+     char **argv;
 {
     char **new;
     register char **current;
@@ -329,8 +321,8 @@ main(int argc,
 #define  USER_SUPPRESS     "SUPPRESS"
 #define  USER_UNSUPPRESS   "UNSUPPRESS"
 
-void
-notice_handler(ZNotice_t *notice)
+void notice_handler(notice)
+     ZNotice_t *notice;
 {
     struct hostent *fromhost = NULL;
 
@@ -351,10 +343,10 @@ notice_handler(ZNotice_t *notice)
 }
 
 #ifdef HAVE_ARES
-static void
-notice_callback(void *arg,
-               int status,
-               struct hostent *fromhost)
+static void notice_callback(arg, status, fromhost)
+     void *arg;
+     int status;
+     struct hostent *fromhost;
 {
     ZNotice_t *notice = (ZNotice_t *) arg;
 
@@ -364,16 +356,15 @@ notice_callback(void *arg,
 }
 #endif
 
-static void
-process_notice(ZNotice_t *notice,
-              char *hostname)
+static void process_notice(notice, hostname)
+     ZNotice_t *notice;
+     char *hostname;
 {
     char *control_opcode;
 
     dprintf("Got a message\n");
 
-    control_opcode = decode_notice(notice, hostname);
-    if (control_opcode) {
+    if (control_opcode = decode_notice(notice, hostname)) {
 #ifdef DEBUG
        printf("got control opcode <%s>.\n", control_opcode);
 #endif
@@ -409,7 +400,7 @@ process_notice(ZNotice_t *notice,
            free(instance);
            free(recipient);
        } else if (!strcasecmp(control_opcode, USER_EXIT)) {
-           signal_exit(0);
+           signal_exit();
        } else
          printf("zwgc: unknown control opcode %s.\n", control_opcode);
 
@@ -443,22 +434,21 @@ process_notice(ZNotice_t *notice,
  *
  */
 
-static void
-signal_exit(int ignored)
+static void signal_exit()
 {
     mux_end_loop_p = 1;
 }
 
 /* clean up ALL the waiting children, in case we get hit with
    multiple SIGCHLD's at once, and don't process in time. */
-static RETSIGTYPE
-signal_child(int ignored)
+static RETSIGTYPE signal_child()
 {
 #ifdef HAVE_WAITPID
   int status;
 #else
   union wait status;
 #endif
+  extern int errno;
   int pid, old_errno = errno;
 
   do {
@@ -472,14 +462,13 @@ signal_child(int ignored)
 }
 
 /* rewrite the wgfile in case it has gone away */
-static RETSIGTYPE
-signal_usr1(int ignored)
+static RETSIGTYPE signal_usr1()
 {
     write_wgfile();
 }
 
-static void
-setup_signals(int dofork)
+static void setup_signals(dofork)
+     int dofork;
 {
 #ifdef _POSIX_VERSION
     struct sigaction sa;
@@ -536,8 +525,7 @@ setup_signals(int dofork)
 
 /* detach() taken from old zwgc, with lots of stuff ripped out */
 
-static void
-detach(void)
+static void detach()
 {
   /* detach from terminal and fork. */
   register int i;
@@ -550,7 +538,6 @@ detach(void)
    * of finding the session leader; otherwise use the process group of
    * the parent process, which is a good guess. */
 #if defined(HAVE_GETSID)
-
   setpgid(0, getsid(0));
 #elif defined(HAVE_GETPGID)
   setpgid(0, getpgid(getppid()));
@@ -559,8 +546,7 @@ detach(void)
 #endif
 
   /* fork off and let parent exit... */
-  i = fork();
-  if (i) {
+  if (i = fork()) {
       if (i < 0) {
          perror("zwgc: cannot fork, aborting:");
          exit(1);
index 3d6ea05b53c198e265dd6d7114d6def62cd92a55..7b6405dfbd4d4efc4537d84ebba2378406481f72 100644 (file)
@@ -33,7 +33,7 @@ extern char *location_override;
  *                 program with error code 1.
  */
 
-extern void usage(void);
+extern void usage();
 
 /* USRDESC points to a file (relative to user's homedir) which has a user's
    description file */
index 341e6e679c11ccfee2993fc5a98baa1a9a8f166f..0e37ebc274b28ea607038d92a9470452a7012d17 100644 (file)
@@ -62,10 +62,10 @@ static int max_source = -1;
  */
 
 static fd_set input_sources;
-static void (*input_handler[MAX_SOURCES])(void *);
+static void (*input_handler[MAX_SOURCES])();
 static pointer input_handler_arg[MAX_SOURCES];
 
-static int check_tty(void);
+static int check_tty();
 
 /*
  *    void mux_init()
@@ -74,8 +74,7 @@ static int check_tty(void);
  *                 any other mux call.
  */
 
-void
-mux_init(void)
+void mux_init()
 {
     int i;
 
@@ -97,10 +96,10 @@ mux_init(void)
  *                 argument arg.
  */
 
-void
-mux_add_input_source(int descriptor,
-                         void (*handler)(void *),
-                         pointer arg)
+void mux_add_input_source(descriptor, handler, arg)
+     int descriptor;
+     void (*handler)();
+     pointer arg;
 {
 #ifdef DEBUG
     if(descriptor < 0 || descriptor >= MAX_SOURCES)
@@ -129,8 +128,7 @@ mux_add_input_source(int descriptor,
  *                 true, we return.
  */
 
-void
-mux_loop(void)
+void mux_loop()
 {
     int i, nfds;
     fd_set inputs, outputs;
@@ -205,8 +203,7 @@ mux_loop(void)
     }
 }
 
-static int
-check_tty(void)
+static int check_tty()
 {
     register int result;
     int pgrp;
index 230f9df6241e07a2923431de5f938c188790971b..3654a3fb32f286d4ca1c67decf1ce734457f655d 100644 (file)
@@ -38,7 +38,7 @@ extern int mux_end_loop_p;
  *                 any other mux call.
  */
 
-extern void mux_init(void);
+extern void mux_init();
 
 /*
  *    void mux_add_input_source(int descriptior; void (*handler)(); void *arg)
@@ -50,7 +50,7 @@ extern void mux_init(void);
  *                 argument arg.
  */
 
-extern void mux_add_input_source(int, void (*)(void *), void *);
+extern void mux_add_input_source();
 
 /*
  *    void mux_loop()
@@ -67,6 +67,6 @@ extern void mux_add_input_source(int, void (*)(void *), void *);
  *                 true, we return.
  */
 
-extern void mux_loop(void);
+extern void mux_loop();
 
 #endif
index 906a2b900d5c9611cdaf567f62f0579ef6a5bcb9..98aa02bdee6bed81a7c3f838f486f6cb7cfac55f 100644 (file)
@@ -56,7 +56,9 @@ typedef char *string;
  *                 string_Copy("foo").
  */
 
-string string__CreateFromData(char *data, int length)
+string string__CreateFromData(data, length)
+     char *data;
+     int length;
 {
     string result;
 
@@ -77,8 +79,8 @@ string string__CreateFromData(char *data, int length)
  *                 freed eventually.
  */
 
-string
-string__Copy(string s)
+string string__Copy(s)
+     string s;
 {
     int length;
     string result;
@@ -101,9 +103,8 @@ string__Copy(string s)
  *                 returns string_Copy("abcdef").
  */
 
-string
-string__Concat(string a,
-              string b)
+string string__Concat(a, b)
+     string a, b;
 {
     string result;
     int a_length, b_size, result_size;
@@ -132,9 +133,8 @@ string__Concat(string a,
  *                 only faster.  I.e., uses realloc instead of malloc+memcpy.
  */
 
-string
-string__Concat2(string a,
-               string b)
+string string__Concat2(a, b)
+     string a, b;
 {
     int a_length = string_Length(a);
     int b_size = string_Length(b)+1;
@@ -159,8 +159,8 @@ string__Concat2(string a,
  *                 S is returned as a convenience.
  */
 
-string
-string_Downcase(string s)
+string string_Downcase(s)
+     string s;
 {
     char *ptr;
 
@@ -181,8 +181,8 @@ string_Downcase(string s)
  *                 S is returned as a convenience.
  */
 
-string
-string_Upcase(string s)
+string string_Upcase(s)
+     string s;
 {
     char *ptr;
 
index ea1010559706a0168c37b4007973e3733f96e959..2ad7851e4d20b6b009f210727c575f39de7afcf9 100644 (file)
@@ -51,7 +51,7 @@ typedef char *string;
  *                 string_Copy("foo").
  */
 
-extern string string__CreateFromData(char *, int);
+extern string string__CreateFromData();
 #ifdef DEBUG_MEMORY
 #define string_CreateFromData(data,length) (set_module(__FILE__,__LINE__),\
                                    string__CreateFromData(data,length))
@@ -65,7 +65,7 @@ extern string string__CreateFromData(char *, int);
  *                 freed eventually.
  */
 
-extern string string__Copy(string);
+extern string string__Copy(/* string s */);
 #ifdef DEBUG_MEMORY
 #define string_Copy(data)  (set_module(__FILE__,__LINE__),\
                            string__Copy(data))
@@ -81,7 +81,7 @@ extern string string__Copy(string);
  *                 returns string_Copy("abcdef").
  */
 
-extern string string__Concat(string, string);
+extern string string__Concat(/* string a, b */);
 #ifdef DEBUG_MEMORY
 #define string_Concat(a,b)  (set_module(__FILE__,__LINE__),\
                             string__Concat(a,b))
@@ -101,7 +101,7 @@ extern string string__Concat(string, string);
  *                 only faster.  I.e., uses realloc instead of malloc+bcopy.
  */
 
-extern string string__Concat2(string, string);
+extern string string__Concat2(/* string a, b */);
 #ifdef DEBUG_MEMORY
 #define string_Concat2(a,b)  (set_module(__FILE__,__LINE__),\
                              string__Concat2(a,b))
@@ -118,7 +118,7 @@ extern string string__Concat2(string, string);
  *                 S is returned as a convenience.
  */
 
-extern string string_Downcase(string);
+extern string string_Downcase();
 
 /*
  *    string string_Upcase(string s):
@@ -129,6 +129,6 @@ extern string string_Downcase(string);
  *                 S is returned as a convenience.
  */
 
-extern string string_Upcase(string);
+extern string string_Upcase();
 
 #endif
index f04225edc408efd0f483db2bfc29417c9fe2a3e3..f3603d36e1ba17736abccb4c472861cfeb2952bb 100644 (file)
@@ -60,8 +60,8 @@ static int last_node_in_current_bunch_used = -1;
  *                 string on the heap when node_DestroyAllNodes is called.
  */
 
-static Node *
-node_create(int opcode)
+static Node *node_create(opcode)
+     int opcode;
 {
     Node *result;
 
@@ -102,8 +102,7 @@ node_create(int opcode)
  *
  */
 
-void
-node_DestroyAllNodes(void)
+void node_DestroyAllNodes()
 {
     struct _bunch_of_nodes *next_bunch;
     int i, last_node_used_in_this_bunch;
@@ -133,9 +132,9 @@ node_DestroyAllNodes(void)
 /*                                                                          */
 /****************************************************************************/
 
-Node *
-node_create_string_constant(int opcode,
-                           string text)
+Node *node_create_string_constant(opcode, text)
+     int opcode;
+     string text;
 {
     Node *n;
 
@@ -144,8 +143,8 @@ node_create_string_constant(int opcode,
     return(n);
 }
 
-Node *
-node_create_noary(int opcode)
+Node *node_create_noary(opcode)
+     int opcode;
 {
     Node *n;
 
@@ -153,9 +152,9 @@ node_create_noary(int opcode)
     return(n);
 }
 
-Node *
-node_create_unary(int opcode,
-                 Node *arg)
+Node *node_create_unary(opcode, arg)
+     int opcode;
+     Node *arg;
 {
     Node *n;
 
@@ -164,10 +163,10 @@ node_create_unary(int opcode,
     return(n);
 }
 
-Node *
-node_create_binary(int opcode,
-                  Node *first_arg,
-                  Node *second_arg)
+Node *node_create_binary(opcode, first_arg, second_arg)
+     int opcode;
+     Node *first_arg;
+     Node *second_arg;
 {
     Node *n;
 
@@ -192,8 +191,8 @@ node_create_binary(int opcode,
  *                 the address of the (previously) last node.
  */
 
-Node *
-reverse_list_of_nodes(Node *list)
+Node *reverse_list_of_nodes(list)
+     Node *list;
 {
     Node *next_node;
     Node *head = NULL;
@@ -221,9 +220,9 @@ reverse_list_of_nodes(Node *list)
 
 #ifdef DEBUG
 
-static void
-print_stuff(Node *node,
-           string format_string)
+static void print_stuff(node, format_string)
+     Node *node;
+     string format_string;
 {
     char c;
 
@@ -312,7 +311,8 @@ static string how_to_print[] = {
     "match %1\n%2",
     "default\n%2" };
 
-void node_display(Node *node)
+void node_display(node)
+     Node *node;
 {
     int opcode = LAST_EXPR_OPCODE + 1;
 
index 556719b68c3c0933a77ec777166ba2a7df7db509..4fdf678f40eca72125160f4ecadf4b2ef3dd51bc 100644 (file)
@@ -100,13 +100,13 @@ typedef struct _Node {
 
 /* Function externs */
 
-extern void node_DestroyAllNodes(void);
+extern void node_DestroyAllNodes();
 
-extern Node *node_create_string_constant(int, string);
+extern Node *node_create_string_constant();
 
-extern Node *node_create_noary(int);
-extern Node *node_create_unary(int, Node *);
-extern Node *node_create_binary(int, Node *, Node *);
+extern Node *node_create_noary();
+extern Node *node_create_unary();
+extern Node *node_create_binary();
 
 /*
  *    Node *reverse_list_of_nodes(Node *list)
@@ -117,10 +117,10 @@ extern Node *node_create_binary(int, Node *, Node *);
  *                 the address of the (previously) last node.
  */
 
-extern Node *reverse_list_of_nodes(Node *);
+extern Node *reverse_list_of_nodes();
 
 #ifdef DEBUG
-extern void node_display(Node *);
+extern void node_display();
 #endif
 
 #endif
index b3a660c9ea40d573c8a3a1983de7c6ae76906ad4..4e09167cd7cc46bbdc3ac70f3a73fffaeb6424e6 100644 (file)
@@ -38,9 +38,9 @@ static const char rcsid_notice_c[] = "$Id$";
  *        Effects: Returns the # of nulls in data[0]..data[length-1]
  */
 
-int
-count_nulls(char *data,
-           int length)
+int count_nulls(data, length)
+     char *data;
+     int length;
 {
     int count = 0;
 
@@ -66,9 +66,9 @@ count_nulls(char *data,
  *                 remain.  (this is the case when *length_p == 0)
  */
 
-string
-get_next_field(char **data_p,
-              int *length_p)
+string get_next_field(data_p, length_p)
+     char **data_p;
+     int *length_p;
 {
     char *data = *data_p;
     int length = *length_p;
@@ -98,9 +98,10 @@ get_next_field(char **data_p,
  *                 "" is returned.
  */
 
-string get_field(char *data,
-                int length,
-                int num)
+string get_field(data, length, num)
+     char *data;
+     int length;
+     int num;
 {
     /*
      * While num>1 and there are fields left, skip a field & decrement num:
@@ -131,9 +132,9 @@ string get_field(char *data,
  *                be freed.
  */
 
-string
-convert_nulls_to_newlines(char *data,
-                         int length)
+string convert_nulls_to_newlines(data, length)
+     char *data;
+     int length;
 {
     char *result, *ptr;
     char c;
@@ -157,8 +158,8 @@ convert_nulls_to_newlines(char *data,
  *                 eventually.
  */
 
-static string
-z_kind_to_ascii(ZNotice_Kind_t z_kind)
+static string z_kind_to_ascii(z_kind)
+     ZNotice_Kind_t z_kind;
 {
     string result;
 
@@ -216,8 +217,8 @@ z_kind_to_ascii(ZNotice_Kind_t z_kind)
  *                 eventually.
  */
 
-static string
-z_auth_to_ascii(int z_auth)
+static string z_auth_to_ascii(z_auth)
+     int z_auth;
 {
     string result;
 
@@ -248,9 +249,9 @@ z_auth_to_ascii(int z_auth)
  *        Effects:
  */
 
-char *
-decode_notice(ZNotice_t *notice,
-             char *hostname)
+char *decode_notice(notice, hostname)
+     ZNotice_t *notice;
+     char *hostname;
 {
     char *temp;
     string time, notyear, year, date_string, time_string;
index ad6635d61a6c3892bba60ca3bd76853fc9597767..7a9faf55861edbc9a3368cb0ae43f4d08ac8cfde 100644 (file)
@@ -17,7 +17,6 @@
 #ifndef notice_MODULE
 #define notice_MODULE
 
-#include <zephyr/zephyr.h>
 #include "new_string.h"
 
 /*
@@ -26,7 +25,7 @@
  *        Effects: Returns the # of nulls in data[0]..data[length-1]
  */
 
-extern int count_nulls(char *, int);
+extern int count_nulls();
 
 /*
  *    string get_next_field(char **data_p, int *length_p)
@@ -43,7 +42,7 @@ extern int count_nulls(char *, int);
  *                 remain.  (this is the case when *length_p == 0)
  */
 
-extern string get_next_field(char **, int *);
+extern string get_next_field();
 
 /*
  *    string get_field(char *data, int length, int num)
@@ -56,7 +55,7 @@ extern string get_next_field(char **, int *);
  *                 "" is returned.
  */
 
-extern string get_field(char *, int, int);
+extern string get_field();
 
 /*
  *    string convert_nulls_to_newlines(data, length)
@@ -67,9 +66,9 @@ extern string get_field(char *, int, int);
  *                be freed.
  */
 
-extern string convert_nulls_to_newlines(char *, int);
+extern string convert_nulls_to_newlines();
 
 
-extern char *decode_notice(ZNotice_t *, char *);
+extern char *decode_notice();
 
 #endif
index 92724ddcc370e9aa2ad174001c4c932645b868f2..8e0d5f67a5b76615f84eaeb851c9d6f5a77ba073 100644 (file)
@@ -31,7 +31,7 @@
  *                 is reported to the user via stderr. 
  */
 
-extern void report_parse_error(char *, int);
+extern void report_parse_error();
 
 /*
  *    struct _Node *parse_file(FILE *input_file)
@@ -49,6 +49,6 @@ extern void report_parse_error(char *, int);
  *                 is closed before this routine returns.
  */
 
-extern struct _Node *parse_file(FILE *);
+extern struct _Node *parse_file();
 
 #endif
index 30f4088d5ca5f679e328f7a84d64b968ac5a42fa..6f539851e0ba264efe174e5fad0482d7d88617a7 100644 (file)
@@ -31,7 +31,7 @@ static const char rcsid_parser_y[] = "$Id$";
 #include "node.h"
 #include "zwgc.h"
 
-static void yyerror(char *);
+static void yyerror();
 
 /*
  * the_program - local variable used to communicate the program's node
@@ -320,9 +320,9 @@ static int error_occured = 0;
  *                 is reported to the user via stderr. 
  */
 
-void
-report_parse_error(char *error_message,
-                  int line_number)
+void report_parse_error(error_message, line_number)
+     char *error_message;
+     int line_number;
 {
     if (error_occured)
       return;
@@ -338,7 +338,8 @@ report_parse_error(char *error_message,
  *            stack overflow errors.
  */
  
-static void yyerror(char *message)
+static void yyerror(message)
+     char *message;
 {
     report_parse_error(message, yylineno);
 }
@@ -359,8 +360,8 @@ static void yyerror(char *message)
  *                 is closed before this routine returns.
  */
 
-struct _Node *
-parse_file(FILE *input_file)
+struct _Node *parse_file(input_file)
+     FILE *input_file;
 {
     the_program = NULL;
     error_occured = 0;
index 3d73a696477bb50cf74e847bc1fa0acc97000b34..0244dac5a6604a8427a22a7fb10fea07d4b7cf4a 100644 (file)
@@ -37,10 +37,10 @@ static const char rcsid_port_c[] = "$Id$";
 /*                                                                          */
 /****************************************************************************/
 
-static string
-port_get(port *p)
+static string port_get(p)
+     port *p;
 {
-    char *(*get_proc)(port *, char **);
+    char *(*get_proc)();
     char *error = NULL;
     char *result;
 
@@ -65,12 +65,12 @@ port_get(port *p)
       return(result);
 }
 
-static void
-port_put(port *p,
-        char *data,
-        int length)
+static void port_put(p, data, length)
+     port *p;
+     char *data;
+     int length;
 {
-    char *(*put_proc)(port *, char *, int);
+    char *(*put_proc)();
     char *error;
 
     if (p->status & OUTPUT_CLOSED) {
@@ -91,10 +91,10 @@ port_put(port *p,
       var_set_variable("error", error);
 }
 
-static void
-port_close_input(port *p)
+static void port_close_input(p)
+     port *p;
 {
-    char *(*close_input_proc)(port *);
+    char *(*close_input_proc)();
     char *error;
 
     if (p->status & INPUT_CLOSED)
@@ -105,15 +105,14 @@ port_close_input(port *p)
     if (!close_input_proc)
       return;
 
-    error = close_input_proc(p);
-    if (error)
+    if (error = close_input_proc(p))
       var_set_variable("error", error);
 }
 
-static void
-port_close_output(port *p)
+static void port_close_output(p)
+     port *p;
 {
-    char *(*close_output_proc)(port *);
+    char *(*close_output_proc)();
     char *error;
 
     if (p->status & OUTPUT_CLOSED)
@@ -124,8 +123,7 @@ port_close_output(port *p)
     if (!close_output_proc)
       return;
 
-    error = close_output_proc(p);
-    if (error)
+    if (error = close_output_proc(p))
       var_set_variable("error", error);
 }
 
@@ -148,15 +146,14 @@ static port_dictionary port_dict = NULL;
  *                 any other port call is made.
  */
 
-static void
-close_port_from_binding(port_dictionary_binding *b)
+static void close_port_from_binding(b)
+     port_dictionary_binding *b;
 {
     port_close_input(&(b->value));
     port_close_output(&(b->value));
 }
 
-void
-init_ports(void)
+void init_ports()
 {
     if (port_dict) {
        port_dictionary_Enumerate(port_dict, close_port_from_binding);
@@ -179,8 +176,8 @@ init_ports(void)
  *                 various fields correctly.
  */
 
-static port *
-create_named_port(string name)
+static port *create_named_port(name)
+     string name;
 {
     int already_exists;
     port_dictionary_binding *binding;
@@ -203,8 +200,8 @@ create_named_port(string name)
  *                 it.  Otherwise returns NULL.
  */
 
-static port *
-get_named_port(string name)
+static port *get_named_port(name)
+     string name;
 {
     port_dictionary_binding *binding;
 
@@ -233,8 +230,8 @@ get_named_port(string name)
  *                 on the heap & must be eventually freed.
  */
 
-string
-read_from_port(string name)
+string read_from_port(name)
+     string name;
 {
     port *p;
 
@@ -256,10 +253,10 @@ read_from_port(string name)
  *                 occurs, $error is set to the error message.
  */
 
-void
-write_on_port(string name,
-             char *text,
-             int length)
+void write_on_port(name, text, length)
+     string name;
+     char *text;
+     int length;
 {
     port *p;
 
@@ -283,8 +280,8 @@ write_on_port(string name,
  *                 occurs, $error is set to the error message.
  */
 
-void
-close_port_input(string name)
+void close_port_input(name)
+     string name;
 {
     port_dictionary_binding *binding;
 
@@ -309,8 +306,8 @@ close_port_input(string name)
  *                 occurs, $error is set to the error message.
  */
 
-void
-close_port_output(string name)
+void close_port_output(name)
+     string name;
 {
     port_dictionary_binding *binding;
 
@@ -329,9 +326,9 @@ close_port_output(string name)
 /*                                                                          */
 /****************************************************************************/
 
-static string
-get_file(port *p,
-        char **error_p)
+static string get_file(p, error_p)
+     port *p;
+     char **error_p;
 {
     char buffer[10000]; /* <<<>>> */
 
@@ -355,10 +352,10 @@ get_file(port *p,
     return(string_Copy(buffer));
 }
 
-static char *
-put_file(port *p,
-        string text,
-        int length)
+static char *put_file(p, text, length)
+     port *p;
+     string text;
+     int length;
 {
     if (!p->data.file.output_connector)
       return(NULL);
@@ -373,8 +370,8 @@ put_file(port *p,
     return(NULL);
 }
 
-static char *
-close_file_input(port *p)
+static char *close_file_input(p)
+     port *p;
 {
     errno = 0;
     if (p->data.file.input_connector) {
@@ -388,8 +385,8 @@ close_file_input(port *p)
     return(NULL);
 }
 
-static char *
-close_file_output(port *p)
+static char *close_file_output(p)
+     port *p;
 {
     errno = 0;
     if (p->data.file.output_connector) {
@@ -403,9 +400,10 @@ close_file_output(port *p)
     return(NULL);
 }
 
-void create_port_from_files(string name,
-                           FILE *input,
-                           FILE *output)
+void create_port_from_files(name, input, output)
+     string name;
+     FILE *input;
+     FILE *output;
 {
     port *p = create_named_port(name);
 
@@ -436,9 +434,9 @@ void create_port_from_files(string name,
 /*                                                                          */
 /****************************************************************************/
 
-void
-create_subprocess_port(string name,
-                      char **argv)
+void create_subprocess_port(name, argv)
+     string name;
+     char **argv;
 {
     int pid;
     int to_child_descriptors[2];
@@ -479,9 +477,9 @@ create_subprocess_port(string name,
     create_port_from_files(name, in, out);
 }
 
-void
-create_file_append_port(string name,
-                       string filename)
+void create_file_append_port(name, filename)
+     string name;
+     string filename;
 {
     FILE *out;
     int oumask;
@@ -499,9 +497,9 @@ create_file_append_port(string name,
     create_port_from_files(name, 0, out);
 }
 
-void
-create_file_input_port(string name,
-                      string filename)
+void create_file_input_port(name, filename)
+     string name;
+     string filename;
 {
     FILE *in;
 
@@ -515,9 +513,9 @@ create_file_input_port(string name,
     create_port_from_files(name, in, 0);
 }
 
-void
-create_file_output_port(string name,
-                       string filename)
+void create_file_output_port(name, filename)
+     string name;
+     string filename;
 {
     FILE *out;
     int oumask;
@@ -541,9 +539,9 @@ create_file_output_port(string name,
 /*                                                                          */
 /****************************************************************************/
 
-static string
-get_filter(port *p,
-          char **error_p)
+static string get_filter(p, error_p)
+     port *p;
+     char **error_p;
 {
     string result;
 
@@ -557,10 +555,10 @@ get_filter(port *p,
     return(result);
 }
 
-static char *
-put_filter(port *p,
-          string text,
-          int length)
+static char *put_filter(p, text, length)
+     port *p;
+     string text;
+     int length;
 {
     string input;
     string output;
@@ -575,8 +573,8 @@ put_filter(port *p,
     return(NULL);
 }
 
-static char *
-close_filter_input(port *p)
+static char *close_filter_input(p)
+     port *p;
 {
     while (!string_stack_empty(p->data.filter.waiting_packets))
       string_stack_pop(p->data.filter.waiting_packets);
@@ -585,15 +583,15 @@ close_filter_input(port *p)
 }
 
 /*ARGSUSED*/
-static char *
-close_filter_output(port *p)
+static char *close_filter_output(p)
+     port *p;
 {
     return(NULL);
 }
 
-void
-create_port_from_filter(string name,
-                       string (*filter)(string))
+void create_port_from_filter(name, filter)
+     string name;
+     string (*filter)();
 {
     port *p = create_named_port(name);
 
@@ -612,10 +610,10 @@ create_port_from_filter(string name,
 /*                                                                          */
 /****************************************************************************/
 
-static char *
-put_output(port *p,
-          string text,
-          int length)
+static char *put_output(p, text, length)
+     port *p;
+     string text;
+     int length;
 {
     string input;
     char *error;
@@ -627,15 +625,15 @@ put_output(port *p,
 }
 
 /*ARGSUSED*/
-static char *
-close_output(port *p)
+static char *close_output(p)
+     port *p;
 {
     return(NULL);
 }
 
-void
-create_port_from_output_proc(string name,
-                            char *(*output)(string))
+void create_port_from_output_proc(name, output)
+     string name;
+     char *(*output)();
 {
 #ifdef SABER /* Yes, it's another ANSI incompatiblity */
     port *p;
index d7da9d3e52c441a0e69055f1cda2b4396df377b3..0cf4591300e996c5d1d3f84748823681a7c2e0ca 100644 (file)
@@ -28,18 +28,18 @@ union port__data {
     } file;
     struct {
        string_stack waiting_packets;
-       string (*filter)(string);
+       string (*filter)();
     } filter;
     struct {
-       char *(*output)(string);
+       char *(*output)();
     } output;
 };
 
-typedef struct port__struct {                /* PRIVATE */
-    char *(*get)(struct port__struct *, char **);
-    char *(*put)(struct port__struct *, char *, int);
-    char *(*close_input)(struct port__struct *);
-    char *(*close_output)(struct port__struct *);
+typedef struct {                /* PRIVATE */
+    char *(*get)();
+    char *(*put)();
+    char *(*close_input)();
+    char *(*close_output)();
 #define  INPUT_CLOSED   0x1
 #define  OUTPUT_CLOSED  0x2
 #define  PORT_CLOSED    0x3
@@ -54,7 +54,7 @@ typedef struct port__struct {                /* PRIVATE */
  *                 any other port call is made.
  */
 
-extern void init_ports(void);
+extern void init_ports();
 
 /*
  *    string read_from_port(string name)
@@ -68,7 +68,7 @@ extern void init_ports(void);
  *                 on the heap & must be eventually freed.
  */
 
-extern string read_from_port(string);
+extern string read_from_port();
 
 /*
  *    void write_on_port(string name, char *text, int length)
@@ -80,7 +80,7 @@ extern string read_from_port(string);
  *                 occurs, $error is set to the error message.
  */
 
-extern void write_on_port(string, char *, int);
+extern void write_on_port();
 
 /*
  *    void close_port_input(string name)
@@ -94,7 +94,7 @@ extern void write_on_port(string, char *, int);
  *                 occurs, $error is set to the error message.
  */
 
-extern void close_port_input(string);
+extern void close_port_input();
 
 /*
  *    void close_port_output(string name)
@@ -108,17 +108,17 @@ extern void close_port_input(string);
  *                 occurs, $error is set to the error message.
  */
 
-extern void close_port_output(string);
+extern void close_port_output();
 
 
-extern void create_subprocess_port(string, char **);
-extern void create_file_append_port(string, string);
-extern void create_file_input_port(string, string);
-extern void create_file_output_port(string, string);
-extern void create_port_from_filter(string, string (*)(string));
-extern void create_port_from_output_proc(string, char *(*)(string));
+extern void create_subprocess_port();
+extern void create_file_append_port();
+extern void create_file_input_port();
+extern void create_file_output_port();
+extern void create_port_from_filter();
+extern void create_port_from_output_proc();
 
-extern void init_standard_ports(int *, char **);
-extern void create_port_from_files(string, FILE *, FILE *);
+extern void init_standard_ports();
+extern void create_port_from_files();
 
 #endif
index a9314ab5fd98c8a1963781db9a19500edf4482b2..d3a2cb5356ec81b31f285780f7489ca8fba0a7a9 100644 (file)
@@ -20,9 +20,9 @@ static const char rcsid_regexp_c[] = "$Id$";
 
 #include "regexp.h"
 
-int
-ed_regexp_match_p(string test_string,
-                 string pattern)
+int ed_regexp_match_p(test_string, pattern)
+     string test_string;
+     string pattern;
 {
     regex_t RE;
     int retval;
index d5efcc2ef71911221d1d64e5b055b180cd39cc58..24299982a0c93720924c535a037133428297208c 100644 (file)
@@ -19,6 +19,6 @@
 
 #include "new_string.h"
 
-extern int ed_regexp_match_p(string, string);
+extern int ed_regexp_match_p();
 
 #endif
index 1c6d1ce93f70be2e969b52c40da7c23e32f5ce10..526e02cdb53f557fa42e0d6748db8ef7ed4b06c8 100644 (file)
@@ -32,22 +32,22 @@ static const char rcsid_standard_ports_c[] = "$Id$";
 #include "main.h"
 #include <zephyr/zephyr.h>
 
-extern char *tty_filter(string, int);
-extern int tty_filter_init(char *, char, int *, char **);
+extern string tty_filter();
+extern int tty_filter_init();
 
 #ifndef X_DISPLAY_MISSING
-extern char *X_driver(string);
-extern int X_driver_init(char *, char, int *, char **);
+extern char *X_driver();
+extern int X_driver_init();
 #endif
 
-extern void usage(void);
+extern void usage();
 
 /*
  *
  */
 
-char *
-plain_driver(string input)
+char *plain_driver(input)
+     string input;
 {
     string processed_input = tty_filter(input, 0);
 
@@ -61,8 +61,8 @@ plain_driver(string input)
  *
  */
 
-char *
-tty_driver(string input)
+char *tty_driver(input)
+     string input;
 {
     string processed_input = tty_filter(input, 1);
 
@@ -76,8 +76,8 @@ tty_driver(string input)
  *
  */
 
-string
-noop_filter(string input)
+string noop_filter(input)
+     string input;
 {
     return(input);
 }
@@ -86,8 +86,8 @@ noop_filter(string input)
  *
  */
 
-string
-plain_filter(string input)
+string plain_filter(input)
+     string input;
 {
     return(tty_filter(input, 0));
 }
@@ -96,8 +96,8 @@ plain_filter(string input)
  *
  */
 
-string
-fancy_filter(string input)
+string fancy_filter(input)
+     string input;
 {
     return(tty_filter(input, 1));
 }
@@ -118,13 +118,13 @@ static struct standard_port_info {
 #define        DISABLED        2
 
     int port_setup_status;
-    int (*port_init)(char *, char, int *, char **);
+    int (*port_init)();
 #define  INPUT_DESC  0
 #define  OUTPUT_DESC 1
 #define  FILTER      2
 #define  OUTPUT_PROC 3
     int type;
-    char *(*function)(string);
+    char *(*function)();
     int setup_arg;
 } standard_port_info_table[] = {
 #ifndef X_DISPLAY_MISSING
@@ -148,8 +148,8 @@ static struct standard_port_info {
  * <<<>>>
  */
 
-static struct standard_port_info *
-get_standard_port_info(string port_name)
+static struct standard_port_info *get_standard_port_info(port_name)
+     string port_name;
 {
     struct standard_port_info *p;
 
@@ -169,8 +169,8 @@ get_standard_port_info(string port_name)
  *                  returns -1.
  */
 
-static int
-boolean_value_of(string text)
+static int boolean_value_of(text)
+     string text;
 {
     if (!text)
        return(-1);                     /* not set */
@@ -190,8 +190,9 @@ boolean_value_of(string text)
  *
  */
 
-void init_standard_ports(int *pargc,
-                        char **argv)
+void init_standard_ports(pargc, argv)
+     int *pargc;
+     char **argv;
 {
     struct standard_port_info *p;
     string first_working_port = "";
@@ -208,25 +209,21 @@ void init_standard_ports(int *pargc,
             current++; *pargc -= 2;
             if (!*current)
               usage();
-           p = get_standard_port_info((string) *current);
-            if (p)
+            if (p = get_standard_port_info((string) *current))
                p->port_setup_status = DISABLED;
         } else if (string_Eq((string) *current, "-default")) {
             current++; *pargc -= 2;
             if (!*current)
               usage();
             default_port = (string) *current;
-           p = get_standard_port_info((string) *current);
-            if (p)
+            if (p = get_standard_port_info((string) *current))
                p->port_setup_status = DEFAULT_OK;
         } else if (string_Eq((string) *current, "-ttymode")) {
            default_port = (string) "tty";
            (*pargc)--;
-           p = get_standard_port_info(default_port);
-            if (p) {
+            if (p = get_standard_port_info(default_port)) {
                p->port_setup_status = DEFAULT_OK;
-               p = get_standard_port_info ((string) "X");
-               if (p)
+               if (p = get_standard_port_info ((string) "X"))
                    p->port_setup_status = DISABLED;
            }
        } else
index 5dfd89d366a27c4a8cd88cf1f655edb09f186f27..b2786ff675d5f91ec0ad6bfa8038f4445e2c7cec 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #if (!defined(lint) && !defined(SABER))
-static const char rcsid_string_dictionary_aux_c[] = "$Id$";
+static char rcsid_string_dictionary_aux_c[] = "$Id$";
 #endif
 
 /*
@@ -43,10 +43,10 @@ static const char rcsid_string_dictionary_aux_c[] = "$Id$";
  *                 heap.
  */
 
-void
-string__dictionary_Set(string_dictionary d,
-                      string key,
-                      string value)
+void string__dictionary_Set(d, key, value)
+     string_dictionary d;
+     string key;
+     string value;
 {
     string_dictionary_binding *binding;
     int already_exists;
@@ -67,9 +67,9 @@ string__dictionary_Set(string_dictionary d,
  *                 disappear later if key is rebound.
  */
 
-char *
-string_dictionary_Fetch(string_dictionary d,
-                       string key)
+char *string_dictionary_Fetch(d, key)
+     string_dictionary d;
+     string key;
 {
     string_dictionary_binding *binding;
 
@@ -87,14 +87,14 @@ string_dictionary_Fetch(string_dictionary d,
  *                 all value's in the dictionary.
  */
 
-static void
-free_value_of_binding(string_dictionary_binding *b)
+static void free_value_of_binding(b)
+     string_dictionary_binding *b;
 {
     free(b->value);
 }
 
-void
-string_dictionary_SafeDestroy(string_dictionary d)
+void string_dictionary_SafeDestroy(d)
+     string_dictionary d;
 {
     string_dictionary_Enumerate(d, free_value_of_binding);
     string_dictionary_Destroy(d);
index e058721c00c7a9c526b83e648afe8aa84afb6919..84fac3364366d53a18c366844d784e8e227ec160 100644 (file)
@@ -25,7 +25,7 @@
  *                 heap.
  */
 
-extern void string__dictionary_Set(string_dictionary, string, string);
+extern void string__dictionary_Set();
 #ifdef DEBUG_MEMORY
 #define string_dictionary_Set(a,b,c)         (set_module(__FILE__,__LINE__),\
                                              string__dictionary_Set(a,b,c))
@@ -42,8 +42,7 @@ extern void string__dictionary_Set(string_dictionary, string, string);
  *                 disappear later if key is rebound.
  */
 
-extern char *string_dictionary_Fetch(string_dictionary,
-                                    string);
+extern char *string_dictionary_Fetch();
 
 /*
  *    void string_dictionary_SafeDestroy(string_dictionary d)
@@ -52,6 +51,6 @@ extern char *string_dictionary_Fetch(string_dictionary,
  *                 all value's in the dictionary.
  */
 
-extern void string_dictionary_SafeDestroy(string_dictionary);
+extern void string_dictionary_SafeDestroy();
 
 #endif
index 5123d5f7b8991040e8ad1144703d322b19df4e48..e72963ebf608847c9fcc149d176e62542290ae5a 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #if (!defined(lint) && !defined(SABER))
-static const char rcsid_subscriptions_c[] = "$Id$";
+static char rcsid_subscriptions_c[] = "$Id$";
 #endif
 
 /****************************************************************************/
@@ -44,16 +44,15 @@ static const char rcsid_subscriptions_c[] = "$Id$";
  */
 static int_dictionary puntable_addresses_dict = 0;
 
-static void
-init_puntable_dict(void)
+static void init_puntable_dict()
 {
     puntable_addresses_dict = int_dictionary_Create(33);
 }
 
-static string
-address_to_string(string class,
-                 string instance,
-                 string recipient)
+static string address_to_string(class, instance, recipient)
+     string class;
+     string instance;
+     string recipient;
 {
     string result;
 
@@ -76,9 +75,10 @@ address_to_string(string class,
     return(result);
 }
 
-int puntable_address_p(string class,
-                      string instance,
-                      string recipient)
+int puntable_address_p(class, instance, recipient)
+     string class;
+     string instance;
+     string recipient;
 {
     string temp;
 
@@ -95,9 +95,10 @@ int puntable_address_p(string class,
     return(0);
 }
 
-void punt(string class,
-         string instance,
-         string recipient)
+void punt(class, instance, recipient)
+     string class;
+     string instance;
+     string recipient;
 {
     string temp;
 
@@ -109,9 +110,10 @@ void punt(string class,
     free(temp);
 }
 
-void unpunt(string class,
-           string instance,
-           string recipient)
+void unpunt(class, instance, recipient)
+     string class;
+     string instance;
+     string recipient;
 {
     string temp;
     int_dictionary_binding *binding;
@@ -144,9 +146,9 @@ static ZSubscription_t subscription_list[BATCH_SIZE];
 static int unsubscription_list_size = 0;
 static ZSubscription_t unsubscription_list[BATCH_SIZE];
 
-static void
-free_subscription_list(ZSubscription_t *list,
-                      int number_of_elements)
+static void free_subscription_list(list, number_of_elements)
+     ZSubscription_t *list;
+     int number_of_elements;
 {
     int i;
 
@@ -157,8 +159,7 @@ free_subscription_list(ZSubscription_t *list,
     }
 }
 
-static void
-flush_subscriptions(void)
+static void flush_subscriptions()
 {
       TRAP(ZSubscribeTo(subscription_list,subscription_list_size, 0),
           "while subscribing");
@@ -167,8 +168,7 @@ flush_subscriptions(void)
     subscription_list_size = 0;
 }
 
-static void
-flush_unsubscriptions(void)
+static void flush_unsubscriptions()
 {
     if (unsubscription_list_size)
       TRAP(ZUnsubscribeTo(unsubscription_list, unsubscription_list_size, 0),
@@ -178,10 +178,10 @@ flush_unsubscriptions(void)
     unsubscription_list_size = 0;
 }
 
-static void
-subscribe(string class,
-         string instance,
-         string recipient)
+static void subscribe(class, instance, recipient)
+     string class;
+     string instance;
+     string recipient;
 {
     subscription_list[subscription_list_size].zsub_class = string_Copy(class);
     subscription_list[subscription_list_size].zsub_classinst= string_Copy(instance);
@@ -191,10 +191,10 @@ subscribe(string class,
       flush_subscriptions();
 }
 
-static void
-unsubscribe(string class,
-           string instance,
-           string recipient)
+static void unsubscribe(class, instance, recipient)
+     string class;
+     string instance;
+     string recipient;
 {
     unsubscription_list[unsubscription_list_size].zsub_class = string_Copy(class);
     unsubscription_list[unsubscription_list_size].zsub_classinst
@@ -219,8 +219,7 @@ unsubscribe(string class,
 
 char ourhost[MAXHOSTNAMELEN],ourhostcanon[MAXHOSTNAMELEN];
 
-static void
-inithosts(void)
+static void inithosts()
 {
     struct hostent *hent;
     if (gethostname(ourhost, sizeof(ourhost)-1) == -1) {
@@ -237,8 +236,8 @@ inithosts(void)
     return;
 }
 
-static void
-macro_sub(char *str)
+static void macro_sub(str)
+     char *str;
 {
     static int initedhosts = 0;
 
@@ -257,8 +256,8 @@ macro_sub(char *str)
 #define  UNSUBSCRIBE_CHARACTER  '!'
 #define  PUNT_CHARACTER         '-'
 
-static void
-load_subscriptions_from_file(FILE *file)
+static void load_subscriptions_from_file(file)
+     FILE *file;
 {
     char line[BUFSIZ];
     char class_buffer[BUFSIZ], instance[BUFSIZ], recipient[BUFSIZ];
@@ -271,9 +270,8 @@ load_subscriptions_from_file(FILE *file)
            /* Parse line */
            /* <<<>>>
             * The below does NOT work is the recipient field  is "":
-            */
-           temp = strchr(line, '#');
-           if (temp)
+            */ 
+           if (temp = strchr(line, '#'))
              *temp = '\0';
            for (temp=line; *temp && *temp==' '; temp++) ;
            if (!*temp || *temp=='\n')
@@ -321,8 +319,7 @@ load_subscriptions_from_file(FILE *file)
 
 #define DEFSUBS "/dev/null"
 
-static void
-load_subscriptions(void)
+static void load_subscriptions()
 {
     FILE *subscriptions_file;
 
@@ -346,7 +343,7 @@ int zwgc_active = 0;
 static ZSubscription_t *saved_subscriptions = NULL;
 static int number_of_saved_subscriptions;
 
-void zwgc_shutdown(void)
+void zwgc_shutdown()
 {
     if (!zwgc_active)
       return;
@@ -370,7 +367,7 @@ void zwgc_shutdown(void)
     zwgc_active = 0;
 }
 
-void zwgc_startup(void)
+void zwgc_startup()
 {
     if (zwgc_active)
       return;
index 91cb360797c88124794fb5ffe9fdbff051e4dedb..88f52c2f25df25171a5c8b3f8b056b3af96d40dd 100644 (file)
 
 extern int zwgc_active;
 
-extern int puntable_address_p(string, string, string);
-extern void punt(string, string, string);
-extern void unpunt(string, string, string);
-extern void zwgc_shutdown(void);
-extern void zwgc_startup(void);
+extern int puntable_address_p(/* string class, instance, recipient */);
+extern void punt();
+extern void unpunt();
+extern void zwgc_shutdown();
+extern void zwgc_startup();
 
 #define USRSUBS ".zephyr.subs"
 
index 26accc1772192da6a54804a2df1f020e263ff35f..ebbd913fcb0194f4327d96aa63986844dd46777d 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #if (!defined(lint) && !defined(SABER))
-static const char rcsid_substitute_c[] = "$Id$";
+static char rcsid_substitute_c[] = "$Id$";
 #endif
 
 #include <zephyr/mit-copyright.h>
@@ -38,9 +38,9 @@ static const char rcsid_substitute_c[] = "$Id$";
  *                 The returned string must not be freed.
  */
 
-static string
-eat_dollar_sign_stuff(string (*lookup)(string),
-                     string *text_ptr)                 /* Input/Output parameter */
+static string eat_dollar_sign_stuff(lookup, text_ptr)
+     string (*lookup)();
+     string *text_ptr;                 /* Input/Output parameter */
 {
     char c;
     char closing_brace = 0;
@@ -132,9 +132,9 @@ eat_dollar_sign_stuff(string (*lookup)(string),
  *                 modified in any way or freed.
  */
 
-string
-substitute(string (*lookup)(string),
-          string text)
+string substitute(lookup, text)
+     string (*lookup)();
+     string text;
 {
     string result_so_far = string_Copy("");
     char *p, *temp;
index 925454afd695b6066a13b17847ced9eb4c0677bd..5c0bb554d87a936a050605eeede69dc97c91ea91 100644 (file)
@@ -40,6 +40,6 @@
  *                 modified in any way or freed.
  */
 
-extern string substitute(string (*)(string), string);
+extern string substitute();
 
 #endif
index 16d9047a7a02a046e0399260d38d1fc94cf1a03b..b5b791a8946c6c6a6a615ae31d1aedaeb0d33c9b 100644 (file)
@@ -23,9 +23,9 @@ static const char rcsid_text_operations_c[] = "$Id$";
 #include "text_operations.h"
 #include "char_stack.h"
 
-string
-lany(string *text_ptr,
-     string str)
+string lany(text_ptr, str)
+     string *text_ptr;
+     string str;
 {
     string result, whats_left;
     char *p = *text_ptr;
@@ -40,14 +40,14 @@ lany(string *text_ptr,
     return(result);
 }
 
-string
-lbreak(string *text_ptr,
-       const character_class set)
+string lbreak(text_ptr, set)
+     string *text_ptr;
+     character_class set;
 {
     string result, whats_left;
     char *p = *text_ptr;
 
-    while (*p && !set[(int)*p]) p++;
+    while (*p && !set[*p]) p++;
 
     result = string_CreateFromData(*text_ptr, p - *text_ptr);
     whats_left = string_Copy(p);
@@ -57,14 +57,14 @@ lbreak(string *text_ptr,
     return(result);
 }
 
-string
-lspan(string *text_ptr,
-      character_class set)
+string lspan(text_ptr, set)
+     string *text_ptr;
+     character_class set;
 {
     string result, whats_left;
     char *p = *text_ptr;
 
-    while (*p && set[(int)*p]) p++;
+    while (*p && set[*p]) p++;
 
     result = string_CreateFromData(*text_ptr, p - *text_ptr);
     whats_left = string_Copy(p);
@@ -74,9 +74,9 @@ lspan(string *text_ptr,
     return(result);
 }
 
-string
-rany(string *text_ptr,
-     string str)
+string rany(text_ptr, str)
+     string *text_ptr;
+     string str;
 {
     string result, whats_left;
     string text = *text_ptr;
@@ -92,15 +92,15 @@ rany(string *text_ptr,
     return(result);
 }
 
-string
-rbreak(string *text_ptr,
-       character_class set)
+string rbreak(text_ptr, set)
+     string *text_ptr;
+     character_class set;
 {
     string result, whats_left;
     string text = *text_ptr;
     char *p = text + strlen(text);
 
-    while (text<p && !set[(int)p[-1]]) p--;
+    while (text<p && !set[p[-1]]) p--;
 
     result = string_Copy(p);
     whats_left = string_CreateFromData(text, p - text);
@@ -110,15 +110,15 @@ rbreak(string *text_ptr,
     return(result);
 }
 
-string
-rspan(string *text_ptr,
-      character_class set)
+string rspan(text_ptr, set)
+     string *text_ptr;
+     character_class set;
 {
     string result, whats_left;
     string text = *text_ptr;
     char *p = text + strlen(text);
 
-    while (text<p && set[(int)p[-1]]) p--;
+    while (text<p && set[p[-1]]) p--;
 
     result = string_Copy(p);
     whats_left = string_CreateFromData(text, p - text);
index 0e1c152b1ab2634b875665a6c7ac192b83f30c59..960e2abc56ed73f17680074192c025effe80c777 100644 (file)
 
 #include "character_class.h"
 
-extern string lany(string *, string);
-extern string lbreak(string *, const character_class);
-extern string lspan(string *, character_class);
-extern string rany(string *, string);
-extern string rbreak(string *, character_class);
-extern string rspan(string *, character_class);
+extern string protect();
+extern string verbatim();
+extern string stylestrip();
+extern string lany();
+extern string lbreak();
+extern string lspan();
+extern string rany();
+extern string rbreak();
+extern string rspan();
 
 #endif
index 97905e35ac838573451e3fd0a7e388fe3f77081d..72a67476caa3f9fe5f96e98973c2a8113ba519cf 100644 (file)
@@ -24,13 +24,6 @@ static const char rcsid_tty_filter_c[] = "$Id$";
 /*                         The tty & plain filters:                         */
 /*                                                                          */
 /****************************************************************************/
-#ifdef HAVE_TERMCAP_H
-#include <termcap.h>
-#else
-#ifdef HAVE_TERM_H
-#include <term.h>
-#endif
-#endif
 
 #include "new_memory.h"
 #include "new_string.h"
@@ -40,7 +33,7 @@ static const char rcsid_tty_filter_c[] = "$Id$";
 #include "error.h"
 
 /***************************************************************************/
-#ifndef HAVE_TERMCAP_H
+
 extern int tgetent();
 extern char *tgetstr(),*getenv();
 #ifdef linux
@@ -49,7 +42,6 @@ extern speed_t ospeed;
 extern short ospeed;
 #endif
 char PC;
-#endif
 
 /* Dictionary naming convention:
 
@@ -84,18 +76,19 @@ static char code_buf[10240], *code_buf_pos = code_buf, *code;
                   *code_buf_pos++ = 0, TD_SET(k, code))
 
 static int
-tty_outc(int c)
+tty_outc(c)
+    int c;
 {
     *code_buf_pos++ = c;
     return 0;
 }
 
 /* ARGSUSED */
-int
-tty_filter_init(char *drivername,
-               char notfirst,
-               int *pargc,
-               char **argv)
+int tty_filter_init(drivername, notfirst, pargc, argv)
+char *drivername;
+char notfirst;
+int *pargc;
+char **argv;
 {
     static char st_buf[128];
     char tc_buf[1024], *p = st_buf, *tmp, *term;
@@ -142,65 +135,59 @@ tty_filter_init(char *drivername,
 
        tmp = tgetstr("pc", &p);
        PC = (tmp) ? *tmp : 0;
-       tmp = tgetstr("md", &p);
-       if (tmp) {      /* bold ? */
+       if (tmp = tgetstr("md",&p)) {   /* bold ? */
            EXPAND("B.bold");
            tmp = tgetstr("me",&p);
            EXPAND("E.bold");
        }
-       tmp = tgetstr("mr", &p);
-       if (tmp) {      /* reverse video? */
+       if (tmp = tgetstr("mr",&p)) {   /* reverse video? */
            EXPAND("B.rw");
-           tmp = tgetstr("me", &p);
+           tmp = tgetstr("me",&p);
            EXPAND("E.rw");
        }
-       tmp = tgetstr("bl", &p);
-       if (tmp) {      /* Bell ? */
+       if (tmp = tgetstr("bl",&p)) {   /* Bell ? */
            EXPAND("B.bell");
            TD_SET("E.bell", NULL);
        }
-       tmp = tgetstr("mb", &p);
-       if (tmp) {      /* Blink ? */
+       if (tmp = tgetstr("mb",&p)) {   /* Blink ? */
            EXPAND("B.blink");
-           tmp = tgetstr("me", &p);
+           tmp = tgetstr("me",&p);
            EXPAND("E.blink");
        }
-       tmp = tgetstr("us", &p);
-       if (tmp) {      /* Underline ? */
+       if (tmp = tgetstr("us",&p))     { /* Underline ? */
            EXPAND("B.u");
-           tmp = tgetstr("ue", &p);
+           tmp = tgetstr("ue",&p);
            EXPAND("E.u");
        }
-       tmp = tgetstr("so", &p);
-       if (tmp) {      /* Standout ? */
+       if (tmp = tgetstr("so",&p))     { /* Standout ? */
            EXPAND("B.so");
-           tmp = tgetstr("se", &p);
+           tmp = tgetstr("se",&p);
            EXPAND("E.so");
        }
     }    
     /* Step 2: alias others to the nearest substitute */
     
     /* Bold = so, else rv, else ul */
-    if (NULL == string_dictionary_Lookup(termcap_dict, "B.bold")) {
-       if((b = string_dictionary_Lookup(termcap_dict, "B.so"))) {
-           TD_SET("B.bold", b->value);
+    if (NULL == string_dictionary_Lookup(termcap_dict,"B.bold")) {
+       if(b = string_dictionary_Lookup(termcap_dict,"B.so")) {
+           TD_SET("B.bold",b->value);
            TD_SET("E.bold",
-                  string_dictionary_Lookup(termcap_dict, "E.so")->value);
-       } else if ((b = string_dictionary_Lookup(termcap_dict, "B.rv"))) {
-           TD_SET("B.bold", b->value);
+                  string_dictionary_Lookup(termcap_dict,"E.so")->value);
+       } else if (b = string_dictionary_Lookup(termcap_dict,"B.rv")) {
+           TD_SET("B.bold",b->value);
            TD_SET("E.bold",
-                  string_dictionary_Lookup(termcap_dict, "E.rv")->value);
-       } else if ((b = string_dictionary_Lookup(termcap_dict,"B.u"))) {
-           TD_SET("B.bold", b->value);
+                  string_dictionary_Lookup(termcap_dict,"E.rv")->value);
+       } else if (b = string_dictionary_Lookup(termcap_dict,"B.u")) {
+           TD_SET("B.bold",b->value);
            TD_SET("E.bold",
-                  string_dictionary_Lookup(termcap_dict, "E.u")->value);
+                  string_dictionary_Lookup(termcap_dict,"E.u")->value);
        }
     }
     
     /* Bell = ^G */
-    if (NULL == string_dictionary_Lookup(termcap_dict, "B.bell")) {
-       TD_SET("B.bell", "\007");
-       TD_SET("E.bell", NULL);
+    if (NULL == string_dictionary_Lookup(termcap_dict,"B.bell")) {
+       TD_SET("B.bell","\007");
+       TD_SET("E.bell",NULL);
     }
     
     /* Underline -> nothing */
@@ -214,10 +201,10 @@ tty_filter_init(char *drivername,
 
 
 
-static int
-fixed_string_eq(string pattern,
-               char *text,
-               int text_length)
+static int fixed_string_eq(pattern, text, text_length)
+     string pattern;
+     char *text;
+     int text_length;
 {
     while (*pattern && text_length>0 && *pattern == *text) {
        pattern++;
@@ -241,8 +228,8 @@ typedef struct _tty_str_info {
     unsigned int ignore: 1;
 } tty_str_info;
 
-static void
-free_info(tty_str_info *info)
+static void free_info(info)
+     tty_str_info *info;
 {
     tty_str_info *next_info;
 
@@ -253,10 +240,10 @@ free_info(tty_str_info *info)
     }
 }
 
-static int
-do_mode_change(tty_str_info *current_mode_p,
-              char *text,
-              int text_length)
+static int do_mode_change(current_mode_p, text, text_length)
+     tty_str_info *current_mode_p;
+     char *text;
+     int text_length;
 {
     /* alignment commands: */
     if (fixed_string_eq("left", text, text_length) ||
@@ -292,8 +279,8 @@ do_mode_change(tty_str_info *current_mode_p,
     return 0;
 }
 
-static tty_str_info *
-convert_desc_to_tty_str_info(desctype *desc)
+static tty_str_info *convert_desc_to_tty_str_info(desc)
+     desctype *desc;
 {
     tty_str_info *temp;
     tty_str_info *result = NULL;
@@ -380,10 +367,10 @@ convert_desc_to_tty_str_info(desctype *desc)
 
 #define  max(a,b)                ((a)>(b)?(a):(b))
 
-static int
-line_width(int left_width,
-          int center_width,
-          int right_width)
+static int line_width(left_width, center_width, right_width)
+     int left_width;
+     int center_width;
+     int right_width;
 {
     if (center_width>0) {
        if (left_width==0 && right_width==0)
@@ -397,8 +384,8 @@ line_width(int left_width,
     }
 }
 
-static int
-calc_max_line_width(tty_str_info *info)
+static int calc_max_line_width(info)
+     tty_str_info *info;
 {
     int max_line_width = 0;
     int left = 0;
@@ -445,9 +432,9 @@ calc_max_line_width(tty_str_info *info)
     return(max_line_width);
 }
 
-string
-tty_filter(string text,
-          int use_fonts)
+string tty_filter(text, use_fonts)
+     string text;
+     int use_fonts;
 {
     string text_copy = string_Copy(text);
     string result_so_far = string_Copy("");
@@ -496,12 +483,10 @@ tty_filter(string text,
            item = string_Copy("");
            
            if (info->bold_p && use_fonts) {
-               temp = string_dictionary_Fetch(termcap_dict, "B.bold");
-               if (temp)
+               if (temp = string_dictionary_Fetch(termcap_dict, "B.bold"))
                  item = string_Concat2(item, temp);
            } else if (info->italic_p && use_fonts) {
-               temp = string_dictionary_Fetch(termcap_dict, "B.u");
-               if (temp)
+               if (temp = string_dictionary_Fetch(termcap_dict, "B.u"))
                  item = string_Concat2(item, temp);
            }
            temp = string_CreateFromData(info->str, info->len);
@@ -509,12 +494,10 @@ tty_filter(string text,
            free(temp);
 
            if (info->bold_p && use_fonts) {
-               temp = string_dictionary_Fetch(termcap_dict, "E.bold");
-               if (temp)
+               if (temp = string_dictionary_Fetch(termcap_dict, "E.bold"))
                  item = string_Concat2(item, temp);
            } else if (info->italic_p && use_fonts) {
-               temp = string_dictionary_Fetch(termcap_dict, "E.u");
-               if (temp)
+               if (temp = string_dictionary_Fetch(termcap_dict, "E.u"))
                  item = string_Concat2(item, temp);
            }
 
index 3368c1fda41bbc6ad77a4edddccf189e67d743db..cda09d6e6ac2e11db2887d91a11d578944d0bc78 100644 (file)
@@ -56,8 +56,8 @@ static string_dictionary number_variable_dict = NULL;
  *        Effects: Returns true iff text matches [0-9]*.  ("" matches...)
  */
 
-static int
-is_digits(string text)
+static int is_digits(text)
+     string text;
 {
     for (; *text; text++)
       if (!isdigit(*text))
@@ -83,8 +83,7 @@ is_digits(string text)
  *        Effects: Sets all description langauge variables to "".
  */
 
-void
-var_clear_all_variables(void)
+void var_clear_all_variables()
 {
     if (non_number_variable_dict) {
        string_dictionary_SafeDestroy(non_number_variable_dict);
@@ -105,16 +104,15 @@ var_clear_all_variables(void)
  *                 call.  DO NOT FREE THIS STRING.
  */
 
-string
-var_get_variable(string name)
+string var_get_variable(name)
+     string name;
 {
     char *result;
     int field_to_get;
     static string last_get_field_call_result = NULL;
 
     if (is_number_variable(name)) {
-       result = string_dictionary_Fetch(number_variable_dict, name);
-       if (result)
+       if (result = string_dictionary_Fetch(number_variable_dict, name))
          return(result);
 
        /*
@@ -152,9 +150,9 @@ var_get_variable(string name)
  *                 to have the value value.
  */
 
-void
-var_set_variable(string name,
-                string value)
+void var_set_variable(name, value)
+     string name;
+     string value;
 {
     string_dictionary_Set(is_number_variable(name) ? number_variable_dict
                          : non_number_variable_dict, name, value);
@@ -169,9 +167,9 @@ var_set_variable(string name,
  *                 to have as its value number's ascii representation.
  */
 
-void
-var_set_variable_to_number(string name,
-                          int number)
+void var_set_variable_to_number(name, number)
+     string name;
+     int number;
 {
     char buffer[20];
 
@@ -192,9 +190,9 @@ var_set_variable_to_number(string name,
  *                 convenience reasons.
  */
 
-void
-var_set_variable_then_free_value(string name,
-                                string value)
+void var_set_variable_then_free_value(name, value)
+     string name;
+     string value;
 {
     string_dictionary_binding *binding;
     int exists;
@@ -231,9 +229,9 @@ var_set_variable_then_free_value(string name,
  *                 data or var_clear_all_variables is called.
  */
 
-void
-var_set_number_variables_to_fields(char *data,
-                                  int length)
+void var_set_number_variables_to_fields(data, length)
+     char *data;
+     int length;
 {
     fields_data = data;
     fields_data_length = length;
index b0be99b1ca20e1eeb2b80532c4cec3148e1318ce..6962341e2d2ec5a680f85eab951b44eee227defe 100644 (file)
@@ -27,7 +27,7 @@
  *        Effects: Sets all description langauge variables to "".
  */
 
-extern void var_clear_all_variables(void);
+extern void var_clear_all_variables();
 
 /*
  *    string var_get_variable(string name)
@@ -38,7 +38,7 @@ extern void var_clear_all_variables(void);
  *                 call.  DO NOT FREE THIS STRING.
  */
 
-extern string var_get_variable(string);
+extern string var_get_variable();
 
 /*
  *    void var_set_variable(string name, value)
@@ -49,7 +49,7 @@ extern string var_get_variable(string);
  *                 to have the value value.
  */
 
-extern void var_set_variable(string, string);
+extern void var_set_variable();
 
 /*
  *    void var_set_variable_to_number(string name; int number)
@@ -60,7 +60,7 @@ extern void var_set_variable(string, string);
  *                 to have as its value number's ascii representation.
  */
 
-extern void var_set_variable_to_number(string, int);
+extern void var_set_variable_to_number();
 
 /*
  *    void var_set_variable_then_free_value(string name, value)
@@ -75,7 +75,7 @@ extern void var_set_variable_to_number(string, int);
  *                 convenience reasons.
  */
 
-extern void var_set_variable_then_free_value(string, string);
+extern void var_set_variable_then_free_value();
 
 /*
  *    void var_set_number_variables_to_fields(char *data, int length)
@@ -91,6 +91,6 @@ extern void var_set_variable_then_free_value(string, string);
  *                 data or var_clear_all_variables is called.
  */
 
-extern void var_set_number_variables_to_fields(char *, int);
+extern void var_set_number_variables_to_fields();
 
 #endif
index 4fad2a71fa74bc32a992afa417033c3f3d25718a..cadfc3d94f3f34315d0488869c09646ffac95da4 100644 (file)
@@ -37,26 +37,26 @@ static const char rcsid_xcut_c[] = "$Id$";
 #include "xmark.h"
 #include "error.h"
 #include "xrevstack.h"
-#include "X_driver.h"
 
 /*
  *
  */
 
+extern char *xmarkGetText();
+
 extern long ttl;
 
 static char *selected_text=NULL;
 static Window selecting_in = 0;
 
-char *
-getSelectedText(void)
+char *getSelectedText()
 {
    return(selected_text);
 }
 
 #ifdef notdef
-static string
-x_gram_to_string(x_gram *gram)
+static string x_gram_to_string(gram)
+     x_gram *gram;
 {
     int i, index, len;
     int last_y = -1;
@@ -86,27 +86,27 @@ x_gram_to_string(x_gram *gram)
  */
 
 /*ARGSUSED*/
-Bool
-isShiftButton1(Display *dpy,
-              XEvent *event,
-              char *arg)
+Bool isShiftButton1(dpy,event,arg)
+     Display *dpy;
+     XEvent *event;
+     char *arg;
 {
    return(event->xbutton.state & (ShiftMask|Button1Mask));
 }
 
 /*ARGSUSED*/
-Bool
-isShiftButton3(Display *dpy,
-              XEvent *event,
-              char *arg)
+Bool isShiftButton3(dpy,event,arg)
+     Display *dpy;
+     XEvent *event;
+     char *arg;
 {
    return(event->xbutton.state & (ShiftMask|Button3Mask));
 }
 
-void
-getLastEvent(Display *dpy,
-            unsigned int state,
-            XEvent *event)
+void getLastEvent(dpy,state,event)
+     Display *dpy;
+     unsigned int state;
+     XEvent *event;
 {
    XEvent xev;
 
@@ -119,11 +119,11 @@ getLastEvent(Display *dpy,
    }
 }
 
-void
-xunmark(Display *dpy,
-       Window w,
-       x_gram *gram,
-       XContext desc_context)
+void xunmark(dpy,w,gram,desc_context)
+     Display *dpy;
+     Window w;
+     x_gram *gram;
+     XContext desc_context;
 {
    if (gram == NULL)
      if (XFindContext(dpy, w, desc_context, (caddr_t *) &gram))
@@ -144,11 +144,11 @@ xunmark(Display *dpy,
 
 static int current_pressop = PRESSOP_NONE;
 
-void
-xdestroygram(Display *dpy,
-            Window w,
-            XContext desc_context,
-            x_gram *gram)
+void xdestroygram(dpy,w,desc_context,gram)
+     Display *dpy;
+     Window w;
+     XContext desc_context;
+     x_gram *gram;
 {
     struct timeval now;
 
@@ -176,10 +176,10 @@ xdestroygram(Display *dpy,
     }
 }
 
-void
-xcut(Display *dpy,
-     XEvent *event,
-     XContext desc_context)
+void xcut(dpy,event,desc_context)
+     Display *dpy;
+     XEvent *event;
+     XContext desc_context;
 {
     x_gram *gram;
     Window w = event->xany.window;
index 4a5a0aed839c4c3dad543411a75dfdbf8086cd69..33e389a7c4c6c53437ec89a37c488172879b301b 100644 (file)
@@ -27,24 +27,24 @@ static const char rcsid_xerror_c[] = "$Id$";
 int xerror_happened;
 
 /*ARGSUSED*/
-static int
-xerrortrap(Display *dpy,
-          XErrorEvent *xerrev)
+static int xerrortrap(dpy,xerrev)
+     Display *dpy;
+     XErrorEvent *xerrev;
 {
    xerror_happened = 1;
    return 0;
 }
 
 /*ARGSUSED*/
-void
-begin_xerror_trap(Display *dpy)
+void begin_xerror_trap(dpy)
+     Display *dpy;
 {
    xerror_happened = 0;
    XSetErrorHandler(xerrortrap);
 }
 
-void
-end_xerror_trap(Display *dpy)
+void end_xerror_trap(dpy)
+     Display *dpy;
 {
    XSync(dpy,False);
    XSetErrorHandler(NULL);
index ea6702ede70f492d9945e345a8e6ea829db82e9e..d5a42e77ef79e7214759e2bcdda896d6d174e7a0 100644 (file)
@@ -22,7 +22,7 @@ static const char rcsid_xerror_h[] = "$Id$";
 
 extern int xerror_happened;
 
-void begin_xerror_trap(Display *);
-void end_xerror_trap(Display *);
+void begin_xerror_trap();
+void end_xerror_trap();
 
 #endif
index 6a6a7a077ce28e09a21b0ff1c2c3c33088a9aec4..1c796f33a889756235c63393073f239fbb6090ec 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #if (!defined(lint) && !defined(SABER))
-static const char rcsid_xmark_c[] = "$Id$";
+static char rcsid_xmark_c[] = "$Id$";
 #endif
 
 #include <zephyr/mit-copyright.h>
@@ -43,11 +43,10 @@ x_gram *oldgram = NULL;
    (STARTCHAR != -1) && (ENDCHAR != -1) && \
    (STARTPIXEL != -1) && (ENDPIXEL != -1))
 
-void
-xmarkSetBound(x_gram *gram,
-             int x,
-             int y,
-             int which)
+void xmarkSetBound(gram,x,y,which)
+     x_gram *gram;
+     int x,y;
+     int which;
 {
    int i,xofs,yofs;
    XFontStruct *font;
@@ -137,9 +136,8 @@ xmarkSetBound(x_gram *gram,
 }
 
 /* needs both bounds to be valid (!= -1) */
-static int
-xmarkNearest(int x,
-            int y)
+static int xmarkNearest(x,y)
+     int x,y;
 {
    int middle;
 
@@ -159,14 +157,11 @@ xmarkNearest(int x,
    }
 }
 
-void
-xmarkExpose(Display *dpy,
-           Window w,
-           x_gram *gram,
-           unsigned int b1,
-           unsigned int p1,
-           unsigned int b2,
-           unsigned int p2)
+void xmarkExpose(dpy,w,gram,b1,p1,b2,p2)
+     Display *dpy;
+     Window w;
+     x_gram *gram;
+     unsigned int b1,p1,b2,p2;
 {
 #define swap(x,y) temp=(x); (x)=(y); (y)=temp
    int i,temp;
@@ -231,11 +226,11 @@ xmarkExpose(Display *dpy,
 
 /* Public functions: */
 
-void
-xmarkRedraw(Display *dpy,
-           Window w,
-           x_gram *gram,
-           int range)
+void xmarkRedraw(dpy,w,gram,range)
+     Display *dpy;
+     Window w;
+     x_gram *gram;
+     int range;
 {
 #define ob1 ((unsigned int) oldblock[XMARK_START_BOUND])
 #define ob2 ((unsigned int) oldblock[XMARK_END_BOUND])
@@ -267,8 +262,7 @@ xmarkRedraw(Display *dpy,
 }
 
 /* needs both bounds to be valid (!= -1) */
-int
-xmarkSecond(void)
+int xmarkSecond()
 {
    if (STARTBLOCK > ENDBLOCK)
      return(XMARK_START_BOUND);
@@ -284,8 +278,7 @@ xmarkSecond(void)
    }
 }
 
-void
-xmarkClear(void)
+void xmarkClear()
 {
    oldblock[0]=markblock[0];
    oldblock[1]=markblock[1];
@@ -302,10 +295,9 @@ xmarkClear(void)
    markgram=NULL;
 }
 
-int
-xmarkExtendFromFirst(x_gram *gram,
-                    int x,
-                    int y)
+int xmarkExtendFromFirst(gram,x,y)
+     x_gram *gram;
+     int x,y;
 {
    if (markgram != gram) {
       xmarkClear();
@@ -325,10 +317,9 @@ xmarkExtendFromFirst(x_gram *gram,
    }
 }
 
-int
-xmarkExtendFromNearest(x_gram *gram,
-                      int x,
-                      int y)
+int xmarkExtendFromNearest(gram,x,y)
+     x_gram *gram;
+     int x,y;
 {
    int bound;
 
@@ -350,8 +341,7 @@ xmarkExtendFromNearest(x_gram *gram,
    }
 }
 
-char *
-xmarkGetText(void)
+char *xmarkGetText()
 {
     int i, index, len;
     int last_y = -1;
index 55c00c2cd673b2e514987338e91748107e444832..f440cde0ff9fe8baadb2a606b1db67d7b55c3e0c 100644 (file)
@@ -41,12 +41,11 @@ extern x_gram *markgram;
 #define STARTPIXEL (markpixel[XMARK_START_BOUND])
 #define ENDPIXEL   (markpixel[XMARK_END_BOUND])
 
-extern void xmarkSetBound(x_gram *, int, int, int);
-extern int xmarkSecond(void);
-extern void xmarkRedraw(Display *, Window, x_gram *, int);
-extern void xmarkClear(void);
-extern int xmarkExtendFromFirst(x_gram *, int, int);
-extern int xmarkExtendFromNearest(x_gram *, int, int);
-extern char *xmarkGetText(void);
+extern void xmarkSetBound();
+extern int xmarkSecond();
+extern void xmarkRedraw();
+extern void xmarkClear();
+extern int xmarkExtendFromStart();
+extern int xmarkExtendFromNearest();
 
 #endif
index 2bd3f266d7ea822497fe7d4e90ffa1137ff4da34..1549956a3bfdfcb2b85c8e1f962d54de9fbb5567 100644 (file)
@@ -28,8 +28,8 @@ x_gram *bottom_gram = NULL;
 x_gram *unlinked = NULL;
 int reverse_stack = 0;
 
-void
-add_to_bottom(x_gram *gram)
+void add_to_bottom(gram)
+     x_gram *gram;
 {
    if (bottom_gram) {
       bottom_gram->below = gram;
@@ -44,19 +44,17 @@ add_to_bottom(x_gram *gram)
 }
 
 /*ARGSUSED*/
-void
-pull_to_top(x_gram *gram)
-{
-}
+void pull_to_top(gram)
+     x_gram *gram;
+{}
 
 /*ARGSUSED*/
-void
-push_to_bottom(x_gram *gram)
-{
-}
+void push_to_bottom(gram)
+     x_gram *gram;
+{}
 
-void
-delete_gram(x_gram *gram)
+void delete_gram(gram)
+     x_gram *gram;
 {
    if (gram == bottom_gram) {
       if (gram->above) {
@@ -84,8 +82,8 @@ delete_gram(x_gram *gram)
    gram->above = gram;
 }
 
-void
-unlink_gram(x_gram *gram)
+void unlink_gram(gram)
+     x_gram *gram;
 {
    delete_gram(gram);
 
@@ -113,8 +111,8 @@ x_gram *bottom_gram=NULL;
 static x_gram *top_gram=NULL;
 
 #ifdef DEBUG
-void
-print_gram_list(char *str)
+void print_gram_list(str)
+char *str;
 {
    x_gram *gram;
    char buf[80];
@@ -137,8 +135,8 @@ print_gram_list(char *str)
 }
 #endif
 
-void
-pull_to_top(x_gram *gram)
+void pull_to_top(gram)
+x_gram *gram;
 {
    if (gram==top_gram) {
       /* already here */
@@ -168,8 +166,8 @@ pull_to_top(x_gram *gram)
 #endif
 }
 
-void
-push_to_bottom(x_gram *gram)
+void push_to_bottom(gram)
+x_gram *gram;
 {
    if (gram==bottom_gram) {
       /* already here */
@@ -201,8 +199,8 @@ push_to_bottom(x_gram *gram)
 #endif
 }
 
-void
-unlink_gram(x_gram *gram)
+void unlink_gram(gram)
+x_gram *gram;
 {
    if (top_gram==bottom_gram) {
       /* the only gram in the stack */
@@ -224,8 +222,8 @@ unlink_gram(x_gram *gram)
 }
 
 #ifdef notdef
-void
-add_to_top(x_gram *gram)
+void add_to_top(gram)
+x_gram *gram;
 {
    if (top_gram==NULL) {
       gram->above=NULL;
@@ -244,8 +242,8 @@ add_to_top(x_gram *gram)
 }
 #endif
 
-void
-add_to_bottom(x_gram *gram)
+void add_to_bottom(gram)
+x_gram *gram;
 {
    if (bottom_gram==NULL) {
       gram->above=NULL;
index 20d1fe9435dea51967f33e8941a937fe336c5d67..061d3d552054b89f64032a091d0afadd548b4f06 100644 (file)
@@ -15,7 +15,7 @@
 #define _XREVSTACK_H_
 
 #if (!defined(lint) && !defined(SABER))
-static const char rcsid_xrevstack_h[] = "$Id$";
+static char rcsid_xrevstack_h[] = "$Id$";
 #endif
 
 #include <zephyr/mit-copyright.h>
@@ -24,10 +24,10 @@ extern x_gram *bottom_gram; /* for testing against NULL */
 extern x_gram *unlinked;
 extern int reverse_stack; /* is reverse stack on? */
 
-extern void add_to_bottom(x_gram *);
-extern void delete_gram(x_gram *);
-extern void unlink_gram(x_gram *);
-extern void pull_to_top(x_gram *);
-extern void push_to_bottom(x_gram *);
+extern void add_to_bottom(/* x_gram */);
+extern void delete_gram(/* x_gram */);
+extern void unlink_gram(/* x_gram */);
+extern void pull_to_top(/* x_gram */);
+extern void push_to_bottom(/* x_gram */);
 
 #endif /* _XREVSTACK_H_ */
index 2192182cf5580447a83c87a269a8a1f57c81b467..9a686587319170ad62aae11dbcdefd3a0ba7d9d1 100644 (file)
@@ -30,7 +30,7 @@ static const char rcsid_xselect_c[] = "$Id$";
 #include "new_string.h"
 #include "xselect.h"
 
-extern char *getSelectedText(void);
+extern char *getSelectedText();
 
 static Time ownership_start = CurrentTime;
 static Time ownership_end = CurrentTime;
@@ -52,10 +52,10 @@ static struct _ZAtom {
 
 /* internal static functions */
 
-static void
-xselNotify(Display *dpy,
-          XSelectionRequestEvent *selreq,
-          Atom property)
+static void xselNotify(dpy,selreq,property)
+     Display *dpy;
+     XSelectionRequestEvent *selreq;
+     Atom property;
 {
    XSelectionEvent ev;
 
@@ -82,12 +82,11 @@ static Atom RequestAtoms[] = {
   XChangeProperty(dpy,w,PROP(property,target),(type),(format), \
                  PropModeReplace, (unsigned char *) (data),(size))
 
-static void
-xselSetProperties(Display *dpy,
-                 Window w,
-                 Atom property,
-                 Atom target,
-                 XSelectionRequestEvent *selreq)
+static void xselSetProperties(dpy,w,property,target,selreq)
+     Display *dpy;
+     Window w;
+     Atom property,target;
+     XSelectionRequestEvent *selreq;
 {
    if (target==ZA_TARGETS) {
 
@@ -118,8 +117,7 @@ xselSetProperties(Display *dpy,
    } else if (target==XA_STRING) {
       char *selected;
 
-      selected = getSelectedText();
-      if (selected) {
+      if (selected = getSelectedText()) {
         ChangeProp(XA_STRING,8,selected,string_Length(selected));
       } else {
         /* This should only happen if the pasting client is out of
@@ -138,8 +136,8 @@ xselSetProperties(Display *dpy,
 
 /* global functions */
 
-void
-xicccmInitAtoms(Display *dpy)
+void xicccmInitAtoms(dpy)
+     Display *dpy;
 {
    int i;
 
@@ -150,10 +148,10 @@ xicccmInitAtoms(Display *dpy)
        RequestAtoms[i] = *(pRequestAtoms[i]);
 }
 
-int
-xselGetOwnership(Display *dpy,
-                Window w,
-                Time time)
+int xselGetOwnership(dpy,w,time)
+     Display *dpy;
+     Window w;
+     Time time;
 {
    int temp;
 
@@ -167,10 +165,10 @@ xselGetOwnership(Display *dpy,
 }
 
 /* Get the selection.  Return !0 if success, 0 if fail */
-int
-xselProcessSelection(Display *dpy,
-                    Window w,
-                    XEvent *event)
+int xselProcessSelection(dpy,w,event)
+     Display *dpy;
+     Window w;
+     XEvent *event;
 {
    XSelectionRequestEvent *selreq = &(event->xselectionrequest);
 
@@ -180,8 +178,8 @@ xselProcessSelection(Display *dpy,
 #endif
 
    if ((ownership_start == CurrentTime) ||
-       (((selreq->time != CurrentTime) &&
-        (selreq->time < ownership_start)) ||
+       ((selreq->time != CurrentTime) &&
+       (selreq->time < ownership_start) ||
        ((ownership_end != CurrentTime) &&
         (ownership_end > ownership_start) &&
         (selreq->time > ownership_end))))
@@ -193,16 +191,16 @@ xselProcessSelection(Display *dpy,
    return(1);
 }
 
-void
-xselOwnershipLost(Time time)
+void xselOwnershipLost(time)
+     Time time;
 {
    ownership_end = time;
 }
 
 /*ARGSUSED*/
-void
-xselGiveUpOwnership(Display *dpy,
-                   Window w)
+void xselGiveUpOwnership(dpy,w)
+     Display *dpy;
+     Window w;
 {
    XSetSelectionOwner(dpy,XA_PRIMARY,None,ownership_start);
 
index f8fa964219c32b459f9ae9afa132893bb8378ceb..aa2a3fd139b0a542d9d0853de96e5f6abce788df 100644 (file)
 #ifndef _XSELECT_H_
 #define _XSELECT_H_
 
-extern void xicccmInitAtoms(Display *);
-extern int xselGetOwnership(Display *, Window, Time);
-extern int xselProcessSelection(Display *, Window, XEvent *);
-extern void xselOwnershipLost(Time);
-extern void xselGiveUpOwnership(Display *, Window);
+extern void xicccmInitAtoms();
+extern int xselGetOwnership();
+extern int xselProcessSelection();
+extern void xselOwnershipLost();
+extern void xselGiveUpOwnership();
 
-extern Atom XA_WM_PROTOCOLS, XA_WM_DELETE_WINDOW;
+extern int xwmprotoDelete();
+
+extern Atom XA_WM_PROTOCOLS,XA_WM_DELETE_WINDOW;
 
 #endif
index 666701336082d94d94c8db976ea12b32e71c5375..d970cccaa3ac89bb23cb7fec0cd2995f3310e775 100644 (file)
@@ -26,11 +26,9 @@ static const char rcsid_xshow_c[] = "$Id$";
 #include <X11/Xresource.h>
 #include "pointer_dictionary.h"
 #include "new_memory.h"
-#include "new_string.h"
 #include "formatter.h"
 #include "variables.h"
 #include "zwgc.h"
-#include "X_driver.h"
 #include "X_fonts.h"
 #include "X_gram.h"
 #include "xmode_stack.h"
@@ -38,13 +36,15 @@ static const char rcsid_xshow_c[] = "$Id$";
 #define max(a,b)   ((a)>(b)?(a):(b))
 
 XContext desc_context;
+static pointer_dictionary colorname_dict = NULL;
 
 extern int internal_border_width;
 extern unsigned long default_bgcolor;
 extern unsigned long default_fgcolor;
+extern unsigned long x_string_to_color();
 
 void
-xshowinit(void)
+xshowinit()
 {
     desc_context = XUniqueContext();
 }
@@ -55,9 +55,9 @@ struct res_dict_type {
     char *             resclass;
 };
 
-static char *
-xres_get_resource(struct res_dict_type *restype,
-                 char *style)
+static char *xres_get_resource (restype, style)
+    struct res_dict_type *restype;
+    char *style;
 {
    char *desc;
    pointer_dictionary_binding *binding;
@@ -102,10 +102,10 @@ static struct res_dict_type fgcolor_resources = {
 };
 
 /*ARGSUSED*/
-char *
-mode_to_colorname (Display *dpy,
-                  char *style,
-                  xmode *mode)
+char *mode_to_colorname (dpy, style, mode)
+    Display *dpy;
+    char *style;
+    xmode *mode;
 {
     char *desc, *result;
 
@@ -116,15 +116,16 @@ mode_to_colorname (Display *dpy,
     return result;
 }
 
-void
-fixup_and_draw(Display *dpy,
-              char *style,
-              xauxblock *auxblocks,
-              xblock *blocks,
-              int num,
-              xlinedesc *lines,
-              int numlines,
-              int beepcount)
+void fixup_and_draw(dpy, style, auxblocks, blocks, num, lines, numlines,
+                   beepcount)
+     Display *dpy;
+     char *style;
+     xblock *blocks;
+     xauxblock *auxblocks;
+     int num;
+     xlinedesc *lines;
+     int numlines;
+     int beepcount;
 {
     int gram_xalign = 1;
     int gram_yalign = 1;
@@ -337,8 +338,8 @@ fixup_and_draw(Display *dpy,
 }
 
 /* Silly almost-but-not-quite-useless helper function */
-char *
-no_dots_downcase_var(char *str)
+char *no_dots_downcase_var(str)
+     char *str;
 {
    register char *var, *var2;
 
@@ -353,11 +354,11 @@ no_dots_downcase_var(char *str)
 #define MODE_TO_FONT(dpy,style,mode) \
   get_font((dpy),(style),(mode)->font?(mode)->font:(mode)->substyle, \
           (mode)->size, (mode)->bold+(mode)->italic*2)
-void
-xshow(Display *dpy,
-      desctype *desc,
-      int numstr,
-      int numnl)
+void xshow(dpy, desc, numstr, numnl)
+     Display *dpy;
+     desctype *desc;
+     int numstr;
+     int numnl;
 {
     XFontStruct *font;
     xmode_stack modes = xmode_stack_create();
@@ -534,10 +535,10 @@ xshow(Display *dpy,
       free(style);
 }
 
-static void
-xhandleevent(Display *dpy,
-            Window w,
-            XEvent *event)
+static void xhandleevent(dpy, w, event)
+     Display *dpy;
+     Window w;
+     XEvent *event;
 {
     x_gram *gram;
     
@@ -552,8 +553,8 @@ xhandleevent(Display *dpy,
     XFlush(dpy);
 }
 
-void
-x_get_input(Display *dpy)
+void x_get_input(dpy)
+     Display *dpy;
 {
     XEvent event;
     
index f672d849ae5ef51930fee40583104385eb9ef5f2..9ad8dbe4aabc78bc2c72c5114e6ccfa8845f5860 100644 (file)
@@ -58,14 +58,13 @@ static unsigned short zephyr_port = 0;
  *                 modified in any way.
  */
 
-static string
-get_zwgc_port_number_filename(void)
+static string get_zwgc_port_number_filename()
 {
     static char buffer[40];
     char *temp;
+    char *getenv();
 
-    temp = getenv("WGFILE");
-    if (temp)
+    if (temp = getenv("WGFILE"))
       return(temp);
     else {
        sprintf(buffer, "/tmp/wg.%d", getuid());
@@ -77,8 +76,7 @@ get_zwgc_port_number_filename(void)
  *  Write out the port number to the wg file.
  */
 
-void
-write_wgfile(void)
+void write_wgfile()
 {
     char *name = get_zwgc_port_number_filename();
     FILE *port_file;
@@ -97,8 +95,8 @@ write_wgfile(void)
  *
  */
 
-static void
-handle_zephyr_input(void (*notice_handler)(ZNotice_t *))
+static void handle_zephyr_input(notice_handler)
+     void (*notice_handler)();
 {
     ZNotice_t *notice;
     struct sockaddr_in from;
@@ -126,7 +124,8 @@ handle_zephyr_input(void (*notice_handler)(ZNotice_t *))
  *
  */
 
-void zephyr_init(void (*notice_handler)(ZNotice_t *))
+void zephyr_init(notice_handler)
+     void (*notice_handler)();
 {
     char *temp;
     char *exposure;
@@ -171,8 +170,7 @@ void zephyr_init(void (*notice_handler)(ZNotice_t *))
      * not one of the allowed ones, print an error and treat it as
      * EXPOSE_NONE.
      */
-    temp = ZGetVariable("exposure");
-    if (temp) {
+    if (temp = ZGetVariable("exposure")) {
        if (!(exposure = ZParseExposureLevel(temp))) {
            ERROR2("invalid exposure level %s, using exposure level none instead.\n", temp);
            exposure = EXPOSE_NONE;
@@ -199,7 +197,7 @@ void zephyr_init(void (*notice_handler)(ZNotice_t *))
     /*
      * <<<>>>
      */
-    mux_add_input_source(ZGetFD(), (void (*)(void *))handle_zephyr_input,
+    mux_add_input_source(ZGetFD(), (void (*)())handle_zephyr_input,
                         notice_handler);
     zephyr_inited = 1;
     return;
@@ -209,7 +207,7 @@ void zephyr_init(void (*notice_handler)(ZNotice_t *))
  *
  */
 
-void finalize_zephyr(void) /* <<<>>> */
+void finalize_zephyr() /* <<<>>> */
 {
     string temp;
 
index 1e714a3d4f05646fa12acdae3f3bcfcfdcc9618b..98265df6d9a4ee99af1ec621921e1d969fa71161 100644 (file)
 #ifndef zephyr_MODULE
 #define zephyr_MODULE
 
-#include <zephyr/zephyr.h>
-
-extern void zephyr_init(void(*)(ZNotice_t *));
-extern void finalize_zephyr(void);
-extern void write_wgfile(void);
+extern void zephyr_init();
+extern void finalize_zephyr();
+extern void write_wgfile();
 
 #endif