9 // Open a new meshlink instance.
11 meshlink_handle_t *mesh = meshlink_open("basic_conf", "foo", "basic", DEV_CLASS_BACKBONE);
14 fprintf(stderr, "Could not initialize configuration for foo\n");
18 // Check that our own node exists.
20 meshlink_node_t *self = meshlink_get_self(mesh);
23 fprintf(stderr, "Foo does not know about itself\n");
27 if(strcmp(self->name, "foo")) {
28 fprintf(stderr, "Foo thinks its name is %s\n", self->name);
32 // Start and stop the mesh.
34 if(!meshlink_start(mesh)) {
35 fprintf(stderr, "Foo could not start\n");
41 // Make sure we can start and stop the mesh again.
43 if(!meshlink_start(mesh)) {
44 fprintf(stderr, "Foo could not start twice\n");
50 // Close the mesh and open it again, now with a different name parameter.
54 // Check that the name is ignored now, and that we still are "foo".
56 mesh = meshlink_open("basic_conf", "bar", "basic", DEV_CLASS_BACKBONE);
59 fprintf(stderr, "Could not open configuration for foo a second time\n");
63 if(meshlink_get_node(mesh, "bar")) {
64 fprintf(stderr, "Foo knows about bar, it shouldn't\n");
68 self = meshlink_get_self(mesh);
71 fprintf(stderr, "Foo doesn't know about itself the second time\n");
75 if(strcmp(self->name, "foo")) {
76 fprintf(stderr, "Foo thinks its name is %s the second time\n", self->name);
80 // Start and stop the mesh.
82 if(!meshlink_start(mesh)) {
83 fprintf(stderr, "Foo could not start a third time\n");
95 if(!meshlink_destroy("basic_conf")) {
96 fprintf(stderr, "Could not destroy configuration\n");
100 if(!access("basic_conf", F_OK) || errno != ENOENT) {
101 fprintf(stderr, "Configuration not fully destroyed\n");