-static char *get_my_name(meshlink_handle_t* mesh) {
- FILE *f = fopen(mesh->meshlink_conf, "r");
- if(!f) {
- return NULL;
- }
-
- char buf[4096];
- char *value;
- while(fgets(buf, sizeof buf, f)) {
- int len = strcspn(buf, "\t =");
- value = buf + len;
- value += strspn(value, "\t ");
- if(*value == '=') {
- value++;
- value += strspn(value, "\t ");
- }
- if(!rstrip(value))
- continue;
- buf[len] = 0;
- if(strcasecmp(buf, "Name"))
- continue;
- if(*value) {
- fclose(f);
- return strdup(value);
- }
- }
-
- fclose(f);
- return NULL;
-}