Esempio n. 1
0
size_t unpack_dirname(char * to, const char *from)
{
  size_t length, h_length;
  char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion;
  DBUG_ENTER("unpack_dirname");

  length= normalize_dirname(buff, from);

  if (buff[0] == FN_HOMELIB)
  {
    suffix=buff+1; tilde_expansion=expand_tilde(&suffix);
    if (tilde_expansion)
    {
      length-= (size_t) (suffix-buff)-1;
      if (length+(h_length= strlen(tilde_expansion)) <= FN_REFLEN)
      {
	if ((h_length > 0) && (tilde_expansion[h_length-1] == FN_LIBCHAR))
	  h_length--;
	if (buff+h_length < suffix)
	  bmove(buff+h_length,suffix,length);
	else
	  bmove_upp((uchar*) buff+h_length+length, (uchar*) suffix+length, length);
	bmove(buff,tilde_expansion,h_length);
      }
    }
  }
#ifdef USE_SYMDIR
  if (my_use_symdir)
    symdirget(buff);
#endif
  DBUG_RETURN(system_filename(to,buff));	/* Fix for open */
} /* unpack_dirname */
Esempio n. 2
0
	static void /* convert columns to power series */
cols(projUV **c, projUV **d, int nu, int nv) {
	projUV *sv, **dd;
	int j, k;

	dd = (projUV **)vector2(nu, nv, sizeof(projUV));
	sv = (projUV *)vector1(nv, sizeof(projUV));
	bclear(d, nu, nv);
	bclear(dd, nu, nv);
	bmove(d[0], c[nu-1], nv);
	for (j = nu-2; j >= 1; --j) {
		for (k = nu-j; k >= 1; --k) {
			bmove(sv, d[k], nv);
			submop(d[k], 2., d[k-1], dd[k], nv);
			bmove(dd[k], sv, nv);
		}
		bmove(sv, d[0], nv);
		subop(d[0], c[j], dd[0], nv);
		bmove(dd[0], sv, nv);
	}
	for (j = nu-1; j >= 1; --j)
		subop(d[j], d[j-1], dd[j], nv);
	submop(d[0], .5, c[0], dd[0], nv);
	freev2((void **) dd, nu);
	pj_dalloc(sv);
}
Esempio n. 3
0
/** Go forward or back to a thingy. See bistoken() for an example
 * thingy predicate function.
 * @param buff The buffer to move in.
 * @param pred The thingy function.
 * @param forward 1 to move forward, 0 to move backward.
 */
void bmoveto(struct buff *buff, int (*pred)(int), int forward)
{
	if (forward)
		while (!bisend(buff) && !pred(*buff->curcptr))
			bmove1(buff);
	else {
		bmove(buff, -1);
		while (!bisstart(buff) && !pred(*buff->curcptr))
			bmove(buff, -1);
		if (!bisstart(buff))
			bmove1(buff);
	}
}
Esempio n. 4
0
/*
**	Coerce the top of stack symbol to the
**	specified type and length. If the current
**	value is a character then it must be converted
**	to numeric. A user error will occure is the
**	char is not syntaxtically correct.
*/
void
typecoerce(sym_t *tosx, int ntype, int nlen)
{
	register sym_t	*tos;
	register char	*cp;
	register int	*val;
	int		ret;
	char		temp[256];

	ret = 0;
	tos = tosx;

	if (tos->type == CHAR_CONST) {
		val = (int *) &tos->value.sym_data;
		cp = temp;
		bmove(tos->value.sym_data.cptype, cp, tos->len & I1MASK);
		cp[tos->len & I1MASK] = '\0';
		if (ntype == FLOAT_CONST)
			ret = ingres_atof(cp, val);
		else {
			if (nlen == 4)
				ret = ingres_atol(cp, val);
			else
				*val = atoi(cp);
		}
		if (ret < 0)
			ov_err(CHARCONVERT);
		tos->type = ntype;
		tos->len = nlen;
	}
	else
		rcvt(tos, ntype, nlen);
}
Esempio n. 5
0
/** Write to a file descriptor using writev.  Can be used for files but
 * meant for sockets. Leaves the point at the end of the write.
 * @param buff The buffer to read from.
 * @param fd The open file descriptor to write to.
 * @param size The number of bytes to write.
 * @return The number of bytes actually written.
 */
