X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fcontext.c;h=478ed03ad71eb5f5f5aa55b733d88e45ddb77a1a;hb=c2c1aa8b94024803f623575c5f9ea89d9317f1e0;hp=3122e5c06b102dd55cc63fc2ef996e25ab18e0f2;hpb=be8d2e8c65b70b7caa227f794c3c849ef2367954;p=citadel.git diff --git a/citadel/context.c b/citadel/context.c index 3122e5c06..478ed03ad 100644 --- a/citadel/context.c +++ b/citadel/context.c @@ -151,6 +151,32 @@ int CtdlIsUserLoggedIn (char *user_name) return ret; } + + +/* + * Check to see if a user is currently logged in. + * Basically same as CtdlIsUserLoggedIn() but uses the user number instead. + * 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 CtdlIsUserLoggedInByNum (int usernum) +{ + CitContext *cptr; + int ret = 0; + + begin_critical_section(S_SESSION_TABLE); + for (cptr = ContextList; cptr != NULL; cptr = cptr->next) { + if (cptr->user.usernum == usernum) { + ret = 1; + } + } + 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