Browse Source

Re-order macros, globals...

master
Arun Prakash Jana 7 years ago
parent
commit
512b7ac6cd
No known key found for this signature in database GPG Key ID: A75979F35C080412
1 changed files with 51 additions and 59 deletions
  1. +51
    -59
      nnn.c

+ 51
- 59
nnn.c View File

@@ -1,4 +1,22 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */

/*
* Visual layout:
* .---------
* | cwd: /mnt/path
* |
* | file0
* | file1
* | > file2
* | file3
* | file4
* ...
* | filen
* |
* | Permission denied
* '------
*/

#ifdef __linux__ #ifdef __linux__
#include <sys/inotify.h> #include <sys/inotify.h>
#define LINUX_INOTIFY #define LINUX_INOTIFY
@@ -150,10 +168,13 @@ disabledbg()
#define NUM_EVENT_FDS 1 #define NUM_EVENT_FDS 1
#endif #endif


/* TYPE DEFINITIONS */
typedef unsigned long ulong; typedef unsigned long ulong;
typedef unsigned int uint; typedef unsigned int uint;
typedef unsigned char uchar; typedef unsigned char uchar;


/* STRUCTURES */

/* Directory entry */ /* Directory entry */
typedef struct entry { typedef struct entry {
char name[NAME_MAX]; char name[NAME_MAX];
@@ -181,17 +202,8 @@ typedef struct {
uchar dircolor : 1; /* Current status of dir color */ uchar dircolor : 1; /* Current status of dir color */
} settings; } settings;


/* Externs */ /* GLOBALS */
#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 */
/* Configuration */ /* Configuration */
static settings cfg = {0, 0, 0, 0, 0, 1, 1, 0}; static settings cfg = {0, 0, 0, 0, 0, 1, 1, 0};


@@ -203,13 +215,12 @@ static char *player;
static char *copier; static char *copier;
static char *editor; static char *editor;
static char *desktop_manager; static char *desktop_manager;
static char *metaviewer;
static blkcnt_t ent_blocks; static blkcnt_t ent_blocks;
static blkcnt_t dir_blocks; static blkcnt_t dir_blocks;
static ulong num_files; static ulong num_files;
static uint open_max; static uint open_max;
static bm bookmark[BM_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; static uchar color = 4;


#ifdef LINUX_INOTIFY #ifdef LINUX_INOTIFY
@@ -234,40 +245,43 @@ static char * const utils[] = {
"exiftool" "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 */ /* Common message strings */
static char *STR_NFTWFAIL = "nftw(3) failed"; static char *STR_NFTWFAIL = "nftw(3) failed";
static char *STR_ATROOT = "You are at /"; static char *STR_ATROOT = "You are at /";
static char *STR_NOHOME = "HOME not set"; static char *STR_NOHOME = "HOME not set";


/* /* For use in functions which are isolated and don't return the buffer */
* Layout: static char g_buf[MAX_CMD_LEN];
* .---------
* | cwd: /mnt/path
* |
* | file0
* | file1
* | > file2
* | file3
* | file4
* ...
* | filen
* |
* | Permission denied
* '------
*/


/* Forward declarations */ /* Forward declarations */
static void printmsg(char *);
static void printerr(int, char *);
static void redraw(char *path); static void redraw(char *path);


/* Functions */ /* 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 */ /* Increase the limit on open file descriptors, if possible */
static rlim_t static rlim_t
max_openfds() max_openfds()
@@ -321,6 +335,7 @@ static size_t
xstrlcpy(char *dest, const char *src, size_t n) xstrlcpy(char *dest, const char *src, size_t n)
{ {
static size_t len, blocks; static size_t len, blocks;
static const uint _WSHIFT = (sizeof(ulong) == 8) ? 3 : 2;


if (!src || !dest) if (!src || !dest)
return 0; return 0;
@@ -768,30 +783,6 @@ entrycmp(const void *va, const void *vb)
return xstricmp(pa->name, pb->name); 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. * Returns SEL_* if key is bound and 0 otherwise.
* Also modifies the run and env pointers (used on SEL_{RUN,RUNARG}). * Also modifies the run and env pointers (used on SEL_{RUN,RUNARG}).
@@ -1242,6 +1233,7 @@ coolsize(off_t size)
static int i; static int i;
static off_t tmp; static off_t tmp;
static long double rem; static long double rem;
static const double div_2_pow_10 = 1.0 / 1024.0;


i = 0; i = 0;
rem = 0; rem = 0;


||||||
x
 
000:0
Loading…
Cancel
Save