1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Bug 887: New function secsave_strerror.

Extracted from write_config_dialog.
This commit is contained in:
Kalle Olavi Niemitalo 2006-12-09 18:14:28 +02:00 committed by Kalle Olavi Niemitalo
parent 3cd0fbe5f0
commit 47a2fc19e1
3 changed files with 33 additions and 31 deletions

View File

@ -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);

View File

@ -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);
}
}

View File

@ -6,6 +6,8 @@
#include <stdio.h>
#include <sys/types.h> /* 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