|
@@ -136,6 +136,10 @@ |
|
|
#define SCROLLOFF 5 |
|
|
#define SCROLLOFF 5 |
|
|
#define LONG_SIZE sizeof(ulong) |
|
|
#define LONG_SIZE sizeof(ulong) |
|
|
|
|
|
|
|
|
|
|
|
/* Program return codes */ |
|
|
|
|
|
#define _SUCCESS 0 |
|
|
|
|
|
#define _FAILURE !_SUCCESS |
|
|
|
|
|
|
|
|
/* Entry flags */ |
|
|
/* Entry flags */ |
|
|
#define DIR_OR_LINK_TO_DIR 0x1 |
|
|
#define DIR_OR_LINK_TO_DIR 0x1 |
|
|
#define FILE_COPIED 0x10 |
|
|
#define FILE_COPIED 0x10 |
|
@@ -4487,7 +4491,7 @@ int main(int argc, char *argv[]) |
|
|
|
|
|
|
|
|
if (fd == -1) { |
|
|
if (fd == -1) { |
|
|
xerror(); |
|
|
xerror(); |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
close(fd); |
|
|
close(fd); |
|
@@ -4501,16 +4505,16 @@ int main(int argc, char *argv[]) |
|
|
break; |
|
|
break; |
|
|
case 'v': |
|
|
case 'v': |
|
|
fprintf(stdout, "%s\n", VERSION); |
|
|
fprintf(stdout, "%s\n", VERSION); |
|
|
return 0; |
|
|
|
|
|
|
|
|
return _SUCCESS; |
|
|
case 'w': |
|
|
case 'w': |
|
|
cfg.wild = 1; |
|
|
cfg.wild = 1; |
|
|
break; |
|
|
break; |
|
|
case 'h': |
|
|
case 'h': |
|
|
usage(); |
|
|
usage(); |
|
|
return 0; |
|
|
|
|
|
|
|
|
return _SUCCESS; |
|
|
default: |
|
|
default: |
|
|
usage(); |
|
|
usage(); |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -4525,7 +4529,7 @@ int main(int argc, char *argv[]) |
|
|
if (*copier) { |
|
|
if (*copier) { |
|
|
if (*copier < '0' || *copier > '7') { |
|
|
if (*copier < '0' || *copier > '7') { |
|
|
fprintf(stderr, "0 <= code <= 7\n"); |
|
|
fprintf(stderr, "0 <= code <= 7\n"); |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
g_ctx[opt].color = *copier - '0'; |
|
|
g_ctx[opt].color = *copier - '0'; |
|
@@ -4545,12 +4549,12 @@ int main(int argc, char *argv[]) |
|
|
home = getenv("HOME"); |
|
|
home = getenv("HOME"); |
|
|
if (!home) { |
|
|
if (!home) { |
|
|
fprintf(stderr, "set HOME\n"); |
|
|
fprintf(stderr, "set HOME\n"); |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
} |
|
|
} |
|
|
DPRINTF_S(home); |
|
|
DPRINTF_S(home); |
|
|
|
|
|
|
|
|
if (!setup_config()) |
|
|
if (!setup_config()) |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
|
|
|
|
|
|
/* Get custom opener, if set */ |
|
|
/* Get custom opener, if set */ |
|
|
opener = xgetenv(env_cfg[NNN_OPENER], utils[OPENER]); |
|
|
opener = xgetenv(env_cfg[NNN_OPENER], utils[OPENER]); |
|
@@ -4559,13 +4563,13 @@ int main(int argc, char *argv[]) |
|
|
/* Parse bookmarks string */ |
|
|
/* Parse bookmarks string */ |
|
|
if (!parsebmstr()) { |
|
|
if (!parsebmstr()) { |
|
|
fprintf(stderr, "%s\n", env_cfg[NNN_BMS]); |
|
|
fprintf(stderr, "%s\n", env_cfg[NNN_BMS]); |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (arg) { /* Open a bookmark directly */ |
|
|
if (arg) { /* Open a bookmark directly */ |
|
|
if (arg[1] || (initpath = get_bm_loc(NULL, *arg)) == NULL) { |
|
|
if (arg[1] || (initpath = get_bm_loc(NULL, *arg)) == NULL) { |
|
|
fprintf(stderr, "%s\n", messages[STR_INVBM_KEY]); |
|
|
fprintf(stderr, "%s\n", messages[STR_INVBM_KEY]); |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
} |
|
|
} |
|
|
} else if (argc == optind) { |
|
|
} else if (argc == optind) { |
|
|
/* Start in the current directory */ |
|
|
/* Start in the current directory */ |
|
@@ -4581,7 +4585,7 @@ int main(int argc, char *argv[]) |
|
|
DPRINTF_S(initpath); |
|
|
DPRINTF_S(initpath); |
|
|
if (!initpath) { |
|
|
if (!initpath) { |
|
|
xerror(); |
|
|
xerror(); |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
@@ -4593,12 +4597,12 @@ int main(int argc, char *argv[]) |
|
|
|
|
|
|
|
|
if (stat(initpath, &sb) == -1) { |
|
|
if (stat(initpath, &sb) == -1) { |
|
|
xerror(); |
|
|
xerror(); |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (S_ISREG(sb.st_mode)) { |
|
|
if (S_ISREG(sb.st_mode)) { |
|
|
execlp(opener, opener, arg, NULL); |
|
|
execlp(opener, opener, arg, NULL); |
|
|
return 0; |
|
|
|
|
|
|
|
|
return _SUCCESS; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -4627,13 +4631,13 @@ int main(int argc, char *argv[]) |
|
|
inotify_fd = inotify_init1(IN_NONBLOCK); |
|
|
inotify_fd = inotify_init1(IN_NONBLOCK); |
|
|
if (inotify_fd < 0) { |
|
|
if (inotify_fd < 0) { |
|
|
xerror(); |
|
|
xerror(); |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
} |
|
|
} |
|
|
#elif defined(BSD_KQUEUE) |
|
|
#elif defined(BSD_KQUEUE) |
|
|
kq = kqueue(); |
|
|
kq = kqueue(); |
|
|
if (kq < 0) { |
|
|
if (kq < 0) { |
|
|
xerror(); |
|
|
xerror(); |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@@ -4650,7 +4654,7 @@ int main(int argc, char *argv[]) |
|
|
|
|
|
|
|
|
/* Prefix for temporary files */ |
|
|
/* Prefix for temporary files */ |
|
|
if (!set_tmp_path()) |
|
|
if (!set_tmp_path()) |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
|
|
|
|
|
|
/* Get the clipboard copier, if set */ |
|
|
/* Get the clipboard copier, if set */ |
|
|
copier = getenv(env_cfg[NNN_COPIER]); |
|
|
copier = getenv(env_cfg[NNN_COPIER]); |
|
@@ -4678,14 +4682,14 @@ int main(int argc, char *argv[]) |
|
|
|
|
|
|
|
|
if (sigaction(SIGINT, &act, NULL) < 0) { |
|
|
if (sigaction(SIGINT, &act, NULL) < 0) { |
|
|
xerror(); |
|
|
xerror(); |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
} |
|
|
} |
|
|
signal(SIGQUIT, SIG_IGN); |
|
|
signal(SIGQUIT, SIG_IGN); |
|
|
|
|
|
|
|
|
/* Test initial path */ |
|
|
/* Test initial path */ |
|
|
if (!xdiraccess(initpath)) { |
|
|
if (!xdiraccess(initpath)) { |
|
|
xerror(); |
|
|
xerror(); |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* Set locale */ |
|
|
/* Set locale */ |
|
@@ -4703,7 +4707,7 @@ int main(int argc, char *argv[]) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
if (!initcurses()) |
|
|
if (!initcurses()) |
|
|
return 1; |
|
|
|
|
|
|
|
|
return _FAILURE; |
|
|
|
|
|
|
|
|
browse(initpath); |
|
|
browse(initpath); |
|
|
exitcurses(); |
|
|
exitcurses(); |
|
@@ -4738,5 +4742,5 @@ int main(int argc, char *argv[]) |
|
|
close(kq); |
|
|
close(kq); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
return _SUCCESS; |
|
|
} |
|
|
} |