redirect router: taint-enforce filenames
[exim.git] / src / src / dummies.c
... / ...
CommitLineData
1/*************************************************
2* Exim - an Internet mail transport agent *
3*************************************************/
4
5/* Copyright (c) University of Cambridge 1995 - 2009 */
6/* See the file NOTICE for conditions of use and distribution. */
7
8/* This file is not part of the main Exim code. There are little bits of test
9code for some of Exim's modules, and when they are used, the module they are
10testing may call other main Exim functions that are not available and/or
11should not be used in a test. The classic case is log_write(). This module
12contains dummy versions of such functions - well not really dummies, more like
13alternates. */
14
15#include <stdarg.h>
16#include <stdio.h>
17#include <errno.h>
18#include <string.h>
19
20/* We don't have the full Exim headers dragged in, but this function
21is used for debugging output. */
22
23extern gstring * string_vformat(gstring *, unsigned, const char *, va_list);
24
25
26/*************************************************
27* Handle calls to write the log *
28*************************************************/
29
30/* The message gets written to stderr when log_write() is called from a
31utility. The message always gets '\n' added on the end of it.
32
33Arguments:
34 selector not relevant when running a utility
35 flags not relevant when running a utility
36 format a printf() format
37 ... arguments for format
38
39Returns: nothing
40*/
41
42void
43log_write(unsigned int selector, int flags, char *format, ...)
44{
45va_list ap;
46va_start(ap, format);
47vfprintf(stderr, format, ap);
48fprintf(stderr, "\n");
49va_end(ap);
50selector = selector; /* Keep picky compilers happy */
51flags = flags;
52}
53
54
55/*************************************************
56* Handle calls to print debug output *
57*************************************************/
58
59/* The message just gets written to stderr.
60We use tainted memory to format into just so that we can handle
61tainted arguments.
62
63Arguments:
64 format a printf() format
65 ... arguments for format
66
67Returns: nothing
68*/
69
70void
71debug_printf(char *format, ...)
72{
73va_list ap;
74rmark reset_point = store_mark();
75gstring * g = string_get_tainted(1024, TRUE);
76
77va_start(ap, format);
78
79if (!string_vformat(g, 0, format, ap))
80 {
81 char * s = "**** debug string overflowed buffer ****\n";
82 char * p = CS g->s + g->ptr;
83 int maxlen = g->size - (int)strlen(s) - 3;
84 if (p > g->s + maxlen) p = g->s + maxlen;
85 if (p > g->s && p[-1] != '\n') *p++ = '\n';
86 strcpy(p, s);
87 }
88
89fprintf(stderr, "%s", string_from_gstring(g));
90fflush(stderr);
91store_reset(reset_point);
92va_end(ap);
93}
94
95
96
97/*************************************************
98* SIGALRM handler *
99*************************************************/
100
101extern int sigalrm_seen;
102
103void
104sigalrm_handler(int sig)
105{
106sig = sig; /* Keep picky compilers happy */
107sigalrm_seen = TRUE;
108}
109
110
111
112/*************************************************
113* Complete Dummies *
114*************************************************/
115
116int
117header_checkname(void *h, char *name, int len)
118{
119h = h; /* Keep picky compilers happy */
120name = name;
121len = len;
122return 0;
123}
124
125void
126directory_make(char *parent, char *name, int mode, int panic)
127{
128parent = parent; /* Keep picky compilers happy */
129name = name;
130mode = mode;
131panic = panic;
132}
133
134void
135host_build_sender_fullhost(void) { }
136
137/* This one isn't needed for test_host */
138
139#ifndef TEST_HOST
140char *
141host_ntoa(int type, const void *arg, char *buffer, int *portptr)
142{
143type = type; /* Keep picky compilers happy */
144arg = arg;
145buffer = buffer;
146portptr = portptr;
147return NULL;
148}
149#endif
150
151
152/* End of dummies.c */