#ifndef CTDL_MODULE_H
#define CTDL_MODULE_H
+#include "sysdep.h"
+
+#ifdef HAVE_GC
+#define GC_THREADS
+#define GC_REDIRECT_TO_LOCAL
+#include <gc/gc_local_alloc.h>
+#else
+#define GC_MALLOC malloc
+#define GC_MALLOC_ATOMIC malloc
+#define GC_FREE free
+#define GC_REALLOC realloc
+#endif
+
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <signal.h>
+#include <pwd.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#include <sys/wait.h>
+#include <string.h>
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#include <limits.h>
+
+
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
+
#include <libcitadel.h>
+
#include "server.h"
#include "sysdep_decls.h"
#include "msgbase.h"
#include "threads.h"
+#include "citadel_dirs.h"
+#include "context.h"
+
/*
* define macros for module init stuff
*/
void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...);
-/*
- * Fix the interface to aide_message so that it complies with the Coding style
- */
-
-#define CtdlAideMessage(TEXT, SUBJECT) aide_message(TEXT, SUBJECT)
+#define CtdlAideMessage(TEXT, SUBJECT) quickie_message("Citadel",NULL,NULL,AIDEROOM,TEXT,FMT_CITADEL,SUBJECT)
/*
* Hook functions available to modules.
void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
-void CtdlUnregisterProtoHook(void (*handler)(char *), char *cmd);
void CtdlRegisterServiceHook(int tcp_port,
char *sockpath,
void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
-void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, char *), char *name);
+void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), char *name);
/*
*/
struct CitContext *CtdlGetContextArray (int *count);
void CtdlFillSystemContext(struct CitContext *context, char *name);
-
+void CtdlClearSystemContext(void);
int CtdlTrySingleUser(void);
void CtdlEndSingleUser(void);
int CtdlWantSingleUser(void);
int CtdlIsSingleUser(void);
+int CtdlIsUserLoggedIn (char *user_name);
+int CtdlIsUserLoggedInByNum (long usernum);
+void CtdlBumpNewMailCounter(long which_user);
+
+
/*
* CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
* This provides a quick way to initialise a variable that might be used to indicate
*/
long CtdlGetCurrentMessageNumber(void);
+
+
+/*
+ * Expose various room operation functions from room_ops.c to the modules API
+ */
+
+unsigned CtdlCreateRoom(char *new_room_name,
+ int new_room_type,
+ char *new_room_pass,
+ int new_room_floor,
+ int really_create,
+ int avoid_access,
+ int new_room_view);
+int CtdlGetRoom(struct ctdlroom *qrbuf, char *room_name);
+int CtdlGetRoomLock(struct ctdlroom *qrbuf, char *room_name);
+int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr);
+void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
+ int *result, int *view);
+void CtdlPutRoomLock(struct ctdlroom *qrbuf);
+void CtdlForEachRoom(void (*CallBack)(struct ctdlroom *EachRoom, void *out_data),
+ void *in_data);
+void CtdlDeleteRoom(struct ctdlroom *qrbuf);
+int CtdlRenameRoom(char *old_name, char *new_name, int new_floor);
+void CtdlUserGoto (char *where, int display_result, int transiently,
+ int *msgs, int *new);
+struct floor *CtdlGetCachedFloor(int floor_num);
+void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf);
+void CtdlGetFloor (struct floor *flbuf, int floor_num);
+void CtdlPutFloor (struct floor *flbuf, int floor_num);
+void CtdlPutFloorLock(struct floor *flbuf, int floor_num);
+int CtdlGetFloorByName(const char *floor_name);
+int CtdlGetFloorByNameLock(const char *floor_name);
+int CtdlGetAvailableFloor(void);
+int CtdlIsNonEditable(struct ctdlroom *qrbuf);
+void CtdlPutRoom(struct ctdlroom *);
+
+/*
+ * Possible return values for CtdlRenameRoom()
+ */
+enum {
+ crr_ok, /* success */
+ crr_room_not_found, /* room not found */
+ crr_already_exists, /* new name already exists */
+ crr_noneditable, /* cannot edit this room */
+ crr_invalid_floor, /* target floor does not exist */
+ crr_access_denied /* not allowed to edit this room */
+};
+
+
+
+/*
+ * API declarations from citserver.h
+ */
+int CtdlAccessCheck(int);
+/* 'required access level' values which may be passed to CtdlAccessCheck()
+ */
+enum {
+ ac_none,
+ ac_logged_in,
+ ac_room_aide,
+ ac_aide,
+ ac_internal
+};
+
+
+
+/*
+ * API declarations from serv_extensions.h
+ */
+void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, const char *search_string, const char *func_name);
+/*
+ * Global system configuration. Don't change anything here. It's all in dtds/config-defs.h now.
+ */
+struct config {
+#include "datadefinitions.h"
+#include "dtds/config-defs.h"
+#include "undef_data.h"
+};
+
+extern struct config config;
+
+
+
+/*
+ * Expose API calls from user_ops.c
+ */
+int CtdlGetUser(struct ctdluser *usbuf, char *name);
+int CtdlGetUserLen(struct ctdluser *usbuf, const char *name, long len);
+int CtdlGetUserLock(struct ctdluser *usbuf, char *name);
+void CtdlPutUser(struct ctdluser *usbuf);
+void CtdlPutUserLock(struct ctdluser *usbuf);
+int CtdlGetUserByNumber(struct ctdluser *usbuf, long number);
+void CtdlGetRelationship(struct visit *vbuf,
+ struct ctdluser *rel_user,
+ struct ctdlroom *rel_room);
+void CtdlSetRelationship(struct visit *newvisit,
+ struct ctdluser *rel_user,
+ struct ctdlroom *rel_room);
+void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix);
+
+int CtdlLoginExistingUser(char *authname, const char *username);
+
+/*
+ * Values which may be returned by CtdlLoginExistingUser()
+ */
+enum {
+ pass_ok,
+ pass_already_logged_in,
+ pass_no_user,
+ pass_internal_error,
+ pass_wrong_password
+};
+
+int CtdlTryPassword(const char *password, long len);
+/*
+ * Values which may be returned by CtdlTryPassword()
+ */
+enum {
+ login_ok,
+ login_already_logged_in,
+ login_too_many_users,
+ login_not_found
+};
+
+void CtdlUserLogout(void);
+
+
+
+
+/*
+ * Expose API calls from msgbase.c
+ */
+char *CtdlGetSysConfig(char *sysconfname);
+void CtdlPutSysConfig(char *sysconfname, char *sysconfdata);
+
+
+
+
+/*
+ * Expose API calls from euidindex.c
+ */
+long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf);
+
+
#endif /* CTDL_MODULE_H */