diff --git a/src/calc.c b/src/calc.c index 08122acccee1554ccce9b04236b9d42cc8b2998f..a8c9dc615b6fc0c6cb0e732f523c0600b8e21986 100644 --- a/src/calc.c +++ b/src/calc.c @@ -28,6 +28,16 @@ #include "exclude.h" #include "util.h" +#include <string.h> +#include <stdlib.h> +#include <errno.h> + +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <dirent.h> + struct state_calc stcalc; @@ -276,7 +286,7 @@ void calc_draw_progress() { char ani[15]; int i; - nccreate(10, 60, dat == NULL ? "Calculating..." : "Recalculating..."); + nccreate(10, 60, stcalc.sterr == ST_QUIT ? "Calculating..." : "Recalculating..."); ncprint(2, 2, "Total items: %-8d size: %s", stcalc.parent->items, formatsize(stcalc.parent->size, sflags & SF_SI)); diff --git a/src/calc.h b/src/calc.h index 527dd67c8131fecbebc56700138bb03d7d7cae2f..187208f3483451c9aab9f097b1e15cdee76e8e04 100644 --- a/src/calc.h +++ b/src/calc.h @@ -26,6 +26,8 @@ #ifndef _calc_h #define _calc_h +#include "ncdu.h" + struct state_calc { char err; /* 1/0, error or not */ char cur[PATH_MAX]; /* current dir/item */ diff --git a/src/main.c b/src/main.c index bcddfa351f26fecae1af7dbe4b89cd36bb33130c..d82e6df0e799c36f39f6476397773f1dbe754bf5 100644 --- a/src/main.c +++ b/src/main.c @@ -26,9 +26,14 @@ #include "ncdu.h" #include "exclude.h" #include "util.h" +#include "calc.h" + +#include <stdlib.h> +#include <string.h> +#include <errno.h> + +#include <unistd.h> -/* check ncdu.h what these are for */ -struct dir *dat; int sflags, bflags, sdelay, bgraph; int pstate; @@ -129,8 +134,6 @@ void argv_parse(int argc, char **argv, char *dir) { /* main program */ int main(int argc, char **argv) { - dat = NULL; - argv_parse(argc, argv, stcalc.cur); pstate = ST_CALC; stcalc.sterr = ST_QUIT; diff --git a/src/ncdu.h b/src/ncdu.h index 382472943869bd1370c854d5ae856848a68524d9..eccc03a225805f532ab3833e3fe47985bcd63b1f 100644 --- a/src/ncdu.h +++ b/src/ncdu.h @@ -27,25 +27,8 @@ #define _ncdu_h #include "config.h" - #include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <ctype.h> -#include <limits.h> -#include <errno.h> - -#include <ncurses.h> -#include <form.h> - -#include <unistd.h> #include <sys/types.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <dirent.h> - -#include "calc.h" /* set S_BLKSIZE if not defined already in sys/stat.h */ #ifndef S_BLKSIZE @@ -85,10 +68,6 @@ #endif - -/* - * G L O B A L F L A G S - */ /* File Flags (struct dir -> flags) */ #define FF_DIR 0x01 #define FF_FILE 0x02 @@ -115,7 +94,7 @@ #define BF_AS 0x40 /* show apparent sizes instead of disk usage */ #define BF_INFO 0x80 /* show file information window */ -/* States */ +/* Program states */ #define ST_CALC 0 #define ST_BROWSE 1 #define ST_DEL 2 @@ -123,10 +102,7 @@ #define ST_QUIT 4 - -/* - * S T R U C T U R E S - */ +/* structure representing a file or directory */ struct dir { struct dir *parent, *next, *sub; char *name; @@ -135,33 +111,14 @@ struct dir { unsigned char flags; }; - - -/* - * G L O B A L V A R I A B L E S - * - * (all defined in main.c) - */ -/* main directory data */ -extern struct dir *dat; /* global settings */ extern int sflags, bflags, sdelay, bgraph; + /* program state */ extern int pstate; - -/* - * G L O B A L F U N C T I O N S - */ -/* main.c */ +/* handle input from keyboard and update display */ int input_handle(int); -/* browser.c */ -void drawBrowser(int); -void showBrowser(void); -/* help.c */ -void showHelp(void); -/* delete.c */ -struct dir *showDelete(struct dir *); #endif diff --git a/src/util.h b/src/util.h index f2b4c1ba3ff3bd8a2cb341197eca9b88d2cbdb65..b250007dfa1a69f3c2df86b63661fb1c5215a21e 100644 --- a/src/util.h +++ b/src/util.h @@ -27,6 +27,7 @@ #define _util_h #include "ncdu.h" +#include <ncurses.h> /* updated when window is resized */ extern int winrows, wincols;