]> git.meshlink.io Git - meshlink-tiny/commitdiff
Fix building the example programs.
authorGuus Sliepen <guus@sliepen.org>
Sat, 12 Jun 2021 21:23:16 +0000 (23:23 +0200)
committerGuus Sliepen <guus@sliepen.org>
Sat, 12 Jun 2021 21:23:16 +0000 (23:23 +0200)
examples/channels.c
examples/chat.c
examples/chatpp.cc
examples/groupchat.c
examples/manynodes.c

index 3a5426ef01746b699fe495369019c0cf44d650bc..e067ba007a413768ae186be92d3f54a9a893e744 100644 (file)
@@ -88,24 +88,7 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) {
                *arg++ = 0;
        }
 
-       if(!strcasecmp(buf, "invite")) {
-               char *invitation;
-
-               if(!arg) {
-                       fprintf(stderr, "/invite requires an argument!\n");
-                       return;
-               }
-
-               invitation = meshlink_invite(mesh, NULL, arg);
-
-               if(!invitation) {
-                       fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_strerror(meshlink_errno));
-                       return;
-               }
-
-               printf("Invitation for %s: %s\n", arg, invitation);
-               free(invitation);
-       } else if(!strcasecmp(buf, "join")) {
+       if(!strcasecmp(buf, "join")) {
                if(!arg) {
                        fprintf(stderr, "/join requires an argument!\n");
                        return;
@@ -123,44 +106,6 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) {
                        fprintf(stderr, "Could not restart MeshLink: %s\n", meshlink_strerror(meshlink_errno));
                        exit(1);
                }
-       } else if(!strcasecmp(buf, "kick")) {
-               if(!arg) {
-                       fprintf(stderr, "/kick 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_blacklist(mesh, node)) {
-                       fprintf(stderr, "Error blacklising '%s': %s", arg, meshlink_strerror(meshlink_errno));
-                       return;
-               }
-
-               printf("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;
-               }
-
-               printf("Node '%s' whitelisted.\n", arg);
        } else if(!strcasecmp(buf, "who")) {
                if(!arg) {
                        nodes = meshlink_get_all_nodes(mesh, nodes, &nnodes);
@@ -192,7 +137,6 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) {
                printf(
                        "<name>: <message>     Send a message to the given node.\n"
                        "                      Subsequent messages don't need the <name>: prefix.\n"
-                       "/invite <name>        Create an invitation for a new node.\n"
                        "/join <invitation>    Join an existing mesh using an invitation.\n"
                        "/kick <name>          Blacklist the given node.\n"
                        "/who [<name>]         List all nodes or show information about the given node.\n"
index 0df04a73c96ac4efbc2cec7f4a61555aedafc342..bf3170916fbfe1c9e4cdb9633b78a91a5543065a 100644 (file)
@@ -69,44 +69,6 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) {
                        fprintf(stderr, "Could not restart MeshLink: %s\n", meshlink_strerror(meshlink_errno));
                        exit(1);
                }
-       } else if(!strcasecmp(buf, "kick")) {
-               if(!arg) {
-                       fprintf(stderr, "/kick 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_blacklist(mesh, node)) {
-                       fprintf(stderr, "Error blacklising '%s': %s", arg, meshlink_strerror(meshlink_errno));
-                       return;
-               }
-
-               printf("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;
-               }
-
-               printf("Node '%s' whitelisted.\n", arg);
        } else if(!strcasecmp(buf, "who")) {
                if(!arg) {
                        nodes = meshlink_get_all_nodes(mesh, nodes, &nnodes);
index 113d9559757161d93642a77d748f34268c7cc2d3..26ffde596cc864eddfa94740173d335c5fecf2b1 100644 (file)
@@ -59,22 +59,6 @@ static void parse_command(meshlink::mesh *mesh, char *buf) {
                        fprintf(stderr, "Could not restart MeshLink: %s\n", meshlink::strerror());
                        exit(1);
                }
-       } else if(!strcasecmp(buf, "kick")) {
-               if(!arg) {
-                       fprintf(stderr, "/kick requires an argument!\n");
-                       return;
-               }
-
-               meshlink::node *node = mesh->get_node(arg);
-
-               if(!node) {
-                       fprintf(stderr, "Error looking up '%s': %s\n", arg, meshlink::strerror());
-                       return;
-               }
-
-               mesh->blacklist(node);
-
-               printf("Node '%s' blacklisted.\n", arg);
        } else if(!strcasecmp(buf, "who")) {
                if(!arg) {
                        nodes = mesh->get_all_nodes(nodes, &nnodes);
index 5f03a619a18ed141d7f090b05a286078fc539c78..ddcbbfa1da96784840c88f269b477d6bbb0dcddd 100644 (file)
@@ -95,48 +95,7 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) {
 
        }
 
-       if(!strcasecmp(buf, "invite")) {
-               if(!arg) {
-                       fprintf(stderr, "/invite requires an argument!\n");
-                       return;
-               }
-
-               meshlink_submesh_t *s = NULL;
-
-               if(arg1) {
-                       size_t nmemb;
-                       meshlink_submesh_t **submeshes = devtool_get_all_submeshes(mesh, NULL, &nmemb);
-
-                       if(!submeshes || !nmemb) {
-                               fprintf(stderr, "Group does not exist!\n");
-                               return;
-                       }
-
-                       for(size_t i = 0; i < nmemb; i++) {
-                               if(!strcmp(arg1, submeshes[i]->name)) {
-                                       s = submeshes[i];
-                                       break;
-                               }
-                       }
-
-                       free(submeshes);
-
-                       if(!s) {
-                               fprintf(stderr, "Group is not yet created!\n");
-                               return;
-                       }
-               }
-
-               char *invitation = meshlink_invite(mesh, s, arg);
-
-               if(!invitation) {
-                       fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_strerror(meshlink_errno));
-                       return;
-               }
-
-               fprintf(stderr, "Invitation for %s: %s\n", arg, invitation);
-               free(invitation);
-       } else if(!strcasecmp(buf, "canonical")) {
+       if(!strcasecmp(buf, "canonical")) {
                bool set;
                char *host = NULL, *port = NULL;
 
@@ -209,44 +168,6 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) {
                        fprintf(stderr, "Could not restart MeshLink: %s\n", meshlink_strerror(meshlink_errno));
                        exit(1);
                }
-       } else if(!strcasecmp(buf, "kick")) {
-               if(!arg) {
-                       fprintf(stderr, "/kick 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_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;
 
@@ -344,8 +265,6 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) {
                        "<name>: <message>                        Send a message to the given node.\n"
                        "                                         Subsequent messages don't need the <name>: prefix.\n"
                        "/group <name>                            Create a new group"
-                       "/invite <name> [submesh]                 Create an invitation for a new node.\n"
-                       "                                         Node joins either coremesh or submesh depending on submesh parameter.\n"
                        "/join <invitation>                               Join an existing mesh using an invitation.\n"
                        "/kick <name>                             Blacklist the given node.\n"
                        "/who [<name>]                            List all nodes or show information about the given node.\n"
index 1fdb3b4923241d149439c940df349dd21934ad3e..0ccf0753795e02cb3f2345c000107326e45b4672 100644 (file)
@@ -202,24 +202,7 @@ static void parse_command(char *buf) {
                *arg++ = 0;
        }
 
-       if(!strcasecmp(buf, "invite")) {
-               char *invitation;
-
-               if(!arg) {
-                       fprintf(stderr, "/invite requires an argument!\n");
-                       return;
-               }
-
-               invitation = meshlink_invite(meshes[nodeindex], NULL, arg);
-
-               if(!invitation) {
-                       fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_strerror(meshlink_errno));
-                       return;
-               }
-
-               printf("Invitation for %s: %s\n", arg, invitation);
-               free(invitation);
-       } else if(!strcasecmp(buf, "join")) {
+       if(!strcasecmp(buf, "join")) {
                if(!arg) {
                        fprintf(stderr, "/join requires an argument!\n");
                        return;
@@ -237,44 +220,6 @@ static void parse_command(char *buf) {
                        fprintf(stderr, "Could not restart MeshLink: %s\n", meshlink_strerror(meshlink_errno));
                        exit(1);
                }
-       } else if(!strcasecmp(buf, "kick")) {
-               if(!arg) {
-                       fprintf(stderr, "/kick requires an argument!\n");
-                       return;
-               }
-
-               meshlink_node_t *node = meshlink_get_node(meshes[nodeindex], arg);
-
-               if(!node) {
-                       fprintf(stderr, "Unknown node '%s'\n", arg);
-                       return;
-               }
-
-               if(!meshlink_blacklist(meshes[nodeindex], node)) {
-                       fprintf(stderr, "Error blacklising '%s': %s", arg, meshlink_strerror(meshlink_errno));
-                       return;
-               }
-
-               printf("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(meshes[nodeindex], arg);
-
-               if(!node) {
-                       fprintf(stderr, "Error looking up '%s': %s\n", arg, meshlink_strerror(meshlink_errno));
-                       return;
-               }
-
-               if(!meshlink_whitelist(meshes[nodeindex], node)) {
-                       fprintf(stderr, "Error whitelising '%s': %s", arg, meshlink_strerror(meshlink_errno));
-                       return;
-               }
-
-               printf("Node '%s' whitelisted.\n", arg);
        } else if(!strcasecmp(buf, "who")) {
                if(!arg) {
                        nodes = meshlink_get_all_nodes(meshes[nodeindex], nodes, &nnodes);
@@ -326,7 +271,6 @@ static void parse_command(char *buf) {
                printf(
                        "<name>: <message>     Send a message to the given node.\n"
                        "                      Subsequent messages don't need the <name>: prefix.\n"
-                       "/invite <name>        Create an invitation for a new node.\n"
                        "/join <invitation>    Join an existing mesh using an invitation.\n"
                        "/kick <name>          Blacklist the given node.\n"
                        "/who [<name>]         List all nodes or show information about the given node.\n"