diff options
Diffstat (limited to '')
-rw-r--r-- | lib/utils.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/utils.c b/lib/utils.c index 6c1c1a8..deb7654 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -2003,3 +2003,17 @@ int proto_a2n(unsigned short *id, const char *buf, 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"); +} |