mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
Bug 887: New function secsave_strerror.
Extracted from write_config_dialog.
This commit is contained in:
parent
3cd0fbe5f0
commit
47a2fc19e1
@ -60,37 +60,7 @@ write_config_dialog(struct terminal *term, unsigned char *config_file,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (secsave_error) {
|
strerr = secsave_strerror(secsave_error, term);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stdio_error > 0)
|
if (stdio_error > 0)
|
||||||
errmsg = straconcat(strerr, " (", strerror(stdio_error), ")", NULL);
|
errmsg = straconcat(strerr, " (", strerror(stdio_error), ")", NULL);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "elinks.h"
|
#include "elinks.h"
|
||||||
|
|
||||||
#include "config/options.h"
|
#include "config/options.h"
|
||||||
|
#include "intl/gettext/libintl.h"
|
||||||
#include "osdep/osdep.h" /* Needed for mkstemp() on win32 */
|
#include "osdep/osdep.h" /* Needed for mkstemp() on win32 */
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
#include "util/secsave.h"
|
#include "util/secsave.h"
|
||||||
@ -350,3 +351,30 @@ secure_fprintf(struct secure_save_info *ssi, const char *format, ...)
|
|||||||
|
|
||||||
return ret;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h> /* mode_t */
|
#include <sys/types.h> /* mode_t */
|
||||||
|
|
||||||
|
struct terminal;
|
||||||
|
|
||||||
enum secsave_errno {
|
enum secsave_errno {
|
||||||
SS_ERR_NONE = 0,
|
SS_ERR_NONE = 0,
|
||||||
SS_ERR_DISABLED, /* secsave is disabled. */
|
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 *, ...);
|
int secure_fprintf(struct secure_save_info *, const char *, ...);
|
||||||
|
|
||||||
|
unsigned char *secsave_strerror(enum secsave_errno, struct terminal *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user