Mercurial > geeqie
diff src/typedefs.h @ 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 | e0e2c2b72c5a |
children | e213fb025621 |
line wrap: on
line diff
--- a/src/typedefs.h Tue Apr 08 21:52:04 2008 +0000 +++ b/src/typedefs.h Tue Apr 08 21:55:58 2008 +0000 @@ -96,6 +96,21 @@ FILE_FORMAT_CLASSES } FileFormatClass; +typedef enum { + SS_ERR_NONE = 0, + SS_ERR_DISABLED, /**< secsave is disabled. */ + SS_ERR_OUT_OF_MEM, /**< memory allocation failure */ + + /* see err field in SecureSaveInfo */ + SS_ERR_OPEN_READ, + SS_ERR_OPEN_WRITE, + SS_ERR_STAT, + SS_ERR_ACCESS, + SS_ERR_MKSTEMP, + SS_ERR_RENAME, + SS_ERR_OTHER, +} SecureSaveErrno; + #define MAX_SPLIT_IMAGES 4 @@ -124,6 +139,7 @@ typedef struct _PixmapFolders PixmapFolders; typedef struct _Histogram Histogram; +typedef struct _SecureSaveInfo SecureSaveInfo; struct _ImageLoader @@ -706,6 +722,14 @@ GdkPixbuf *parent; }; +struct _SecureSaveInfo { + FILE *fp; /**< file stream pointer */ + gchar *file_name; /**< final file name */ + gchar *tmp_file_name; /**< temporary file name */ + gint err; /**< set to non-zero value in case of error */ + gint secure_save; /**< use secure save for this file */ +}; + #endif