+
+ if (!(f = fopen("/etc/lsb-release", "r")))
+ return -1;
+
+ while (!feof(f)) {
+ char ln[256], *p;
+
+ if (!fgets(ln, sizeof(ln), f))
+ break;
+
+ if (strncmp(ln, "DISTRIB_ID=", 11))
+ continue;
+
+ p = ln + 11;
+ p += strspn(p, "\"");
+ p[strcspn(p, "\"")] = 0;
+
+ snprintf(ret_s, size, "%s", p);
+
+ fclose(f);
+ return 0;
+ }
+
+ fclose(f);
+ return -1;
+}
+#endif
+
+char *avahi_get_host_name(char *ret_s, size_t size) {
+ assert(ret_s);
+ assert(size > 0);
+
+ if (gethostname(ret_s, size) >= 0) {
+ ret_s[size-1] = 0;
+ strip_bad_chars(ret_s);
+ } else
+ *ret_s = 0;
+
+ if (strcmp(ret_s, "localhost") == 0 || strncmp(ret_s, "localhost.", 10) == 0) {
+ *ret_s = 0;
+ avahi_log_warn("System host name is set to 'localhost'. This is not a suitable mDNS host name, looking for alternatives.");
+ }