Пример #1
0
/* returns:
 *		0 on success
 *		1 if data is empty
 *		2 if ConfigWriter cannot be initialized
 *
 */
int
WriteIdentOptions (const char *filename, char *myname, IdentConfig * config, unsigned long flags)
{
	ConfigDef    *IdentConfigWriter = NULL;
	FreeStorageElem *Storage = NULL, **tail = &Storage;
	ConfigData cd ;

	if (config == NULL)
		return 1;
	cd.filename = filename ;
	if ((IdentConfigWriter = InitConfigWriter (myname, &IdentSyntax, CDT_Filename, cd)) == NULL)
		return 2;

	CopyFreeStorage (&Storage, config->more_stuff);
    if (config->style_defs)
        *tail = MyStyleDefinitionsList2free_storage (config->style_defs, &IdentSyntax);
	ADVANCE_LINKED_LIST_TAIL(tail);

	/* building free storage here */
	/* writing config into the file */
	cd.filename = filename ;
	WriteConfig (IdentConfigWriter, Storage, CDT_Filename, &cd, flags);
	DestroyFreeStorage (&Storage);
	DestroyConfig (IdentConfigWriter);

	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;
}
Пример #2
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;
}