-/* $Cambridge: exim/test/src/mtpscript.c,v 1.1 2006/02/06 16:24:05 ph10 Exp $ */
-
/* A little hacked up program that allows a script to play the part of a remote
SMTP/LMTP server on stdin/stdout for testing purposes. Hacked from the more
complicated version that does it over a socket. */
#include <errno.h>
#include <unistd.h>
+#ifndef CS
+# define CS (char *)
+#endif
+
static FILE *log;
/* Read the script, and do what it says. */
-while (fgets(sbuffer, sizeof(sbuffer), script) != NULL)
+while (fgets(CS sbuffer, sizeof(sbuffer), script) != NULL)
{
- int n = (int)strlen(sbuffer);
+ int n = (int)strlen(CS sbuffer);
while (n > 0 && isspace(sbuffer[n-1])) n--;
sbuffer[n] = 0;
before continuing. Do not write this to the log, as it may not get
written at the right place in a log that's being shared. */
- else if (strncmp(sbuffer, "*sleep ", 7) == 0)
+ else if (strncmp(CS sbuffer, "*sleep ", 7) == 0)
{
- sleep(atoi(sbuffer+7));
+ sleep(atoi(CS sbuffer+7));
}
/* Otherwise the script line is the start of an input line we are expecting
else
{
- int data = strcmp(sbuffer, ".") == 0;
+ int data = strcmp(CS sbuffer, ".") == 0;
fprintf(log, "%s\n", sbuffer);
fflush(log);
{
int n;
alarm(5);
- if (fgets(ibuffer, sizeof(ibuffer), stdin) == NULL)
+ if (fgets(CS ibuffer, sizeof(ibuffer), stdin) == NULL)
{
fprintf(log, "%sxpected EOF read from client\n",
- (strncmp(sbuffer, "*eof", 4) == 0)? "E" : "Une");
+ (strncmp(CS sbuffer, "*eof", 4) == 0)? "E" : "Une");
goto END_OFF;
}
alarm(0);
- n = (int)strlen(ibuffer);
+ n = (int)strlen(CS ibuffer);
while (n > 0 && isspace(ibuffer[n-1])) n--;
ibuffer[n] = 0;
fprintf(log, "<<< %s\n", ibuffer);
- if (!data || strcmp(ibuffer, ".") == 0) break;
+ if (!data || strcmp(CS ibuffer, ".") == 0) break;
}
/* Check received what was expected */
- if (strncmp(sbuffer, ibuffer, (int)strlen(sbuffer)) != 0)
+ if (strncmp(CS sbuffer, CS ibuffer, (int)strlen(CS sbuffer)) != 0)
{
fprintf(log, "Comparison failed - bailing out\n");
goto END_OFF;