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 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */ 30 31 #include "ctype.h" 32 #include "string.h" 33 #include "sys/param.h" 34 35 #include "lp.h" 36 37 int 38 #if defined(__STDC__) 39 syn_name ( 40 char * str 41 ) 42 #else 43 syn_name (str) 44 char *str; 45 #endif 46 { 47 register char *p; 48 49 if (!str || !*str) 50 return(0); 51 52 if (strlen(str) > (size_t) MAXPATHLEN) 53 return (0); 54 55 for (p = str; *p; p++) 56 if (!isalnum(*p) && *p != '_' && *p != '-' && *p != '.') 57 return (0); 58 59 return (1); 60 } 61 62 int 63 #if defined(__STDC__) 64 syn_type ( 65 char * str 66 ) 67 #else 68 syn_type (str) 69 char *str; 70 #endif 71 { 72 register char *p; 73 74 if (!str) 75 return(0); 76 77 if (strlen(str) > (size_t) MAXPATHLEN) 78 return (0); 79 80 for (p = str; *p; p++) 81 if (!isalnum(*p) && *p != '-') 82 return (0); 83 84 return (1); 85 } 86 87 int 88 #if defined(__STDC__) 89 syn_text ( 90 char * str 91 ) 92 #else 93 syn_text (str) 94 char *str; 95 #endif 96 { 97 register char *p; 98 99 if (!str) 100 return(0); 101 102 for (p = str; *p; p++) 103 if (!isgraph(*p) && *p != '\t' && *p != ' ') 104 return (0); 105 106 return (1); 107 } 108 109 int 110 #if defined(__STDC__) 111 syn_comment ( 112 char * str 113 ) 114 #else 115 syn_comment (str) 116 char *str; 117 #endif 118 { 119 register char *p; 120 121 if (!str) 122 return(0); 123 124 for (p = str; *p; p++) 125 if (!isgraph(*p) && *p != '\t' && *p != ' ' && *p != '\n') 126 return (0); 127 128 return (1); 129 } 130 131 int 132 #if defined(__STDC__) 133 syn_machine_name ( 134 char * str 135 ) 136 #else 137 syn_machine_name (str) 138 char *str; 139 #endif 140 { 141 if (!str) 142 return(0); 143 144 if (strlen(str) > (size_t) 8) 145 return (0); 146 147 return (1); 148 } 149 150 int 151 #if defined(__STDC__) 152 syn_option ( 153 char * str 154 ) 155 #else 156 syn_option (str) 157 char *str; 158 #endif 159 { 160 register char *p; 161 162 if (!str) 163 return(0); 164 165 for (p = str; *p; p++) 166 if (!isprint(*p)) 167 return (0); 168 169 return (1); 170 } 171