X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0e16ef4c4c660214ac42b733a0abc6f6c12e9ef3..418a8a2942538b0741691f030b2fa8e6bae47290:/tools/gras/stub_generator.c?ds=sidebyside diff --git a/tools/gras/stub_generator.c b/tools/gras/stub_generator.c index fbba2fffb3..dfe760ce2d 100644 --- a/tools/gras/stub_generator.c +++ b/tools/gras/stub_generator.c @@ -1,9 +1,7 @@ -/* $Id$ */ - /* gras_stub_generator - creates the main() to use a GRAS program */ -/* Copyright (c) 2003-2007 Martin Quinson, Arnaud Legrand, Malek Cherier. */ -/* All rights reserved. */ +/* Copyright (c) 2005, 2006, 2007, 2009, 2010. The SimGrid Team. + * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -19,17 +17,14 @@ #include "xbt/log.h" #include "surf/surfxml_parse.h" #include "surf/surf.h" -#include "portable.h" /* Needed for the time of the SIMIX convertion */ +#include "portable.h" /* Needed for the time of the SIMIX convertion */ #include "gras_stub_generator.h" #include +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(stubgen, gras, "Stub generator"); - -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(stubgen,gras,"Stub generator"); - - -#ifdef _WIN32 +#ifdef _XBT_WIN32 #include #endif @@ -45,11 +40,13 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(stubgen,gras,"Stub generator"); xbt_dict_t process_function_set = NULL; xbt_dynar_t process_list = NULL; xbt_dict_t machine_set = NULL; +char *warning = NULL; -void s_process_free(void *process) { - s_process_t*p = (s_process_t*)process; +void s_process_free(void *process) +{ + s_process_t *p = (s_process_t *) process; int i; - for (i=0; iargc ; i++) + for (i = 0; i < p->argc; i++) free(p->argv[i]); free(p->argv); free(p->host); @@ -59,32 +56,37 @@ static s_process_t process; static void parse_process_init(void) { - xbt_dict_set(process_function_set, A_surfxml_process_function, NULL, NULL); + xbt_dict_set(process_function_set, A_surfxml_process_function, NULL, + NULL); xbt_dict_set(machine_set, A_surfxml_process_host, NULL, NULL); - process.argc = 1 ; - process.argv = xbt_new(char*,1); + process.argc = 1; + process.argv = xbt_new(char *, 1); process.argv[0] = xbt_strdup(A_surfxml_process_function); - process.host=strdup(A_surfxml_process_host); - /*VERB1("Function: %s",A_surfxml_process_function);*/ + process.host = strdup(A_surfxml_process_host); + /*XBT_VERB("Function: %s",A_surfxml_process_function); */ } static void parse_argument(void) { process.argc++; - process.argv = xbt_realloc(process.argv, (process.argc) * sizeof(char *)); + process.argv = + xbt_realloc(process.argv, (process.argc) * sizeof(char *)); process.argv[(process.argc) - 1] = xbt_strdup(A_surfxml_argument_value); } static void parse_process_finalize(void) { - xbt_dynar_push(process_list,&process); - /*VERB1("Function: %s",process.argv[0]);*/ + xbt_dynar_push(process_list, &process); + /*XBT_VERB("Function: %s",process.argv[0]); */ } +/*FIXME Defined in surfxml_parse.c*/ +#ifndef WIN32 void surfxml_add_callback(xbt_dynar_t cb_list, void_f_void_t function) { - xbt_dynar_push(cb_list, &function); + xbt_dynar_push(cb_list, &function); } +#endif int main(int argc, char *argv[]) @@ -92,82 +94,91 @@ int main(int argc, char *argv[]) char *project_name = NULL; char *deployment_file = NULL; int i; - + surf_init(&argc, argv); process_function_set = xbt_dict_new(); - process_list = xbt_dynar_new(sizeof(s_process_t),s_process_free); + process_list = xbt_dynar_new(sizeof(s_process_t), s_process_free); machine_set = xbt_dict_new(); - for (i=1; i= 3), + "Usage: %s project_name deployment_file [deployment_file...]\n", + argv[0]); project_name = argv[1]; - surf_parse_reset_parser(); - DEBUG2("%p %p",parse_process_init,&parse_process_init); + surf_parse_reset_callbacks(); + XBT_DEBUG("%p %p", parse_process_init, &parse_process_init); surfxml_add_callback(STag_surfxml_process_cb_list, &parse_process_init); surfxml_add_callback(ETag_surfxml_argument_cb_list, &parse_argument); - surfxml_add_callback(ETag_surfxml_process_cb_list, &parse_process_finalize); - - for(i=2; i