6 int main(int argc, char *argv[]) {
7 // Open a new meshlink instance.
9 meshlink_handle_t *mesh = meshlink_open("basic_conf", "foo");
11 fprintf(stderr, "Could not initialize configuration for foo\n");
15 // Check that our own node exists.
17 meshlink_node_t *self = meshlink_get_node(mesh, "foo");
19 fprintf(stderr, "Foo does not know about itself\n");
22 if(strcmp(self->name, "foo")) {
23 fprintf(stderr, "Foo thinks its name is %s\n", self->name);
27 // Start and stop the mesh.
29 if(!meshlink_start(mesh)) {
30 fprintf(stderr, "Foo could not start\n");
35 // Make sure we can start and stop the mesh again.
37 if(!meshlink_start(mesh)) {
38 fprintf(stderr, "Foo could not start twice\n");
43 // Close the mesh and open it again, now with a different name parameter.
47 // Check that the name is ignored now, and that we still are "foo".
49 mesh = meshlink_open("basic_conf", "bar");
51 fprintf(stderr, "Could not open configuration for foo a second time\n");
55 if(meshlink_get_node(mesh, "bar")) {
56 fprintf(stderr, "Foo knows about bar, it shouldn't\n");
60 self = meshlink_get_node(mesh, "foo");
62 fprintf(stderr, "Foo doesn't know about itself the second time\n");
65 if(strcmp(self->name, "foo")) {
66 fprintf(stderr, "Foo thinks its name is %s the second time\n", self->name);
70 // Start and stop the mesh.
72 if(!meshlink_start(mesh)) {
73 fprintf(stderr, "Foo could not start a third time\n");