From 290c7a7d709a155e8932d46cbb5c230b5867b2a4 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sun, 26 Apr 2009 11:08:40 +0200 Subject: Renamed ncdu.h to global.h and #included all other header files into that So we're actually back to having one header file for everything, except it's now maintainable. --- src/Makefile.am | 2 +- src/browser.c | 11 ++----- src/browser.h | 2 +- src/calc.c | 7 +---- src/calc.h | 2 +- src/delete.c | 5 +-- src/delete.h | 2 +- src/global.h | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/help.c | 5 +-- src/help.h | 2 +- src/main.c | 9 +----- src/ncdu.h | 87 --------------------------------------------------- src/util.h | 2 +- 13 files changed, 108 insertions(+), 124 deletions(-) create mode 100644 src/global.h delete mode 100644 src/ncdu.h diff --git a/src/Makefile.am b/src/Makefile.am index 0a3764a..bf6a746 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,4 +2,4 @@ bin_PROGRAMS = ncdu ncdu_SOURCES = browser.c calc.c delete.c exclude.c help.c main.c path.c util.c -noinst_HEADERS = browser.h calc.h delete.h exclude.h help.h ncdu.h path.h util.h +noinst_HEADERS = browser.h calc.h delete.h exclude.h global.h help.h path.h util.h diff --git a/src/browser.c b/src/browser.c index abe84f8..3961cfa 100644 --- a/src/browser.c +++ b/src/browser.c @@ -23,12 +23,7 @@ */ -#include "ncdu.h" -#include "browser.h" -#include "util.h" -#include "calc.h" -#include "delete.h" -#include "help.h" +#include "global.h" #include #include @@ -418,14 +413,12 @@ int browse_key(int ch) { nonfo++; break; - /* refresh */ + /* and other stuff */ case 'r': if(browse_dir != NULL) calc_init(getpath(browse_dir->parent), browse_dir->parent); nonfo++; break; - - /* and other stuff */ case 'q': if(flags & BF_INFO) nonfo++; diff --git a/src/browser.h b/src/browser.h index f823947..c7fe1f5 100644 --- a/src/browser.h +++ b/src/browser.h @@ -26,7 +26,7 @@ #ifndef _browser_h #define _browser_h -#include "ncdu.h" +#include "global.h" int browse_key(int); void browse_draw(void); diff --git a/src/calc.c b/src/calc.c index df8a38f..33db219 100644 --- a/src/calc.c +++ b/src/calc.c @@ -23,12 +23,7 @@ */ -#include "ncdu.h" -#include "calc.h" -#include "exclude.h" -#include "util.h" -#include "browser.h" -#include "path.h" +#include "global.h" #include #include diff --git a/src/calc.h b/src/calc.h index da75060..e2f11ad 100644 --- a/src/calc.h +++ b/src/calc.h @@ -26,7 +26,7 @@ #ifndef _calc_h #define _calc_h -#include "ncdu.h" +#include "global.h" extern char calc_smfs; /* stay on the same filesystem */ diff --git a/src/delete.c b/src/delete.c index 5e54d53..ee95e54 100644 --- a/src/delete.c +++ b/src/delete.c @@ -24,10 +24,7 @@ */ -#include "ncdu.h" -#include "util.h" -#include "browser.h" -#include "path.h" +#include "global.h" #include #include diff --git a/src/delete.h b/src/delete.h index 55991b7..afcb733 100644 --- a/src/delete.h +++ b/src/delete.h @@ -26,7 +26,7 @@ #ifndef _delete_h #define _delete_h -#include "ncdu.h" +#include "global.h" void delete_process(void); int delete_key(int); diff --git a/src/global.h b/src/global.h new file mode 100644 index 0000000..4ccbcdf --- /dev/null +++ b/src/global.h @@ -0,0 +1,96 @@ +/* ncdu - NCurses Disk Usage + + Copyright (c) 2007-2009 Yoran Heling + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef _global_h +#define _global_h + +#include "config.h" +#include +#include +#include + +/* PATH_MAX 260 on Cygwin is too small for /proc/registry */ +#ifdef __CYGWIN__ +# if PATH_MAX < 1024 +# undef PATH_MAX +# define PATH_MAX 1024 +# endif +#endif + +/* get PATH_MAX */ +#ifndef PATH_MAX +# ifdef _POSIX_PATH_MAX +# define PATH_MAX _POSIX_PATH_MAX +# else +# define PATH_MAX 4096 +# endif +#endif + + +/* File Flags (struct dir -> flags) */ +#define FF_DIR 0x01 +#define FF_FILE 0x02 +#define FF_ERR 0x04 /* error while reading this item */ +#define FF_OTHFS 0x08 /* excluded because it was an other filesystem */ +#define FF_EXL 0x10 /* excluded using exlude patterns */ +#define FF_SERR 0x20 /* error in subdirectory */ +#define FF_BSEL 0x40 /* selected */ + +/* Program states */ +#define ST_CALC 0 +#define ST_BROWSE 1 +#define ST_DEL 2 +#define ST_HELP 3 +#define ST_QUIT 4 + + +/* structure representing a file or directory */ +struct dir { + struct dir *parent, *next, *sub; + char *name; + off_t size, asize; + unsigned long items; + unsigned char flags; +}; + +/* program state */ +extern int pstate; +/* minimum screen update interval when calculating, in ms */ +extern long update_delay; + +/* handle input from keyboard and update display */ +int input_handle(int); + + +/* import all other global functions and variables */ +#include "exclude.h" +#include "util.h" +#include "calc.h" +#include "delete.h" +#include "browser.h" +#include "help.h" +#include "path.h" + +#endif diff --git a/src/help.c b/src/help.c index 79d5bb7..01e9fa2 100644 --- a/src/help.c +++ b/src/help.c @@ -23,10 +23,7 @@ */ -#include "ncdu.h" -#include "help.h" -#include "browser.h" -#include "util.h" +#include "global.h" #include #include diff --git a/src/help.h b/src/help.h index 96d8c8e..091560d 100644 --- a/src/help.h +++ b/src/help.h @@ -26,7 +26,7 @@ #ifndef _help_h #define _help_h -#include "ncdu.h" +#include "global.h" int help_key(int); void help_draw(void); diff --git a/src/main.c b/src/main.c index b13b55d..a31dfbe 100644 --- a/src/main.c +++ b/src/main.c @@ -23,14 +23,7 @@ */ -#include "ncdu.h" -#include "exclude.h" -#include "util.h" -#include "calc.h" -#include "delete.h" -#include "browser.h" -#include "help.h" -#include "path.h" +#include "global.h" #include #include diff --git a/src/ncdu.h b/src/ncdu.h deleted file mode 100644 index 26a5095..0000000 --- a/src/ncdu.h +++ /dev/null @@ -1,87 +0,0 @@ -/* ncdu - NCurses Disk Usage - - Copyright (c) 2007-2009 Yoran Heling - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -*/ - -#ifndef _ncdu_h -#define _ncdu_h - -#include "config.h" -#include -#include -#include - -/* PATH_MAX 260 on Cygwin is too small for /proc/registry */ -#ifdef __CYGWIN__ -# if PATH_MAX < 1024 -# undef PATH_MAX -# define PATH_MAX 1024 -# endif -#endif - -/* get PATH_MAX */ -#ifndef PATH_MAX -# ifdef _POSIX_PATH_MAX -# define PATH_MAX _POSIX_PATH_MAX -# else -# define PATH_MAX 4096 -# endif -#endif - - -/* File Flags (struct dir -> flags) */ -#define FF_DIR 0x01 -#define FF_FILE 0x02 -#define FF_ERR 0x04 /* error while reading this item */ -#define FF_OTHFS 0x08 /* excluded because it was an other filesystem */ -#define FF_EXL 0x10 /* excluded using exlude patterns */ -#define FF_SERR 0x20 /* error in subdirectory */ -#define FF_BSEL 0x40 /* selected */ - -/* Program states */ -#define ST_CALC 0 -#define ST_BROWSE 1 -#define ST_DEL 2 -#define ST_HELP 3 -#define ST_QUIT 4 - - -/* structure representing a file or directory */ -struct dir { - struct dir *parent, *next, *sub; - char *name; - off_t size, asize; - unsigned long items; - unsigned char flags; -}; - -/* program state */ -extern int pstate; -/* minimum screen update interval when calculating, in ms */ -extern long update_delay; - -/* handle input from keyboard and update display */ -int input_handle(int); - - -#endif diff --git a/src/util.h b/src/util.h index 265f6fb..e83c25e 100644 --- a/src/util.h +++ b/src/util.h @@ -26,7 +26,7 @@ #ifndef _util_h #define _util_h -#include "ncdu.h" +#include "global.h" #include /* updated when window is resized */ -- cgit v1.2.3