head 1.7; access; symbols; locks; strict; comment @ * @; 1.7 date 92.12.15.00.20.22; author jromine; state Exp; branches; next 1.6; 1.6 date 92.01.31.21.55.34; author jromine; state Exp; branches; next 1.5; 1.5 date 91.02.14.14.46.26; author mh; state Exp; branches; next 1.4; 1.4 date 90.04.05.15.32.00; author sources; state Exp; branches; next 1.3; 1.3 date 90.04.05.14.49.19; author sources; state Exp; branches; next 1.2; 1.2 date 90.02.06.13.09.00; author sources; state Exp; branches; next 1.1; 1.1 date 90.02.06.13.06.00; author sources; state Exp; branches; next ; desc @@ 1.7 log @endif sugar @ text @/* m_seqnew.c - manage sequences */ #ifndef lint static char ident[] = "@@(#)$Id: m_seqnew.c,v 1.6 1992/01/31 21:55:34 jromine Exp jromine $"; #endif /* lint */ #include "../h/mh.h" #include #include static int m_seqok(); int m_seqnew (mp, cp, public) register struct msgs *mp; register char *cp; register int public; { int bits; register int i, j; if (!m_seqok (cp)) return 0; if (public == -1) /* XXX */ public = mp -> msgflags & READONLY ? 0 : 1; bits = FFATTRSLOT; for (i = 0; mp -> msgattrs[i]; i++) if (strcmp (mp -> msgattrs[i], cp) == 0) { for (j = mp -> lowmsg; j <= mp -> hghmsg; j++) mp -> msgstats[j] &= ~(1 << (bits + i)); if (public) mp -> attrstats &= ~(1 << (bits + i)); else mp -> attrstats |= 1 << (bits + i); mp -> msgflags |= SEQMOD; return 1; } if (i >= NATTRS) { advise (NULLCP, "only %d sequences allowed (no room for %s)!", NATTRS, cp); return 0; } mp -> msgattrs[i] = getcpy (cp); for (j = mp -> lowmsg; j <= mp -> hghmsg; j++) mp -> msgstats[j] &= ~(1 << (bits + i)); if (public) mp -> attrstats &= ~(1 << (bits + i)); else mp -> attrstats |= 1 << (bits + i); mp -> msgflags |= SEQMOD; mp -> msgattrs[++i] = NULL; return 1; } /* */ int m_seqadd (mp, cp, j, public) register struct msgs *mp; register char *cp; register int j, public; { int bits; register int i, k; if (!m_seqok (cp)) return 0; /* keep mp->curmsg & msgattrs["cur"] in sync - see m_seq() */ if (strcmp (current,cp) == 0) mp->curmsg = j; if (public == -1) /* XXX */ public = mp -> msgflags & READONLY ? 0 : 1; bits = FFATTRSLOT; for (i = 0; mp -> msgattrs[i]; i++) if (strcmp (mp -> msgattrs[i], cp) == 0) { mp -> msgstats[j] |= 1 << (bits + i); if (public) mp -> attrstats &= ~(1 << (bits + i)); else mp -> attrstats |= 1 << (bits + i); mp -> msgflags |= SEQMOD; return 1; } if (i >= NATTRS) { advise (NULLCP, "only %d sequences allowed (no room for %s)!", NATTRS, cp); return 0; } mp -> msgattrs[i] = getcpy (cp); for (k = mp -> lowmsg; k <= mp -> hghmsg; k++) mp -> msgstats[k] &= ~(1 << (bits + i)); mp -> msgstats[j] |= 1 << (bits + i); if (public) mp -> attrstats &= ~(1 << (bits + i)); else mp -> attrstats |= 1 << (bits + i); mp -> msgflags |= SEQMOD; mp -> msgattrs[++i] = NULL; return 1; } /* */ int m_seqdel (mp, cp, j) register struct msgs *mp; register char *cp; register int j; { int bits; register int i; if (!m_seqok (cp)) return 0; bits = FFATTRSLOT; for (i = 0; mp -> msgattrs[i]; i++) if (strcmp (mp -> msgattrs[i], cp) == 0) { mp -> msgstats[j] &= ~(1 << (bits + i)); mp -> msgflags |= SEQMOD; return 1; } advise (NULLCP, "no such sequence as %s", cp); return 0; } /* */ static int m_seqok (cp) register char *cp; { register char *pp; if (cp == NULL || *cp == 0) { advise (NULLCP, "empty sequence name"); return 0; } if (strcmp (cp, "new") == 0 #ifdef notdef || strcmp (cp, "cur") == 0 #endif /* notdef */ || strcmp (cp, "all") == 0 || strcmp (cp, "first") == 0 || strcmp (cp, "last") == 0 || strcmp (cp, "prev") == 0 || strcmp (cp, "next") == 0) { advise (NULLCP, "illegal sequence name: %s", cp); return 0; } if (!isalpha (*cp)) { advise (NULLCP, "illegal sequence name: %s", cp); return 0; } for (pp = cp + 1; *pp; pp++) if (!isalnum (*pp)) { advise (NULLCP, "illegal sequence name: %s", cp); return 0; } return 1; } @ 1.6 log @kerberos @ text @d3 2 a4 2 static char ident[] = "@@(#)$Id: m_seqnew.c,v 1.5 1991/02/14 14:46:26 mh Exp jromine $"; #endif lint d158 1 a158 1 #endif notdef @ 1.5 log @fix van jacobson bug. jlr @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: m_seqnew.c,v 1.4 90/04/05 15:32:00 sources Exp Locker: mh $"; d150 1 a150 1 if (cp == NULL || *cp == NULL) { @ 1.4 log @add ID @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id:$"; d75 4 @ 1.3 log @add ID @ text @d3 1 a3 1 static char ident[] = "$Id:"; @ 1.2 log @ANSI Compilance @ text @d2 3 @ 1.1 log @Initial revision @ text @d7 1 @