xref: /netbsd/games/hunt/hunt/connect.c (revision bf9ec67e)
1 /*	$NetBSD: connect.c,v 1.3 1997/10/11 08:13:40 lukem Exp $	*/
2 /*
3  *  Hunt
4  *  Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold
5  *  San Francisco, California
6  */
7 
8 #include <sys/cdefs.h>
9 #ifndef lint
10 __RCSID("$NetBSD: connect.c,v 1.3 1997/10/11 08:13:40 lukem Exp $");
11 #endif /* not lint */
12 
13 # include	"hunt.h"
14 # include	<signal.h>
15 # include	<unistd.h>
16 
17 void
18 do_connect(name, team, enter_status)
19 	char	*name;
20 	char	team;
21 	long	enter_status;
22 {
23 	static long	uid;
24 	static long	mode;
25 
26 	if (uid == 0)
27 		uid = htonl(getuid());
28 	(void) write(Socket, (char *) &uid, LONGLEN);
29 	(void) write(Socket, name, NAMELEN);
30 	(void) write(Socket, &team, 1);
31 	enter_status = htonl(enter_status);
32 	(void) write(Socket, (char *) &enter_status, LONGLEN);
33 	(void) strcpy(Buf, ttyname(fileno(stderr)));
34 	(void) write(Socket, Buf, NAMELEN);
35 # ifdef INTERNET
36 	if (Send_message != NULL)
37 		mode = C_MESSAGE;
38 	else
39 # endif
40 # ifdef MONITOR
41 	if (Am_monitor)
42 		mode = C_MONITOR;
43 	else
44 # endif
45 		mode = C_PLAYER;
46 	mode = htonl(mode);
47 	(void) write(Socket, (char *) &mode, sizeof mode);
48 }
49