X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0039674dc4260ce2203ff4b35a012ea3a1c7a22a..e2d9affd41689205b3fd38b2d6c12128d5672c6c:/examples/gras/properties/gras_prop.c diff --git a/examples/gras/properties/gras_prop.c b/examples/gras/properties/gras_prop.c index 3e03f0a4d5..fa74db454e 100644 --- a/examples/gras/properties/gras_prop.c +++ b/examples/gras/properties/gras_prop.c @@ -1,6 +1,8 @@ -#include +/* $Id$ */ -XBT_LOG_NEW_DEFAULT_CATEGORY(property,"Simple Property example"); +#include "gras.h" + +XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Simple Property example"); int client(int argc, char *argv[]) { @@ -17,13 +19,31 @@ int client(int argc, char *argv[]) { } /* Try to get a property that does not exist */ - char *noexist=xbt_strdup("Nonexisent"); + char *noexist="Nonexisent"; const char *value = gras_process_property_value(noexist); if ( value == NULL) INFO1("Process property: %s is undefined", noexist); else INFO2("Process property: %s has value: %s", noexist, value); - + + /* Modify an existing property. First check it exists */\ + INFO0("Trying to modify a process property"); + char *exist="otherprop"; + value = gras_process_property_value(exist); + if ( value == NULL) + INFO1("\tProperty: %s is undefined", exist); + else { + INFO2("\tProperty: %s old value: %s", exist, value); + xbt_dict_set(props, exist, strdup("newValue"), free); + } + + /* Test if we have changed the value */ + value = gras_process_property_value(exist); + if ( value == NULL) + INFO1("\tProperty: %s is undefined", exist); + else + INFO2("\tProperty: %s new value: %s", exist, value); + gras_exit(); return 0; } @@ -42,7 +62,7 @@ int server(int argc, char *argv[]) { } /* Try to get a property that does not exist */ - char *noexist=xbt_strdup("Nonexisent"); + char *noexist="Nonexisent"; const char *value = gras_os_host_property_value(noexist); if ( value == NULL) INFO1("Host property: %s is undefined", noexist);