ze-filter  (ze-filter-0.8.0-develop-180218)
ze-databases.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 : Mon Mar 19 16:54:09 CET 2007
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-databases.h>
29 
31 char *work_db_dir = NULL;
32 
33 void close_work_db_env();
34 
35 /* ****************************************************************************
36  * *
37  * *
38  **************************************************************************** */
39 bool
40 open_work_db_env(cfdir, defdir, rdonly)
41  char *cfdir;
42  char *defdir;
43  bool rdonly;
44 {
45  char *home = NULL;
46 
47  if (work_db_env != NULL) {
48  ZE_MessageInfo(9, "Work database environnement already initialized");
49  return TRUE;
50  }
51 
52  if (defdir != NULL)
53  home = defdir;
54  if (cfdir != NULL)
55  home = cfdir;
56 
57  work_db_env = zeDb_EnvOpen(home, rdonly, 60);
58 
59  if (work_db_env != NULL) {
60  (void) atexit(close_work_db_env);
61  work_db_dir = strdup(home);
62  if (work_db_dir == NULL)
63  ZE_LogSysError("Error strdup(%s)", home);
64  }
65 
66  return work_db_env != NULL;
67 }
68 
69 /* ****************************************************************************
70  * *
71  * *
72  **************************************************************************** */
73 void
75 {
76  if (work_db_env != NULL)
78 
79  work_db_env = NULL;
81 
82  return;
83 }
bool open_work_db_env(char *cfdir, char *defdir, bool rdonly)
Definition: ze-databases.c:40
char * work_db_dir
Definition: ze-databases.c:31
#define FREE(x)
Definition: macros.h:37
void close_work_db_env()
Definition: ze-databases.c:74
ZEDB_ENV_T * zeDb_EnvOpen(char *home, bool rdonly, int dt_chkpoint)
Definition: zeDb.c:243
bool zeDb_EnvClose(ZEDB_ENV_T *dbenv)
Definition: zeDb.c:416
#define ZE_MessageInfo(level,...)
Definition: zeSyslog.h:90
#define TRUE
Definition: macros.h:157
#define ZE_LogSysError(...)
Definition: zeSyslog.h:129
void ZEDB_ENV_T
Definition: zeDb.h:85
ZEDB_ENV_T * work_db_env
Definition: ze-databases.c:30