Exemplo n.º 1
0
bool
fill_cmnd(const char *src, size_t len)
{
    char *dst;
    size_t i;
    debug_decl(fill_cmnd, SUDOERS_DEBUG_PARSER)

    arg_len = arg_size = 0;

    dst = sudoerslval.command.cmnd = malloc(len + 1);
    if (dst == NULL) {
	sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
	sudoerserror(NULL);
	debug_return_bool(false);
    }
    sudoerslval.command.args = NULL;

    /* Copy the string and collapse any escaped sudo-specific characters. */
    for (i = 0; i < len; i++) {
	if (src[i] == '\\' && i != len - 1 && SPECIAL(src[i + 1]))
	    *dst++ = src[++i];
	else
	    *dst++ = src[i];
    }
    *dst = '\0';

    debug_return_bool(true);
}
/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
static inline unsigned int get_secindex(unsigned int shndx,
					unsigned int sym_offs,
					const Elf32_Word *symtab_shndx_start)
{
	if (is_shndx_special(shndx))
		return SPECIAL(shndx);
	if (shndx != SHN_XINDEX)
		return shndx;
	return r(&symtab_shndx_start[sym_offs]);
}
Exemplo n.º 3
0
static PyObject *
CP_getattro(PyObject *self, PyObject *name)
{
    char *cname;

    cname = PyString_AsString(name);
    if (cname == NULL)
        return NULL;

    if (SPECIAL(cname))
        /* delegate to persistent */
        return cPersistenceCAPI->pertype->tp_getattro(self, name);

    /* Use the wrapper version to delegate */
    return wrap_getattro(self, name);
}
Exemplo n.º 4
0
int delete_quest(qst_rnum rnum)
{
  qst_rnum i;
  zone_rnum rznum;
  mob_vnum qm = QST_MASTER(rnum);
  SPECIAL (*tempfunc);
  int  quests_remaining = 0;

  if (rnum >= total_quests)
    return FALSE;
  rznum = real_zone_by_thing(QST_NUM(rnum)); 
  log("GenOLC: delete_quest: Deleting quest #%d (%s).",
       QST_NUM(rnum), QST_NAME(rnum));
  /* make a note of the quest master's secondary spec proc */
  tempfunc = QST_FUNC(rnum);


  free_quest_strings(&aquest_table[rnum]);
  for (i = rnum; i < total_quests - 1; i++) {
    aquest_table[i] = aquest_table[i + 1];
  }
  total_quests--;
  if (total_quests > 0)
    RECREATE(aquest_table, struct aq_data, total_quests);
  else {
    free(aquest_table);
    aquest_table = NULL; 
   }
  if (rznum != NOWHERE)
     add_to_save_list(zone_table[rznum].number, SL_QST);
  else
    mudlog(BRF, ADMLVL_BUILDER, TRUE,
           "SYSERR: GenOLC: Cannot determine quest zone.");
  /* does the questmaster mob have any quests left? */
  if (qm != NOBODY) {
    for (i = 0; i < total_quests; i++) {
      if (QST_MASTER(i) == qm)
        quests_remaining++;
    }
    if (quests_remaining == 0)
      mob_index[qm].func = tempfunc; // point back to original spec proc
  }
  return TRUE;
}
Exemplo n.º 5
0
void
play(Play *play)
{
/* put the pieces on the board,
 * adjust the board data structures.
 */
	int		j;
	Pos		p;
	char	c;

	firstmove = false;

	/* describe the play */
	if(1) {
		print("(%d,%d,%c) %d ",
			play->pos.x, play->pos.y, play->o ? 'V' : 'H', play->score);
		wordprint(&play->word);
		print("\n");
		if(DBG)
			score(&play->word, play->pos, play->o);
	}

	assert(isword(root, &play->word));

	/* place the letters */
	p = play->pos;
	for (j= play->word.n -1; j>= 0; j--) {
		if(!HASLETTER(p)){
			/* place the letter on the board */
			LETTER(p) = play->word.c[j];
			HASLETTER(p)=true;
			SPECIAL(p) = Not;	/* not needed */
			ISANCHOR(p) = false;
			SCORE(p) = play->word.blank[j] ? 0 : points[play->word.c[j]];
			adjust(p,ORTHO(play->o));
		}
		p = PREV(p,play->o);
	}
	p = NEXT(p,play->o);
	adjust(p, play->o);	 /* squares to the sides */
}
Exemplo n.º 6
0
#define SPECIALP(f, P) FTYPE_SPECIAL, 0, P, f
#define SPECIAL(f) SPECIALP(f, NULL)

} tokens[] = {
#ifdef _WIN32
#define CSIDLP(C,P) FTYPE_CSIDL, C, P, _expand_csidl
#define CSIDL(C) CSIDLP(C, NULL)

    {"APPDATA", CSIDL(CSIDL_APPDATA)}, /* Roaming application data (for current user) */
    {"COMMON_APPDATA", CSIDL(CSIDL_COMMON_APPDATA)}, /* Application data (all users) */
    {"LOCAL_APPDATA", CSIDL(CSIDL_LOCAL_APPDATA)}, /* Local application data (for current user) */
    {"SYSTEM", CSIDL(CSIDL_SYSTEM)}, /* Windows System folder (e.g. %WINDIR%\System32) */
    {"WINDOWS", CSIDL(CSIDL_WINDOWS)}, /* Windows folder */
    {"USERCONFIG", CSIDLP(CSIDL_APPDATA, "\\" PACKAGE)}, /* Per user Heimdal configuration file path */
    {"COMMONCONFIG", CSIDLP(CSIDL_COMMON_APPDATA, "\\" PACKAGE)}, /* Common Heimdal configuration file path */
    {"LIBDIR", SPECIAL(_expand_bin_dir)},
    {"BINDIR", SPECIAL(_expand_bin_dir)},
    {"LIBEXEC", SPECIAL(_expand_bin_dir)},
    {"SBINDIR", SPECIAL(_expand_bin_dir)},
#else
    {"LIBDIR", FTYPE_SPECIAL, 0, LIBDIR, _expand_path},
    {"BINDIR", FTYPE_SPECIAL, 0, BINDIR, _expand_path},
    {"LIBEXEC", FTYPE_SPECIAL, 0, LIBEXECDIR, _expand_path},
    {"SBINDIR", FTYPE_SPECIAL, 0, SBINDIR, _expand_path},
#endif
    {"TEMP", SPECIAL(_expand_temp_folder)},
    {"USERID", SPECIAL(_expand_userid)},
    {"uid", SPECIAL(_expand_userid)},
    {"null", SPECIAL(_expand_null)}
};
Exemplo n.º 7
0
void
tds_check_column_extra(const TDSCOLUMN * column)
{
	int size;
	TDSCONNECTION conn;
	int varint_ok;
	int column_varint_size;

	assert(column);
	column_varint_size = column->column_varint_size;

	/* 8 is for varchar(max) or similar */
	assert(column_varint_size == 8 || (column_varint_size <= 5 && column_varint_size != 3));

	assert(column->column_scale <= column->column_prec);
	assert(column->column_prec <= MAXPRECISION);

	/* I don't like this that much... freddy77 */
	if (column->column_type == 0)
		return;
	assert(column->funcs);
	assert(column->column_type > 0);

	/* check type and server type same or SQLNCHAR -> SQLCHAR */
#define SPECIAL(ttype, server_type, varint) \
	if (column->column_type == ttype && column->on_server.column_type == server_type && column_varint_size == varint) {} else
	SPECIAL(SYBTEXT, XSYBVARCHAR, 8)
	SPECIAL(SYBTEXT, XSYBNVARCHAR, 8)
	SPECIAL(SYBIMAGE, XSYBVARBINARY, 8)
	assert(tds_get_cardinal_type(column->on_server.column_type, column->column_usertype) == column->column_type
		|| (tds_get_conversion_type(column->on_server.column_type, column->column_size) == column->column_type
		&& column_varint_size == 1 && is_fixed_type(column->column_type)));

	varint_ok = 0;
	if (column_varint_size == 8) {
		assert(column->on_server.column_type == XSYBVARCHAR || column->on_server.column_type == XSYBVARBINARY || column->on_server.column_type == XSYBNVARCHAR || column->on_server.column_type == SYBMSXML || column->on_server.column_type == SYBMSUDT);
		varint_ok = 1;
	} else if (is_blob_type(column->column_type)) {
		assert(column_varint_size >= 4);
	} else if (column->column_type == SYBVARIANT) {
		assert(column_varint_size == 4);
	}
	conn.tds_version = 0x500;
	varint_ok = varint_ok || tds_get_varint_size(&conn, column->on_server.column_type) == column_varint_size;
	conn.tds_version = 0x700;
	varint_ok = varint_ok || tds_get_varint_size(&conn, column->on_server.column_type) == column_varint_size;
	assert(varint_ok);

	/* check current size <= size */
	if (is_numeric_type(column->column_type)) {
		/* I don't like that much this difference between numeric and not numeric - freddy77 */
		/* TODO what should be the size ?? */
		assert(column->column_prec >= 1 && column->column_prec <= MAXPRECISION);
		assert(column->column_scale <= column->column_prec);
/*		assert(column->column_cur_size == tds_numeric_bytes_per_prec[column->column_prec] + 2 || column->column_cur_size == -1); */
	} else {
		assert(column->column_cur_size <= column->column_size);
	}

	/* check size of fixed type correct */
	size = tds_get_size_by_type(column->column_type);
	assert(size != 0 || column->column_type == SYBVOID);
	if (size >= 0 && column->column_type != SYBBITN) {
		/* check macro */
		assert(is_fixed_type(column->column_type));
		/* check current size */
		if (column->column_type != SYBMSDATE)
			assert(size == column->column_size);
		/* check cases where server need nullable types */
		if (column->column_type != column->on_server.column_type && (column->column_type != SYBINT8 || column->on_server.column_type != SYB5INT8)) {
			assert(!is_fixed_type(column->on_server.column_type));
			assert(column_varint_size == 1);
			assert(column->column_size == column->column_cur_size || column->column_cur_size == -1);
		} else {
			assert(column_varint_size == 0
				|| (column->column_type == SYBUNIQUE && column_varint_size == 1)
				|| (column->column_type == SYBMSDATE  && column_varint_size == 1));
			assert(column->column_size == column->column_cur_size
				|| (column->column_type == SYBUNIQUE && column->column_cur_size == -1)
				|| (column->column_type == SYBMSDATE  && column->column_cur_size == -1));
		}
		assert(column->column_size == column->on_server.column_size);
	} else {
		assert(!is_fixed_type(column->column_type));
		assert(is_char_type(column->column_type) || (column->on_server.column_size == column->column_size || column->on_server.column_size == 0));
		assert(column_varint_size != 0);
	}

	/* check size of nullable types (ie intN) it's supported */
	if (tds_get_conversion_type(column->column_type, 4) != column->column_type) {
		/* check macro */
		assert(is_nullable_type(column->column_type));
		/* check that size it's correct for this type of nullable */
		assert(tds_get_conversion_type(column->column_type, column->column_size) != column->column_type);
		/* check current size */
		assert(column->column_size >= column->column_cur_size || column->column_cur_size == -1);
		/* check same type and size on server */
		assert(column->column_type == column->on_server.column_type);
		assert(column->column_size == column->on_server.column_size);
	}
}
Exemplo n.º 8
0
const struct mips_operand *
decode_mips16_operand (char type, bfd_boolean extended_p)
{
  switch (type)
    {
    case '0': MAPPED_REG (0, 0, GP, reg_0_map);

    case 'L': SPECIAL (6, 5, ENTRY_EXIT_LIST);
    case 'M': SPECIAL (7, 0, SAVE_RESTORE_LIST);
    case 'P': SPECIAL (0, 0, PC);
    case 'R': MAPPED_REG (0, 0, GP, reg_31_map);
    case 'S': MAPPED_REG (0, 0, GP, reg_29_map);
    case 'X': REG (5, 0, GP);
    case 'Y': MAPPED_REG (5, 3, GP, reg32r_map);
    case 'Z': MAPPED_REG (3, 0, GP, reg_m16_map);

    case 'a': JUMP (26, 0, 2);
    case 'e': UINT (11, 0);
    case 'i': JALX (26, 0, 2);
    case 'l': SPECIAL (6, 5, ENTRY_EXIT_LIST);
    case 'm': SPECIAL (7, 0, SAVE_RESTORE_LIST);
    case 'v': MAPPED_REG (3, 8, GP, reg_m16_map);
    case 'w': MAPPED_REG (3, 5, GP, reg_m16_map);
    case 'x': MAPPED_REG (3, 8, GP, reg_m16_map);
    case 'y': MAPPED_REG (3, 5, GP, reg_m16_map);
    case 'z': MAPPED_REG (3, 2, GP, reg_m16_map);
    }

  if (extended_p)
    switch (type)
      {
      case '<': UINT (5, 0);
      case '>': UINT (5, 0);
      case '[': UINT (6, 0);
      case ']': UINT (6, 0);

      case '4': SINT (15, 0);
      case '5': SINT (16, 0);
      case '6': SINT (16, 0);
      case '8': SINT (16, 0);

      case 'A': PCREL (16, 0, TRUE, 0, 2, FALSE, FALSE);
      case 'B': PCREL (16, 0, TRUE, 0, 3, FALSE, FALSE);
      case 'C': SINT (16, 0);
      case 'D': SINT (16, 0);
      case 'E': PCREL (16, 0, TRUE, 0, 2, FALSE, FALSE);
      case 'H': SINT (16, 0);
      case 'K': SINT (16, 0);
      case 'U': UINT (16, 0);
      case 'V': SINT (16, 0);
      case 'W': SINT (16, 0);

      case 'j': SINT (16, 0);
      case 'k': SINT (16, 0);
      case 'p': BRANCH (16, 0, 1);
      case 'q': BRANCH (16, 0, 1);
      }
  else
    switch (type)
      {
      case '<': INT_ADJ (3, 2, 8, 0, FALSE);
      case '>': INT_ADJ (3, 8, 8, 0, FALSE);
      case '[': INT_ADJ (3, 2, 8, 0, FALSE);
      case ']': INT_ADJ (3, 8, 8, 0, FALSE);

      case '4': SINT (4, 0);
      case '5': UINT (5, 0);
      case '6': UINT (6, 5);
      case '8': UINT (8, 0);

      case 'A': PCREL (8, 0, FALSE, 2, 2, FALSE, FALSE);
      case 'B': PCREL (5, 0, FALSE, 3, 3, FALSE, FALSE);
      case 'C': INT_ADJ (8, 0, 255, 3, FALSE);	/* (0 .. 255) << 3 */
      case 'D': INT_ADJ (5, 0, 31, 3, FALSE);	/* (0 .. 31) << 3 */
      case 'E': PCREL (5, 0, FALSE, 2, 2, FALSE, FALSE);
      case 'H': INT_ADJ (5, 0, 31, 1, FALSE);	/* (0 .. 31) << 1 */
      case 'K': INT_ADJ (8, 0, 127, 3, FALSE);	/* (-128 .. 127) << 3 */
      case 'U': UINT (8, 0);
      case 'V': INT_ADJ (8, 0, 255, 2, FALSE);	/* (0 .. 255) << 2 */
      case 'W': INT_ADJ (5, 0, 31, 2, FALSE);	/* (0 .. 31) << 2 */

      case 'j': SINT (5, 0);
      case 'k': SINT (8, 0);
      case 'p': BRANCH (8, 0, 1);
      case 'q': BRANCH (11, 0, 1);
      }
  return 0;
}
Exemplo n.º 9
0
#define SPECIAL(x)      offsetof(struct reg, r_special)         \
                        + offsetof(struct _special, x)

