** complete copyright information.
*/
+#include <sysexits.h>
#include <h/mh.h>
#include <h/utils.h>
static void
seq_public(struct msgs *mp)
{
- int state;
- char *cp, seqfile[PATH_MAX];
- char name[NAMESZ], field[BUFSIZ];
+ enum state state;
+ struct field f = {{0}};
+ char seqfile[PATH_MAX];
FILE *fp;
/*
return;
/* Use m_getfld to scan sequence file */
- for (state = FLD;;) {
- switch (state = m_getfld(state, name, field, sizeof(field),
- fp)) {
- case FLD:
- case FLDPLUS:
- case FLDEOF:
- if (state == FLDPLUS) {
- cp = getcpy(field);
- while (state == FLDPLUS) {
- state = m_getfld(state, name, field,
- sizeof(field), fp);
- cp = add(field, cp);
- }
- seq_init(mp, getcpy(name), trimcpy(cp));
- free(cp);
- } else {
- seq_init(mp, getcpy(name), trimcpy(field));
- }
- if (state == FLDEOF)
- break;
+ for (state = FLD2;;) {
+ switch (state = m_getfld2(state, &f, fp)) {
+ case FLD2:
+ seq_init(mp, getcpy(f.name), trimcpy(f.value));
continue;
- case BODY:
- case BODYEOF:
- adios(NULL, "no blank lines are permitted in %s",
+ case BODY2:
+ adios(EX_CONFIG, NULL, "no blank lines are permitted in %s",
seqfile);
- /* fall */
+ /* FALL */
- case FILEEOF:
+ case FILEEOF2:
break;
default:
- adios(NULL, "%s is poorly formatted", seqfile);
+ adios(EX_CONFIG, NULL, "%s is poorly formatted", seqfile);
}
- break; /* break from for loop */
+ break;
}
lkfclose(fp, seqfile);
plen = strlen(mp->foldpath) + 1;
for (np = m_defs; np; np = np->n_next) {
- if (strncmp(np->n_name, "atr-", alen)==0
- && (j = strlen(np->n_name) - plen) > alen
- && *(np->n_name + j) == '-'
- && strcmp(mp->foldpath, np->n_name + j + 1)
- == 0) {
+ if (strncmp(np->n_name, "atr-", alen)==0 &&
+ (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)
static int
seq_init(struct msgs *mp, char *name, char *field)
{
- int i, j, k, is_current;
+ unsigned int i;
+ int j, k, is_current;
char *cp, **ap;
/*
** Check if this is the cur sequence,
** so we can do some special things.
*/
- is_current = !strcmp(seq_cur, name);
+ is_current = (strcmp(seq_cur, name)==0);
/*
** Search for this sequence name to see if we've seen
** mesages in this folder.
*/
for (i = 0; mp->msgattrs[i]; i++) {
- if (!strcmp(mp->msgattrs[i], name)) {
+ if (strcmp(mp->msgattrs[i], name)==0) {
for (j = mp->lowmsg; j <= mp->hghmsg; j++)
clear_sequence(mp, i, j);
break;