ia64/xen-unstable

view tools/vnet/libxutil/sxpr_parser.h @ 19848:5839491bbf20

[IA64] replace MAX_VCPUS with d->max_vcpus where necessary.

don't use MAX_VCPUS, and use vcpu::max_vcpus.
The changeset of 2f9e1348aa98 introduced max_vcpus to allow more vcpus
per guest. This patch is ia64 counter part.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Mon Jun 29 11:26:05 2009 +0900 (2009-06-29)
parents 06d84bf87159
children
line source
1 /*
2 * Copyright (C) 2001 - 2005 Mike Wray <mike.wray@hp.com>
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation; either version 2.1 of the
7 * License, or (at your option) any later version. This library is
8 * distributed in the hope that it will be useful, but WITHOUT ANY
9 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE.
11 * See the GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
18 #ifndef _XUTIL_SXPR_PARSER_H_
19 #define _XUTIL_SXPR_PARSER_H_
21 #include "sxpr.h"
22 #include "iostream.h"
24 /** @file
25 * Sxpr parsing definitions.
26 */
28 /** Initial size of a parser input buffer.
29 */
30 #define PARSER_BUF_SIZE 512
32 /** Input buffer size increment (when it's full).
33 */
34 #define PARSER_BUF_INCREMENT 512
36 struct Parser;
37 typedef int ParserStateFn(struct Parser *, char c);
39 typedef struct ParserState {
40 struct ParserState *parent;
41 Sxpr val;
42 int ival;
43 int count;
44 char delim;
45 ParserStateFn *fn;
46 char *name;
47 } ParserState;
49 typedef struct Parser {
50 /** Initial state function. */
51 ParserStateFn *begin;
52 /** Parse value. */
53 Sxpr val;
54 /** Error reporting stream (null for no reports). */
55 IOStream *error_out;
56 /** End-of-file flag, */
57 int eof;
58 /** Error flag. Non-zero if there has been a read error. */
59 int err;
60 /** Line number on input (from 1). */
61 int line_no;
62 /** Column number of input (reset on new line). */
63 int char_no;
64 /** Buffer for reading tokens. */
65 char *buf;
66 char *buf_end;
67 char *tok;
68 char *tok_end;
69 /** Line the last token started on. */
70 int tok_begin_line;
71 /** Character number the last token started on. */
72 int tok_begin_char;
73 /** Parsing flags. */
74 int flags;
75 ParserState *state;
76 ParserState *start_state;
77 } Parser;
79 /** Parser error codes. */
80 typedef enum {
81 PARSE_ERR_NONE=0,
82 PARSE_ERR_UNSPECIFIED,
83 PARSE_ERR_NOMEM,
84 PARSE_ERR_UNEXPECTED_EOF,
85 PARSE_ERR_TOKEN_TOO_LONG,
86 PARSE_ERR_INVALID_SYNTAX,
87 PARSE_ERR_INVALID_ESCAPE,
88 } ParseErrorId;
91 /** Parser flags. */
92 enum {
93 /** Convert integer atoms to ints. */
94 PARSE_INT=1,
95 };
97 /** Raise some parser flags.
98 *
99 * @param in parser
100 * @param flags flags mask
101 */
102 static inline void Parser_flags_raise(Parser *in, int flags){
103 in->flags |= flags;
104 }
106 /** Lower some parser flags.
107 *
108 * @param in parser
109 * @param flags flags mask
110 */
111 static inline void Parser_flags_lower(Parser *in, int flags){
112 in->flags &= ~flags;
113 }
115 /** Clear all parser flags.
116 *
117 * @param in parser
118 */
119 static inline void Parser_flags_clear(Parser *in){
120 in->flags = 0;
121 }
123 static inline int Parser_flags(Parser *in, int flags){
124 return in->flags & flags;
125 }
127 extern void Parser_free(Parser *z);
128 extern Parser * Parser_new(void);
129 extern int Parser_input(Parser *p, char *buf, int buf_n);
130 extern int Parser_input_eof(Parser *p);
131 extern int Parser_input_char(Parser *p, char c);
132 extern void Parser_set_error_stream(Parser *z, IOStream *error_out);
134 extern int Parser_error_message(Parser *in, char *buf, int n);
135 extern int Parser_has_error(Parser *in);
136 extern int Parser_at_eof(Parser *in);
138 extern int Parser_ready(Parser *p);
139 extern Sxpr Parser_get_val(Parser *p);
140 extern Sxpr Parser_get_all(Parser *p);
142 /* Internal parser api. */
143 void Parser_pop(Parser *p);
144 int Parser_push(Parser *p, ParserStateFn *fn, char *name);
145 int Parser_return(Parser *p);
146 int Parser_at_eof(Parser *p);
147 int Parser_error(Parser *in);
148 int Parser_set_value(Parser *p, Sxpr val);
149 int Parser_intern(Parser *p);
150 int Parser_string(Parser *p);
151 int Parser_data(Parser *p);
152 int Parser_uint(Parser *p);
154 char *peek_token(Parser *p);
155 char *copy_token(Parser *p);
156 void new_token(Parser *p);
157 int save_char(Parser *p, char c);
158 int token_len(Parser *p);
160 #endif /* ! _XUTIL_SXPR_PARSER_H_ */