Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / uip / RCS / whatnowproc.c,v
1 head    1.4;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.4
9 date    92.12.15.00.20.22;      author jromine; state Exp;
10 branches;
11 next    1.3;
12
13 1.3
14 date    92.11.04.00.36.34;      author jromine; state Exp;
15 branches;
16 next    1.2;
17
18 1.2
19 date    92.02.04.17.46.56;      author jromine; state Exp;
20 branches;
21 next    1.1;
22
23 1.1
24 date    92.02.04.17.44.08;      author jromine; state Exp;
25 branches;
26 next    ;
27
28
29 desc
30 @formerly sbr/m_whatnow.c
31 @
32
33
34 1.4
35 log
36 @endif sugar
37 @
38 text
39 @/* whatnowproc.c - exec whatnowproc */
40 #ifndef lint
41 static char ident[] = "@@(#)$Id: whatnowproc.c,v 1.3 1992/11/04 00:36:34 jromine Exp jromine $";
42 #endif  /* lint */
43
44 #include "../h/mh.h"
45 #include <stdio.h>
46
47 what_now (ed, nedit, use, file, altmsg, dist, mp, text, inplace, cwd)
48 struct msgs *mp;
49 char  *ed,
50        *file,
51        *altmsg,
52        *text,
53        *cwd;
54 int     nedit,
55         use,
56         dist,
57         inplace;
58 {
59     int     found,
60             k,
61             msgnum,
62             vecp;
63     register char  *bp;
64     char    buffer[BUFSIZ],
65            *vec[MAXARGS];
66
67     vecp = 0;
68     vec[vecp++] = r1bindex (whatnowproc, '/');
69     vec[vecp] = NULL;
70
71     (void) m_putenv ("mhdraft", file);
72     if (mp)
73         (void) m_putenv ("mhfolder", mp -> foldpath);
74     else
75         (void) unputenv ("mhfolder");
76     if (altmsg)
77         if (mp == NULL || *altmsg == '/' || cwd == NULL)
78             (void) m_putenv ("mhaltmsg", altmsg);
79         else {
80             (void) sprintf (buffer, "%s/%s", mp -> foldpath, altmsg);
81             (void) m_putenv ("mhaltmsg", buffer);
82         }
83     else
84         (void) unputenv ("mhaltmsg");
85     if (bp = getenv ("mhaltmsg"))/* XXX */
86         (void) m_putenv ("editalt", bp);
87     (void) sprintf (buffer, "%d", dist);
88     (void) m_putenv ("mhdist", buffer);
89     if (nedit)
90         (void) unputenv ("mheditor");
91     else
92         (void) m_putenv ("mheditor", ed ? ed : (ed = m_find ("editor")) ? ed : sysed);
93     (void) sprintf (buffer, "%d", use);
94     (void) m_putenv ("mhuse", buffer);
95
96     (void) unputenv ("mhmessages");
97     (void) unputenv ("mhannotate");
98     (void) unputenv ("mhinplace");
99     if (text && mp && !(mp -> msgflags & READONLY)) {
100         found = 0;
101         bp = buffer;
102         for (msgnum = mp -> lowmsg; msgnum <= mp -> hghmsg; msgnum++)
103             if (mp -> msgstats[msgnum] & SELECTED) {
104                 (void) sprintf (bp, "%s%s", found ? " " : "", m_name (msgnum));
105                 bp += strlen (bp);
106                 for (k = msgnum + 1;
107                         k <= mp -> hghmsg && mp -> msgstats[k] & SELECTED;
108                         k++)
109                     continue;
110                 if (--k > msgnum) {
111                     (void) sprintf (bp, "-%s", m_name (k));
112                     bp += strlen (bp);
113                 }
114                 msgnum = k + 1;
115                 found++;
116             }
117         if (found) {
118             (void) m_putenv ("mhmessages", buffer);
119             (void) m_putenv ("mhannotate", text);
120             (void) sprintf (buffer, "%d", inplace);
121             (void) m_putenv ("mhinplace", buffer);
122         }
123     }
124
125     m_update ();
126     (void) fflush (stdout);
127
128     if (cwd)
129         (void) chdir (cwd);
130
131     if (strcmp (vec[0], "whatnow") == 0) {
132         WhatNow (vecp, vec);
133         done (0);
134     }
135
136     execvp (whatnowproc, vec);
137     fprintf (stderr, "unable to exec ");
138     perror (whatnowproc);
139
140     return 0;
141 }
142 @
143
144
145 1.3
146 log
147 @putenv -> m_putenv
148 @
149 text
150 @d3 2
151 a4 2
152 static char ident[] = "@@(#)$Id: whatnowproc.c,v 1.2 1992/02/04 17:46:56 jromine Exp jromine $";
153 #endif  lint
154 @
155
156
157 1.2
158 log
159 @rename m_whatnow() to what_now() since it's not a m_ routine
160 @
161 text
162 @d3 1
163 a3 1
164 static char ident[] = "@@(#)$Id: whatnowproc.c,v 1.1 1992/02/04 17:44:08 jromine Exp jromine $";
165 d33 1
166 a33 1
167     (void) putenv ("mhdraft", file);
168 d35 1
169 a35 1
170         (void) putenv ("mhfolder", mp -> foldpath);
171 d40 1
172 a40 1
173             (void) putenv ("mhaltmsg", altmsg);
174 d43 1
175 a43 1
176             (void) putenv ("mhaltmsg", buffer);
177 d48 1
178 a48 1
179         (void) putenv ("editalt", bp);
180 d50 1
181 a50 1
182     (void) putenv ("mhdist", buffer);
183 d54 1
184 a54 1
185         (void) putenv ("mheditor", ed ? ed : (ed = m_find ("editor")) ? ed : sysed);
186 d56 1
187 a56 1
188     (void) putenv ("mhuse", buffer);
189 d80 2
190 a81 2
191             (void) putenv ("mhmessages", buffer);
192             (void) putenv ("mhannotate", text);
193 d83 1
194 a83 1
195             (void) putenv ("mhinplace", buffer);
196 @
197
198
199 1.1
200 log
201 @Initial revision
202 @
203 text
204 @d1 1
205 a1 1
206 /* m_whatnow.c - exec whatnowproc */
207 d3 1
208 a3 1
209 static char ident[] = "@@(#)$Id: scan.c,v 1.11 1992/02/03 22:45:20 jromine Exp $";
210 d9 1
211 a9 1
212 m_whatnow (ed, nedit, use, file, altmsg, dist, mp, text, inplace, cwd)
213 @