summaryrefslogtreecommitdiff
path: root/test/src/loaded.c
blob: 2527384276a9c679dd89b3580cfc98ed7f8b0526 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* $Cambridge: exim/test/src/loaded.c,v 1.1 2006/02/06 16:24:05 ph10 Exp $ */

/* This is a test function for dynamic loading in Exim expansions. It uses the
number of arguments to control the result. */

/* These lines are taken from local_scan.h in the Exim source: */

/* ========================================================================== */
/* Return codes from the support functions lss_match_xxx(). These are also the
codes that dynamically-loaded ${dlfunc functions must return. */

#define  OK            0          /* Successful match */
#define  DEFER         1          /* Defer - some problem */
#define  FAIL          2          /* Matching failed */
#define  ERROR         3          /* Internal or config error */

/* Extra return code for ${dlfunc functions */

#define  FAIL_FORCED   4          /* "Forced" failure */
/* ========================================================================== */


int dltest(unsigned char **yield, int argc, unsigned char *argv[])
{
switch (argc)
  {
  case 0:
  return ERROR;

  case 1:
  *yield = argv[0];
  return OK;

  case 2:
  *yield = (unsigned char *)"yield FAIL_FORCED";
  return FAIL_FORCED;

  default:
  *yield = (unsigned char *)"yield FAIL";
  return FAIL;
  }
}