X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fseq_read.c;h=141c1a2e66b3aedc35b88ad82470ca0fb85b3945;hp=448f9ef9a9ecf8f4e492b23d3f4712e172652395;hb=714b5c530ece27ea2835a313013f5b770163403c;hpb=ced6090a330d3d83d0bce709f756aa3d7d65fea4 diff --git a/sbr/seq_read.c b/sbr/seq_read.c index 448f9ef..141c1a2 100644 --- a/sbr/seq_read.c +++ b/sbr/seq_read.c @@ -13,9 +13,9 @@ /* ** static prototypes */ -static int seq_init (struct msgs *, char *, char *); -static void seq_public (struct msgs *); -static void seq_private (struct msgs *); +static int seq_init(struct msgs *, char *, char *); +static void seq_public(struct msgs *); +static void seq_private(struct msgs *); /* @@ -25,25 +25,25 @@ static void seq_private (struct msgs *); */ void -seq_read (struct msgs *mp) +seq_read(struct msgs *mp) { /* ** Initialize the list of sequence names. Go ahead and ** add the "cur" sequence to the list of sequences. */ - mp->msgattrs[0] = getcpy (current); + mp->msgattrs[0] = getcpy(current); mp->msgattrs[1] = NULL; - make_all_public (mp); /* initially, make all public */ + make_all_public(mp); /* initially, make all public */ /* If folder is empty, don't scan for sequence information */ if (mp->nummsg == 0) return; /* Initialize the public sequences */ - seq_public (mp); + seq_public(mp); /* Initialize the private sequences */ - seq_private (mp); + seq_private(mp); } @@ -52,7 +52,7 @@ seq_read (struct msgs *mp) */ static void -seq_public (struct msgs *mp) +seq_public(struct msgs *mp) { int state; char *cp, seqfile[PATH_MAX]; @@ -69,27 +69,27 @@ seq_public (struct msgs *mp) return; /* get filename of sequence file */ - snprintf (seqfile, sizeof(seqfile), "%s/%s", mp->foldpath, mh_seq); + snprintf(seqfile, sizeof(seqfile), "%s/%s", mp->foldpath, mh_seq); - if ((fp = lkfopen (seqfile, "r")) == NULL) + if ((fp = lkfopen(seqfile, "r")) == NULL) return; /* Use m_getfld to scan sequence file */ for (state = FLD;;) { - switch (state = m_getfld (state, name, field, sizeof(field), fp)) { + switch (state = m_getfld(state, name, field, sizeof(field), fp)) { case FLD: case FLDPLUS: case FLDEOF: if (state == FLDPLUS) { - cp = getcpy (field); + cp = getcpy(field); while (state == FLDPLUS) { - state = m_getfld (state, name, field, sizeof(field), fp); - cp = add (field, cp); + state = m_getfld(state, name, field, sizeof(field), fp); + cp = add(field, cp); } - seq_init (mp, getcpy (name), trimcpy (cp)); - free (cp); + seq_init(mp, getcpy(name), trimcpy(cp)); + free(cp); } else { - seq_init (mp, getcpy (name), trimcpy (field)); + seq_init(mp, getcpy(name), trimcpy(field)); } if (state == FLDEOF) break; @@ -97,19 +97,19 @@ seq_public (struct msgs *mp) case BODY: case BODYEOF: - adios (NULL, "no blank lines are permitted in %s", seqfile); + adios(NULL, "no blank lines are permitted in %s", seqfile); /* fall */ case FILEEOF: break; default: - adios (NULL, "%s is poorly formatted", seqfile); + adios(NULL, "%s is poorly formatted", seqfile); } break; /* break from for loop */ } - lkfclose (fp, seqfile); + lkfclose(fp, seqfile); } @@ -121,24 +121,25 @@ seq_public (struct msgs *mp) */ static void -seq_private (struct msgs *mp) +seq_private(struct msgs *mp) { int i, j, alen, plen; char *cp; struct node *np; - alen = strlen ("atr-"); - plen = strlen (mp->foldpath) + 1; + alen = strlen("atr-"); + plen = strlen(mp->foldpath) + 1; for (np = m_defs; np; np = np->n_next) { - if (ssequal ("atr-", np->n_name) - && (j = strlen (np->n_name) - plen) > alen - && *(np->n_name + j) == '-' - && strcmp (mp->foldpath, np->n_name + j + 1) == 0) { - cp = getcpy (np->n_name + alen); + if (ssequal("atr-", np->n_name) + && (j = strlen(np->n_name) - plen) > alen + && *(np->n_name + j) == '-' + && strcmp(mp->foldpath, np->n_name + j + 1) + == 0) { + cp = getcpy(np->n_name + alen); *(cp + j - alen) = '\0'; - if ((i = seq_init (mp, cp, getcpy (np->n_field))) != -1) - make_seq_private (mp, i); + if ((i = seq_init(mp, cp, getcpy(np->n_field))) != -1) + make_seq_private(mp, i); } } } @@ -155,7 +156,7 @@ seq_private (struct msgs *mp) */ static int -seq_init (struct msgs *mp, char *name, char *field) +seq_init(struct msgs *mp, char *name, char *field) { int i, j, k, is_current; char *cp, **ap; @@ -164,7 +165,7 @@ seq_init (struct msgs *mp, char *name, char *field) ** Check if this is "cur" sequence, ** so we can do some special things. */ - is_current = !strcmp (current, name); + is_current = !strcmp(current, name); /* ** Search for this sequence name to see if we've seen @@ -173,17 +174,17 @@ seq_init (struct msgs *mp, char *name, char *field) ** mesages in this folder. */ for (i = 0; mp->msgattrs[i]; i++) { - if (!strcmp (mp->msgattrs[i], name)) { + if (!strcmp(mp->msgattrs[i], name)) { for (j = mp->lowmsg; j <= mp->hghmsg; j++) - clear_sequence (mp, i, j); + clear_sequence(mp, i, j); break; } } /* Return error, if too many sequences */ if (i >= NUMATTRS) { - free (name); - free (field); + free(name); + free(field); return -1; } @@ -192,7 +193,7 @@ seq_init (struct msgs *mp, char *name, char *field) ** name string. Else add it to the list of sequence names. */ if (mp->msgattrs[i]) { - free (name); + free(name); } else { mp->msgattrs[i] = name; mp->msgattrs[i + 1] = NULL; @@ -201,11 +202,11 @@ seq_init (struct msgs *mp, char *name, char *field) /* ** Split up the different message ranges at whitespace */ - for (ap = brkstring (field, " ", "\n"); *ap; ap++) { + for (ap = brkstring(field, " ", "\n"); *ap; ap++) { if ((cp = strchr(*ap, '-'))) *cp++ = '\0'; - if ((j = m_atoi (*ap)) > 0) { - k = cp ? m_atoi (cp) : j; + if ((j = m_atoi(*ap)) > 0) { + k = cp ? m_atoi(cp) : j; /* ** Keep mp->curmsg and "cur" sequence in synch. Unlike @@ -222,12 +223,13 @@ seq_init (struct msgs *mp, char *name, char *field) ** and flip on bit for this sequence. */ for (; j <= k; j++) { - if (j >= mp->lowmsg && j <= mp->hghmsg && does_exist(mp, j)) - add_sequence (mp, i, j); + if (j >= mp->lowmsg && j <= mp->hghmsg && + does_exist(mp, j)) + add_sequence(mp, i, j); } } } - free (field); /* free string containing message ranges */ + free(field); /* free string containing message ranges */ return i; }