Fix DSN Final-Recipient: field
[exim.git] / src / src / dummies.c
CommitLineData
059ec3d9
PH
1/*************************************************
2* Exim - an Internet mail transport agent *
3*************************************************/
4
0a49a7a4 5/* Copyright (c) University of Cambridge 1995 - 2009 */
059ec3d9
PH
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
d12746bc 23extern gstring * string_vformat(gstring *, BOOL, const char *, va_list);
059ec3d9
PH
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
60
61Arguments:
62 format a printf() format
63 ... arguments for format
64
65Returns: nothing
66*/
67
68void
69debug_printf(char *format, ...)
70{
71va_list ap;
d12746bc
JH
72gstring * g = string_get(1024);
73void * reset_point = g;
059ec3d9
PH
74
75va_start(ap, format);
76
d12746bc 77if (!string_vformat(g, FALSE, format, ap))
059ec3d9 78 {
d12746bc
JH
79 char * s = "**** debug string overflowed buffer ****\n";
80 char * p = CS g->s + g->ptr;
81 int maxlen = g->size - (int)strlen(s) - 3;
82 if (p > g->s + maxlen) p = g->s + maxlen;
83 if (p > g->s && p[-1] != '\n') *p++ = '\n';
059ec3d9
PH
84 strcpy(p, s);
85 }
86
d12746bc 87fprintf(stderr, "%s", string_from_gstring(g));
059ec3d9 88fflush(stderr);
d12746bc 89store_reset(reset_point);
059ec3d9
PH
90va_end(ap);
91}
92
93
94
95/*************************************************
96* SIGALRM handler *
97*************************************************/
98
99extern int sigalrm_seen;
100
101void
102sigalrm_handler(int sig)
103{
104sig = sig; /* Keep picky compilers happy */
c2a1bba0 105sigalrm_seen = TRUE;
059ec3d9
PH
106}
107
108
109
110/*************************************************
111* Complete Dummies *
112*************************************************/
113
114int
115header_checkname(void *h, char *name, int len)
116{
117h = h; /* Keep picky compilers happy */
118name = name;
119len = len;
120return 0;
121}
122
123void
124directory_make(char *parent, char *name, int mode, int panic)
125{
126parent = parent; /* Keep picky compilers happy */
127name = name;
128mode = mode;
129panic = panic;
130}
131
132void
133host_build_sender_fullhost(void) { }
134
135/* This one isn't needed for test_host */
136
137#ifndef TEST_HOST
138char *
139host_ntoa(int type, const void *arg, char *buffer, int *portptr)
140{
141type = type; /* Keep picky compilers happy */
142arg = arg;
143buffer = buffer;
144portptr = portptr;
145return NULL;
146}
147#endif
148
149
150/* End of dummies.c */