Beispiel #1
0
char		*get_next_line(const int fd)
{
  static char	buff_rd[READ_SIZE];
  static int	i;
  int		j;
  char		*buff_ret;
  int		len;

  j = 0;
  if ((buff_ret = malloc_ret()) == NULL)
    return (NULL);
  if (i > READ_SIZE + 1)
    i = 0;
  if (buff_rd[0] == 0 && (len = mread(fd, buff_rd, READ_SIZE, &i) < 0))
    return (NULL);
  while (buff_rd[i] != '\n')
    {
      if (buff_rd[i] == 0 && (len = mread(fd, buff_rd, READ_SIZE, &i) < 0))
	return (NULL);
      if (j != 0 && ( j % READ_SIZE) == 0
	  && ((buff_ret = mrealloc(buff_ret, j)) == NULL))
	return (NULL);
      buff_ret[j++] = buff_rd[i++];
    }
  i = i + 1;
  buff_ret[j] = 0;
  return (buff_ret);
}
struct obj *
restobjchn(int fd)
{
	struct obj *otmp, *otmp2;
	struct obj *first = NULL;
	int xl;

	/* suppress "used before set" warning from lint */
	otmp2 = NULL;
	for (;;) {
		mread(fd, (char *)&xl, sizeof(xl));
		if (xl == -1)
			break;
		otmp = newobj(xl);
		if (!first)
			first = otmp;
		else
			otmp2->nobj = otmp;
		mread(fd, (char *)otmp, (unsigned)xl + sizeof(struct obj));
		if (!otmp->o_id) otmp->o_id = flags.ident++;
		otmp2 = otmp;
	}
	if (first && otmp2->nobj) {
		impossible("Restobjchn: error reading objchn.");
		otmp2->nobj = 0;
	}
	return (first);
}
Beispiel #3
0
struct monst *
restmonchn(int fd)
{
	struct monst *mtmp, *mtmp2;
	struct monst *first = 0;
	int xl;

	struct permonst *monbegin;
	long differ;

	mread(fd, (char *)&monbegin, sizeof(monbegin));
	differ = (char *)(&mons[0]) - (char *)(monbegin);

	while(1) {
		mread(fd, (char *) &xl, sizeof(xl));
		if(xl == -1) break;
		mtmp = newmonst(xl);
		if(!first) first = mtmp;
		else mtmp2->nmon = mtmp;
		mread(fd, (char *) mtmp, (unsigned) xl + sizeof(struct monst));
		if(!mtmp->m_id)
			mtmp->m_id = flags.ident++;
		mtmp->data = (struct permonst *)
			((char *) mtmp->data + differ);
		if(mtmp->minvent)
			mtmp->minvent = restobjchn(fd);
		mtmp2 = mtmp;
	}
	if(first && mtmp2->nmon){
		impossible("Restmonchn: error reading monchn.");
		mtmp2->nmon = 0;
	}
	return(first);
}
Beispiel #4
0
struct obj     *
restobjchn(int fd)
{
	struct obj     *otmp, *otmp2 = NULL;
	struct obj     *first = 0;
	int             xl;
	while (1) {
		mread(fd, &xl, sizeof(xl));
		if (xl == -1)
			break;
		otmp = newobj(xl);
		if (!first)
			first = otmp;
		else
			otmp2->nobj = otmp;
		mread(fd, otmp, (unsigned) xl + sizeof(struct obj));
		if (!otmp->o_id)
			otmp->o_id = flags.ident++;
		otmp2 = otmp;
	}
	if (first && otmp2->nobj) {
		impossible("Restobjchn: error reading objchn.");
		otmp2->nobj = 0;
	}
	return (first);
}
Beispiel #5
0
void
restnames(int fd)
{
	int i;
	unsigned len;

	mread(fd, (char *) bases, sizeof bases);
	mread(fd, (char *) objects, sizeof objects);
	for(i=0; i < nitems(objects); i++) if(objects[i].oc_uname) {
		mread(fd, (char *) &len, sizeof len);
		objects[i].oc_uname = (char *) alloc(len);
		mread(fd, objects[i].oc_uname, len);
	}
}
Beispiel #6
0
/*
 * reading BigGlyphMetrics/SmallGlyphMetrics in EBLC
 * in:  on-memory location: top of Big/Small GlyphMetrics
 *      (for out) info of glyph
 *      Big or Small (1==big, 0==small)
 * out: on-memory location: just after Big/Small GlyphMetrics
 */
