aboutsummaryrefslogtreecommitdiffstats
path: root/nnn.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-08-24 20:48:01 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-08-24 21:39:16 +0530
commit512b7ac6cd066fc8396ad70b652230249ab87b7d (patch)
tree28b67e7b98fcdb4d1bb0dede420366322719e490 /nnn.c
parentf31978573efcbf5179bb55947f58be0efac7b718 (diff)
downloadnnn-512b7ac6cd066fc8396ad70b652230249ab87b7d.tar.gz
Re-order macros, globals...
Diffstat (limited to 'nnn.c')
-rw-r--r--nnn.c110
1 files changed, 51 insertions, 59 deletions
diff --git a/nnn.c b/nnn.c
index 84008fa..d2d4096 100644
--- a/nnn.c
+++ b/nnn.c
@@ -1,4 +1,22 @@
/* See LICENSE file for copyright and license details. */
+
+/*
+ * Visual layout:
+ * .---------
+ * | cwd: /mnt/path
+ * |
+ * | file0
+ * | file1
+ * | > file2
+ * | file3
+ * | file4
+ * ...
+ * | filen
+ * |
+ * | Permission denied
+ * '------
+ */
+
#ifdef __linux__
#include <sys/inotify.h>
#define LINUX_INOTIFY
@@ -150,10 +168,13 @@ disabledbg()
#define NUM_EVENT_FDS 1
#endif
+/* TYPE DEFINITIONS */
typedef unsigned long ulong;
typedef unsigned int uint;
typedef unsigned char uchar;
+/* STRUCTURES */
+
/* Directory entry */
typedef struct entry {
char name[NAME_MAX];
@@ -181,17 +202,8 @@ typedef struct {
uchar dircolor : 1; /* Current status of dir color */
} settings;
-/* Externs */
-#if 0
-#ifdef __APPLE__
-extern int add_history(const char *string);
-#else
-extern void add_history(const char *string);
-#endif
-extern int wget_wch(WINDOW *win, wint_t *wch);
-#endif
+/* GLOBALS */
-/* Globals */
/* Configuration */
static settings cfg = {0, 0, 0, 0, 0, 1, 1, 0};
@@ -203,13 +215,12 @@ static char *player;
static char *copier;
static char *editor;
static char *desktop_manager;
+static char *metaviewer;
static blkcnt_t ent_blocks;
static blkcnt_t dir_blocks;
static ulong num_files;
static uint open_max;
static bm bookmark[BM_MAX];
-static const double div_2_pow_10 = 1.0 / 1024.0;
-static uint _WSHIFT = (sizeof(ulong) == 8) ? 3 : 2;
static uchar color = 4;
#ifdef LINUX_INOTIFY
@@ -234,40 +245,43 @@ static char * const utils[] = {
"exiftool"
};
-static char *metaviewer;
-
-/* For use in functions which are isolated and don't return the buffer */
-static char g_buf[MAX_CMD_LEN];
-
/* Common message strings */
static char *STR_NFTWFAIL = "nftw(3) failed";
static char *STR_ATROOT = "You are at /";
static char *STR_NOHOME = "HOME not set";
-/*
- * Layout:
- * .---------
- * | cwd: /mnt/path
- * |
- * | file0
- * | file1
- * | > file2
- * | file3
- * | file4
- * ...
- * | filen
- * |
- * | Permission denied
- * '------
- */
+/* For use in functions which are isolated and don't return the buffer */
+static char g_buf[MAX_CMD_LEN];
/* Forward declarations */
-static void printmsg(char *);
-static void printerr(int, char *);
static void redraw(char *path);
/* Functions */
+/* Messages show up at the bottom */
+static void
+printmsg(char *msg)
+{
+ mvprintw(LINES - 1, 0, "%s\n", msg);
+}
+
+/* Kill curses and display error before exiting */
+static void
+printerr(int ret, char *prefix)
+{
+ exitcurses();
+ fprintf(stderr, "%s: %s\n", prefix, strerror(errno));
+ exit(ret);
+}
+
+/* Print prompt on the last line */
+static void
+printprompt(char *str)
+{
+ clearprompt();
+ printw(str);
+}
+
/* Increase the limit on open file descriptors, if possible */
static rlim_t
max_openfds()
@@ -321,6 +335,7 @@ static size_t
xstrlcpy(char *dest, const char *src, size_t n)
{
static size_t len, blocks;
+ static const uint _WSHIFT = (sizeof(ulong) == 8) ? 3 : 2;
if (!src || !dest)
return 0;
@@ -768,30 +783,6 @@ entrycmp(const void *va, const void *vb)
return xstricmp(pa->name, pb->name);
}
-/* Messages show up at the bottom */
-static void
-printmsg(char *msg)
-{
- mvprintw(LINES - 1, 0, "%s\n", msg);
-}
-
-/* Kill curses and display error before exiting */
-static void
-printerr(int ret, char *prefix)
-{
- exitcurses();
- fprintf(stderr, "%s: %s\n", prefix, strerror(errno));
- exit(ret);
-}
-
-/* Print prompt on the last line */
-static void
-printprompt(char *str)
-{
- clearprompt();
- printw(str);
-}
-
/*
* Returns SEL_* if key is bound and 0 otherwise.
* Also modifies the run and env pointers (used on SEL_{RUN,RUNARG}).
@@ -1242,6 +1233,7 @@ coolsize(off_t size)
static int i;
static off_t tmp;
static long double rem;
+ static const double div_2_pow_10 = 1.0 / 1024.0;
i = 0;
rem = 0;