1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
28
29
30 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
31 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
32
33 #include "ctype.h"
34 #include "string.h"
35 #include "sys/param.h"
36
37 #include "lp.h"
38
39 int
40 #if defined(__STDC__)
syn_name(char * str)41 syn_name (
42 char * str
43 )
44 #else
45 syn_name (str)
46 char *str;
47 #endif
48 {
49 register char *p;
50
51 if (!str || !*str)
52 return(0);
53
54 if (strlen(str) > (size_t) MAXPATHLEN)
55 return (0);
56
57 for (p = str; *p; p++)
58 if (!isalnum(*p) && *p != '_' && *p != '-' && *p != '.')
59 return (0);
60
61 return (1);
62 }
63
64 int
65 #if defined(__STDC__)
syn_type(char * str)66 syn_type (
67 char * str
68 )
69 #else
70 syn_type (str)
71 char *str;
72 #endif
73 {
74 register char *p;
75
76 if (!str)
77 return(0);
78
79 if (strlen(str) > (size_t) MAXPATHLEN)
80 return (0);
81
82 for (p = str; *p; p++)
83 if (!isalnum(*p) && *p != '-')
84 return (0);
85
86 return (1);
87 }
88
89 int
90 #if defined(__STDC__)
syn_text(char * str)91 syn_text (
92 char * str
93 )
94 #else
95 syn_text (str)
96 char *str;
97 #endif
98 {
99 register char *p;
100
101 if (!str)
102 return(0);
103
104 for (p = str; *p; p++)
105 if (!isgraph(*p) && *p != '\t' && *p != ' ')
106 return (0);
107
108 return (1);
109 }
110
111 int
112 #if defined(__STDC__)
syn_comment(char * str)113 syn_comment (
114 char * str
115 )
116 #else
117 syn_comment (str)
118 char *str;
119 #endif
120 {
121 register char *p;
122
123 if (!str)
124 return(0);
125
126 for (p = str; *p; p++)
127 if (!isgraph(*p) && *p != '\t' && *p != ' ' && *p != '\n')
128 return (0);
129
130 return (1);
131 }
132
133 int
134 #if defined(__STDC__)
syn_machine_name(char * str)135 syn_machine_name (
136 char * str
137 )
138 #else
139 syn_machine_name (str)
140 char *str;
141 #endif
142 {
143 if (!str)
144 return(0);
145
146 if (strlen(str) > (size_t) 8)
147 return (0);
148
149 return (1);
150 }
151
152 int
153 #if defined(__STDC__)
syn_option(char * str)154 syn_option (
155 char * str
156 )
157 #else
158 syn_option (str)
159 char *str;
160 #endif
161 {
162 register char *p;
163
164 if (!str)
165 return(0);
166
167 for (p = str; *p; p++)
168 if (!isprint(*p))
169 return (0);
170
171 return (1);
172 }
173