summaryrefslogtreecommitdiff
path: root/lib/intercept/intercept.h
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2006-12-03 10:29:01 +0000
committerChris Wilson <chris+github@qwirx.com>2006-12-03 10:29:01 +0000
commit4008ada60d5fdf946a8c5e5aa03ea0f01172335d (patch)
tree05f2a239747cf45595ba456eb848917ea93ca553 /lib/intercept/intercept.h
parent7400293edc37751f109afc8a5516108b61474374 (diff)
Added a header file for including in test/bbackupd/testbbackupd.cpp and
other modules which might need intercepts in future. Added opendir/readdir and lstat hook capability. (refs #3, refs #9)
Diffstat (limited to 'lib/intercept/intercept.h')
-rw-r--r--lib/intercept/intercept.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/intercept/intercept.h b/lib/intercept/intercept.h
new file mode 100644
index 00000000..b1122434
--- /dev/null
+++ b/lib/intercept/intercept.h
@@ -0,0 +1,42 @@
+// --------------------------------------------------------------------------
+//
+// File
+// Name: intercept.h
+// Purpose: Syscall interception code for unit tests
+// Created: 2006/11/29
+//
+// --------------------------------------------------------------------------
+
+#ifndef INTERCEPT_H
+#define INTERCEPT_H
+
+#include <dirent.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+extern "C"
+{
+ typedef DIR *(opendir_t) (const char *name);
+ typedef struct dirent *(readdir_t) (DIR *dir);
+ typedef struct dirent *(readdir_t) (DIR *dir);
+ typedef int (closedir_t)(DIR *dir);
+#if defined __GNUC__ && __GNUC__ >= 2
+#define LINUX_WEIRD_LSTAT
+#define STAT_STRUCT struct stat /* should be stat64 */
+ typedef int (lstat_t) (int ver, const char *file_name,
+ STAT_STRUCT *buf);
+#else
+#define STAT_STRUCT struct stat
+ typedef int (lstat_t) (const char *file_name,
+ STAT_STRUCT *buf);
+#endif
+}
+
+void intercept_setup_error(const char *filename, unsigned int errorafter,
+ int errortoreturn, int syscalltoerror);
+
+void intercept_setup_readdir_hook(const char *dirname, readdir_t hookfn);
+void intercept_setup_lstat_hook (const char *filename, lstat_t hookfn);
+
+#endif // !INTERCEPT_H