Did away with lprintf all together now its called CtdlLogPrintf()
[citadel.git] / citadel / sysdep.c
index 164cafd5a70e2e530d888cb2b4df3695d5fb057e..acc3f9aa09f436c335177b0b8d45292dff619b80 100644 (file)
@@ -97,30 +97,16 @@ int enable_syslog = 0;
 
 
 /*
- * Create an interface to lprintf that follows the coding convention.
- * This is here until such time as we have replaced all calls to lprintf with CtdlLogPrintf
+ * CtdlLogPrintf()  ...   Write logging information
  */
-void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...)
-{
-       va_list arg_ptr;
-       va_start(arg_ptr, format);
-       vlprintf(loglevel, format, arg_ptr);
-       va_end(arg_ptr);
-}
-
-
-/*
- * lprintf()  ...   Write logging information
- */
-void lprintf(enum LogLevel loglevel, const char *format, ...) {   
+void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...) {   
        va_list arg_ptr;
        va_start(arg_ptr, format);
-       vlprintf(loglevel, format, arg_ptr);
+       vCtdlLogPrintf(loglevel, format, arg_ptr);
        va_end(arg_ptr);
 }
 
-void vlprintf(enum LogLevel loglevel, const char *format, va_list arg_ptr)
+void vCtdlLogPrintf(enum LogLevel loglevel, const char *format, va_list arg_ptr)
 {
        char buf[SIZ], buf2[SIZ];
 
@@ -460,6 +446,24 @@ struct CitContext *CreateNewContext(void) {
 }
 
 
+struct CitContext *CtdlGetContextArray(int *count)
+{
+       int nContexts, i;
+       struct CitContext *nptr, *cptr;
+       
+       nContexts = num_sessions;
+       nptr = malloc(sizeof(struct CitContext) * nContexts);
+       if (!nptr)
+               return NULL;
+       begin_critical_section(S_SESSION_TABLE);
+       for (cptr = ContextList, i=0; cptr != NULL && i < nContexts; cptr = cptr->next, i++)
+               memcpy(&nptr[i], cptr, sizeof (struct CitContext));
+       end_critical_section (S_SESSION_TABLE);
+       
+       *count = i;
+       return nptr;
+}
+
 /*
  * The following functions implement output buffering. If the kernel supplies
  * native TCP buffering (Linux & *BSD), use that; otherwise, emulate it with
@@ -756,7 +760,7 @@ void context_cleanup(void)
                rem = ptr->next;
                --num_sessions;
                
-               lprintf(CTDL_DEBUG, "Purging session %d\n", ptr->cs_pid);
+               CtdlLogPrintf(CTDL_DEBUG, "Purging session %d\n", ptr->cs_pid);
                RemoveContext(ptr);
                free (ptr);
                ptr = rem;
@@ -1143,8 +1147,8 @@ do_select:        force_purge = 0;
                        tv.tv_usec = 0;
                        retval = CtdlThreadSelect(highest + 1, &readfds, NULL, NULL, &tv);
                }
-
-               if (CtdlThreadCheckStop()) return(NULL);
+               else
+                       return NULL;
 
                /* Now figure out who made this select() unblock.
                 * First, check for an error or exit condition.
@@ -1164,6 +1168,7 @@ do_select:        force_purge = 0;
                        }
                }
                else if(retval == 0) {
+                       if (CtdlThreadCheckStop()) return(NULL);
                        goto SKIP_SELECT;
                }
                /* Next, check to see if it's a new client connecting