Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add some convenient functions
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 7 Dec 2004 18:08:29 +0000 (18:08 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 7 Dec 2004 18:08:29 +0000 (18:08 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@547 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/include/surf/surf_parse.h
src/surf/surf_parse.l

index 02ea0ae..e6ced1a 100644 (file)
@@ -6,6 +6,9 @@
 #ifndef _SURF_SURF_PARSE_H
 #define _SURF_SURF_PARSE_H
 
 #ifndef _SURF_SURF_PARSE_H
 #define _SURF_SURF_PARSE_H
 
+#include "xbt/misc.h"
+#include "surf/trace_mgr.h"
+
 typedef enum {
   TOKEN_EMPTY = 0,
   TOKEN_LP = 512,
 typedef enum {
   TOKEN_EMPTY = 0,
   TOKEN_LP = 512,
@@ -28,6 +31,9 @@ extern int tok_num;
 e_surf_token_t surf_parse(void);
 void find_section(const char* file, const char* section_name);
 void close_section(const char* section_name);
 e_surf_token_t surf_parse(void);
 void find_section(const char* file, const char* section_name);
 void close_section(const char* section_name);
+void surf_parse_float(xbt_maxmin_float_t *value);
+void surf_parse_trace(tmgr_trace_t *trace);
+
 
 /* Should not be called if you use the previous "section" functions */
 void  surf_parse_open(const char *file);
 
 /* Should not be called if you use the previous "section" functions */
 void  surf_parse_open(const char *file);
index 39fd337..27034bf 100644 (file)
@@ -200,7 +200,29 @@ void  surf_parse_close(void) {
   tok_num = 0;
 }
 
   tok_num = 0;
 }
 
+void surf_parse_float(xbt_maxmin_float_t *value)
+{ 
+  e_surf_token_t token;
+  int ret = 0;
+
+  token = surf_parse();                /* power_scale */
+  xbt_assert1((token == TOKEN_WORD), "Parse error line %d", line_pos);
+  ret = sscanf(surf_parse_text, XBT_MAXMIN_FLOAT_T, value);
+  xbt_assert2((ret==1), "Parse error line %d : %s not a number", line_pos,
+             surf_parse_text);
+}
 
 
+void surf_parse_trace(tmgr_trace_t *trace)
+{
+  e_surf_token_t token;
+  
+  token = surf_parse();                /* power_trace */
+  xbt_assert1((token == TOKEN_WORD), "Parse error line %d", line_pos);
+  if (strcmp(surf_parse_text, "") == 0)
+    *trace = NULL;
+  else
+    *trace = tmgr_trace_new(surf_parse_text);
+}
 /*  Local variables: */
 /*  mode: c */
 /*  End: */
 /*  Local variables: */
 /*  mode: c */
 /*  End: */