#define STR_NOHOME_ID 1
#define STR_INPUT_ID 2
#define STR_INVBM_KEY 3
-#define STR_COPY_ID 4
-#define STR_DATE_ID 5
-#define STR_UNSAFE 6
+#define STR_DATE_ID 4
+#define STR_UNSAFE 5
+#define STR_TMPFILE 6
static const char messages[][16] = {
"nftw failed",
"HOME not set",
"no traversal",
"invalid key",
- "copy not set",
"%F %T %z",
"unsafe cmd",
+ "/.nnnXXXXXX",
};
/* Forward declarations */
/* Writes buflen char(s) from buf to a file */
static void writecp(const char *buf, const size_t buflen)
{
+ static FILE *fp;
+
if (cfg.pickraw)
return;
- if (!g_cppath[0]) {
- printmsg(messages[STR_COPY_ID]);
+ if (!g_cppath[0])
return;
- }
- FILE *fp = fopen(g_cppath, "w");
+ fp = fopen(g_cppath, "w");
if (fp) {
fwrite(buf, 1, buflen, fp);
return FALSE;
if (g_tmpfpath[0])
- xstrlcpy(g_tmpfpath + g_tmpfplen - 1, "/.nnnXXXXXX", HOME_LEN_MAX - g_tmpfplen);
+ xstrlcpy(g_tmpfpath + g_tmpfplen - 1, messages[STR_TMPFILE], HOME_LEN_MAX - g_tmpfplen);
else {
printmsg(messages[STR_NOHOME_ID]);
return -1;
if (arg) {
if (r >= CMD_LEN_MAX - 4) { /* space for at least 4 chars - space'c' */
- printmsg(messages[6]);
+ printmsg(messages[STR_UNSAFE]);
return FALSE;
}
for (ptr = arg; *ptr; ++ptr)
if (*ptr == '\'') {
- printmsg(messages[6]);
+ printmsg(messages[STR_UNSAFE]);
return FALSE;
}
g_buf[r] = '\'';
r += xstrlcpy(g_buf + r + 1, arg, CMD_LEN_MAX - 1 - r);
if (r >= CMD_LEN_MAX - 1) {
- printmsg(messages[6]);
+ printmsg(messages[STR_UNSAFE]);
return FALSE;
}
char *p, *begin = g_buf;
if (g_tmpfpath[0])
- xstrlcpy(g_tmpfpath + g_tmpfplen - 1, "/.nnnXXXXXX", HOME_LEN_MAX - g_tmpfplen);
+ xstrlcpy(g_tmpfpath + g_tmpfplen - 1, messages[STR_TMPFILE], HOME_LEN_MAX - g_tmpfplen);
else {
printmsg(messages[STR_NOHOME_ID]);
return FALSE;
static bool show_help(char *path)
{
if (g_tmpfpath[0])
- xstrlcpy(g_tmpfpath + g_tmpfplen - 1, "/.nnnXXXXXX", HOME_LEN_MAX - g_tmpfplen);
+ xstrlcpy(g_tmpfpath + g_tmpfplen - 1, messages[STR_TMPFILE], HOME_LEN_MAX - g_tmpfplen);
else {
printmsg(messages[STR_NOHOME_ID]);
return FALSE;
}
mkpath(path, dents[cur].name, newpath, PATH_MAX);
+ DPRINTF_S(newpath);
spawn(newpath, NULL, NULL, path, F_NORMAL | F_SIGINT);
break;
case SEL_SHELL: