From 421aa4b3efd1134af2afa1ebb920bb562ee58973 Mon Sep 17 00:00:00 2001 From: alegrand Date: Fri, 17 Dec 2004 23:30:56 +0000 Subject: [PATCH 1/1] Add a convenient function git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@682 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/include/surf/surf_parse.h | 1 + src/surf/surf_parse.l | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/include/surf/surf_parse.h b/src/include/surf/surf_parse.h index 8aea81b594..284224fc05 100644 --- a/src/include/surf/surf_parse.h +++ b/src/include/surf/surf_parse.h @@ -35,6 +35,7 @@ void find_section(const char *file, const char *section_name); void close_section(const char *section_name); void surf_parse_double(double *value); void surf_parse_trace(tmgr_trace_t * trace); +void surf_parse_deployment_line(char **host, int *argc, char ***argv); /* Should not be called if you use the previous "section" functions */ diff --git a/src/surf/surf_parse.l b/src/surf/surf_parse.l index d0c25da9b4..911124840c 100644 --- a/src/surf/surf_parse.l +++ b/src/surf/surf_parse.l @@ -225,6 +225,30 @@ void surf_parse_trace(tmgr_trace_t *trace) else *trace = tmgr_trace_new(surf_parse_text); } + +void surf_parse_deployment_line(char **host, int *argc, char ***argv) +{ + e_surf_token_t token; + + + /* Parse Host name */ + *host = xbt_strdup(surf_parse_text); + + *argc = 0; + *argv = NULL; + + /* Parse command line */ + while((token = surf_parse())) { + if(token == TOKEN_NEWLINE) return; + xbt_assert1((token == TOKEN_WORD), "Parse error line %d", surf_line_pos); + + (*argc)++; + *argv=xbt_realloc (*argv, (*argc) * sizeof(char*)); + (*argv)[(*argc)-1]=xbt_strdup(surf_parse_text); + } +} + + /* Local variables: */ /* mode: c */ /* End: */ -- 2.20.1