Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Trying to fix modification with new master branch
[simgrid.git] / include / surf / surfxml_parse.h
1 /* Copyright (c) 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef _SURF_SURFXML_PARSE_H
8 #define _SURF_SURFXML_PARSE_H
9
10 #include <stdio.h>              /* to have FILE */
11 #include "xbt/misc.h"
12 #include "xbt/function_types.h"
13 #include "xbt/dict.h"
14 #include "surf/simgrid_dtd.h"
15
16 SG_BEGIN_DECL()
17
18 XBT_PUBLIC(void) surf_parse_open(const char *file);
19 XBT_PUBLIC(void) surf_parse_close(void);
20 XBT_PUBLIC(void) surf_parse_init_callbacks(void);
21 XBT_PUBLIC(void) surf_parse_reset_callbacks(void);
22 XBT_PUBLIC(void) surf_parse_free_callbacks(void);
23 XBT_PUBLIC(void) surf_parse_error(const char *msg,...) _XBT_GNUC_PRINTF(1,2) _XBT_GNUC_NORETURN;
24 XBT_PUBLIC(void) surf_parse_warn(const char *msg,...) _XBT_GNUC_PRINTF(1,2);
25 XBT_PUBLIC(double) surf_parse_get_double(const char *string);
26 XBT_PUBLIC(int) surf_parse_get_int(const char *string);
27 /* Prototypes of the functions offered by flex */
28 XBT_PUBLIC(int) surf_parse_lex(void);
29 XBT_PUBLIC(int) surf_parse_get_lineno(void);
30 XBT_PUBLIC(FILE *) surf_parse_get_in(void);
31 XBT_PUBLIC(FILE *) surf_parse_get_out(void);
32 XBT_PUBLIC(int) surf_parse_get_leng(void);
33 XBT_PUBLIC(char *) surf_parse_get_text(void);
34 XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
35 XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
36 XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
37 XBT_PUBLIC(int) surf_parse_get_debug(void);
38 XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
39 XBT_PUBLIC(int) surf_parse_lex_destroy(void);
40
41 /* What is needed to bypass the parser. */
42 XBT_PUBLIC_DATA(int_f_void_t) surf_parse;       /* Entry-point to the parser. Set this to your function. */
43
44 /* Set of macros to make the bypassing work easier.
45  * See examples/msg/masterslave_bypass.c for an example of use */
46
47 extern unsigned int surfxml_buffer_stack_stack_ptr;
48 extern unsigned int surfxml_buffer_stack_stack[1024];
49
50 #define SURFXML_BUFFER_SET(key,val) do { \
51   AX_surfxml_##key=AX_ptr; \
52   strcpy(A_surfxml_##key,val); \
53   AX_ptr+=(int)strlen(val)+1; } while(0)
54
55 #define SURFXML_BUFFER_RESET() do { \
56   AX_ptr = 0; \
57   memset(surfxml_bufferstack,0,surfxml_bufferstack_size); } while(0)
58
59 #define SURFXML_START_TAG(tag) \
60   do{                                                                   \
61     surfxml_buffer_stack_stack[surfxml_buffer_stack_stack_ptr++] = AX_ptr; \
62     STag_surfxml_##tag();                                               \
63   }while(0)
64
65 #define SURFXML_END_TAG(tag)                                            \
66   do{                                                                   \
67     AX_ptr = surfxml_buffer_stack_stack[--surfxml_buffer_stack_stack_ptr]; \
68     ETag_surfxml_##tag();                                               \
69   } while(0)
70
71 SG_END_DECL()
72 #endif