X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e9ffd4609de30c64881e5f799cf16344986b9686..9452e3db4f35f9d2b1fa15d751b704dc16b38297:/src/gras/Virtu/rl_process.c diff --git a/src/gras/Virtu/rl_process.c b/src/gras/Virtu/rl_process.c index 477c547928..ad664c0eb1 100644 --- a/src/gras/Virtu/rl_process.c +++ b/src/gras/Virtu/rl_process.c @@ -11,17 +11,49 @@ #include "gras/Virtu/virtu_rl.h" #include "portable.h" +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(gras_virtu_process); + /* globals */ static gras_procdata_t *_gras_procdata = NULL; XBT_EXPORT_NO_IMPORT(char const *) _gras_procname = NULL; +static xbt_dict_t _process_properties = NULL; +static xbt_dict_t _host_properties = NULL; + +# ifdef __APPLE__ +/* under darwin, the environment gets added to the process at startup time. So, it's not defined at library link time, forcing us to extra tricks */ +# include +# define environ (*_NSGetEnviron()) +# else + /* the environment, as specified by the opengroup, used to initialize the process properties */ + extern char **environ; +# endif void gras_process_init() { + char **env_iter; _gras_procdata=xbt_new0(gras_procdata_t,1); gras_procdata_init(); + + /* initialize the host & process properties */ + _host_properties = xbt_dict_new(); + _process_properties = xbt_dict_new(); + env_iter = environ; + while (*env_iter) { + char *equal, *buf = xbt_strdup(*env_iter); + equal = strchr(buf, '='); + if (!equal) { + WARN1("The environment contains an entry without '=' char: %s (ignore it)",*env_iter); + continue; + } + *equal = '\0'; + xbt_dict_set(_process_properties,buf,xbt_strdup(equal + 1),xbt_free_f); + free(buf); + env_iter++; + } } void gras_process_exit() { gras_procdata_exit(); free(_gras_procdata); + xbt_dict_free(&_process_properties); } const char *xbt_procname(void) { @@ -56,19 +88,16 @@ void gras_agent_spawn(const char *name, void *data, * Properties * **************************************************************************/ -const char* gras_process_property_value(char* name) { - THROW_UNIMPLEMENTED; +const char* gras_process_property_value(const char* name) { + return xbt_dict_get_or_null(_process_properties,name); } xbt_dict_t gras_process_properties(void) { - THROW_UNIMPLEMENTED; + return _process_properties; } -const char* gras_os_host_property_value(char* name) { - THROW_UNIMPLEMENTED; +const char* gras_os_host_property_value(const char* name) { + return xbt_dict_get_or_null(_host_properties,name); } xbt_dict_t gras_os_host_properties(void) { - THROW_UNIMPLEMENTED; + return _host_properties; } - - - \ No newline at end of file