X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=examples%2Fgroupchat.c;h=75e259db7d1d8ed16caee6e7cac92abe9b0043f4;hb=902446edf822a32383c4fa4b7c13b83a568095ad;hp=a866943a63bef4ca316a22efc060e0ddd5ffeb6b;hpb=9e2e05f3495c883356be93232b26d6cbb796a269;p=meshlink diff --git a/examples/groupchat.c b/examples/groupchat.c index a866943a..75e259db 100644 --- a/examples/groupchat.c +++ b/examples/groupchat.c @@ -129,7 +129,7 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) { } if(!s) { - fprintf(stderr, "Group is not yet creted!\n"); + fprintf(stderr, "Group is not yet created!\n"); return; } } @@ -227,9 +227,31 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) { return; } - meshlink_blacklist(mesh, node); + if(!meshlink_blacklist(mesh, node)) { + fprintf(stderr, "Error blacklising '%s': %s", arg, meshlink_strerror(meshlink_errno)); + return; + } fprintf(stderr, "Node '%s' blacklisted.\n", arg); + } else if(!strcasecmp(buf, "whitelist")) { + if(!arg) { + fprintf(stderr, "/whitelist requires an argument!\n"); + return; + } + + meshlink_node_t *node = meshlink_get_node(mesh, arg); + + if(!node) { + fprintf(stderr, "Error looking up '%s': %s\n", arg, meshlink_strerror(meshlink_errno)); + return; + } + + if(!meshlink_whitelist(mesh, node)) { + fprintf(stderr, "Error whitelising '%s': %s", arg, meshlink_strerror(meshlink_errno)); + return; + } + + fprintf(stderr, "Node '%s' whitelisted.\n", arg); } else if(!strcasecmp(buf, "who")) { meshlink_submesh_t *node_group = NULL; @@ -239,10 +261,10 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) { if(!nnodes) { fprintf(stderr, "Could not get list of nodes: %s\n", meshlink_strerror(meshlink_errno)); } else { - fprintf(stderr, "%zu known nodes:\n", nnodes); + fprintf(stderr, "%lu known nodes:\n", (unsigned long)nnodes); for(size_t i = 0; i < nnodes; i++) { - fprintf(stderr, " %lu. %s", i, nodes[i]->name); + fprintf(stderr, " %lu. %s", (unsigned long)i, nodes[i]->name); if((node_group = meshlink_get_node_submesh(mesh, nodes[i]))) { fprintf(stderr, "\t%s", node_group->name); @@ -328,7 +350,7 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) { "/who [] List all nodes or show information about the given node.\n" "/listgroup List all nodes in a given group.\n" "/canonical -h -p Set Canonical address to be present in invitation.\n" - " Any one of two options an be specified. Atleast one option must be present\n" + " Any one of two options an be specified. At least one option must be present\n" "/quit Exit this program.\n" ); } else {