Plan 9 from Bell Labs’s /usr/web/sources/contrib/akumar/igo/goban/main.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>
#include <thread.h>
#include <draw.h>
#include <keyboard.h>
#include <mouse.h>
#include <igo.h>
#include <io.h>
#include <chan.h>

extern char goban[Bansz+1][Bansz+1];
int      mainstacksize = 2*Stacksz;

void
usage(void)
{
	fprint(2, "usage: %s [-v] [-r] [-p B|W] [-m mtpt] game\n", argv0);
	exits("usage");
}

void
threadmain(int argc, char **argv)
{
	char *mtpt, *player, *file;
	int ro;

	mtpt=nil;
	player=nil;
	ro=0;
	verbose=0;

	ARGBEGIN {
 	case 'v':
		verbose=1;
		break;
	case 'p':
		player = EARGF(usage());
		break;
	case 'm':
		mtpt = EARGF(usage());
		break;
	case 'r':
		ro=1;
		break;
	default:
		usage();
 	}ARGEND;

	if(argc != 1)
		usage();

	if(player && strcmp(player, "B")
		&& strcmp(player, "W"))
		usage();

	if(!mtpt)
		mtpt = strdup("/n/gofs");

	file = malloc((strlen(mtpt)+1+strlen(argv[0])+3)*sizeof(char));
	sprint(file, "%s/%s/ ", mtpt, argv[0]);	/* whitespace for char */

	ifcchan=chancreate(sizeof(Move*),0);

	keyboardctl = initkeyboard(nil);
	if(keyboardctl == nil)
		sysfatal("initkeyboard");

	mousectl = initmouse(nil, screen);
	if(mousectl == nil)
		sysfatal("initmouse");

	filectl = initfile(file, player, ro);
	if(filectl == nil)
		sysfatal("initfile");

	threadcreate(ifcthread, nil, Stacksz);
	threadcreate(inthread, nil, Stacksz);
	threadexits(0);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.