int bwritev(struct buff *buff, int fd, unsigned size)
{
	struct iovec iovs[MAX_IOVS];
	struct page *pg;
	int i, n, amount, did = 0;

	do {
		unsigned have = curplen(buff) - buff->curchar;

		iovs[0].iov_base = buff->curcptr;
		iovs[0].iov_len = MIN(have, size);
		size -= iovs[0].iov_len;
		amount = iovs[0].iov_len;

		for (pg = buff->curpage->nextp, i = 1;
			 i < MAX_IOVS && size > 0 && pg;
			 ++i, pg = pg->nextp) {
			iovs[i].iov_base = pg->pdata;
			iovs[i].iov_len = MIN(pg->plen, size);
			size -= iovs[i].iov_len;
			amount += iovs[i].iov_len;
		}

		do
			n = writev(fd, iovs, i);
		while (n < 0 && errno == EINTR);

		if (n > 0) {
			bmove(buff, n);
			did += n;
		}
	} while (n == amount && size > 0);

	return did;
}
Esempio n. 6
0
bagen()
{
	int *p1, *p2, v;

	p1 = lmp;
	if((flag&010)!=0)
	if(board[5]==0 && board[6]==0 && board[7]==4)
	if(wattack(4) && wattack(5) && wattack(6))
		btry(4, 0, 2); /* kingside castle */
	if((flag&020)!=0)
	if(board[0]==4 && board[1]==0 && board[2]==0 && board[3]==0)
	if(wattack(2) && wattack(3) && wattack(4))
		btry(4, 0, -2); /* queenside castle */
	bgen();
	p2 = p1;
	while(p2 != lmp) {
		v = *p2++;
		bmove(*p2);
		if(wattack(bkpos)) {
			*p1++ = v;
			*p1++ = *p2;
		}
		p2++;
		bremove();
	}
	lmp = p1;
}
Esempio n. 7
0
File: test2.c Progetto: OPSF/uClinux
static void put_blob_in_record(char *blob_pos, char **blob_buffer)
{
  ulong i,length;
  if (use_blob)
  {
    if (rnd(10) == 0)
    {
      if (! *blob_buffer &&
	  !(*blob_buffer=my_malloc((uint) use_blob,MYF(MY_WME))))
      {
	use_blob=0;
	return;
      }
      length=rnd(use_blob);
      for (i=0 ; i < length ; i++)
	(*blob_buffer)[i]=(char) (length+i);
      longstore(blob_pos,length);
      bmove(blob_pos+4,(char*) blob_buffer,sizeof(char*));
    }
    else
    {
      longstore(blob_pos,0);
    }
  }
  return;
}
Esempio n. 8
0
void
killk(int ix, int iy)
{
	int		i;

	printf("   *** Klingon at %d,%d destroyed ***\n", ix, iy);

	/* remove the scoundrel */
	Now.klings -= 1;
	Sect[ix][iy] = EMPTY;
	Quad[Ship.quadx][Ship.quady].klings -= 1;
	/* %%% IS THIS SAFE???? %%% */
	Quad[Ship.quadx][Ship.quady].scanned -= 100;
	Game.killk += 1;

	/* find the Klingon in the Klingon list */
	for (i = 0; i < Etc.nkling; i++)
		if (ix == Etc.klingon[i].x && iy == Etc.klingon[i].y) {
			/* purge him from the list */
			Etc.nkling -= 1;
			for (; i < Etc.nkling; i++)
				bmove(&Etc.klingon[i+1], &Etc.klingon[i], sizeof Etc.klingon[i]);
			break;
		}

	/* find out if that was the last one */
	if (Now.klings <= 0)
		win();

	/* recompute time left */
	Now.time = Now.resource / Now.klings;
	return;
}
Esempio n. 9
0
int bsave(char *nom,void *adr,long offset,long len)
{
	void *buffer;
	long filesize;
	HMMIO fp;
	int r= -1;

	char nom2[200];
	verifnom(nom,nom2);
	fp = mmioOpen(nom2,NULL,MMIO_READ);
	if (fp)
	{
		r=0;
		filesize = mmioSeek(fp, 0L, SEEK_END);
		mmioClose(fp,NULL);

		if (!r)
		{
			r= -1;
			buffer=memalloc(filesize);
			if (buffer)
			{
				if (!bload(nom,buffer,0L,filesize))
				{
                                	bmove(adr,(char *)buffer+offset,len);
					r=bmake(nom,buffer,filesize);
				}
				memfree((void **)&buffer);
			}
		}
	}

	return(r);
}
Esempio n. 10
0
File: test2.c Progetto: OPSF/uClinux
static void fix_length( byte *rec, uint length)
{
  bmove(rec+STANDAR_LENGTH,
	"0123456789012345678901234567890123456789012345678901234567890",
	length-STANDAR_LENGTH);
  strfill(rec+length,STANDAR_LENGTH+60-length,' ');
} /* fix_length */
Esempio n. 11
0
/** This is an implementation of the Boyer-Moore Search.
 * It uses the delta1 only with the fast/slow loops.
 * It searches for the string 'str' starting at the current buffer location.
 * If sensitive is 0, then the match is case insensitive.
 * The point is left at the byte after the search str.
 * @param buff The buffer to search in.
 * @param str The string to search for.
 * @param sensitive Should the search be case sensitive?
 * @return 1 if string found, 0 if not.
 */