#define HIGH_FP(x)      offsetof(struct fpreg, fpr_high)        \
                        + offsetof(struct _high_fp, x)
#define PRESERVED_FP(x) offsetof(struct fpreg, fpr_preserved)   \
                        + offsetof(struct _callee_saved_fp, x)
#define SCRATCH_FP(x)   offsetof(struct fpreg, fpr_scratch)     \
                        + offsetof(struct _caller_saved_fp, x)

static int regofs[] = {
        /*
	 * General registers (0-127)
	 */
        -1,             /* gr0 */
        SPECIAL(gp),
        SCRATCH(gr2),   SCRATCH(gr3),
        PRESERVED(gr4), PRESERVED(gr5), PRESERVED(gr6), PRESERVED(gr7),
        SCRATCH(gr8),   SCRATCH(gr9),   SCRATCH(gr10),  SCRATCH(gr11),
        SPECIAL(sp),    SPECIAL(tp),
        SCRATCH(gr14),  SCRATCH(gr15),  SCRATCH(gr16),  SCRATCH(gr17),
        SCRATCH(gr18),  SCRATCH(gr19),  SCRATCH(gr20),  SCRATCH(gr21),
        SCRATCH(gr22),  SCRATCH(gr23),  SCRATCH(gr24),  SCRATCH(gr25),
        SCRATCH(gr26),  SCRATCH(gr27),  SCRATCH(gr28),  SCRATCH(gr29),
        SCRATCH(gr30),  SCRATCH(gr31),
        /*
         * gr32 through gr127 are not directly available as they are
         * stacked registers.
         */
        -1, -1, -1, -1, -1, -1, -1, -1,         /* gr32-gr39 */
        -1, -1, -1, -1, -1, -1, -1, -1,         /* gr40-gr47 */
Exemplo n.º 10
0
pass1()
{
	register int c, i, j;
	register DINODE *dp;
	struct zlncnt *zlnp;
	int ndb, partial, cgd;
	struct inodesc idesc;
	ino_t inumber;

	/*
	 * Set file system reserved blocks in used block map.
	 */
	for (c = 0; c < sblock.fs_ncg; c++) {
		cgd = cgdmin(&sblock, c);
		if (c == 0) {
			i = cgbase(&sblock, c);
			cgd += howmany(sblock.fs_cssize, sblock.fs_fsize);
		} else
			i = cgsblock(&sblock, c);
		for (; i < cgd; i++)
			setbmap(i);
	}
	/*
	 * Find all allocated blocks.
	 */
	bzero((char *)&idesc, sizeof(struct inodesc));
	idesc.id_type = ADDR;
	idesc.id_func = pass1check;
	inumber = 0;
	n_files = n_blks = 0;
	for (c = 0; c < sblock.fs_ncg; c++) {
		for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
			if (inumber < ROOTINO)
				continue;
			dp = ginode(inumber);
			if (!ALLOC(dp)) {
				if (bcmp((char *)dp->di_db, (char *)zino.di_db,
					NDADDR * sizeof(daddr_t)) ||
				    bcmp((char *)dp->di_ib, (char *)zino.di_ib,
					NIADDR * sizeof(daddr_t)) ||
				    dp->di_mode || dp->di_size) {
					pfatal("PARTIALLY ALLOCATED INODE I=%u",
						inumber);
					if (reply("CLEAR") == 1) {
						zapino(dp);
						inodirty();
					}
				}
				statemap[inumber] = USTATE;
				continue;
			}
			lastino = inumber;
			if (dp->di_size < 0 ||
			    dp->di_size + sblock.fs_bsize - 1 < 0) {
				if (debug)
					printf("bad size %d:", dp->di_size);
				goto unknown;
			}
			if (!preen && (dp->di_mode & IFMT) == IFMT &&
			    reply("HOLD BAD BLOCK") == 1) {
				dp->di_size = sblock.fs_fsize;
				dp->di_mode = IFREG|0600;
				inodirty();
			}
			ndb = howmany(dp->di_size, sblock.fs_bsize);
			if (SPECIAL(dp))
				ndb++;
			for (j = ndb; j < NDADDR; j++)
				if (dp->di_db[j] != 0) {
					if (debug)
						printf("bad direct addr: %d\n",
							dp->di_db[j]);
					goto unknown;
				}
			for (j = 0, ndb -= NDADDR; ndb > 0; j++)
				ndb /= NINDIR(&sblock);
			for (; j < NIADDR; j++)
				if (dp->di_ib[j] != 0) {
					if (debug)
						printf("bad indirect addr: %d\n",
							dp->di_ib[j]);
					goto unknown;
				}
			if (ftypeok(dp) == 0)
				goto unknown;
			n_files++;
			lncntp[inumber] = dp->di_nlink;
			if (dp->di_nlink <= 0) {
				zlnp = (struct zlncnt *)malloc(sizeof *zlnp);
				if (zlnp == NULL) {
					pfatal("LINK COUNT TABLE OVERFLOW");
					if (reply("CONTINUE") == 0)
						errexit("");
				} else {
					zlnp->zlncnt = inumber;
					zlnp->next = zlnhead;
					zlnhead = zlnp;
				}
			}
			statemap[inumber] = DIRCT(dp) ? DSTATE : FSTATE;
			badblk = dupblk = 0; maxblk = 0;
			idesc.id_number = inumber;
			(void)ckinode(dp, &idesc);
			idesc.id_entryno *= btodb(sblock.fs_fsize);
			if (dp->di_blocks != idesc.id_entryno) {
				pwarn("INCORRECT BLOCK COUNT I=%u (%ld should be %ld)",
				    inumber, dp->di_blocks, idesc.id_entryno);
				if (preen)
					printf(" (CORRECTED)\n");
				else if (reply("CORRECT") == 0)
					continue;
				dp->di_blocks = idesc.id_entryno;
				inodirty();
			}
			continue;
	unknown:
			pfatal("UNKNOWN FILE TYPE I=%u", inumber);
			statemap[inumber] = FCLEAR;
			if (reply("CLEAR") == 1) {
				statemap[inumber] = USTATE;
				zapino(dp);
				inodirty();
			}
		}
	}
}
Exemplo n.º 11
0
const struct mips_operand *
decode_mips16_operand (char type, bfd_boolean extended_p)
{
  switch (type)
    {
    case '.': MAPPED_REG (0, 0, GP, reg_0_map);
    case '>': HINT (5, 22);

    case '0': HINT (5, 0);
    case '1': HINT (3, 5);
    case '2': HINT (3, 8);
    case '3': HINT (5, 16);
    case '4': HINT (3, 21);
    case '6': HINT (6, 5);
    case '9': SINT (9, 0);

    case 'G': SPECIAL (0, 0, REG28);
    case 'L': SPECIAL (6, 5, ENTRY_EXIT_LIST);
    case 'N': REG (5, 0, COPRO);
    case 'O': UINT (3, 21);
    case 'Q': REG (5, 16, HW);
    case 'P': SPECIAL (0, 0, PC);
    case 'R': MAPPED_REG (0, 0, GP, reg_31_map);
    case 'S': MAPPED_REG (0, 0, GP, reg_29_map);
    case 'T': HINT (5, 16);
    case 'X': REG (5, 0, GP);
    case 'Y': MAPPED_REG (5, 3, GP, reg32r_map);
    case 'Z': MAPPED_REG (3, 0, GP, reg_m16_map);

    case 'a': JUMP (26, 0, 2);
    case 'b': BIT (5, 22, 0);			/* (0 .. 31) */
    case 'c': MSB (5, 16, 1, TRUE, 32);		/* (1 .. 32) */
    case 'd': MSB (5, 16, 1, FALSE, 32);	/* (1 .. 32) */
    case 'e': HINT (11, 0);
    case 'i': JALX (26, 0, 2);
    case 'l': SPECIAL (6, 5, ENTRY_EXIT_LIST);
    case 'm': SPECIAL (7, 0, SAVE_RESTORE_LIST);
    case 'n': INT_BIAS (2, 0, 3, 1, 0, FALSE);	/* (1 .. 4) */
    case 'o': INT_ADJ (5, 16, 31, 4, FALSE);	/* (0 .. 31) << 4 */
    case 'r': MAPPED_REG (3, 16, GP, reg_m16_map);
    case 's': HINT (3, 24);
    case 'u': HINT (16, 0);
    case 'v': OPTIONAL_MAPPED_REG (3, 8, GP, reg_m16_map);
    case 'w': OPTIONAL_MAPPED_REG (3, 5, GP, reg_m16_map);
    case 'x': MAPPED_REG (3, 8, GP, reg_m16_map);
    case 'y': MAPPED_REG (3, 5, GP, reg_m16_map);
    case 'z': MAPPED_REG (3, 2, GP, reg_m16_map);
    }

  if (extended_p)
    switch (type)
      {
      case '<': UINT (5, 22);
      case '[': UINT (6, 0);
      case ']': UINT (6, 0);

      case '5': SINT (16, 0);
      case '8': SINT (16, 0);

      case 'A': PCREL (16, 0, TRUE, 0, 2, FALSE, FALSE);
      case 'B': PCREL (16, 0, TRUE, 0, 3, FALSE, FALSE);
      case 'C': SINT (16, 0);
      case 'D': SINT (16, 0);
      case 'E': PCREL (16, 0, TRUE, 0, 2, FALSE, FALSE);
      case 'F': SINT (15, 0);
      case 'H': SINT (16, 0);
      case 'K': SINT (16, 0);
      case 'U': UINT (16, 0);
      case 'V': SINT (16, 0);
      case 'W': SINT (16, 0);

      case 'j': SINT (16, 0);
      case 'k': SINT (16, 0);
      case 'p': BRANCH (16, 0, 1);
      case 'q': BRANCH (16, 0, 1);
      }
  else
    switch (type)
      {
      case '<': INT_ADJ (3, 2, 8, 0, FALSE);
      case '[': INT_ADJ (3, 2, 8, 0, FALSE);
      case ']': INT_ADJ (3, 8, 8, 0, FALSE);

      case '5': UINT (5, 0);
      case '8': UINT (8, 0);

      case 'A': PCREL (8, 0, FALSE, 2, 2, FALSE, FALSE);
      case 'B': PCREL (5, 0, FALSE, 3, 3, FALSE, FALSE);
      case 'C': INT_ADJ (8, 0, 255, 3, FALSE);	/* (0 .. 255) << 3 */
      case 'D': INT_ADJ (5, 0, 31, 3, FALSE);	/* (0 .. 31) << 3 */
      case 'E': PCREL (5, 0, FALSE, 2, 2, FALSE, FALSE);
      case 'F': SINT (4, 0);
      case 'H': INT_ADJ (5, 0, 31, 1, FALSE);	/* (0 .. 31) << 1 */
      case 'K': INT_ADJ (8, 0, 127, 3, FALSE);	/* (-128 .. 127) << 3 */
      case 'U': UINT (8, 0);
      case 'V': INT_ADJ (8, 0, 255, 2, FALSE);	/* (0 .. 255) << 2 */
      case 'W': INT_ADJ (5, 0, 31, 2, FALSE);	/* (0 .. 31) << 2 */

      case 'j': SINT (5, 0);
      case 'k': SINT (8, 0);
      case 'p': BRANCH (8, 0, 1);
      case 'q': BRANCH (11, 0, 1);
      }
  return 0;
}
Exemplo n.º 12
0
#include "keys.h"
#include "vterm_input.h"
#include "stdlib.h"
kbstate_t keyboard;
#define NOKEY       { .type = KEY_NONE }
#define ASCII(l,u)  { .type = KEY_ASCII,   .v = { .ascii = { .lower = l, .upper = u } } }
#define SPECIAL(s)  { .type = KEY_SPECIAL, .v = { .value = s } }
#define MODIFIER(m) { .type = KEY_MOD,     .v = { .modifier = m } }
/* See also  http://www.quadibloc.com/comp/scan.htm  */
static key_t keys[] = {
    NOKEY,
    /* First row: 0x01 - 0x0e */
    SPECIAL(VTERM_KEY_ESCAPE),
    ASCII('1','!'),
    ASCII('2','@'),
    ASCII('3','#'),
    ASCII('4','$'),
    ASCII('5','%'),
    ASCII('6','^'),
    ASCII('7','&'),
    ASCII('8','*'),
    ASCII('9','('),
    ASCII('0',')'),
    ASCII('-','_'),
    ASCII('=','+'),
    SPECIAL(VTERM_KEY_BACKSPACE),
    /* Second row: 0x0f - 0x1c */
    SPECIAL(VTERM_KEY_TAB),
    ASCII('q','Q'),
    ASCII('w','W'),
    ASCII('e','E'),
Exemplo n.º 13
0
void
tds_check_column_extra(const TDSCOLUMN * column)
{
	int size;
	TDSCONNECTION conn;
	int varint_ok;
	int column_varint_size;

	assert(column);
	column_varint_size = column->column_varint_size;

	/* 8 is for varchar(max) or similar */
	assert(column_varint_size == 8 || (column_varint_size <= 5 && column_varint_size != 3));

	assert(column->column_scale <= column->column_prec);
	assert(column->column_prec <= MAXPRECISION);

	/* I don't like this that much... freddy77 */
	if (column->column_type == 0)
		return;
	assert(column->funcs);
	assert(column->column_type > 0);

	/* specific checks, if true fully checked */
	if (column->funcs->check(column))
		return;

	/* check type and server type same or SQLNCHAR -> SQLCHAR */
#define SPECIAL(ttype, server_type, varint) \
	if (column->column_type == ttype && column->on_server.column_type == server_type && column_varint_size == varint) {} else
	SPECIAL(SYBTEXT, XSYBVARCHAR, 8)
	SPECIAL(SYBTEXT, XSYBNVARCHAR, 8)
	SPECIAL(SYBIMAGE, XSYBVARBINARY, 8)
	assert(tds_get_cardinal_type(column->on_server.column_type, column->column_usertype) == column->column_type
		|| (tds_get_conversion_type(column->on_server.column_type, column->column_size) == column->column_type
		&& column_varint_size == 1 && is_fixed_type(column->column_type)));

	varint_ok = 0;
	if (column_varint_size == 8) {
		if (column->on_server.column_type == XSYBVARCHAR
		    || column->on_server.column_type == XSYBVARBINARY
		    || column->on_server.column_type == XSYBNVARCHAR)
			varint_ok = 1;
	} else if (is_blob_type(column->column_type)) {
		assert(column_varint_size >= 4);
	} else if (column->column_type == SYBVARIANT) {
		assert(column_varint_size == 4);
	}
	conn.tds_version = 0x500;
	varint_ok = varint_ok || tds_get_varint_size(&conn, column->on_server.column_type) == column_varint_size;
	conn.tds_version = 0x700;
	varint_ok = varint_ok || tds_get_varint_size(&conn, column->on_server.column_type) == column_varint_size;
	assert(varint_ok);

	assert(!is_numeric_type(column->column_type));
	assert(column->column_cur_size <= column->column_size);

	/* check size of fixed type correct */
	size = tds_get_size_by_type(column->column_type);
	assert(size != 0 || column->column_type == SYBVOID);
	/* these peculiar types are variable but have only a possible size */
	if (size >= 0 && (column->column_type != SYBBITN
		  && column->column_type != SYBDATEN && column->column_type != SYBTIMEN)) {
		/* check macro */
		assert(is_fixed_type(column->column_type));
		/* check current size */
		assert(size == column->column_size);
		/* check cases where server need nullable types */
		if (column->column_type != column->on_server.column_type && (column->column_type != SYBINT8 || column->on_server.column_type != SYB5INT8)) {
			assert(!is_fixed_type(column->on_server.column_type));
			assert(column_varint_size == 1);
			assert(column->column_size == column->column_cur_size || column->column_cur_size == -1);
		} else {
			assert(column_varint_size == 0
				|| (column->column_type == SYBUNIQUE && column_varint_size == 1));
			assert(column->column_size == column->column_cur_size
				|| (column->column_type == SYBUNIQUE && column->column_cur_size == -1));
		}
		assert(column->column_size == column->on_server.column_size);
	} else {
		assert(!is_fixed_type(column->column_type));
		assert(is_char_type(column->column_type) || (column->on_server.column_size == column->column_size || column->on_server.column_size == 0));
		assert(column_varint_size != 0);
	}

	/* check size of nullable types (ie intN) it's supported */
	if (tds_get_conversion_type(column->column_type, 4) != column->column_type) {
		/* check macro */
		assert(is_nullable_type(column->column_type));
		/* check that size it's correct for this type of nullable */
		assert(tds_get_conversion_type(column->column_type, column->column_size) != column->column_type);
		/* check current size */
		assert(column->column_size >= column->column_cur_size || column->column_cur_size == -1);
		/* check same type and size on server */
		assert(column->column_type == column->on_server.column_type);
		assert(column->column_size == column->on_server.column_size);
	}
}
Exemplo n.º 14
0
    const char * tok;
    int ftype;
#define FTYPE_CSIDL 0
#define FTYPE_SPECIAL 1

    PTYPE param;
    const char * postfix;

    int (*exp_func)(krb5_context, PTYPE, const char *, char **);

#define SPECIALP(f, P) FTYPE_SPECIAL, 0, P, f
#define SPECIAL(f) SPECIALP(f, NULL)

} tokens[] = {
#ifdef __APPLE__
    {"ApplicationResources", SPECIAL(_expand_resources) },
    {"IPHONE_SIMULATOR_ROOT", SPECIALP(_expand_env, "IPHONE_SIMULATOR_ROOT") },
#endif
#ifdef _WIN32
#define CSIDLP(C,P) FTYPE_CSIDL, C, P, _expand_csidl
#define CSIDL(C) CSIDLP(C, NULL)

    {"APPDATA", CSIDL(CSIDL_APPDATA)}, /* Roaming application data (for current user) */
    {"COMMON_APPDATA", CSIDL(CSIDL_COMMON_APPDATA)}, /* Application data (all users) */
    {"LOCAL_APPDATA", CSIDL(CSIDL_LOCAL_APPDATA)}, /* Local application data (for current user) */
    {"SYSTEM", CSIDL(CSIDL_SYSTEM)}, /* Windows System folder (e.g. %WINDIR%\System32) */
    {"WINDOWS", CSIDL(CSIDL_WINDOWS)}, /* Windows folder */
    {"USERCONFIG", CSIDLP(CSIDL_APPDATA, "\\" PACKAGE)}, /* Per user Heimdal configuration file path */
    {"COMMONCONFIG", CSIDLP(CSIDL_COMMON_APPDATA, "\\" PACKAGE)}, /* Common Heimdal configuration file path */
    {"LIBDIR", SPECIAL(_expand_bin_dir)},
    {"BINDIR", SPECIAL(_expand_bin_dir)},
Exemplo n.º 15
0
bool checkcheck_b (TFastNode* node, int move) 
{ //check if black move checked white king
	char offset,	
		offset_ssq_tsq;

        unsigned char piece,
                csq,
                sq;
        
	if (!SPECIAL (move)) {
		piece = PIECE (move);
		sq = TARGETSQ (move);
		if (!t.pieceattacks [piece] [node->wkpos] [sq]) {		       
			goto AFTREKSCHAAK;
		}
		if (piece < BISHOP) {
			return true;
		}	
		// check if no piece in between
		offset = t.direction [sq] [node->wkpos];
		sq += offset;		
		while (sq != node -> wkpos) {
			if (node->matrix [sq]) {				
				goto AFTREKSCHAAK;
			}			
			sq += offset;
		}		
		return true;		
	} else {
		switch (SPECIALCASE (move)) {
		case _EN_PASSANT:
			sq = TARGETSQ (move);
			if (t.pieceattacks [PAWN] [node->wkpos] [sq]) {
				return true;
			}
			csq = sq + 8;
			offset = t.direction [node -> wkpos] [csq];
			if (offset) {
				sq = node -> wkpos + offset;
				if (node -> matrix [sq]) {
					break;
				}
				sq = t.sqonline [node->wkpos] [sq];
				while (sq != node -> wkpos) {				
					BOOST_ASSERT (sq >= 0 && sq <= 63);
					piece = node -> matrix [sq];
					if (piece) {
						if (piece > BKNIGHT && t.pieceattacks [piece - KING] [sq] [node->wkpos]) {
							return true;
						}
						goto AFTREKSCHAAK;
					}
					sq = t.sqonline [node -> wkpos] [sq];
				}
			}
			break;
		case _QUEEN_PROMOTION:
			sq = TARGETSQ (move);
			if (!t.pieceattacks [QUEEN] [sq] [node->wkpos]) {
				goto AFTREKSCHAAK;
			}
			offset = t.direction [sq] [node->wkpos];
			sq += offset;
			while (sq != node->wkpos) {
				piece = node -> matrix [sq];
				if (piece) {
					goto AFTREKSCHAAK;
				}
				sq += offset;
			}
			return true;
		case _SHORT_CASTLE:
			if (!t.pieceattacks [ROOK] [f8] [node->wkpos]) {
				return false;
			}
			offset = t.direction [f8] [node->wkpos];
			sq = f8 + offset;
			do {
				if (node->matrix [sq]) {
					return false;
				}
				sq += offset;
			} while (sq != node->wkpos);
			return true;		       
		case _LONG_CASTLE:
			 if (!t.pieceattacks [ROOK] [d8] [node->wkpos]) {
				return false;
			}
			offset = t.direction [d8] [node->wkpos];
			sq = d8 + offset;
			do {
				if (node->matrix [sq]) {
					return false;
				}
				sq += offset;
			} while (sq != node->wkpos);
			return true;		     		
		case _ROOK_PROMOTION:
			sq = TARGETSQ (move);
			if (!t.pieceattacks [ROOK] [sq] [node->wkpos]) {
				goto AFTREKSCHAAK;
			}
			offset = t.direction [sq] [node->wkpos];
			sq += offset;
			while (sq != node->wkpos) {
				piece = node -> matrix [sq];
				if (piece) {
					goto AFTREKSCHAAK;
				}
				sq += offset;
			}
			return true;
		case _BISHOP_PROMOTION:
			sq = TARGETSQ (move);
			if (!t.pieceattacks [BISHOP] [sq] [node->wkpos]) {
				goto AFTREKSCHAAK;
			}
			offset = t.direction [sq] [node->wkpos];
			sq += offset;
			while (sq != node->wkpos) {
				piece = node -> matrix [sq];
				if (piece) {
					goto AFTREKSCHAAK;
				}
				sq += offset;
			}
			return true;
			
		case _KNIGHT_PROMOTION:
			sq = TARGETSQ (move);
			if (!t.pieceattacks [KNIGHT] [sq] [node->wkpos]) {
				goto AFTREKSCHAAK;
			}			
			return true;

		case _PLUNKMOVE:
			piece = PIECE (move);
			sq = TARGETSQ (move);
			if (!t.pieceattacks [piece] [node->wkpos] [sq]) {		       
				return false;
			}
			if (piece < BISHOP) {
				return true;
			}	
			// check if no piece in between
			offset = t.direction [sq] [node->wkpos];
			sq += offset;		
			while (sq != node -> wkpos) {
				if (node->matrix [sq]) {				
					return false;
				}			
				sq += offset;
			}		
			return true;		
		}
	}
	
 AFTREKSCHAAK:	
	sq = SOURCESQ (move);	
	offset = t.direction [node->wkpos] [sq];
	if (!offset) {
		return false;
	}
	offset_ssq_tsq = t.direction [sq] [TARGETSQ (move)];	
	if ((offset_ssq_tsq == offset) || (offset_ssq_tsq == (- offset))) {
		return false;
	}
       	sq = node -> wkpos + offset;
	if (node -> matrix [sq]) {
		return false;
	}	
	sq = t.sqonline [node -> wkpos] [sq];
	while (sq != node -> wkpos) {
		piece = node->matrix [sq];
		if (piece) {
			return piece > BKNIGHT && t.pieceattacks [piece - KING] [sq] [node->wkpos];
		}
		sq = t.sqonline [node -> wkpos] [sq];
	}
	return false;	
}