diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:00:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:00:48 +0000 |
commit | 851b6a097165af4d51c0db01b5e05256e5006896 (patch) | |
tree | 5f7c388ec894a7806c49a99f3bdb605d0b299a7c /test/interactive-helper/libnoprofile.c | |
parent | Initial commit. (diff) | |
download | apt-851b6a097165af4d51c0db01b5e05256e5006896.tar.xz apt-851b6a097165af4d51c0db01b5e05256e5006896.zip |
Adding upstream version 2.6.1.upstream/2.6.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/interactive-helper/libnoprofile.c')
-rw-r--r-- | test/interactive-helper/libnoprofile.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/interactive-helper/libnoprofile.c b/test/interactive-helper/libnoprofile.c new file mode 100644 index 0000000..b26ec2a --- /dev/null +++ b/test/interactive-helper/libnoprofile.c @@ -0,0 +1,45 @@ +#define _GNU_SOURCE +#undef _FORTIFY_SOURCE +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> +#include <dlfcn.h> +#include <unistd.h> +#include <stdio.h> + +int vprintf(const char *format, va_list ap) { + if (strncmp(format, "profiling:", strlen("profiling:")) == 0) + return 0; + + static int (*func_fprintf)(const char *format, va_list ap) = NULL; + if (func_fprintf == NULL) + func_fprintf = (int (*)(const char *format, va_list ap))dlsym(RTLD_NEXT, "vprintf"); + + return func_fprintf(format, ap); +} +int printf(const char *format, ...) { + va_list ap; + va_start(ap, format); + int res = vprintf(format, ap); + va_end(ap); + return res; +} + +int vfprintf(FILE *stream, const char *format, va_list ap) { + if (strncmp(format, "profiling:", strlen("profiling:")) == 0) + return 0; + + static int (*func_vfprintf)(FILE * stream, const char *format, va_list ap) = NULL; + if (func_vfprintf == NULL) + func_vfprintf = (int (*)(FILE * stream, const char *format, va_list ap))dlsym(RTLD_NEXT, "vfprintf"); + + return func_vfprintf(stream, format, ap); +} + +int fprintf(FILE *stream, const char *format, ...) { + va_list ap; + va_start(ap, format); + int res = vfprintf(stream, format, ap); + va_end(ap); + return res; +} |