uchar *see_glyphMetrics(uchar *p, metricinfo *met, int big){
    char s[BUFSIZE];

    //height
    p = mread(p, sizeof(uchar), s);
    met->height = (uchar)strtol(s,(char**)NULL,16);

    //width
    p = mread(p, sizeof(uchar), s);
    met->width = (uchar)strtol(s,(char**)NULL,16);

    //horiBearingX
    p = mread(p, sizeof(char), s);
    met->offsetx = (char)strtol(s,(char**)NULL,16);

    //horiBearingY
    p = mread(p, sizeof(char), s);
    met->offsety = (char)strtol(s,(char**)NULL,16) - met->height;

    //horiAdvance
    p = mread(p, sizeof(uchar), s);
    met->advance = (uchar)strtol(s,(char**)NULL,16);

    if(big){
        //vertBearingX
        p = mread(p, sizeof(char), s);

        //vertBearingY
        p = mread(p, sizeof(char), s);

        //vertAdvance
        p = mread(p, sizeof(uchar), s);
    }
    return p;
}
Beispiel #7
0
void main()
{
//	FILE *f = fopen("TTL6502.BIN", "r");
	int fd = open("TTL6502.BIN", O_RDONLY);
	int rv, i;

	memset(mem, 0, 65536);

	read(fd, &mem[0xe000], 0x2000);
	pc = mread(0xfffc) + (mread(0xfffd) << 8);
	trace = 1;
	while (1) {
		printf("a %02x x %02x y %02x flags %02x sp %02x pc %04x:%02x %02x %02x\n", a, x, y, flags, sp, pc, mem[pc], mem[pc + 1], mem[pc + 2]);
		step();
	}
}
Beispiel #8
0
SparseMatrix * loadSparseMatrix(char * filename, int pad)
{
	char input[128];
	strcpy(input,filename);
	strcat(input,".bin");
	printf("loading binary: %s\n", input);
	SparseMatrix * m = bmpaddedread(input,pad);
	if(m == NULL)
	{
		strcpy(input,filename);
		strcat(input,".txt");
		printf("binary not found, loading text and then saving as binary for next time: %s\n",input);
		m = mread(input);
		strcphttps://mail.google.com/mail/u/0/?ui=2&shva=1#inboxy(input,filename);
		strcat(input,".bin");
		bmwrite(input,m);
	}
	assert(m);
	int i;
	for(i = 0; i < 10; i++)
	{
		printf("%d, %e, %d\n",m->cpu_cols[i],m->cpu_vals[i],m->cpu_index[i]);
	}
	int result;
	//make the gpu side data structure
	m->gpu_cols = clCreateBuffer(context,CL_MEM_READ_WRITE, sizeof(int)*m->colsLength,NULL,&result);
	m->gpu_vals = clCreateBuffer(context,CL_MEM_READ_WRITE, sizeof(TYPE)*m->colsLength,NULL,&result);
	m->gpu_index = clCreateBuffer(context,CL_MEM_READ_WRITE, sizeof(int)*m->indexLength,NULL,&result);
	m->locality = 0;
	return m;
}
Beispiel #9
0
/*
 * reading an indexSubTableArray
 * in:  on-memery location: top of indexSubTableArray-elements
 *      on-memery location: top of indexSubTableArray
 *      (for out) info of indexSubTable
 * out: nothing
 */
void see_indexSubTableArray(uchar *elemL, uchar *arrayL, indexSubTable_info *st){
    char s[BUFSIZE];
    uchar *p = elemL;

    //firstGlyphIndex
    p = mread(p, sizeof(ushort), s);
    st->first = (ushort)strtol(s,(char**)NULL,16);

    //lastGlyphIndex
    p = mread(p, sizeof(ushort), s);
    st->last = (ushort)strtol(s,(char**)NULL,16);

    //location of indexSubTable
    p = mread(p, sizeof(ulong), s);
    st->subtableL = arrayL + (ulong)strtol(s,(char**)NULL,16);
}
Beispiel #10
0
void restnames(int fd)
{
    int i;
    unsigned int len;

    mread(fd, (char *)bases, sizeof(bases));
    mread(fd, (char *)objects, sizeof(objects));
    
    for(i = 0; i < SIZE(objects); ++i) {
        if(objects[i].oc_uname != NULL) {
            mread(fd, (char *)&len, sizeof(len));
            objects[i].oc_uname = (char *)alloc(len);
            mread(fd, objects[i].oc_uname, len);
        }
    }
}
Beispiel #11
0
/*
 *			N R E A D
 */
