Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
updating the dtd and some memory leacks
[simgrid.git] / include / surf / surfxml_parse.h
1 /*      $Id$     */
2
3 /* Copyright (c) 2005 Arnaud Legrand. All rights reserved.                  */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #ifndef _SURF_SURFXML_PARSE_H
9 #define _SURF_SURFXML_PARSE_H
10
11 #include <stdio.h> /* to have FILE */
12 #include "surf/surfxml.h"
13 #include "xbt/function_types.h"
14 #include "xbt/dict.h"
15
16 /* Hook for the different tags. All the functions which pointer to are push into here are run when the tag is encountered */
17 XBT_PUBLIC(xbt_dynar_t) STag_surfxml_platform_description_cb_list;
18 XBT_PUBLIC(xbt_dynar_t) ETag_surfxml_platform_description_cb_list;
19 XBT_PUBLIC(xbt_dynar_t) STag_surfxml_host_cb_list;
20 XBT_PUBLIC(xbt_dynar_t) ETag_surfxml_host_cb_list;
21 XBT_PUBLIC(xbt_dynar_t) STag_surfxml_router_cb_list;
22 XBT_PUBLIC(xbt_dynar_t) ETag_surfxml_router_cb_list;
23 XBT_PUBLIC(xbt_dynar_t) STag_surfxml_link_cb_list;
24 XBT_PUBLIC(xbt_dynar_t) ETag_surfxml_link_cb_list;
25 XBT_PUBLIC(xbt_dynar_t) STag_surfxml_route_cb_list;
26 XBT_PUBLIC(xbt_dynar_t) ETag_surfxml_route_cb_list;
27 XBT_PUBLIC(xbt_dynar_t) STag_surfxml_link_c_ctn_cb_list;
28 XBT_PUBLIC(xbt_dynar_t) ETag_surfxml_link_c_ctn_cb_list;
29 XBT_PUBLIC(xbt_dynar_t) STag_surfxml_process_cb_list;
30 XBT_PUBLIC(xbt_dynar_t) ETag_surfxml_process_cb_list;
31 XBT_PUBLIC(xbt_dynar_t) STag_surfxml_argument_cb_list;
32 XBT_PUBLIC(xbt_dynar_t) ETag_surfxml_argument_cb_list;
33 XBT_PUBLIC(xbt_dynar_t) STag_surfxml_prop_cb_list;
34 XBT_PUBLIC(xbt_dynar_t) ETag_surfxml_prop_cb_list;
35
36 XBT_PUBLIC(void) surf_parse_open(const char *file);
37 XBT_PUBLIC(void) surf_parse_close(void);
38 XBT_PUBLIC(void) surf_parse_reset_parser(void);
39 XBT_PUBLIC(void) surf_parse_free_callbacks(void);
40 XBT_PUBLIC(void) surf_parse_get_double(double *value,const char *string);
41
42 /* Prototypes of the functions offered by flex */
43 XBT_PUBLIC(int) surf_parse_lex(void);
44 XBT_PUBLIC(int) surf_parse_get_lineno(void);
45 XBT_PUBLIC(FILE*) surf_parse_get_in(void);
46 XBT_PUBLIC(FILE*) surf_parse_get_out(void);
47 XBT_PUBLIC(int) surf_parse_get_leng(void);
48 XBT_PUBLIC(char*) surf_parse_get_text(void);
49 XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
50 XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
51 XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
52 XBT_PUBLIC(int) surf_parse_get_debug(void);
53 XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
54 XBT_PUBLIC(int) surf_parse_lex_destroy(void);
55
56 /* What is needed to bypass the parser. */
57 XBT_PUBLIC_DATA(int_f_void_t) surf_parse; /* Entry-point to the parser. Set this to your function. */
58
59 /* Set of macros to make the bypassing work easier.
60  * See examples/msg/masterslave_bypass.c for an example of use */
61 #define SURFXML_BUFFER_SET(key,val) do { \
62   AX_surfxml_##key=AX_ptr; \
63   strcpy(A_surfxml_##key,val); \
64   AX_ptr+=strlen(val)+1; } while(0)
65
66 #define SURFXML_BUFFER_RESET() do { \
67   AX_ptr = 0; \
68   memset(surfxml_bufferstack,0,surfxml_bufferstack_size); } while(0)
69
70 #define SURFXML_START_TAG(tag)  STag_surfxml_##tag()
71 #define SURFXML_END_TAG(tag)  do { ETag_surfxml_##tag(); SURFXML_BUFFER_RESET(); } while(0)     
72
73 XBT_PUBLIC(void) surfxml_add_callback(xbt_dynar_t cb_list, void_f_void_t function);
74
75
76 #endif