10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23*692Seota * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _SYS_KOBJ_LEX_H 280Sstevel@tonic-gate #define _SYS_KOBJ_LEX_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate /* 370Sstevel@tonic-gate * This file contains declarations for lex and its associated functions that 380Sstevel@tonic-gate * are used by the kernel to parse the contents of system files. 390Sstevel@tonic-gate * 400Sstevel@tonic-gate * These lex functions are for a few selected kernel modules that are required 410Sstevel@tonic-gate * to parse contents of file(s) on disk. This file is not for general kernel 420Sstevel@tonic-gate * usage. 430Sstevel@tonic-gate */ 440Sstevel@tonic-gate 450Sstevel@tonic-gate #define isunary(ch) ((ch) == '~' || (ch) == '-') 460Sstevel@tonic-gate 470Sstevel@tonic-gate #define iswhite(ch) ((ch) == ' ' || (ch) == '\t') 480Sstevel@tonic-gate 490Sstevel@tonic-gate #define isnewline(ch) ((ch) == '\n' || (ch) == '\r' || (ch) == '\f') 500Sstevel@tonic-gate 510Sstevel@tonic-gate #define isdigit(ch) ((ch) >= '0' && (ch) <= '9') 520Sstevel@tonic-gate 530Sstevel@tonic-gate #define isxdigit(ch) (isdigit(ch) || ((ch) >= 'a' && (ch) <= 'f') || \ 540Sstevel@tonic-gate ((ch) >= 'A' && (ch) <= 'F')) 550Sstevel@tonic-gate 560Sstevel@tonic-gate #define isalpha(ch) (((ch) >= 'a' && (ch) <= 'z') || \ 570Sstevel@tonic-gate ((ch) >= 'A' && (ch) <= 'Z')) 580Sstevel@tonic-gate 590Sstevel@tonic-gate #define isalphanum(ch) (isalpha(ch) || isdigit(ch)) 600Sstevel@tonic-gate 610Sstevel@tonic-gate #define isnamechar(ch) (isalphanum(ch) || (ch) == '_' || (ch) == '-') 620Sstevel@tonic-gate 630Sstevel@tonic-gate typedef enum { 64*692Seota UNEXPECTED = -1, 650Sstevel@tonic-gate EQUALS, 660Sstevel@tonic-gate AMPERSAND, 670Sstevel@tonic-gate BIT_OR, 680Sstevel@tonic-gate STAR, 690Sstevel@tonic-gate POUND, 700Sstevel@tonic-gate COLON, 710Sstevel@tonic-gate SEMICOLON, 720Sstevel@tonic-gate COMMA, 730Sstevel@tonic-gate SLASH, 740Sstevel@tonic-gate WHITE_SPACE, 750Sstevel@tonic-gate NEWLINE, 760Sstevel@tonic-gate EOF, 770Sstevel@tonic-gate STRING, 780Sstevel@tonic-gate HEXVAL, 790Sstevel@tonic-gate DECVAL, 800Sstevel@tonic-gate NAME 810Sstevel@tonic-gate } token_t; 820Sstevel@tonic-gate 830Sstevel@tonic-gate #ifdef DEBUG 840Sstevel@tonic-gate /* string values for token_t */ 850Sstevel@tonic-gate extern char *tokennames[]; 860Sstevel@tonic-gate #endif /* DEBUG */ 870Sstevel@tonic-gate 880Sstevel@tonic-gate /* 890Sstevel@tonic-gate * return 1 with sptr pointing to the string represented by token 900Sstevel@tonic-gate * On error returns NULL. The memory pointed to by sptr should be 910Sstevel@tonic-gate * freed using free_string function. 920Sstevel@tonic-gate */ 930Sstevel@tonic-gate int kobj_get_string(u_longlong_t *sptr, char *token); 940Sstevel@tonic-gate void kobj_free_string(void *ptr, int len); 950Sstevel@tonic-gate 960Sstevel@tonic-gate /* 970Sstevel@tonic-gate * returns decimal/octal/hex number in valuep 980Sstevel@tonic-gate * return 0 on success, -1 on failure 990Sstevel@tonic-gate */ 1000Sstevel@tonic-gate int kobj_getvalue(const char *token, u_longlong_t *valuep); 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate /* prints a formated message via cmn_err */ 1030Sstevel@tonic-gate /*PRINTFLIKE3*/ 1040Sstevel@tonic-gate extern void kobj_file_err(int type, struct _buf *file, char *fmt, ...) 1050Sstevel@tonic-gate __KPRINTFLIKE(3); 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate /* 1080Sstevel@tonic-gate * returns the next token in the file on success, 1090Sstevel@tonic-gate * return -1 on failure 1100Sstevel@tonic-gate */ 1110Sstevel@tonic-gate token_t kobj_lex(struct _buf *file, char *val, size_t size); 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate void kobj_find_eol(struct _buf *file); 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate #ifdef __cplusplus 1160Sstevel@tonic-gate } 1170Sstevel@tonic-gate #endif 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate #endif /* !_SYS_KOBJ_LEX_H */ 120