8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libpkg / common / path_valid.c
blobc320685cdb7d96b50e09ca139690d0ce501d112e
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright (c) 2017 Peter Tribble.
27 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
31 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
32 /* All Rights Reserved */
34 #include <limits.h>
35 #include <string.h>
36 #include <sys/types.h>
39 * Name: path_valid
40 * Description: Checks a string for being a valid path
42 * Arguments: path - path to validate
44 * Returns : B_TRUE - success, B_FALSE otherwise.
45 * B_FALSE means path was null, too long (>PATH_MAX),
46 * or too short (<1)
48 boolean_t
49 path_valid(char *path)
51 if (path == NULL) {
52 return (B_FALSE);
53 } else if (strlen(path) > PATH_MAX) {
54 return (B_FALSE);
55 } else if (strlen(path) >= 1) {
56 return (B_TRUE);
57 } else {
58 /* path < 1 */
59 return (B_FALSE);