- xasprintf(&filename, "%s" SLASH "hosts" SLASH "%s", confbase, name);
- FILE *f = fopen(filename, "r");
- if(f) {
- while(fgets(line, sizeof line, f)) {
- if(!rstrip(line))
- continue;
- char *p = line, *q;
- p += strcspn(p, "\t =");
- if(!*p)
- continue;
- q = p + strspn(p, "\t ");
- if(*q == '=')
- q += 1 + strspn(q + 1, "\t ");
- *p = 0;
- if(strcasecmp(line, "Address"))
- continue;
- p = q + strcspn(q, "\t ");
- if(*p)
- *p++ = 0;
- p += strspn(p, "\t ");
- p[strcspn(p, "\t ")] = 0;
- if(*p) {
- if(strchr(q, ':'))
- xasprintf(&hostname, "[%s]:%s", q, p);
- else
- xasprintf(&hostname, "%s:%s", q, p);
- } else {
- hostname = xstrdup(q);
- }
- break;
- }
- fclose(f);
- }
+ snprintf(filename, sizeof filename, "%s" SLASH "hosts" SLASH "%s", confbase, name);
+ scan_for_hostname(filename, &hostname, &port);
+ scan_for_hostname(tinc_conf, &hostname, &port);