#include "citadel.h"
#include "server.h"
#include "proto.h"
+#include "database.h"
/*
* Reclaim unused space in the databases. We need to do each one of
* these discretely, rather than in a loop.
*/
-void defrag_databases() {
+void defrag_databases(void) {
/* defrag the message base */
begin_critical_section(S_MSGMAIN);
gdbm_reorganize(gdbms[CDB_MSGMAIN]);
end_critical_section(S_MSGMAIN);
- /* defrag the user file */
+ /* defrag the user file and mailboxes */
begin_critical_section(S_USERSUPP);
gdbm_reorganize(gdbms[CDB_USERSUPP]);
+ gdbm_reorganize(gdbms[CDB_MAILBOXES]);
end_critical_section(S_USERSUPP);
- /* defrag the room files */
+ /* defrag the room files and message lists */
begin_critical_section(S_QUICKROOM);
gdbm_reorganize(gdbms[CDB_QUICKROOM]);
- gdbm_reorganize(gdbms[CDB_FULLROOM]);
+ gdbm_reorganize(gdbms[CDB_MSGLISTS]);
end_critical_section(S_QUICKROOM);
/* defrag the floor table */
* Open the various gdbm databases we'll be using. Any database which
* does not exist should be created.
*/
-void open_databases() {
+void open_databases(void) {
int a;
gdbms[CDB_MSGMAIN] = gdbm_open("msgmain.gdbm", 8192,
- GDBM_WRCREAT, 0700, NULL);
+ GDBM_WRCREAT, 0600, NULL);
if (gdbms[CDB_MSGMAIN] == NULL) {
lprintf(2, "Cannot open msgmain: %s\n",
gdbm_strerror(gdbm_errno));
}
gdbms[CDB_USERSUPP] = gdbm_open("usersupp.gdbm", 0,
- GDBM_WRCREAT, 0700, NULL);
+ GDBM_WRCREAT, 0600, NULL);
if (gdbms[CDB_USERSUPP] == NULL) {
lprintf(2, "Cannot open usersupp: %s\n",
gdbm_strerror(gdbm_errno));
}
gdbms[CDB_QUICKROOM] = gdbm_open("quickroom.gdbm", 0,
- GDBM_WRCREAT, 0700, NULL);
+ GDBM_WRCREAT, 0600, NULL);
if (gdbms[CDB_QUICKROOM] == NULL) {
lprintf(2, "Cannot open quickroom: %s\n",
gdbm_strerror(gdbm_errno));
}
- gdbms[CDB_FULLROOM] = gdbm_open("fullroom.gdbm", 0,
- GDBM_WRCREAT, 0700, NULL);
- if (gdbms[CDB_FULLROOM] == NULL) {
- lprintf(2, "Cannot open fullroom: %s\n",
- gdbm_strerror(gdbm_errno));
- }
-
gdbms[CDB_FLOORTAB] = gdbm_open("floortab.gdbm", 0,
- GDBM_WRCREAT, 0700, NULL);
+ GDBM_WRCREAT, 0600, NULL);
if (gdbms[CDB_FLOORTAB] == NULL) {
lprintf(2, "Cannot open floortab: %s\n",
gdbm_strerror(gdbm_errno));
}
+ gdbms[CDB_MSGLISTS] = gdbm_open("msglists.gdbm", 0,
+ GDBM_WRCREAT, 0600, NULL);
+ if (gdbms[CDB_MSGLISTS] == NULL) {
+ lprintf(2, "Cannot open msglists: %s\n",
+ gdbm_strerror(gdbm_errno));
+ }
+
+ gdbms[CDB_MAILBOXES] = gdbm_open("mailboxes.gdbm", 0,
+ GDBM_WRCREAT, 0600, NULL);
+ if (gdbms[CDB_MAILBOXES] == NULL) {
+ lprintf(2, "Cannot open mailboxes: %s\n",
+ gdbm_strerror(gdbm_errno));
+ }
+
for (a=0; a<MAXKEYS; ++a) {
dtkey[a].dsize = 0;
dtkey[a].dptr = NULL;
}
-
}
* Close all of the gdbm database files we've opened. This can be done
* in a loop, since it's just a bunch of closes.
*/
-void close_databases() {
+void close_databases(void) {
int a;
defrag_databases();
* datum already exists it should be overwritten.
*/
int cdb_store(int cdb,
- char *key, int keylen,
- char *data, int datalen) {
+ void *key, int keylen,
+ void *data, int datalen) {
datum dkey, ddata;
/*
* Delete a piece of data. Returns 0 if the operation was successful.
*/
-int cdb_delete(int cdb, char *key, int keylen) {
+int cdb_delete(int cdb, void *key, int keylen) {
datum dkey;
* a struct cdbdata which it is the caller's responsibility to free later on
* using the cdb_free() routine.
*/
-struct cdbdata *cdb_fetch(int cdb, char *key, int keylen) {
+struct cdbdata *cdb_fetch(int cdb, void *key, int keylen) {
struct cdbdata *tempcdb;
datum dkey, dret;