9 date 92.12.15.00.20.22; author jromine; state Exp;
14 date 92.10.26.22.53.13; author jromine; state Exp;
19 date 92.01.31.21.49.42; author jromine; state Exp;
24 date 91.02.12.16.51.00; author mh; state Exp;
29 date 91.01.09.11.19.24; author mh; state Exp;
34 date 90.12.26.16.41.46; author mh; state Exp;
39 date 90.04.05.15.31.48; author sources; state Exp;
44 date 90.04.05.14.49.04; author sources; state Exp;
49 date 90.02.06.13.05.17; author sources; state Exp;
54 date 90.02.06.13.03.55; author sources; state Exp;
68 @/* m_convert.c - parse a message sequence and set SELECTED */
70 static char ident[] = "@@(#)$Id: m_convert.c,v 1.9 1992/10/26 22:53:13 jromine Exp jromine $";
86 #define getnew(mp) (mp -> hghmsg + 1)
91 static m_conv(), attr();
95 register struct msgs *mp;
107 switch (err = attr (mp, cp = name)) {
121 flags = mp -> msgflags & MHPATH ? EXISTS | SELECT_EMPTY : EXISTS;
123 if ((mp -> msgflags & MHPATH) && strcmp (cp, "new") == 0)
124 if ((err = first = getnew (mp)) <= 0)
128 if (strcmp (cp, "all") == 0)
130 if ((err = first = m_conv (mp, cp, FIRST)) <= 0)
132 if (*(cp = delimp) && *cp != '-' && *cp != ':') {
134 advise (NULLCP, "illegal argument delimiter: `%c'(0%o)",
140 if ((err = last = m_conv (mp, cp, LAST)) <= 0) {
144 advise (NULLCP, "no %s message", cp);
148 advise (NULLCP, "message %s doesn't exist", cp);
152 advise (NULLCP, "message %s out of range 1-%d",
158 advise (NULLCP, "bad message list %s", name);
162 advise (NULLCP, "folder full, no %s message", name);
166 advise (NULLCP, "no messages match specification");
174 if (first > mp -> hghmsg || last < mp -> lowmsg) {
176 advise (NULLCP, "no messages in range %s", name);
179 if (last > mp -> hghmsg)
181 if (first < mp -> lowmsg)
182 first = mp -> lowmsg;
196 if ((range = atoi (bp = cp)) == 0)
198 while (isdigit (*bp))
202 if ((convdir > 0 && first > mp -> hghmsg)
203 || (convdir < 0 && first < mp -> lowmsg))
205 if (first < mp -> lowmsg)
206 first = mp -> lowmsg;
207 if (first > mp -> hghmsg)
208 first = mp -> hghmsg;
210 last >= mp -> lowmsg && last <= mp -> hghmsg;
212 if (mp -> msgstats[last] & EXISTS)
215 if (last < mp -> lowmsg)
217 if (last > mp -> hghmsg)
226 if (!(mp -> msgflags & MHPATH))
227 if (first > mp -> hghmsg
228 || first < mp -> lowmsg
229 || !(mp -> msgstats[first] & EXISTS)) {
230 if (strcmp (name, "cur") == 0 || strcmp (name, ".") == 0)
231 advise (NULLCP, "no %s message", name);
233 advise (NULLCP, "message %d doesn't exist", first);
238 if (mp -> msgflags & MHPATH)
239 mp -> msgstats[first] |= SELECT_EMPTY;
241 for (; first <= last; first++)
242 if (mp -> msgstats[first] & flags) {
243 if (!(mp -> msgstats[first] & SELECTED)) {
245 mp -> msgstats[first] |= SELECTED;
246 if (mp -> lowsel == 0 || first < mp -> lowsel)
247 mp -> lowsel = first;
248 if (first > mp -> hghsel)
249 mp -> hghsel = first;
261 static m_conv (mp, str, call)
262 register struct msgs *mp;
274 while (isdigit (*bp))
277 return ((i = atoi (cp)) <= mp -> hghmsg ? i
278 : *delimp || call == LAST ? mp -> hghmsg + 1
279 : mp -> msgflags & MHPATH ? BADRNG : BADNUM);
284 while ((*cp >= 'a' && *cp <= 'z') || *cp == '.')
286 while (isalpha(*cp) || *cp == '.') /* doesn't enforce lower case */
292 if (strcmp (buf, "first") == 0)
293 return (mp -> hghmsg || !(mp -> msgflags & MHPATH)
294 ? mp -> lowmsg : BADMSG);
296 if (strcmp (buf, "last") == 0) {
298 return (mp -> hghmsg || !(mp -> msgflags & MHPATH)
299 ? mp -> hghmsg : BADMSG);
302 if (strcmp (buf, "cur") == 0 || strcmp (buf, ".") == 0)
303 return (mp -> curmsg > 0 ? mp -> curmsg : BADMSG);
305 if (strcmp (buf, "prev") == 0) {
307 for (i = (mp -> curmsg <= mp -> hghmsg) ? mp -> curmsg - 1 : mp -> hghmsg;
308 i >= mp -> lowmsg; i--) {
309 if (mp -> msgstats[i] & EXISTS)
315 if (strcmp (buf, "next") == 0) {
316 for (i = (mp -> curmsg >= mp -> lowmsg) ? mp -> curmsg + 1 : mp -> lowmsg;
317 i <= mp -> hghmsg; i++) {
318 if (mp -> msgstats[i] & EXISTS)
330 register struct msgs *mp;
333 char *bp = (char *)NULL;
337 range = 0, /* no range */
343 if (strcmp (cp, "cur") == 0)/* hack for "cur-xyz", etc. */
345 if (ssequal ("cur:", cp)) /* this code need to be rewritten... */
348 if (inverted = (dp = m_find (nsequence)) && *dp && ssequal (dp, cp))
352 for (dp = cp; *dp && isalnum(*dp); dp++)
358 if (isalpha (*dp)) { /* optimize? */
359 if (strcmp (dp, "prev") == 0) {
361 first = (mp -> curmsg > 0) && (mp -> curmsg <= mp -> hghmsg)
365 else if (strcmp (dp, "next") == 0) {
367 first = (mp -> curmsg >= mp -> lowmsg)
371 else if (strcmp (dp, "first") == 0) {
374 else if (strcmp (dp, "last") == 0) {
380 else { /* a numeric range */
383 else if (*dp == '-') {
387 if ((range = atoi(dp)) == 0)
389 while (isdigit (*dp))
395 *bp = '\0'; /* terminate sequence name */
400 for (i = 0; mp -> msgattrs[i]; i++)
401 if (strcmp (mp -> msgattrs[i], cp) == 0)
404 *bp = ':'; /* restore sequence name */
405 if (mp -> msgattrs[i] == NULL)
409 for (j = first ? first : (convdir > 0) ? mp -> lowmsg : mp -> hghmsg;
410 j >= mp -> lowmsg && j <= mp -> hghmsg; j += convdir)
411 if ((mp -> msgstats[j] & EXISTS)
412 && inverted ? !(mp -> msgstats[j] & (1 << (bits + i)))
413 : mp -> msgstats[j] & (1 << (bits + i))) {
414 if (!(mp -> msgstats[j] & SELECTED)) {
416 mp -> msgstats[j] |= SELECTED;
417 if (mp -> lowsel == 0 || j < mp -> lowsel)
419 if (j > mp -> hghsel)
423 if (range && found >= range)
424 break; /* we've done enough */
431 advise (NULLCP, "sequence %s %s", cp, inverted ? "full" : "empty");
444 static char ident[] = "@@(#)$Id: m_convert.c,v 1.8 1992/01/31 21:49:42 jromine Exp jromine $";
456 static char ident[] = "@@(#)$Id: m_convert.c,v 1.7 1991/02/12 16:51:00 mh Exp jromine $";
464 @fix bug. - this code need to be reorganized.
470 static char ident[] = "@@(#)$Id: m_convert.c,v 1.6 91/01/09 11:19:24 mh Exp Locker: mh $";
479 @allow sequence:{first,last,next,prev}
485 static char ident[] = "@@(#)$Id: m_convert.c,v 1.5 90/12/26 16:41:46 mh Exp Locker: mh $";
492 @add sequence ranges (e.g., sel:10)
498 static char ident[] = "@@(#)$Id: m_convert.c,v 1.4 90/04/05 15:31:48 sources Exp Locker: mh $";
504 range = 0; /* no range */
507 if (*(bp = dp) == ':') {
511 else if (*dp == '-') {
516 if ((range = atoi(dp)) == 0)
518 while (isdigit (*dp))
527 for (j = convdir > 0 ? mp -> lowmsg : mp -> hghmsg;
528 j >= mp -> lowmsg && j <= mp -> hghmsg; j += convdir)
540 static char ident[] = "@@(#)$Id:$";
552 for (j = mp -> lowmsg; j <= mp -> hghmsg; j++)
564 static char ident[] = "$Id:";