diff --git a/src/config/dialogs.c b/src/config/dialogs.c index 49a7837d3..e06e4a54f 100644 --- a/src/config/dialogs.c +++ b/src/config/dialogs.c @@ -60,37 +60,7 @@ write_config_dialog(struct terminal *term, unsigned char *config_file, return; } - switch (secsave_error) { - case SS_ERR_OPEN_READ: - strerr = _("Cannot read the file", term); - break; - case SS_ERR_STAT: - strerr = _("Cannot get file status", term); - break; - case SS_ERR_ACCESS: - strerr = _("Cannot access the file", term); - break; - case SS_ERR_MKSTEMP: - strerr = _("Cannot create temp file", term); - break; - case SS_ERR_RENAME: - strerr = _("Cannot rename the file", term); - break; - case SS_ERR_DISABLED: - strerr = _("File saving disabled by option", term); - break; - case SS_ERR_OUT_OF_MEM: - strerr = _("Out of memory", term); - break; - case SS_ERR_OPEN_WRITE: - strerr = _("Cannot write the file", term); - break; - case SS_ERR_NONE: /* Impossible. */ - case SS_ERR_OTHER: - default: - strerr = _("Secure file saving error", term); - break; - } + strerr = secsave_strerror(secsave_error, term); if (stdio_error > 0) errmsg = straconcat(strerr, " (", strerror(stdio_error), ")", NULL); diff --git a/src/util/secsave.c b/src/util/secsave.c index 10ffd3263..6e9d76660 100644 --- a/src/util/secsave.c +++ b/src/util/secsave.c @@ -18,6 +18,7 @@ #include "elinks.h" #include "config/options.h" +#include "intl/gettext/libintl.h" #include "osdep/osdep.h" /* Needed for mkstemp() on win32 */ #include "util/memory.h" #include "util/secsave.h" @@ -350,3 +351,30 @@ secure_fprintf(struct secure_save_info *ssi, const char *format, ...) return ret; } + +unsigned char * +secsave_strerror(enum secsave_errno secsave_error, struct terminal *term) +{ + switch (secsave_error) { + case SS_ERR_OPEN_READ: + return _("Cannot read the file", term); + case SS_ERR_STAT: + return _("Cannot get file status", term); + case SS_ERR_ACCESS: + return _("Cannot access the file", term); + case SS_ERR_MKSTEMP: + return _("Cannot create temp file", term); + case SS_ERR_RENAME: + return _("Cannot rename the file", term); + case SS_ERR_DISABLED: + return _("File saving disabled by option", term); + case SS_ERR_OUT_OF_MEM: + return _("Out of memory", term); + case SS_ERR_OPEN_WRITE: + return _("Cannot write the file", term); + case SS_ERR_NONE: /* Impossible. */ + case SS_ERR_OTHER: + default: + return _("Secure file saving error", term); + } +} diff --git a/src/util/secsave.h b/src/util/secsave.h index 001c14605..65506dc0c 100644 --- a/src/util/secsave.h +++ b/src/util/secsave.h @@ -6,6 +6,8 @@ #include #include /* mode_t */ +struct terminal; + enum secsave_errno { SS_ERR_NONE = 0, SS_ERR_DISABLED, /* secsave is disabled. */ @@ -40,4 +42,6 @@ int secure_fputc(struct secure_save_info *, int); int secure_fprintf(struct secure_save_info *, const char *, ...); +unsigned char *secsave_strerror(enum secsave_errno, struct terminal *); + #endif