コード例 #1
0
ファイル: fat.c プロジェクト: vrthra/9front-tmp
int
read(void *f, void *data, int len)
{
	File *fp = f;
	Fat *fat = fp->fat;

	if(fp->len > 0 && fp->rp >= fp->ep){
		if(fp->clust != ~0U){
			if(fp->lbaoff % fat->clustsize == 0){
				if((fp->clust >> 4) == fat->eofmark)
					return -1;
				fp->lbaoff = (fp->clust - 2) * fat->clustsize;
				fp->clust = readnext(fp, fp->clust);
				fp->lba = fp->lbaoff + fat->datalba;
			}
			fp->lbaoff++;
		}
		if(readsect(fat->drive, fp->lba++, fp->rp = fp->buf))
			return -1;
	}
	if(fp->len < len)
		len = fp->len;
	if(len > (fp->ep - fp->rp))
		len = fp->ep - fp->rp;
	memmove(data, fp->rp, len);
	fp->rp += len;
	fp->len -= len;
	return len;
}
コード例 #2
0
// number of bytes available in the receive buffer
int usb_serial_class::available()
{
        uint8_t c;

	c = prev_byte;  // assume 1 byte static volatile access is atomic
	if (c) return 1;
	c = readnext();
	if (c) {
		prev_byte = c;
		return 1;
	}
	return 0;
}
コード例 #3
0
int usb_serial_class::peek()
{
	uint8_t c;
	
	c = prev_byte;
	if (c) return c;
	c = readnext();
	if (c) {
		prev_byte = c;
		return c;
	}
	return -1;
}
コード例 #4
0
// get the next character, or -1 if nothing received
int usb_serial_class::read(void)
{
	uint8_t c;

	c = prev_byte;
	if (c) {
		prev_byte = 0;
		return c;
	}
	c = readnext();
	if (c) return c;
	return -1;
}
コード例 #5
0
ファイル: aglib.c プロジェクト: gitpan/DB-Appgen
char *		ag_readnext(unsigned dbh, int foo)
{ return readnext(h2p(dbh),foo);
}