Merge with git+ssh://pasky.or.cz/srv/git/elinks.git
[elinks.git] / src / util / secsave.h
blob65506dc0c7a3cceaeda58a9d4fc36a11d72fc185
1 /* Secure file saving handling */
3 #ifndef EL__UTIL_SECSAVE_H
4 #define EL__UTIL_SECSAVE_H
6 #include <stdio.h>
7 #include <sys/types.h> /* mode_t */
9 struct terminal;
11 enum secsave_errno {
12 SS_ERR_NONE = 0,
13 SS_ERR_DISABLED, /* secsave is disabled. */
14 SS_ERR_OUT_OF_MEM, /* memory allocation failure */
16 /* see err field in struct secure_save_info */
17 SS_ERR_OPEN_READ,
18 SS_ERR_OPEN_WRITE,
19 SS_ERR_STAT,
20 SS_ERR_ACCESS,
21 SS_ERR_MKSTEMP,
22 SS_ERR_RENAME,
23 SS_ERR_OTHER,
26 extern enum secsave_errno secsave_errno; /* internal secsave error number */
28 struct secure_save_info {
29 FILE *fp; /* file stream pointer */
30 unsigned char *file_name; /* final file name */
31 unsigned char *tmp_file_name; /* temporary file name */
32 int err; /* set to non-zero value in case of error */
33 int secure_save; /* use secure save for this file */
36 struct secure_save_info *secure_open(unsigned char *);
38 int secure_close(struct secure_save_info *);
40 int secure_fputs(struct secure_save_info *, const char *);
41 int secure_fputc(struct secure_save_info *, int);
43 int secure_fprintf(struct secure_save_info *, const char *, ...);
45 unsigned char *secsave_strerror(enum secsave_errno, struct terminal *);
47 #endif