summaryrefslogtreecommitdiffstats
path: root/src/dummies.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 09:44:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 09:44:07 +0000
commit39ce00b8d520cbecbd6af87257e8fb11df0ec273 (patch)
tree4c21a2674c19e5c44be3b3550b476b9e63d8ae3d /src/dummies.c
parentInitial commit. (diff)
downloadexim4-39ce00b8d520cbecbd6af87257e8fb11df0ec273.tar.xz
exim4-39ce00b8d520cbecbd6af87257e8fb11df0ec273.zip
Adding upstream version 4.94.2.upstream/4.94.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/dummies.c152
1 files changed, 152 insertions, 0 deletions
diff --git a/src/dummies.c b/src/dummies.c
new file mode 100644
index 0000000..197415f
--- /dev/null
+++ b/src/dummies.c
@@ -0,0 +1,152 @@
+/*************************************************
+* Exim - an Internet mail transport agent *
+*************************************************/
+
+/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* See the file NOTICE for conditions of use and distribution. */
+
+/* This file is not part of the main Exim code. There are little bits of test
+code for some of Exim's modules, and when they are used, the module they are
+testing may call other main Exim functions that are not available and/or
+should not be used in a test. The classic case is log_write(). This module
+contains dummy versions of such functions - well not really dummies, more like
+alternates. */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+/* We don't have the full Exim headers dragged in, but this function
+is used for debugging output. */
+
+extern gstring * string_vformat(gstring *, unsigned, const char *, va_list);
+
+
+/*************************************************
+* Handle calls to write the log *
+*************************************************/
+
+/* The message gets written to stderr when log_write() is called from a
+utility. The message always gets '\n' added on the end of it.
+
+Arguments:
+ selector not relevant when running a utility
+ flags not relevant when running a utility
+ format a printf() format
+ ... arguments for format
+
+Returns: nothing
+*/
+
+void
+log_write(unsigned int selector, int flags, char *format, ...)
+{
+va_list ap;
+va_start(ap, format);
+vfprintf(stderr, format, ap);
+fprintf(stderr, "\n");
+va_end(ap);
+selector = selector; /* Keep picky compilers happy */
+flags = flags;
+}
+
+
+/*************************************************
+* Handle calls to print debug output *
+*************************************************/
+
+/* The message just gets written to stderr.
+We use tainted memory to format into just so that we can handle
+tainted arguments.
+
+Arguments:
+ format a printf() format
+ ... arguments for format
+
+Returns: nothing
+*/
+
+void
+debug_printf(char *format, ...)
+{
+va_list ap;
+rmark reset_point = store_mark();
+gstring * g = string_get_tainted(1024, TRUE);
+
+va_start(ap, format);
+
+if (!string_vformat(g, 0, format, ap))
+ {
+ char * s = "**** debug string overflowed buffer ****\n";
+ char * p = CS g->s + g->ptr;
+ int maxlen = g->size - (int)strlen(s) - 3;
+ if (p > g->s + maxlen) p = g->s + maxlen;
+ if (p > g->s && p[-1] != '\n') *p++ = '\n';
+ strcpy(p, s);
+ }
+
+fprintf(stderr, "%s", string_from_gstring(g));
+fflush(stderr);
+store_reset(reset_point);
+va_end(ap);
+}
+
+
+
+/*************************************************
+* SIGALRM handler *
+*************************************************/
+
+extern int sigalrm_seen;
+
+void
+sigalrm_handler(int sig)
+{
+sig = sig; /* Keep picky compilers happy */
+sigalrm_seen = TRUE;
+}
+
+
+
+/*************************************************
+* Complete Dummies *
+*************************************************/
+
+int
+header_checkname(void *h, char *name, int len)
+{
+h = h; /* Keep picky compilers happy */
+name = name;
+len = len;
+return 0;
+}
+
+void
+directory_make(char *parent, char *name, int mode, int panic)
+{
+parent = parent; /* Keep picky compilers happy */
+name = name;
+mode = mode;
+panic = panic;
+}
+
+void
+host_build_sender_fullhost(void) { }
+
+/* This one isn't needed for test_host */
+
+#ifndef TEST_HOST
+char *
+host_ntoa(int type, const void *arg, char *buffer, int *portptr)
+{
+type = type; /* Keep picky compilers happy */
+arg = arg;
+buffer = buffer;
+portptr = portptr;
+return NULL;
+}
+#endif
+
+
+/* End of dummies.c */