int
Nread(int fd, void *buf, int count)
{
	struct sockaddr_in from;
	socklen_t len = sizeof(from);
	register int cnt;
	if (udp) {
		cnt = recvfrom(fd, buf, count, 0, (struct sockaddr *)&from, &len);
		numCalls++;
	} else {
		if (b_flag)
			cnt = mread(fd, buf, count);	/* fill buf */
		else {
			cnt = read(fd, buf, count);
			numCalls++;
		}
		if (touchdata && cnt > 0) {
			register int c = cnt, sum = 0;
			register char *b = buf;
			while (c--)
				sum += *b++;
		}
	}
	return(cnt);
}
Beispiel #12
0
int main() {
	mount("volume2.vfs");
	ls();
	touch("ppg");
	ls();
	int fd;
	fd = mopen("ppg");
	char *out = mread(fd);
	printf(out);
	mclose(fd);

	fd = mopen("ppg");
	mwrite(fd, "spider man!");
	mclose(fd);
	
	fd = mopen("ppg");
	out = mread(fd);
	printf(out);
	mclose(fd);

	ls();
	touch("hello.c");
	ls();

	fd = mopen("hello.c");
	out = mread(fd);
	printf(out);
	mclose(fd);

	fd = mopen("hello.c");
	mwrite(fd, "hello\nworld!\n");
	mclose(fd);

	fd = mopen("hello.c");
	out = mread(fd);
	mclose(fd);


	fd = mopen("ppg");
	out = mread(fd);
	printf(out);
	mclose(fd);


	umount();
	return 0;
}
Beispiel #13
0
/*
 * reading bitmapSizeTable(defines info of strike) in EBLC
 * in:  on-memory location: top of a bitmapSizeTable
 *      (for out) number of indexSubTableArray-elements
 *      (for out) on-memory location: top of indexSubTableArray
 *      (for out) info of BoundingBox
 * out: nothing
 */
void see_bitmapSizeTable(uchar *p, int *numElem, ulong *arrayOffset, metricinfo *bbox){
    char s[BUFSIZE]; //stored string

    //offset from EBLCtop to indexSubTableArray
    p = mread(p, sizeof(ulong), s);
    *arrayOffset = (ulong)strtol(s,(char**)NULL,16);

    //indexSubTable size (byte) (not use)
    p = mread(p, sizeof(ulong), s);

    //number of indexSubTableArray-elements (= number of indexSubTables)
    p = mread(p, sizeof(ulong), s);
    *numElem = (ulong)strtol(s,(char**)NULL,16);

    //colorRef (always 0)
    p = mread(p, sizeof(ulong), s);

    //sbitLineMetrics: hori
    //info of metric about all glyphs in a strike
    p = see_sbitLineMetrics(p, bbox, 1); // 1 means direction==horizontal


    //sbitLineMetrics: vert  (not use)
    p = see_sbitLineMetrics(p, NULL, 0); // 0 means direction==vertical

    //start glyphIndex for this size
    p = mread(p, sizeof(ushort), s);

    //end glyphIndex for this size
    p = mread(p, sizeof(ushort), s);

    //ppemX (the strike's boundingbox width (pixel))
    p = mread(p, sizeof(uchar), s);
    bbox->ppem = (uchar)strtol(s,(char**)NULL,16);

    //ppemY
    p = mread(p, sizeof(uchar), s);

    //bitDepth (always 1)
    p = mread(p, sizeof(uchar), s);

    //flags (1=horizontal, 2=vertical)
    p = mread(p, sizeof(char), s);

    return;
}
Beispiel #14
0
void
rest_engravings(int fd)
{
	struct engr *ep;
	unsigned lth;

	head_engr = 0;
	while(1) {
		mread(fd, (char *) &lth, sizeof(unsigned));
		if(lth == 0) return;
		ep = (struct engr *) alloc(sizeof(struct engr) + lth);
		mread(fd, (char *) ep, sizeof(struct engr) + lth);
		ep->nxt_engr = head_engr;
		ep->engr_txt = (char *) (ep + 1);	/* Andreas Bormann */
		head_engr = ep;
	}
}
Beispiel #15
0
/*
 * raeding header of an indexSubTable
 * in:  (for in and out) info of indexSubTable
 * out: imageFormat
 */
