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; }
char *make_session_rc_file( ASSession *session, const char *tmpl ) { if( tmpl == NULL ) return NULL; if( tmpl[0] == '/' || tmpl[0] == '$' || tmpl[0] == '~' ) return copy_replace_envvar (tmpl); return make_session_data_file(session, False, 0, tmpl, NULL ); }
void LoadConfig (char *config_file_name, void (*read_options_func) (const char *)) { if (Session == NULL) { show_error ("Session has not been properly initialized. Exiting"); exit (1); } if (Session->overriding_file == NULL) { char *configfile; const char *const_configfile; configfile = make_session_file (Session, config_file_name, False); if (configfile != NULL) { read_options_func (configfile); show_progress ("configuration loaded from \"%s\" ...", configfile); free (configfile); } else { show_warning ("configuration file \"%s\" cannot be found", config_file_name); } if ((const_configfile = get_session_file (Session, 0, F_CHANGE_THEME, False)) != NULL) { read_options_func (const_configfile); show_progress ("THEME configuration loaded from \"%s\" ...", const_configfile); if ((configfile = make_session_data_file (Session, False, R_OK, THEME_OVERRIDE_FILE, NULL)) != NULL) { read_options_func (configfile); show_progress ("THEME OVERRIDES configuration loaded from \"%s\" ...", configfile); free (configfile); } } } else read_options_func (Session->overriding_file); }