File:  [OS/2 SDKs] / os2sdk / demos / apps / lqh / lqhinit.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:26:06 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: os2sdk-1988, HEAD
Microsoft OS/2 SDK 03-01-1988

/****************************************************************************

    PROGRAM: lqh.c

    MODULE: lqhinit.c

    FUNCTIONS:
        Init()

    COMMENTS:
        This module contains all the initialization that needs to be done
        when opening a new database. It returns TRUE if initialization was
        successful, or FALSE if the requested database could not be found
        or opened.

****************************************************************************/

#include "lqh.h"

BOOL Init() {
    USHORT i;
    CHAR chMessage[80];
    BYTE bScanCode;
    NC ncRequest;

    if (ncHelp)         /* Closes the current data file if its open */
        HelpClose(ncHelp);

    /* Open the help data file */

    if (!(ncHelp = HelpOpen((PCH) chHelpName))) {
        Dstrcpy(chMessage, "Cannot open ");
        Dstrcat(chMessage, chHelpName);
        BoxMessage(chMessage, atWARNING, THIN, hmou, TRUE);
        return FALSE;
    }

    /* A table is maintained of all preloaded topics that includes the
     * context number, the segment selector, the current top line displayed,
     * and the current highlighted line (if any). When HelpSearch is called,
     * it checks this table, and if the context number is found, it uses the
     * selector associated with that context number to retrieve the
     * decompressed data. If the context number is not found, it will call the
     * help-engine routines to decompress the data. Whenever Init() is called,
     * it deallocates any existing selectors, and clears all the context
     * numbers, that indicate no data has been preloaded.
     */

    for (i = 0; i < MAXPRELOAD; i++) {
        selTable[i].ncContext = (NC) 0; /* no context               */
        selTable[i].usTopLine = 1;    /* default current position   */
        if (selTable[i].sel)          /* Frees any allocated memory */
            DosFreeSeg(selTable[i].sel);
    }

    usListPos = 0;
    if ((ncRequest = HelpNc("List categories", ncHelp))) {

        /* The list of categories will be small, so both the
         * compressed and decompressed data are placed in the 64K-memory block
         * that is used for the character-attribute strings.
         */

        HelpLook(ncRequest, MAKEP(selStringTable, 0));
        HelpDecomp(MAKEP(selStringTable, 0),
            MAKEP(selStringTable, 32000), ncRequest);
        while (HelpGetLine(usListPos + 2, MAXCATNAME,
                (PCH) lstList[usListPos].name, MAKEP(selStringTable, 32000))
                > 1)
            usListPos++;
    }

    return TRUE;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.