summaryrefslogtreecommitdiff
path: root/src/libc-verbose.h
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-02-22 18:40:15 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-02-22 18:46:36 +0200
commitc4f2f8449ad09301e5725f69b7374d958cc5dff8 (patch)
tree084c8e916e09cd0cbd16bd6732b0fbff217fc81b /src/libc-verbose.h
parent952720c8def83d62bc0d328c2cc46ead8254703d (diff)
refactor commit
Diffstat (limited to 'src/libc-verbose.h')
-rw-r--r--src/libc-verbose.h117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/libc-verbose.h b/src/libc-verbose.h
new file mode 100644
index 0000000..bb03686
--- /dev/null
+++ b/src/libc-verbose.h
@@ -0,0 +1,117 @@
+#pragma once
+
+#include <stdarg.h>
+#include <string.h>
+
+/**
+ * This file implements functions only for verbose output, which is useful for debugging.
+ * These functions can be enabled with -DVERBOSE_FUNCTIONS
+ */
+
+int
+bionic_chdir(const char *path)
+{
+ verbose("%s", path);
+ return chdir(path);
+}
+
+int
+bionic_rename(const char *old, const char *fresh)
+{
+ verbose("%s -> %s", old, fresh);
+ return rename(old, fresh);
+}
+
+FILE*
+bionic_fopen(const char *path, const char *mode)
+{
+ verbose("%s %s", path, mode);
+ return fopen(path, mode);
+}
+
+DIR*
+bionic_opendir(const char *path)
+{
+ verbose("%s", path);
+ return opendir(path);
+}
+
+int
+bionic_sprintf(char *str, const char *fmt, ...)
+{
+ verbose("%s", fmt);
+ va_list ap;
+ va_start(ap, fmt);
+ int r = vsprintf(str, fmt, ap);
+ va_end(ap);
+ return r;
+}
+
+int
+bionic_snprintf(char *str, size_t size, const char *fmt, ...)
+{
+ verbose("%s (%zu)", fmt, size);
+ va_list ap;
+ va_start(ap, fmt);
+ int r = vsnprintf(str, size, fmt, ap);
+ va_end(ap);
+ return r;
+}
+
+size_t
+bionic_strlen(const char *str)
+{
+ verbose("%s", str);
+ return strlen(str);
+}
+
+char*
+bionic_strcpy(char *dest, const char *src)
+{
+ verbose("%s", src);
+ return strcpy(dest, src);
+}
+
+char*
+bionic_strncpy(char *dest, const char *src, size_t n)
+{
+ verbose("%s (%zu)", src, n);
+ return strncpy(dest, src, n);
+}
+
+extern char* strdup(const char*);
+
+char*
+bionic_strdup(const char *str)
+{
+ verbose("%s", str);
+ return strdup(str);
+}
+
+char*
+bionic_strstr(const char *haystack, const char *needle)
+{
+ verbose("%s, %s", haystack, needle);
+ return strstr(haystack, needle);
+}
+
+int
+bionic_strcmp(const char *s1, const char *s2)
+{
+ verbose("%s == %s", s1, s2);
+ return strcmp(s1, s2);
+}
+
+int
+bionic_strncmp(const char *s1, const char *s2, size_t n)
+{
+ verbose("%s == %s (%zu)", s1, s2, n);
+ return strncmp(s1, s2, n);
+}
+
+ssize_t
+bionic_readlink(const char *path, char *buf, size_t bufsize)
+{
+ verbose("%s", path);
+ return readlink(path, buf, bufsize);
+}