v04i036: xmtool -- X interface for ucbMail, Part01/03

Dan Heller argv at island.uu.net
Fri Jun 30 11:48:09 AEST 1989


Submitted-by: Peter Chang <chang at eds.com>
Posting-number: Volume 4, Issue 36
Archive-name: xmtool/part01

[ This is an interface for ucbMail using athena widgets.  This will not work
  on anything but Suns because all mail commands and options are hardcoded
  constants in the code and are Sun-Mail specific.  --argv ]

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix at uunet.uu.net if you want that tool.
# If this archive is complete, you will see the following message at the end:
#		"End of shell archive."
# Contents:  xmtool.c
# Wrapped by argv at maui on Thu Jun 29 18:32:18 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xmtool.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xmtool.c'\"
else
echo shar: Extracting \"'xmtool.c'\" \(55939 characters\)
sed "s/^X//" >'xmtool.c' <<'END_OF_FILE'
X#if !defined(lint) && !defined(NOSCCS)
Xstatic char rcsid[] = "@(#)xmtool.c	1.5 89/06/23 Peter Chang";
X#endif	lint
X/***********************************************************************
XCopyright 1989 by Electronic Data Systems Corporation
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the name of EDS not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XThis software was developed for testing the X11 Release 3 Toolkit
XIntrinsics and the Toolkit Athena Widgets. It is not a finished product
Xnor intended to be supported or under further development by EDS.
X
XEDS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XEDS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X******************************************************************/
X#include <stdio.h>
X#include <X11/Xatom.h>
X#include <X11/Intrinsic.h>
X#include <X11/IntrinsicP.h>
X#include <X11/StringDefs.h>
X#include <X11/Box.h>
X#include <X11/Clock.h>
X#include <X11/Command.h>
X#include <X11/Dialog.h>
X#include <X11/Label.h>
X#include <X11/Load.h>
X#include <X11/Scroll.h>
X#include <X11/AsciiText.h>
X#include <X11/AsciiTextP.h>
X#include <X11/VPaned.h>
X#include <X11/Viewport.h>
X#include <X11/Cardinals.h>
X#include <X11/Shell.h>
X#include <errno.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
Xint pid;
Xvoid createname();
Xvoid Destroyed(), quitOnCond();
Xchar mbxname[80];
Xchar logf1[40], logf2[40], logf3[40], logf4[40], logf5[40], logdir[40];
Xchar rplylogf[40], editlogf[40], createlogf[40];
Xchar logcmd1[80], logcmd2[80], logcmd3[80], savecmd[80], rplycmd[160], clrcmd[80];
Xchar clrcmd1[80], clrcmd2[80], clrcmd3[80], clrcmd4[80], clrcmd5[80], clrcmd6[80], clrcmd7[80], clrcmd8[80], clrcmd9[80];;
Xchar filename[110], editcmd[80], createcmd[80], mailtcmd[80], clrstatuscmd[80];
Xchar rplyinlogf[40], subj[45], ccl[45];
Xchar mailutildir[80],hlpfname[80];
Xint length = 400;
Xint countnew = 1, delete_sw = 0, minusflag = 0, editflag = 0, createflag = 0;
XWidget toplevel, outer, viewport, viewport2, box1, msgNumber, plusB, box2;;
XWidget form, command,textw, textw1, incrementB, minusB, incrB, viewB, rangeB;
XWidget viewport3, viewport4, outer2, outer3, box3, box4;
XWidget UpperLimit, resetB, deleteB, saveB, helpbutton;
XWidget stringW, box1hlp, box2hlp, viewporthlp, cmdhlp, donehlpw,selectw,rplyw, rplyallw;
XWidget editw, createw, mailtw, statusMailw, clrstatusw, updatew;
XWidget boxtextw, boxtextw1;
Xint topstack = 2;
Xstatic XrmOptionDescRec options[] = {
X{"-label",      XtNlabel,       XrmoptionSepArg,        NULL}
X};
Xstatic int increm = 1, count = 1, incremsw = 0, UpdateLflag = 1;
Xstatic int x1, y1, x2, y2;
Xint fp, helpflag = 0, selectflag = 0, selectList[1000], rplyallflag = 0;
Xint updateflag = 0;
Xstatic XtAppContext appcontxt;
Xstatic Pixel stringToPixel();
Xstatic Pixmap StringToPixmap();
X
Xstatic XtActionProc UpdateLine(inflag)
Xint inflag;
X{
X   struct _DiskSourceData {
X   /* resources */
X   char       *fileName;
X   /* private data */
X   Boolean     is_tempfile;
X   FILE *file;
X   XtTextPosition position,    /* file position of first char in buffer */
X   length;      /* length of file */
X   char *buffer;               /* piece of file in memory */
X   int charsInBuffer;          /* number of bytes used in memory */
X   } *wdata;
X
X   AsciiDiskWidget w;
X   XtTextPosition pos, pos0;
X   char c, text[10];
X   int i;
X   Arg arg[10];
X
X   pos = XtTextGetInsertionPoint(textw);
X   w = (AsciiDiskWidget)textw;
X   wdata = (struct _DiskSourceData *)(w->text.source->data);
X   pos0 = (XtTextPosition)ftell(wdata->file);
X   if (fseek(wdata->file, (int)pos, 0) != 0){
X     fprintf(stderr, "can't find msgnumber\n");
X     exit(-1);
X   }
X   bzero(text,10);
X   i = 0;
X   c = fgetc(wdata->file);
X   while ('0' > c || '9' < c){
X    i++;
X    if (i > 9) {
X     fprintf(stderr, "can't find msgnumber\n");
X     return;
X    }
X    c = fgetc(wdata->file);
X   }
X   i = 0;
X   while (c != ' '){
X    if (i > 9) {
X     fprintf(stderr, "can't find msgnumber\n");
X     return;
X    }
X    text[i] = c;
X    c = fgetc(wdata->file);
X    i++;
X   }
X   if (inflag == 0){
X    count = atoi(text);
X    bzero(text,10);
X    preparetext(count,text);
X    XtSetArg(arg[0], XtNlabel, text);
X    XtSetArg(arg[1], XtNresize, False);
X    XtSetValues((Widget)msgNumber, arg, 2);
X    UpdateLflag = 1;
X   } else {
X    countnew = atoi(text);
X    bzero(text,10);
X    preparetext(countnew,text);
X    XtSetArg(arg[0], XtNlabel, text);
X    XtSetArg(arg[1], XtNresize, False);
X    XtSetValues((Widget)UpperLimit, arg, 2);
X    UpdateLflag = 0;
X   }
X   if (fseek(wdata->file, (int)pos0, 0) != 0){
X     fprintf(stderr, "can't set pos0\n");
X     exit(-1);
X   }
X}
Xvoid help();
X
Xvoid quithlp0()
X{
X   struct _DiskSourceData {
X   /* resources */
X   char       *fileName;
X   /* private data */
X   Boolean     is_tempfile;
X   FILE *file;
X   XtTextPosition position,    /* file position of first char in buffer */
X   length;      /* length of file */
X   char *buffer;               /* piece of file in memory */
X   int charsInBuffer;          /* number of bytes used in memory */
X   } *wdata;
X
X    AsciiDiskWidget w;
X    if (cmdhlp != NULL){
X       XtDestroyWidget(cmdhlp);
X       XtUnmanageChild(cmdhlp);
X       cmdhlp = NULL;
X    }
X    if (textw1 != NULL) {
X       XtDestroyWidget(textw1);
X       XtUnmanageChild(textw1);
X       w = (AsciiDiskWidget)textw1;
X       wdata = (struct _DiskSourceData *)(w->text.source->data);
X       if (fclose(wdata->file) != 0){
X	 fprintf(stderr, "error closing file\n");
X	 exit(-1);
X       }
X       textw1 = NULL;
X    }
X    if (box2hlp != NULL) {
X       XtDestroyWidget(box2hlp);
X       XtUnmanageChild(box2hlp);
X       box2hlp = NULL;
X    }
X    if (boxtextw1 != NULL) {
X       XtDestroyWidget(boxtextw1);
X       XtUnmanageChild(boxtextw1);
X       boxtextw1 = NULL;
X    }
X}
X
Xvoid quithlp1()
X{
X    quithlp0();
X    if (box1hlp != NULL){
X       XtDestroyWidget(box1hlp);
X       XtUnmanageChild(box1hlp);
X       box1hlp = NULL;
X    }
X}
Xvoid print()
X{
X    Arg arg[10];
X    int i, j, len, fp, num;
X    char text[400];
X    if ((fp = creat(logf3, 0700)) < 0){
X       perror("open problem");
X       exit(-1);
X    };
X    if (selectflag){
X       num = selectflag / 15;
X       num++;
X       for (j=0; j < num; j++){
X        bzero(text, 400);
X        sprintf(text, "p %d", selectList[j*15]);
X        for (i = 1; i <  umailmin(15,selectflag - j*15); i++){
X	  len = strlen(text);
X	  sprintf(&text[len], " %d", selectList[i+j*15]);
X        }
X        len = strlen(text);
X        sprintf(&text[len], "\n");
X        write(fp, text, strlen(text));
X       }
X    }
X    else {
X       bzero(text, 400);
X       if (delete_sw == 0)
X          sprintf(text, "p %d", count);
X       else {
X          sprintf(text, "p %d-%d", count, countnew);
X       }
X       write(fp, text, strlen(text));
X    }
X    close(fp);
X    system(logcmd2);
X    quithlp1();
X    boxtextw1 = XtCreateManagedWidget(NULL, boxWidgetClass, viewport4, NULL, 0);
X    XtSetArg( arg[0], XtNfile, logf2);
X    XtSetArg( arg[1], XtNtextOptions, scrollVertical );
X    XtSetArg( arg[2], XtNfromVert, viewport3);
X    XtSetArg( arg[3], XtNwidth, 990);
X    XtSetArg( arg[4], XtNheight, 250);
X    XtSetArg( arg[5], XtNbackground, stringToPixel(outer,"yellow"));
X    textw1 = XtCreateManagedWidget( NULL, asciiDiskWidgetClass, boxtextw1, arg, 6 );
X}
Xvoid selectf()
X{
X    selectList[selectflag] = count;
X    selectflag++;
X}
Xvoid quithlp()
X{
X    quithlp0();
X    help();
X}
Xvoid closefd() /* assume that fd is increased by 1*/
X{
X    register int i;
X    for (i = 30; i > 2; i--){
X       if (close(i) >= 0)
X       {
X	 fprintf(stderr, "close fd %d\n", i);
X	 return;
X       }
X    }
X    perror("can't close more file descriptor");
X    exit(-1);
X}
Xvoid dpyhlp(fname)
Xchar fname[];
X{
X    register int i = 0;
X    Arg arg[10];
X
X    quithlp1();
X    XtSetArg( arg[0], XtNheight, 240);
X    XtSetArg( arg[1], XtNwidth, 990);
X    XtSetArg( arg[2], XtNallowVert, False);
X    XtSetArg( arg[3], XtNallowHoriz, False);
X    box2hlp = XtCreateManagedWidget( NULL, boxWidgetClass, viewport4,
X				arg, 4 );
X    cmdhlp = XtCreateManagedWidget( "quit", commandWidgetClass, box2hlp, NULL, 0);
X    XtAddCallback(cmdhlp, XtNcallback, quithlp, NULL);
X
X    XtSetArg( arg[0], XtNfile, fname);
X    XtSetArg( arg[1], XtNtextOptions, scrollVertical );
X    XtSetArg( arg[2], XtNheight, 230);
X    XtSetArg( arg[3], XtNwidth, 990);
X    XtSetArg( arg[4], XtNfromVert, viewport3);
X    XtSetArg( arg[5], XtNx, x2);
X    XtSetArg( arg[6], XtNy, y2);
X    textw1 = XtCreateManagedWidget( NULL, asciiDiskWidgetClass, box2hlp, arg, 7 );
X}
Xvoid inputboxhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/inputboxhlp");
X    dpyhlp(hlpfname);
X}
Xvoid msgNumberhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/msgNumberhlp");
X    dpyhlp(hlpfname);
X}
Xvoid incrementBhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/incrementBhlp");
X    dpyhlp(hlpfname);
X}
Xvoid UpperLimithlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/UpperLimithlp");
X    dpyhlp(hlpfname);
X}
Xvoid plusBhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/plusBhlp");
X    dpyhlp(hlpfname);
X}
Xvoid minusBhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/minusBhlp");
X    dpyhlp(hlpfname);
X}
Xvoid incrBhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/incrBhlp");
X    dpyhlp(hlpfname);
X}
Xvoid viewBhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/viewBhlp");
X    dpyhlp(hlpfname);
X}
Xvoid rangeBhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/rangeBhlp");
X    dpyhlp(hlpfname);
X}
Xvoid resetBhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/setCounterhlp");
X    dpyhlp(hlpfname);
X}
Xvoid deleteBhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/deleteBhlp");
X    dpyhlp(hlpfname);
X}
Xvoid saveBhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/saveBhlp");
X    dpyhlp(hlpfname);
X}
Xvoid selecthlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/selecthlp");
X    dpyhlp(hlpfname);
X}
Xvoid rplyhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/rplyhlp");
X    dpyhlp(hlpfname);
X}
Xvoid rplyallhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/rplyallhlp");
X    dpyhlp(hlpfname);
X}
Xvoid edithlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/edithlp");
X    dpyhlp(hlpfname);
X}
Xvoid createhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/createhlp");
X    dpyhlp(hlpfname);
X}
Xvoid mailthlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/mailthlp");
X    dpyhlp(hlpfname);
X}
Xvoid statushlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/statushlp");
X    dpyhlp(hlpfname);
X}
Xvoid clrstatushlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/clrstatushlp");
X    dpyhlp(hlpfname);
X}
Xvoid updatehlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/updatehlp");
X    dpyhlp(hlpfname);
X}
Xvoid helpbuttonhlpf()
X{
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/hlp/helpbuttonhlp");
X    dpyhlp(hlpfname);
X}
X
Xvoid donehlp()
X{
X    quithlp1();
X    print();
X}
X
Xvoid help()
X{
X    Arg arg[10];
X    Widget msgNumberhlp, plusBhlp;
X    Widget commandhlp,incrementBhlp, minusBhlp, incrBhlp, viewBhlp, rangeBhlp;
X    Widget UpperLimithlp, resetBhlp, deleteBhlp, saveBhlp, helpbuttonhlp;
X    Widget inputboxhlp, stringWhlp;
X    Widget selecthlp, rplyhlp, rplyallhlp, edithlp, createhlp, mailthlp;
X    Widget statushlp, clrstatushlp, updatehlp;
X    helpflag = 1;
X    quithlp1();
X
X    box1hlp = XtCreateManagedWidget( NULL, boxWidgetClass, viewport4,
X				NULL, ZERO );
X
X    donehlpw = XtCreateManagedWidget(  "quit", commandWidgetClass,
X				box1hlp, NULL, 0);
X    XtAddCallback( donehlpw, XtNcallback, donehlp, (caddr_t)incrementB );
X    XtSetArg(arg[0],XtNwidth, 930);
X    XtSetArg( arg[1], XtNlabel, "Press the following buttons to get help");
X    XtSetArg( arg[2], XtNallowVert, False);
X    command = XtCreateManagedWidget( "label", labelWidgetClass,
X					 box1hlp, arg, 3 );
X
X    msgNumberhlp = XtCreateManagedWidget("001", commandWidgetClass,
X				box1hlp, NULL, ZERO );
X    XtAddCallback( msgNumberhlp, XtNcallback, msgNumberhlpf, (caddr_t)incrementB );
X
X    XtSetArg(arg[0],XtNfromHoriz,msgNumberhlp);
X    UpperLimithlp = XtCreateManagedWidget("001", commandWidgetClass,
X				box1hlp, arg, ONE);
X    XtAddCallback( UpperLimithlp, XtNcallback, UpperLimithlpf, (caddr_t)incrementB );
X
X    XtSetArg(arg[0],XtNfromHoriz,UpperLimithlp);
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/bitmap/f1");
X    XtSetArg(arg[1], XtNbitmap, StringToPixmap(outer,hlpfname));
X    plusBhlp = XtCreateManagedWidget( "plus", commandWidgetClass,
X				box1hlp, arg, TWO);
X    XtAddCallback( plusBhlp, XtNcallback, plusBhlpf, (caddr_t)msgNumber );
X
X    XtSetArg(arg[0],XtNfromHoriz,plusBhlp);
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/bitmap/f2");
X    XtSetArg(arg[1], XtNbitmap, StringToPixmap(outer,hlpfname));
X    minusBhlp = XtCreateManagedWidget( "minus", commandWidgetClass,
X				box1hlp, arg, TWO);
X    XtAddCallback( minusBhlp, XtNcallback, minusBhlpf, (caddr_t)msgNumber );
X
X    XtSetArg(arg[0],XtNfromHoriz,minusBhlp);
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/bitmap/f3");
X    XtSetArg(arg[1], XtNbitmap, StringToPixmap(outer,hlpfname));
X    rangeBhlp = XtCreateManagedWidget( "range", commandWidgetClass,
X				box1hlp, arg, TWO);
X    XtAddCallback( rangeBhlp, XtNcallback, rangeBhlpf, (caddr_t)UpperLimit );
X
X    XtSetArg(arg[0],XtNfromHoriz,rangeBhlp);
X    resetBhlp = XtCreateManagedWidget( "set counter", commandWidgetClass,
X				box1hlp, arg, ONE);
X    XtAddCallback( resetBhlp, XtNcallback, resetBhlpf, (caddr_t)UpperLimit );
X
X    XtSetArg(arg[0],XtNfromHoriz,resetBhlp);
X    viewBhlp = XtCreateManagedWidget( "view", commandWidgetClass,
X				box1hlp, arg, ONE);
X    XtAddCallback( viewBhlp, XtNcallback, viewBhlpf, (caddr_t)msgNumber );
X
X    XtSetArg(arg[0],XtNfromHoriz,viewBhlp);
X    deleteBhlp = XtCreateManagedWidget( "delete", commandWidgetClass,
X				box1hlp, arg, ONE);
X    XtAddCallback( deleteBhlp, XtNcallback, deleteBhlpf, (caddr_t)msgNumber );
X
X    XtSetArg(arg[0],XtNfromHoriz,deleteBhlp);
X    saveBhlp = XtCreateManagedWidget( "save", commandWidgetClass,
X				box1hlp, arg, ONE);
X    XtAddCallback( saveBhlp, XtNcallback, saveBhlpf, (caddr_t)msgNumber );
X
X    XtSetArg(arg[0],XtNfromHoriz,saveBhlp);
X    inputboxhlp = XtCreateManagedWidget( "input box", commandWidgetClass,
X				box1hlp, arg, ONE);
X    XtAddCallback( inputboxhlp, XtNcallback, inputboxhlpf, (caddr_t)msgNumber );
X
X    XtSetArg(arg[0],XtNfromHoriz,inputboxhlp);
X    XtSetArg(arg[1],XtNwidth, 430);
X    stringW = XtCreateManagedWidget(" ", labelWidgetClass,
X			     box1hlp, arg, TWO);
X
X    XtSetArg(arg[0],XtNfromVert,msgNumberhlp);
X    incrementBhlp = XtCreateManagedWidget(  "001", commandWidgetClass,
X				box1hlp, arg, ONE );
X    XtAddCallback( incrementBhlp, XtNcallback, incrementBhlpf, (caddr_t)incrementB );
X
X    XtSetArg(arg[0],XtNfromHoriz,incrementBhlp);
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/bitmap/f1");
X    XtSetArg(arg[1], XtNbitmap, StringToPixmap(outer,hlpfname));
X    incrBhlp = XtCreateManagedWidget( "incr", commandWidgetClass,
X				box1hlp, arg, TWO );
X    XtAddCallback( incrBhlp, XtNcallback, incrBhlpf, (caddr_t)incrementB );
X
X    selecthlp = XtCreateManagedWidget( "select", commandWidgetClass,
X				box1hlp, NULL, ZERO);
X    XtAddCallback( selecthlp, XtNcallback, selecthlpf, NULL);
X
X    rplyhlp = XtCreateManagedWidget( "reply to sender", commandWidgetClass,
X				box1hlp, NULL, ZERO);
X    XtAddCallback( rplyhlp, XtNcallback, rplyhlpf, NULL);
X
X    rplyallhlp = XtCreateManagedWidget( "reply to all", commandWidgetClass,
X				box1hlp, NULL, ZERO);
X    XtAddCallback( rplyallhlp, XtNcallback, rplyallhlpf, NULL);
X
X    edithlp = XtCreateManagedWidget( "edit", commandWidgetClass,
X				box1hlp, NULL, ZERO);
X    XtAddCallback( edithlp, XtNcallback, edithlpf, NULL);
X
X    createhlp = XtCreateManagedWidget( "create", commandWidgetClass,
X				box1hlp, NULL, ZERO);
X    XtAddCallback( createhlp, XtNcallback, createhlpf, NULL);
X
X    mailthlp = XtCreateManagedWidget( "mail to list", commandWidgetClass,
X				box1hlp, NULL, ZERO);
X    XtAddCallback( mailthlp, XtNcallback, mailthlpf, NULL);
X
X    statushlp = XtCreateManagedWidget( "status", commandWidgetClass,
X				box1hlp, NULL, ZERO);
X    XtAddCallback( statushlp, XtNcallback, statushlpf, NULL);
X
X    clrstatushlp = XtCreateManagedWidget( "clear status", commandWidgetClass,
X				box1hlp, NULL, ZERO);
X    XtAddCallback( clrstatushlp, XtNcallback, clrstatushlpf, NULL);
X
X    updatehlp = XtCreateManagedWidget( "update", commandWidgetClass,
X				box1hlp, NULL, ZERO);
X    XtAddCallback( updatehlp, XtNcallback, updatehlpf, NULL);
X
X    XtSetArg(arg[0],XtNfromHoriz,updatehlp);
X    helpbuttonhlp = XtCreateManagedWidget( "help", commandWidgetClass,
X				box1hlp, arg, ONE );
X    XtAddCallback( helpbuttonhlp, XtNcallback, helpbuttonhlpf, (caddr_t)incrementB );
X
X}
X
Xvoid quithlp2()
X{
X   struct _DiskSourceData {
X   /* resources */
X   char       *fileName;
X   /* private data */
X   Boolean     is_tempfile;
X   FILE *file;
X   XtTextPosition position,    /* file position of first char in buffer */
X   length;      /* length of file */
X   char *buffer;               /* piece of file in memory */
X   int charsInBuffer;          /* number of bytes used in memory */
X   } *wdata;
X
X    AsciiDiskWidget w;
X    if (textw != NULL) {
X       XtDestroyWidget(textw);
X       XtUnmanageChild(textw);
X       w = (AsciiDiskWidget)textw;
X       wdata = (struct _DiskSourceData *)(w->text.source->data);
X       if (fclose(wdata->file) != 0){
X	 fprintf(stderr, "error closing file\n");
X	 exit(-1);
X       }
X       textw = NULL;
X    }
X    if (boxtextw != NULL) {
X       XtDestroyWidget(boxtextw);
X       XtUnmanageChild(boxtextw);
X       boxtextw = NULL;
X    }
X}
Xvoid delete()
X{
X    int i, j, len, fp, num;
X    Arg arg[10];
X    char text[400];
X   struct _DiskSourceData {
X   /* resources */
X   char       *fileName;
X   /* private data */
X   Boolean     is_tempfile;
X   FILE *file;
X   XtTextPosition position,    /* file position of first char in buffer */
X   length;      /* length of file */
X   char *buffer;               /* piece of file in memory */
X   int charsInBuffer;          /* number of bytes used in memory */
X   } *wdata;
X   XtTextPosition currentPos;
X   AsciiDiskWidget ascW;
X
X    if ((fp = creat(logf3, 0700)) < 0){
X       perror("open problem");
X       exit(-1);
X    };
X    if (selectflag){
X       num = selectflag / 15;
X       num++;
X       for (j = 0; j < num; j++){
X	bzero(text, 400);
X        sprintf(text, "d %d", selectList[j*15]);
X        for (i = 1; i <  umailmin(15,selectflag - j*15) ; i++){
X	   len = strlen(text);
X	   sprintf(&text[len], " %d", selectList[i+j*15]);
X        }
X        len = strlen(text);
X        sprintf(&text[len], "\n");
X        write(fp, text, strlen(text));  
X       }
X       selectflag = 0;
X    }
X    else {
X       bzero(text, 400);
X       if (delete_sw == 0)
X          sprintf(text, "d %d\n", count);
X       else {
X          sprintf(text, "d %d-%d\n", count, countnew);
X          delete_sw = 0;
X       }
X       write(fp, text, strlen(text));  
X    }
X    close(fp);
X
X    /* update current position */
X    ascW = (AsciiDiskWidget)textw;
X    wdata = (struct _DiskSourceData *)(ascW->text.source->data);
X    currentPos = wdata->position;
X
X    quithlp2();
X    system(logcmd3);
X    system(logcmd1);
X    XtSetArg( arg[0], XtNheight, 250);
X    XtSetArg( arg[1], XtNwidth, 990);
X    XtSetArg( arg[2], XtNallowVert, False);
X    XtSetArg( arg[3], XtNallowHoriz, False);
X    boxtextw = XtCreateManagedWidget(NULL, boxWidgetClass, viewport3, arg, 4);
X    XtSetArg( arg[0], XtNfile, logf1 );
X    XtSetArg( arg[1], XtNtextOptions, scrollVertical );
X    XtSetArg( arg[2], XtNheight, 250);
X    XtSetArg( arg[3], XtNwidth, 990);
X    XtSetArg( arg[4], XtNx, x1);
X    XtSetArg( arg[5], XtNy, y1);
X    XtSetArg( arg[6], XtNmappedWhenManaged, False);
X    XtSetArg( arg[7], XtNbackground, stringToPixel(outer,"light blue"));
X    textw = XtCreateManagedWidget( NULL, asciiDiskWidgetClass, boxtextw, arg, 8 );
X    ascW = (AsciiDiskWidget)textw;
X    if (updateflag) {
X       currentPos = 0;
X       updateflag = 0;
X    } else {
X       for (i = 0; i < wdata->charsInBuffer; i++)
X          if (*(wdata->buffer + i) == '\n') {
X             currentPos += i + 1;
X             break;
X          }
X    }
X    XtTextSetSource(ascW, ascW->text.source, currentPos);
X    XtSetArg( arg[0], XtNmappedWhenManaged, True);
X    XtSetValues( textw, arg, 1);
X}
X
Xvoid quitOnCond()
X{
X    system(clrcmd);
X    XtDestroyWidget(toplevel);
X}
X
Xvoid Quit(widget,closure,callData)
X    Widget widget;
X    caddr_t closure;		/* Widget */
X    caddr_t callData;
X{
X    quitOnCond();
X    exit(0);
X}
X
Xvoid resetf(widget, closure, callData)
X    Widget widget;
X    caddr_t closure;		/* Widget */
X    caddr_t callData;
X{
X    Arg arg[2];
X    char text[10];
X    int i;
X    if (!delete_sw && !minusflag && !selectflag){
X       UpdateLine(0);
X       countnew = count;
X       preparetext(countnew, text);
X       XtSetArg( arg[0], XtNlabel, text);
X       XtSetArg(arg[1], XtNresize, False);
X       XtSetValues( (Widget)UpperLimit, arg, (Cardinal) 2);
X    }
X    delete_sw = 0;/* reset range and minus */
X    minusflag = 0;
X    selectflag = 0;
X    bzero(text, 10);
X    if (!increm){
X       i = atoi(filename);
X       if (0 < i && i < 1000){
X	  count = i;
X	  countnew = i;
X	  preparetext(i, text);
X          XtSetArg( arg[0], XtNlabel, text);
X          XtSetArg(arg[1], XtNresize, False);
X          XtSetValues( (Widget)msgNumber, arg, (Cardinal) 2);
X          XtSetValues( (Widget)UpperLimit, arg, (Cardinal) 2);
X       }	  
X       return;
X    }
X}
Xvoid deleteswitch(widget, closure, callData) /* range */
X    Widget widget;
X    caddr_t closure;		/* Widget */
X    caddr_t callData;
X{
X    Arg arg[10];
X    char text[10];
X    if (UpdateLflag){
X     UpdateLine(1);
X    } else {
X     bzero(text, 10);
X     if (minusflag) {
X        countnew = countnew - increm;
X     } else
X        countnew = countnew + increm;
X     preparetext(countnew, text);
X     XtSetArg( arg[0], XtNwidth, 40);
X     XtSetArg( arg[1], XtNlabel, text);
X     XtSetArg( arg[2], XtNallowVert, False );
X     XtSetArg( arg[3], XtNallowHoriz, False );
X     XtSetValues( (Widget)closure, arg, (Cardinal) 4);
X    }
X    if (countnew < count){
X      return;
X    }
X    delete_sw = 1;
X}
X
Xvoid Count(widget, closure, callData) /* plus */
X    Widget widget;
X    caddr_t closure;		/* Widget */
X    caddr_t callData;
X{
X    Arg arg[10];
X    char text[10];
X    minusflag = 0;
X    bzero(text, 10);
X    count = count + increm;
X    preparetext(count, text);
X    XtSetArg( arg[0], XtNwidth, 40);
X    XtSetArg( arg[1], XtNlabel, text);
X    XtSetArg( arg[2], XtNallowVert, False );
X    XtSetArg( arg[3], XtNallowHoriz, False );
X    XtSetValues( (Widget)closure, arg, (Cardinal) 3);
X}
X
Xvoid Count1(widget, closure, callData) /* minus */
X    Widget widget;
X    caddr_t closure;		/* Widget */
X    caddr_t callData;
X{
X    Arg arg[10];
X    char text[10];
X    minusflag = 1;
X    if (delete_sw) return;
X    bzero(text, 10);
X    count = count - increm;
X    preparetext(count, text);
X    XtSetArg( arg[0], XtNwidth, 40);
X    XtSetArg( arg[1], XtNlabel, text);
X    XtSetArg( arg[2], XtNallowVert, False );
X    XtSetArg( arg[3], XtNallowHoriz, False );
X    XtSetValues( (Widget)closure, arg, (Cardinal) 4);
X}
Xvoid Count2(widget, closure, callData) /* incr in increment */
X    Widget widget;
X    caddr_t closure;		/* Widget */
X    caddr_t callData;
X{
X    Arg arg[10];
X    char text[10];
X    register int i;
X    if (incremsw == 0){
X       increm = 10;
X       incremsw++;
X    } else if (incremsw == 1){
X       increm = 100;
X       incremsw++;
X    } else if (incremsw == 2){
X       increm = 0;
X       incremsw++;
X    } else {
X       increm = 1;
X       incremsw = 0;
X    }
X    bzero(text, 10);
X    preparetext(increm, text);
X    XtSetArg( arg[0], XtNwidth, 40);
X    XtSetArg( arg[1], XtNlabel, text);
X    XtSetArg( arg[2], XtNallowVert, False );
X    XtSetArg( arg[3], XtNallowHoriz, False );
X    XtSetValues( (Widget)closure, arg, 4);
X}
Xvoid save(widget, clientData, callData)
X    Widget widget;
X    caddr_t clientData;		/* Boolean* */
X    caddr_t callData;
X{
X    struct stat stbuf;
X    int i, j, fd, fp, len, num;
X    char msg[80];
X    char text[400], dirname[40];
X    bzero(dirname, 40);
X    parsefname(dirname);
X    if ((i = stat(dirname, &stbuf)) != 0) {
X	  if ((fd = open(logf4, 2)) < 0) {
X	     perror("open problem");
X	     quitOnCond();
X	     exit(-1);
X	  }
X	  if (lseek(fd, 0L, 2) < 0){
X	     perror("lseek problem");
X	     quitOnCond();
X	     exit(-1);
X	  }
X	  bzero(msg, 80);
X	  strcpy(msg,  "Mail Tool: save -- Invalid directory: ");
X	  strcat(msg, dirname);
X	  strcat(msg, "\n");
X	  if (write(fd, msg, strlen(msg)) < 0){
X	     perror("write problem");
X	     quitOnCond();
X	     exit(-1);
X	  }
X	  close(fd);
X	  return;
X    }
X    if ((fp = creat(logf3, 0700)) < 0){
X       perror("open problem");
X       exit(-1);
X    };
X    if (selectflag){
X       num = selectflag / 15;
X       num++;
X       for (j=0; j < num; j++){
X        bzero(text, 400); 
X        sprintf(text, "s %d", selectList[j*15]);
X        for (i = 1; i <  umailmin(15,selectflag - j*15); i++){
X	   len = strlen(text);
X	   sprintf(&text[len], " %d", selectList[i+j*15]);
X        }
X        strcat(text, " ");
X        strcat(text, filename);
X        len = strlen(text);
X        sprintf(&text[len], "\n");
X        write(fp, text, strlen(text));
X       }
X    }
X    else {
X       bzero(text, 400); 
X       if (delete_sw == 0)
X          sprintf(text, "s %d", count);
X       else {
X          sprintf(text, "s %d-%d", count, countnew);
X       }
X       strcat(text, " ");
X       strcat(text, filename);
X       write(fp, text, strlen(text));
X    }
X    close(fp);
X    system(savecmd);
X}
Xvoid rplyf()
X{
X    Arg arg[10];
X    int i, len, fd, fp;
X    char text[400], users[45], subj[45], ccl[45], rplyusrcmd[80];
X    if (filename[0] == '=' && filename[1] == '>') {
X       bzero(users, 45);
X       bzero(rplyusrcmd, 80);
X       for (i=2; i < 47; i++)
X	  filename[i-2] = filename[i];
X/* handle subject and cc list */
X       bzero(subj, 45);
X       bzero(ccl, 45);
X       parseSubCc(users, subj, ccl);
X       if (subj[0] != 0 || ccl[0] != 0){
X	  if ((fd = open(rplylogf, 2)) < 0) {
X	     perror("open problem");
X	     quitOnCond();
X	     exit(-1);
X	  }
X	  if (lseek(fd, 0L, 2) < 0){
X	     perror("lseek problem");
X	     quitOnCond();
X	     exit(-1);
X	  }
X          if (subj[0] != 0){
X	     if (write(fd, "~s ", 3) != 3){
X	        perror("write problem");
X	        quitOnCond();
X	        exit(-1);
X	     }
X	     i = strlen(subj);
X	     if (write(fd, subj, i) != i){
X	        perror("write problem");
X	        quitOnCond();
X	        exit(-1);
X	     }
X	     if (write(fd, "\n", 1) != 1){
X	        perror("write problem");
X	        quitOnCond();
X	        exit(-1);
X	     }
X	  }
X          if (ccl[0] != 0){
X	     if (write(fd, "~c ", 3) != 3){
X	        perror("write problem");
X	        quitOnCond();
X	        exit(-1);
X	     }
X	     i = strlen(ccl);
X	     if (write(fd, ccl, i) != i){
X	        perror("write problem");
X	        quitOnCond();
X	        exit(-1);
X	     }
X	     if (write(fd, "\n", 1) != 1){
X	        perror("write problem");
X	        quitOnCond();
X	        exit(-1);
X	     }
X	  }
X	  close(fd);
X       }
X       strcpy(rplyusrcmd, "mail ");
X       if (mbxname[0] != 0){
X	strcat(rplyusrcmd,"-f ");
X	strcat(rplyusrcmd,mbxname);
X	strcat(rplyusrcmd," ");
X       }
X       strcat(rplyusrcmd, users);
X       strcat(rplyusrcmd, " <");
X       strcat(rplyusrcmd, rplylogf);
X       strcat(rplyusrcmd, " >>");
X       strcat(rplyusrcmd, logf4);
X       system(rplyusrcmd);
X       if (rplyallflag) rplyallflag = 0;
X       return;
X    }
X    system(clrcmd5);
X    system(clrcmd8);
X    bzero(text, 400);
X    if ((fp = creat(rplyinlogf, 0700)) < 0){
X       perror("open problem");
X       exit(-1);
X    };
X    if (selectflag){
X       if (!rplyallflag)
X          sprintf(text, "r %d", selectList[0]);
X       else {
X          sprintf(text, "R %d", selectList[0]);
X	  rplyallflag = 0;
X       }
X       len = strlen(text);
X       sprintf(&text[len], "\n");
X    }
X    else {
X       if (delete_sw == 0){
X	  if (!rplyallflag)
X             sprintf(text, "r %d\n", count);
X	  else {
X             sprintf(text, "R %d\n", count);
X	     rplyallflag = 0;
X	  }
X       }
X       else {
X	  if (!rplyallflag)
X             sprintf(text, "r %d\n", count);
X	  else {
X             sprintf(text, "R %d\n", count);
X	     rplyallflag = 0;
X	  }
X       }
X    }
X    write(fp, text, strlen(text));
X    close(fp);
X    system(rplycmd);
X}
X
Xvoid rplyallf()
X{
X    rplyallflag = 1;
X    rplyf();
X}
X
Xvoid quitpop(widget, clientData, callData)
X    Widget widget;
X    caddr_t clientData;
X    caddr_t callData;
X{
X    XtDestroyWidget((Widget)clientData);
X    if (editflag)
X       system(editcmd);
X    if (createflag){
X      system(clrcmd7);
X      system(createcmd);
X    }
X}
Xvoid confirm1(widget, clientData, callData)
X    Widget widget;
X    caddr_t clientData;
X    caddr_t callData;
X{
X    strcpy(subj, XtDialogGetValueString((Widget)clientData));
X}
Xvoid confirm2(widget, clientData, callData)
X    Widget widget;
X    caddr_t clientData;
X    caddr_t callData;
X{
X    strcpy(ccl, XtDialogGetValueString((Widget)clientData));
X}
Xvoid startpop()
X{
X    Widget tolevel, viewport, viewport2, box, box2, vpane, quitcmd;
X    Arg arg[10];
X    static XtCallbackRec callbackList[] = { {quitpop, NULL}, {NULL, NULL} };
X    static XtCallbackRec callbackListp[] = { {confirm1, NULL}, 
X					{confirm2, NULL}, {quitpop, NULL},
X					{NULL, NULL} };
X
X    XtSetArg(arg[0], XtNwidth, 400);
X    XtSetArg(arg[1], XtNheight, 125);
X    tolevel = XtCreatePopupShell("Subject Cc",applicationShellWidgetClass,toplevel,
X	    arg, 2);
X    XtSetArg(arg[0], XtNwidth, 400);
X    vpane = XtCreateManagedWidget("pane",vPanedWidgetClass,tolevel, arg, 1);
X    XtSetArg(arg[0], XtNlabel, "Enter Subject");
X    XtSetArg(arg[1], XtNvalue, "      ");
X    viewport = XtCreateManagedWidget(
X			 "Subject", dialogWidgetClass,
X			 vpane, arg, 2);
X    XtSetArg(arg[0], XtNlabel, "Enter Cc list");
X    XtSetArg(arg[1], XtNvalue, "      ");
X    viewport2 = XtCreateManagedWidget(
X			 "Enter Cc list", dialogWidgetClass,
X			 vpane, arg, 2);
X
X    XtSetArg(arg[0], XtNlabel, "confirm");
X    callbackListp[0].closure = (caddr_t)viewport;
X    callbackListp[1].closure = (caddr_t)viewport2;
X    callbackListp[2].closure = (caddr_t)tolevel;
X    XtSetArg(arg[1], XtNcallback,(XtArgVal)callbackListp);
X    box2 = XtCreateManagedWidget(NULL, commandWidgetClass, viewport2, arg, 2);
X
X    callbackList[0].closure = (caddr_t)tolevel;
X    XtSetArg(arg[0], XtNcallback,(XtArgVal)callbackList);
X    quitcmd = XtCreateManagedWidget("quit", commandWidgetClass, viewport2, arg, 1);
X
X    XtPopup(tolevel, XtGrabNone);
X}
X
Xvoid editf()
X{
X/* must first press view button (i.e. call the function print) to update
X   the file logf2 */
X    editflag = 1;
X    startpop();
X}
X
Xvoid createf()
X{
X    createflag = 1;
X    startpop();
X}
X
Xvoid mailtf()
X{
X    char fname[38], fname1[45];
X    int i, fd;
X    bzero(mailtcmd, 80);
X    if (filename[0] == '-' && filename[1] == '>'){
X       bzero(fname, 38);
X       for (i=2; i < 40; i++)
X	 fname[i-2] = filename[i];
X       strcpy(mailtcmd, "xterm -fn 9x15 -e mail ");
X       strcat(mailtcmd, fname);
X       system(mailtcmd);
X       return;
X    }
X    strcpy(mailtcmd, "mail ");
X    bzero(fname1, 45);
X    if ((subj[0] == 0 && ccl[0] == 0)||(subj[0] == ' ' && ccl[0] == ' '))
X       parseSubCc(fname1, subj, ccl); /* user did not fill the popup at
X					 the end of create or edit. Look
X					 instead in the input box for s: c: */
X    else
X       memcpy(fname1, filename, 45);
X    strcat(mailtcmd, fname1);
X    strcat(mailtcmd, " <");
X    if (subj[0] != 0 || ccl[0] != 0){
X       if (editflag){
X	  if ((fd = open(editlogf, 2)) < 0) {
X	     perror("open problem");
X	     quitOnCond();
X	     exit(-1);
X	  }
X       }
X       if (createflag){
X	  if ((fd = open(createlogf, 2)) < 0) {
X	     perror("open problem");
X	     quitOnCond();
X	     exit(-1);
X	  }
X       }
X       if (editflag || createflag){
X	  if (lseek(fd, 0L, 2) < 0){
X	     perror("lseek problem");
X	     quitOnCond();
X	     exit(-1);
X	  }
X          if (subj[0] != 0){
X	     if (write(fd, "~s ", 3) != 3){
X	        perror("write problem");
X	        quitOnCond();
X	        exit(-1);
X	     }
X	     i = strlen(subj);
X	     if (write(fd, subj, i) != i){
X	        perror("write problem");
X	        quitOnCond();
X	        exit(-1);
X	     }
X	     if (write(fd, "\n", 1) != 1){
X	        perror("write problem");
X	        quitOnCond();
X	        exit(-1);
X	     }
X	  }
X          if (ccl[0] != 0){
X	     if (write(fd, "~c ", 3) != 3){
X	        perror("write problem");
X	        quitOnCond();
X	        exit(-1);
X	     }
X	     i = strlen(ccl);
X	     if (write(fd, ccl, i) != i){
X	        perror("write problem");
X	        quitOnCond();
X	        exit(-1);
X	     }
X	     if (write(fd, "\n", 1) != 1){
X	        perror("write problem");
X	        quitOnCond();
X	        exit(-1);
X	     }
X	  }
X	  close(fd);
X       }
X    }
X    if (editflag) {
X       editflag = 0;
X       strcat(mailtcmd, editlogf);
X    } else if (createflag) {
X       createflag = 0;
X       strcat(mailtcmd, createlogf);
X    } else 
X      return;
X    strcat(mailtcmd, " >>");
X    strcat(mailtcmd, logf4);
X    system(mailtcmd);
X    bzero(subj, 45);
X    bzero(ccl, 45);
X}
X
Xvoid statusMailf()
X{
X/* status for the commands save, reply to sender and reply to all*/
X    Arg arg[10];
X    quithlp1();
X    boxtextw1 = XtCreateManagedWidget(NULL, boxWidgetClass, viewport4, NULL, 0);
X    XtSetArg( arg[0], XtNfile, logf4);
X    XtSetArg( arg[1], XtNtextOptions, scrollVertical );
X    XtSetArg( arg[2], XtNfromVert, viewport3);
X    XtSetArg( arg[3], XtNx, x2);
X    XtSetArg( arg[4], XtNy, y2);
X    XtSetArg( arg[5], XtNwidth, 990);
X    XtSetArg( arg[6], XtNheight, 250);
X    XtSetArg( arg[7], XtNbackground, stringToPixel(outer,"yellow"));
X    textw1 = XtCreateManagedWidget( NULL, asciiDiskWidgetClass, boxtextw1, arg, 8 );
X}
X
Xvoid clrstatusf()
X{
X   system(clrstatuscmd);
X   statusMailf();
X}
X
Xvoid updatef()
X{
X   Arg arg[10];
X   register int i;
X   struct _DiskSourceData {
X   /* resources */
X   char       *fileName;
X   /* private data */
X   Boolean     is_tempfile;
X   FILE *file;
X   XtTextPosition position,    /* file position of first char in buffer */
X   length;      /* length of file */
X   char *buffer;               /* piece of file in memory */
X   int charsInBuffer;          /* number of bytes used in memory */
X   } *wdata;
X   XtTextPosition currentPos;
X   AsciiDiskWidget ascW;
X
X   if (filename[0] == 'g' && filename[1] == 'r' &&
X       filename[2] == 'e' && filename[3] == 'p'){
X       int fd, len;
X       char c, buf[2], text[5], cmd[80];
X       updateflag = 1;
X       bzero(text, 5);
X       bzero(cmd, 80);
X       strcpy(cmd, filename);
X       strcat(cmd, " ");
X       strcat(cmd, logf1);
X       strcat(cmd, " >");
X       strcat(cmd, logf5);
X       system(cmd);
X       if ((fd = open(logf5, 0)) < 0) {
X	perror("updatef: open problem");
X	quitOnCond();
X	exit(-1);
X       }
X       skipspace(fd);
X       selectflag = 0;
X       while (read(fd, buf, 1) != 0) {
X	while (buf[0] < '0' || buf[0] > '9' || buf[0] == ' ')/* U or N or space */
X	  read(fd, buf, 1);
X        len = 0;
X	while (buf[0] != ' ') {
X	 text[len] = buf[0];
X	 len++;
X	 read(fd, buf, 1);
X	}
X	selectList[selectflag] = atoi(text);
X	selectflag++;
X	bzero(text,5);
X	skipnewline(fd);
X	skipspace(fd);
X       }
X       close(fd);
X       quithlp2();
X       XtSetArg( arg[0], XtNheight, 250);
X       XtSetArg( arg[1], XtNwidth, 990);
X       XtSetArg( arg[2], XtNallowVert, False);
X       XtSetArg( arg[3], XtNallowHoriz, False);
X       boxtextw = XtCreateManagedWidget(NULL, boxWidgetClass, viewport3, arg, 4);
X       XtSetArg( arg[0], XtNfile, logf5 );
X       XtSetArg( arg[1], XtNtextOptions, scrollVertical );
X       XtSetArg( arg[2], XtNheight, 250);
X       XtSetArg( arg[3], XtNwidth, 990);
X       XtSetArg( arg[4], XtNx, x1);
X       XtSetArg( arg[5], XtNy, y1);
X       XtSetArg( arg[6], XtNmappedWhenManaged, False);
X       XtSetArg( arg[7], XtNbackground, stringToPixel(outer,"light blue"));
X       textw = XtCreateManagedWidget( NULL, asciiDiskWidgetClass, boxtextw, arg, 8 );
X       XtSetArg( arg[0], XtNmappedWhenManaged, True);
X       XtSetValues( textw, arg, 1);
X       return;
X   }
X
X    /* update current position */
X    ascW = (AsciiDiskWidget)textw;
X    wdata = (struct _DiskSourceData *)(ascW->text.source->data);
X    currentPos = wdata->position;
X   system(logcmd1);
X   quithlp2();
X    XtSetArg( arg[0], XtNheight, 250);
X    XtSetArg( arg[1], XtNwidth, 990);
X    XtSetArg( arg[2], XtNallowVert, False);
X    XtSetArg( arg[3], XtNallowHoriz, False);
X    boxtextw = XtCreateManagedWidget(NULL, boxWidgetClass, viewport3, arg, 4);
X    XtSetArg( arg[0], XtNfile, logf1 );
X    XtSetArg( arg[1], XtNtextOptions, scrollVertical );
X    XtSetArg( arg[2], XtNheight, 250);
X    XtSetArg( arg[3], XtNwidth, 990);
X    XtSetArg( arg[4], XtNx, x1);
X    XtSetArg( arg[5], XtNy, y1);
X    XtSetArg( arg[6], XtNmappedWhenManaged, False);
X    XtSetArg( arg[7], XtNbackground, stringToPixel(outer,"light blue"));
X    textw = XtCreateManagedWidget( NULL, asciiDiskWidgetClass, boxtextw, arg, 8 );
X    ascW = (AsciiDiskWidget)textw;
X    for (i = 0; i < wdata->charsInBuffer; i++)
X       if (*(wdata->buffer + i) == '\n') {
X          currentPos += i + 1;
X          break;
X       }
X    XtTextSetSource(ascW, ascW->text.source, currentPos);
X    XtSetArg( arg[0], XtNmappedWhenManaged, True);
X    XtSetValues( textw, arg, 1);
X    updateflag = 0;
X}
X
X/* ARGSUSED */
Xvoid Destroyed(widget, closure, callData)
X    Widget widget;
X    caddr_t closure;		/* unused */
X    caddr_t callData;		/* unused */
X{
X    fprintf( stderr, "everything now destroyed");
X}
X
X
Xvoid main(argc, argv)
X    unsigned int argc;
X    char **argv;
X{
X    static XtCallbackRec callback[2];
X    Arg arg[10];
X    bzero(mailutildir, 80);
X    if (getenv("XMTOOLRESRC") != NULL)
X      strcpy(mailutildir, getenv("XMTOOLRESRC"));
X    else {
X      fprintf(stderr, "The environment variable XMTOOLRESRC is not set\n");
X      exit(-1);
X    }
X    bzero(mbxname,80);
X    if ((argc > 2) && strcmp(argv[1],"-f") == 0)
X      strcpy(mbxname,argv[2]);
X    pid = getpid();
X    createname();
X    if (mkdir(logdir, 0700) < 0){
X     perror("Can't create directory");
X     exit(-1);
X    }
X    if (chmod(logdir, 0700) < 0){
X     perror("Can't change mode");
X     exit(-1);
X    }
X    toplevel = XtInitialize( NULL, "xmtool", options, XtNumber(options),
X			     &argc, argv);
X
X    appcontxt = XtCreateApplicationContext();
X    XtSetArg( arg[0], XtNwidth, 1000 );
X    outer = XtCreateManagedWidget( "vpaned", vPanedWidgetClass, toplevel,
X				   arg, ONE );
X    XtAddCallback( outer, XtNdestroyCallback, Destroyed, NULL );
X
X    callback[0].callback = Quit;
X    callback[0].closure = (caddr_t)toplevel;
X    XtSetArg( arg[0], XtNcallback, callback );
X    XtSetArg( arg[1], XtNbackground, stringToPixel(outer,"yellow green"));
X    XtCreateManagedWidget( "quit", commandWidgetClass, outer, arg, TWO );
X
X    XtSetArg( arg[0], XtNlabel, "Mail Tool");
X    XtSetArg( arg[1], XtNallowVert, False);
X    XtSetArg( arg[2], XtNbackground, stringToPixel(outer,"gray"));
X    command = XtCreateManagedWidget( "label", labelWidgetClass,
X					 outer, arg, THREE );
X
X    XtSetArg( arg[0], XtNallowVert, False );
X    XtSetArg( arg[1], XtNallowHoriz, False );
X    XtSetArg( arg[2], XtNbackground, stringToPixel(outer,"gray"));
X    viewport = XtCreateManagedWidget( "viewport", viewportWidgetClass, outer,
X				  arg, THREE );
X
X    XtSetArg( arg[0], XtNallowVert, False );
X    XtSetArg( arg[1], XtNallowHoriz, False );
X    XtSetArg( arg[2], XtNbackground, stringToPixel(outer,"yellow green"));
X    box1 = XtCreateManagedWidget( NULL, boxWidgetClass, viewport,
X				arg, THREE );
X
X    XtSetArg( arg[0], XtNallowVert, False );
X    XtSetArg( arg[1], XtNallowHoriz, False );
X    XtSetArg(arg[2],XtNwidth, 40);
X    XtSetArg( arg[3], XtNbackground, stringToPixel(outer,"gray"));
X    XtSetArg(arg[4], XtNresize, False);
X    msgNumber = XtCreateManagedWidget(  "001", labelWidgetClass,
X				box1, arg, 5);
X
X    XtSetArg(arg[0],XtNfromHoriz,msgNumber);
X    XtSetArg(arg[1],XtNwidth, 40);
X    XtSetArg( arg[2], XtNbackground, stringToPixel(outer,"gray"));
X    XtSetArg(arg[3], XtNresize, False);
X    UpperLimit = XtCreateManagedWidget(  "001", labelWidgetClass,
X				box1, arg, 4);
X
X    XtSetArg(arg[0],XtNfromHoriz,UpperLimit);
X    XtSetArg( arg[1], XtNbackground, stringToPixel(outer,"gray"));
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/bitmap/f1");
X    XtSetArg(arg[2], XtNbitmap, StringToPixmap(outer,hlpfname));
X    plusB = XtCreateManagedWidget( "plus", commandWidgetClass,
X				box1, arg, 3);
X    XtAddCallback( plusB, XtNcallback, Count, (caddr_t)msgNumber );
X
X    XtSetArg(arg[0],XtNfromHoriz,plusB);
X    XtSetArg( arg[1], XtNbackground, stringToPixel(outer,"gray"));
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/bitmap/f2");
X    XtSetArg(arg[2], XtNbitmap, StringToPixmap(outer,hlpfname));
X    minusB = XtCreateManagedWidget( "minus", commandWidgetClass,
X				box1, arg, 3);
X    XtAddCallback( minusB, XtNcallback, Count1, (caddr_t)msgNumber );
X
X    XtSetArg(arg[0],XtNfromHoriz,minusB);
X    XtSetArg( arg[1], XtNbackground, stringToPixel(outer,"gray"));
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/bitmap/f3");
X    XtSetArg(arg[2], XtNbitmap, StringToPixmap(outer,hlpfname));
X    rangeB = XtCreateManagedWidget( "range", commandWidgetClass,
X				box1, arg, 3);
X    XtAddCallback( rangeB, XtNcallback, deleteswitch, (caddr_t)UpperLimit );
X
X    XtSetArg(arg[0],XtNfromHoriz,rangeB);
X    XtSetArg( arg[1], XtNbackground, stringToPixel(outer,"gray"));
X    resetB = XtCreateManagedWidget( "set counter", commandWidgetClass,
X				box1, arg, 2);
X    XtAddCallback( resetB, XtNcallback, resetf, (caddr_t)UpperLimit );
X
X    XtSetArg(arg[0],XtNfromHoriz,resetB);
X    XtSetArg( arg[1], XtNbackground, stringToPixel(outer,"gray"));
X    viewB = XtCreateManagedWidget( "view", commandWidgetClass,
X				box1, arg, 2);
X    XtAddCallback( viewB, XtNcallback, print, NULL);
X
X    XtSetArg(arg[0],XtNfromHoriz,viewB);
X    XtSetArg( arg[1], XtNbackground, stringToPixel(outer,"gray"));
X    deleteB = XtCreateManagedWidget( "delete", commandWidgetClass,
X				box1, arg, 2);
X    XtAddCallback( deleteB, XtNcallback, delete, NULL);
X
X    XtSetArg(arg[0],XtNfromHoriz,deleteB);
X    XtSetArg( arg[1], XtNbackground, stringToPixel(outer,"gray"));
X    saveB = XtCreateManagedWidget( "save", commandWidgetClass,
X				box1, arg, 2);
X    XtAddCallback( saveB, XtNcallback, save, NULL);
X
X    XtSetArg(arg[0],XtNfromHoriz,saveB);
X    XtSetArg(arg[1], XtNeditType, (XtArgVal)XttextEdit );
X    XtSetArg(arg[2], XtNstring,(XtArgVal)filename);
X    XtSetArg(arg[3], XtNwidth,  (XtArgVal)length);
X    XtSetArg(arg[4], XtNlength, (XtArgVal)1000);
X    XtSetArg( arg[5], XtNbackground, stringToPixel(outer,"gray"));
X    stringW = XtCreateManagedWidget("stringthing", asciiStringWidgetClass,
X			     box1, arg, 6);
X    mailtoolcheck(stringW);
X
X    XtSetArg( arg[0], XtNallowVert, False );
X    XtSetArg( arg[1], XtNallowHoriz, False );
X    viewport2 = XtCreateManagedWidget( "viewport", viewportWidgetClass, outer,
X				  arg, TWO );
X
X    XtSetArg( arg[0], XtNallowVert, False );
X    XtSetArg( arg[1], XtNallowHoriz, False );
X    XtSetArg( arg[2], XtNbackground, stringToPixel(outer,"yellow green"));
X    box2 = XtCreateManagedWidget( NULL, boxWidgetClass, viewport2,
X				arg, THREE );
X
X    XtSetArg( arg[0], XtNallowVert, False );
X    XtSetArg( arg[1], XtNallowHoriz, False );
X    XtSetArg(arg[2],XtNwidth, 40);
X    XtSetArg( arg[3], XtNbackground, stringToPixel(outer,"gray"));
X    XtSetArg( arg[4], XtNresize, False);
X    incrementB = XtCreateManagedWidget(  "001", labelWidgetClass,
X				box2, arg, 5);
X    XtSetArg( arg[0], XtNbackground, stringToPixel(outer,"gray"));
X    bzero(hlpfname, 80);
X    strcpy(hlpfname, mailutildir);
X    strcat(hlpfname, "/bitmap/f1");
X    XtSetArg(arg[1], XtNbitmap, StringToPixmap(outer,hlpfname));
X    incrB = XtCreateManagedWidget( "incr", commandWidgetClass,
X				box2, arg, 2 );
X    XtAddCallback( incrB, XtNcallback, Count2, (caddr_t)incrementB );
X
X    XtSetArg( arg[0], XtNbackground, stringToPixel(outer,"gray"));
X    selectw = XtCreateManagedWidget( "select", commandWidgetClass,
X				box2, arg, 1 );
X    XtAddCallback( selectw, XtNcallback, selectf, NULL);
X
X    XtSetArg( arg[0], XtNbackground, stringToPixel(outer,"gray"));
X    rplyw = XtCreateManagedWidget( "reply to sender", commandWidgetClass,
X				box2, arg, 1 );
X    XtAddCallback( rplyw, XtNcallback, rplyf, NULL);
X
X    XtSetArg( arg[0], XtNbackground, stringToPixel(outer,"gray"));
X    rplyallw = XtCreateManagedWidget( "reply to all", commandWidgetClass,
X				box2, arg, 1 );
X    XtAddCallback( rplyallw, XtNcallback, rplyallf, NULL);
X
X    XtSetArg( arg[0], XtNbackground, stringToPixel(outer,"gray"));
X    editw = XtCreateManagedWidget( "edit", commandWidgetClass,
X				box2, arg, 1 );
X    XtAddCallback( editw, XtNcallback, editf, NULL);
X
X    XtSetArg( arg[0], XtNbackground, stringToPixel(outer,"gray"));
X    createw = XtCreateManagedWidget( "create", commandWidgetClass,
X				box2, arg, 1 );
X    XtAddCallback( createw, XtNcallback, createf, NULL);
X
X    XtSetArg( arg[0], XtNbackground, stringToPixel(outer,"gray"));
X    mailtw = XtCreateManagedWidget( "mail to list", commandWidgetClass,
X				box2, arg, 1 );
X    XtAddCallback( mailtw, XtNcallback, mailtf, NULL);
X
X    XtSetArg( arg[0], XtNbackground, stringToPixel(outer,"gray"));
X    statusMailw = XtCreateManagedWidget( "status", commandWidgetClass,
X				box2, arg, 1 );
X    XtAddCallback( statusMailw, XtNcallback, statusMailf, NULL);
X
X    XtSetArg( arg[0], XtNbackground, stringToPixel(outer,"gray"));
X    clrstatusw = XtCreateManagedWidget( "clear status", commandWidgetClass,
X				box2, arg, 1 );
X    XtAddCallback( clrstatusw, XtNcallback, clrstatusf, NULL);
X
X    XtSetArg( arg[0], XtNbackground, stringToPixel(outer,"gray"));
X    updatew = XtCreateManagedWidget( "update", commandWidgetClass,
X				box2, arg, 1 );
X    XtAddCallback( updatew, XtNcallback, updatef, NULL);
X
X    XtSetArg( arg[0], XtNbackground, stringToPixel(outer,"gray"));
X    helpbutton = XtCreateManagedWidget( "help", commandWidgetClass,
X				box2, arg, 1 );
X    XtAddCallback( helpbutton, XtNcallback, help, (caddr_t)incrementB );
X
X    XtSetArg( arg[0], XtNallowVert, False );
X    XtSetArg( arg[1], XtNallowHoriz, False );
X    viewport3 = XtCreateManagedWidget( "viewport", viewportWidgetClass, outer,
X				  arg, TWO );
X    XtSetArg( arg[0], XtNheight, 250);
X    XtSetArg( arg[1], XtNwidth, 990);
X    XtSetArg( arg[2], XtNallowVert, False);
X    XtSetArg( arg[3], XtNallowHoriz, False);
X    boxtextw = XtCreateManagedWidget(NULL, boxWidgetClass, viewport3, arg, 4);
X    system(logcmd1);
X    XtSetArg( arg[0], XtNfile, logf1);
X    XtSetArg( arg[1], XtNtextOptions, scrollVertical );
X    XtSetArg( arg[2], XtNheight, 250);
X    XtSetArg( arg[3], XtNwidth, 990);
X    XtSetArg( arg[4], XtNbackground, stringToPixel(outer,"light blue"));
X    textw = XtCreateManagedWidget( NULL, asciiDiskWidgetClass, boxtextw, arg, 5 );
X    XtSetArg(arg[0], XtNx, &x1);
X    XtSetArg(arg[1], XtNy, &y1);
X    XtGetValues(textw, arg, 2);
X
X    XtSetArg( arg[0], XtNallowVert, False );
X    XtSetArg( arg[1], XtNallowHoriz, False );
X    viewport4 = XtCreateManagedWidget( "viewport", viewportWidgetClass, outer,
X				  arg, TWO );
X
X    {
X       int fp;
X       char text[10];
X       bzero(text, 10);
X       if ((fp = creat(logf3, 0700)) < 0){
X          perror("open problem");
X          exit(-1);
X       };
X       sprintf(text, "p 1\n");
X       write(fp, text, strlen(text));
X       close(fp);
X    }
X    system(logcmd2);
X    boxtextw1 = XtCreateManagedWidget(NULL, boxWidgetClass, viewport4, NULL, 0);
X    XtSetArg( arg[0], XtNfile, logf2);
X    XtSetArg( arg[1], XtNtextOptions, scrollVertical );
X    XtSetArg( arg[2], XtNheight, 250);
X    XtSetArg( arg[3], XtNwidth, 990);
X    XtSetArg( arg[4], XtNbackground, stringToPixel(outer,"yellow"));
X    textw1 = XtCreateManagedWidget( NULL, asciiDiskWidgetClass, boxtextw1, arg, 5 );
X    XtSetArg(arg[0], XtNx, &x2);
X    XtSetArg(arg[1], XtNy, &y2);
X    XtGetValues(textw1, arg, 2);
X    XtRealizeWidget(toplevel);
X    XtMainLoop();
X}
Xvoid createname()
X{
X    char bufz[20];
X    bzero(bufz, 20);
X    bzero(logf1, 40);
X    bzero(logcmd1, 80);
X    bzero(logf2, 40);
X    bzero(logcmd2, 80);
X    bzero(logf3, 40);
X    bzero(logf4, 40);
X    bzero(logf5, 40);
X    bzero(logdir, 40);
X    bzero(logcmd3, 80);
X    bzero(clrcmd, 80);
X    bzero(clrcmd1, 80);
X    bzero(clrcmd2, 80);
X    bzero(clrcmd3, 80);
X    bzero(clrcmd4, 80);
X    bzero(clrcmd5, 80);
X    bzero(clrcmd6, 80);
X    bzero(clrcmd7, 80);
X    bzero(clrcmd8, 80);
X    bzero(clrcmd9, 80);
X    bzero(rplycmd, 160);
X    bzero(editcmd, 80);
X    bzero(createcmd, 80);
X    bzero(rplylogf, 40);
X    bzero(rplyinlogf, 40);
X    bzero(editlogf, 40);
X    bzero(createlogf, 40);
X    sprintf(bufz, "%d", pid);
X    strcpy(logdir, "/tmp/xm");
X    strcat(logdir, bufz);
X    strcpy(logf1, logdir);
X    strcat(logf1, "/xm1");
X    strcpy(logf2, logdir);
X    strcat(logf2, "/xm2");
X    strcpy(logf3, logdir);
X    strcat(logf3, "/xm3");
X    strcpy(logf4, logdir);
X    strcat(logf4, "/xm4");
X    strcpy(logf5, logdir);
X    strcat(logf5, "/xm5a");
X    strcpy(rplylogf, logdir);
X    strcat(rplylogf, "/xm5");
X    strcpy(editlogf, logdir);
X    strcat(editlogf, "/xm6");
X    strcpy(createlogf, logdir);
X    strcat(createlogf, "/xm7");
X    strcpy(rplyinlogf, logdir);
X    strcat(rplyinlogf, "/xm8");
X    if (mbxname[0] == 0)
X     strcpy(logcmd1, "mail -H >");
X    else{
X     strcat(logcmd1,"mail -f ");
X     strcat(logcmd1,mbxname);
X     strcat(logcmd1," -H >");
X    }
X    strcat(logcmd1, logf1);
X    if (mbxname[0] == 0)
X     strcpy(logcmd2, "mail -N <");
X    else{
X     strcat(logcmd2,"mail -f ");
X     strcat(logcmd2,mbxname);
X     strcat(logcmd2," -N <");
X    }
X    strcat(logcmd2, logf3);
X    strcat(logcmd2, " >");
X    strcat(logcmd2, logf2);
X    if (mbxname[0] == 0)
X     strcat(logcmd3, "mail -N <");
X    else{
X     strcat(logcmd3,"mail -f ");
X     strcat(logcmd3,mbxname);
X     strcat(logcmd3," -N <");
X    }
X    strcat(logcmd3, logf3);
X    strcat(logcmd3, " >/dev/null");
X    strcpy(clrcmd, "rm -fr ");
X    strcat(clrcmd, logdir);
X    strcpy(clrcmd1, "rm -f ");
X    strcat(clrcmd1, logf1);
X    strcpy(clrcmd2, "rm -f ");
X    strcat(clrcmd2, logf2);
X    strcpy(clrcmd3, "rm -f ");
X    strcat(clrcmd3, logf3);
X    strcpy(clrcmd4, "rm -f ");
X    strcat(clrcmd4, logf4);
X    strcpy(clrcmd5, "rm -f ");
X    strcat(clrcmd5, rplylogf);
X    strcpy(clrcmd6, "rm -f ");
X    strcat(clrcmd6, editlogf);
X    strcpy(clrcmd7, "rm -f ");
X    strcat(clrcmd7, createlogf);
X    strcpy(clrcmd8, "rm -f ");
X    strcat(clrcmd8, rplyinlogf);
X    strcpy(clrcmd9, "rm -f ");
X    strcat(clrcmd9, logf5);
X    strcpy(rplycmd, "(xterm -fn 9x15 -e vi ");
X    strcat(rplycmd, rplylogf);
X    strcat(rplycmd, "; ");
X    strcat(rplycmd, "cat ");
X    strcat(rplycmd, rplylogf);
X    strcat(rplycmd, " >>");
X    strcat(rplycmd, rplyinlogf);
X    if (mbxname[0] == 0)
X     strcat(rplycmd, "; mail -N <");
X    else{
X     strcat(rplycmd,"; mail -f ");
X     strcat(rplycmd,mbxname);
X     strcat(rplycmd," -N <");
X    }
X    strcat(rplycmd, rplyinlogf);
X    strcat(rplycmd, " >>");
X    strcat(rplycmd, logf4);
X    strcat(rplycmd, ") &");
X    strcpy(editcmd, "cp ");
X    strcat(editcmd, logf2);
X    strcat(editcmd, " ");
X    strcat(editcmd, editlogf);
X    strcat(editcmd, "; xterm -fn 9x15 -e vi ");
X    strcat(editcmd, editlogf);
X    strcat(editcmd, " &");
X    strcpy(createcmd, "xterm -fn 9x15 -e vi ");
X    strcat(createcmd, createlogf);
X    strcat(createcmd, " &");
X    bzero(clrstatuscmd, 80);
X    strcpy(clrstatuscmd, "cp /dev/null ");
X    strcat(clrstatuscmd, logf4);
X    bzero(savecmd, 80);
X    if (mbxname[0] == 0)
X     strcpy(savecmd, "mail -N ");
X    else{
X     strcat(savecmd,"mail -f ");
X     strcat(savecmd,mbxname);
X     strcat(savecmd," -N ");
X    }
X    strcat(savecmd, "< ");
X    strcat(savecmd, logf3);
X    strcat(savecmd, " 1>>");
X    strcat(savecmd, logf4);
X    strcat(savecmd, " 2>&1");
X}
Xmailtoolcheck(widg)
XWidget widg;
X{
X    if (widg == NULL){
X       fprintf(stderr, "can't open widget, exiting ...\n");
X       exit(-1);
X    }
X}
Xpreparetext(i, text)
Xint i;
Xchar text[];
X{
X    if (0 <= i && i <= 9)
X      sprintf(text,"00%1d", i);
X    else if (10 <= i && i <= 99)
X      sprintf(text,"0%2d", i);
X    else if (100 <= i && i <= 999)
X      sprintf(text,"%3d", i);
X}
Xparsefname(fname)
Xchar fname[];
X{
X    int i, j;
X    i = strlen(filename);
X    for (j = i - 1; j >= 0; j--){
X       if (filename[j] == '/'){
X	 j--;
X	 break;
X       }
X    }
X    for (i = 0; i <= j; i++)
X      fname[i] = filename[i];
X}
XparseSubCc(fname, subj, ccl)
Xchar fname[], subj[], ccl[];
X{
X   int i, j, k, k1, k2;
X   for (i = 0; i < 45; i++){
X      if (filename[i+1] != ':')
X	 fname[i] = filename[i];
X      else
X	 break;
X   }
X
X   if (i == 0 || i == 45) return;
X
X   j = i;
X   k = j;
X
X   if (filename[j] == 's'){
X      for (k = j + 2; k < 45; k++){
X	 if (filename[k] != 'c' || filename[k+1] != ':')
X	    subj[k-j-2] = filename[k];
X	 else
X	    break;
X      }
X   }
X
X   /* either k == j or k > j, we start with k */
X
X   k1 = k;
X
X   if (filename[k1] == 'c' && filename[k1+1] == ':'){
X      for (k2 = k1 + 2; k2 < 45; k2++)
X	 ccl[k2-k1-2] = filename[k2];
X   }
X}
Xstatic Pixel
XstringToPixel(w, colorname)
XWidget w;
XString colorname;
X{
X        XrmValue        in, out;
X
X        in.addr = colorname;
X        in.size = strlen(colorname) + 1;
X        XtConvert(w, XtRString, &in,
X                XtRPixel, &out);
X        return
X        *(Pixel*)out.addr;
X}
Xstatic Pixmap
XStringToPixmap(w, filebitmap)
XWidget w;
XString filebitmap;
X{
X        XrmValue        in, out;
X
X        in.addr = filebitmap;
X        in.size = strlen(filebitmap) + 1;
X        XtConvert(w, XtRString, &in,
X                XtRPixmap, &out);
X        return
X        *(Pixmap*)out.addr;
X}
Xskipspace(fd)
Xint fd;
X{
X	char buf[2];
X	if (read(fd, buf, 1) == 0) return;
X	if (buf[0] != ' ') return;
X	while (buf[0] == ' ')
X	  if (read(fd, buf, 1) == 0) return;
X	lseek(fd, -1, 1);
X}
Xskipnewline(fd)
Xint fd;
X{
X	char buf[2];
X	if (read(fd, buf, 1) == 0) return;
X	if (buf[0] == '\n') return;
X	while (buf[0] != '\n')
X	  if (read(fd, buf, 1) == 0) return;
X}
Xumailmin(i,j)
Xint i,j;
X{
X	if (i < j) return i;
X	else return j;
X}
END_OF_FILE
if test 55939 -ne `wc -c <'xmtool.c'`; then
    echo shar: \"'xmtool.c'\" unpacked with wrong size!
fi
# end of 'xmtool.c'
fi
echo shar: End of shell archive.
exit 0



More information about the Comp.sources.x mailing list