+gboolean set_names() {
+
+ /*gchar *hostname_buf, *ret;
+ size_t hostname_divider;
+
+ hostname_buf = (gchar*) g_malloc0(MAXHOSTNAMELEN);
+ ret = (gchar*) g_malloc0(MAXHOSTNAMELEN);
+
+ g_ptr_array_add(hostnamed_freeable, hostname_buf);
+ g_ptr_array_add(hostnamed_freeable, ret);
+
+ if(gethostname(hostname_buf, MAXHOSTNAMELEN) || g_strcmp0(hostname_buf, "") == 0)
+ return "localhost";
+
+ hostname_divider = strcspn(hostname_buf, ".");
+
+ return strncpy(ret, hostname_buf, hostname_divider);*/
+
+
+
+ /*const gchar *pretty_hostname;
+ const gchar *ret;
+
+ pretty_hostname = our_get_pretty_hostname();
+
+ if(g_strcmp0(pretty_hostname, "") == 0)
+ ret = our_get_hostname();
+
+ else if((ret = g_hostname_to_ascii(pretty_hostname))) {
+
+ g_ptr_array_add(hostnamed_freeable, (gpointer)ret);
+ return ret;
+ }
+
+ return ret;*/
+
+
+
+ /*GKeyFile *config;
+ gchar *ret;
+
+ config = g_key_file_new();
+
+ if(g_key_file_load_from_file(config, "/etc/systemd_compat.conf", G_KEY_FILE_NONE, NULL)
+ && (ret = g_key_file_get_value(config, "hostnamed", "PrettyHostname", NULL))) { ret might need to be freed, docs dont specify but i am suspicious
+
+ g_key_file_unref(config);
+ return ret;
+ }
+
+ if(config)
+ g_free(config);
+
+ return "";*/
+
+
+
+
+ return FALSE; /* temp */
+}
+
+gboolean set_uname_properties() {
+
+ struct utsname un;
+
+ if(-1 == uname(&un))
+ return FALSE;
+
+ KERN_NAME = (gchar*)g_malloc0(sizeof(un.sysname));
+ g_ptr_array_add(hostnamed_freeable, KERN_NAME);
+ g_strlcpy(KERN_NAME, un.sysname, sizeof(un.sysname));
+
+ KERN_RELEASE = (gchar*)g_malloc0(sizeof(un.release));
+ g_ptr_array_add(hostnamed_freeable, KERN_RELEASE);
+ g_strlcpy(KERN_RELEASE, un.release, sizeof(un.release));
+
+ KERN_VERS = (gchar*)g_malloc0(sizeof(un.version));
+ g_ptr_array_add(hostnamed_freeable, KERN_VERS);
+ g_strlcpy(KERN_VERS, un.version, sizeof(un.version));
+
+ return TRUE;
+}
+
+gboolean determine_chassis_and_icon() {
+
+ const size_t bufsize = 4096;
+
+ char *hwproduct, *hwmodel, *hwvendor, *hwmachine;
+ size_t hwproduct_size, hwmodel_size, hwvendor_size, hwmachine_size;
+ int hwproduct_name[2], hwmodel_name[2], hwvendor_name[2], hwmachine_name[2];
+ unsigned int i;
+ gboolean UNSURE_CHASSIS_FLAG, UNSURE_ICON_FLAG;
+
+ hwproduct_size = hwmodel_size = hwvendor_size = hwmachine_size = bufsize;
+ UNSURE_CHASSIS_FLAG = UNSURE_ICON_FLAG = FALSE;
+ i = 0;
+
+ hwproduct = (char*)g_malloc0(4096);
+ hwmodel = (char*)g_malloc0(4096);
+ hwvendor = (char*)g_malloc0(4096);
+ hwmachine = (char*)g_malloc0(4096);
+
+ g_ptr_array_add(hostnamed_freeable, hwproduct);
+ g_ptr_array_add(hostnamed_freeable, hwmodel);
+ g_ptr_array_add(hostnamed_freeable, hwvendor);
+ g_ptr_array_add(hostnamed_freeable, hwmachine);
+
+ hwproduct_name[0] = CTL_HW;
+ hwproduct_name[1] = HW_PRODUCT;
+
+ hwmodel_name[0] = CTL_HW;
+ hwmodel_name[1] = HW_MODEL;
+
+ hwvendor_name[0] = CTL_HW;
+ hwvendor_name[1] = HW_VENDOR;
+
+ hwmachine_name[0] = CTL_HW;
+ hwmachine_name[1] = HW_MACHINE;
+
+ /* pass NULL buffer to check size first, then pass hw to be filled according to freshly-set hw_size */
+ if(-1 == sysctl(hwproduct_name, 2, NULL, &hwproduct_size, NULL, 0) || -1 == sysctl(hwproduct_name, 2, hwproduct, &hwproduct_size, NULL, 0))
+ return FALSE;
+
+ if(-1 == sysctl(hwmodel_name, 2, NULL, &hwmodel_size, NULL, 0) || -1 == sysctl(hwmodel_name, 2, hwmodel, &hwmodel_size, NULL, 0))
+ return FALSE;
+
+ if(-1 == sysctl(hwvendor_name, 2, NULL, &hwvendor_size, NULL, 0) || -1 == sysctl(hwvendor_name, 2, hwvendor, &hwvendor_size, NULL, 0))
+ return FALSE;
+
+ if(-1 == sysctl(hwmachine_name, 2, NULL, &hwmachine_size, NULL, 0) || -1 == sysctl(hwmachine_name, 2, hwmachine, &hwmachine_size, NULL, 0))
+ return FALSE;
+
+ /* TODO: test for laptop, if not, dmidecode for desktop vs. server
+ * probably move this code to vm test func and set a global after running it early, once */
+
+ for(; i < G_N_ELEMENTS(chassis_indicator_table); i++) {
+ if(strcasestr(hwproduct, chassis_indicator_table[i].match_string)
+ || strcasestr(hwmodel, chassis_indicator_table[i].match_string)
+ || strcasestr(hwvendor, chassis_indicator_table[i].match_string)) {
+
+ if(!UNSURE_CHASSIS_FLAG && chassis_indicator_table[i].chassis) {
+
+ UNSURE_CHASSIS_FLAG = chassis_indicator_table[i].chassis_precedence;
+ CHASSIS = chassis_indicator_table[i].chassis;
+ }
+
+ if(!UNSURE_ICON_FLAG && chassis_indicator_table[i].icon) {
+
+ UNSURE_ICON_FLAG = chassis_indicator_table[i].icon_precedence;
+ ICON = chassis_indicator_table[i].icon;
+ }