int bm_search(struct buff *buff, const char *str, int sensitive)
{
	int delta[NUMASCII], len, i, shift;

	len = strlen(str) - 1;

	/* Init the delta table to str length.  For each char in the
	 * str, store the offset from the str start in the delta
	 * table.  If we are in case insensitive mode - lower case the
	 * match string and mark both the upper case version and the
	 * lower case version of the match string chars in the delta
	 * array.
	 */
	for (i = 0; i < NUMASCII; ++i)
		delta[i] = len ? len : 1;
	if (sensitive)
		for (i = 0; i <= len;  ++i)
			delta[(uint8_t)str[i]] = len - i;
	else
		for (i = 0; i <= len;  ++i) {
			delta[toupper(str[i])] = len - i;
			delta[tolower(str[i])] = len - i;
		}

	/* search forward*/
	while (!bisend(buff)) {
		/* fast loop - delta will be 0 if matched */
		while (!bisend(buff) && delta[buffint()])
			bmove(buff, delta[buffint()]);
		/* slow loop */
		for (i = len;
			 bequal(buff, str[i], sensitive);
			 bmove(buff, -1), --i)
			if (i == 0) {
				bmove(buff, len + 1);
				return 1;
			}
		/* compute shift. shift must be forward! */
		if (i + delta[buffint()] > len)
			shift = delta[buffint()];
		else
			shift = len - i + 1;
		bmove(buff, shift);
	}

	return 0;
}
Esempio n. 12
0
int
main(int argc, char **argv)
{
     _i18n_init(I18N_CAT_MIN);

    bmove(argc, argv, TO_BOTTOM);
    return 0;
}
Esempio n. 13
0
int
icompare(char *ax, char *bx, char frmt, char frml)
{
	register ANYTYPE	*a, *b;
	register int		length;
	ANYTYPE			atemp, btemp;

	length = frml & I1MASK;
	if (frmt == CHAR_CONST)
		return (scompare(ax, length, bx, length));
	a = &atemp;
	b = &btemp;
	bmove(ax, (char *) a, length);
	bmove(bx, (char *) b, length);
	if (bequal((char *) a, (char *) b, length))
		return (0);
	switch (frmt) {
	  case INT_CONST:
		switch (length) {
		  case 1:
			return (a->i1type - b->i1type);
		  case 2:
			return (a->i2type - b->i2type);
		  case 4:
			return (a->i4type > b->i4type ? 1 : -1);
		}
		break;

	  case FLOAT_CONST:
		if (frml == 4) {
			if ( a->f4type > b->f4type )
				return ( 1 );
			else
				return ( -1 );
		} else {
			if ( a->f8type > b->f8type )
				return ( 1 );
			else
				return ( -1 );
		}
		break;
	}
	syserr("compare: t=%d,l=%d", frmt, frml);
	/*NOTREACHED*/
	return(-1);
}
Esempio n. 14
0
void bchange(register char *dst, uint old_length, register const char *src, uint new_length, uint tot_length)
{
  uint rest=tot_length-old_length;
  if (old_length < new_length)
    bmove_upp(dst+rest+new_length,dst+tot_length,rest);
  else
    bmove(dst+new_length,dst+old_length,rest);
  memcpy(dst,src,new_length);
}
Esempio n. 15
0
checkflags(int *argc, char **argv)
{
	register char	*cp, **nargv;
	register int	cnt;
	int		ret;

	ret = 0;
	cnt = *argc;
	nargv = argv;
	while (cnt--) {
		cp = *argv++;
		if (*cp == '-') {
			(*argc)--;
			cp++;
			switch (*cp++) {

			  case 's':
				timezone = atoi(cp);
				break;

			  case 't':
				bmove(cp, tzname[0], 3);
				bmove(cp+3, tzname[1], 3);
				break;

			  case 'd':
				daylight = atoi(cp);
				break;

			  case 'u':
				Noupdate++;
				break;

			  default:
				printf("bad flag %s\n", cp - 2);
				ret = -1;
			}
		}
		else
			*nargv++ = cp;
	}

	return (ret);
}
Esempio n. 16
0
/** This is an implementation of the Boyer-Moore Search that searches backwards.
 * It uses the delta1 only with the fast/slow loops.
 * It searches for the string 'str' starting at the current buffer location.
 * If sensitive is 0, then the match is case insensitive.
 * The point is left at the start of the search str.
 * @param buff The buffer to search in.
 * @param str The string to search backwards for.
 * @param sensitive Should the search be case sensitive?
 * @return 1 if string found, 0 if not.
 */