int see_indexSubHeader(indexSubTable_info *st){
    char s[BUFSIZE];
    char *p = st->subtableL;
    int imageFormat;

    //indexFormat
    p = mread(p, sizeof(ushort), s);
    st->indexFormat = strtol(s,(char**)NULL,16);

    //imageFormat
    p = mread(p, sizeof(ushort), s);
    imageFormat = (ushort)strtol(s,(char**)NULL,16);

    //imageDataOffset
    p = mread(p, sizeof(ulong), s);
    st->off = (ulong)strtol(s,(char**)NULL,16);

    return imageFormat;
}
Beispiel #16
0
int mcopy(memstream *to, const unsigned int size, memstream *s){
	int _size=size;
	if(_size>mavail(s))_size=mavail(s);
	if(_size>mavail(to))_size=mavail(to);
	if(!_size)return 0;

	mread((unsigned char*)(to->p)+mtell(to),_size,s);mseek(to,_size,SEEK_CUR);
	//mwrite((unsigned char*)(s->p)+mtell(s),_size,to);mseek(s,_size,SEEK_CUR);

	return _size;
}
Beispiel #17
0
size_t hio_read(void *buf, size_t size, size_t num, HIO_HANDLE *h)
{
	switch (HIO_HANDLE_TYPE(h)) {
	case HIO_HANDLE_TYPE_FILE:
		return fread(buf, size, num, h->handle.file);
	case HIO_HANDLE_TYPE_MEMORY:
		return mread(buf, size, num, h->handle.mem);
	default:
		return 0;
	}
}
Beispiel #18
0
void main()
{
	int rv, i = 0;

	fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK);

	memset(mem, 0, sizeof(mem));

//	read(fd, &mem[0xff00], 0x2000);
	pc = mread(0xfffc) + (mread(0xfffd) << 8);
//	pc = 0xe000;
	trace = 0;
	while (1) {
		if (trace) printf("a %02x x %02x y %02x flags %02x sp %02x pc %04x:%02x %02x %02x\n", a, x, y, flags, sp, pc, mread(pc), mread(pc+1), mread(pc+2));
		step();

//		if (!c && test[i]) c = test[i++];
		if (!c && (read(0, &c, 1) == 1));
	}
}
Beispiel #19
0
struct monst   *
restmonchn(int fd)
{
	struct monst   *mtmp, *mtmp2 = NULL;
	struct monst   *first = 0;
	int             xl;

	struct permonst *monbegin;
	long            differ;

	mread(fd, &monbegin, sizeof(monbegin));
	differ = (const char *) (&mons[0]) - (const char *) (monbegin);

#ifdef lint
	/* suppress "used before set" warning from lint */
	mtmp2 = 0;
#endif	/* lint */
	while (1) {
		mread(fd, &xl, sizeof(xl));
		if (xl == -1)
			break;
		mtmp = newmonst(xl);
		if (!first)
			first = mtmp;
		else
			mtmp2->nmon = mtmp;
		mread(fd, mtmp, (unsigned) xl + sizeof(struct monst));
		if (!mtmp->m_id)
			mtmp->m_id = flags.ident++;
		mtmp->data = (const struct permonst *)
			((const char *) mtmp->data + differ);
		if (mtmp->minvent)
			mtmp->minvent = restobjchn(fd);
		mtmp2 = mtmp;
	}
	if (first && mtmp2->nmon) {
		impossible("Restmonchn: error reading monchn.");
		mtmp2->nmon = 0;
	}
	return (first);
}
Beispiel #20
0
		template <class T> Matrix<T>
		Read (const std::string& uri = "") const {

			int dt;
			size_t  ns, n;
			std::vector<size_t> dim;
			std::vector<float>  res;
			char* name;
			Matrix<T> M;
			T t;

			// Read type
			if (!mread (&dt, 1, m_file, "data type"))
				return M;

			// Matrix and data type must fit as of now.
			if (CODTraits<T>::dt == dt) {

				if (!mread (&n, 1, m_file, "dimensions"))
					return M;
				dim = std::vector<size_t>(n,1);
				res = std::vector<float>(n,1.0);

				// Read dimensions and allocate matrix
				if (!mread (dim, m_file, "dimensions"))
					return M;

				//Read resolutions and assign
				if (!mread (res, m_file, "resolutions"))
					return M;
				M = Matrix<T>(dim,res);
				n = numel(M);

				// Name
				if (!mread (&n,  1, m_file, "name length"))
					return M;

				name = new char [n+1];

				if (!mread (name, n, m_file, "name"))
					return M;
				name[n] = '\0';
				M.SetClassName(name);

				// Read data
				if (!mread (M.Container(), m_file, "data"))
					return M;

				//Close and clean up;
				delete name;

			}

			return M;

		}
