int parse_entry(t_chopstick **sticks, t_philosopher **philo) { char *buff; int ret; if ((buff = malloc(sizeof(char) * 512)) == NULL) return (-1); printf("Would you like to configure the settings ? \ Otherwise I'll do it myself. (y/n)\n"); while ((ret = read(0, buff, 512)) > 0) { buff[ret - 1] = 0; if (strcmp(buff, "n") == 0) { free(buff); return (default_settings(sticks, philo)); } else if (strcmp(buff, "y") == 0) { free(buff); return (custom_settings(sticks, philo)); } else printf("Do not mess with me. I said y or n.\n"); } return (-1); }
status_t BPrinter::DefaultSettings(BMessage& settings) { status_t status = B_ERROR; image_id id = _LoadDriver(); if (id < 0) return status; typedef BMessage* (*default_settings_func_t)(BNode*); default_settings_func_t default_settings; if (get_image_symbol(id, "default_settings", B_SYMBOL_TYPE_TEXT , (void**)&default_settings) == B_OK) { BNode printerNode(&fPrinterEntryRef); BMessage *newSettings = default_settings(&printerNode); if (newSettings) { status = B_OK; settings = *newSettings; _AddPrinterName(settings); } delete newSettings; } unload_add_on(id); return status; }
// Read settings from persistent storage static void load_settings() { default_settings(); persist_read_data(SETTINGS_KEY, &userSettings, sizeof(userSettings)); }