8 int main(int argc, char *argv[]) {
9 // Open a new meshlink instance.
11 meshlink_handle_t *mesh = meshlink_open("basic_conf", "foo", "basic", DEV_CLASS_BACKBONE);
13 fprintf(stderr, "Could not initialize configuration for foo\n");
17 // Check that our own node exists.
19 meshlink_node_t *self = meshlink_get_self(mesh);
21 fprintf(stderr, "Foo does not know about itself\n");
24 if(strcmp(self->name, "foo")) {
25 fprintf(stderr, "Foo thinks its name is %s\n", self->name);
29 // Start and stop the mesh.
31 if(!meshlink_start(mesh)) {
32 fprintf(stderr, "Foo could not start\n");
37 // Make sure we can start and stop the mesh again.
39 if(!meshlink_start(mesh)) {
40 fprintf(stderr, "Foo could not start twice\n");
45 // Close the mesh and open it again, now with a different name parameter.
49 // Check that the name is ignored now, and that we still are "foo".
51 mesh = meshlink_open("basic_conf", "bar", "basic", DEV_CLASS_BACKBONE);
53 fprintf(stderr, "Could not open configuration for foo a second time\n");
57 if(meshlink_get_node(mesh, "bar")) {
58 fprintf(stderr, "Foo knows about bar, it shouldn't\n");
62 self = meshlink_get_self(mesh);
64 fprintf(stderr, "Foo doesn't know about itself the second time\n");
67 if(strcmp(self->name, "foo")) {
68 fprintf(stderr, "Foo thinks its name is %s the second time\n", self->name);
72 // Start and stop the mesh.
74 if(!meshlink_start(mesh)) {
75 fprintf(stderr, "Foo could not start a third time\n");
86 if(!meshlink_destroy("basic_conf")) {
87 fprintf(stderr, "Could not destroy configuration\n");
91 if(!access("basic_conf", F_OK) || errno != ENOENT) {
92 fprintf(stderr, "Configuration not fully destroyed\n");