Grabbed that previously noted bad code from rename_user that walked
[citadel.git] / citadel / context.c
index cc8885483be0f52a620425cc044921f81412f9c7..3122e5c06b102dd55cc63fc2ef996e25ab18e0f2 100644 (file)
@@ -127,6 +127,30 @@ int CtdlIsSingleUser(void)
 }
 
 
+
+
+/*
+ * Check to see if a user is currently logged in
+ * Take care with what you do as a result of this test.
+ * The user may not have been logged in when this function was called BUT
+ * because of threading the user might be logged in before you test the result.
+ */
+int CtdlIsUserLoggedIn (char *user_name)
+{
+       CitContext *cptr;
+       int ret = 0;
+
+       begin_critical_section (S_SESSION_TABLE);
+       for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
+               if (!strcasecmp(cptr->user.fullname, user_name)) {
+                       ret = 1;
+                       break;
+               }
+       }
+       end_critical_section(S_SESSION_TABLE);
+       return ret;
+}
+
 /*
  * Return a pointer to the CitContext structure bound to the thread which
  * called this function.  If there's no such binding (for example, if it's