/[dynamips]/upstream/dynamips-0.2.6-RC5/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

Annotation of /upstream/dynamips-0.2.6-RC5/parser.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5 - (hide annotations)
Sat Oct 6 16:08:03 2007 UTC (16 years, 5 months ago) by dpavlin
Original Path: upstream/dynamips-0.2.6-RC4/parser.h
File MIME type: text/plain
File size: 1655 byte(s)
dynamips-0.2.6-RC4

1 dpavlin 1 /*
2     * Cisco 7200 (Predator) 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 dpavlin 2 /* 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 dpavlin 1 /* Token */
28     typedef struct parser_token parser_token_t;
29     struct parser_token {
30     char *value;
31     struct parser_token *next;
32     };
33    
34 dpavlin 2 /* 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 dpavlin 1 /* Get a description given an error code */
53 dpavlin 2 char *parser_strerror(parser_context_t *ctx);
54 dpavlin 1
55     /* Dump a token list */
56 dpavlin 2 void parser_dump_tokens(parser_context_t *ctx);
57 dpavlin 1
58     /* Map a token list to an array */
59 dpavlin 2 char **parser_map_array(parser_context_t *ctx);
60 dpavlin 1
61 dpavlin 2 /* 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 dpavlin 1 /* 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