ze-filter  (ze-filter-0.8.0-develop-180218)
ze-read-conf-data.c
Go to the documentation of this file.
1 
2 /*
3  *
4  * ze-filter - Mail Server Filter for sendmail
5  *
6  * Copyright (c) 2001-2018 - Jose-Marcio Martins da Cruz
7  *
8  * Auteur : Jose Marcio Martins da Cruz
9  * jose.marcio.mc@gmail.org
10  *
11  * Historique :
12  * Creation : Tue May 23 13:43:08 CEST 2006
13  *
14  * This program is free software, but with restricted license :
15  *
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * More details about ze-filter license can be found at ze-filter
22  * web site : http://foss.jose-marcio.org
23  */
24 
25 
26 #include <ze-sys.h>
27 #include <ze-filter.h>
28 #include <ze-read-conf-data.h>
29 
30 
31 bool
32 read_conf_data_file(cfdir, fname, dfile, func)
33  char *cfdir;
34  char *fname;
35  char *dfile;
37 {
38  char path[1024];
39 
40  int i;
41  int argc;
42  char *argv[32];
43  char fbuf[1024];
44 
45  bool result = TRUE;
46 
47  ASSERT(func != NULL);
48 
49  if (cfdir == NULL || strlen(cfdir) == 0)
50  cfdir = ZE_CONFDIR;
51  memset(fbuf, 0, sizeof (fbuf));
52  if (fname != NULL)
53  strlcpy(fbuf, fname, sizeof (fbuf));
54  argc = zeStr2Tokens(fbuf, 32, argv, " ,");
55 
56  result = TRUE;
57  for (i = 0; i < argc && result; i++) {
58  char *tag;
59 
60  tag = strchr(argv[i], ':');
61  if (tag != NULL)
62  *tag++ = '\0';
63  ADJUST_FILENAME(path, argv[i], cfdir, dfile);
64  ZE_MessageInfo(11, " * Loading file path=(%s) tag=(%s)",
65  path, STRNULL(tag, "(null)"));
66 
67  result = func(path, tag);
68  if (!result)
69  break;
70  }
71 
72  return result && i > 0;
73 }
#define ASSERT(a)
Definition: macros.h:27
bool(* read_conf_data_file_F)(char *, char *)
#define STRNULL(x, r)
Definition: macros.h:81
#define strlcpy
Definition: zeString.h:32
#define ADJUST_FILENAME(path, fname, cfdir, defval)
Definition: macros.h:236
int zeStr2Tokens(char *, int, char **, char *)
Definition: zeStrings.c:610
bool read_conf_data_file(char *cfdir, char *fname, char *dfile, read_conf_data_file_F func)
#define strchr
Definition: ze-sys.h:218
#define ZE_MessageInfo(level,...)
Definition: zeSyslog.h:90
#define TRUE
Definition: macros.h:157
#define ZE_CONFDIR
Definition: defs.h:36