summaryrefslogtreecommitdiff
path: root/server/uloc.c
diff options
context:
space:
mode:
authorGravatar John Kohl <jtkohl@mit.edu>1987-07-14 13:08:43 +0000
committerGravatar John Kohl <jtkohl@mit.edu>1987-07-14 13:08:43 +0000
commit6ea374cae5e25b47a573d075568c63a23004e4c5 (patch)
treefbe25c95e635bc5c0ed9fc9d6b7b740274172d5f /server/uloc.c
parent6c14d8e1e74a24fd6c9ab7e8c62b3e8e12e76e7f (diff)
plug a memory hole; add brain dump support
Diffstat (limited to 'server/uloc.c')
-rw-r--r--server/uloc.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/server/uloc.c b/server/uloc.c
index e99962b..a523e85 100644
--- a/server/uloc.c
+++ b/server/uloc.c
@@ -39,6 +39,9 @@ static char rcsid_uloc_s_c[] = "$Header$";
* void uloc_hflush(addr)
* struct in_addr *addr;
*
+ * void uloc_send_locations(server, host)
+ * ZServerDesc_t *server;
+ * ZHostList_t *host;
*/
/*
@@ -47,6 +50,12 @@ static char rcsid_uloc_s_c[] = "$Header$";
* binary searches), growing and shrinking it as necessary.
*/
+/* WARNING: make sure this is the same as the number of strings you */
+/* plan to hand back to the user in response to a locate request, */
+/* else you will lose. See ulogin_locate() and uloc_send_locations() */
+#define NUM_FIELDS 2
+
+
typedef enum _login_type {
INVISIBLE,
VISIBLE
@@ -63,11 +72,6 @@ typedef struct _ZLocation_t {
struct in_addr zlt_addr; /* IP addr of this loc */
} ZLocation_t;
-/* WARNING: make sure this is the same as the number of strings you */
-/* plan to hand back to the user in response to a locate request, */
-/* else you will lose. See ulogin_locate() */
-#define NUM_FIELDS 2
-
#define NULLZLT ((ZLocation_t *) 0)
#define NOLOC (1)
#define QUIET (-1)
@@ -79,7 +83,7 @@ static int uloc_compare(), ulogin_setup(), ulogin_parse(), ul_equiv();
static int ulogin_remove_user(), ulogin_hide_user();
static ZLocation_t *locations = NULLZLT; /* ptr to first in array */
-static int num_locs = 0; /* number in array */
+static int num_locs = 0; /* number in array */
/*
* Dispatch a LOGIN notice.
@@ -232,6 +236,7 @@ struct in_addr *addr;
zdbug((LOG_DEBUG,"no more locs"));
xfree(loc);
locations = NULLZLT;
+ num_locs = new_num;
return;
}
locations = loc;
@@ -252,6 +257,37 @@ struct in_addr *addr;
}
/*
+ * Send the locations for host for a brain dump
+ */
+
+void
+uloc_send_locations(host)
+ZHostList_t *host;
+{
+ register ZLocation_t *loc;
+ register int i;
+ register struct in_addr *haddr = &host->zh_addr.sin_addr;
+ char *lyst[NUM_FIELDS];
+
+ for (i = 0, loc = locations; i < num_locs; i++, loc++) {
+ if (loc->zlt_addr.s_addr != haddr->s_addr)
+ continue;
+ lyst[0] = loc->zlt_machine;
+#ifdef notdef
+ lyst[1] = loc->zlt_tty;
+ lyst[2] = loc->zlt_time;
+#else
+ lyst[1] = loc->zlt_time;
+#endif notdef
+ bdump_send_list_tcp(ACKED, bdump_sin.sin_port, LOGIN_CLASS,
+ loc->zlt_user,
+ (loc->zlt_visible == VISIBLE) ? LOGIN_USER_LOGIN : LOGIN_QUIET_LOGIN,
+ myname, "", lyst, NUM_FIELDS);
+ }
+ return;
+}
+
+/*
* Add the user to the internal table of locations.
*/
@@ -675,6 +711,7 @@ rep:
answer[i*NUM_FIELDS + 1] = matches[i]->zlt_time;
}
+ xfree(matches);
/* if it's too long, chop off one at a time till it fits */
while ((retval = ZFormatRawNoticeList(&reply,
answer,