* added RCS Id keyword strings to sources
[citadel.git] / citadel / server.h
index 2649c1140371ac2c7d3b87bf6e24d50c2cd87a55..96258a208641c8f214ef2a42fe993d4c73790f92 100644 (file)
@@ -1,4 +1,4 @@
-
+/* $Id$ */
 typedef pthread_t THREAD;
 
 
@@ -26,7 +26,6 @@ struct CitContext {
        int num_msgs;
 
         char curr_user[32];            /* name of current user */
-        int curr_rm;                   /* index of current room */
         int logged_in;                 /* logged in */
         int internal_pgm;              /* authenticated as internal program */
         char temp[32];                 /* temp file name */
@@ -38,7 +37,7 @@ struct CitContext {
        struct ExpressMessage *FirstExpressMessage;
        int cs_pid;                     /* session ID */
        char cs_room[20];               /* current room */
-       long cs_lastupdt;               /* time of last update */
+       time_t cs_lastupdt;             /* time of last update */
        time_t lastcmd;                 /* time of last command executed */
        time_t lastidle;                /* For computing idle time */
        char lastcmdname[5];            /* name of last command executed */
@@ -68,8 +67,14 @@ struct CitContext {
        char fake_hostname[25];         /* Name of the fake hostname <bc>    */
        char fake_roomname[20];         /* Name of the fake room <bc>        */
        char last_pager[32];            /* The username of the last pager    */
+
+       int FloorBeingSearched;         /* This is used by cmd_lrms() etc.   */
+
+       int CtdlErrno;                  /* Error return for CitadelAPI calls */
        };
 
+typedef struct CitContext t_context;
+
 #define CS_STEALTH     1               /* stealth mode */
 #define CS_CHAT                2               /* chat mode */
 #define CS_POSTING     4               /* Posting */
@@ -118,15 +123,79 @@ struct ChatLine {
 /*
  * Citadel DataBases (define one for each cdb we need to open)
  */
-#define CDB_MSGMAIN    0       /* message base */
-#define CDB_USERSUPP   1       /* user file */
-#define CDB_QUICKROOM  2       /* room index */
-#define CDB_FLOORTAB   3       /* floor index */
-#define CDB_MSGLISTS   4       /* room message lists */
-#define CDB_MAILBOXES  5       /* mailbox message lists */
+#define CDB_MSGMAIN    0       /* message base                  */
+#define CDB_USERSUPP   1       /* user file                     */
+#define CDB_QUICKROOM  2       /* room index                    */
+#define CDB_FLOORTAB   3       /* floor index                   */
+#define CDB_MSGLISTS   4       /* room message lists            */
+#define CDB_VISIT      5       /* user/room relationships       */
 #define MAXCDB         6       /* total number of CDB's defined */
 
 struct cdbdata {
        size_t len;
        char *ptr;
        };
+
+
+/* Structures and declarations for function hooks of various types */
+
+struct CleanupFunctionHook {
+       struct CleanupFunctionHook *next;
+       void (*h_function_pointer) (void);
+       };
+extern struct CleanupFunctionHook *CleanupHookTable;
+
+
+/*
+ * SessionFunctionHook extensions are used for any type of hook for which
+ * the context in which it's being called (which is determined by the event
+ * type) will make it obvious for the hook function to know where to look for
+ * pertinent data.
+ */
+struct SessionFunctionHook {
+       struct SessionFunctionHook *next;
+       void (*h_function_pointer) (void);
+       int eventtype;
+       };
+extern struct SessionFunctionHook *SessionHookTable;
+
+#define EVT_STOP       0       /* Session is terminating */
+#define EVT_START      1       /* Session is starting */
+#define EVT_LOGIN      2       /* A user is logging in */
+#define EVT_NEWROOM    3       /* Changing rooms */
+#define EVT_LOGOUT     4       /* A user is logging out */
+#define EVT_SETPASS    5       /* Setting or changing password */
+
+
+/*
+ * UserFunctionHook extensions are used for any type of hook which implements
+ * an operation on a user or username (potentially) other than the one
+ * operating the current session.
+ */
+struct UserFunctionHook {
+       struct UserFunctionHook *next;
+       void (*h_function_pointer) (char *username, long usernum);
+       int eventtype;
+       };
+extern struct UserFunctionHook *UserHookTable;
+
+#define EVT_PURGEUSER  100     /* Deleting a user */
+#define EVT_OUTPUTMSG  101     /* Outputting a message */
+
+
+/* Defines the relationship of a user to a particular room */
+struct visit {
+       char v_roomname[ROOMNAMELEN];
+       long v_generation;
+       long v_lastseen;
+       unsigned int v_flags;
+       };
+
+#define V_FORGET       1               /* User has zapped this room        */
+#define V_LOCKOUT      2               /* User is locked out of this room  */
+#define V_ACCESS       4               /* Access is granted to this room   */
+
+#define UA_KNOWN                2
+#define UA_GOTOALLOWED          4
+#define UA_HASNEWMSGS           8
+#define UA_ZAPPED              16