Removed the space between function names and the opening parenthesis.
[mmh] / sbr / seq_nameok.c
1 /*
2 ** seq_nameok.c -- check if a sequence name is ok
3 **
4 ** This code is Copyright (c) 2002, by the authors of nmh.  See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
7 */
8
9 #include <h/mh.h>
10
11
12 int
13 seq_nameok(unsigned char *s)
14 {
15         unsigned char *pp;
16
17         if (s == NULL || *s == '\0') {
18                 advise(NULL, "empty sequence name");
19                 return 0;
20         }
21
22         /*
23         ** Make sure sequence name doesn't clash with one
24         ** of the `reserved' sequence names.
25         */
26         if (!(strcmp(s, "new") &&
27                   strcmp(s, "all") &&
28                   strcmp(s, "first") &&
29                   strcmp(s, "last") &&
30                   strcmp(s, "prev") &&
31                   strcmp(s, "next"))) {
32                 advise(NULL, "illegal sequence name: %s", s);
33                 return 0;
34         }
35
36         /*
37         ** First character in a sequence name must be
38         ** an alphabetic character ...
39         */
40         if (!isalpha(*s)) {
41                 advise(NULL, "illegal sequence name: %s", s);
42                 return 0;
43         }
44
45         /*
46         ** and can be followed by zero or more alphanumeric characters
47         */
48         for (pp = s + 1; *pp; pp++)
49                 if (!isalnum(*pp)) {
50                         advise(NULL, "illegal sequence name: %s", s);
51                         return 0;
52                 }
53
54         return 1;
55 }