/* * Help Access Library * A Library to access the contents of Windows Help files. * * Copyright (C) 1995-2000 Bernd Herd, http://www.herdsoft.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* GETVAL.C ------------------------------------------- * @doc * * @module GETVAL.C | * Simple iGetLongValue, iGetShortValue etc. routines * * Help Access Library Project. * *-----------------------------------------------------*/ #include #include #include #include #include "hlpacces.h" #include "top.h" int iGetShortValue(BYTE **from, UINT *length) { BYTE *p = *from; UINT l = *length; short a = *p++; --l; if (a & 1) { a|= (short) ( (*p++) << 8); --l; a-=(short) 0x8000; } else a -= (short) 0x80; a /= (short) 2; *length=l; *from =p; return a; } LONG iGetLongValue(BYTE **from, UINT *length) { WORD w1= iGetLeWordValue(from, length), w2; LONG a; if (!(w1 & 1)) a = w1-0x8000; else { w2 = iGetLeWordValue(from, length); a = (w1 + w2*65536)-0x80000000L; } return a; } /*LONG iGetLongValue(BYTE **from, UINT *length) { WORD *p = (WORD *) (*from); LONG l = *length; LONG a = *p++; --l; if (a & 1) { a |= ( (LONG) (*p++)) << 16; --l; a-= 0x80000000L; } else a-= 0x8000; a /= 2; *length=l; *from =(BYTE *) p; return a; }*/ short iGetWordValue(BYTE **from, UINT *length) { BYTE *p = *from; UINT l = *length; short a = *p++; --l; if (a & 1) { a|= (short) ((*p++) << 8); --l; } a /= (short) 2; *length=l; *from =p; return a; } WORD iGetLeWordValue(BYTE **from, UINT *length) { BYTE *p = *from; WORD a = p[0]+p[1]*256; *from += sizeof(WORD); if (length!=NULL) *length -= sizeof(WORD); return a; } // iGetLeWordValue DWORD iGetLeDWordValue(BYTE **from, UINT *length) { BYTE *p = *from; DWORD a = p[0]+p[1]*256+(p[2]<<16)+(p[3]<<24); *from += sizeof(DWORD); if (length!=NULL) *length -= sizeof(DWORD); //printf("a:%d",a); return a; } // iGetLeDWordValue