1 /*
2  * Copyright (c) 1998 Sasha Vasko <sasha at aftercode.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  *
18  */
19 
20 
21 #include "../configure.h"
22 #include "../libAfterStep/asapp.h"
23 #include "../libAfterStep/afterstep.h"
24 #include "../libAfterStep/mystyle.h"
25 #include "../libAfterStep/parser.h"
26 #include "../libAfterStep/balloon.h"
27 
28 #include "afterconf.h"
29 
30 /*****************************************************************************
31  *
32  * This routine is responsible for reading and parsing the config file
33  *
34  ****************************************************************************/
35 
36 TermDef PagerDecorationTerms[] = {
37 	{TF_NO_MYNAME_PREPENDING, "NoDeskLabel", 11, TT_FLAG,
38 	 PAGER_DECOR_NOLABEL_ID, NULL}
39 	,
40 	{TF_NO_MYNAME_PREPENDING, "NoPageSeparator", 15, TT_FLAG,
41 	 PAGER_DECOR_NOSEPARATOR_ID, NULL}
42 	,
43 	{TF_NO_MYNAME_PREPENDING, "NoSelection", 11, TT_FLAG,
44 	 PAGER_DECOR_NOSELECTION_ID, NULL}
45 	,
46 	{TF_NO_MYNAME_PREPENDING, "SelectionColor", 14, TT_COLOR,
47 	 PAGER_DECOR_SEL_COLOR_ID, NULL}
48 	,
49 	{TF_NO_MYNAME_PREPENDING, "GridColor", 9, TT_COLOR,
50 	 PAGER_DECOR_GRID_COLOR_ID, NULL}
51 	,
52 	{TF_NO_MYNAME_PREPENDING, "DeskBorderWidth", 15, TT_INTEGER,
53 	 PAGER_DECOR_BORDER_WIDTH_ID, NULL}
54 	,
55 	{TF_NO_MYNAME_PREPENDING, "DeskBorderColor", 15, TT_COLOR,
56 	 PAGER_DECOR_BORDER_COLOR_ID, NULL}
57 	,
58 	{TF_NO_MYNAME_PREPENDING, "LabelBelowDesk", 14, TT_FLAG,
59 	 PAGER_DECOR_LABEL_BELOW_ID, NULL}
60 	,
61 	{TF_NO_MYNAME_PREPENDING, "HideInactiveLabels", 18, TT_FLAG,
62 	 PAGER_DECOR_HIDE_INACTIVE_ID, NULL}
63 	,
64 	{TF_NO_MYNAME_PREPENDING, "VerticalLabel", 13, TT_FLAG,
65 	 PAGER_DECOR_VERTICAL_LABEL_ID, NULL}
66 	,
67 	{0, NULL, 0, 0, 0}
68 };
69 
70 SyntaxDef PagerDecorationSyntax = {
71 	',',
72 	'\n',
73 	PagerDecorationTerms,
74 	0,														/* use default hash size */
75 	' ',
76 	" ",
77 	"\t",
78 	"Module:Pager Decoration options",
79 	"PagerDecorations",
80 	"Visual attributes of the Pager window",
81 	NULL,
82 	0
83 };
84 
85 #define PAGER_FEEL_TERMS \
86     {0, "DontDrawBg", 8, TT_FLAG, PAGER_DRAW_BG_ID, NULL}, \
87     {0, "StartIconic", 11, TT_FLAG, PAGER_START_ICONIC_ID, NULL}
88 
89 #define PAGER_LOOK_TERMS \
90     {0, "Align", 5, TT_FLAG, PAGER_ALIGN_ID, &AlignSyntax}, \
91     {0, "SmallFont", 9, TT_FONT, PAGER_SMALL_FONT_ID, NULL}, \
92     {TF_DONT_SPLIT, "ShadeButton", 11, TT_OPTIONAL_PATHNAME, PAGER_SHADE_BUTTON_ID, NULL}, \
93     {TF_INDEXED|TF_QUOTES_OPTIONAL, "Style", 5, TT_QUOTED_TEXT, PAGER_STYLE_ID, NULL}, \
94     {0, "ActiveDeskBevel", 15,   TT_FLAG, PAGER_ActiveBevel_ID   , &BevelSyntax}, \
95     {0, "InActiveDeskBevel", 17, TT_FLAG, PAGER_InActiveBevel_ID , &BevelSyntax}, \
96     {TF_DONT_REMOVE_COMMENTS, "Decoration", 10, TT_TEXT, PAGER_DECORATION_ID, &PagerDecorationSyntax}
97 
98 #define PAGER_PRIVATE_TERMS \
99 	{0, "Geometry", 8, TT_GEOMETRY, PAGER_GEOMETRY_ID, NULL}, \
100     {0, "IconGeometry", 12, TT_GEOMETRY, PAGER_ICON_GEOMETRY_ID, NULL}, \
101     {0, "Rows", 4, TT_INTEGER, PAGER_ROWS_ID, NULL}, \
102     {0, "Columns", 7, TT_INTEGER, PAGER_COLUMNS_ID, NULL}, \
103     {0, "StickyIcons", 11, TT_FLAG, PAGER_STICKY_ICONS_ID, NULL}, \
104     {TF_INDEXED, "Label", 5, TT_TEXT, PAGER_LABEL_ID, NULL}
105 
106 /* we have sybsyntax for this one too, just like for MyStyle */
107 
108 TermDef PagerFeelTerms[] = {
109 	/* Feel */
110 	PAGER_FEEL_TERMS,
111 	BALLOON_FEEL_TERMS,
112 	{0, NULL, 0, 0, 0}
113 };
114 
115 SyntaxDef PagerFeelSyntax = {
116 	'\n',
117 	'\0',
118 	PagerFeelTerms,
119 	0,														/* use default hash size */
120 	'\t',
121 	"",
122 	"\t",
123 	"PagerFeel",
124 	"PagerFeel",
125 	"AfterStep virtual desktop navigation module feel",
126 	NULL,
127 	0
128 };
129 
130 
131 /* use ModuleMyStyleSyntax for MyStyles */
132 /*	INCLUDE_MYSTYLE, */
133 
134 TermDef PagerLookTerms[] = {
135 	/* Look */
136 	PAGER_LOOK_TERMS,
137 /* now special cases that should be processed by it's own handlers */
138 	BALLOON_LOOK_TERMS,
139 	{0, NULL, 0, 0, 0}
140 };
141 
142 SyntaxDef PagerLookSyntax = {
143 	'\n',
144 	'\0',
145 	PagerLookTerms,
146 	0,														/* use default hash size */
147 	'\t',
148 	"",
149 	"\t",
150 	"PagerLook",
151 	"PagerLook",
152 	"AfterStep virtual desktop navigation module look",
153 	NULL,
154 	0
155 };
156 
157 TermDef PagerPrivateTerms[] = {
158 	PAGER_PRIVATE_TERMS,
159 	BALLOON_FLAG_TERM,
160 	{0, NULL, 0, 0, 0}
161 };
162 
163 SyntaxDef PagerPrivateSyntax = {
164 	'\n',
165 	'\0',
166 	PagerPrivateTerms,
167 	0,														/* use default hash size */
168 	'\t',
169 	"",
170 	"\t",
171 	"Pager",
172 	"Pager",
173 	"AfterStep virtual desktop navigation module",
174 	NULL,
175 	0
176 };
177 
178 
179 
180 TermDef PagerTerms[] = {
181 	/* Feel */
182 	PAGER_FEEL_TERMS,
183 	/* Look */
184 	PAGER_LOOK_TERMS,
185 	/* private stuff */
186 	PAGER_PRIVATE_TERMS,
187 /* including MyStyles definitions processing */
188 	INCLUDE_MYSTYLE,
189 /* now special cases that should be processed by it's own handlers */
190 	BALLOON_TERMS,
191 	{0, NULL, 0, 0, 0}
192 };
193 
194 SyntaxDef PagerSyntax = {
195 	'\n',
196 	'\0',
197 	PagerTerms,
198 	0,														/* use default hash size */
199 	' ',
200 	"",
201 	"\t",
202 	"Module:Pager",
203 	"Pager",
204 	"AfterStep module for virtual desktop navigation",
205 	NULL,
206 	0
207 };
208 
CreatePagerConfig(int ndesks)209 PagerConfig *CreatePagerConfig (int ndesks)
210 {
211 	PagerConfig *config =
212 			(PagerConfig *) safecalloc (1, sizeof (PagerConfig));
213 
214 	/* let's initialize Pager's config with some nice values: */
215 	init_asgeometry (&(config->icon_geometry));
216 	init_asgeometry (&(config->geometry));
217 	config->ndesks = ndesks;
218 	config->labels = CreateStringArray (ndesks);
219 	config->styles = CreateStringArray (ndesks);
220 	config->align = 0;
221 	config->flags = PAGER_FLAGS_DEFAULT;
222 	config->set_flags = 0;
223 	config->small_font_name = NULL;
224 	config->rows = 1;
225 	config->columns = ndesks;
226 	config->selection_color = NULL;
227 	config->grid_color = NULL;
228 	config->border_width = 1;
229 	config->border_color = NULL;
230 	config->style_defs = NULL;
231 	config->shade_button[0] = NULL;
232 	config->shade_button[1] = NULL;
233 
234 	config->balloon_conf = NULL;
235 	config->more_stuff = NULL;
236 	config->gravity = NorthWestGravity;
237 
238 	return config;
239 }
240 
DestroyPagerConfig(PagerConfig * config)241 void DestroyPagerConfig (PagerConfig * config)
242 {
243 	int i;
244 
245 	if (config->labels) {
246 		for (i = 0; i < config->ndesks; ++i)
247 			if (config->labels[i])
248 				free (config->labels[i]);
249 		free (config->labels);
250 	}
251 	if (config->styles) {
252 		for (i = 0; i < config->ndesks; ++i)
253 			if (config->styles[i])
254 				free (config->styles[i]);
255 		free (config->styles);
256 	}
257 	destroy_string (&(config->selection_color));
258 	destroy_string (&(config->grid_color));
259 	destroy_string (&(config->border_color));
260 
261 /*
262     if( config->shade_button[0] )
263         free (config->shade_button[0]);
264     if( config->shade_button[1] )
265         free (config->shade_button[1]);
266  */
267 	Destroy_balloonConfig (config->balloon_conf);
268 	DestroyFreeStorage (&(config->more_stuff));
269 	DestroyMyStyleDefinitions (&(config->style_defs));
270 	free (config);
271 }
272 
ReadDecorations(PagerConfig * config,FreeStorageElem * pCurr)273 void ReadDecorations (PagerConfig * config, FreeStorageElem * pCurr)
274 {
275 	ConfigItem item;
276 
277 	item.memory = NULL;
278 
279 	for (; pCurr; pCurr = pCurr->next) {
280 		if (pCurr->term == NULL)
281 			continue;
282 
283 		if (pCurr->term->type == TT_FLAG) {
284 			switch (pCurr->term->id) {
285 			case PAGER_DECOR_NOLABEL_ID:
286 				config->flags &= ~USE_LABEL;
287 				set_flags (config->set_flags, USE_LABEL);
288 				break;
289 			case PAGER_DECOR_NOSEPARATOR_ID:
290 				config->flags &= ~PAGE_SEPARATOR;
291 				set_flags (config->set_flags, PAGE_SEPARATOR);
292 				break;
293 			case PAGER_DECOR_NOSELECTION_ID:
294 				config->flags &= ~SHOW_SELECTION;
295 				set_flags (config->set_flags, SHOW_SELECTION);
296 				break;
297 			case PAGER_DECOR_LABEL_BELOW_ID:
298 				config->flags |= LABEL_BELOW_DESK;
299 				set_flags (config->set_flags, LABEL_BELOW_DESK);
300 				break;
301 			case PAGER_DECOR_HIDE_INACTIVE_ID:
302 				config->flags |= HIDE_INACTIVE_LABEL;
303 				set_flags (config->set_flags, HIDE_INACTIVE_LABEL);
304 				break;
305 			case PAGER_DECOR_VERTICAL_LABEL_ID:
306 				config->flags |= VERTICAL_LABEL;
307 				set_flags (config->set_flags, VERTICAL_LABEL);
308 				break;
309 			}
310 		} else {
311 			if (!ReadConfigItem (&item, pCurr))
312 				continue;
313 
314 			switch (pCurr->term->id) {
315 			case PAGER_DECOR_SEL_COLOR_ID:
316 				config->selection_color = item.data.string;
317 				config->flags |= SHOW_SELECTION;
318 				set_flags (config->set_flags,
319 									 PAGER_SET_SELECTION_COLOR | SHOW_SELECTION);
320 				break;
321 			case PAGER_DECOR_GRID_COLOR_ID:
322 				config->grid_color = item.data.string;
323 				config->flags |= DIFFERENT_GRID_COLOR;
324 				set_flags (config->set_flags,
325 									 PAGER_SET_GRID_COLOR | DIFFERENT_GRID_COLOR);
326 				break;
327 			case PAGER_DECOR_BORDER_WIDTH_ID:
328 				config->border_width = item.data.integer;
329 				set_flags (config->set_flags, PAGER_SET_BORDER_WIDTH);
330 				break;
331 			case PAGER_DECOR_BORDER_COLOR_ID:
332 				config->border_color = item.data.string;
333 				config->flags |= DIFFERENT_BORDER_COLOR;
334 				set_flags (config->set_flags,
335 									 PAGER_SET_BORDER_COLOR | DIFFERENT_BORDER_COLOR);
336 				break;
337 			default:
338 				item.ok_to_free = 1;
339 			}
340 		}
341 	}
342 	ReadConfigItem (&item, NULL);
343 }
344 
ParsePagerOptions(const char * filename,char * myname,int desk1,int desk2)345 PagerConfig *ParsePagerOptions (const char *filename, char *myname,
346 																int desk1, int desk2)
347 {
348 	ConfigData cd;
349 	ConfigDef *PagerConfigReader;
350 	int ndesks = (desk2 - desk1) + 1;
351 	PagerConfig *config = CreatePagerConfig (ndesks);
352 
353 	FreeStorageElem *Storage = NULL, *pCurr;
354 	ConfigItem item;
355 
356 	cd.filename = filename;
357 	PagerConfigReader =
358 			InitConfigReader (myname, &PagerSyntax, CDT_Filename, cd, NULL);
359 	if (!PagerConfigReader)
360 		return config;
361 
362 	item.memory = NULL;
363 	PrintConfigReader (PagerConfigReader);
364 	ParseConfig (PagerConfigReader, &Storage);
365 
366 	/* getting rid of all the crap first */
367 	StorageCleanUp (&Storage, &(config->more_stuff), CF_DISABLED_OPTION);
368 
369 	config->balloon_conf =
370 			Process_balloonOptions (Storage, NULL, BALLOON_ID_START);
371 	config->style_defs = free_storage2MyStyleDefinitionsList (Storage);
372 
373 	for (pCurr = Storage; pCurr; pCurr = pCurr->next) {
374 		if (pCurr->term == NULL)
375 			continue;
376 
377 		if (pCurr->term->type == TT_FLAG) {
378 			switch (pCurr->term->id) {
379 			case PAGER_ALIGN_ID:
380 				set_flags (config->set_flags, PAGER_SET_ALIGN);
381 				config->align = ParseAlignOptions (pCurr->sub);
382 				break;
383 			case PAGER_DRAW_BG_ID:
384 				config->flags &= ~REDRAW_BG;
385 				set_flags (config->set_flags, REDRAW_BG);
386 				break;
387 			case PAGER_START_ICONIC_ID:
388 				config->flags |= START_ICONIC;
389 				set_flags (config->set_flags, START_ICONIC);
390 				break;
391 			case PAGER_FAST_STARTUP_ID:
392 				config->flags |= FAST_STARTUP;
393 				set_flags (config->set_flags, FAST_STARTUP);
394 				break;
395 			case PAGER_SET_ROOT_ID:
396 				config->flags |= SET_ROOT_ON_STARTUP;
397 				set_flags (config->set_flags, SET_ROOT_ON_STARTUP);
398 				break;
399 			case PAGER_STICKY_ICONS_ID:
400 				set_flags (config->flags, STICKY_ICONS);
401 				set_flags (config->set_flags, STICKY_ICONS);
402 				break;
403 			case PAGER_ActiveBevel_ID:
404 				set_flags (config->set_flags, PAGER_SET_ACTIVE_BEVEL);
405 				config->active_desk_bevel = ParseBevelOptions (pCurr->sub);
406 				break;
407 			case PAGER_InActiveBevel_ID:
408 				set_flags (config->set_flags, PAGER_SET_INACTIVE_BEVEL);
409 				config->inactive_desk_bevel = ParseBevelOptions (pCurr->sub);
410 				break;
411 			}
412 		} else {
413 			if (!ReadConfigItem (&item, pCurr))
414 				continue;
415 			if ((pCurr->term->flags & TF_INDEXED)
416 					&& (item.index < desk1 || item.index > desk2)) {
417 				item.ok_to_free = 1;
418 				continue;
419 			}
420 
421 			switch (pCurr->term->id) {
422 			case PAGER_GEOMETRY_ID:
423 				config->geometry = item.data.geometry;
424 				set_flags (config->set_flags, PAGER_SET_GEOMETRY);
425 				break;
426 			case PAGER_ICON_GEOMETRY_ID:
427 				config->icon_geometry = item.data.geometry;
428 				set_flags (config->set_flags, PAGER_SET_ICON_GEOMETRY);
429 				break;
430 			case PAGER_SMALL_FONT_ID:
431 				config->small_font_name = item.data.string;
432 				set_flags (config->set_flags, PAGER_SET_SMALL_FONT);
433 				break;
434 			case PAGER_ROWS_ID:
435 				config->rows = (int)item.data.integer;
436 				set_flags (config->set_flags, PAGER_SET_ROWS);
437 				break;
438 			case PAGER_COLUMNS_ID:
439 				config->columns = (int)item.data.integer;
440 				set_flags (config->set_flags, PAGER_SET_COLUMNS);
441 				break;
442 			case PAGER_LABEL_ID:
443 				config->labels[item.index - desk1] = item.data.string;
444 				break;
445 			case PAGER_STYLE_ID:
446 				config->styles[item.index - desk1] = item.data.string;
447 				break;
448 			case PAGER_SHADE_BUTTON_ID:
449 				destroy_string (&(config->shade_button[0]));
450 				destroy_string (&(config->shade_button[1]));
451 				if (item.data.string) {
452 					register char *tmp =
453 							parse_filename (item.data.string,
454 															&(config->shade_button[0]));
455 
456 					while (isspace (*tmp))
457 						++tmp;
458 					if (*tmp != '\0')
459 						parse_filename (tmp, &(config->shade_button[1]));
460 				}
461 				set_flags (config->set_flags, PAGER_SET_SHADE_BUTTON);
462 				break;
463 				/* decoration options */
464 			case PAGER_DECORATION_ID:
465 				ReadDecorations (config, pCurr->sub);
466 				item.ok_to_free = 1;
467 				break;
468 			default:
469 				item.ok_to_free = 1;
470 			}
471 		}
472 	}
473 
474 	ReadConfigItem (&item, NULL);
475 	DestroyConfig (PagerConfigReader);
476 	DestroyFreeStorage (&Storage);
477 	/*    PrintMyStyleDefinitions( config->style_defs ); */
478 	return config;
479 }
480 
481 /* returns:
482  *            0 on success
483  *              1 if data is empty
484  *              2 if ConfigWriter cannot be initialized
485  *
486  */
487 #if 0
488 int
489 WritePagerOptions (const char *filename, char *myname, int desk1,
490 									 int desk2, PagerConfig * config, unsigned long flags)
491 {
492 	ConfigDef *PagerConfigWriter = NULL;
493 	FreeStorageElem *Storage = NULL, **tail = &Storage;
494 	char *Decorations = NULL;
495 
496 	if (config == NULL)
497 		return 1;
498 	if ((PagerConfigWriter =
499 			 InitConfigWriter (myname, &PagerSyntax, CDT_Filename,
500 												 (void *)filename)) == NULL)
501 		return 2;
502 
503 	CopyFreeStorage (&Storage, config->more_stuff);
504 
505 	if (config->balloon_conf)
506 		tail = balloon2FreeStorage (&PagerSyntax, tail, config->balloon_conf);
507 	/* building free storage here */
508 	/* geometry */
509 	tail =
510 			Geometry2FreeStorage (&PagerSyntax, tail, &(config->geometry),
511 														PAGER_GEOMETRY_ID);
512 	/* icon_geometry */
513 	tail =
514 			Geometry2FreeStorage (&PagerSyntax, tail, &(config->icon_geometry),
515 														PAGER_ICON_GEOMETRY_ID);
516 	/* labels */
517 	tail =
518 			StringArray2FreeStorage (&PagerSyntax, tail, config->labels, desk1,
519 															 desk2, PAGER_LABEL_ID);
520 	/* styles */
521 	tail =
522 			StringArray2FreeStorage (&PagerSyntax, tail, config->styles, desk1,
523 															 desk2, PAGER_STYLE_ID);
524 	/* align */
525 	tail =
526 			Integer2FreeStorage (&PagerSyntax, tail, config->align,
527 													 PAGER_ALIGN_ID);
528 	/* flags */
529 	if (!(config->flags & REDRAW_BG))
530 		tail = Flag2FreeStorage (&PagerSyntax, tail, PAGER_DRAW_BG_ID);
531 	if (config->flags & START_ICONIC)
532 		tail = Flag2FreeStorage (&PagerSyntax, tail, PAGER_START_ICONIC_ID);
533 	if (config->flags & FAST_STARTUP)
534 		tail = Flag2FreeStorage (&PagerSyntax, tail, PAGER_FAST_STARTUP_ID);
535 	if (config->flags & SET_ROOT_ON_STARTUP)
536 		tail = Flag2FreeStorage (&PagerSyntax, tail, PAGER_SET_ROOT_ID);
537 	if (config->flags & STICKY_ICONS)
538 		tail = Flag2FreeStorage (&PagerSyntax, tail, PAGER_STICKY_ICONS_ID);
539 
540 	/* small_font_name */
541 	tail =
542 			String2FreeStorage (&PagerSyntax, tail, config->small_font_name,
543 													PAGER_SMALL_FONT_ID);
544 	/* rows */
545 	tail =
546 			Integer2FreeStorage (&PagerSyntax, tail, config->rows,
547 													 PAGER_ROWS_ID);
548 	/* columns */
549 	tail =
550 			Integer2FreeStorage (&PagerSyntax, tail, config->columns,
551 													 PAGER_COLUMNS_ID);
552 
553 	/* now storing PagerDecorations */
554 	{
555 		ConfigDef *DecorConfig =
556 				InitConfigWriter (myname, &PagerDecorationSyntax, CDT_Data, NULL);
557 		FreeStorageElem *DecorStorage = NULL, **d_tail = &DecorStorage;
558 
559 		/* flags */
560 		if (!(config->flags & ~USE_LABEL))
561 			d_tail =
562 					Flag2FreeStorage (&PagerDecorationSyntax, d_tail,
563 														PAGER_DECOR_NOLABEL_ID);
564 		if (!(config->flags & PAGE_SEPARATOR))
565 			d_tail =
566 					Flag2FreeStorage (&PagerDecorationSyntax, d_tail,
567 														PAGER_DECOR_NOSEPARATOR_ID);
568 		if (!(config->flags & SHOW_SELECTION))
569 			d_tail =
570 					Flag2FreeStorage (&PagerDecorationSyntax, d_tail,
571 														PAGER_DECOR_NOSELECTION_ID);
572 		if (config->flags & LABEL_BELOW_DESK)
573 			d_tail =
574 					Flag2FreeStorage (&PagerDecorationSyntax, d_tail,
575 														PAGER_DECOR_LABEL_BELOW_ID);
576 		if (config->flags & HIDE_INACTIVE_LABEL)
577 			d_tail =
578 					Flag2FreeStorage (&PagerDecorationSyntax, d_tail,
579 														PAGER_DECOR_HIDE_INACTIVE_ID);
580 
581 		/* selection_color */
582 		d_tail =
583 				String2FreeStorage (&PagerDecorationSyntax, d_tail,
584 														config->selection_color,
585 														PAGER_DECOR_SEL_COLOR_ID);
586 		/* border_width */
587 		d_tail =
588 				Integer2FreeStorage (&PagerDecorationSyntax, d_tail,
589 														 config->border_width,
590 														 PAGER_DECOR_BORDER_WIDTH_ID);
591 		/* grid_color */
592 		d_tail =
593 				String2FreeStorage (&PagerDecorationSyntax, d_tail,
594 														config->grid_color, PAGER_DECOR_GRID_COLOR_ID);
595 		/* border_color */
596 		d_tail =
597 				String2FreeStorage (&PagerDecorationSyntax, d_tail,
598 														config->border_color,
599 														PAGER_DECOR_BORDER_COLOR_ID);
600 
601 		WriteConfig (DecorConfig, DecorStorage, CDT_Data,
602 								 (void **)&Decorations, 0);
603 		DestroyFreeStorage (&DecorStorage);
604 		DestroyConfig (DecorConfig);
605 		if (DecorStorage)
606 			DestroyFreeStorage (&DecorStorage);
607 
608 		tail =
609 				String2FreeStorage (&PagerSyntax, tail, Decorations,
610 														PAGER_DECORATION_ID);
611 		if (Decorations) {
612 			free (Decorations);
613 			Decorations = NULL;
614 		}
615 	}
616 
617 	/* writing config into the file */
618 	WriteConfig (PagerConfigWriter, Storage, CDT_Filename,
619 							 (void **)&filename, flags);
620 	DestroyFreeStorage (&Storage);
621 	DestroyConfig (PagerConfigWriter);
622 
623 	if (Storage) {
624 		fprintf (stderr,
625 						 "\n%s:Config Writing warning: Not all Free Storage discarded! Trying again...",
626 						 myname);
627 		DestroyFreeStorage (&Storage);
628 		fprintf (stderr, (Storage != NULL) ? " failed." : " success.");
629 	}
630 	return 0;
631 }
632 #endif
633