return 0;
}
+
+FILE *generic_proc_open(const char *env, const char *name)
+{
+ const char *p = getenv(env);
+ char store[128];
+
+ if (!p) {
+ p = getenv("PROC_ROOT") ? : "/proc";
+ snprintf(store, sizeof(store) - 1, "%s/%s", p, name);
+ p = store;
+ }
+
+ return fopen(p, "r");
+}
char info_source[128];
int source_mismatch;
-static int generic_proc_open(const char *env, const char *name)
-{
- char store[128];
- char *p = getenv(env);
-
- if (!p) {
- p = getenv("PROC_ROOT") ? : "/proc";
- snprintf(store, sizeof(store)-1, "%s/%s", p, name);
- p = store;
- }
- return open(p, O_RDONLY);
-}
-
-static int net_netstat_open(void)
+static FILE *net_netstat_open(void)
{
return generic_proc_open("PROC_NET_NETSTAT", "net/netstat");
}
-static int net_snmp_open(void)
+static FILE *net_snmp_open(void)
{
return generic_proc_open("PROC_NET_SNMP", "net/snmp");
}
-static int net_snmp6_open(void)
+static FILE *net_snmp6_open(void)
{
return generic_proc_open("PROC_NET_SNMP6", "net/snmp6");
}
-static int net_sctp_snmp_open(void)
+static FILE *net_sctp_snmp_open(void)
{
return generic_proc_open("PROC_NET_SCTP_SNMP", "net/sctp/snmp");
}
static void load_sctp_snmp(void)
{
- FILE *fp = fdopen(net_sctp_snmp_open(), "r");
+ FILE *fp = net_sctp_snmp_open();
if (fp) {
load_good_table(fp);
static void load_snmp(void)
{
- FILE *fp = fdopen(net_snmp_open(), "r");
+ FILE *fp = net_snmp_open();
if (fp) {
load_ugly_table(fp);
static void load_snmp6(void)
{
- FILE *fp = fdopen(net_snmp6_open(), "r");
+ FILE *fp = net_snmp6_open();
if (fp) {
load_good_table(fp);
static void load_netstat(void)
{
- FILE *fp = fdopen(net_netstat_open(), "r");
+ FILE *fp = net_netstat_open();
if (fp) {
load_ugly_table(fp);
}
}
-static FILE *generic_proc_open(const char *env, const char *name)
-{
- const char *p = getenv(env);
- char store[128];
-
- if (!p) {
- p = getenv("PROC_ROOT") ? : "/proc";
- snprintf(store, sizeof(store)-1, "%s/%s", p, name);
- p = store;
- }
-
- return fopen(p, "r");
-}
#define net_tcp_open() generic_proc_open("PROC_NET_TCP", "net/tcp")
#define net_tcp6_open() generic_proc_open("PROC_NET_TCP6", "net/tcp6")
#define net_udp_open() generic_proc_open("PROC_NET_UDP", "net/udp")