4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
27 * Copyright (c) 1997-2000 by Sun Microsystems, Inc.
28 * All rights reserved.
35 #include <sys/types.h>
39 static char *rsvrd
[] = {
49 #define ABI_NAMELNGTH 9
50 #define NON_ABI_NAMELNGTH 32
52 static int abi_namelngth
= 0;
55 valname(char *pkg
, int wild
)
60 /* wild == 1 allow wildcard specification as a name */
61 if (wild
&& (strcmp(pkg
, "all") == 0))
64 /* check for reserved package names */
65 for (i
= 0; rsvrd
[i
]; i
++) {
66 n
= (int)strlen(rsvrd
[i
]);
67 if ((strncmp(pkg
, rsvrd
[i
], n
) == 0) &&
68 (!pkg
[n
] || strchr(NMBRK
, pkg
[n
])))
73 * check for valid extensions; we used to do this
74 * first since we needed to look for SVR3 ".name"
75 * before we validate the package abbreviation
77 if (pt
= strpbrk(pkg
, NMBRK
)) {
78 if ((strcmp(pt
, WILD1
) == 0) || (strcmp(pt
, WILD2
) == 0)) {
79 /* wildcard specification */
86 if (!isalpha((unsigned char)*pt
) &&
87 !isdigit((unsigned char)*pt
) &&
91 if (!count
|| (count
> 4))
96 /* check for valid package name */
98 if (!isalpha((unsigned char)*pkg
))
100 while (*pkg
&& !strchr(NMBRK
, *pkg
)) {
101 if (!isalnum((unsigned char)*pkg
) && !strpbrk(pkg
, "-+"))
106 /* Check for ABI package name length */
107 if (get_ABI_namelngth() == 1) {
108 if (count
> ABI_NAMELNGTH
)
110 } else if (count
> NON_ABI_NAMELNGTH
)
113 return (0); /* pkg is valid */
116 /* presvr4flg - check for pre-svr4 package names also ? */
118 pkgnmchk(char *pkg
, char *spec
, int presvr4flg
)
120 _NOTE(ARGUNUSED(presvr4flg
));
122 /* pkg is assumed to be non-NULL upon entry */
125 * this routine reacts based on the value passed in spec:
126 * NULL pkg must be valid and may be a wildcard spec
127 * "all" pkg must be valid and must be an instance
128 * "x.*" pkg must be valid and must be an instance of "x"
129 * "x*" pkg must be valid and must be an instance of "x"
132 if (valname(pkg
, ((spec
== NULL
) ? 1 : 0)))
133 return (1); /* invalid or reserved name */
135 if ((spec
== NULL
) || (strcmp(spec
, "all") == 0))
138 while (*pkg
== *spec
) {
139 if ((strcmp(spec
, WILD1
) == 0) || (strcmp(spec
, WILD2
) == 0))
140 break; /* wildcard spec, so stop right here */
141 else if (*pkg
++ == '\0')
142 return (0); /* identical match */
146 if ((strcmp(spec
, WILD1
) == 0) || (strcmp(spec
, WILD2
) == 0))
147 if ((pkg
[0] == '\0') || (pkg
[0] == '.'))
153 set_ABI_namelngth(void)
159 get_ABI_namelngth(void)
161 return (abi_namelngth
);