/* * 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. */ /* ISSECOND.C ----------------------------------------- * * @doc * @module ISSECOND.C | * Test validity of Secondary Window Names * * Help File Acces Project. * *-----------------------------------------------------*/ #include #include #include #include #include #include "hlpacces.h" /* Help Compiler 3.1 System record. Multiple records possible */ #pragma pack(1) typedef struct SYSTEMRECORD { WORD RecordType; /* Type of Data in record */ WORD DataSize; /* Size of RData */ } PACKED SYSTEMRECORD, NEAR *NPSYSTEMRECORD; #pragma pack() /* @func BOOL | IsSecondaryWindow | * * Tests if the given Help-File contains a Definition of the diven Secondary Window-Name. * * @rdesc Indicates if the Window-Definition exists * @flag TRUE | The file contains such a Window-Definition * @flag FALSE| The file does not exist, is no help file or does not contain such a Window-Definition * @comm Lower/Upper case do not care. * */ BOOL WINAPI DLLEXP IsSecondaryWindow( LPCSTR FileName, // @parm Filename of the Help-File LPCSTR WindowName) // @parm name of the secondary Window { NPIFS ifs = IFSOpen (FileName); NPIFSFILE ifsfile; BOOL rtn = FALSE; SYSTEMHEADER SysHeader; /* Global System Header Record */ SYSTEMRECORD SystemRec; NPSTR ptr; SECWINDOW NEAR *SWin; /* Secondary Window record */ if (ifs) { ifsfile = IFSOpenFile(ifs, "|SYSTEM"); if (ifsfile) { //---------- Read in System-Header ------------------------ IFSReadFile(ifsfile, &SysHeader, sizeof(SYSTEMHEADER)); //---------- Read Records --------------------------------- while (!rtn && sizeof(SYSTEMRECORD) ==IFSReadFile(ifsfile, &SystemRec, sizeof(SYSTEMRECORD)) && NULL !=(ptr=(NPSTR) LocalAlloc(LPTR, SystemRec.DataSize)) && SystemRec.DataSize ==IFSReadFile(ifsfile, ptr, SystemRec.DataSize) ) { SWin = (SECWINDOW *) ptr; if (SystemRec.RecordType == 0x0006) rtn = !stricmp((NPSTR) SWin->Name, WindowName); LocalFree((HLOCAL) ptr); } IFSCloseFile(ifsfile); } IFSClose(ifs); } return rtn; }