int bm_rsearch(struct buff *buff, const char *str, int sensitive)
{
	int delta[NUMASCII], len, i, shift;

	len = strlen(str) - 1;

	/* Init the delta table to str length.  For each char in the
	 * str, store the negative offset from the str start in the
	 * delta table.
	 */
	for (i = 0; i < NUMASCII; ++i)
		delta[i] = len ? -len : -1;
	if (sensitive)
		for (i = len; i >= 0; --i)
			delta[(uint8_t)str[i]] = -i;
	else
		for (i = len; i >= 0; --i) {
			delta[toupper(str[i])] = -i;
			delta[tolower(str[i])] = -i;
		}

	/* reverse search */
	bmove(buff, -len);
	while (!bisstart(buff)) {
		/* fast loop - delta will be 0 if matched */
		while (delta[buffint()] && !bisstart(buff))
			bmove(buff, delta[buffint()]);
		/* slow loop */
		for (i = 0;
			 i <= len && bequal(buff, str[i], sensitive);
			 ++i, bmove1(buff))
			;
		if (i > len) {
			/* we matched! */
			bmove(buff, -len - 1);
			return 1;
		}
		/* compute shift. shift must be backward! */
		shift = delta[buffint()] + i < 0 ? delta[buffint()] : -i - 1;
		bmove(buff, shift);
	}

	return 0;
}
Esempio n. 17
0
void bchange(register uchar *dst, size_t old_length, register const uchar *src,
	     size_t new_length, size_t tot_length)
{
  size_t rest=tot_length-old_length;
  if (old_length < new_length)
    bmove_upp(dst+rest+new_length,dst+tot_length,rest);
  else
    bmove(dst+new_length,dst+old_length,rest);
  memcpy(dst,src,new_length);
}
Esempio n. 18
0
uint unpack_dirname(my_string to, const char *from)
{
  uint length,h_length;
  char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion;
  DBUG_ENTER("unpack_dirname");

  (void) intern_filename(buff,from);		/* Change to intern name */
  length= (uint) strlen(buff);			/* Fix that '/' is last */
  if (length &&
#ifdef FN_DEVCHAR
      buff[length-1] != FN_DEVCHAR &&
#endif
      buff[length-1] != FN_LIBCHAR && buff[length-1] != '/')
  {
    buff[length]=FN_LIBCHAR;
    buff[length+1]= '\0';
  }

  length=cleanup_dirname(buff,buff);
  if (buff[0] == FN_HOMELIB)
  {
    suffix=buff+1; tilde_expansion=expand_tilde(&suffix);
    if (tilde_expansion)
    {
      length-=(uint) (suffix-buff)-1;
      if (length+(h_length= (uint) strlen(tilde_expansion)) <= FN_REFLEN)
      {
	if (tilde_expansion[h_length-1] == FN_LIBCHAR)
	  h_length--;
	if (buff+h_length < suffix)
	  bmove(buff+h_length,suffix,length);
	else
	  bmove_upp(buff+h_length+length,suffix+length,length);
	bmove(buff,tilde_expansion,h_length);
      }
    }
  }
#ifdef USE_SYMDIR
  if (my_use_symdir)
    symdirget(buff);
#endif
  DBUG_RETURN(system_filename(to,buff));	/* Fix for open */
} /* unpack_dirname */
Esempio n. 19
0
static char *process_int_arg(char *to, char *end, size_t length,
                             longlong par, char arg_type, uint print_type)
{
  size_t res_length, to_length;
  char *store_start= to, *store_end;
  char buff[32];

  if ((to_length= (size_t) (end-to)) < 16 || length)
    store_start= buff;

  if (arg_type == 'd' || arg_type == 'i')
    store_end= longlong10_to_str(par, store_start, -10);
  else if (arg_type == 'u')
    store_end= longlong10_to_str(par, store_start, 10);
  else if (arg_type == 'p')
  {
    store_start[0]= '0';
    store_start[1]= 'x';
    store_end= ll2str(par, store_start + 2, 16, 0);
  }
  else if (arg_type == 'o')
  {
    store_end= ll2str(par, store_start, 8, 0);
  }
  else
  {
    DBUG_ASSERT(arg_type == 'X' || arg_type =='x');
    store_end= ll2str(par, store_start, 16, (arg_type == 'X'));
  }

  if ((res_length= (size_t) (store_end - store_start)) > to_length)
    return to;                           /* num doesn't fit in output */
  /* If %#d syntax was used, we have to pre-zero/pre-space the string */
  if (store_start == buff)
  {
    length= min(length, to_length);
    if (res_length < length)
    {
      size_t diff= (length- res_length);
      bfill(to, diff, (print_type & PREZERO_ARG) ? '0' : ' ');
      if (arg_type == 'p' && print_type & PREZERO_ARG)
      {
        if (diff > 1)
          to[1]= 'x';
        else
          store_start[0]= 'x';
        store_start[1]= '0';
      }
      to+= diff;
    }
    bmove(to, store_start, res_length);
  }
  to+= res_length;
  return to;
}
Esempio n. 20
0
static void initscreen()
{
	int i;

	gfxbase=(long)OpenLibrary("graphics.library",0L);
	oldcoplist=*(long *)(gfxbase+38L);

	bigbloc=pt_ecran_actif=(long)memalloc(64000L);
	pt_ecran_travail=bigbloc+32000L;

	for(i=0;i<4;i++)
	{	
		copperlist.bitp[1+i*4]=(pt_ecran_actif+i*8000L)>>16;
		copperlist.bitp[3+i*4]=(pt_ecran_actif+i*8000L)&0xffff;
	}	
	for(i=0;i<8;i++)
	{
		copperlist.ispr[1+i*4]=silence>>16;
		copperlist.ispr[3+i*4]=silence&0xffff;
	}


	chipspr=(long)memalloc((long)sizeof(struct sprlist));
	sprite=(struct sprlist *)chipspr;
	copperlist.ispr[1]=chipspr>>16;
	copperlist.ispr[3]=chipspr&0xffff;
	bmove(&spritelist,chipspr,(long)sizeof(struct sprlist));

	chipcop=(long)memalloc((long)sizeof(struct coplist));
	copper=(struct coplist *)chipcop;
	bmove(&copperlist,chipcop,(long)sizeof(struct coplist));

	*(int *)0xdff096L=0x0080;
	*(long *)0xdff080L=chipcop;
	*(int *)0xdff088L=0;
	*(int *)0xdff096L=0x8080;

	*(int *)0xdff1a2L=0x000;
	*(int *)0xdff1a4L=0x000;
	*(int *)0xdff1a6L=0xfff;
	*(int *)0xdff096L=0x8220;
}
Esempio n. 21
0
/*
**  sort klingons
**
**	bubble sort on ascending distance
*/
void
sortkl()
{
	struct kling		t;
	register int		f, i, m;

	m = Etc.nkling - 1;
	f = 1;
	while (f)
	{
		f = 0;
		for (i = 0; i < m; i++)
			if (Etc.klingon[i].dist > Etc.klingon[i+1].dist)
			{
				bmove(&Etc.klingon[i], &t, sizeof t);
				bmove(&Etc.klingon[i+1], &Etc.klingon[i], sizeof t);
				bmove(&t, &Etc.klingon[i+1], sizeof t);
				f = 1;
			}
	}
}
Esempio n. 22
0
/* map_open: just send a warning to console */
int map_open(void)
{
    char buf[60];
    struct conidcpkt pkt;
    int pid;

    /* notify the console of this attempt */
    bmove(buf,"Warning: process PID=00000\0",27);
    /* 00000 at char pos 21 */
    pid = GetPID();
    i2ascii(buf+21,pid);
    /* end is at char pos 26 */
    bmove(buf+26," is accessing /dev/pmap$\r\n\0",27);

    pkt.buf = buf;
    pkt.buflen = 52;

    cons_idc_init();
    cons_idc_send(&pkt);

    return RPDONE;
}
Esempio n. 23
0
void Znext_page(void)
{
	int i, col = forcecol();

	bpnttomrk(Bbuff, Sstart);
	for (i = wheight() + prefline() - 2; i > 0 && bcsearch(Bbuff, NL); --i) {
		bmove(Bbuff, -1);
		i -= bgetcol(true, 0) / Colmax;
		bmove1(Bbuff);
	}
	bmakecol(col);
	reframe();
}
Esempio n. 24
0
bplay()
{
	int v1, v2, *p1, *p2, *p3, ab;

	if(value > ivalue)
		ivalue = value;
	ab = 0;
	v1 = -3000;
	ply = 0;
	p1 = (int *) statl();
	if(lmp == p1+2) {
		abmove = p1[1];
		lmp = p1;
		return(ivalue);
	}
	p2 = p1;
	mantom = !mantom;
	while(p2 != lmp) {
		p2++;
		bmove(*p2);
		if(testf) {
			mantom = !mantom;
			bstatic(1);
			mantom = !mantom;
		}
		if(rept())
			v2 = 0; else
			v2 = wplay1(v1);
		if(v2 > v1 && !mate(3, 0)) {
			ab = *p2;
			v1 = v2;
		}
		bremove();
		if(testf) {
			mantom = !mantom;
			printf("%6d ", v2);
			out(*p2);
			printf("\n");
			mantom = !mantom;
		}
		p2++;
	}
	if(ab == 0 && lmp != p1)
		ab = p1[1];
	mantom = !mantom;
	lmp = p1;
	abmove = ab;
	return(v1);
}
Esempio n. 25
0
void ttinit(TTY tp)
{
	bmove(tp->t_cc, ttydefchars, sizeof(ttydefchars));
/*
	tp->t_iflag = TTYDEF_IFLAG;
	tp->t_oflag = TTYDEF_OFLAG;
	tp->t_lflag = TTYDEF_LFLAG;
*/
  tp->t_iflag = 0;
  tp->t_oflag = 0;
  tp->t_lflag = 0;
	tp->t_cflag = TTYDEF_CFLAG;
	bset((char far*)&tp->winsize, 0, sizeof(struct pt_winsize));
	qinit(&tp->inq);
	qinit(&tp->outq);
}
Esempio n. 26
0
int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key,
            key_part_map keypart_map, enum ha_rkey_function search_flag)
{
  uchar *key_buff;
  MYISAM_SHARE *share=info->s;
  MI_KEYDEF *keyinfo;
  HA_KEYSEG *last_used_keyseg;
  uint pack_key_length, use_key_length, nextflag;
  ICP_RESULT res= ICP_NO_MATCH;
  DBUG_ENTER("mi_rkey");
  DBUG_PRINT("enter", ("base: 0x%lx  buf: 0x%lx  inx: %d  search_flag: %d",
                       (long) info, (long) buf, inx, search_flag));

  if ((inx = _mi_check_index(info,inx)) < 0)
    DBUG_RETURN(my_errno);

  info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
  info->last_key_func= search_flag;
  keyinfo= share->keyinfo + inx;

  if (info->once_flags & USE_PACKED_KEYS)
  {
    info->once_flags&= ~USE_PACKED_KEYS;	/* Reset flag */
    /*
      key is already packed!;  This happens when we are using a MERGE TABLE
      In this key 'key_part_map' is the length of the key !
    */
    key_buff=info->lastkey+info->s->base.max_key_length;
    pack_key_length= keypart_map;
    bmove(key_buff, key, pack_key_length);
    last_used_keyseg= info->s->keyinfo[inx].seg + info->last_used_keyseg;
  }
  else
  {
    DBUG_ASSERT(keypart_map);
    /* Save the packed key for later use in the second buffer of lastkey. */
    key_buff=info->lastkey+info->s->base.max_key_length;
    pack_key_length=_mi_pack_key(info,(uint) inx, key_buff, (uchar*) key,
				 keypart_map, &last_used_keyseg);
    /* Save packed_key_length for use by the MERGE engine. */
    info->pack_key_length= pack_key_length;
    info->last_used_keyseg= (uint16) (last_used_keyseg -
                                      info->s->keyinfo[inx].seg);
    DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE, keyinfo->seg,
				     key_buff, pack_key_length););
  }
