#include <stdio.h>
#include "gras.h"
+#include "portable.h"
XBT_LOG_EXTERNAL_CATEGORY(dict);
XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
static xbt_error_t debuged_remove(xbt_dict_t head,const char*key);
static xbt_error_t traverse(xbt_dict_t head);
-#define STRING(str) (str)?:"(null)"
-
static void print_str(void *str);
static void print_str(void *str) {
- printf("%s",(char*)STRING(str));
+ printf("%s",(char*)PRINTF_STR(str));
}
static void fill(xbt_dict_t *head) {
{
char *data=xbt_strdup(key);
- printf(" - Add %s\n",STRING(key));
+ printf(" - Add %s\n",PRINTF_STR(key));
xbt_dict_set(head,key,data,&free);
if (XBT_LOG_ISENABLED(dict,xbt_log_priority_debug)) {
xbt_dict_dump(head,(void (*)(void*))&printf);
errcode=xbt_dict_get(head,key,&data);
- printf(" - Search %s. Found %s\n",STRING(key),(char*) STRING(data));fflush(stdout);
+ printf(" - Search %s. Found %s\n",PRINTF_STR(key),(char*) PRINTF_STR(data));fflush(stdout);
if (!data)
return errcode;
if (strcmp((char*)data,key))
{
xbt_error_t errcode;
- printf(" Remove '%s'\n",STRING(key));fflush(stdout);
+ printf(" Remove '%s'\n",PRINTF_STR(key));fflush(stdout);
errcode=xbt_dict_remove(head,key);
/* xbt_dict_dump(head,(void (*)(void*))&printf); */
return errcode;
char *data;
xbt_dict_foreach(head,cursor,key,data) {
- printf(" - Seen: %s->%s\n",STRING(key),STRING(data));
+ printf(" - Seen: %s->%s\n",PRINTF_STR(key),PRINTF_STR(data));
xbt_assert2(!data || !strcmp(key,data),
"Key(%s) != value(%s). Abording\n",key,data);
}
xbt_dict_t head=NULL;
char *data;
- xbt_init_defaultlog(&argc,argv,"dict.thresh=verbose");
+ xbt_init(&argc,argv);
printf("\nGeneric dictionnary: USAGE test:\n");
int found=0;
xbt_dict_foreach(head,cursor,key,data) {
- printf(" - Seen: %s->%s\n",STRING(key),STRING(data));fflush(stdout);
+ printf(" - Seen: %s->%s\n",PRINTF_STR(key),PRINTF_STR(data));fflush(stdout);
if (!strcmp(key,"null"))
found = 1;
}