diff options
author | Karl Ramm <kcr@mit.edu> | 2008-01-20 20:47:18 +0000 |
---|---|---|
committer | Karl Ramm <kcr@mit.edu> | 2008-01-20 20:47:18 +0000 |
commit | 06adfe440e910326106e56762fcef69f566a6bf7 (patch) | |
tree | 17bcb584c5678ab6ffd124ef2efa921d2d9a25a6 /clients | |
parent | fc8abb852f17e00ed7fd265e8e448e6e9537bab7 (diff) |
remove xzwrite, zmailnotify, zpopnotify
Diffstat (limited to 'clients')
30 files changed, 0 insertions, 4150 deletions
diff --git a/clients/xzwrite/GetString.c b/clients/xzwrite/GetString.c deleted file mode 100644 index 85e3463..0000000 --- a/clients/xzwrite/GetString.c +++ /dev/null @@ -1,125 +0,0 @@ -#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/clients/xzwrite/GetString.h b/clients/xzwrite/GetString.h deleted file mode 100644 index 562485d..0000000 --- a/clients/xzwrite/GetString.h +++ /dev/null @@ -1,9 +0,0 @@ -#include <X11/Intrinsic.h> - -#define GETSTRING_ACCEPT -1000 -#define GETSTRING_CANCEL -1001 - -Widget InitGetString(); -int GetString(); - - diff --git a/clients/xzwrite/Makefile.in b/clients/xzwrite/Makefile.in deleted file mode 100644 index 7ece4a9..0000000 --- a/clients/xzwrite/Makefile.in +++ /dev/null @@ -1,70 +0,0 @@ -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/clients/xzwrite/Popup.c b/clients/xzwrite/Popup.c deleted file mode 100644 index 616f594..0000000 --- a/clients/xzwrite/Popup.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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/clients/xzwrite/XZwrite.in b/clients/xzwrite/XZwrite.in deleted file mode 100644 index 691cc1c..0000000 --- a/clients/xzwrite/XZwrite.in +++ /dev/null @@ -1,249 +0,0 @@ -! @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/clients/xzwrite/associate.c b/clients/xzwrite/associate.c deleted file mode 100644 index db51e0b..0000000 --- a/clients/xzwrite/associate.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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/clients/xzwrite/associate.h b/clients/xzwrite/associate.h deleted file mode 100644 index a6ff2dc..0000000 --- a/clients/xzwrite/associate.h +++ /dev/null @@ -1,18 +0,0 @@ -#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/clients/xzwrite/bfgets.c b/clients/xzwrite/bfgets.c deleted file mode 100644 index 96636f9..0000000 --- a/clients/xzwrite/bfgets.c +++ /dev/null @@ -1,33 +0,0 @@ -/* 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/clients/xzwrite/dest_window.c b/clients/xzwrite/dest_window.c deleted file mode 100644 index 82831c3..0000000 --- a/clients/xzwrite/dest_window.c +++ /dev/null @@ -1,120 +0,0 @@ -#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 *) ¤t_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 *) ¤t_dest, (char *) &dest, - sizeof(DestRec)); - } -} diff --git a/clients/xzwrite/destlist.c b/clients/xzwrite/destlist.c deleted file mode 100644 index 8621922..0000000 --- a/clients/xzwrite/destlist.c +++ /dev/null @@ -1,414 +0,0 @@ -#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 *) ¤t_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(¬ice->z_sender, 1); -} - diff --git a/clients/xzwrite/edit_window.c b/clients/xzwrite/edit_window.c deleted file mode 100644 index 8c77bb0..0000000 --- a/clients/xzwrite/edit_window.c +++ /dev/null @@ -1,126 +0,0 @@ -#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(¤t_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(¤t_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(¤t_dest, buf); - - XawAsciiSourceFreeString(text_source); -} diff --git a/clients/xzwrite/gethomedir.c b/clients/xzwrite/gethomedir.c deleted file mode 100644 index ffd25bf..0000000 --- a/clients/xzwrite/gethomedir.c +++ /dev/null @@ -1,16 +0,0 @@ -#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/clients/xzwrite/interface.c b/clients/xzwrite/interface.c deleted file mode 100644 index 716e0e3..0000000 --- a/clients/xzwrite/interface.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * 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/clients/xzwrite/logins.c b/clients/xzwrite/logins.c deleted file mode 100644 index 66fe825..0000000 --- a/clients/xzwrite/logins.c +++ /dev/null @@ -1,97 +0,0 @@ -#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/clients/xzwrite/menu_window.c b/clients/xzwrite/menu_window.c deleted file mode 100644 index 2e11c90..0000000 --- a/clients/xzwrite/menu_window.c +++ /dev/null @@ -1,72 +0,0 @@ -#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/clients/xzwrite/resource.c b/clients/xzwrite/resource.c deleted file mode 100644 index 2c9d64f..0000000 --- a/clients/xzwrite/resource.c +++ /dev/null @@ -1,129 +0,0 @@ -#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/clients/xzwrite/util.c b/clients/xzwrite/util.c deleted file mode 100644 index f52ee7e..0000000 --- a/clients/xzwrite/util.c +++ /dev/null @@ -1,91 +0,0 @@ -#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/clients/xzwrite/xzwrite-proto.h b/clients/xzwrite/xzwrite-proto.h deleted file mode 100644 index baeccca..0000000 --- a/clients/xzwrite/xzwrite-proto.h +++ /dev/null @@ -1,104 +0,0 @@ -#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/clients/xzwrite/xzwrite.1 b/clients/xzwrite/xzwrite.1 deleted file mode 100644 index 20f3cd8..0000000 --- a/clients/xzwrite/xzwrite.1 +++ /dev/null @@ -1,407 +0,0 @@ -.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/clients/xzwrite/xzwrite.bitmap b/clients/xzwrite/xzwrite.bitmap deleted file mode 100644 index 2accd67..0000000 --- a/clients/xzwrite/xzwrite.bitmap +++ /dev/null @@ -1,6 +0,0 @@ -#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/clients/xzwrite/xzwrite.c b/clients/xzwrite/xzwrite.c deleted file mode 100644 index 318e5e9..0000000 --- a/clients/xzwrite/xzwrite.c +++ /dev/null @@ -1,122 +0,0 @@ -#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/clients/xzwrite/xzwrite.h b/clients/xzwrite/xzwrite.h deleted file mode 100644 index a9b020b..0000000 --- a/clients/xzwrite/xzwrite.h +++ /dev/null @@ -1,52 +0,0 @@ -#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/clients/xzwrite/yank.c b/clients/xzwrite/yank.c deleted file mode 100644 index bb580f1..0000000 --- a/clients/xzwrite/yank.c +++ /dev/null @@ -1,58 +0,0 @@ -#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/clients/xzwrite/zephyr.c b/clients/xzwrite/zephyr.c deleted file mode 100644 index 6e25dd5..0000000 --- a/clients/xzwrite/zephyr.c +++ /dev/null @@ -1,285 +0,0 @@ -#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(¬ice, &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(¬ice); - - else if (defs.auto_reply && - ! strcasecmp(notice.z_class, DEFAULT_CLASS) && - ! strcasecmp(notice.z_recipient, ZGetSender())) - dest_add_reply(¬ice); - - /* 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(¬ice); - } -} - -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 *) ¬ice, 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(¬ice, (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 *) ¬ice, 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(¬ice, ZNOAUTH)); -} - -int zeph_pong(dest) - Dest dest; -{ - ZNotice_t notice; - - (void) memset((char *) ¬ice, 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(¬ice, 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 *) ¬ice->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); -} diff --git a/clients/zmailnotify/Makefile.in b/clients/zmailnotify/Makefile.in deleted file mode 100644 index fc38fea..0000000 --- a/clients/zmailnotify/Makefile.in +++ /dev/null @@ -1,56 +0,0 @@ -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/clients/zmailnotify/zmailnotify.1 b/clients/zmailnotify/zmailnotify.1 deleted file mode 100644 index 3c6be20..0000000 --- a/clients/zmailnotify/zmailnotify.1 +++ /dev/null @@ -1,77 +0,0 @@ -.\" $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/clients/zmailnotify/zmailnotify.c b/clients/zmailnotify/zmailnotify.c deleted file mode 100644 index 5b1ed06..0000000 --- a/clients/zmailnotify/zmailnotify.c +++ /dev/null @@ -1,644 +0,0 @@ -/* 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 *)¬ice, 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(¬ice,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); -} diff --git a/clients/zpopnotify/Makefile.in b/clients/zpopnotify/Makefile.in deleted file mode 100644 index 55c63b6..0000000 --- a/clients/zpopnotify/Makefile.in +++ /dev/null @@ -1,56 +0,0 @@ -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/clients/zpopnotify/zpopnotify.8 b/clients/zpopnotify/zpopnotify.8 deleted file mode 100644 index 0d01923..0000000 --- a/clients/zpopnotify/zpopnotify.8 +++ /dev/null @@ -1,38 +0,0 @@ -.\" $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/clients/zpopnotify/zpopnotify.c b/clients/zpopnotify/zpopnotify.c deleted file mode 100644 index b2f79e3..0000000 --- a/clients/zpopnotify/zpopnotify.c +++ /dev/null @@ -1,104 +0,0 @@ -/* 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 *)¬ice, 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(¬ice,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); -} |