Also move their declarations (from iptraf-ng-compat.h) to utils.h.
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/Makefile.am | 1 -
src/iptraf-ng-compat.h | 4 ---
src/iptraf.c | 2 +-
src/itrafmon.c | 1 +
src/usage.c | 56 ------------------------------------------------
src/utils.c | 38 ++++++++++++++++++++++++++++++++
src/utils.h | 3 ++
7 files changed, 43 insertions(+), 62 deletions(-)
delete mode 100644 src/usage.c
diff --git a/src/Makefile.am b/src/Makefile.am
index e57689f..d4fe7d2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -87,7 +87,6 @@ LIB_C += isdntab.c
LIB_C += options.c
LIB_C += promisc.c
LIB_C += ifaces.c
-LIB_C += usage.c
LIB_C += iptraf.c
LIB_C += itrafmon.c
LIB_C += utils.c
diff --git a/src/iptraf-ng-compat.h b/src/iptraf-ng-compat.h
index 71f54f8..71d326c 100644
--- a/src/iptraf-ng-compat.h
+++ b/src/iptraf-ng-compat.h
@@ -88,8 +88,4 @@
#define __noreturn __attribute__((noreturn))
#define __unused __attribute__((unused))
-extern void die(const char *err, ...);
-extern void die_errno(const char *err) __noreturn;
-extern void error(const char *err, ...);
-
#endif /* IPTRAF_NG_COMPAT_H */
diff --git a/src/iptraf.c b/src/iptraf.c
index 48636c6..05702c8 100644
--- a/src/iptraf.c
+++ b/src/iptraf.c
@@ -37,8 +37,8 @@ details.
#include "attrs.h"
#include "rvnamed.h"
#include "logvars.h"
-
#include "parse-options.h"
+#include "utils.h"
#include "../config.h"
diff --git a/src/itrafmon.c b/src/itrafmon.c
index 82fc1f0..4c81cc8 100644
--- a/src/itrafmon.c
+++ b/src/itrafmon.c
@@ -39,6 +39,7 @@ details.
#include "instances.h"
#include "logvars.h"
#include "bar.h"
+#include "utils.h"
#define SCROLLUP 0
#define SCROLLDOWN 1
diff --git a/src/usage.c b/src/usage.c
deleted file mode 100644
index 5618e4c..0000000
--- a/src/usage.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- Copyright (C) 2010 Nikola Pajkovsky (npajkovs(a)redhat.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-#include "iptraf-ng-compat.h"
-
-static void vreportf(const char *prefix, const char *err, va_list params)
-{
- char msg[4096];
-
- vsnprintf(msg, sizeof(msg), err, params);
- fprintf(stderr, "%s%s\n", prefix, msg);
-}
-
-static __noreturn void die_buildin(const char *err, va_list params)
-{
- vreportf("fatal: ", err, params);
- exit(129);
-}
-
-static void error_buildin(const char *err, va_list params)
-{
- vreportf("error: ", err, params);
-}
-
-void die(const char *err, ...)
-{
- va_list params;
-
- va_start(params, err);
- die_buildin(err, params);
- va_end(params);
-}
-
-void error(const char *err, ...)
-{
- va_list params;
-
- va_start(params, err);
- error_buildin(err, params);
- va_end(params);
-}
diff --git a/src/utils.c b/src/utils.c
index 1eed876..8584a8a 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -19,6 +19,43 @@
#define _GNU_SOURCE
#include "iptraf-ng-compat.h"
+static void vreportf(const char *prefix, const char *err, va_list params)
+{
+ char msg[4096];
+
+ vsnprintf(msg, sizeof(msg), err, params);
+ fprintf(stderr, "%s%s\n", prefix, msg);
+}
+
+static __noreturn void die_buildin(const char *err, va_list params)
+{
+ vreportf("fatal: ", err, params);
+ exit(129);
+}
+
+static void error_buildin(const char *err, va_list params)
+{
+ vreportf("error: ", err, params);
+}
+
+void die(const char *err, ...)
+{
+ va_list params;
+
+ va_start(params, err);
+ die_buildin(err, params);
+ va_end(params);
+}
+
+void error(const char *err, ...)
+{
+ va_list params;
+
+ va_start(params, err);
+ error_buildin(err, params);
+ va_end(params);
+}
+
// Die if we can't allocate size bytes of memory.
void *xmalloc(size_t size)
{
@@ -90,3 +127,4 @@ char *skip_whitespace(char *str)
return ptr;
}
+
diff --git a/src/utils.h b/src/utils.h
index 96f1363..17053e0 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -11,4 +11,7 @@ void *xmallocz(size_t size);
char *xstrdup(const char *s);
char *skip_whitespace(char *str);
+void die(const char *err, ...);
+void error(const char *err, ...);
+
#endif /* IPTRAF_NG_UTILS_H */
--
1.7.8.4