]> code.citadel.org Git - citadel.git/commitdiff
usetable.c: moved CheckIfAlreadySeen() out of database.c
authorArt Cancro <ajc@citadel.org>
Tue, 8 Aug 2023 17:17:27 +0000 (13:17 -0400)
committerArt Cancro <ajc@citadel.org>
Tue, 8 Aug 2023 17:17:27 +0000 (13:17 -0400)
citadel/server/citserver.h
citadel/server/database.h
citadel/server/database_bdb.c
citadel/server/usetable.c [new file with mode: 0644]

index 27eae38e6d0cab8ef41862a7224c914199b810e2..09412b0524364d09d502bbff7a13b5c607c8ed70 100644 (file)
@@ -36,6 +36,7 @@ void citproto_begin_session(void);
 void citproto_begin_admin_session(void);
 void help_subst (char *strbuf, char *source, char *dest);
 char CtdlCheckExpress(void);
+int CheckIfAlreadySeen(StrBuf *guid);
 
 extern int panic_fd;
 extern time_t server_startup_time;
index 053603a50aef2b73d11e18d2791ae0b09513adec..1c489712be202b7e6e29f13c1aad0209dbcbcf05 100644 (file)
@@ -24,5 +24,4 @@ void cdb_chmod_data(void);
 void cdb_checkpoint(void);
 void check_handles(void *arg);
 void cdb_compact(void);
-int CheckIfAlreadySeen(StrBuf *guid);
 #endif
index cb5adafca46246a38ac1c036a240028034e72423..ef538d05d576846f21574342b27460f1fc7768a0 100644 (file)
@@ -741,30 +741,6 @@ void cdb_compact(void) {
 }
 
 
-// Has an item already been seen (is it in the CDB_USETABLE) ?
-// Returns 0 if it hasn't, 1 if it has
-// In either case, writes the item to the database for next time.
-int CheckIfAlreadySeen(StrBuf *guid) {
-       int found = 0;
-       struct UseTable ut;
-       struct cdbdata *cdbut;
-       int hash = HashLittle(ChrPtr(guid), StrLength(guid));
-
-       syslog(LOG_DEBUG, "db: CheckIfAlreadySeen(0x%8x)", hash);
-       cdbut = cdb_fetch(CDB_USETABLE, &hash, sizeof(hash));
-       if (cdbut != NULL) {
-               found = 1;
-               cdb_free(cdbut);
-       }
-
-       // (Re)write the record, to update the timestamp.
-       ut.hash = hash;
-       ut.timestamp = time(NULL);
-       cdb_store(CDB_USETABLE, &hash, sizeof(hash), &ut, sizeof(struct UseTable));
-       return (found);
-}
-
-
 char *ctdl_module_init_database() {
        if (!threading) {
                // nothing to do here
diff --git a/citadel/server/usetable.c b/citadel/server/usetable.c
new file mode 100644 (file)
index 0000000..9caea83
--- /dev/null
@@ -0,0 +1,41 @@
+// use table handler
+//
+// Copyright (c) 1987-2023 by the citadel.org team
+//
+// This program is open source software.  Use, duplication, or disclosure
+// is subject to the terms of the GNU General Public License, version 3.
+
+
+#include "sysdep.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <libcitadel.h>
+#include "database.h"
+#include "server.h"
+
+
+// Has an item already been seen (is it in the CDB_USETABLE) ?
+// Returns 0 if it hasn't, 1 if it has
+// In either case, writes the item to the database for next time.
+int CheckIfAlreadySeen(StrBuf *guid) {
+       int found = 0;
+       struct UseTable ut;
+       struct cdbdata *cdbut;
+       int hash = HashLittle(ChrPtr(guid), StrLength(guid));
+
+       syslog(LOG_DEBUG, "usetable: CheckIfAlreadySeen(0x%8x)", hash);
+       cdbut = cdb_fetch(CDB_USETABLE, &hash, sizeof(hash));
+       if (cdbut != NULL) {
+               found = 1;
+               cdb_free(cdbut);
+       }
+
+       // (Re)write the record, to update the timestamp.
+       ut.hash = hash;
+       ut.timestamp = time(NULL);
+       cdb_store(CDB_USETABLE, &hash, sizeof(hash), &ut, sizeof(struct UseTable));
+       return (found);
+}