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]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright 2015 PALO, Richard. All rights reserved.
29 #ifndef _SYS_KOBJ_LEX_H
30 #define _SYS_KOBJ_LEX_H
32 #include <sys/ctype.h>
39 * This file contains declarations for lex and its associated functions that
40 * are used by the kernel to parse the contents of system files.
42 * These lex functions are for a few selected kernel modules that are required
43 * to parse contents of file(s) on disk. This file is not for general kernel
47 #define isunary(ch) ((ch) == '~' || (ch) == '-')
49 #define iswhite(ch) ((ch) == ' ' || (ch) == '\t')
51 #define isnewline(ch) ((ch) == '\n' || (ch) == '\r' || (ch) == '\f')
53 #define isalphanum(ch) (isalpha(ch) || isdigit(ch))
55 #define isnamechar(ch) (isalphanum(ch) || (ch) == '_' || (ch) == '-')
78 /* string values for token_t */
79 extern char *tokennames
[];
83 * return 1 with sptr pointing to the string represented by token
84 * On error returns NULL. The memory pointed to by sptr should be
85 * freed using free_string function.
87 int kobj_get_string(u_longlong_t
*sptr
, char *token
);
88 void kobj_free_string(void *ptr
, int len
);
91 * returns decimal/octal/hex number in valuep
92 * return 0 on success, -1 on failure
94 int kobj_getvalue(const char *token
, u_longlong_t
*valuep
);
96 /* prints a formated message via cmn_err */
98 extern void kobj_file_err(int type
, struct _buf
*file
, char *fmt
, ...)
102 * returns the next token in the file on success,
103 * return -1 on failure
105 token_t
kobj_lex(struct _buf
*file
, char *val
, size_t size
);
107 void kobj_find_eol(struct _buf
*file
);
113 #endif /* !_SYS_KOBJ_LEX_H */