Now we name all the private contexts.
[citadel.git] / citadel / sysdep.c
index 265f879e7838eff771687237610a320512a7b961..14e9e3e9d18b454c9e4967d1c549a3691e5a75b4 100644 (file)
@@ -71,6 +71,8 @@
 
 #include "ctdl_module.h"
 #include "threads.h"
+#include "user_ops.h"
+
 
 #ifdef DEBUG_MEMORY_LEAKS
 struct igheap {
@@ -463,6 +465,27 @@ struct CitContext *CtdlGetContextArray(int *count)
        return nptr;
 }
 
+
+
+/**
+ * This function returns a private context with the user filled in correctly
+ */
+void CtdlFillPrivateContext(struct CitContext *context, char *name)
+{
+       char sysname[USERNAME_SIZE];
+
+       memset(context, 0, sizeof(struct CitContext));
+       context->internal_pgm = 1;
+       context->cs_pid = 0;
+       strcpy (sysname, "SYS_");
+       strcat (sysname, name);
+       if (getuser(&(context->user), sysname))
+       {
+               strcpy(context->user.fullname, sysname);
+               putuser(&(context->user));
+       }
+}
+
 /*
  * The following functions implement output buffering. If the kernel supplies
  * native TCP buffering (Linux & *BSD), use that; otherwise, emulate it with