Exemple #1
0
int
map_init()
{
	FILE *fp;
	int map_y = 0, map_x = 0;
	fp = fopen(WORKERPATH "/map.dat", "r");
	if (fp == NULL)
		return 0;
	map_x = 0;
	while (1) {
		bzero(genbuf, 80);
		if (fgets(genbuf, 80, fp) <= 0)
			break;
		if (genbuf[0] == '-') {
			map_y = 0;
			map_total++;
		}
		for (map_x = 0; map_x < 30; map_x++) {
			if (!strncmp(genbuf + map_x * 2, map_char(1), 2))
				map_data[map_total - 1][map_y][map_x] = 1;
			if (!strncmp(genbuf + map_x * 2, map_char(2), 2))
				map_data[map_total - 1][map_y][map_x] = 2;
			if (!strncmp(genbuf + map_x * 2, map_char(4), 2))
				map_data[map_total - 1][map_y][map_x] = 4;
			if (!strncmp(genbuf + map_x * 2, map_char(8), 2))
				map_data[map_total - 1][map_y][map_x] = 8;
		}
		if (map_y < 20)
			map_y++;
	}
	fclose(fp);
	return 1;
}
Exemple #2
0
int
map_show_pos(int y, int x)
{
	int c = map_now[y][x];
	move(y, x);
	if (c == 5)
		printf("%2.2s", map_char(c));
	else
		printf("%2.2s", map_char(c));
	return 0;
}
Exemple #3
0
int
map_show()
{
	int m, n;
	clear();
	for (n = 0; n < 20; n++) {
		for (m = 0; m < 30; m++)
			printf("%2.2s", map_char(map_now[n][m]));
		printf("\r\n");
	}
	move(20, 0);
	printf
	    ("                                                                        ");
	move(19, 0);
	printf
	    ("¹¦Äܼü  ¡ü ¡ý ¡û ¡úÒƶ¯  ' ' ^C ^DÍ˳ö  BackSpace»ÚÆå  ^LˢР TABÖØ¿ª\r\n");
	move(now_y, now_x);
	return 0;
}
Exemple #4
0
void
grub_console_putchar (grub_uint32_t c)
{
  grub_console_real_putchar (map_char (c));
}
Exemple #5
0
afs_int32
ka_ParseLoginName(char *login, char name[MAXKTCNAMELEN],
		  char inst[MAXKTCNAMELEN], char cell[MAXKTCREALMLEN])
{
    int login_len = strlen(login);
    char rc, c;
    int i, j;
#define READNAME 1
#define READINST 2
#define READCELL 3
    int reading;

    if (!name)
	return KABADARGUMENT;
    strcpy(name, "");
    if (inst)
	strcpy(inst, "");
    if (cell)
	strcpy(cell, "");
    reading = READNAME;
    i = 0;
    j = 0;
    while (i < login_len) {
	rc = login[i];
	c = map_char(login, &i);
	switch (reading) {
	case READNAME:
	    if (rc == '@') {
		name[j] = 0;	/* finish name */
		reading = READCELL;	/* but instance is null */
		j = 0;
		break;
	    }
	    if (inst && (rc == '.')) {
		name[j] = 0;	/* finish name */
		reading = READINST;
		j = 0;
		break;
	    }
	    if (j >= MAXKTCNAMELEN - 1)
		return KABADNAME;
	    name[j++] = c;
	    break;
	case READINST:
	    if (!inst)
		return KABADNAME;
	    if (rc == '@') {
		inst[j] = 0;	/* finish name */
		reading = READCELL;
		j = 0;
		break;
	    }
	    if (j >= MAXKTCNAMELEN - 1)
		return KABADNAME;
	    inst[j++] = c;
	    break;
	case READCELL:
	    if (!cell)
		return KABADNAME;
	    if (j >= MAXKTCREALMLEN - 1)
		return KABADNAME;
	    cell[j++] = c;
	    break;
	}
	i++;
    }
    if (reading == READNAME)
	name[j] = 0;
    else if (reading == READINST) {
	if (inst)
	    inst[j] = 0;
	else
	    return KABADNAME;
    } else if (reading == READCELL) {
	if (cell)
	    cell[j] = 0;
	else
	    return KABADNAME;
    }

    /* the cell is really an authDomain and therefore is really a realm */
    if (cell)
	ucstring(cell, cell, MAXKTCREALMLEN);
    return 0;
}