Beispiel #21
0
static void
rest_room (int fd, struct mkroom *r)
{
        short i;

        mread(fd, (void *) r, sizeof(struct mkroom));
        for(i=0; i<r->nsubrooms; i++) {
                r->sbrooms[i] = &subrooms[nsubroom];
                rest_room(fd, &subrooms[nsubroom]);
                subrooms[nsubroom++].resident = (struct monst *)0;
        }
}
Beispiel #22
0
void
rest_rooms (int fd)
{
        short i;

        mread(fd, (void *) &nroom, sizeof(nroom));
        nsubroom = 0;
        for(i = 0; i<nroom; i++) {
            rest_room(fd, &rooms[i]);
            rooms[i].resident = (struct monst *)0;
        }
        rooms[nroom].hx = -1;           /* restore ending flags */
        subrooms[nsubroom].hx = -1;
}
Beispiel #23
0
bool dorecover (void)
{
    char savefile [PATH_MAX];
    snprintf (ArrayBlock(savefile), HACK_SAVEFILE, getenv("HOME"));
    int fd = open (savefile, O_RDONLY);
    if (fd < 0)
	return false;
    mread (fd, &_u, sizeof(struct you));
    if (_u.maxdlevel < 1 || _u.maxdlevel > MAXLEVEL) {
	close (fd);
	you_dtor();
	return false;
    }
    invent = restobjchn (fd);
    for (struct obj* o = invent; o; o = o->nobj)
	if (o->owornmask)
	    setworn (o, o->owornmask);
    fcobj = restobjchn (fd);
    fallen_down = restmonchn (fd);
    mread (fd, &_wflags, sizeof(struct worldflag));
    mread (fd, pl_character, sizeof pl_character);
    restnames (fd);
    restgenocided (fd);
    for (unsigned i = 0; i < _u.maxdlevel; ++i) {
	level_dtor (&_levels[i]);
	getlev (fd, &_levels[i]);
    }
    if (_u.dlevel < 1 || _u.dlevel > _u.maxdlevel)
	_u.dlevel = _u.maxdlevel;
    _level = &_levels[_u.dlevel-1];
    setsee();	// only to recompute seelx etc. - these weren't saved
    docrt();
    close (fd);
    unlink (savefile);
    return true;
}
Beispiel #24
0
void
restore_history(struct memfile *mf)
{
    int i, len;

    mfmagic_check(mf, HISTORY_MAGIC);
    histcount = mread32(mf);
    histevents = malloc(histcount * sizeof (struct histevent));
    for (i = 0; i < histcount; i++) {
        histevents[i].when = mread32(mf);
        histevents[i].hidden = mread32(mf);
        len = mread32(mf);
        mread(mf, histevents[i].what, len);
    }
}
Beispiel #25
0
/*
 * checking TrueTypefont or not
 * in:  on-memory location: top of truetype font
 * out: nothing
 *
 *  If errors, exit program.
 */
void validiateTTF(uchar *p){
    char s[BUFSIZE];

    p = mread(p, sizeof(ulong), s); //version
    if(strcmp(s,"0x00010000")==0){
        printf("  Microsoft TrueType/OpenType\n");
    }else if(strcmp(s, "0x74746366")==0){
        printf("  Microsoft TrueTypeCollection\n");
        errexit("TTC file is not supported yet.");
    }else if(strcmp(s, "0x74727565")==0){
        printf("  Apple TrueType\n");
    }else{
        errexit("This file is not a TrueTypeFont.");
    }
}
/*
 *===========================================================================
 *                         Nread
 *===========================================================================
 */
