Skip to content

Commit

Permalink
use walk_kvpair in bot instead of reinventing it.
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin committed Jun 19, 2009
1 parent e576267 commit 89317f1
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions examples/bot.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@

/* ************************************************************ */

/*
* kvpair visitor callback to display a received config parameter.
*/
static bool config_visitor(void *opaque, const char *key, const char **values)
{
printf("\t%s\n", key);

for (int i = 0; values[i]; i++) {
printf("\t\t%s\n", values[i]);
}

return true;
}

/*
* Example callback to handle a newly receive configuration.
*/
Expand All @@ -21,16 +35,7 @@ static void display_config(void* userdata, kvpair_t* conf)
printf("Hey. I received a new config (userdata: %s):\n",
(char*)userdata);

while (conf) {
int i = 0;
printf("\t%s\n", conf->key);

for (i = 0; conf->values[i]; i++) {
printf("\t\t%s\n", conf->values[i]);
}

conf = conf->next;
}
walk_kvpair(conf, NULL, config_visitor);
}

/*
Expand Down

0 comments on commit 89317f1

Please sign in to comment.