v06i044: xmail -- Mail front end for X11, Part04/06

Michael C. Wagnitz michael at parns.nsc.com
Thu Mar 22 17:57:03 AEST 1990


Submitted-by: michael at parns.nsc.com (Michael C. Wagnitz)
Posting-number: Volume 6, Issue 44
Archive-name: xmail/part04

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 4 (of 6)."
# Contents:  parser.c regex.h utils.c xmail.c
# Wrapped by michael at harley on Tue Mar 20 15:28:06 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'parser.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'parser.c'\"
else
echo shar: Extracting \"'parser.c'\" \(15239 characters\)
sed "s/^X//" >'parser.c' <<'END_OF_FILE'
X/*
X * xmail - X window system interface to the mail program
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author:	Po Cheung
X * Date:	March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation.  The University of Texas at Austin makes no 
X * representations about the suitability of this software for any purpose.  
X * It is provided "as is" without express or implied warranty.
X *
X * Copyright 1990 by National Semiconductor Corporation
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of National Semiconductor Corporation not
X * be used in advertising or publicity pertaining to distribution of the
X * software without specific, written prior permission.
X *
X * NATIONAL SEMICONDUCTOR CORPORATION MAKES NO REPRESENTATIONS ABOUT THE
X * SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE.  IT IS PROVIDED "AS IS"
X * WITHOUT EXPRESS OR IMPLIED WARRANTY.  NATIONAL SEMICONDUCTOR CORPORATION
X * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO
X * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
X * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
X * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
X * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X * PERFORMANCE OF THIS SOFTWARE.
X *
X * Author:  Michael C. Wagnitz - National Semiconductor Corporation
X *
X */
X
X
X#include	"global.h"
X#include	"regex.h"
X#include	"xmailregex.h"
X
X#define		BYTEWIDTH	8
X#define		RE_BUFFER	100
X
Xextern void	reset_mailbox();
X
X/*
X**  @(#)compile() - regular expression patterns into a pattern table.
X**  A pattern table is an array of pattern records.
X**  Each pattern record consists of a regular expression,
X**  and a buffer for the to-be-compiled regular expression,
X*/
Xstatic void
Xcompile(patternTable)
XPatternRec *patternTable;
X{
X PatternRec	*p;
X char 	fastmap[(1 << BYTEWIDTH)];
X int		i;
X
X    for (i=0; patternTable[i].pat; i++) {
X	p = &patternTable[i];
X	p->buf = (struct re_pattern_buffer *) 
X	  XtMalloc (sizeof (struct re_pattern_buffer));
X	p->buf->allocated = RE_BUFFER;
X	p->buf->buffer = (char *) XtMalloc (p->buf->allocated);
X	p->buf->fastmap = fastmap;
X	p->buf->translate = NULL;
X	re_compile_pattern(p->pat, strlen(p->pat), p->buf);
X	re_compile_fastmap(p->buf);
X    }
X} 
X
X/*
X** @(#)match() - string against regular expressions in pattern table.
X** The best match is found, and function returns index to the pattern table.
X*/
Xstatic int
Xmatch(patternTable, string)
XPatternRec 	*patternTable;
Xchar 	*string;
X{
X    struct re_registers	regs;
X    int			m, bestmatch = -1, index = -1, i, j, r, start, n;
X    char 		*s;
X
X    if (strcmp(string, "") == NULL) return -1;
X    for (i=0; patternTable[i].pat; i++) {
X	m = re_match(patternTable[i].buf, string, strlen(string), 0, NULL);
X	if (m > bestmatch) {
X	    bestmatch = m;
X	    index = i;
X	}
X    }
X    return index;
X}
X
X/*
X** @(#)parser_init()- compile output and command pattern tables.
X*/
Xvoid
Xparser_init()
X{
X compile(output_pattern);
X compile(command_pattern);
X}
X
X
X/*
X** @(#)parse() - command and output and call appropriate handler
X*/
Xvoid
Xparse(msg)
XString	msg;
X{
X Arg		args[1];
X Cardinal	j, k, msgnum;
X XtTextBlock	textblock;
X XtTextPosition	pos;
X Widget		button, popup;
X char		tmp[128], *c, *index();
X static	String	old_msg = NULL;
X static int	shown_msg = 0;
X
X
X j = match(command_pattern, Command);
X switch (j) {
X/*
X** If error on startup, mail has terminated connection.  Remove our input
X** handler, close the file from our end, and indicate that no connection
X** exists.  Otherwise, establish conversation requirements and display the
X** current message.  Track current message shown for delete display control.
X** If *Show_Last: resource is NOT False, show latest message, if none new.
X*/
X    case C_START :  if (O_BELL == match(output_pattern, msg)) {
X                       XtRemoveInput(mailInputId);
X                       fclose(mailfp);
X                       close(mail_fd);
X                       mailpid = 0;
X		       LASTCH(msg) = '\0';    /* Don't ring Bell() for this */
X		       Bell(msg);
X		       UpdateTitleBar("No current folder");
X                       XtFree(msg);
X		       *msg = '\0';
X                      } else {
X#ifdef X11R3
X                       XtFree(QueryMail("set screen=100 nocrt noautoprint"));
X#else
X                       XtFree(QueryMail("set screen=500 nocrt noautoprint"));
X#endif
X                       if (msgnum = file_handler(1)) {
X                          sprintf(tmp, "size %d", msgnum);
X                          XtFree(msg);
X                          msg = QueryMail(tmp);
X                          c = index(msg, '/');
X                          if (65536 < atoi(++c))
X                             strcpy(msg, " ");	/* Don't auto-read huge msgs */
X                          else {
X                             sprintf(tmp, "%d", msgnum);
X                             XtFree(msg);
X                             msg = QueryMail(tmp);
X                             shown_msg = msgnum;
X                            }
X                         }
X                      }
X	            break;
X/*
X** In response to normal or change folder commands, test output.  If an
X** error, display message in status window and ring bell.  If we have
X** text of next mail message, tell index_handler to mark its number, else
X** retrieve the appropriate message text (which also marks its number).
X** If *Show_Last: resource is NOT False, file cmd shows latest, if none new.
X** Track current message shown for delete display control.
X*/
X    case C_EXEC  :
X    case C_FILE  :  j = match(output_pattern, msg);
X		    switch (j) {
X		       case O_BELL  : Bell(msg); XtFree(msg); *msg='\0'; break;
X		       case O_EXEC  : shown_msg = index_handler(0);  break;
X		       case O_FILE  : msgnum = file_handler(1);
X		                      c = index(msg, '\n');
X		                      if ((int)(c - msg) < strlen(msg) - 1) {
X                                         *c = '\0';	/* don't bell this */
X					 Bell(msg);
X		                        }
X                                      XtFree(msg);
X                                      *msg = '\0';
X                                      if (msgnum) {
X                                         sprintf(tmp, "size %d", msgnum);
X                                         msg = QueryMail(tmp);
X                                         c = index(msg, '/');
X                                         if (65536 < atoi(++c))
X				            strcpy(msg, " ");
X                                         else {
X                                            sprintf(tmp, "%d", msgnum);
X                                            XtFree(msg);
X                                            msg = QueryMail(tmp);
X                                            shown_msg = msgnum;
X                                           }
X                                        }
X		                      break;
X	              }
X                    break;
X/*
X** When deleting a message, if the message deleted was not the one currently
X** shown, simply mark that message's index line with a capital 'D'.  Else, if
X** we deleted the currently displayed message, or we undeleted one, display
X** the next (or undeleted) message, and track our message shown number.
X*/
X    case C_DELETE : if (O_BELL == match(output_pattern, msg)) {
X                       Bell(msg);
X                       XtFree(msg);
X                       *msg = '\0';
X                      } else {
X                       pos = XtTextGetInsertionPoint(WidgetOf(WidgetOf(toplevel,
X                                                  "vpane"), "indexWindow")) + 1;
X                       msgnum = PositionToMsgNumber(pos);
X                       if (*Command == 'd' && msgnum && msgnum != shown_msg) {
X                          XtTextSetInsertionPoint(WidgetOf(WidgetOf(toplevel,
X                                                 "vpane"), "indexWindow"), pos);
X                          textblock.firstPos	= 0;
X                          textblock.length	= 1;
X                          textblock.ptr		= "D";
X                          textblock.format	= FMT8BIT;
X                          XtTextReplace(WidgetOf(WidgetOf(toplevel, "vpane"),
X                                        "indexWindow"), pos, pos+1, &textblock);
X		          index_handler(++msgnum); /* point to next msg */
X                          XtFree(msg);
X                          *msg = '\0';
X                         } else {
X                          if (msgnum = file_handler(0)) {
X                             sprintf(tmp, "size %d", msgnum);
X                             XtFree(msg);
X                             msg = QueryMail(tmp);
X                             c = index(msg, '/');
X                             if (65536 < atoi(++c))
X                                strcpy(msg, " ");
X                             else {
X                             sprintf(tmp, "%d", msgnum);
X                             XtFree(msg);
X                             msg = QueryMail(tmp);
X                             shown_msg = msgnum;
X                            }
X                         }
X                      }
X                      }
X		    break;
X/*
X** In response to a request to view new mail, first reset the mailbox flag.
X** If mail came back with an error, complain to the user.  Otherwise, clear
X** the Newmail command button highlighting, and (if it exists) destroy the
X** current folder popup list.  Then display new mail text and track number.
X*/
X    case C_NEWMAIL:
X                    reset_mailbox(WidgetOf(WidgetOf(toplevel,"icon"),"mailbox"));
X		    UnsetNewmail(WidgetOf(WidgetOf(toplevel, "vpane"),
X                                                   "commandPanel"), NULL, NULL);
X		    button = WidgetOf(WidgetOf(WidgetOf(toplevel, "vpane"),
X                                                     "commandPanel"), "Folder");
X		    if (popup = WidgetOf(button, "popupList"))
X		       XtDestroyWidget(popup);
X                    if (O_BELL == match(output_pattern, msg)) {
X                       if (strncmp(msg, "No mail for ", 12) == 0) {
X                          Bell("No mail in system mailbox\n");
X                         } else { Bell(msg); }
X                       XtFree(msg);
X                       *msg = '\0';
X                      } else {
X                       msgnum = file_handler(1);
X		       c = index(msg, '\n');
X		       if ((int)(c - msg) < strlen(msg) - 1) {
X                          *c = '\0';	/* don't bell this */
X			  Bell(msg);
X                         }
X                       XtFree(msg);
X                       *msg = '\0';
X                       if (msgnum) {
X                          sprintf(tmp, "size %d", msgnum);
X                          msg = QueryMail(tmp);
X                          c = index(msg, '/');
X                          if (65536 < atoi(++c))
X		             strcpy(msg, " ");
X                          else {
X                             sprintf(tmp, "%d", msgnum);
X                             XtFree(msg);
X                             msg = QueryMail(tmp);
X                             shown_msg = msgnum;
X                            }
X                         }
X                      }
X		    break;
X
X           default: j = match(output_pattern, msg);
X		    switch (j) {
X                       case O_BELL:
X                            Bell(msg);
X                            XtFree(msg);
X                            *msg = '\0';
X		            break;
X/*
X** If output is from the print command, display a status message
X*/
X		       case O_PRINT:
X                            sscanf(&Command[2], "%d", &j);
X                            sscanf(&msg[26], "%*d/%d", &k);
X                            sprintf(tmp,
X                             "Message %d sent to printer -- %d bytes\n", j, k);
X                            Bell(tmp);
X                            XtFree(msg);
X                            *msg = '\0';
X		            break;
X                      }
X		    break;
X   }
X/*
X** If any text remains, display it in the bottom (text) window.
X*/
X if (*msg) {
X    if (old_msg)
X       XtFree(old_msg);
X    old_msg = msg;
X    for (j = strlen(msg)-1; j > 1 && msg[j] == '\n' && msg[j-1] == '\n'; j--);
X    msg[++j] = '\0';			/* drop all but the last newline */
X
X    writeTo(WidgetOf(WidgetOf(toplevel, "vpane"), "textWindow"), msg);
X   }
X} /* parse */
X
X#undef	BUFSIZ
X#define	BUFSIZ	8192
X
X/*
X** @(#)QueryMail() - Sends a command and returns corresponding output.
X** If called by the Xt input procedure readMail, no command is included.
X*/
Xchar *
XQueryMail(command)
Xchar *command;
X{
X Widget		w, x, y, z;
X int		j, outputsize, size, length = strlen(MailPrompt);
X char *output = "", s[BUFSIZ];
X
X
X if (! mailpid)
X    Bell("No mail\n");
X else {
X    if (*command) {			/* allow us to be called by readMail */
X       if (LASTCH(command) != '\n')
X          sprintf(s, "%s\n", command);
X       else
X          strcpy(s, command);
X       writeMail(s);
X      }
X
X    w = WidgetOf(toplevel, "vpane");
X    x = WidgetOf(w, "indexWindow");
X    y = WidgetOf(w, "textWindow");
X    z = WidgetOf(WidgetOf(w, "commandPanel"), "fileWindow");
X    XDefineCursor(XtDisplay(w), XtWindow(w), waitC);
X    XDefineCursor(XtDisplay(x), XtWindow(x), waitC);
X    XDefineCursor(XtDisplay(y), XtWindow(y), waitC);
X    XDefineCursor(XtDisplay(z), XtWindow(z), waitC);
X    XFlush(XtDisplay(toplevel));
X/*
X** allocate one block to 'output' to begin with
X*/
X    outputsize = BUFSIZ;
X    output = XtMalloc(outputsize);
X    strcpy(output, "");
X
X    for (;;) {
X    while ((size = read(mail_fd, s, BUFSIZ)) == -1);
X
X        if (size == 0) break;		/* END-OF-FILE? should never happen */
X
X        if (size < BUFSIZ)
X           s[size] = '\0';
X
X        if (strlen(output) + size > outputsize) {
X           outputsize += BUFSIZ;
X           output = XtRealloc(output, outputsize);
X          }
X        strcat(output, s);
X
X        j = strlen(output) - length;	/* no accidents allowed here */
X        if (j < 0) j = 0;		/* no references before zero */
X        if (strcmp(&output[j], MailPrompt) == 0) {
X           output[j] = '\0';		/* Drop prompt from end of text */
X           break;			/* and return from read routine */
X          }
X
X        if (O_BELL == match(output_pattern,output) && !strcmp(Command,"Start"))
X           break;
X       }
X
X    if (*command) 
X       LASTCH(output) = '\0';		/* drop newline for normal queries */
X
X    XDefineCursor(XtDisplay(w), XtWindow(w), None);
X    XDefineCursor(XtDisplay(x), XtWindow(x), xtermC);
X    XDefineCursor(XtDisplay(y), XtWindow(y), xtermC);
X    XDefineCursor(XtDisplay(z), XtWindow(z), xtermC);
X   }
X
X return(output);
X} /* QueryMail */
END_OF_FILE
if test 15239 -ne `wc -c <'parser.c'`; then
    echo shar: \"'parser.c'\" unpacked with wrong size!
