source: trunk/third/nmh/sbr/seq_nameok.c @ 12455

Revision 12455, 1.0 KB checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12454, which included commits to RCS files with non-trunk default branches.
Line 
1
2/*
3 * seq_nameok.c -- check if a sequence name is ok
4 *
5 * $Id: seq_nameok.c,v 1.1.1.1 1999-02-07 18:14:10 danw Exp $
6 */
7
8#include <h/mh.h>
9
10
11int
12seq_nameok (char *s)
13{
14    char *pp;
15
16    if (s == NULL || *s == '\0') {
17        advise (NULL, "empty sequence name");
18        return 0;
19    }
20
21    /*
22     * Make sure sequence name doesn't clash with one
23     * of the `reserved' sequence names.
24     */
25    if (!(strcmp (s, "new") &&
26          strcmp (s, "all") &&
27          strcmp (s, "first") &&
28          strcmp (s, "last") &&
29          strcmp (s, "prev") &&
30          strcmp (s, "next"))) {
31        advise (NULL, "illegal sequence name: %s", s);
32        return 0;
33    }
34
35    /*
36     * First character in a sequence name must be
37     * an alphabetic character ...
38     */
39    if (!isalpha (*s)) {
40        advise (NULL, "illegal sequence name: %s", s);
41        return 0;
42    }
43
44    /*
45     * and can be followed by zero or more alphanumeric characters
46     */
47    for (pp = s + 1; *pp; pp++)
48        if (!isalnum (*pp)) {
49            advise (NULL, "illegal sequence name: %s", s);
50            return 0;
51        }
52
53    return 1;
54}
Note: See TracBrowser for help on using the repository browser.