diff --git a/cmd/ifctrstat-linux.c b/cmd/ifctrstat-linux.c index e7dcfa3..8203fc4 100644 --- a/cmd/ifctrstat-linux.c +++ b/cmd/ifctrstat-linux.c @@ -17,7 +17,8 @@ #include #include #include -#include "multicall.h" +#include "cmd/multicall.h" +#include "cmd/ifctrstat-linux.h" struct counter_desc { const char *name; @@ -41,7 +42,7 @@ counter_compare(const void *key, const void *candidate) return strcasecmp((const char *)key, ((struct counter_desc *)candidate)->name); } -char * +const char * read_counter(const char *interface, const char *counter) { FILE *fp; diff --git a/cmd/ifctrstat-linux.h b/cmd/ifctrstat-linux.h new file mode 100644 index 0000000..3510013 --- /dev/null +++ b/cmd/ifctrstat-linux.h @@ -0,0 +1,22 @@ +/* + * cmd/ifctrstat-linux.c + * Purpose: Implement ifctrstat system-specific routines for Linux + * + * Copyright (c) 2021 Maximilian Wilhelm + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * This software is provided 'as is' and without any warranty, express or + * implied. In no event shall the authors be liable for any damages arising + * from the use of this software. + */ + + +#ifndef IFUPDOWN_IFCTRSTAT_LINUX__H__GUARD +#define IFUPDOWN_IFCTRSTAT_LINUX__H__GUARD + +extern const char * read_counter(const char *interface, const char *counter); + +#endif diff --git a/cmd/ifctrstat.c b/cmd/ifctrstat.c index 89aff80..8b0482f 100644 --- a/cmd/ifctrstat.c +++ b/cmd/ifctrstat.c @@ -20,12 +20,11 @@ #include #include "libifupdown/libifupdown.h" #include "cmd/multicall.h" +#include "cmd/ifctrstat-linux.h" extern struct counter_desc { const char *name; const void *data; } avail_counters[]; extern int avail_counters_count; -extern const char *read_counter(const char *interface, const char *counter); - static bool show_label = true; static bool @@ -96,7 +95,7 @@ ifctrstat_set_nolabel(const char *opt_arg) show_label = false; } -int +static int ifctrstat_main(int argc, char *argv[]) { if (optind >= argc)