comparison src/filelist.c @ 276:4f526d436873

Implement secure rc file saving. First data is written to a temporary file, then if nothing was wrong, this file is renamed to the final name. This way the risk of corrupted rc file is greatly reduced. The code is borrowed from ELinks (http://elinks.cz).
author zas_
date Tue, 08 Apr 2008 21:55:58 +0000
parents 1f5aed61644b
children 9de0f88b2b91
comparison
equal deleted inserted replaced
275:dc69ea2dcf76 276:4f526d436873
362 } 362 }
363 363
364 return FALSE; 364 return FALSE;
365 } 365 }
366 366
367 void filter_write_list(FILE *f) 367 void filter_write_list(SecureSaveInfo *ssi)
368 { 368 {
369 GList *work; 369 GList *work;
370 370
371 work = filter_list; 371 work = filter_list;
372 while (work) 372 while (work)
375 work = work->next; 375 work = work->next;
376 376
377 gchar *extensions = escquote_value(fe->extensions); 377 gchar *extensions = escquote_value(fe->extensions);
378 gchar *description = escquote_value(fe->description); 378 gchar *description = escquote_value(fe->description);
379 379
380 fprintf(f, "filter_ext: \"%s%s\" %s %s\n", (fe->enabled) ? "" : "#", 380 secure_fprintf(ssi, "filter_ext: \"%s%s\" %s %s\n",
381 fe->key, extensions, description); 381 (fe->enabled) ? "" : "#",
382 fe->key, extensions, description);
382 g_free(extensions); 383 g_free(extensions);
383 g_free(description); 384 g_free(description);
384 } 385 }
385 } 386 }
386 387
488 sidecar_ext_list = filter_to_list(value); 489 sidecar_ext_list = filter_to_list(value);
489 490
490 g_free(value); 491 g_free(value);
491 } 492 }
492 493
493 void sidecar_ext_write(FILE *f) 494 void sidecar_ext_write(SecureSaveInfo *ssi)
494 { 495 {
495 fprintf(f, "\nsidecar_ext: \"%s\"\n", sidecar_ext_to_string()); 496 secure_fprintf(ssi, "\nsidecar_ext: \"%s\"\n", sidecar_ext_to_string());
496 } 497 }
497 498
498 char *sidecar_ext_to_string() 499 char *sidecar_ext_to_string()
499 { 500 {
500 GList *work; 501 GList *work;