aboutsummaryrefslogtreecommitdiff
path: root/reloc.h
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2019-11-07 23:34:06 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2019-11-08 08:41:29 -0500
commitc4c62db41d3aa70ae0c99b53d3d697285a7f0e18 (patch)
treebb34ebf1bfc8d5501652e6584146bd6d177c0e21 /reloc.h
downloadreloc-c4c62db41d3aa70ae0c99b53d3d697285a7f0e18.tar.gz
Initial commit
Diffstat (limited to 'reloc.h')
-rw-r--r--reloc.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/reloc.h b/reloc.h
new file mode 100644
index 0000000..bebd8bb
--- /dev/null
+++ b/reloc.h
@@ -0,0 +1,47 @@
+//
+// Created by jhunk on 11/7/2019.
+//
+
+#ifndef RELOC_RELOC_H
+#define RELOC_RELOC_H
+
+#define _GNU_SOURCE 1
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(_WIN32) || defined(_WIN64)
+#define DIRSEP '\\'
+#elif defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined(__MACH__)
+#define DIRSEP '/'
+#endif
+
+
+typedef struct {
+ size_t size;
+ char *path;
+ char *data;
+} RelocData;
+
+
+typedef struct {
+ char *begin;
+ char *end;
+ char *post;
+ size_t length;
+ size_t post_length;
+ size_t total_length;
+} RelocMatch;
+
+
+RelocMatch *reloc_match(char *haystack, const char *needle);
+char *reloc_find_null(char *s);
+RelocData *reloc_read(const char *filename);
+size_t reloc_write(RelocData *finfo, const char *filename);
+void reloc_deinit_data(RelocData *finfo);
+void reloc_replace(RelocMatch *match, const char *rstr);
+
+
+#endif //RELOC_RELOC_H