Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel
[citadel.git] / citadel / context.h
index c2578036035f92bc73062aaf81566b8912a6a43e..9243d5148230270912919694e908ee9b68a81dea 100644 (file)
@@ -28,6 +28,8 @@ typedef enum __CCState {
        CON_SYS                 /* This is a system context and mustn't be purged */
 } CCState;
 
+typedef struct AsyncIO AsyncIO; /* forward declaration for event_client.h */
+typedef struct CitContext CitContext;
 
 /*
  * Here's the big one... the Citadel context structure.
@@ -37,11 +39,12 @@ typedef enum __CCState {
  *
  */
 struct CitContext {
-       struct CitContext *prev;        /* Link to previous session in list */
-       struct CitContext *next;        /* Link to next session in the list */
+       CitContext *prev;       /* Link to previous session in list */
+       CitContext *next;       /* Link to next session in the list */
 
        int cs_pid;             /* session ID */
        int dont_term;          /* for special activities like artv so we don't get killed */
+       double created;      /* time of birth */
        time_t lastcmd;         /* time of last command executed */
        time_t lastidle;        /* For computing idle time */
        CCState state;          /* thread state (see CON_ values below) */
@@ -139,9 +142,10 @@ struct CitContext {
 
        long *cached_msglist;                   /* results of the previous CtdlForEachMessage() */
        int cached_num_msgs;
+
+       AsyncIO *IO;                            /* if this session has AsyncIO going on... */
 };
 
-typedef struct CitContext CitContext;
 
 
 #define CC MyContext()
@@ -194,4 +198,19 @@ static INLINE void become_session(CitContext *which_con) {
 }
 
 
+
+/* typedef void (*CtdlDbgFunction) (const int); */
+
+extern int DebugSession;
+#define CONDBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (DebugSession != 0))
+
+#define CON_syslog(LEVEL, FORMAT, ...)                         \
+       CONDBGLOG(LEVEL) syslog(LEVEL,                          \
+                               "Context: " FORMAT, __VA_ARGS__)
+
+#define CONM_syslog(LEVEL, FORMAT)                     \
+       CONDBGLOG(LEVEL) syslog(LEVEL,                  \
+                               "Context: " FORMAT);
+
+
 #endif /* CONTEXT_H */