DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T m

⟦b8fb2c7fc⟧ TextFile

    Length: 3174 (0xc66)
    Types: TextFile
    Names: »main.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/X/Xtrek/main.c« 

TextFile

static char sccsid[] = "@(#)main.c	1.2";
#ifndef lint
static char *rcsid_main_c = "$Header: /uraid2/riedl/src/xceltrek/RCS/main.c,v 1.1 88/04/18 16:10:25 riedl Exp Locker: riedl $";
#endif	lint
/* Copyright (c) 1986 	Chris Guthrie */

#include <X11/Xlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <signal.h>
#include <pwd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#ifdef SUN40
#include <sys/filio.h>
#else
#define	FD_SET(n, s)	(((s)->fds_bits[0]) |= (1 << n))
#define	FD_CLR(n, s)	(((s)->fds_bits[0]) &= ~(1 << n))
#define	FD_ZERO(s)	bzero((char *)(s), sizeof (*(s)))
#define	FD_ISSET(n, s)	(((s)->fds_bits[0]) & (1 << n))
#include <sys/ioctl.h>
#endif /* SUN40 */
#include "defs.h"
#include "data.h"

extern int debug;
extern int	xtrek_socket;
struct sockaddr_in	xtrekAddress;

main(argc, argv)
int argc;
char **argv;
{
    struct player	*p;
    struct servent	*sp;
    extern struct servent	*getservbyname();
    int docycle(), move();
    char *host;
    register int i;
    extern char *optarg;
    extern int optind, opterr;
    char *getenv();
    char c;
    int argerr = 0;
    int	on = 1;
    int oldinetd = 0;

    freopen("/tmp/trek","a",stderr);
#if defined(sun) && !defined(SUN40)
    oldinetd = 1;
#endif
    while ((c = getopt(argc, argv, "dT:c:u:")) != EOF) {
      switch (c) {
      case 'T':
	switch (optarg[0]) {
#ifdef notdef
	case 'f': LocalTeam = 0; break;
	case 'r': LocalTeam = 1; break;
	case 'k': LocalTeam = 2; break;
	case 'o': LocalTeam = 3; break;
#endif
	default: argerr = 1; break;
	}
        break;
      case 'c':
/*	copilot = 1;*/
	break;
      case 'd':
	debug++;
	break;
      case '?':
      default:
	argerr = 1;
	break;
      }
    }
    if (optind < argc) host = argv[optind];
    else host = getenv("DISPLAY");

    if (argerr) {
      fprintf(stderr,"Usage: %s [-Tfrko] [-c pno] -u uid [ host:display ]\n",
	      argv[0]);
	exit(1);
    }

    if (debug || oldinetd) {
	    sp = getservbyname("xtrek", "tcp");
	    if (sp == (struct servent *) NULL) {
		fprintf(stderr, "Can't find xtrek service\n");
		exit(1);
	    }
	    xtrekAddress.sin_family = AF_INET;
	    xtrekAddress.sin_addr.s_addr = INADDR_ANY;
	    xtrekAddress.sin_port = sp->s_port;

	    xtrek_socket = socket(AF_INET, SOCK_STREAM, 0);
	    if (xtrek_socket < 0) {
		fprintf(stderr, "Can't open xtrek socket\n");
		perror("socket");
		exit(1);
	    }
	    if (bind(xtrek_socket, &xtrekAddress, sizeof xtrekAddress) < 0) {
		fprintf(stderr, "Can't bind to xtrek address\n");
		perror("bind");
		(void) close(xtrek_socket);
		exit(1);
	    }
    } else {
	    xtrek_socket = 0;
    }
    (void) setsockopt(xtrek_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof on);
    (void) setsockopt(xtrek_socket, SOL_SOCKET, SO_KEEPALIVE, (char *)&on, sizeof on);
    ioctl(xtrek_socket, FIONBIO, (char *) &on);
    if (listen(xtrek_socket, MAXPLAYER) < 0) {
	fprintf(stderr, "Can't listen on xtrek socket\n");
	perror("listen");
	(void) close(xtrek_socket);
	exit(1);
    }

    /* this finds the shared memory information plus a player slot */
    openmem();

    /* The main loop monster! */
    input();
}