MyStyle *mystyle_find_or_get_from_file(struct ASHashTable *list, const char *name) { MyStyle *ms; if ((ms = mystyle_list_find (list, name)) == NULL) { char *fn = make_session_data_file (Session, False, S_IFREG, MYSTYLES_DIR, name, NULL ); if (fn == NULL) fn = make_session_data_file (Session, False, S_IFREG, MYSTYLES_DIR, "mystyle.", name, NULL ); if (fn == NULL) fn = make_session_data_file (Session, True, S_IFREG, MYSTYLES_DIR, name, NULL ); if (fn == NULL) fn = make_session_data_file (Session, True, S_IFREG, MYSTYLES_DIR, "mystyle.", name, NULL ); if (fn != NULL) { FreeStorageElem *Storage = NULL; MyStyleDefinition *msd = NULL; Storage = file2free_storage(fn, MyName, &MyStyleSyntax, NULL, NULL ); if( Storage ) { msd = free_storage_elem2MyStyleDefinition(Storage, name); DestroyFreeStorage (&Storage); if (msd != NULL) { ms = mystyle_create_from_definition (list, msd); DestroyMyStyleDefinitions (&msd); } } free (fn); } } return ms; }
BaseConfig *ParseBaseOptions (const char *filename, char *myname) { BaseConfig *config = CreateBaseConfig (); FreeStorageElem *Storage = NULL, *pCurr; ConfigItem item; Storage = file2free_storage (filename, myname, &BaseSyntax, NULL, &(config->more_stuff)); if (Storage == NULL) return config; item.memory = NULL; for (pCurr = Storage; pCurr; pCurr = pCurr->next) { if (pCurr->term == NULL) continue; if (ReadFlagItem (&(config->set_flags), &(config->flags), pCurr, BaseFlags)) continue; if (!ReadConfigItem (&item, pCurr)) continue; switch (pCurr->term->id) { case BASE_MODULE_PATH_ID: set_string (&(config->module_path), item.data.string); break; case BASE_SOUND_PATH_ID: set_string (&(config->sound_path), item.data.string); break; case BASE_ICON_PATH_ID: set_string (&(config->icon_path), item.data.string); break; case BASE_PIXMAP_PATH_ID: set_string (&(config->pixmap_path), item.data.string); break; case BASE_FONT_PATH_ID: set_string (&(config->font_path), item.data.string); break; case BASE_CURSOR_PATH_ID: set_string (&(config->cursor_path), item.data.string); break; case BASE_MYNAME_PATH_ID: set_string (&(config->myname_path), item.data.string); break; case BASE_GTKRC_PATH_ID: set_string (&(config->gtkrc_path), item.data.string); break; case BASE_GTKRC20_PATH_ID: set_string (&(config->gtkrc20_path), item.data.string); break; case BASE_DESKTOP_SIZE_ID: set_flags (config->set_flags, BASE_DESKTOP_SIZE_SET); config->desktop_size = item.data.geometry; /* errorneous value check */ if (!(config->desktop_size.flags & WidthValue)) config->desktop_size.width = 1; if (!(config->desktop_size.flags & HeightValue)) config->desktop_size.height = 1; config->desktop_size.flags = WidthValue | HeightValue; break; case BASE_DESKTOP_SCALE_ID: set_flags (config->set_flags, BASE_DESKTOP_SCALE_SET); config->desktop_scale = item.data.integer; /* errorneous value check */ if (config->desktop_scale < 1) config->desktop_scale = 1; break; case BASE_NoModuleNameCollisions_ID: set_flags (config->set_flags, BASE_NoModuleNameCollisions_SET); config->NoModuleNameCollisions = item.data.integer; break; case BASE_TermCommand_ID: if (item.index < MAX_TOOL_COMMANDS && item.index >= 0) set_string (&(config->term_command[item.index]), item.data.string); else item.ok_to_free = 1; break; case BASE_BrowserCommand_ID: if (item.index < MAX_TOOL_COMMANDS && item.index >= 0) set_string (&(config->browser_command[item.index]), item.data.string); else item.ok_to_free = 1; break; case BASE_EditorCommand_ID: if (item.index < MAX_TOOL_COMMANDS && item.index >= 0) set_string (&(config->editor_command[item.index]), item.data.string); else item.ok_to_free = 1; break; case BASE_IconTheme_ID: set_string (&(config->IconTheme), item.data.string); break; case BASE_IconThemePath_ID: set_string (&(config->IconThemePath), item.data.string); break; case BASE_IconThemeFallback_ID: set_string (&(config->IconThemeFallback), item.data.string); break; default: item.ok_to_free = 1; } } ReadConfigItem (&item, NULL); DestroyFreeStorage (&Storage); return config; }