summaryrefslogtreecommitdiff
path: root/server/uloc.c
diff options
context:
space:
mode:
authorGravatar John Kohl <jtkohl@mit.edu>1987-09-28 12:42:02 +0000
committerGravatar John Kohl <jtkohl@mit.edu>1987-09-28 12:42:02 +0000
commitf7acf447ef157e3da0ba27021b1891b280a7a106 (patch)
treef8b23d3baf428fe2b41cac9c166b7fec034fa9dd /server/uloc.c
parentfce886e74ccd299e6f5ff7af785eb7923da50389 (diff)
add ulogin_flush_user
Diffstat (limited to 'server/uloc.c')
-rw-r--r--server/uloc.c82
1 files changed, 80 insertions, 2 deletions
diff --git a/server/uloc.c b/server/uloc.c
index aa63472..e191f42 100644
--- a/server/uloc.c
+++ b/server/uloc.c
@@ -74,7 +74,7 @@ typedef struct _ZLocation_t {
#define QUIET (-1)
#define UNAUTH (-2)
-static void ulogin_locate(), ulogin_add_user();
+static void ulogin_locate(), ulogin_add_user(), ulogin_flush_user();
static ZLocation_t *ulogin_find();
static int ulogin_setup(), ulogin_parse(), ul_equiv();
static int ulogin_remove_user(), ulogin_hide_user();
@@ -128,7 +128,12 @@ ZServerDesc_t *server;
clt_ack(notice, who, AUTH_FAILED);
return;
}
- if (!strcmp(notice->z_opcode, LOGIN_USER_LOGIN)) {
+ if (!strcmp(notice->z_opcode, LOGIN_USER_FLUSH)) {
+ zdbug((LOG_DEBUG, "user flush"));
+ ulogin_flush_user(notice, who);
+ if (server == me_server)
+ ack(notice, who);
+ } else if (!strcmp(notice->z_opcode, LOGIN_USER_LOGIN)) {
zdbug((LOG_DEBUG,"user login"));
ulogin_add_user(notice, VISIBLE, who);
if (server == me_server)
@@ -610,6 +615,79 @@ struct sockaddr_in *who;
}
/*
+ * remove all locs of the user specified in notice from the internal table
+ */
+
+static void
+ulogin_flush_user(notice, who)
+ZNotice_t *notice;
+struct sockaddr_in *who;
+{
+ ZLocation_t *loc, *loc2;
+ register int i, j, num_match, num_left;
+
+ i = num_match = num_left = 0;
+
+ if (!(loc2 = ulogin_find(notice, 0))) {
+ zdbug((LOG_DEBUG,"ul_rem: not here"));
+ return;
+ }
+
+ num_left = num_locs - (loc2 - locations);
+
+ while (num_left &&
+ !strcmp(loc2[num_match].zlt_user, notice->z_class_inst)) {
+ num_match++;
+ num_locs--;
+ num_left--;
+ }
+ if (num_locs == 0) { /* last one */
+ zdbug((LOG_DEBUG,"last loc"));
+ xfree(locations);
+ locations = NULLZLT;
+ return;
+ }
+
+ if (!(loc = (ZLocation_t *) xmalloc(num_locs * sizeof(ZLocation_t)))) {
+ syslog(LOG_CRIT, "ul_rem malloc");
+ abort();
+ /*NOTREACHED*/
+ }
+
+ /* copy old entries */
+ while (i < num_locs && &locations[i] < loc2) {
+ loc[i] = locations[i];
+ i++;
+ }
+
+ for (j = 0; j < num_match; j++)
+ i++; /* skip over the matches */
+
+ /* copy the rest */
+ while (i <= num_locs) {
+ loc[i - num_match] = locations[i];
+ i++;
+ }
+
+ xfree(locations);
+
+ locations = loc;
+
+#ifdef DEBUG
+ if (zdebug) {
+ register int i;
+
+ for (i = 0; i < num_locs; i++)
+ syslog(LOG_DEBUG, "%s/%d",
+ locations[i].zlt_user,
+ (int) locations[i].zlt_visible);
+ }
+#endif DEBUG
+ /* all done */
+ return;
+}
+
+/*
* Set the user's visible flag to visible
*/