]> arthur.barton.de Git - netatalk.git/blob - libatalk/cnid/cdb/cnid_cdb_close.c
big merge for db frontend and unicode.
[netatalk.git] / libatalk / cnid / cdb / cnid_cdb_close.c
1 /*
2  * $Id: cnid_cdb_close.c,v 1.1.4.1 2003-09-09 16:42:21 didg Exp $
3  */
4
5 #ifdef HAVE_CONFIG_H
6 #include "config.h"
7 #endif /* HAVE_CONFIG_H */
8
9 #ifdef CNID_BACKEND_CDB
10
11 #ifdef HAVE_UNISTD_H
12 #include <unistd.h>
13 #endif /* HAVE_UNISTD_H */
14 #ifdef HAVE_FCNTL_H
15 #include <fcntl.h>
16 #endif /* HAVE_FCNTL_H */
17 #include <stdlib.h>
18 #include <atalk/logger.h>
19 #include <db.h>
20 #include <errno.h>
21 #include <string.h>
22
23 #include "cnid_cdb_private.h"
24 #include "cnid_cdb.h"
25
26 void cnid_cdb_close(struct _cnid_db *cdb) {
27     CNID_private *db;
28
29     if (!cdb) {
30             LOG(log_error, logtype_afpd, "cnid_close called with NULL argument !");
31             return;
32     }
33
34     if (!(db = cdb->_private)) {
35         return;
36     }
37     db->db_didname->sync(db->db_didname, 0); 
38     db->db_devino->sync(db->db_devino, 0);
39     db->db_cnid->sync(db->db_cnid, 0);
40     
41     db->db_didname->close(db->db_didname, 0);
42     db->db_devino->close(db->db_devino, 0);
43     db->db_cnid->close(db->db_cnid, 0);
44
45     db->dbenv->close(db->dbenv, 0);
46
47     free(db);
48     free(cdb->volpath);
49     free(cdb);
50 }
51
52 #endif /* CNID_BACKEND_CDB */