/[dynamips]/upstream/dynamips-0.2.7-RC1/parser.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /upstream/dynamips-0.2.7-RC1/parser.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (show annotations)
Sat Oct 6 16:23:47 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 1646 byte(s)
dynamips-0.2.7-RC1

1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)
4 */
5
6 #ifndef __PARSER_H__
7 #define __PARSER_H__
8
9 #include <sys/types.h>
10
11 /* Parser Errors */
12 enum {
13 PARSER_ERROR_NOMEM = 1,
14 PARSER_ERROR_UNEXP_QUOTE, /* Unexpected quote in a word */
15 PARSER_ERROR_UNEXP_EOL, /* Unexpected end of line */
16 };
17
18 /* Parser states */
19 enum {
20 PARSER_STATE_DONE,
21 PARSER_STATE_SKIP,
22 PARSER_STATE_BLANK,
23 PARSER_STATE_STRING,
24 PARSER_STATE_QUOTED_STRING,
25 };
26
27 /* Token */
28 typedef struct parser_token parser_token_t;
29 struct parser_token {
30 char *value;
31 struct parser_token *next;
32 };
33
34 /* Parser context */
35 typedef struct parser_context parser_context_t;
36 struct parser_context {
37 /* Token list */
38 parser_token_t *tok_head,*tok_last;
39 int tok_count;
40
41 /* Temporary token */
42 char *tmp_tok;
43 size_t tmp_tot_len,tmp_cur_len;
44
45 /* Parser state and error */
46 int state,error;
47
48 /* Number of consumed chars */
49 size_t consumed_len;
50 };
51
52 /* Get a description given an error code */
53 char *parser_strerror(parser_context_t *ctx);
54
55 /* Dump a token list */
56 void parser_dump_tokens(parser_context_t *ctx);
57
58 /* Map a token list to an array */
59 char **parser_map_array(parser_context_t *ctx);
60
61 /* Initialize parser context */
62 void parser_context_init(parser_context_t *ctx);
63
64 /* Free memory used by a parser context */
65 void parser_context_free(parser_context_t *ctx);
66
67 /* Send a buffer to the tokenizer */
68 int parser_scan_buffer(parser_context_t *ctx,u_char *buf,size_t buf_size);
69
70 /* Tokenize a string */
71 int parser_tokenize(char *str,struct parser_token **tokens,int *tok_count);
72
73 #endif

  ViewVC Help
Powered by ViewVC 1.1.26