summaryrefslogtreecommitdiff
path: root/server/client.c
diff options
context:
space:
mode:
authorGravatar Kenneth G Raeburn <raeburn@mit.edu>1990-11-13 12:02:59 +0000
committerGravatar Kenneth G Raeburn <raeburn@mit.edu>1990-11-13 12:02:59 +0000
commita36a075433165839ec7a02379ad83c03e08498a5 (patch)
treef6ad43e0f7a6e60f5e65d3e632b49edabf9a9a7a /server/client.c
parentdb89d0d2485f01c3d411c87952f2cd09e372f844 (diff)
C++ conversion and lots of modifications from summer & fall work
Diffstat (limited to 'server/client.c')
-rw-r--r--server/client.c65
1 files changed, 24 insertions, 41 deletions
diff --git a/server/client.c b/server/client.c
index 185d059..053f97f 100644
--- a/server/client.c
+++ b/server/client.c
@@ -13,11 +13,10 @@
#include <zephyr/mit-copyright.h>
-#ifndef lint
-#ifndef SABER
-static char rcsid_client_c[] = "$Header$";
-#endif SABER
-#endif lint
+#if !defined (lint) && !defined (SABER)
+static const char rcsid_client_c[] =
+ "$Header$";
+#endif
/*
* External functions:
@@ -46,8 +45,6 @@ static char rcsid_client_c[] = "$Header$";
#include "zserver.h"
#include <sys/socket.h>
-static void clt_free();
-
/*
* register a client: allocate space, find or insert the address in the
* server's list of hosts, initialize and insert the client into
@@ -58,12 +55,7 @@ static void clt_free();
*/
Code_t
-client_register(notice, who, client, server, wantdefaults)
-ZNotice_t *notice;
-struct sockaddr_in *who;
-register ZClient_t **client; /* RETURN */
-ZServerDesc_t *server;
-int wantdefaults;
+client_register(ZNotice_t *notice, struct sockaddr_in *who, register ZClient_t **client, ZServerDesc_t *server, int wantdefaults)
{
register ZHostList_t *hlp = server->zs_hosts;
register ZHostList_t *hlp2;
@@ -93,11 +85,12 @@ int wantdefaults;
}
/* allocate a client struct */
- if (!(*client = (ZClient_t *) xmalloc(sizeof(ZClient_t))))
+ *client = new ZClient_t;
+ if (!*client)
return(ENOMEM);
if (!(clist = (ZClientList_t *) xmalloc(sizeof(ZClientList_t)))) {
- xfree(*client);
+ delete *client;
return(ENOMEM);
}
@@ -105,13 +98,16 @@ int wantdefaults;
clist->zclt_client = *client;
/* initialize the struct */
- bzero((caddr_t) &(*client)->zct_sin, sizeof(struct sockaddr_in));
+ bzero((caddr_t) &(*client)->zct_sin,
+ sizeof(struct sockaddr_in));
+ bzero((caddr_t) &(*client)->zct_cblock,
+ sizeof((*client)->zct_cblock));
(*client)->zct_sin.sin_addr.s_addr = who->sin_addr.s_addr;
(*client)->zct_sin.sin_port = notice->z_port;
(*client)->zct_sin.sin_family = AF_INET;
(*client)->zct_subs = NULLZST;
(*client)->zct_subs = NULLZST;
- (*client)->zct_principal = strsave(notice->z_sender);
+ (*client)->zct_principal = ZString (notice->z_sender);
/* chain him in to the clients list in the host list*/
@@ -135,10 +131,7 @@ int wantdefaults;
*/
void
-client_deregister(client, host, flush)
-ZClient_t *client;
-ZHostList_t *host;
-int flush;
+client_deregister(ZClient_t *client, ZHostList_t *host, int flush)
{
ZClientList_t *clients;
int omask = sigblock(sigmask(SIGFPE)); /* don't let db dumps start */
@@ -161,7 +154,7 @@ int flush;
clients = clients->q_forw)
if (clients->zclt_client == client) {
xremque(clients);
- clt_free(client);
+ delete client;
xfree(clients);
(void) sigsetmask(omask);
return;
@@ -176,20 +169,22 @@ int flush;
*/
ZClient_t *
-client_which_client(who, notice)
-struct sockaddr_in *who;
-ZNotice_t *notice;
+client_which_client(struct sockaddr_in *who, ZNotice_t *notice)
{
register ZHostList_t *hlt;
register ZClientList_t *clients;
if (!(hlt = hostm_find_host(&who->sin_addr))) {
+#if 0
zdbug((LOG_DEBUG,"cl_wh_clt: host not found"));
+#endif
return(NULLZCNT);
}
if (!hlt->zh_clients) {
+#if 0
zdbug((LOG_DEBUG,"cl_wh_clt: no clients"));
+#endif
return(NULLZCNT);
}
@@ -200,39 +195,27 @@ ZNotice_t *notice;
return(clients->zclt_client);
}
+#if 0
zdbug((LOG_DEBUG, "cl_wh_clt: no port"));
+#endif
return(NULLZCNT);
}
/*
- * Free storage in use by client
- */
-
-static void
-clt_free(client)
-ZClient_t *client;
-{
- xfree(client->zct_principal);
- xfree(client);
-}
-
-/*
* dump info about clients in this clist onto the fp.
* assumed to be called with SIGFPE blocked
* (true if called from signal handler)
*/
void
-client_dump_clients(fp, clist)
-FILE *fp;
-ZClientList_t *clist;
+client_dump_clients(FILE *fp, ZClientList_t *clist)
{
register ZClientList_t *ptr;
for (ptr = clist->q_forw; ptr != clist; ptr = ptr->q_forw) {
(void) fprintf(fp, "\t%d (%s):\n",
ntohs(ptr->zclt_client->zct_sin.sin_port),
- ptr->zclt_client->zct_principal);
+ ptr->zclt_client->zct_principal.value ());
subscr_dump_subs(fp, ptr->zclt_client->zct_subs);
}
return;