fi
# end of 'parser.c'
fi
if test -f 'regex.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'regex.h'\"
else
echo shar: Extracting \"'regex.h'\" \(10832 characters\)
sed "s/^X//" >'regex.h' <<'END_OF_FILE'
X/* Definitions for data structures callers pass the regex library.
X   Copyright (C) 1985 Free Software Foundation, Inc.
X
X		       NO WARRANTY
X
X  BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
XNO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
XWHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
XRICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
XWITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
XBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
XAND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
XDEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
XCORRECTION.
X
X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
XSTALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
XWHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
XLIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
XOTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
XUSE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
XDATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
XA FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
XPROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
XDAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
X
X		GENERAL PUBLIC LICENSE TO COPY
X
X  1. You may copy and distribute verbatim copies of this source file
Xas you receive it, in any medium, provided that you conspicuously and
Xappropriately publish on each copy a valid copyright notice "Copyright
X(C) 1985 Free Software Foundation, Inc."; and include following the
Xcopyright notice a verbatim copy of the above disclaimer of warranty
Xand of this License.  You may charge a distribution fee for the
Xphysical act of transferring a copy.
X
X  2. You may modify your copy or copies of this source file or
Xany portion of it, and copy and distribute such modifications under
Xthe terms of Paragraph 1 above, provided that you also do the following:
X
X    a) cause the modified files to carry prominent notices stating
X    that you changed the files and the date of any change; and
X
X    b) cause the whole of any work that you distribute or publish,
X    that in whole or in part contains or is a derivative of this
X    program or any part thereof, to be licensed at no charge to all
X    third parties on terms identical to those contained in this
X    License Agreement (except that you may choose to grant more extensive
X    warranty protection to some or all third parties, at your option).
X
X    c) You may charge a distribution fee for the physical act of
X    transferring a copy, and you may at your option offer warranty
X    protection in exchange for a fee.
X
XMere aggregation of another unrelated program with this program (or its
Xderivative) on a volume of a storage or distribution medium does not bring
Xthe other program under the scope of these terms.
X
X  3. You may copy and distribute this program (or a portion or derivative
Xof it, under Paragraph 2) in object code or executable form under the terms
Xof Paragraphs 1 and 2 above provided that you also do one of the following:
X
X    a) accompany it with the complete corresponding machine-readable
X    source code, which must be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    b) accompany it with a written offer, valid for at least three
X    years, to give any third party free (except for a nominal
X    shipping charge) a complete machine-readable copy of the
X    corresponding source code, to be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    c) accompany it with the information you received as to where the
X    corresponding source code may be obtained.  (This alternative is
X    allowed only for noncommercial distribution and only if you
X    received the program in object code or executable form alone.)
X
XFor an executable file, complete source code means all the source code for
Xall modules it contains; but, as a special exception, it need not include
Xsource code for modules which are standard libraries that accompany the
Xoperating system on which the executable file runs.
X
X  4. You may not copy, sublicense, distribute or transfer this program
Xexcept as expressly provided under this License Agreement.  Any attempt
Xotherwise to copy, sublicense, distribute or transfer this program is void and
Xyour rights to use the program under this License agreement shall be
Xautomatically terminated.  However, parties who have received computer
Xsoftware programs from you with this License Agreement will not have
Xtheir licenses terminated so long as such parties remain in full compliance.
X
X  5. If you wish to incorporate parts of this program into other free
Xprograms whose distribution conditions are different, write to the Free
XSoftware Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
Xworked out a simple rule that can be stated here, but we will often permit
Xthis.  We will be guided by the two goals of preserving the free status of
Xall derivatives of our free software and of promoting the sharing and reuse of
Xsoftware.
X
X
XIn other words, you are welcome to use, share and improve this program.
XYou are forbidden to forbid anyone else to use, share and improve
Xwhat you give them.   Help stamp out software-hoarding!  */
X
X
X#ifndef RE_NREGS
X#define RE_NREGS 10
X#endif
X
X/* This data structure is used to represent a compiled pattern. */
X
Xstruct re_pattern_buffer
X  {
X    char *buffer;	/* Space holding the compiled pattern commands. */
X    int allocated;	/* Size of space that  buffer  points to */
X    int used;		/* Length of portion of buffer actually occupied */
X    char *fastmap;	/* Pointer to fastmap, if any, or zero if none. */
X			/* re_search uses the fastmap, if there is one,
X			   to skip quickly over totally implausible characters */
X    char *translate;	/* Translate table to apply to all characters 
X                           before comparing.
X			   Or zero for no translation.
X			   The translation is applied to a pattern when it is compiled
X			   and to data when it is matched. */
X    char fastmap_accurate;
X			/* Set to zero when a new pattern is stored,
X			   set to one when the fastmap is updated from it. */
X    char can_be_null;   /* Set to one by compiling fastmap
X			   if this pattern might match the null string.
X			   It does not necessarily match the null string
X			   in that case, but if this is zero, it cannot.
X			   2 as value means can match null string
X			   but at end of range or before a character
X			   listed in the fastmap.  */
X  };
X
X/* Structure to store "register" contents data in.
X
X   Pass the address of such a structure as an argument to re_match, etc.,
X   if you want this information back.
X
X   start[i] and end[i] record the string matched by \( ... \) grouping i,
X   for i from 1 to RE_NREGS - 1.
X   start[0] and end[0] record the entire string matched. */
X
Xstruct re_registers
X  {
X    int start[RE_NREGS];
X    int end[RE_NREGS];
X  };
X
X/* These are the command codes that appear in compiled regular expressions, 
X  one per byte.
X  Some command codes are followed by argument bytes.
X  A command code can specify any interpretation whatever for its arguments.
X  Zero-bytes may appear in the compiled regular expression. */
X
Xenum regexpcode
X  {
X    unused,
X    exactn,    /* followed by one byte giving n, and then by n literal bytes */
X    begline,   /* fails unless at beginning of line */
X    endline,   /* fails unless at end of line */
X    jump,	 /* followed by two bytes giving relative address to jump to */
X    on_failure_jump,	 /* followed by two bytes giving relative address of place
X		            to resume at in case of failure. */
X    finalize_jump,	 /* Throw away latest failure point and then 
X			    jump to address. */
X    maybe_finalize_jump, /* Like jump but finalize if safe to do so.
X			    This is used to jump back to the beginning
X			    of a repeat.  If the command that follows
X			    this jump is clearly incompatible with the
X			    one at the beginning of the repeat, such that
X			    we can be sure that there is no use backtracking
X			    out of repetitions already completed,
X			    then we finalize. */
X    dummy_failure_jump,  /* jump, and push a dummy failure point.
X			    This failure point will be thrown away
X			    if an attempt is made to use it for a failure.
X			    A + construct makes this before the first repeat.  */
X    anychar,	 /* matches any one character */
X    charset,     /* matches any one char belonging to specified set.
X		    First following byte is # bitmap bytes.
X		    Then come bytes for a bit-map saying which chars are in.
X		    Bits in each byte are ordered low-bit-first.
X		    A character is in the set if its bit is 1.
X		    A character too large to have a bit in the map
X		    is automatically not in the set */
X    charset_not, /* similar but match any character that is NOT one 
X                    of those specified */
X    start_memory, /* starts remembering the text that is matched
X		    and stores it in a memory register.
X		    followed by one byte containing the register number.
X		    Register numbers must be in the range 0 through NREGS. */
X    stop_memory, /* stops remembering the text that is matched
X		    and stores it in a memory register.
X		    followed by one byte containing the register number.
X		    Register numbers must be in the range 0 through NREGS. */
X    duplicate,    /* match a duplicate of something remembered.
X		    Followed by one byte containing the index of the memory register. */
X    before_dot,	 /* Succeeds if before dot */
X    at_dot,	 /* Succeeds if at dot */
X    after_dot,	 /* Succeeds if after dot */
X    begbuf,      /* Succeeds if at beginning of buffer */
X    endbuf,      /* Succeeds if at end of buffer */
X    wordchar,    /* Matches any word-constituent character */
X    notwordchar, /* Matches any char that is not a word-constituent */
X    wordbeg,	 /* Succeeds if at word beginning */
X    wordend,	 /* Succeeds if at word end */
X    wordbound,   /* Succeeds if at a word boundary */
X    notwordbound, /* Succeeds if not at a word boundary */
X    syntaxspec,  /* Matches any character whose syntax is specified.
X		    followed by a byte which contains a syntax code, Sword 
X	            or such like */
X    notsyntaxspec /* Matches any character whose syntax differs from 
X                     the specified. */
X  };
X
Xextern char *re_compile_pattern ();
X/* Is this really advertised? */
Xextern void re_compile_fastmap ();
Xextern int re_search (), re_search_2 ();
Xextern int re_match (), re_match_2 ();
X
X/* 4.2 bsd compatibility (yuck) */
Xextern char *re_comp ();
Xextern int re_exec ();
X
X#ifdef SYNTAX_TABLE
Xextern char *re_syntax_table;
X#endif
END_OF_FILE
if test 10832 -ne `wc -c <'regex.h'`; then
    echo shar: \"'regex.h'\" unpacked with wrong size!
