/* returns: * 0 on success * 1 if data is empty * 2 if ConfigWriter cannot be initialized * */ int WriteBaseOptions (const char *filename, char *myname, BaseConfig * config, unsigned long flags) { ConfigDef *BaseConfigWriter = NULL; FreeStorageElem *Storage = NULL, **tail = &Storage; ConfigData cd; if (config == NULL) return 1; cd.filename = filename; if ((BaseConfigWriter = InitConfigWriter (myname, &BaseSyntax, CDT_Filename, cd)) == NULL) return 2; CopyFreeStorage (&Storage, config->more_stuff); /* building free storage here */ /* module_path */ tail = String2FreeStorage (&BaseSyntax, tail, config->module_path, BASE_MODULE_PATH_ID); /* icon_path */ tail = String2FreeStorage (&BaseSyntax, tail, config->icon_path, BASE_ICON_PATH_ID); /* pixmap_path */ tail = String2FreeStorage (&BaseSyntax, tail, config->pixmap_path, BASE_PIXMAP_PATH_ID); /* cursor_path */ tail = String2FreeStorage (&BaseSyntax, tail, config->cursor_path, BASE_CURSOR_PATH_ID); /* sound_path */ tail = String2FreeStorage (&BaseSyntax, tail, config->sound_path, BASE_SOUND_PATH_ID); /* myname_path */ tail = String2FreeStorage (&BaseSyntax, tail, config->myname_path, BASE_MYNAME_PATH_ID); /* IconTheme */ tail = String2FreeStorage (&BaseSyntax, tail, config->IconTheme, BASE_IconTheme_ID); /* IconThemePath */ tail = String2FreeStorage (&BaseSyntax, tail, config->IconThemePath, BASE_IconThemePath_ID); /* IconThemeFallback */ tail = String2FreeStorage (&BaseSyntax, tail, config->IconThemeFallback, BASE_IconThemeFallback_ID); /* desktop_size */ tail = Geometry2FreeStorage (&BaseSyntax, tail, &(config->desktop_size), BASE_DESKTOP_SIZE_ID); /* desktop_scale */ tail = Integer2FreeStorage (&BaseSyntax, tail, NULL, config->desktop_scale, BASE_DESKTOP_SCALE_ID); cd.filename = filename; /* writing config into the file */ WriteConfig (BaseConfigWriter, Storage, CDT_Filename, &cd, flags); DestroyFreeStorage (&Storage); DestroyConfig (BaseConfigWriter); return 0; }
/* returns: * 0 on success * 1 if data is empty * 2 if ConfigWriter cannot be initialized * */ int WriteWharfOptions (const char *filename, char *myname, WharfConfig * config, unsigned long flags) { ConfigDef *WharfConfigWriter = NULL; FreeStorageElem *Storage = NULL, **tail = &Storage; TermDef *folder_term = func2fterm (F_Folder, True); int i; if (config == NULL) return 1; folder_term->sub_syntax = &WharfSyntax; if ((WharfConfigWriter = InitConfigWriter (myname, &WharfSyntax, CDT_Filename, (void *)filename)) == NULL) return 2; CopyFreeStorage (&Storage, config->more_stuff); if (config->style_defs) *tail = MyStyleDefinitionsList2free_storage (config->style_defs, &WharfSyntax); if (config->balloon_conf) tail = balloon2FreeStorage (&WharfSyntax, tail, config->balloon_conf); /* building free storage here */ /* geometry */ if (get_flags (config->set_flags, WHARF_GEOMETRY)) tail = Geometry2FreeStorage (&WharfSyntax, tail, &(config->geometry), WHARF_Geometry_ID); if (get_flags (config->set_flags, WHARF_FORCE_SIZE)) tail = Geometry2FreeStorage (&WharfSyntax, tail, &(config->force_size), WHARF_ForceSize_ID); /* Integer values : */ /* rows */ if (get_flags (config->set_flags, WHARF_ROWS)) tail = Integer2FreeStorage (&WharfSyntax, tail, NULL, config->rows, WHARF_Rows_ID); /* columns */ if (get_flags (config->set_flags, WHARF_COLUMNS)) tail = Integer2FreeStorage (&WharfSyntax, tail, NULL, config->columns, WHARF_Columns_ID); /* withdraw_style */ if (get_flags (config->set_flags, WHARF_WITHDRAW_STYLE)) tail = Integer2FreeStorage (&WharfSyntax, tail, NULL, config->withdraw_style, WHARF_WithdrawStyle_ID); /* texture_type */ if (get_flags (config->set_flags, WHARF_TEXTURE_TYPE)) tail = Integer2FreeStorage (&WharfSyntax, tail, NULL, config->texture_type, WHARF_TextureType_ID); /* animate_steps */ if (get_flags (config->set_flags, WHARF_ANIMATE_STEPS)) tail = Integer2FreeStorage (&WharfSyntax, tail, NULL, config->animate_steps, WHARF_AnimateSteps_ID); /* animate_steps_main */ if (get_flags (config->set_flags, WHARF_ANIMATE_STEPS_MAIN)) tail = Integer2FreeStorage (&WharfSyntax, tail, NULL, config->animate_steps_main, WHARF_AnimateStepsMain_ID); /* animate_delay */ if (get_flags (config->set_flags, WHARF_ANIMATE_DELAY)) tail = Integer2FreeStorage (&WharfSyntax, tail, NULL, config->animate_delay, WHARF_AnimateDelay_ID); /* Flags : */ tail = Flags2FreeStorage (&WharfSyntax, tail, WharfFlags, 0xFFFFFFFF, config->set_flags); /* StringValues */ /* bg_color */ if (get_flags (config->set_flags, WHARF_BG_COLOR)) tail = String2FreeStorage (&WharfSyntax, tail, config->bg_color, WHARF_BgColor_ID); /* texture_color */ if (get_flags (config->set_flags, WHARF_TEXTURE_COLOR)) tail = String2FreeStorage (&WharfSyntax, tail, config->texture_color, WHARF_TextureColor_ID); /* pixmap name */ if (get_flags (config->set_flags, WHARF_PIXMAP)) tail = String2FreeStorage (&WharfSyntax, tail, config->pixmap, WHARF_Pixmap_ID); /* sound */ if (get_flags (config->set_flags, WHARF_SOUND)) for (i = 0; i < WHEV_MAX_EVENTS; i++) tail = String2FreeStorage (&WharfSyntax, tail, config->sounds[i], WHARF_Sound_ID); /* Writing Wharf Entries : */ if (config->root_folder) tail = WharfFolder2FreeStorage (&WharfSyntax, tail, config->root_folder, True); /* writing config into the file */ WriteConfig (WharfConfigWriter, Storage, CDT_Filename, (void **)&filename, flags); DestroyFreeStorage (&Storage); DestroyConfig (WharfConfigWriter); if (Storage) { fprintf (stderr, "\n%s:Config Writing warning: Not all Free Storage discarded! Trying again...", myname); DestroyFreeStorage (&Storage); fprintf (stderr, (Storage != NULL) ? " failed." : " success."); } return 0; }
int WriteSoundOptions (const char *filename, char *myname, SoundConfig * config, unsigned long flags) { ConfigDef *SoundConfigWriter = NULL; FreeStorageElem *Storage = NULL, **tail = &Storage; register int i ; ConfigData cd ; if (config == NULL) return 1; cd.filename = filename ; if ((SoundConfigWriter = InitConfigWriter (myname, &SoundSyntax, CDT_Filename, cd)) == NULL) return 2; CopyFreeStorage (&Storage, config->more_stuff); /* building free storage here */ /* PCM Device */ if( config->pcmdevice ) tail = String2FreeStorage (&SoundSyntax, tail, config->pcmdevice, SOUND_PCMDEVICE_ID); if (config->debug) tail = Integer2FreeStorage (&SoundSyntax, tail, NULL, config->debug, SOUND_DEBUG_ID); /* delay */ /* if( get_flags(config->set_flags, SOUND_SET_DELAY) ) tail = Integer2FreeStorage (&SoundSyntax, tail, NULL, config->delay, SOUND_DELAY_ID); */ /* rplay_host */ // if (get_flags(config->set_flags, SOUND_SET_RPLAY_HOST) && config->rplay_host) // tail = String2FreeStorage (&SoundSyntax, tail, config->rplay_host, SOUND_RPLAY_HOST_ID); /* rplay_priority */ // if (get_flags(config->set_flags, SOUND_SET_RPLAY_PRIORITY)) // tail = Integer2FreeStorage (&SoundSyntax, tail, NULL, config->rplay_priority, SOUND_RPLAY_PRI_ID); /* rplay_volume */ // if( get_flags(config->set_flags, SOUND_SET_RPLAY_VOLUME) ) // tail = Integer2FreeStorage (&SoundSyntax, tail, NULL, config->rplay_volume, SOUND_RPLAY_VOL_ID); /* line structure */ for( i = EVENT_ID_END-EVENT_ID_START-1 ; i >=0 ; i-- ) if( config->sounds[i] ) { FreeStorageElem **dtail = tail ; tail = Flag2FreeStorage (&SoundSyntax, tail, SOUND_SOUND_ID); if( *dtail ) Path2FreeStorage (&SoundEventsSyntax, &((*dtail)->sub), NULL, config->sounds[i], EVENT_ID_START + i); } /* writing config into the file */ WriteConfig (SoundConfigWriter, Storage, CDT_Filename, &cd, flags); DestroyFreeStorage (&Storage); DestroyConfig (SoundConfigWriter); if (Storage) { fprintf (stderr, "\n%s:Config Writing warning: Not all Free Storage discarded! Trying again...", myname); DestroyFreeStorage (&Storage); fprintf (stderr, (Storage != NULL) ? " failed." : " success."); } return 0; }