1: /* m_whatnow.c - exec whatnowproc */
   2: 
   3: #include "../h/mh.h"
   4: #include <stdio.h>
   5: 
   6: m_whatnow (ed, nedit, use, file, altmsg, dist, mp, text, inplace, cwd)
   7: struct msgs *mp;
   8: char  *ed,
   9:        *file,
  10:        *altmsg,
  11:        *text,
  12:        *cwd;
  13: int nedit,
  14:     use,
  15:     dist,
  16:     inplace;
  17: {
  18:     int     found,
  19:             k,
  20:             msgnum,
  21:             vecp;
  22:     register char  *bp;
  23:     char    buffer[BUFSIZ],
  24:            *vec[MAXARGS];
  25: 
  26:     vecp = 0;
  27:     vec[vecp++] = r1bindex (whatnowproc, '/');
  28:     vec[vecp] = NULL;
  29: 
  30:     (void) putenv ("mhdraft", file);
  31:     if (mp)
  32:     (void) putenv ("mhfolder", mp -> foldpath);
  33:     else
  34:     (void) unputenv ("mhfolder");
  35:     if (altmsg)
  36:     if (mp == NULL || *altmsg == '/' || cwd == NULL)
  37:         (void) putenv ("mhaltmsg", altmsg);
  38:     else {
  39:         (void) sprintf (buffer, "%s/%s", mp -> foldpath, altmsg);
  40:         (void) putenv ("mhaltmsg", buffer);
  41:     }
  42:     else
  43:     (void) unputenv ("mhaltmsg");
  44:     if (bp = getenv ("mhaltmsg"))/* XXX */
  45:     (void) putenv ("editalt", bp);
  46:     (void) sprintf (buffer, "%d", dist);
  47:     (void) putenv ("mhdist", buffer);
  48:     if (nedit)
  49:     (void) unputenv ("mheditor");
  50:     else
  51:     (void) putenv ("mheditor", ed ? ed : (ed = m_find ("editor")) ? ed : sysed);
  52:     (void) sprintf (buffer, "%d", use);
  53:     (void) putenv ("mhuse", buffer);
  54: 
  55:     (void) unputenv ("mhmessages");
  56:     (void) unputenv ("mhannotate");
  57:     (void) unputenv ("mhinplace");
  58:     if (text && mp && !(mp -> msgflags & READONLY)) {
  59:     found = 0;
  60:     bp = buffer;
  61:     for (msgnum = mp -> lowmsg; msgnum <= mp -> hghmsg; msgnum++)
  62:         if (mp -> msgstats[msgnum] & SELECTED) {
  63:         (void) sprintf (bp, "%s%s", found ? " " : "", m_name (msgnum));
  64:         bp += strlen (bp);
  65:         for (k = msgnum + 1;
  66:             k <= mp -> hghmsg && mp -> msgstats[k] & SELECTED;
  67:             k++)
  68:             continue;
  69:         if (--k > msgnum) {
  70:             (void) sprintf (bp, "-%s", m_name (k));
  71:             bp += strlen (bp);
  72:         }
  73:         msgnum = k + 1;
  74:         found++;
  75:         }
  76:     if (found) {
  77:         (void) putenv ("mhmessages", buffer);
  78:         (void) putenv ("mhannotate", text);
  79:         (void) sprintf (buffer, "%d", inplace);
  80:         (void) putenv ("mhinplace", buffer);
  81:     }
  82:     }
  83: 
  84:     m_update ();
  85:     (void) fflush (stdout);
  86: 
  87:     if (cwd)
  88:     (void) chdir (cwd);
  89: 
  90:     if (strcmp (vec[0], "whatnow") == 0) {
  91:     WhatNow (vecp, vec);
  92:     done (0);
  93:     }
  94: 
  95:     execvp (whatnowproc, vec);
  96:     fprintf (stderr, "unable to exec ");
  97:     perror (whatnowproc);
  98: 
  99:     return 0;
 100: }

Defined functions

m_whatnow defined in line 6; never used
Last modified: 1985-10-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1068
Valid CSS Valid XHTML 1.0 Strict