static int
Nread(int fd, void *ibuf, int count, struct Ipcom_cmd_ttcp_data *context)
{
    union Ip_sockaddr_union from;
    Ip_socklen_t            len = context->addrsize;
    register int         cnt;

    if(context->udp)
    {
        if ((cnt = ipcom_recvfrom(fd, ibuf, count, 0, (struct Ip_sockaddr *)&from, &len)) < 0)
            context->err_no = ipcom_errno;
        context->numCalls++;
    }
    else
#ifdef IPCOM_USE_TCP
    {
        if(context->b_flag)
            cnt = mread(fd, ibuf, count, context);		/* fill buf */
        else
        {
            if ((cnt = ipcom_socketread(fd, ibuf, count)) < 0)
                context->err_no = ipcom_errno;
            context->numCalls++;
        }
        if(context->touchdata && cnt > 0)
        {
            register int c = cnt;
            volatile int sum = 0;
            register char *b = ibuf;

            while (c--)
                sum += *b++;

            (void)sum;				  /* lint */
        }
    }
#else
    {
        (void)b_flag;
        (void)touchdata;
        cnt = 0;
    }
#endif /* IPCOM_USE_TCP */

    return (cnt);
}
Beispiel #27
0
static int
readn(int fd, IxpMsg *msg, uint count) {
	uint num;
	int r;

	num = count;
	while(num > 0) {
		r = mread(fd, msg, num);
		if(r == -1 && errno == EINTR)
			continue;
		if(r == 0) {
			werrstr("broken pipe");
			return count - num;
		}
		num -= r;
	}
	return count - num;
}
Beispiel #28
0
int
pad_view()
{
  int fd, count;
  Pad *pad;

  if ((fd = open(FN_RUN_NOTE_PAD, O_RDONLY)) < 0)
    return XEASY;

  count = 0;
  mgets(-1);

  for (;;)
  {
    pad = mread(fd, sizeof(Pad));
    if (!pad)
    {
      vmsg(NULL);
      break;
    }
    else if (!(count % 5))	/* itoc.020122: 有 pad 才印 */
    {
      clear();
      move(0, 23);
      prints("【 酸 甜 苦 辣 留 言 板 】                第 %d 頁\n\n", count / 5 + 1);
    }

    outs(pad->msg);
    count++;

    if (!(count % 5))
    {
      move(b_lines, 0);
      outs("請按 [SPACE] 繼續觀賞,或按其他鍵結束: ");
      /* itoc.010127: 修正在偵測左右鍵全形下,按左鍵會跳離二層選單的問題 */

      if (vkey() != ' ')
	break;
    }
  }

  close(fd);
  return 0;
}
Beispiel #29
0
struct block_info{
  unsigned int next_addr;
  unsigned int addr_end;
}

block_info  read_info(unsigned int addr){
  
    uint8_t n1 = mread(addr);
    uint8_t n2 = mread(addr+1);
    uint8_t n3 = mread(addr+2);
    uint8_t n4 = mread(addr+3);
  
    uint8_t e1 = mread(addr+4);
    uint8_t e2 = mread(addr+5);
    uint8_t e3 = mread(addr+6);
    uint8_t e4 = mread(addr+7);
  
    struct block_info readed;
    readed.next_addr= n1;
    readed.next_addr = readed.next_addr<<8;
    readed.next_addr += n2;
    readed.next_addr = readed.next_addr<<8;
    readed.next_addr += n3;
    readed.next_addr = readed.next_addr<<8;
    readed.next_addr += n4;
  
    readed.addr_end = e1;
    readed.addr_end = readed.addr_end<<8;
    readed.addr_end += e2;
    readed.addr_end = readed.addr_end<<8;
    readed.addr_end += e3;
    readed.addr_end = readed.addr_end<<8;
    readed.addr_end += e4;
  
  return readed;
}
Beispiel #30
0
/*
 * reading TrueTypefont header
 * in:  on-memory top of truetype font
 *      (for out) info of each table
 * out: nothing
 */
void getTableInfo(uchar *p, tableinfo *t){
    int i;
    ushort numTable;
    char s[BUFSIZE];

    p = mread(p, sizeof(ulong), s); //version

    p = mread(p, sizeof(ushort), s); //number of tables
    numTable = (ushort)strtol(s,(char**)NULL,16);

    p = mread(p, sizeof(ushort), s); //searchRange
    p = mread(p, sizeof(ushort), s); //entrySelector
    p = mread(p, sizeof(ushort), s); //rangeShift

    /*
     * assign info of table
     */
    for(i=0; i<numTable; i++){
        //allocate for a tableinfo (free() don't exist)
        if( (t->next=malloc(sizeof(tableinfo))) == NULL)
            errexit("malloc");
        t = t->next;

        //a name of table (tag)
        memset(t->tag, 0x00, 5); // 0 clear
        memcpy(t->tag, p, 4);
        p += sizeof(ulong);

        p += sizeof(ulong); //checksum (not use now)

        //offset
        p = mread(p, sizeof(ulong), s); //number of tables
        t->offset = (ulong)strtol(s,(char**)NULL,16);

        p += sizeof(ulong); //length (not use now)

    }
    t->next = NULL;
}