1: /* m_seqnew.c - manage sequences */
   2: 
   3: #include "../h/mh.h"
   4: #include <ctype.h>
   5: #include <stdio.h>
   6: 
   7: 
   8: int     m_seqnew (mp, cp, public)
   9: register struct msgs *mp;
  10: register char   *cp;
  11: register int    public;
  12: {
  13:     int     bits;
  14:     register int    i,
  15:                     j;
  16: 
  17:     if (!m_seqok (cp))
  18:     return 0;
  19: 
  20:     if (public == -1)       /* XXX */
  21:     public = mp -> msgflags & READONLY ? 0 : 1;
  22: 
  23:     bits = FFATTRSLOT;
  24:     for (i = 0; mp -> msgattrs[i]; i++)
  25:     if (strcmp (mp -> msgattrs[i], cp) == 0) {
  26:         for (j = mp -> lowmsg; j <= mp -> hghmsg; j++)
  27:         mp -> msgstats[j] &= ~(1 << (bits + i));
  28:         if (public)
  29:         mp -> attrstats &= ~(1 << (bits + i));
  30:         else
  31:         mp -> attrstats |= 1 << (bits + i);
  32:         mp -> msgflags |= SEQMOD;
  33: 
  34:         return 1;
  35:     }
  36: 
  37:     if (i >= NATTRS) {
  38:     advise (NULLCP, "only %d sequences allowed (no room for %s)!",
  39:         NATTRS, cp);
  40:     return 0;
  41:     }
  42: 
  43:     mp -> msgattrs[i] = getcpy (cp);
  44:     for (j = mp -> lowmsg; j <= mp -> hghmsg; j++)
  45:     mp -> msgstats[j] &= ~(1 << (bits + i));
  46:     if (public)
  47:     mp -> attrstats &= ~(1 << (bits + i));
  48:     else
  49:     mp -> attrstats |= 1 << (bits + i);
  50:     mp -> msgflags |= SEQMOD;
  51: 
  52:     mp -> msgattrs[++i] = NULL;
  53: 
  54:     return 1;
  55: }
  56: 
  57: /*  */
  58: 
  59: int     m_seqadd (mp, cp, j, public)
  60: register struct msgs *mp;
  61: register char   *cp;
  62: register int     j,
  63:          public;
  64: {
  65:     int     bits;
  66:     register int    i,
  67:                     k;
  68: 
  69:     if (!m_seqok (cp))
  70:     return 0;
  71: 
  72:     if (public == -1)       /* XXX */
  73:     public = mp -> msgflags & READONLY ? 0 : 1;
  74: 
  75:     bits = FFATTRSLOT;
  76:     for (i = 0; mp -> msgattrs[i]; i++)
  77:     if (strcmp (mp -> msgattrs[i], cp) == 0) {
  78:         mp -> msgstats[j] |= 1 << (bits + i);
  79:         if (public)
  80:         mp -> attrstats &= ~(1 << (bits + i));
  81:         else
  82:         mp -> attrstats |= 1 << (bits + i);
  83:         mp -> msgflags |= SEQMOD;
  84: 
  85:         return 1;
  86:     }
  87: 
  88:     if (i >= NATTRS) {
  89:     advise (NULLCP, "only %d sequences allowed (no room for %s)!",
  90:         NATTRS, cp);
  91:     return 0;
  92:     }
  93: 
  94:     mp -> msgattrs[i] = getcpy (cp);
  95:     for (k = mp -> lowmsg; k <= mp -> hghmsg; k++)
  96:     mp -> msgstats[k] &= ~(1 << (bits + i));
  97:     mp -> msgstats[j] |= 1 << (bits + i);
  98:     if (public)
  99:     mp -> attrstats &= ~(1 << (bits + i));
 100:     else
 101:     mp -> attrstats |= 1 << (bits + i);
 102:     mp -> msgflags |= SEQMOD;
 103: 
 104:     mp -> msgattrs[++i] = NULL;
 105: 
 106:     return 1;
 107: }
 108: 
 109: /*  */
 110: 
 111: int     m_seqdel (mp, cp, j)
 112: register struct msgs *mp;
 113: register char   *cp;
 114: register int     j;
 115: {
 116:     int     bits;
 117:     register int    i;
 118: 
 119:     if (!m_seqok (cp))
 120:     return 0;
 121: 
 122:     bits = FFATTRSLOT;
 123:     for (i = 0; mp -> msgattrs[i]; i++)
 124:     if (strcmp (mp -> msgattrs[i], cp) == 0) {
 125:         mp -> msgstats[j] &= ~(1 << (bits + i));
 126:         mp -> msgflags |= SEQMOD;
 127: 
 128:         return 1;
 129:     }
 130: 
 131:     advise (NULLCP, "no such sequence as %s", cp);
 132:     return 0;
 133: }
 134: 
 135: /*  */
 136: 
 137: static int  m_seqok (cp)
 138: register char   *cp;
 139: {
 140:     register char  *pp;
 141: 
 142:     if (cp == NULL || *cp == NULL) {
 143:     advise (NULLCP, "empty sequence name");
 144:     return 0;
 145:     }
 146: 
 147:     if (strcmp (cp, "new") == 0
 148: #ifdef  notdef
 149:         || strcmp (cp, "cur") == 0
 150: #endif	notdef
 151:         || strcmp (cp, "all") == 0
 152:         || strcmp (cp, "first") == 0
 153:         || strcmp (cp, "last") == 0
 154:         || strcmp (cp, "prev") == 0
 155:         || strcmp (cp, "next") == 0) {
 156:     advise (NULLCP, "illegal sequence name: %s", cp);
 157:     return 0;
 158:     }
 159: 
 160:     if (!isalpha (*cp)) {
 161:     advise (NULLCP, "illegal sequence name: %s", cp);
 162:     return 0;
 163:     }
 164:     for (pp = cp + 1; *pp; pp++)
 165:     if (!isalnum (*pp)) {
 166:         advise (NULLCP, "illegal sequence name: %s", cp);
 167:         return 0;
 168:     }
 169: 
 170:     return 1;
 171: }

Defined functions

m_seqdel defined in line 111; used 1 times
m_seqnew defined in line 8; used 2 times
m_seqok defined in line 137; used 3 times
Last modified: 1985-11-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1170
Valid CSS Valid XHTML 1.0 Strict