From 9003b522ca66f1a3723c63ce1c4753ad7aea9b70 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 16 Oct 2012 02:12:07 +0200 Subject: [PATCH] sg_cmdline is a public dynar containing all command-line arguments we got --- ChangeLog | 4 ++++ include/simgrid_config.h.in | 6 +++++- src/surf/surf.c | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 393ab80104..a93902a2a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -76,6 +76,10 @@ SimGrid (3.8) NOT RELEASED; urgency=low * Implement the exchange of non-contiguous data. [Khalid Hasanov & Jean-Noel Quintin] Thanks for the patch, guys. + SimGrid: + * Export a sg_cmdline dynar containing all the arguments we got from + the command line. + XBT: * Functions xbt_dict_hash() and xbt_dict_hash_ext() are made public, and renamed to xbt_str_hash() and xbt_str_hash_ext(). diff --git a/include/simgrid_config.h.in b/include/simgrid_config.h.in index 1c5edc8acf..06ecec882a 100644 --- a/include/simgrid_config.h.in +++ b/include/simgrid_config.h.in @@ -1,11 +1,12 @@ /* simgrid_config.h - Results of the configure made visible to user code */ -/* Copyright (c) 2009, 2010, 2011. Da SimGrid team. All rights reserved. */ +/* Copyright (c) 2009-2012. Da 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. */ #include "xbt/misc.h" /* XBT_PUBLIC */ +#include "xbt/dynar.h" /* sg_commandline */ #ifndef SIMGRID_PUBLIC_CONFIG_H #define SIMGRID_PUBLIC_CONFIG_H @@ -33,6 +34,9 @@ SG_BEGIN_DECL() SIMGRID_VERSION_MAJOR and friends give the version numbers of the used header files */ XBT_PUBLIC(void) sg_version(int *major,int *minor,int *patch); +/** Contains all the parameters we got from the command line */ +XBT_PUBLIC_DATA(xbt_dynar_t) sg_cmdline; + /* take care of DLL usage madness */ #ifdef _XBT_DLL_EXPORT diff --git a/src/surf/surf.c b/src/surf/surf.c index 729e6c3166..67cd8a4b34 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -391,6 +391,8 @@ void sg_version(int *ver_major,int *ver_minor,int *ver_patch) { *ver_patch = SIMGRID_VERSION_PATCH; } +xbt_dynar_t sg_cmdline = NULL; + void surf_init(int *argc, char **argv) { XBT_DEBUG("Create all Libs"); @@ -411,6 +413,11 @@ void surf_init(int *argc, char **argv) SURF_WKS_LEVEL = xbt_lib_add_level(host_lib,surf_resource_free); SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_resource_free); + sg_cmdline = xbt_dynar_new(sizeof(char*),NULL); + int i; + for (i=0;i<*argc;i++) { + xbt_dynar_push(sg_cmdline,&(argv[i])); + } xbt_init(argc, argv); if (!model_list) model_list = xbt_dynar_new(sizeof(surf_model_private_t), NULL); @@ -482,6 +489,7 @@ void surf_exit(void) #endif xbt_dynar_free(&surf_path); + xbt_dynar_free(&sg_cmdline); xbt_lib_free(&host_lib); xbt_lib_free(&link_lib); -- 2.20.1