From 8069df82512455e7a1d2c7d48c55f1e6ed0220c8 Mon Sep 17 00:00:00 2001 From: Rolf Offermanns Date: Tue, 9 Jun 2020 10:01:00 +0200 Subject: Only define global variables once. Fixes #1. --- src/hashmap.h | 6 ++++-- src/whatfiles.c | 2 ++ src/whatfiles.h | 10 ++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/hashmap.h b/src/hashmap.h index 920ebcb..3c30548 100644 --- a/src/hashmap.h +++ b/src/hashmap.h @@ -39,9 +39,11 @@ HashError decrement(pid_t key, HashMap map); HashError set_name(pid_t key, char *name, HashMap map); HashError get_name(pid_t key, HashMap map, struct String *name); -struct { +typedef struct { int collisions; int steps; -} DebugStats; +} DebugStats_t; + +extern DebugStats_t DebugStats; #endif /* !HASHMAP_H */ diff --git a/src/whatfiles.c b/src/whatfiles.c index bc05408..ae8c3e1 100644 --- a/src/whatfiles.c +++ b/src/whatfiles.c @@ -15,6 +15,8 @@ FILE *Handle = (FILE*)NULL; int Debug = 0; +LastSyscall_t LastSyscall; +DebugStats_t DebugStats; // looks at the current syscall and outputs its information if it's one we're interested in void check_syscall(pid_t current_pid, struct user_regs_struct regs, HashMap map) diff --git a/src/whatfiles.h b/src/whatfiles.h index 0a83f06..681638c 100644 --- a/src/whatfiles.h +++ b/src/whatfiles.h @@ -7,8 +7,8 @@ #include "hashmap.h" -int Debug; -FILE *Handle; +extern int Debug; +extern FILE *Handle; #define MODE_LEN 32 #define OUTPUT(...) fprintf(Handle, __VA_ARGS__) @@ -23,10 +23,12 @@ FILE *Handle; exit(err); \ } -struct { +typedef struct { pid_t pid; unsigned long long syscall; -} LastSyscall; +} LastSyscall_t; + +extern LastSyscall_t LastSyscall; // utilities.c void build_output( -- cgit v1.2.3