** complete copyright information.
*/
+#include <sysexits.h>
#include <h/mh.h>
#include <h/utils.h>
** Initialize the list of sequence names. Go ahead and
** add the cur sequence to the list of sequences.
*/
- mp->msgattrs[0] = getcpy(seq_cur);
+ mp->msgattrs[0] = mh_xstrdup(seq_cur);
mp->msgattrs[1] = NULL;
make_all_public(mp); /* initially, make all public */
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 LENERR2:
+ state = FLD2;
+ /* FALL */
+ case FLD2:
+ seq_init(mp, mh_xstrdup(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);
(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 = mh_xstrdup(np->n_name + alen);
*(cp + j - alen) = '\0';
- if ((i = seq_init(mp, cp, getcpy(np->n_field))) != -1)
+ if ((i = seq_init(mp, cp, mh_xstrdup(np->n_field))) != -1)
make_seq_private(mp, i);
}
}
/* Return error, if too many sequences */
if (i >= NUMATTRS) {
- free(name);
- free(field);
+ mh_free0(&name);
+ mh_free0(&field);
return -1;
}
** name string. Else add it to the list of sequence names.
*/
if (mp->msgattrs[i]) {
- free(name);
+ mh_free0(&name);
} else {
mp->msgattrs[i] = name;
mp->msgattrs[i + 1] = NULL;
}
}
- free(field); /* free string containing message ranges */
+ mh_free0(&field); /* free string containing message ranges */
return i;
}