1: /* m_readefs.c - read a profile/context file */
   2: 
   3: #include "../h/mh.h"
   4: #include <stdio.h>
   5: 
   6: 
   7: static struct procs {
   8:     char    *procname;
   9:     char    **procnaddr;
  10: } procs [] = {
  11:     { "context",    &context    },
  12:     { "mh-sequences",
  13:             &mh_seq     },
  14:     { "fileproc",   &fileproc       },
  15:     { "incproc",    &incproc    },
  16:         { "installproc",&installproc    },
  17:     { "lproc",      &lproc          },
  18:     { "mailproc",   &mailproc   },
  19:     { "mhlproc",    &mhlproc    },
  20:     { "moreproc",   &moreproc   },
  21:     { "mshproc",    &mshproc    },
  22:     { "packproc",   &packproc   },
  23:     { "postproc",   &postproc       },
  24:     { "rmfproc",    &rmfproc    },
  25:     { "rmmproc",    &rmmproc    },
  26:     { "sendproc",   &sendproc       },
  27:     { "showproc",   &showproc       },
  28:     { "slocalproc", &slocalproc     },
  29:     { "vmhproc",    &vmhproc        },
  30:     { "whatnowproc",
  31:             &whatnowproc    },
  32:     { "whomproc",   &whomproc   },
  33:     { NULL,         NULL            }
  34: };
  35: 
  36: static struct node **opp = NULL;
  37: 
  38: 
  39: void    m_readefs (npp, ib, file, ctx)
  40: register struct node **npp;
  41: register FILE   *ib;
  42: register char   *file;
  43: register int     ctx;
  44: {
  45:     register int    state;
  46:     register char  *cp;
  47:     char    name[NAMESZ],
  48:             field[BUFSIZ];
  49:     register struct node   *np;
  50:     register struct procs  *ps;
  51: 
  52:     if (npp == NULL && (npp = opp) == NULL) {
  53:     admonish (NULLCP, "bug: m_readefs called but pump not primed");
  54:     return;
  55:     }
  56: 
  57:     for (state = FLD;;) {
  58:     switch (state = m_getfld (state, name, field, sizeof field, ib)) {
  59:         case FLD:
  60:         case FLDPLUS:
  61:         case FLDEOF:
  62:         np = (struct node *) malloc (sizeof *np);
  63:         if (np == NULL)
  64:             adios (NULLCP, "unable to allocate profile storage");
  65:         *npp = np;
  66:         *(npp = &np -> n_next) = NULL;
  67:         np -> n_name = getcpy (name);
  68:         if (state == FLDPLUS) {
  69:             cp = getcpy (field);
  70:             while (state == FLDPLUS) {
  71:             state = m_getfld
  72:                     (state, name, field, sizeof field, ib);
  73:             cp = add (field, cp);
  74:             }
  75:             np -> n_field = trimcpy (cp);
  76:             free (cp);
  77:         }
  78:         else
  79:             np -> n_field = trimcpy (field);
  80:         np -> n_context = ctx;
  81:         for (ps = procs; ps -> procname; ps++)
  82:             if (strcmp (np -> n_name, ps -> procname) == 0) {
  83:             *ps -> procnaddr = np -> n_field;
  84:             break;
  85:             }
  86:         if (state == FLDEOF)
  87:             break;
  88:         continue;
  89: 
  90:         case BODY:
  91:         case BODYEOF:
  92:         adios (NULLCP, "no blank lines are permitted in %s", file);
  93: 
  94:         case FILEEOF:
  95:         break;
  96: 
  97:         default:
  98:         adios (NULLCP, "%s is poorly formatted", file);
  99:     }
 100:     break;
 101:     }
 102: 
 103:     opp = npp;
 104: }

Defined functions

m_readefs defined in line 39; used 3 times

Defined variables

opp defined in line 36; used 2 times
procs defined in line 10; used 1 times
  • in line 81

Defined struct's

procs defined in line 7; used 2 times
  • in line 50(2)
Last modified: 1985-11-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1187
Valid CSS Valid XHTML 1.0 Strict