summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheron Spiegl <tspiegl@gmail.com>2020-06-09 18:47:50 -0500
committerGitHub <noreply@github.com>2020-06-09 18:47:50 -0500
commitefc171b69f7abf0ad42e58e67af41f945bf38c26 (patch)
tree5b595acf75bf1fe7ef0cd89dbf66daaf919e7ca4
parentf3a4c0dc10086d49a5d5878439d8f922887f13f6 (diff)
parent8069df82512455e7a1d2c7d48c55f1e6ed0220c8 (diff)
Merge pull request #2 from zapp42/fix-multiple-definition
Only define global variables once. Fixes #1.
-rw-r--r--src/hashmap.h6
-rw-r--r--src/whatfiles.c2
-rw-r--r--src/whatfiles.h10
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(