fi
# end of 'regex.h'
fi
if test -f 'utils.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'utils.c'\"
else
echo shar: Extracting \"'utils.c'\" \(6085 characters\)
sed "s/^X//" >'utils.c' <<'END_OF_FILE'
X/*
X * xmail - X window system interface to the mail program
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author:	Po Cheung
X * Date:	March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation.  The University of Texas at Austin makes no 
X * representations about the suitability of this software for any purpose.  
X * It is provided "as is" without express or implied warranty.
X *
X * Copyright 1990 by National Semiconductor Corporation
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of National Semiconductor Corporation not
X * be used in advertising or publicity pertaining to distribution of the
X * software without specific, written prior permission.
X *
X * NATIONAL SEMICONDUCTOR CORPORATION MAKES NO REPRESENTATIONS ABOUT THE
X * SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE.  IT IS PROVIDED "AS IS"
X * WITHOUT EXPRESS OR IMPLIED WARRANTY.  NATIONAL SEMICONDUCTOR CORPORATION
X * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO
X * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
X * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
X * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
X * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X * PERFORMANCE OF THIS SOFTWARE.
X *
X * The following software modules were created and are Copyrighted by National
X * Semiconductor Corporation:
X *
X * 1. Normalize: and
X * 2. PositionToMsgNumber.
X *
X * Author:  Michael C. Wagnitz - National Semiconductor Corporation
X *
X */
X
X
X#include <ctype.h>
X#include "global.h"
X
X
X/*
X** @(#)TextGetLastPos() - return value of text insert position
X*/
XXtTextPosition
XTextGetLastPos(w)
XWidget w;
X{
X TextWidget ctx = (TextWidget) w;
X return (ctx->text.lastPos);
X}
X
X
X/*
X** @(#)Normalize() - Position insertion pointer at end of any text
X*/
Xvoid
XNormalize(w)
XWidget	w;
X{
X Arg		args[1];
X XtTextPosition lastPos;
X
X
X lastPos = TextGetLastPos(w);
X XtTextSetInsertionPoint(w, lastPos);
X/*
X** Display text starting from the top
X*/
X XtSetArg(args[0], XtNdisplayPosition, (XtArgVal) 0);
X XtSetValues(w, args, ONE);
X} /* Normalize */
X
X
X/*
X** @(#)writeText() - write text to the current string source
X*/
Xvoid
XwriteText(w, s, do_append)
XWidget	w;
Xchar   *s;
Xint	do_append;
X{
X XtTextBlock 	textblock;
X XtTextPosition	startPos, endPos;
X Arg            args[MAXARGS];
X int		status;
X
X
X if (!s || strcmp(s, "") == 0) return;
X
X#ifndef X11R3
X if (w == WidgetOf(WidgetOf(toplevel, "vpane"), "indexWindow"))
X    if (strlen(s) > INDEXSIZE) {
X       INDEXSIZE = strlen(s) + 1;
X       IndexBuf = XtRealloc(IndexBuf, INDEXSIZE);
X       XtSetArg(args[0], XtNstring, (XtArgVal) IndexBuf);
X       XtSetArg(args[1], XtNlength, (XtArgVal) INDEXSIZE);
X       XtSetValues(w, args, TWO);
X      }
X#endif
X
X textblock.firstPos = 0;
X textblock.length   = strlen(s);
X textblock.ptr      = s;
X textblock.format   = FMT8BIT;
X
X endPos = TextGetLastPos(w) + (do_append ? 0 : 1);
X startPos = (do_append ? endPos : 0);
X
X XtTextReplace(w, startPos, endPos, &textblock);
X
X Normalize(w);
X} /* writeText */
X
X
X/*
X** @(#)PositionToMsgNumber() - Get mail index number from line position
X*/
Xint
XPositionToMsgNumber(pos)
XXtTextPosition pos;
X{
X int	j = 0;			/* return zero if no valid message exists */
X char	*s;
X 
X for (s = IndexBuf + pos; s > IndexBuf && *(s-1) != '\n'; s--);
X for (s++; *s && !isdigit(*s); s++);
X sscanf(s, "%d", &j);
X return j;
X} /* PositionToMsgNumber */
X
X
X/*
X** @(#)Bell() - write status message and (optionally) ring bell
X*/
Xvoid
XBell(msg)
XString	msg;
X{
X Arg	args[1];
X char	*p, *strchr();
X int	worthy = 0;			/* only msgs with ending newline are */
X
X
X if ((p = strchr(msg, '\n')) != NULL) {	/* Only display first line of output */
X    *p = '\0';				/* (and no new line at end of label) */
X    worthy = 1;
X   }
X
X XtSetArg(args[0], XtNlabel, (XtArgVal) msg);	/* show the error message */
X XtSetValues(WidgetOf(WidgetOf(toplevel, "vpane"), "statusWindow"), args, ONE);
X
X if (worthy && XMail.bellRing)		/* ring bell if not silenced by user */
X    XBell(XtDisplay(toplevel), 33);
X} /* Bell */
X
X
X/*
X** @(#)UpdateTitleBar() - replace information in the title bar label
X*/
Xvoid
XUpdateTitleBar(format, arg)
Xchar *format, *arg;
X{
X char		message[BUFSIZ], string[BUFSIZ];
X Arg		args[1];
X Widget		w, m;
X
X
X w = WidgetOf(WidgetOf(WidgetOf(toplevel, "vpane"), "titleBar"), "titleBar");
X
X sprintf(string, format, arg);
X sprintf(message, "%s - %s", TITLE, string);
X XtSetArg(args[0], XtNlabel, (XtArgVal) message);
X XtSetValues(w, args, ONE);
X 
X w = WidgetOf(WidgetOf(WidgetOf(toplevel, "vpane"), "commandPanel"), "hold");
X    XtSetSensitive(w, (string[1] == '+') ? False : True);
X
X w = WidgetOf(WidgetOf(WidgetOf(toplevel,"vpane"),"commandPanel"),"Newmail");
X m = WidgetOf(WidgetOf(WidgetOf(w, "Newmail_menu"), "menu"), "inc");
X if (m)
X    XtSetSensitive(m, (string[1] == '+') ? False : True);
X} /* UpdateTitleBar */
X
X
X/*
X** @(#)writeTo() - install a new text source for the textWindow widget
X*/
Xvoid
XwriteTo(w, s)
XWidget	w;
Xchar	*s;
X{
X Arg 	args[MAXARGS];
X Cardinal 	n;
X static XtTextSource	old, new;
X
X if (s && *s) {
X    n = 0;
X    XtSetArg(args[n], XtNstring, (XtArgVal) s);			n++;
X    XtSetArg(args[n], XtNlength, (XtArgVal) strlen(s));		n++;
X    XtSetArg(args[n], XtNeditType, (XtArgVal) XttextRead);	n++;
X
X    new = XtStringSourceCreate(w, args, n);
X    XtTextSetSource(w, new, (XtTextPosition) 0);
X    if (old)
X       XtStringSourceDestroy(old);
X    old = new;
X   }
X} /* writeTo */
END_OF_FILE
if test 6085 -ne `wc -c <'utils.c'`; then
    echo shar: \"'utils.c'\" unpacked with wrong size!
