home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume15 / xmail / part08 / xmail.c < prev    next >
C/C++ Source or Header  |  1991-10-29  |  20KB  |  514 lines

  1. /*
  2.  * xmail - X window system interface to the mail program
  3.  *
  4.  * Copyright 1989 The University of Texas at Austin
  5.  *
  6.  * Author:    Po Cheung
  7.  * Date:    March 10, 1989
  8.  *
  9.  * Permission to use, copy, modify, and distribute this software and
  10.  * its documentation for any purpose and without fee is hereby granted,
  11.  * provided that the above copyright notice appear in all copies and that
  12.  * both that copyright notice and this permission notice appear in
  13.  * supporting documentation.  The University of Texas at Austin makes no 
  14.  * representations about the suitability of this software for any purpose.  
  15.  * It is provided "as is" without express or implied warranty.
  16.  *
  17.  * Copyright 1990,1991 by National Semiconductor Corporation
  18.  *
  19.  * Permission to use, copy, modify, and distribute this software and its
  20.  * documentation for any purpose is hereby granted without fee, provided that
  21.  * the above copyright notice appear in all copies and that both that
  22.  * copyright notice and this permission notice appear in supporting
  23.  * documentation, and that the name of National Semiconductor Corporation not
  24.  * be used in advertising or publicity pertaining to distribution of the
  25.  * software without specific, written prior permission.
  26.  *
  27.  * NATIONAL SEMICONDUCTOR CORPORATION MAKES NO REPRESENTATIONS ABOUT THE
  28.  * SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE.  IT IS PROVIDED "AS IS"
  29.  * WITHOUT EXPRESS OR IMPLIED WARRANTY.  NATIONAL SEMICONDUCTOR CORPORATION
  30.  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
  31.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO
  32.  * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
  33.  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  34.  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  35.  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  36.  * PERFORMANCE OF THIS SOFTWARE.
  37.  *
  38.  * The following software modules were created and are Copyrighted by National
  39.  * Semiconductor Corporation:
  40.  *
  41.  * 1. initialize: and
  42.  * 2. SetHints.
  43.  *
  44.  * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  45.  *
  46.  */
  47.  
  48. #include "global.h"
  49. #include "Mailwatch.h"            /* use as icon and watch for newmail */
  50. #include <X11/Xaw/CommandP.h>
  51. #include <X11/Xaw/TextP.h>
  52. #include <X11/cursorfont.h>        /* use watch cursor for busy notify */
  53. #include <X11/bitmaps/cross_weave>    /* background use in Newmail notify */
  54.  
  55. #ifndef    lint
  56. static char what[] =
  57.  "@(#)xmail.c 1.4 91/09/20 Copyright 1989,1990,1991 National Semiconductor Corp.";
  58. #endif
  59.  
  60. #ifndef    DEFAULT_PROMPT
  61. #define    DEFAULT_PROMPT    "& "
  62. #endif
  63.  
  64. #define Offset(field) (XtOffset(XmailResources *, field))
  65.  
  66. static XtResource resrcs[] = {
  67.     {"textFont", XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  68.     Offset(textFont), XtRString, XtDefaultFont},
  69.     {"helpFont", XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  70.     Offset(helpFont), XtRString, XtDefaultFont},
  71.     {"buttonFont", XtCFont, XtRFontStruct, sizeof (XFontStruct *),
  72.     Offset(buttonFont), XtRString, XtDefaultFont},
  73.     {"iconGeometry", "IconGeometry", XtRString, sizeof(char *),
  74.         Offset(iconGeometry), XtRString, (caddr_t) NULL},
  75.     {"mFileName", "MFileName", XtRString, sizeof(char *), 
  76.     Offset(MFileName), XtRString, (caddr_t) NULL},
  77.     {"editorCommand", "EditorCommand", XtRString, sizeof(char *), 
  78.     Offset(editorCommand), XtRString, (caddr_t) NULL},
  79.     {"bellRing", "BellRing", XtRBoolean, sizeof(Boolean), 
  80.     Offset(bellRing), XtRImmediate, (caddr_t) True},
  81.     {"expert", "Expert", XtRBoolean, sizeof(Boolean), 
  82.     Offset(expert), XtRImmediate, (caddr_t) False},
  83.     {"iconic", "Iconic", XtRBoolean, sizeof(Boolean), 
  84.     Offset(iconic), XtRImmediate, (caddr_t) False},
  85.     {"mailopt_n", "Mailopt_n", XtRBoolean, sizeof(Boolean), 
  86.     Offset(mailopt_n), XtRImmediate, (caddr_t) False},
  87.     {"mailopt_U", "Mailopt_U", XtRBoolean, sizeof(Boolean), 
  88.     Offset(mailopt_U), XtRImmediate, (caddr_t) False},
  89.     {"show_Last", "Show_Last", XtRBoolean, sizeof(Boolean), 
  90.     Offset(Show_Last), XtRImmediate, (caddr_t) True},
  91.     {"show_Info", "Show_Info", XtRBoolean, sizeof(Boolean), 
  92.     Offset(Show_Info), XtRImmediate, (caddr_t) True},
  93.     {"no_X_Hdr", "No_X_Hdr", XtRBoolean, sizeof(Boolean), 
  94.     Offset(No_X_Hdr), XtRImmediate, (caddr_t) False},
  95.     { XtNborderWidth, XtCBorderWidth, XtRInt, sizeof (int),
  96.     Offset(borderWidth), XtRString, "1"},
  97. };
  98.  
  99. #undef Offset
  100.  
  101. static XrmOptionDescRec Opts[] = {
  102.     {"-borderwidth",    ".TopLevelShell.borderWidth",    XrmoptionSepArg,    (caddr_t) NULL},
  103.     {"-buttonfont",    "*buttonFont",            XrmoptionSepArg,    (caddr_t) NULL},
  104.     {"-buttonFont",    "*buttonFont",            XrmoptionSepArg,    (caddr_t) NULL},
  105.     {"-bw",        ".TopLevelShell.borderWidth",    XrmoptionSepArg,    (caddr_t) NULL},
  106.     {"-editorcommand",    "*editorCommand",        XrmoptionSepArg,    (caddr_t) NULL},
  107.     {"-editorCommand",    "*editorCommand",        XrmoptionSepArg,    (caddr_t) NULL},
  108.     {"-e",        "*expert",            XrmoptionNoArg,        (caddr_t) "True"},
  109.     {"-f",        "*MFileName",            XrmoptionSepArg,    (caddr_t) NULL},
  110.     {"-fn",        "*Font",            XrmoptionSepArg,    (caddr_t) NULL},
  111.     {"-font",        "*Font",            XrmoptionSepArg,    (caddr_t) NULL},
  112.     {"-geometry",    ".geometry",            XrmoptionSepArg,    (caddr_t) NULL},
  113.     {"-helpfont",    "*helpFont",            XrmoptionSepArg,    (caddr_t) NULL},
  114.     {"-helpFont",    "*helpFont",            XrmoptionSepArg,    (caddr_t) NULL},
  115.     {"-iconGeometry",    "*iconGeometry",        XrmoptionSepArg,    (caddr_t) NULL},
  116.     {"-iconic",        "*iconic",            XrmoptionNoArg,        (caddr_t) "True"},
  117.     {"-ls",        "*show_Last",            XrmoptionNoArg,        (caddr_t) "False"},
  118.     {"-m",        "*icon*useHost",        XrmoptionNoArg,        (caddr_t) "True"},
  119.     {"-n",        "*mailopt_n",            XrmoptionNoArg,        (caddr_t) "True"},
  120.     {"-nb",        "*bellRing",            XrmoptionNoArg,        (caddr_t) "False"},
  121.     {"-noinfo",        "*show_Info",            XrmoptionNoArg,        (caddr_t) "False"},
  122.     {"-nx",        "*no_X_Hdr",            XrmoptionNoArg,        (caddr_t) "True"},
  123.     {"-rv",        "*icon*reverseVideo",        XrmoptionNoArg,        (caddr_t) "True"},
  124.     {"-textfont",    "*textFont",            XrmoptionSepArg,    (caddr_t) NULL},
  125.     {"-textFont",    "*textFont",            XrmoptionSepArg,    (caddr_t) NULL},
  126.     {"-U",        "*mailopt_U",            XrmoptionNoArg,        (caddr_t) "True"},
  127.     {"-u",        "*icon*useName",        XrmoptionNoArg,        (caddr_t) "True"},
  128.     {"-xrm",        NULL,                XrmoptionResArg,    (caddr_t) NULL},
  129. };
  130.  
  131. Atom        wmDeleteWindow;
  132.  
  133. int        mailargc;        /* counter passed to mail child    */
  134. int        RootWidth, RootHeight;
  135. int        Highlighted;        /* state of 'Newmail' highlighting */
  136.  
  137. char        Command[BUFSIZ];    /* xmail command string */
  138. char         InReply[BUFSIZ];    /* reply reference string */
  139. char         tmpName[BUFSIZ];    /* message temporary filename */
  140. char        *mailargv[7];        /* array passed to mail child */
  141.  
  142. Pixmap        hatch;            /* cross_weave used to note Newmail */
  143. Widget        toplevel;         /* top level shell widget */
  144. Window        WaitCursorWindow;
  145. helpList    HelpList;
  146.  
  147. XmailResources     XMail;            /* application resources of xmail */
  148.  
  149. /*
  150. ** @(#)mailoptions() - construct command line arguments for calling mail.
  151. **                     Return the argument list for mail and new value of argc.
  152. */
  153. int
  154. mailoptions()
  155. {
  156.  XWMHints    *wm_hints;
  157.  int        i;
  158.  char        *Mailpgm;        /* name of executable Mailpgm */
  159.  
  160.  
  161.  if (! (Mailpgm = (char *)getenv("XMAILER")))    /* first looks up env var */
  162.     Mailpgm = DEFAULT_MAILER;
  163.  
  164.  
  165.  wm_hints = XGetWMHints(XtDisplay(toplevel), XtWindow(toplevel));
  166.  
  167.  i = 0;
  168.  mailargv[i++] = Mailpgm;    /* Argv[0] is the name of the program */
  169.  mailargv[i++] = "-N";        /* no version or header info at start */
  170.  if (XMail.mailopt_n)
  171.     mailargv[i++] = "-n";    /* don't initialize from Mail.rc file */
  172.  if (XMail.mailopt_U)
  173.     mailargv[i++] = "-U";    /* Change uucp to Internet addresses */
  174.  
  175.  if (wm_hints->initial_state == IconicState) {    /* start iconic in bogus */
  176.     FILE    *fp;
  177.     char    bogus[BUFSIZ];
  178.  
  179.     (void) sprintf(bogus, "%s+", tmpName);
  180.     if (fp = fopen(bogus, "w")) {    /* create our bogus mail file */
  181.        (void) fprintf(fp, "\n");
  182.        (void) fclose(fp);
  183.        mailargv[i++] = "-f";        /* start in our bogus mail folder */
  184.        mailargv[i++] = bogus;
  185.        In_Bogus_Mail_File = True;
  186.       }
  187.    } else if (XMail.MFileName) {
  188.          mailargv[i++] = "-f";    /* start from mail folder MFileName */
  189.          mailargv[i++] = XMail.MFileName;
  190.             }
  191.  mailargv[i] = NULL;
  192.  XFree(wm_hints);
  193.  return (i);
  194. } /* mailoptions */
  195.  
  196.  
  197. /*
  198. ** @(#)initialize() - establish xmail program defaults and setups
  199. */
  200. void
  201. initialize()
  202. {
  203.  String        disp, file;
  204.  long        buttonSpace, i;
  205.  Display    *dpy = XtDisplay(toplevel);
  206.  char        *str_type[20];
  207.  XrmValue    value;
  208.  
  209.  
  210.  if (XrmGetResource(dpy->db, "command.borderWidth", "Command.BorderWidth",
  211.     str_type, &value)) {
  212.     if ((i = atoi(value.addr)) > XMail.borderWidth)
  213.        XMail.borderWidth = i;
  214.    }
  215.  
  216.  if (XrmGetResource(dpy->db, "send.borderWidth", "Send.BorderWidth",
  217.     str_type, &value)) {
  218.     if ((i = atoi(value.addr)) > XMail.borderWidth)
  219.        XMail.borderWidth = i;
  220.    }
  221.  
  222.  HelpList.indx = 0;
  223.  
  224.  (void) strcpy(Command, "Start");    /* let parser know we've started */
  225.  
  226.  (void) sprintf(tmpName, "/tmp/xmail%d", getpid());
  227. /*
  228. ** TRAP any stupid attempt to set the border width of this application to less
  229. ** than the allowed minimum (0) or greater than an acceptable maximum.  This
  230. ** to prevent a really wierd reaction to a negative number for border width.
  231. */
  232.  if (XMail.borderWidth < 0)
  233.      XMail.borderWidth = 1;
  234.  if (XMail.borderWidth > 6)
  235.      XMail.borderWidth = 6;
  236. /*
  237. ** Compute all window dimensions based on extents of the specified fonts.
  238. ** Make shell wide enough to hold eight buttons on a row.  Total button width
  239. ** includes width of text area plus width of separation plus width of border.
  240. */
  241.  XMail.commandHSpace    = 10;
  242.  XMail.commandVSpace    = 10;
  243.  XMail.buttonHeight    = CHARHEIGHT(XMail.buttonFont) + (XMail.buttonFont->ascent / 2);
  244.  XMail.buttonWidth    = figureWidth(XMail.buttonFont) * 9; /* ' NewMail ' */
  245.        buttonSpace    = XMail.borderWidth * 2;
  246.        buttonSpace    += XMail.buttonWidth + XMail.commandHSpace;
  247.  XMail.shellWidth    = (8 * buttonSpace) + 26;    /*  8 buttons per row */
  248.  XMail.fileBoxWidth    = (4 * buttonSpace) + XMail.buttonWidth;
  249.  XMail.helpHeight    = CHARHEIGHT(XMail.helpFont) * 14 + 5;
  250.  XMail.helpWidth    = figureWidth(XMail.helpFont) * 60 + 5;
  251.  XMail.helpX        = (XMail.shellWidth - XMail.helpWidth) / 2;
  252.  XMail.helpY        = 70;
  253.        buttonSpace    = CHARHEIGHT(XMail.textFont) + (XMail.textFont->ascent / 2);
  254.  XMail.indexHeight    = 12 * buttonSpace;
  255.  XMail.textHeight    = 23 * buttonSpace;
  256.  XMail.commandHeight    = (XMail.buttonHeight*2) + (XMail.commandVSpace*3) +
  257.               (4 * XMail.borderWidth);
  258.  XMail.menuX        = 15;
  259.  XMail.menuY        = 7;
  260.        RootWidth    = XDisplayWidth(XtDisplay(toplevel),
  261.               DefaultScreen(XtDisplay(toplevel))) - 1;
  262.        RootHeight    = XDisplayHeight(XtDisplay(toplevel),
  263.                DefaultScreen(XtDisplay(toplevel))) - 1;
  264. /*
  265. ** Ensure xmail shell height does not exceed the height of the root window.
  266. */
  267.       buttonSpace    = (2 * XMail.buttonHeight) + XMail.indexHeight +
  268.               XMail.commandHeight + XMail.textHeight + 
  269.               (6 * XMail.borderWidth);
  270.  
  271.  for (i = 0, buttonSpace -= RootHeight; buttonSpace > 0; i++) {
  272.      buttonSpace -= CHARHEIGHT(XMail.textFont);
  273.      if (i % 2)
  274.         XMail.indexHeight -= CHARHEIGHT(XMail.textFont);
  275.      else
  276.         XMail.textHeight -= CHARHEIGHT(XMail.textFont);
  277.     }
  278. /*
  279. ** If editorCommand resource exists, warn if it doesn't have two %s entries.
  280. */
  281.  if (XMail.editorCommand)
  282.     if (! (disp =  strchr(XMail.editorCommand, '%')) || *(disp + 1) != 's' ||
  283.         ! (file = strrchr(XMail.editorCommand, '%')) || *(file + 1) != 's' ||
  284.            disp == file) {
  285.     XtWarning("xmail editorCommand resource improperly defined... ignoring");
  286.     XtFree((char *) XMail.editorCommand);
  287.     XMail.editorCommand = NULL;
  288.    }
  289.  
  290.  parser_init();
  291. } /* initialize */
  292.  
  293.  
  294. /*
  295. ** @(#)SetHints() - Sets hatching, cursor, icon and size hints, and wm protocol
  296. */
  297. SetHints()
  298. {
  299.  int            x, y;
  300.  unsigned long        valuemask;
  301.  CommandWidget        nm = (CommandWidget)XtNameToWidget(toplevel, "topBox.commandPanel.Newmail");
  302.  Display        *dpy = XtDisplay(toplevel);
  303.  Screen            *scn = XtScreen(toplevel);
  304.  Window            win = XtWindow(toplevel);
  305.  XSetWindowAttributes    attributes;
  306.  XSizeHints        size_hints;
  307.  XWMHints        wm_hints;
  308. /*
  309. ** Hatch will be used to indicate new mail arrival on the command button
  310. */
  311.  hatch    = XCreatePixmapFromBitmapData(dpy, XtScreen(toplevel)->root,
  312.             cross_weave_bits, cross_weave_width, cross_weave_height,
  313.             nm->label.foreground, nm->core.background_pixel,
  314.             DefaultDepth(dpy, DefaultScreen(dpy)));
  315. /*
  316. ** Notify the window manager about our icon window
  317. */
  318.  wm_hints.input        = True;
  319.  wm_hints.initial_state    = (XMail.iconic) ? IconicState : NormalState;
  320.  wm_hints.flags        = InputHint | StateHint;
  321.  
  322.  if (XMail.iconGeometry) {
  323.     ParseIconGeometry(XMail.iconGeometry, &x, &y);
  324.     wm_hints.icon_x    = x;
  325.     wm_hints.icon_y    = y;
  326.     wm_hints.flags    |= IconPositionHint;
  327.    }
  328.  wm_hints.flags        |= IconWindowHint;
  329.  wm_hints.icon_window    = XtWindow(XtNameToWidget(toplevel, "icon"));
  330.  
  331.  XSetWMHints(dpy, win, &wm_hints);
  332. /*
  333. ** Set starting position and default geometry
  334. */
  335.  if (! XGetNormalHints(dpy, win, &size_hints)) {
  336.     size_hints.x = 56;
  337.     size_hints.y = 56;            /* slightly off from top left corner */
  338.    }
  339.  
  340.  size_hints.width    = XMail.shellWidth;
  341.  size_hints.height    = (2 * XMail.buttonHeight) + XMail.indexHeight +
  342.               XMail.commandHeight + XMail.textHeight +
  343.               (6 * XMail.borderWidth);
  344.  
  345.  size_hints.min_width = size_hints.max_width = size_hints.width;
  346.  size_hints.min_height = size_hints.max_height = size_hints.height;
  347.  size_hints.flags = USPosition | USSize | PMinSize;
  348.  
  349.  XSetNormalHints(dpy, win, &size_hints);
  350. /*
  351. ** Add a protocol flag indicating we wish to handle WM_DELETE_WINDOW requests
  352. */
  353.  wmDeleteWindow = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
  354.  XSetWMProtocols(dpy, win, &wmDeleteWindow, 1);
  355. /*
  356. ** Create a WaitCursor window, ala FAQ to Ignore device events while
  357. ** the busy cursor is displayed.  The window will be as big as the
  358. ** display screen, and clipped by its own parent window, so we never
  359. ** have to worry about resizing.
  360. */
  361.  valuemask = CWDontPropagate | CWCursor;
  362.  
  363.  attributes.do_not_propagate_mask =  (KeyPressMask | KeyReleaseMask |
  364.                                    ButtonPressMask | ButtonReleaseMask |
  365.                                    PointerMotionMask);
  366.  
  367.  attributes.cursor = XCreateFontCursor(dpy, XC_watch);
  368.  
  369.  WaitCursorWindow = XCreateWindow(dpy, win, 0, 0, WidthOfScreen(scn),
  370.                           HeightOfScreen(scn), (unsigned int) 0, CopyFromParent,
  371.                           InputOnly, CopyFromParent, valuemask, &attributes);
  372. } /* SetHints */
  373.  
  374.  
  375. /*
  376. ** @(#)main() - main routine for the x11 interface to the mail utility
  377. */
  378. main(argc, argv)
  379. int    argc;
  380. char    **argv;
  381. {
  382.  char    *cp, **aV;
  383.  int    indx, value, aC;
  384.  
  385.  static XtActionsRec actionTable[] = {
  386.     {"CheckInsert",        (XtActionProc) CheckInsert},
  387.     {"DeleteChar",        (XtActionProc) DeleteChar},
  388.     {"DeleteLine",        (XtActionProc) DeleteLine},
  389.     {"DeleteWord",        (XtActionProc) DeleteWord},
  390.     {"DoCmd",        (XtActionProc) DoCmd},
  391.     {"DoNothing",        (XtActionProc) DoNothing},
  392.     {"DoReply",        (XtActionProc) DoReply},
  393.     {"DoSave",        (XtActionProc) DoSave},
  394.     {"DoSelected",        (XtActionProc) DoSelected},
  395.     {"Iconify",        (XtActionProc) Iconify},
  396.     {"Folder",        (XtActionProc) Folder},
  397.     {"MyNotify",        (XtActionProc) MyNotify},
  398.     {"NextField",        (XtActionProc) NextField},
  399.     {"PrintMsg",        (XtActionProc) PrintMsg},
  400.     {"Quit",        (XtActionProc) Quit},
  401.     {"SetAliases",        (XtActionProc) SetAliases},
  402.     {"SetDirectory",    (XtActionProc) SetDirectory},
  403.     {"SetFolders",        (XtActionProc) SetFolders},
  404.     {"SetMenu",        (XtActionProc) SetMenu},
  405.     {"SetPopup",        (XtActionProc) SetPopup},
  406.     {"SetSelect",        (XtActionProc) SetSelect},
  407.     {"ShowHelp",        (XtActionProc) ShowHelp},
  408.         {NULL, NULL}
  409.       };
  410. /*
  411. ** First, examine our command line arguments and Class resources for bogus
  412. ** values which would cause the application to operate incorrectly.  Drop
  413. ** command lines arguments and/or change the resource values before we
  414. ** initialize our widgets.
  415. */
  416.  aV = (char **) XtMalloc((unsigned) (argc + 1) * sizeof(char *));
  417.  aC = 0;
  418.  
  419.  for (value = indx = 0; indx < argc; indx++)
  420.       value += strlen(argv[indx]) + 1;
  421.  aV[aC] = (char *) XtMalloc((unsigned) value);
  422.  
  423.  (void) strcpy(aV[aC++], *argv);
  424.  aV[aC] = aV[aC - 1] + strlen(aV[aC - 1]) + 1;
  425.  for (indx = 1; indx < argc; indx++)
  426.      switch (argv[indx][0]) {        /* look for, -xrm *[Bb]orderWidth or */
  427.          case '-':            /* -bw, w/ negative valued arguments */
  428.               if (argv[indx][1] != 'b' && argv[indx][2] != 'w' &&
  429.                   argv[indx][1] != 'x' && argv[indx][2] != 'r' &&
  430.                   argv[indx][3] != 'm') {
  431.                  (void) strcpy(aV[aC++], argv[indx]);
  432.                  aV[aC] = aV[aC - 1] + strlen(aV[aC - 1]) + 1;
  433.                 }
  434.               else if (sscanf(argv[indx+1], "%d", &value) == 1) {
  435.                    if (value < 0)
  436.                       indx++;        /* skip the value argument too */
  437.                    else if (value < 7) {
  438.                            (void) strcpy(aV[aC++], argv[indx]);
  439.                            aV[aC] = aV[aC - 1] + strlen(aV[aC - 1]) + 1;
  440.                           } else {
  441.                            (void) strcpy(aV[aC++], argv[indx++]);
  442.                            aV[aC] = aV[aC - 1] + strlen(aV[aC - 1]) + 1;
  443.                            (void) strcpy(aV[aC++], "6");
  444.                            aV[aC] = aV[aC - 1] + 2;
  445.                           }
  446.                 }
  447.               else if ((cp = strchr(argv[indx + 1], 'o')) == NULL ||
  448.                        strncmp(cp, "orderWidth:", 11)     != 0    ||
  449.                        sscanf(cp + 11, "%d", &value)      != 1) {
  450.                       (void) strcpy(aV[aC++], argv[indx]);
  451.                       aV[aC] = aV[aC - 1] + strlen(aV[aC - 1]) + 1;
  452.                      }
  453.               else if (value >= 0) {
  454.                       if (value < 7) {
  455.                          (void) strcpy(aV[aC++], argv[indx]);
  456.                          aV[aC] = aV[aC - 1] + strlen(aV[aC - 1]) + 1;
  457.                         } else {
  458.                          (void) strcpy(aV[aC++], argv[indx++]);
  459.                          aV[aC] = aV[aC - 1] + strlen(aV[aC - 1]) + 1;
  460.                          (void) strcpy(aV[aC], argv[indx]);
  461.                          cp = strchr(aV[aC], ':');
  462.                          *++cp = '\0';
  463.                          (void) strcat(aV[aC], " 6");    /* max allowed value */
  464.                          aV[aC + 1] = aV[aC] + strlen(aV[aC]) + 1;
  465.                          aC++;
  466.                         }
  467.                 }
  468.               else indx++;        /* skip the value argument too */
  469.               break;            /* if negative, it is not included */
  470.          default :
  471.               (void) strcpy(aV[aC++], argv[indx]);
  472.               aV[aC] = aV[aC - 1] + strlen(aV[aC - 1]) + 1;
  473.               break;
  474.         }
  475.  aV[aC] = NULL;                /* array MUST end with a null */
  476. /*
  477. ** Now, initialize our toplevel widget and parse the command line
  478. */
  479.  toplevel = XtInitialize(*aV, "XMail", Opts, XtNumber(Opts), &aC, aV);
  480.  if (aC > 1) {
  481.     (void) fprintf(stderr,"Usage: %s [-toolkitoptions] [-xmailoptions]\n",*aV);
  482.     exit(-1);
  483.     /*NOTREACHED*/
  484.    }
  485.  
  486.  XtFree((char *)aV[0]);                /* we're done we these now */
  487.  XtFree((char *)aV);
  488. /*
  489. ** Next, add xmail specific as well as Athena text widget actions
  490. */
  491.  XtAddActions(actionTable, XtNumber(actionTable));
  492.  XtAddActions(_XawTextActionsTable, _XawTextActionsTableCount);
  493.  
  494.  XtGetApplicationResources(toplevel, &XMail, resrcs, XtNumber(resrcs), NULL, 0);
  495.  
  496.  XtOverrideTranslations(toplevel,
  497.                      XtParseTranslationTable("<Message>WM_PROTOCOLS: Quit(q)"));
  498.  
  499.  initialize();                /* set window sizes based on font */
  500.  CreateSubWindows(toplevel);        /* and build our widget hierarchy */
  501.  XSync(XtDisplay(toplevel), False);    /* ensure everyone's on the same page */
  502.  XtRealizeWidget(toplevel);        /* initialize widgets for our hints */
  503.  SetHints();                /* tell WM about our icon and size */
  504.  
  505.  mailargc = mailoptions();        /* set up the mail pgm argv and argc */
  506.  
  507.  callMail(mailargv);            /* attempt to start Mail connection */
  508.  
  509.  SetCursor(WATCH);
  510.  
  511.  XtMainLoop();
  512.  /* NOTREACHED */
  513. } /* main */
  514.