Annotation of os2sdk/demos/apps/lqh/lqhinit.c, revision 1.1.1.1

1.1       root        1: /****************************************************************************
                      2: 
                      3:     PROGRAM: lqh.c
                      4: 
                      5:     MODULE: lqhinit.c
                      6: 
                      7:     FUNCTIONS:
                      8:         Init()
                      9: 
                     10:     COMMENTS:
                     11:         This module contains all the initialization that needs to be done
                     12:         when opening a new database. It returns TRUE if initialization was
                     13:         successful, or FALSE if the requested database could not be found
                     14:         or opened.
                     15: 
                     16: ****************************************************************************/
                     17: 
                     18: #include "lqh.h"
                     19: 
                     20: BOOL Init() {
                     21:     USHORT i;
                     22:     CHAR chMessage[80];
                     23:     BYTE bScanCode;
                     24:     NC ncRequest;
                     25: 
                     26:     if (ncHelp)         /* Closes the current data file if its open */
                     27:         HelpClose(ncHelp);
                     28: 
                     29:     /* Open the help data file */
                     30: 
                     31:     if (!(ncHelp = HelpOpen((PCH) chHelpName))) {
                     32:         Dstrcpy(chMessage, "Cannot open ");
                     33:         Dstrcat(chMessage, chHelpName);
                     34:         BoxMessage(chMessage, atWARNING, THIN, hmou, TRUE);
                     35:         return FALSE;
                     36:     }
                     37: 
                     38:     /* A table is maintained of all preloaded topics that includes the
                     39:      * context number, the segment selector, the current top line displayed,
                     40:      * and the current highlighted line (if any). When HelpSearch is called,
                     41:      * it checks this table, and if the context number is found, it uses the
                     42:      * selector associated with that context number to retrieve the
                     43:      * decompressed data. If the context number is not found, it will call the
                     44:      * help-engine routines to decompress the data. Whenever Init() is called,
                     45:      * it deallocates any existing selectors, and clears all the context
                     46:      * numbers, that indicate no data has been preloaded.
                     47:      */
                     48: 
                     49:     for (i = 0; i < MAXPRELOAD; i++) {
                     50:         selTable[i].ncContext = (NC) 0; /* no context               */
                     51:         selTable[i].usTopLine = 1;    /* default current position   */
                     52:         if (selTable[i].sel)          /* Frees any allocated memory */
                     53:             DosFreeSeg(selTable[i].sel);
                     54:     }
                     55: 
                     56:     usListPos = 0;
                     57:     if ((ncRequest = HelpNc("List categories", ncHelp))) {
                     58: 
                     59:         /* The list of categories will be small, so both the
                     60:          * compressed and decompressed data are placed in the 64K-memory block
                     61:          * that is used for the character-attribute strings.
                     62:          */
                     63: 
                     64:         HelpLook(ncRequest, MAKEP(selStringTable, 0));
                     65:         HelpDecomp(MAKEP(selStringTable, 0),
                     66:             MAKEP(selStringTable, 32000), ncRequest);
                     67:         while (HelpGetLine(usListPos + 2, MAXCATNAME,
                     68:                 (PCH) lstList[usListPos].name, MAKEP(selStringTable, 32000))
                     69:                 > 1)
                     70:             usListPos++;
                     71:     }
                     72: 
                     73:     return TRUE;
                     74: }

unix.superglobalmegacorp.com

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