fi
# end of 'utils.c'
fi
if test -f 'xmail.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xmail.c'\"
else
echo shar: Extracting \"'xmail.c'\" \(11987 characters\)
sed "s/^X//" >'xmail.c' <<'END_OF_FILE'
X/*
X * xmail - X window system interface to the mail program
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author:	Po Cheung
X * Date:	March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation.  The University of Texas at Austin makes no 
X * representations about the suitability of this software for any purpose.  
X * It is provided "as is" without express or implied warranty.
X *
X * Copyright 1990 by National Semiconductor Corporation
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of National Semiconductor Corporation not
X * be used in advertising or publicity pertaining to distribution of the
X * software without specific, written prior permission.
X *
X * NATIONAL SEMICONDUCTOR CORPORATION MAKES NO REPRESENTATIONS ABOUT THE
X * SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE.  IT IS PROVIDED "AS IS"
X * WITHOUT EXPRESS OR IMPLIED WARRANTY.  NATIONAL SEMICONDUCTOR CORPORATION
X * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO
X * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
X * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
X * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
X * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X * PERFORMANCE OF THIS SOFTWARE.
X *
X * The following software modules were created and are Copyrighted by National
X * Semiconductor Corporation:
X *
X * 1. initialize: and
X * 2. SetHints.
X *
X * Author:  Michael C. Wagnitz - National Semiconductor Corporation
X *
X */
X
X#include "global.h"
X#include "Mailwatch.h"			/* use as icon and watch for newmail */
X#ifdef X11R3
X#include <X11/CommandP.h>
X#else
X#include <X11/Xaw/CommandP.h>
X#endif
X#include "icon.nomail"			/* default icon pixmap source */
X#include <X11/cursorfont.h>		/* use watch cursor for busy notify */
X#include <X11/bitmaps/cross_weave>	/* background use in Newmail notify */
X
X#define Offset(field) (XtOffset(XmailResources *, field))
X
Xstatic char what[] =
X "@(#)xmail.c 1.0 90/03/19 Copyright 1989 National Semiconductor Corp.";
X
Xstatic XtResource resrcs[] = {
X    {XtNfont, XtCFont, XtRString, sizeof(char *),
X        Offset(textFont), XtRString, (caddr_t) NULL},
X    {"bellRing", "BellRing", XtRBoolean, sizeof(Boolean), 
X	Offset(bellRing), XtRImmediate, (caddr_t) True},
X    {"helpFont", "HelpFont", XtRString, sizeof(char *),
X        Offset(helpFont), XtRString, (caddr_t) NULL},
X    {"mailopt_i", "Mailopt_i", XtRBoolean, sizeof(Boolean), 
X	Offset(mailopt_i), XtRImmediate, (caddr_t) False},
X    {"mailopt_n", "Mailopt_n", XtRBoolean, sizeof(Boolean), 
X	Offset(mailopt_n), XtRImmediate, (caddr_t) False},
X    {"mailopt_U", "Mailopt_U", XtRBoolean, sizeof(Boolean), 
X	Offset(mailopt_U), XtRImmediate, (caddr_t) False},
X    {"MFileName", "MFileName", XtRString, sizeof(char *), 
X	Offset(MFileName), XtRImmediate, (caddr_t) NULL},
X    {"SubjectStr", "SubjectStr", XtRString, sizeof(char *), 
X	Offset(SubjectStr), XtRImmediate, (caddr_t) NULL},
X    {"Show_Last", "Show_Last", XtRBoolean, sizeof(Boolean), 
X	Offset(Show_Last), XtRImmediate, (caddr_t) True},
X};
X
Xstatic XrmOptionDescRec Opts[] = {
X    {"-nb",	"*bellRing",	XrmoptionNoArg, (caddr_t) "False"},
X    {"-helpfont", "*helpFont",	XrmoptionSepArg, (caddr_t) NULL},
X    {"-i",	"*mailopt_i",	XrmoptionNoArg, (caddr_t) "True"},
X    {"-n",	"*mailopt_n",	XrmoptionNoArg, (caddr_t) "True"},
X    {"-U",	"*mailopt_U",	XrmoptionNoArg, (caddr_t) "True"},
X    {"-f",	"*MFileName",	XrmoptionSepArg, (caddr_t) NULL},
X    {"-s",	"*SubjectStr",	XrmoptionSepArg, (caddr_t) NULL},
X    {"-ls",	"*Show_Last",	XrmoptionNoArg, (caddr_t) "False"},
X};
X
Xchar	*IndexBuf;		/* buffer for index widget	*/
Xchar	Command[BUFSIZ];	/* xmail command string		*/
Xchar 	Recipient[BUFSIZ];	/* message addressee		*/
Xchar	FileBuf[BUFSIZ];	/* buffer for file widget	*/
Xchar 	SubjBuf[BUFSIZ];	/* message subject		*/
Xchar 	InReply[BUFSIZ];	/* reply reference string	*/
Xchar 	CcBuf[BUFSIZ];		/* message Cc list		*/
Xchar 	tmpName[BUFSIZ];	/* message temporary filename	*/
Xchar 	MailPrompt[20];		/* mail program prompt string	*/
Xchar	*HelpNames[23];		/* array of help window names	*/
Xchar	**mailargv;		/* array passed to mail child	*/
X
Xint	mailargc;		/* counter passed to mail child	*/
Xint	RootWidth, RootHeight;
Xint	Highlighted;		/* state of 'Newmail' highlighting */
Xint	INDEXSIZE;		/* default size of index window buffer */
X
XCursor	waitC;
XCursor	xtermC;
XPixmap	hatch;			/* cross_weave pattern, used on Newmail */
XWidget  toplevel; 		/* top level shell widget */
X
XXmailResources 	XMail;		/* application resources of xmail */
XXtTextSource	HelpStrings[22];
XXFontStruct	*TextFontStr, *HelpFontStr;
X
X
X/*
X** @(#)mailoptions() - construct command line arguments for calling mail.
X** Return the argument list for mail and new value of argc.
X*/
Xchar **
Xmailoptions(argc, argv, XMail)
Xint  *argc;
Xchar **argv;
XXmailResources *XMail;
X{
X char **mailargv;
X int  i = 0;
X
X mailargv = (char **) XtMalloc (MAXARGS * sizeof(char *));
X for (i=0; i < *argc; i++)
X	mailargv[i] = argv[i];
X
X    mailargv[i++] = "-N";		/* no version or header info at start */
X    if (XMail->mailopt_i)
X	mailargv[i++] = "-i";		/* ignore interrupts */
X    if (XMail->mailopt_n)
X	mailargv[i++] = "-n";		/* don't initialize from mailrc files */
X    if (XMail->mailopt_U)
X	mailargv[i++] = "-U";		/* Change uucp to Internet addresses */
X    if (XMail->MFileName) {
X	mailargv[i++] = "-f";		/* start from mail folder MFileName */
X	mailargv[i++] = XMail->MFileName;
X      }
X    if (XMail->SubjectStr) {		/* set subject string to SubjectStr */
X	strcpy(SubjBuf, XMail->SubjectStr);
X      }
X    mailargv[i] = NULL;
X    *argc = i;
X    return mailargv;
X} /* mailoptions */
X
X
X/*
X** @(#)initialize() - establish xmail program defaults and setups
X*/
Xvoid
Xinitialize(pgm)
Xchar	*pgm;
X{
X Cardinal	buttonSpace, i = 0;
X char		*txt;
X
X HelpNames[i++] = "Cc";		HelpNames[i++] = "copy";
X HelpNames[i++] = "delete";	HelpNames[i++] = "Deliver";
X HelpNames[i++] = "file";	HelpNames[i++] = "folder";
X HelpNames[i++] = "hold";	HelpNames[i++] = "index";
X HelpNames[i++] = "Newmail";	HelpNames[i++] = "Print";
X HelpNames[i++] = "quit";	HelpNames[i++] = "read";
X HelpNames[i++] = "reply";	HelpNames[i++] = "save";
X HelpNames[i++] = "Send";	HelpNames[i++] = "status";
X HelpNames[i++] = "Subject";	HelpNames[i++] = "text";
X HelpNames[i++] = "title";	HelpNames[i++] = "To";
X HelpNames[i++] = "Autograph";	HelpNames[i]   = NULL;
X
X strcpy(Command, "Start");		/* let parser know we've started */
X Recipient[0] = SubjBuf[0] = CcBuf[0] = '\0';
X
X INDEXSIZE = 10000;
X IndexBuf = (char *) XtMalloc(INDEXSIZE);
X
X txt = GetMailrc("prompt");
X if (! txt)
X    strcpy(MailPrompt, "& ");
X else {
X    strcpy(MailPrompt, txt);
X    XtFree(txt);
X   }
X
X sprintf(tmpName, "/tmp/xmail%d", getpid());
X/*
X** Retrieve the specified or default font and set some appropriate dimensions
X*/
X if (XMail.textFont == NULL)
X     XMail.textFont = XtNewString("9x15");
X
X if (! (TextFontStr = XLoadQueryFont(XtDisplay(toplevel), XMail.textFont))) {
X    fprintf(stderr, "%s: Can't open text font %s\n", pgm, XMail.textFont);
X    exit(-1);
X   }
X
X if (XMail.helpFont == NULL)
X     XMail.helpFont = XtNewString("8x13bold");
X
X if (! (HelpFontStr = XLoadQueryFont(XtDisplay(toplevel), XMail.helpFont))) {
X    fprintf(stderr, "%s: Can't open help font %s\n", pgm, XMail.helpFont);
X    exit(-1);
X   }
X/*
X** Compute all window dimensions based on extents of the specified fonts.
X** Make shell wide enough to hold eight buttons on a row.  Total button width
X** includes width of text area plus width of separation plus width of border.
X*/
X XMail.commandHSpace    = 10;
X XMail.commandVSpace    = 10;
X XMail.buttonHeight	= TEXTHEIGHT *  1.6;
X XMail.buttonWidth	= TEXTWIDTH  *  8.5;
X       buttonSpace      = XMail.buttonWidth + XMail.commandHSpace + 2;
X XMail.shellWidth       = (8 * buttonSpace) + 24;    /*  8 buttons per row */
X XMail.fileBoxWidth     = (4 * buttonSpace) + XMail.buttonWidth + 2;
X XMail.helpHeight       = HELPHEIGHT * 14;           /* 14 lines long by */
X XMail.helpWidth        = HELPWIDTH  * 60;           /* 60 characters wide */
X XMail.helpX		= (XMail.shellWidth - XMail.helpWidth) / 2;
X XMail.helpY            = 70;
X XMail.indexHeight      = 240;
X XMail.textHeight       = 450;
X XMail.textMinHeight    = 150;
X XMail.commandMinHeight = (XMail.buttonHeight*2) + (XMail.commandVSpace*3) + 4;
X XMail.menuX            = 15;
X XMail.menuY            = 7;
X
X parser_init();
X
X} /* initialize */
X
X
X/*
X** @(#)SetHints() - Set Normal and WindowManager hints, cursor and hatching
X*/
XSetHints()
X{
X Arg		args[MAXARGS];
X Cardinal	n;
X Display	*dpy;
X XSizeHints	size_hints;
X XWMHints	wm_hints, *hints;
X int		scn, depth;
X CommandWidget  nm = (CommandWidget)WidgetOf(WidgetOf(WidgetOf(toplevel, "vpane"), "commandPanel"), "Newmail");
X
X
X dpy = XtDisplay(toplevel);
X scn = DefaultScreen(dpy);
X depth = DefaultDepth(dpy, scn);
X RootWidth = XDisplayWidth(dpy, scn) - 1;
X RootHeight = XDisplayHeight(dpy, scn) - 1;
X waitC = XCreateFontCursor(dpy, XC_watch);
X xtermC = XCreateFontCursor(dpy, XC_xterm);
X hatch = XCreatePixmapFromBitmapData(dpy, XtScreen(toplevel)->root,
X                cross_weave_bits, cross_weave_width, cross_weave_height,
X                nm->label.foreground,
X                nm->core.background_pixel, depth);
X
X size_hints.flags = PSize | PMinSize;
X size_hints.width = XMail.shellWidth;
X size_hints.min_width = size_hints.max_width = size_hints.width;
X size_hints.height = XMail.indexHeight + XMail.textHeight +
X                     XMail.commandMinHeight +  (2 * XMail.buttonHeight) + 6;
X size_hints.min_height = size_hints.max_height = size_hints.height;
X
X XSetNormalHints(XtDisplay(toplevel), XtWindow(toplevel), &size_hints);
X/*
X** Notify the window manager about our icon window
X** Use XGetWMHints to retain icon initial_state and position
X*/
X hints = XGetWMHints(XtDisplay(toplevel),
X                     XtWindow(XtNameToWidget(toplevel, "icon")));
X
X wm_hints.input = True;
X wm_hints.initial_state = hints->initial_state;	/* take care of iconic state */
X wm_hints.icon_x = hints->icon_x;		/* restore icon position */
X wm_hints.icon_y = hints->icon_y;
X wm_hints.flags  = InputHint | StateHint;
X
X XFree(hints);
X
X#ifndef PIXMAP_ICON
X wm_hints.flags |= IconWindowHint;
X wm_hints.icon_window = XtWindow(XtNameToWidget(toplevel, "icon"));
X#else
X wm_hints.flags |= IconPixmapHint;
X wm_hints.icon_pixmap = XCreateBitmapFromData(dpy, XtScreen(toplevel)->root,
X                                 no_mail_bits, no_mail_width, no_mail_height);
X#endif
X
X XSetWMHints(dpy, XtWindow(toplevel), &wm_hints);
X
X} /* SetHints */
X
X
X/*
X** @(#)main() - main routine for x11 interface to the mail utility
X*/
Xmain(argc, argv)
Xint	argc;
Xchar	**argv;
X{
X Arg args[2];
X
X
X toplevel = XtInitialize(*argv, "XMail", Opts, XtNumber(Opts), &argc, argv);
X
X XtGetApplicationResources(toplevel, &XMail, resrcs, XtNumber(resrcs), NULL, 0);
X
X if (argc > 1) {
X    fprintf(stderr, "Usage: %s [-toolkitoptions] [-xmailoptions]\n", *argv);
X    exit(-1);
X   }
X
X initialize(*argv);
X
X mailargc = argc;
X mailargv = mailoptions(&mailargc, argv, &XMail);
X
X CreateSubWindows(toplevel);
X
X XtSetArg(args[0], XtNinput, (XtArgVal) True);
X XtSetArg(args[1], XtNiconWindow, XtWindow(XtNameToWidget(toplevel, "icon")));
X XtSetValues(toplevel, args, TWO);
X
X XtRealizeWidget(toplevel);
X
X SetHints();
X
X callMail(mailargc, mailargv);
X
X XtMainLoop();
X} /* main */
END_OF_FILE
if test 11987 -ne `wc -c <'xmail.c'`; then
    echo shar: \"'xmail.c'\" unpacked with wrong size!
fi
# end of 'xmail.c'
fi
echo shar: End of archive 4 \(of 6\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 6 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 6 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0

dan
-----------------------------------------------------------
		    O'Reilly && Associates
		argv at sun.com / argv at ora.com
	   632 Petaluma Ave, Sebastopol, CA 95472 
     800-338-NUTS, in CA: 800-533-NUTS, FAX 707-829-0104
    Opinions expressed reflect those of the author only.



More information about the Comp.sources.x mailing list