+
+ if (gethostname(ret_s, size) >= 0) {
+ ret_s[size-1] = 0;
+ strip_bad_chars(ret_s);
+ } else
+ *ret_s = 0;
+
+ if (*ret_s == 0) {
+ struct utsname utsname;
+
+ /* No hostname was set, so let's take the OS name */
+
+ if (uname(&utsname) >= 0) {
+ snprintf(ret_s, size, "%s", utsname.sysname);
+ strip_bad_chars(ret_s);
+ avahi_strdown(ret_s);
+ }
+
+ if (*ret_s == 0)
+ snprintf(ret_s, size, "unnamed");
+ }
+
+ if (size >= AVAHI_LABEL_MAX)
+ ret_s[AVAHI_LABEL_MAX-1] = 0;