Esempio n. 27
0
/*
**  CM_CLEANUP -- cleanup after interrupt or error.
**
**	This routine does things like call the interrupt cleanup
**	function, reset the input, etc.
**
**	Parameters:
**		typ -- the type of cleanup:
**			1 -- fatal error (from error [error.c]).
**			2 -- keyboard interrupt.
**
**	Returns:
**		never (uses non-local jump to ctlmod/main.c).
**
**	Side Effects:
**		Proc_name & Cm.cm_input are reset.
**
**	Trace Flags:
**		0
*/
void
cm_cleanup(int typ)
{
	register int		i;
	register func_t	*f;
	extern jmp_buf		CmReset;
	register ctx_t		*ctx;

#ifdef xCTR2
	if (tTf(0, 13))
		printf("cm_cleanup: %d\n", typ);
#endif

	/*
	**  Call all interrupt cleanup functions for active
	**	modules.
	*/

	for (i = 0; i < NumFunc; i++) {
		f = FuncVect[i];
		if (f->fn_active > 0) {
			setprocname(Ctx.ctx_name = f->fn_name);
			(*f->fn_cleanup)(typ);
		}
	}

	/* clean up memory */
	for (ctx = &Ctx; ctx != NULL; ctx = ctx->ctx_link) {
		if (ctx->ctx_qt != NULL) {
			xfree(ctx->ctx_qt);
		}
		if (ctx->ctx_glob != NULL) {
			bmove(ctx->ctx_glob, ctx->ctx_fn->fn_gptr, ctx->ctx_fn->fn_gsize);
			xfree(ctx->ctx_glob);
		}
	}

	/* return to top of loop */
	longjmp(CmReset, typ);
}
Esempio n. 28
0
static void crfixup(void)
{
	char *p = (char *)memchr(Bbuff->curpage->pdata + 1, '\n', curplen(Bbuff) - 1);
	if (!p)
		return;

	if (*(p - 1) != '\r')
		return;

	if (raw_mode)
		return;

	Curbuff->bmode |= FILE_CRLF;

	while (bcsearch(Bbuff, '\r'))
		if (Buff() == '\n') {
			bmove(Bbuff, -1);
			bdelete(Bbuff, 1);
		}

	btostart(Bbuff);
}
Esempio n. 29
0
void _nisam_log_record(enum nisam_log_commands command, N_INFO *info, const byte *record, ulong filepos, int result)
{
  char buff[17],*pos;
  int error,old_errno;
  uint length;
  ulong pid=(ulong) GETPID();

  old_errno=my_errno;
  if (!info->s->base.blobs)
    length=info->s->base.reclength;
  else
    length=info->s->base.reclength+ _calc_total_blob_length(info,record);
  buff[0]=(char) command;
  int2store(buff+1,info->dfile);
  int4store(buff+3,pid);
  int2store(buff+7,result);
  int4store(buff+9,filepos);
  int4store(buff+13,length);
  pthread_mutex_lock(&THR_LOCK_isam);
  error=my_lock(nisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
  VOID(my_write(nisam_log_file,buff,sizeof(buff),MYF(0)));
  VOID(my_write(nisam_log_file,(byte*) record,info->s->base.reclength,MYF(0)));
  if (info->s->base.blobs)
  {
    N_BLOB *blob,*end;

    for (end=info->blobs+info->s->base.blobs, blob= info->blobs;
	 blob != end ;
	 blob++)
    {
      bmove(&pos,record+blob->offset+blob->pack_length,sizeof(char*));
      VOID(my_write(nisam_log_file,pos,blob->length,MYF(0)));
    }
  }
  if (!error)
    error=my_lock(nisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
  pthread_mutex_unlock(&THR_LOCK_isam);
  my_errno=old_errno;
}
Esempio n. 30
0
qtree_t *
makezero(int typ)
{
	register int		l;
	register qtree_t	*s;
	int			symbuf[(sizeof(*s)) / sizeof(l)];
				/*word aligned*/

	l = 0;
	s = (qtree_t *) symbuf;
	s->sym.type = typ;

	switch (typ) {
	  case INT_CONST:
		s->sym.len = l = 2;
		s->sym.value.sym_data.i2type = 0;
		break;

	  case FLOAT_CONST:
		s->sym.len = l = 4;
		s->sym.value.sym_data.f4type = 0.0;
		break;

	  case CHAR_CONST:
		s->sym.len = l = 2;
		memset(&s->sym.value.sym_data.i2type, ' ', 2);	/* (2 spaces) */
		break;

	  default:
		syserr("makezero: typ %d", typ);
	}

	/* duplicate the node into Qbuf */
	l += 2 + 2 * QT_HDR_SIZ;	/* size of type + len + left + right */
	s = (qtree_t *) need(Qbuf, l);
	bmove(symbuf, s, l);
	return (s);
}