/* * Help Access Library * A Library to access the contents of Windows Help files. * * Copyright (C) 1995-2004 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. */ /* gettopiccount.c ------------------------------------ * @doc * @module gettopiccount.c | * Gets number of topics in a help file. * * Help Access Library Project. * *-----------------------------------------------------*/ #include #include #include #include #include #include "hlpacces.h" static int nGetBtreeCount(NPIFSFILE ifsfile); /** * Get the number of topics stored in a helpfile. * This is required to aid for "next" button handling * * @param ifs Handle for Integrated Help filesystem opened by IFSOpen * * @return Number of topics, -1 on error. */ int WINAPI HlpGetTopicCount(HIFS ifs) { int result=-1; NPIFSFILE ifsfile = IFSOpenFile(ifs, "|TTLBTREE"); if (ifsfile) { result = nGetBtreeCount(ifsfile); IFSCloseFile(ifsfile); } return result; } /** * Get the number of keywords stored in a helpfile. * * @param ifs Handle for Integrated Help filesystem opened by IFSOpen * * @return Number of Keywords, 0 on error. */ int WINAPI HlpGetKeywordCount(HIFS ifs) { int result=0; NPIFSFILE ifsfile = IFSOpenFile(ifs, "|KWBTREE"); if (ifsfile) { result = nGetBtreeCount(ifsfile); IFSCloseFile(ifsfile); } return result; } /** * Get the number of entries in a btree */ static int nGetBtreeCount(NPIFSFILE ifsfile) { BTREEHEADER BTreeHdr; //--------- Read Title B-Tree header ------------------ IFSReadFile(ifsfile, &BTreeHdr, sizeof(BTreeHdr)); return ledword(BTreeHdr.TotalBtreeEntries); }