- *bp = '\0'; /* temporarily terminate sequence name */
- }
-
- i = seq_getnum (mp, cp); /* get index of sequence */
-
- if (bp)
- *bp = ':'; /* restore sequence name */
- if (i == -1)
- return 0;
-
- found = 0; /* count the number we select for this argument */
-
- for (j = first ? first : (convdir > 0) ? mp->lowmsg : mp->hghmsg;
- j >= mp->lowmsg && j <= mp->hghmsg; j += convdir) {
- if (does_exist (mp, j)
- && inverted ? !in_sequence (mp, i, j) : in_sequence (mp, i, j)) {
- if (!is_selected (mp, j)) {
- set_selected (mp, j);
- mp->numsel++;
- if (mp->lowsel == 0 || j < mp->lowsel)
- mp->lowsel = j;
- if (j > mp->hghsel)
- mp->hghsel = j;
- }
- found++;
-
- /*
- * If we have a range, then break out
- * once we've found enough.
- */
- if (range && found >= range)
- break;
+/*
+** Handle user defined sequences.
+** They can take the following forms:
+**
+** seq
+** seq:p
+** seq:n
+** seq:f
+** seq:l
+** seq:+42
+** seq:-42
+** seq:42
+**
+** (`42' being an arbitrary integer)
+*/
+static int
+attr(struct msgs *mp, char *cp)
+{
+ unsigned char *dp;
+ char *bp = NULL;
+ int i, j;
+ int found;
+ int inverted = 0;
+ int range = 0; /* no range */
+ int first = 0;
+
+ /* hack for "c-..." */
+ if (strcmp(cp, seq_cur)==0)
+ return 0;
+ /* "c:..." -- this code need to be rewritten... */
+ if (strncmp(seq_cur, cp, strlen(seq_cur))==0 &&
+ cp[strlen(seq_cur)] == ':') {
+ return 0;
+ }
+
+ /* Check for sequence negation */
+ if (!(dp = context_find(nsequence))) {
+ dp = seq_neg; /* use default */
+ }
+ if (*dp && strncmp(cp, dp, strlen(dp))==0) {
+ inverted = 1;
+ cp += strlen(dp);
+ }
+
+ convdir = 1; /* convert direction */
+
+ for (dp = cp; *dp && isalnum(*dp); dp++)
+ continue;
+
+ if (*dp == ':') {
+ bp = dp++;
+ range = 1;
+
+ /*
+ ** seq:p (or)
+ ** seq:n (or)
+ ** seq:f (or)
+ ** seq:l
+ */
+ if (isalpha(*dp)) {
+ if (strcmp(dp, seq_prev)==0) {
+ convdir = -1;
+ first = (mp->curmsg > 0) && (mp->curmsg <= mp->hghmsg)
+ ? mp->curmsg - 1 : mp->hghmsg;
+ } else if (strcmp(dp, seq_next)==0) {
+ convdir = 1;
+ first = (mp->curmsg >= mp->lowmsg)
+ ? mp->curmsg + 1 : mp->lowmsg;
+ } else if (strcmp(dp, seq_first)==0) {
+ convdir = 1;
+ } else if (strcmp(dp, seq_last)==0) {
+ convdir = -1;
+ } else
+ return BADLST;
+ } else {
+ /*
+ ** seq:42 (or)
+ ** seq:+42 (or)
+ ** seq:-42
+ */
+ if (*dp == '+')
+ dp++;
+ else if (*dp == '-') {
+ dp++;
+ convdir = -1;
+ }
+ if ((range = atoi(dp)) == 0)
+ return BADLST;
+ while (isdigit(*dp))
+ dp++;
+ if (*dp)
+ return BADLST;
+ }
+
+ *bp = '\0'; /* temporarily terminate sequence name */
+ }
+
+ i = seq_getnum(mp, cp); /* get index of sequence */
+
+ if (bp)
+ *bp = ':'; /* restore sequence name */
+ if (i == -1)
+ return 0;
+
+ found = 0; /* count the number we select for this argument */
+
+ for (j = first ? first : (convdir > 0) ? mp->lowmsg : mp->hghmsg;
+ j >= mp->lowmsg && j <= mp->hghmsg; j += convdir) {
+ if (does_exist(mp, j)
+ && inverted ? !in_sequence(mp, i, j) :
+ in_sequence(mp, i, j)) {
+ addtosel(mp, j);
+ found++;
+
+ /*
+ ** If we have a range, then break out
+ ** once we've found enough.
+ */
+ if (range && found >= range)
+ break;
+ }