Example #1
0
File: pac.c Project: stig/pac
/* As is usual, main() just sets up a few things, then pass over
 * control to a different controlling function */
int main(void)
{
        int retval;
        struct env board;
        struct creature pac;
        struct creature ghost[NUM_GHOSTS];

	printf("This is %s, version %s by Stig Brautaset\n", 
			PACKAGE_NAME, PACKAGE_VERSION);
	printf("Report bugs to %s\n\n", PACKAGE_BUGREPORT);

        if (!read_layout(&board)) 
                return EXIT_FAILURE;

        /* set up our gui things */
        if (!init_gui(board.rows, board.cols)) 
                return EXIT_FAILURE;

        /* initialise the random number generator */
        srand(time(NULL));

        /* main game loop */
        retval = main_game_loop(&board, &pac, ghost, NUM_GHOSTS);

	d2_free_location_proper(board.pos, board.rows, board.cols);
        return EXIT_SUCCESS;
}
Example #2
0
File: btt.c Project: mdalecki/nvml
/*
 * btt_init -- prepare a btt namespace for use, returning an opaque handle
 *
 * Returns handle on success, otherwise NULL/errno.
 *
 * XXX handle case where lbasize doesn't match lbasize found in valid arenas.
 * XXX check rawsize against size from valid arenas.
 * XXX what if write_layout produces something read_layout says is invalid?
 * XXX what if arenas have different nfree?
 */
struct btt *
btt_init(uint64_t rawsize, uint32_t lbasize, uint8_t parent_uuid[],
		int maxlane, void *ns, const struct ns_callback *ns_cbp)
{
	LOG(3, "rawsize %zu lbasize %u", rawsize, lbasize);

	if (rawsize < BTT_MIN_SIZE) {
		LOG(1, "rawsize smaller than BTT_MIN_SIZE %zu", BTT_MIN_SIZE);
		errno = EINVAL;
		return NULL;
	}

	struct btt *bttp = Malloc(sizeof (*bttp));

	if (bttp == NULL) {
		LOG(1, "!Malloc %zu bytes", sizeof (*bttp));
		return NULL;
	}

	memset(bttp, '\0', sizeof (*bttp));

	pthread_mutex_init(&bttp->layout_write_mutex, NULL);
	memcpy(bttp->parent_uuid, parent_uuid, BTTINFO_UUID_LEN);
	bttp->rawsize = rawsize;
	bttp->lbasize = lbasize;
	bttp->ns = ns;
	bttp->ns_cbp = ns_cbp;

	/*
	 * Load up layout, if it exists.
	 *
	 * Whether read_layout() finds a valid layout or not, it finishes
	 * updating these layout-related fields:
	 * 	bttp->nfree
	 * 	bttp->nlba
	 * 	bttp->narena
	 * since these fields are used even before a valid layout it written.
	 */
	if (read_layout(bttp, 0) < 0) {
		btt_fini(bttp);		/* free up any allocations */
		return NULL;
	}

	bttp->nlane = bttp->nfree;

	/* maxlane, if provided, is an upper bound on nlane */
	if (maxlane && bttp->nlane > maxlane)
		bttp->nlane = maxlane;

	LOG(3, "success, bttp %p nlane %d", bttp, bttp->nlane);
	return bttp;
}
Example #3
0
File: 705.cpp Project: waiwai444/oj
int main()
{
	while(scanf("%d%d", &maze.w, &maze.h))
	{
		if(maze.w == 0 && maze.h == 0)
			break;
		memset(maze.s_line, false, sizeof(maze.s_line));
		memset(maze.l_line, false, sizeof(maze.l_line));
		read_layout();
		search();
	}
	return 0;
}
Example #4
0
static int layoutloader (char* filename )
{
    int i;
    //("loading layout inside \n");
    //get default layout name.
    //("size %d : %d \n", spi_layout[0], ARRAY_SIZE(spi_layout));

    read_layout(filename, spi_layout);
    // for( i=0; i<NUM_CANONICAL; i++) {
    //     //("Layout that I read was: index: %d value: %d , valuename: %s \n"
    //      //      ,i, spi_layout[i], CANONICAL_NAMES[i] );
    // }
    //("loadinglayout done\n");
    return 0;

}