Update copyright year in (most) files (those that my script finds).
[exim.git] / src / src / dummies.c
CommitLineData
d7d7b7b9 1/* $Cambridge: exim/src/src/dummies.c,v 1.3 2006/02/07 11:19:00 ph10 Exp $ */
059ec3d9
PH
2
3/*************************************************
4* Exim - an Internet mail transport agent *
5*************************************************/
6
d7d7b7b9 7/* Copyright (c) University of Cambridge 1995 - 2006 */
059ec3d9
PH
8/* See the file NOTICE for conditions of use and distribution. */
9
10/* This file is not part of the main Exim code. There are little bits of test
11code for some of Exim's modules, and when they are used, the module they are
12testing may call other main Exim functions that are not available and/or
13should not be used in a test. The classic case is log_write(). This module
14contains dummy versions of such functions - well not really dummies, more like
15alternates. */
16
17#include <stdarg.h>
18#include <stdio.h>
19#include <errno.h>
20#include <string.h>
21
22/* We don't have the full Exim headers dragged in, but this function
23is used for debugging output. */
24
25extern int string_vformat(char *, int, char *, va_list);
26
27
28/*************************************************
29* Handle calls to write the log *
30*************************************************/
31
32/* The message gets written to stderr when log_write() is called from a
33utility. The message always gets '\n' added on the end of it.
34
35Arguments:
36 selector not relevant when running a utility
37 flags not relevant when running a utility
38 format a printf() format
39 ... arguments for format
40
41Returns: nothing
42*/
43
44void
45log_write(unsigned int selector, int flags, char *format, ...)
46{
47va_list ap;
48va_start(ap, format);
49vfprintf(stderr, format, ap);
50fprintf(stderr, "\n");
51va_end(ap);
52selector = selector; /* Keep picky compilers happy */
53flags = flags;
54}
55
56
57/*************************************************
58* Handle calls to print debug output *
59*************************************************/
60
61/* The message just gets written to stderr
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;
74char buffer[1024];
75
76va_start(ap, format);
77
78if (!string_vformat(buffer, sizeof(buffer), format, ap))
79 {
80 char *s = "**** debug string overflowed buffer ****\n";
81 char *p = buffer + (int)strlen(buffer);
82 int maxlen = sizeof(buffer) - (int)strlen(s) - 3;
83 if (p > buffer + maxlen) p = buffer + maxlen;
84 if (p > buffer && p[-1] != '\n') *p++ = '\n';
85 strcpy(p, s);
86 }
87
88fprintf(stderr, "%s", buffer);
89fflush(stderr);
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 */
105sigalrm_seen = 1;
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 */