FILE *extractlump(FILE *wad,long f_size) { long f_pos; long f_ofs; long f_len; f_pos = ftell(wad); getlong(wad,f_ofs); getlong(wad,f_len); if (((f_ofs + f_len) > f_size) || (f_ofs < 0)) { throw exception::root("Part or all of lump data outside wad file"); } if (f_len < 0) { throw exception::root("Lump has negative length"); } fseek(wad,f_ofs,SEEK_SET); FILE *tmp; tmp = tmpfile(); log("Extracting lump..."); for (int i = 0;i < f_len;i++) fputc(fgetc(wad),tmp); fseek(tmp,0,SEEK_SET); fseek(wad,f_pos + 16,SEEK_SET); return tmp; }
static void readttftables(FILE *pcl,struct ttf_header *hdr,int seg_size) { int header_base = ftell(pcl); int end_at = header_base+seg_size; int num, i,j; /* version = */ getlong(pcl); num = getshort(pcl); /* srange = */ getshort(pcl); /* esel = */ getshort(pcl); /* rshift = */ getshort(pcl); hdr->subtable_cnt = num; hdr->subtables = malloc(num*sizeof(struct subtables)); for ( i=j=0; i<num; ++i ) { hdr->subtables[j].tag = getlong(pcl); /* checksum = */ getlong(pcl); hdr->subtables[j].offset = header_base+getlong(pcl); hdr->subtables[j].len = getlong(pcl); hdr->subtables[j].file = pcl; hdr->subtables[j].closeme = false; if ( hdr->subtables[j].tag != CHR('g','d','i','r')) ++j; else --hdr->subtable_cnt; } /* head, hhea, hmtx and maxp required to be present */ /* We must synthesize: OS/2, name, cmap, glyf, loca, post */ /* We should remove 'gdir' (not part of truetype) */ fseek(pcl,end_at,SEEK_SET); }
static void parseavar(struct ttfinfo *info, FILE *ttf) { int axis_count, pair_count; int i,j; if ( info->variations==NULL || info->avar_start==0 || info->avar_len==0 ) return; fseek(ttf,info->avar_start,SEEK_SET); if ( getlong(ttf)!=0x00010000 ) { /* I only understand version 1 */ VariationFree(info); return; } axis_count = getlong(ttf); if ( axis_count!=info->variations->axis_count ) { LogError( _("Hmm, the axis count in the 'avar' table is different from that in the 'fvar' table.\n") ); VariationFree(info); return; } for ( i=0; i<axis_count; ++i ) { pair_count = getushort(ttf); if ( pair_count!=0 ) { info->variations->axes[i].mapfrom = malloc(pair_count*sizeof(real)); info->variations->axes[i].mapto= malloc(pair_count*sizeof(real)); for ( j=0; j<pair_count; ++j ) { info->variations->axes[i].mapfrom[j] = getushort(ttf)/16384.0; info->variations->axes[i].mapto[j] = getushort(ttf)/16384.0; } } } if ( ftell(ttf)-info->avar_start>info->avar_len) { LogError( _("Hmm, the 'avar' table is too long.\n") ); VariationFree(info); return; } }
/* * Handling the alignment problem of struct ipart. */ static void fill_ipart(char *bootptr, struct ipart *partp) { #if defined(sparc) /* * Sparc platform: * * Packing short/word for struct ipart to resolve * little endian on Sparc since it is not * properly aligned on Sparc. */ partp->bootid = getbyte((uchar_t **)&bootptr); partp->beghead = getbyte((uchar_t **)&bootptr); partp->begsect = getbyte((uchar_t **)&bootptr); partp->begcyl = getbyte((uchar_t **)&bootptr); partp->systid = getbyte((uchar_t **)&bootptr); partp->endhead = getbyte((uchar_t **)&bootptr); partp->endsect = getbyte((uchar_t **)&bootptr); partp->endcyl = getbyte((uchar_t **)&bootptr); partp->relsect = getlong((uchar_t **)&bootptr); partp->numsect = getlong((uchar_t **)&bootptr); #elif defined(i386) /* * i386 platform: * * The fdisk table does not begin on a 4-byte boundary within * the master boot record; so, we need to recopy its contents * to another data structure to avoid an alignment exception. */ (void) bcopy(bootptr, partp, sizeof (struct ipart)); #else #error No Platform defined #endif /* defined(sparc) */ }
static void init(Display *d) { /* Hrm... assumes one display... */ char *toks[nelem(types)]; char *s, *p; long n; int i; xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY); if(xlib == nil) return; mapwindow = (mapfn)(uintptr_t)dlsym(xlib, "XMapWindow"); mapraised = (mapfn)(uintptr_t)dlsym(xlib, "XMapRaised"); unsetenv("LD_PRELOAD"); if((s = getenv("WMII_HACK_TRANSIENT"))) { if(getlong(s, &n)) transient = n; unsetenv("WMII_HACK_TRANSIENT"); } if((s = getenv("WMII_HACK_TYPE"))) { s = strdup(s); unsetenv("WMII_HACK_TYPE"); n = tokenize(toks, nelem(toks), s, ','); for(i=0; i < n; i++) { for(p=toks[i]; *p; p++) if(*p >= 'a' && *p <= 'z') *p += 'A' - 'a'; toks[i] = smprint("_NET_WM_WINDOW_TYPE_%s", toks[i]); } XInternAtoms(d, toks, n, false, types); ntypes = n; for(i=0; i < n; i++) free(toks[i]); free(s); } if((s = getenv("WMII_HACK_TAGS"))) { s = strdup(s); unsetenv("WMII_HACK_TAGS"); n = tokenize(toks, nelem(toks)-1, s, '+'); tags = strlistdup(toks, n); free(s); } if((s = getenv("WMII_HACK_TIME"))) { getlong(s, &stime); unsetenv("WMII_HACK_TIME"); } pid = getpid(); gethostname(hostname, sizeof hostname - 1); }
static unsigned char *read_zip_file(FILE *file, int offset, int *sizep) { int sig, method, csize, usize; int namelength, extralength; char *cdata, *udata; fseek(file, offset, 0); sig = getlong(file); if (sig != ZIP_LOCAL_FILE_SIG) { warn("zip: wrong signature for local file"); return NULL; } (void) getshort(file); /* version */ (void) getshort(file); /* general */ method = getshort(file); (void) getshort(file); /* file time */ (void) getshort(file); /* file date */ (void) getlong(file); /* crc-32 */ csize = getlong(file); /* csize */ usize = getlong(file); /* usize */ namelength = getshort(file); extralength = getshort(file); fseek(file, namelength + extralength, 1); if (method == 0 && csize == usize) { cdata = malloc(csize); fread(cdata, 1, csize, file); *sizep = csize; return (unsigned char*) cdata; } if (method == 8) { cdata = malloc(csize); fread(cdata, 1, csize, file); udata = malloc(usize); usize = stbi_zlib_decode_noheader_buffer(udata, usize, cdata, csize); free(cdata); if (usize < 0) { warn("zip: %s", stbi_failure_reason()); return NULL; } *sizep = usize; return (unsigned char*) udata; } warn("zip: unknown compression method"); return NULL; }
static void recv_ssh_smsg_public_key(Conn *c) { Msg *m; m = recvmsg(c, SSH_SMSG_PUBLIC_KEY); memmove(c->cookie, getbytes(m, COOKIELEN), COOKIELEN); c->serverkey = getRSApub(m); c->hostkey = getRSApub(m); c->flags = getlong(m); c->ciphermask = getlong(m); c->authmask = getlong(m); free(m); }
static void getsgiheader(struct sgiheader *head, FILE *fp) { head->magic = getshort(fp); head->format = getc(fp); head->bpc = getc(fp); head->dim = getshort(fp); head->width = getshort(fp); head->height = getshort(fp); head->chans = getshort(fp); head->pixmin = getlong(fp); head->pixmax = getlong(fp); fread(head->dummy,sizeof(head->dummy),1,fp); fread(head->imagename,sizeof(head->imagename),1,fp); head->colormap = getlong(fp); fread(head->pad,sizeof(head->pad),1,fp); }
void handleagentopen(Msg *m) { int i; uint32_t remote; assert(m->type == SSH_SMSG_AGENT_OPEN); remote = getlong(m); debug(DBG_AUTH, "agent open %d\n", remote); for(i=0; i<nelem(achan); i++) if(achan[i].open == 0 && achan[i].needeof == 0 && achan[i].needclosed == 0) break; if(i == nelem(achan)){ m = allocmsg(m->c, SSH_MSG_CHANNEL_OPEN_FAILURE, 4); putlong(m, remote); sendmsg(m); return; } debug(DBG_AUTH, "\tremote %d is local %d\n", remote, i); achan[i].open = 1; achan[i].needeof = 1; achan[i].needclosed = 1; achan[i].nlbuf = 0; achan[i].chan = remote; m = allocmsg(m->c, SSH_MSG_CHANNEL_OPEN_CONFIRMATION, 8); putlong(m, remote); putlong(m, i); sendmsg(m); }
int AGOSEngine_PN::setposition(int process, int line) { uint8 *ourptr; int np; int ct; ourptr = _dataBase + getlong(_quickptr[6] + 3 * process); np = *ourptr++; for (ct = 0; ct < line; ++ct) { ourptr += (127 & *ourptr); } while (true) { _linebase = ourptr; _linct = (127 & *ourptr) - 1; if (*ourptr++ <= 127) break; ct = varval(); if (ct == (int)_variableArray[1]) break; ourptr += _linct - 1; line++; } _linembr = line; _procnum = process; _variableArray[0] = process; _workptr = ourptr; return np; }
void AGOSEngine_PN::loadGamePcFile() { if (getFileName(GAME_BASEFILE) != NULL) { Common::File in; // Read dataBase if (!in.open(getFileName(GAME_BASEFILE))) { error("loadGamePcFile: Can't load database file '%s'", getFileName(GAME_BASEFILE)); } _dataBaseSize = in.size(); _dataBase = (byte *)malloc(_dataBaseSize); if (_dataBase == NULL) error("loadGamePcFile: Out of memory for dataBase"); in.read(_dataBase, _dataBaseSize); if (_dataBase[31] != 0) error("Later version of system requested"); } if (getFileName(GAME_TEXTFILE) != NULL) { Common::File in; // Read textBase if (!in.open(getFileName(GAME_TEXTFILE))) { error("loadGamePcFile: Can't load textbase file '%s'", getFileName(GAME_TEXTFILE)); } _textBaseSize = in.size(); _textBase = (byte *)malloc(_textBaseSize); if (_textBase == NULL) error("loadGamePcFile: Out of memory for textBase"); in.read(_textBase, _textBaseSize); if (_textBase[getlong(30L)] != 128) error("Unknown compression format"); } }
Area * strarea(View *v, char *s) { Area *a; long i; if(!strcmp(s, "sel")) return v->sel; if(!strcmp(s, "~")) return v->area; if(!getlong(s, &i) || i == 0) return nil; if(i > 0) for(a = v->area; a; a = a->next) { if(i-- == 0) break; } else { for(a = v->area; a->next; a = a->next) ; for(; a != v->area; a = a->prev) if(++i == 0) break; if(a == v->area) a = nil; } return a; }
unsigned int getdef_unum (const char *item, unsigned int dflt) { struct itemdef *d; long val; if (!def_loaded) { def_load (); } d = def_find (item); if ((NULL == d) || (NULL == d->value)) { return dflt; } if ( (getlong (d->value, &val) == 0) || (val < 0) || (val > INT_MAX)) { fprintf (stderr, _("configuration error - cannot parse %s value: '%s'"), item, d->value); return dflt; } return (unsigned int) val; }
void read_CIcon(CIcon* cicn, FILE* f) { int len; cicn->PMap = calloc(1, sizeof(PixMap)); if (NULL == cicn->PMap) die("calloc failed"); cicn->Mask = calloc(1, sizeof(BitMap)); if (NULL == cicn->Mask) die("calloc failed"); cicn->BMap = calloc(1, sizeof(BitMap)); if (NULL == cicn->BMap) die("calloc failed"); read_PixMap(cicn->PMap, f); read_BitMap(cicn->Mask, f); read_BitMap(cicn->BMap, f); assert(0 == getlong(f)); len = cicn->Mask->rowBytes * (cicn->Mask->bounds[bottom] - cicn->Mask->bounds[top]); cicn->Mask->baseAddr = calloc(len, sizeof(uint8_t)); if (NULL == cicn->Mask->baseAddr) die("calloc failed"); fread(cicn->Mask->baseAddr, sizeof(uint8_t), len, f); assert(!ferror(f)); len = cicn->BMap->rowBytes * (cicn->BMap->bounds[bottom] - cicn->BMap->bounds[top]); cicn->BMap->baseAddr = calloc(len, sizeof(uint8_t)); if (NULL == cicn->BMap->baseAddr) die("calloc failed"); fread(cicn->BMap->baseAddr, sizeof(uint8_t), len, f); assert(!ferror(f)); cicn->PMap->pmTable.ctSeed = getlong(f); cicn->PMap->pmTable.ctFlags = getint(f); cicn->PMap->pmTable.ctSize = getint(f); cicn->PMap->pmTable.ctTable = calloc(cicn->PMap->pmTable.ctSize + 1, sizeof(ColorSpec)); if (NULL == cicn->PMap->pmTable.ctTable) die("calloc failed"); for (len = 0; len <= cicn->PMap->pmTable.ctSize; len++) { cicn->PMap->pmTable.ctTable[len].value = getint(f); cicn->PMap->pmTable.ctTable[len].red = getint(f); cicn->PMap->pmTable.ctTable[len].green = getint(f); cicn->PMap->pmTable.ctTable[len].blue = getint(f); } len = (cicn->PMap->rowBytes & 0x7FFF) * (cicn->PMap->bounds[bottom] - cicn->PMap->bounds[top]); cicn->PMap->baseAddr = calloc(len, sizeof(uint8_t)); if (NULL == cicn->PMap->baseAddr) die("calloc failed"); fread(cicn->PMap->baseAddr, sizeof(uint8_t), len, f); assert(!ferror(f)); }
Img* dssread(char *file) { int nx, ny, scale, sumall; Pix *p, *pend; uint8_t buf[21]; Biobuf *bp; Img *ip; if(debug) Bprint(&bout, "reading %s\n", file); bp = Bopen(file, OREAD); if(bp == 0) return 0; if(Bread(bp, buf, sizeof(buf)) != sizeof(buf) || buf[0] != 0xdd || buf[1] != 0x99){ werrstr("bad format"); return 0; } nx = getlong(buf+2); ny = getlong(buf+6); scale = getlong(buf+10); sumall = getlong(buf+14); if(debug) fprint(2, "%s: nx=%d, ny=%d, scale=%d, sumall=%d, nbitplanes=%d,%d,%d\n", file, nx, ny, scale, sumall, buf[18], buf[19], buf[20]); ip = malloc(sizeof(Img) + (nx*ny-1)*sizeof(int)); if(ip == 0){ Bterm(bp); werrstr("no memory"); return 0; } ip->nx = nx; ip->ny = ny; dodecode(bp, ip->a, nx, ny, buf+18); ip->a[0] = sumall; /* sum of all pixels */ Bterm(bp); if(scale > 1){ p = ip->a; pend = &ip->a[nx*ny]; while(p < pend) *p++ *= scale; } hinv(ip->a, nx, ny); return ip; }
static void readlongtab (FILE *fp, unsigned long *tab, int tablen) { int i; for (i = 0; i < tablen; ++i) tab[i] = getlong (fp); }
static void getrasheader(SUNRASTER *head, FILE *fp) { head->MagicNumber = getlong(fp); head->Width = getlong(fp); head->Height = getlong(fp); head->Depth = getlong(fp); head->Length = getlong(fp); head->Type = getlong(fp); head->ColorMapType = getlong(fp); head->ColorMapLength = getlong(fp); }
void read_PixMap(PixMap* pmap, FILE* f) { pmap->baseAddr = NULL; assert(0 == getlong(f)); pmap->rowBytes = getint(f); assert(0x8000 == (pmap->rowBytes & 0xC000)); pmap->bounds[top] = getint(f); pmap->bounds[left] = getint(f); pmap->bounds[bottom] = getint(f); pmap->bounds[right] = getint(f); pmap->pmVersion = getint(f); assert(0 == pmap->pmVersion); pmap->packType = getint(f); assert(0 == pmap->packType); pmap->packSize = getlong(f); assert(0 == pmap->packSize); pmap->hRes = getlong(f); assert(0x480000 == pmap->hRes); pmap->vRes = getlong(f); assert(0x480000 == pmap->vRes); pmap->pixelType = getint(f); assert(0 == pmap->pixelType); pmap->pixelSize = getint(f); pmap->cmpCount = getint(f); assert(1 == pmap->cmpCount); pmap->cmpSize = getint(f); pmap->planeBytes = getlong(f); assert(0 == pmap->planeBytes); // pmap->pmTable = NULL; assert(0 == getlong(f)); pmap->pmReserved = getlong(f); assert(0 == pmap->pmReserved); }
/* * process_flags - parse the command line options * * It will not return if an error is encountered. */ static void process_flags (int argc, char **argv) { int c; static struct option long_options[] = { {"crypt-method", required_argument, NULL, 'c'}, {"encrypted", no_argument, NULL, 'e'}, {"help", no_argument, NULL, 'h'}, {"md5", no_argument, NULL, 'm'}, {"root", required_argument, NULL, 'R'}, #ifdef USE_SHA_CRYPT {"sha-rounds", required_argument, NULL, 's'}, #endif {NULL, 0, NULL, '\0'} }; while ((c = getopt_long (argc, argv, #ifdef USE_SHA_CRYPT "c:ehmR:s:", #else "c:ehmR:", #endif long_options, NULL)) != -1) { switch (c) { case 'c': crypt_method = optarg; break; case 'e': eflg = true; break; case 'h': usage (E_SUCCESS); /*@notreached@*/break; case 'm': md5flg = true; break; case 'R': /* no-op, handled in process_root_flag () */ break; #ifdef USE_SHA_CRYPT case 's': sflg = true; if (getlong(optarg, &sha_rounds) == 0) { fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, optarg); usage (E_USAGE); } break; #endif default: usage (E_USAGE); /*@notreached@*/break; } } /* validate options */ check_flags (); }
void read_BitMap(BitMap* bmap, FILE* f) { bmap->baseAddr = NULL; assert(0 == getlong(f)); bmap->rowBytes = getint(f); bmap->bounds[top] = getint(f); bmap->bounds[left] = getint(f); bmap->bounds[bottom] = getint(f); bmap->bounds[right] = getint(f); }
void handleagentmsg(Msg *m) { uint32_t chan, len; int n; Achan *a; assert(m->type == SSH_MSG_CHANNEL_DATA); debug(DBG_AUTH, "agent data\n"); debug(DBG_AUTH, "\t%.*H\n", (int)(m->ep - m->rp), m->rp); chan = getlong(m); len = getlong(m); if(m->rp+len != m->ep) sysfatal("got bad channel data"); if(chan >= nelem(achan)) error("bad channel in agent request"); a = &achan[chan]; while(m->rp < m->ep){ if(a->nlbuf < 4){ a->lbuf[a->nlbuf++] = getbyte(m); if(a->nlbuf == 4){ a->len = (a->lbuf[0]<<24) | (a->lbuf[1]<<16) | (a->lbuf[2]<<8) | a->lbuf[3]; a->data = erealloc(a->data, a->len); a->ndata = 0; } continue; } if(a->ndata < a->len){ n = a->len - a->ndata; if(n > m->ep - m->rp) n = m->ep - m->rp; memmove(a->data+a->ndata, getbytes(m, n), n); a->ndata += n; } if(a->ndata == a->len){ handlefullmsg(m->c, a); a->nlbuf = 0; } } }
BOOL check_space(COUNT drive, BYTE * BlkBuffer) { BYTE *bpbp; BYTE nfat; UWORD nfsect; ULONG hidden; ULONG count; ULONG block; UBYTE nreserved; UCOUNT i; WORD track, head, sector; UBYTE buffer[SEC_SIZE]; ULONG bpb_huge; UWORD bpb_nsize; /* get local information */ getbyte((VOID *) & BlkBuffer[BT_BPB + BPB_NFAT], &nfat); getword((VOID *) & BlkBuffer[BT_BPB + BPB_NFSECT], &nfsect); getlong((VOID *) & BlkBuffer[BT_BPB + BPB_HIDDEN], &hidden); getbyte((VOID *) & BlkBuffer[BT_BPB + BPB_NRESERVED], &nreserved); getlong((VOID *) & BlkBuffer[BT_BPB + BPB_HUGE], &bpb_huge); getword((VOID *) & BlkBuffer[BT_BPB + BPB_NSIZE], &bpb_nsize); count = miarray[drive].mi_size = bpb_nsize == 0 ? bpb_huge : bpb_nsize; /* Fix media information for disk */ getword((&(((BYTE *) & BlkBuffer[BT_BPB])[BPB_NHEADS])), &miarray[drive].mi_heads); head = miarray[drive].mi_heads; getword((&(((BYTE *) & BlkBuffer[BT_BPB])[BPB_NSECS])), &miarray[drive].mi_sectors); if (miarray[drive].mi_size == 0) getlong(&((((BYTE *) & BlkBuffer[BT_BPB])[BPB_HUGE])), &miarray[drive].mi_size); sector = miarray[drive].mi_sectors; if (head == 0 || sector == 0) { fprintf(stderr, "Drive initialization failure.\n"); exit(1); } miarray[drive].mi_cyls = count / (head * sector); return 1; }
void AGOSEngine_PN::getObjectName(char *v, uint16 x) { if (x & 0x8000) { x &= ~0x8000; if (x > getptr(51)) error("getObjectName: Object %d out of range", x); uncomstr(v, ftext(getlong(27), x * _dataBase[47])); } else { assert(x < 30); strcpy(v, objectNames[x]); } }
void AGOSEngine_PN::patok(int n) { int x; uint8 *tokbase; tokbase = _textBase + getlong(30); x = n; while (x -= (*tokbase++ > 127)) ; while (*tokbase < 128) pcf(*tokbase++); pcf((uint8)(*tokbase & 127)); }
void Satellite::tle(const char *nm, const char *l1, const char *l2) { name = nm ; // direct quantities from the orbital elements N = getlong(l2, 2, 7) ; YE = getlong(l1, 18, 20) ; if (YE < 58) YE += 2000 ; else YE += 1900 ; TE = getdouble(l1, 20, 32) ; M2 = RADIANS(getdouble(l1, 33, 43)) ; IN = RADIANS(getdouble(l2, 8, 16)) ; RA = RADIANS(getdouble(l2, 17, 25)) ; EC = getdouble(l2, 26, 33)/1e7f ; WP = RADIANS(getdouble(l2, 34, 42)) ; MA = RADIANS(getdouble(l2, 43, 51)) ; MM = 2.0f * M_PI * getdouble(l2, 52, 63) ; RV = getlong(l2, 63, 68) ; // derived quantities from the orbital elements // convert TE to DE and TE DE = fnday(YE, 1, 0) + (long) TE ; TE -= (long) TE ; N0 = MM/86400 ; A_0 = pow(GM/(N0*N0), 1./3.) ; B_0 = A_0*sqrt(1.-EC*EC) ; PC = RE*A_0/(B_0*B_0) ; PC = 1.5f*J2*PC*PC*MM ; double CI = cos(IN) ; QD = -PC*CI ; WD = PC*(5*CI*CI-1)/2 ; DC = -2*M2/(3*MM) ; }
COUNT get_part(COUNT drive, COUNT idx) { REG retry = N_RETRY; REG BYTE *p = (BYTE *) & buffer.bytes[PARTOFF + (idx * SIZEOF_PARTENT)]; REG ret; BYTE packed_byte, pb1; do { ret = fl_read((WORD) DrvMap[drive], (WORD) 0, (WORD) 0, (WORD) 1, (WORD) 1, (byteptr) & buffer); } while (ret != 0 && --retry > 0); if (ret != 0) return FALSE; getbyte((VOID *) p, &partition[idx].peBootable); ++p; getbyte((VOID *) p, &partition[idx].peBeginHead); ++p; getbyte((VOID *) p, &packed_byte); partition[idx].peBeginSector = packed_byte & 0x3f; ++p; getbyte((VOID *) p, &pb1); ++p; partition[idx].peBeginCylinder = pb1 + ((0xc0 & packed_byte) << 2); getbyte((VOID *) p, &partition[idx].peFileSystem); ++p; getbyte((VOID *) p, &partition[idx].peEndHead); ++p; getbyte((VOID *) p, &packed_byte); partition[idx].peEndSector = packed_byte & 0x3f; ++p; getbyte((VOID *) p, &pb1); ++p; partition[idx].peEndCylinder = pb1 + ((0xc0 & packed_byte) << 2); getlong((VOID *) p, &partition[idx].peStartSector); p += sizeof(LONG); getlong((VOID *) p, &partition[idx].peSectors); return TRUE; }
int getint(const char *fmt,int *myint) { long l; int ret; ret = getlong(fmt,&l); if( ret ==-1 || l<INT_MIN || l>INT_MAX ) return -1; if( myint ) *myint = l; return 0; }
char *AGOSEngine_PN::unctok(char *c, int n) { int x; uint8 *tokbase; tokbase = _textBase + getlong(30); x = n; while (x-=(*tokbase++ > 127)) ; while (*tokbase < 128) *c++=*tokbase++; *c++ = *tokbase & 127; *c = 0; return c; }
int AGOSEngine_PN::gvwrd(uint8 *wptr, int mask) { int val = 0, code = 0, q = _dataBase[57]; uint8 *vocbase = _dataBase + getlong(15); while (*vocbase != 255) { if (*vocbase < 0x80) { val = vocbase[q] + 256 * vocbase[q + 1]; code = vocbase[q + 2]; } if (wrdmatch(vocbase, mask, wptr, code)) return val; vocbase += (*vocbase > 127) ? q : q + 3; } return -1; }
static int readheaderformat(FILE *pcl,struct ttf_header *hdr) { int ch, i; memset(hdr,0,sizeof(*hdr)); fscanf(pcl,"%d", &hdr->header_size ); ch = getc(pcl); if ( ch!='W' ) { fprintf( stderr, "Bad font, font header command doesn't end in \"W\"\n" ); return( false ); } hdr->fd_size = getshort(pcl); hdr->header_format = getc(pcl); hdr->fonttype = getc(pcl); hdr->style = getc(pcl)<<8; (void) getc(pcl); hdr->baseline_pos = getshort(pcl); hdr->cell_width = getshort(pcl); hdr->cell_height = getshort(pcl); hdr->orientation = getc(pcl); hdr->spacing = getc(pcl); hdr->symbol_set = getshort(pcl); hdr->pitch = getshort(pcl); hdr->height = getshort(pcl); hdr->xheight = getshort(pcl); hdr->widthtype = getc(pcl); hdr->style |= getc(pcl); hdr->strokeweight = getc(pcl); hdr->typeface = getc(pcl); hdr->typeface |= getc(pcl)<<8; hdr->serifstyle = getc(pcl); hdr->quality = getc(pcl); hdr->placement = getc(pcl); hdr->upos = getc(pcl); hdr->uthick = getc(pcl); hdr->textheight = getshort(pcl); hdr->textwidth = getshort(pcl); hdr->firstcode = getshort(pcl); hdr->num_chars = getshort(pcl); hdr->pitchx = getc(pcl); hdr->heightx = getc(pcl); hdr->capheight = getshort(pcl); hdr->fontnumber = getlong(pcl); for ( i=0; i<16; ++i ) hdr->fontname[i] = getc(pcl); while ( i>1 && hdr->fontname[i-1]==' ' ) --i; hdr->fontname[i] = '\0'; return( false ); }