Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
3e03f0a4d5e6819c032abdef433c4f280b7fabc0
[simgrid.git] / examples / gras / properties / gras_prop.c
1 #include <gras.h>
2
3 XBT_LOG_NEW_DEFAULT_CATEGORY(property,"Simple Property example");
4
5
6 int client(int argc, char *argv[]) {
7   gras_init(&argc,argv);
8
9   /* Get the properties */
10   xbt_dict_t props = gras_process_properties();
11   xbt_dict_cursor_t cursor = NULL;
12   char *key,*data;
13
14   /* Print the properties of the workstation 1 */
15   xbt_dict_foreach(props,cursor,key,data) {
16     INFO2("Process property: %s has value: %s",key,data);
17   }
18  
19   /* Try to get a property that does not exist */
20   char *noexist=xbt_strdup("Nonexisent");
21   const char *value = gras_process_property_value(noexist);
22   if ( value == NULL) 
23     INFO1("Process property: %s is undefined", noexist);
24   else
25     INFO2("Process property: %s has value: %s", noexist, value);
26   
27   gras_exit();
28   return 0;
29 }
30
31 int server(int argc, char *argv[]) {
32   gras_init(&argc,argv);
33
34   /* Get the properties */
35   xbt_dict_t props = gras_os_host_properties();
36   xbt_dict_cursor_t cursor = NULL;
37   char *key,*data;
38
39   /* Print the properties of the workstation 1 */
40   xbt_dict_foreach(props,cursor,key,data) {
41     INFO2("Host property: %s has value: %s",key,data);
42   }
43  
44   /* Try to get a property that does not exist */
45   char *noexist=xbt_strdup("Nonexisent");
46   const char *value = gras_os_host_property_value(noexist);
47   if ( value == NULL) 
48     INFO1("Host property: %s is undefined", noexist);
49   else
50     INFO2("Host property: %s has value: %s", noexist, value);
51   
52   gras_exit();
53   return 0;
54 }