home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / SD386PRO.C < prev    next >
Text File  |  1995-12-11  |  48KB  |  838 lines

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   sd86pro.c                                                               */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*   Define key map for windows.                                             */
  7. /*                                                                           */
  8. /* History:                                                                  */
  9. /*                                                                           */
  10. /*   02/08/91 Creation of 32-bit SD386, from 16-bit version                  */
  11. /*                                                                           */
  12. /*...Release 1.00                                                            */
  13. /*...                                                                        */
  14. /*... 02/08/91  116   rewritten for 32 bit.                                  */
  15. /*                                                                           */
  16. /*...Release 1.00 (Pre-release 105 10/10/91)                                 */
  17. /*...                                                                        */
  18. /*... 10/31/91  308   Srinivas  Menu for exceptions.                         */
  19. /*...                                                                        */
  20. /*...Release 1.00 (Pre-release 108 12/05/91)                                 */
  21. /*...                                                                        */
  22. /*... 02/12/92  521   Srinivas  Port to C-Set/2.                             */
  23. /*... 01/12/93  808   Selwyn    Profile fixes/improvements.                  */
  24. /*... 01/04/94  913   Joe       Trap when reading .pro and no 0x1a.          */
  25. /*****************************************************************************/
  26.  
  27. #define INCL_PROFILE_ARRAYS
  28.  
  29. #include "all.h"                        /* SD386 include files               */
  30. #include "diahelp.h"
  31. #define __MIG_LIB__                                                     /*521*/
  32. #include <io.h>
  33. /**Variables defined**********************************************************/
  34.  
  35. extern   uchar    VideoAtr;
  36. extern   uchar   *VideoMap;             /* video attribute map               */
  37. extern   char    *vaTypes[];            /* video attribute types             */
  38. extern   char    *FGColors[];           /* foreground color names            */
  39. extern   char    *BGColors[];           /* background color names            */
  40.  
  41.  
  42. extern   uchar    ExceptionMap[MAXEXCEPTIONS];
  43. extern   char    *ExcepTypes[MAXEXCEPTIONS];
  44. extern   char    *ExcepSel[];           /* notification names                */
  45. extern   uchar   ClearField[];          /* clear field attributes         701*/
  46. extern   uchar   hilite[];              /* high light field attributes    701*/
  47. extern   uchar   normal[];              /* normal field attributes        701*/
  48.  
  49. extern   CmdParms cmd;
  50. static   int   index[USERKEYS][2];
  51.  
  52. typedef  struct _keyshelp
  53. {
  54.   int   key;
  55.   ULONG helpid;
  56. } KEYSHELP;
  57.  
  58. #define NUMKEYSHELP 4
  59.  
  60. static KEYSHELP KeysHelp[] =
  61. {
  62.   { F10,  HELP_ABAR_ABAR },
  63.   { ESC,  HELP_ABAR_ABAR },
  64.   { C_F2, HELP_PULL_DATASHOW },
  65.   { S_F9, HELP_PULL_DATABREAK }
  66. };
  67.  
  68. #define READERROR      1
  69. #define VERSIONERROR   2
  70. #define DEFSECERROR    3
  71. #define NOKEYERROR     4
  72. #define NOFUNCERROR    5
  73. #define NOATTRERROR    6
  74. #define NOBGCLRERROR   7
  75. #define NOFGCLRERROR   8
  76. #define NOEXTYPERROR   9
  77. #define NOEXCEPERROR   0
  78. #define NESTEDCMT     10
  79.  
  80. /*****************************************************************************/
  81. /* Profile                                                                   */
  82. /*                                                                           */
  83. /* Description:                                                              */
  84. /*   See if the sd386.pro profile exists and alter scan code to function     */
  85. /*   table accordingly.                                                      */
  86. /*   Set user-defined color values to logical attributes.                    */
  87. /*                                                                           */
  88. /* Parameters:                                                               */
  89. /*   defk2f     scan code to function table (similar to KEY2FUNC).           */
  90. /*                                                                           */
  91. /* Return:                                                                   */
  92. /*   char *     Error message to be displayed.                               */
  93. /*                                                                           */
  94. /*****************************************************************************/
  95. void  Profile( KEY2FUNC  defk2f[])
  96.                                         /* scan code to function table       */
  97. {                                       /* begin Profile                     */
  98.   int         fh;                       /* pointer to profile file        808*/
  99.   uint        bg, fg;                   /* bg and fg color indices           */
  100.   uint        f, k, n, kf;              /* indices                           */
  101.   uchar      *fn;                       /* fully qualified file name         */
  102.   int         ErrorCode;                /* return code.                      */
  103.   long        FileSize;                 /* Total file size of .pro        808*/
  104.   long        LineNum;
  105.   char        LineNumStr[10];
  106.   long        CurrentChar;              /* Current character pos in file  808*/
  107.   char        *FileBuffer, *BufferStart;/* Buffer to read the file.       808*/
  108.   char        *newtext;                 /* string to look for either:        */
  109.                                         /*   1) "Start_Of_Defs" indicator,   */
  110.                                         /*   2) profile key,                 */
  111.                                         /*   3) function definition,         */
  112.                                         /*   4) "Start_Of_Colors" indicator, */
  113.                                         /*   5) attribute name,              */
  114.                                         /*   6) background color name, or    */
  115.                                         /*   7) foreground color name,       */
  116. /*****************************************************************************/
  117. /* We want to find SD386.PRO according to a specified path search.           */
  118. /*                                                                           */
  119. /*****************************************************************************/
  120.   fn=Talloc(MAXFNAMELEN);               /* allocate space for a fully     521*/
  121.                                         /* qualified filename.               */
  122.   findpro("SD386.PRO",fn,MAXFNAMELEN);  /* get fully qualified profile nam116*/
  123. /*****************************************************************************/
  124. /*                                                                           */
  125. /* First we must see if the profile exists.  If it does not, the defaults    */
  126. /* are as you see them in defk2f.  If it does, we shall read in a character  */
  127. /* string key and convert that to a scan code.  We will then read in a       */
  128. /* character string function definition, and convert that to a function code.*/
  129. /* Then we will search defk2f for the scan code and replace that entry's     */
  130. /* function code with the one read in.  We will do this for as many key code */
  131. /* and function code definitions that exist realizing that comments and other*/
  132. /* information character strings exist in the file.                          */
  133. /*                                                                           */
  134. /*****************************************************************************/
  135.   fh = open( fn, 0x00000004 | 0x00008000, NULL );                       /*808*/
  136.   if(fn) Tfree(fn);                                                      /*813*/
  137.   if( fh == -1 )                        /* troubles opening it ?             */
  138.     return;                             /* we are done; later, you may want  */
  139.                                         /*   to notify the user              */
  140.   FileSize = filelength( fh );                                          /*808*/
  141.  
  142.   FileBuffer = (char *)Talloc( FileSize + 1 );                          /*808*/
  143.   BufferStart = FileBuffer;                                             /*808*/
  144.   memset( FileBuffer, '\0', FileSize + 1 );                             /*808*/
  145.  
  146.   if( read( fh, FileBuffer, FileSize ) == -1 )                          /*808*/
  147.   {                                                                     /*808*/
  148.     ErrorCode = READERROR;                                              /*808*/
  149.     goto error;                                                         /*808*/
  150.   }                                                                     /*808*/
  151.  
  152. /*****************************************************************************/
  153. /*                                                                           */
  154. /* Here we search for the title area.  This allows the user to format his    */
  155. /* informational front matter in any manner that he wants.                   */
  156. /*                                                                           */
  157. /*****************************************************************************/
  158.  
  159.   newtext = strtok( FileBuffer, "\n" );                                 /*808*/
  160.   if( strncmp( newtext, "Version 2.00", 12 ) )                          /*808*/
  161.   {                                                                     /*808*/
  162.     ErrorCode = VERSIONERROR;                                           /*808*/
  163.     goto error;                                                         /*808*/
  164.   }                                                                     /*808*/
  165.  
  166.   newtext = strtok( NULL, " \n" );                                      /*808*/
  167.   while( newtext )                                                      /*808*/
  168.   {
  169.     if ( !strncmp( newtext, "Start_Of_Defs", 13 ) )
  170.       break;                            /* we are done searching             */
  171.    newtext = strtok( NULL, " \n" );                                     /*808*/
  172.   }
  173.  
  174.   if( !newtext )                                                        /*808*/
  175.   {                                                                     /*808*/
  176.     ErrorCode = DEFSECERROR;                                            /*808*/
  177.     goto error;                                                         /*808*/
  178.   }                                                                     /*808*/
  179.  
  180. /*****************************************************************************/
  181. /*                                                                           */
  182. /* Now we can process the key to function code area.  We next try to find a  */
  183. /* key definition in the file and see if it is the key2code table.           */
  184. /*                                                                           */
  185. /*****************************************************************************/
  186.  
  187. keydef:
  188.   while( (newtext = strtok( NULL, " \n" )) &&                           /*808*/
  189.          strnicmp(newtext, "Start_Of_Colors", 15 ))                     /*808*/
  190.   {                                     /* process key/func definitions      */
  191.     if( *newtext == 0x0d )              /* skip blank lines.              808*/
  192.       goto keydef;                                                      /*808*/
  193.  
  194.     if( *newtext == 0x1a )              /* if end of file break.          808*/
  195.       break;                                                            /*808*/
  196.  
  197.     if( newtext[0] == '?' )             /* If you get a '?' as the first  701*/
  198.     {                                   /* character, key is not defined  701*/
  199.       newtext = strtok( NULL, " \n" );  /* for the function, so skip the  808*/
  200.       if( newtext )                     /* full line.                     701*/
  201.         goto keydef;                                                    /*701*/
  202.     }                                                                   /*701*/
  203.  
  204.     if ( newtext[0] == '/' &&           /* did we find the start of a        */
  205.          newtext[1] == '*'    )         /*   comment ?                       */
  206.     {                                   /* begin processing comment          */
  207.       while( !strstr( newtext, "*/" ) && /* not found comment end yet and we */
  208.              newtext  )                   /*   still have room to read ?     */
  209.       {                                                                 /*808*/
  210.         newtext = strtok( NULL, " \n" );  /* read in potential end of cmt 808*/
  211.         if( strstr( newtext, "/*" ) )                                   /*808*/
  212.         {                                                               /*808*/
  213.           ErrorCode = NESTEDCMT;                                        /*808*/
  214.           goto error;                                                   /*808*/
  215.         }                                                               /*808*/
  216.       }
  217.       goto keydef;                      /* try to get a key definition       */
  218.     }                                   /* end processing comment            */
  219.  
  220. /*****************************************************************************/
  221. /*                                                                           */
  222. /* Now we see if the key definition matches any of our key names in the      */
  223. /* key2code table.  If it does, we know the scan code for the definition.    */
  224. /*                                                                           */
  225. /*****************************************************************************/
  226.  
  227.     for(
  228.          k = 0;                         /* will start w/1st key2code entry   */
  229.          k < USERKEYS;                  /* stay within key2code         /*808*/
  230.          k++                            /* bump to next key2code entry       */
  231.        )
  232.     {
  233.       int CompareLen = strlen( newtext );                               /*808*/
  234.  
  235.       if( newtext[CompareLen - 1] == 0xd )                              /*808*/
  236.         CompareLen--;                                                   /*808*/
  237.       if( !strnicmp( newtext, key2code[k].key, CompareLen ) )           /*808*/
  238.         break;                          /* then we are done looking          */
  239.     }
  240.  
  241.       if ( k == USERKEYS )              /* did we not find this key def   808*/
  242.       {                                 /* this is a problem!                */
  243.         ErrorCode = NOKEYERROR;                                         /*808*/
  244.         goto error;                                                     /*808*/
  245.       }                                 /* end this is a problem             */
  246.  
  247. /*****************************************************************************/
  248. /*                                                                           */
  249. /* Now we try to find a function definition to pair up with our key scan     */
  250. /* code.  We need to ensure that this function definition is legit, too.     */
  251. /*                                                                           */
  252. /*****************************************************************************/
  253.  
  254. funcdef:
  255.     newtext = strtok( NULL, " \n" );    /* read in potential func def.    808*/
  256.     if ( newtext[0] == '/' &&           /* did we find the start of a        */
  257.          newtext[1] == '*'    )         /*   comment ?                       */
  258.     {                                   /* begin processing comment          */
  259.       while( !strstr( newtext, "*/" ) && /* not found comment end yet and we */
  260.              newtext )                     /*   still have room to read ?    */
  261.       {                                                                 /*808*/
  262.         newtext = strtok( NULL, " \n" );   /* read in potential cmt end   808*/
  263.         if( strstr( newtext, "/*" ) )                                   /*808*/
  264.         {                                                               /*808*/
  265.           ErrorCode = NESTEDCMT;                                        /*808*/
  266.           goto error;                                                   /*808*/
  267.         }                                                               /*808*/
  268.       }
  269.  
  270.       if ( !newtext )                   /* still have room to read ?    /*808*/
  271.         goto funcdef;                   /* try to get a func definition      */
  272.     }                                   /* end processing comment            */
  273.  
  274. /*****************************************************************************/
  275. /*                                                                           */
  276. /* Now we see if the function definition mathces any of our names in the     */
  277. /* func2code table.  If it does, we know the function code for the           */
  278. /* definition.                                                               */
  279. /*                                                                           */
  280. /*****************************************************************************/
  281.  
  282.     for(
  283.          f = 0;                         /* will start w/1st func2code entry  */
  284.          f < USERFUNCS;                 /* stay within func2code          808*/
  285.          f++                            /* bump to nest func2code entry      */
  286.        )
  287.     {
  288.       int CompareLen = strlen( newtext );                               /*808*/
  289.  
  290.       if( newtext[CompareLen - 1] == 0xd )                              /*808*/
  291.         CompareLen--;                                                   /*808*/
  292.       if ( !strnicmp( newtext, func2code[f].func, CompareLen ))         /*808*/
  293.         break;                          /* then we are done looking          */
  294.     }
  295.  
  296.       if ( f == USERFUNCS )             /* did we not find this func def  808*/
  297.       {                                 /* this is a problem!                */
  298.         ErrorCode = NOFUNCERROR;                                        /*808*/
  299.         goto error;                                                     /*808*/
  300.       }                                 /* end this is a problem             */
  301.  
  302. /*****************************************************************************/
  303. /*                                                                           */
  304. /* At this point we have a scan code and a function code that the user wants */
  305. /* associated.  We look within defk2f for the scan code, and, if found, we   */
  306. /* replace the defk2f function code with the new one.                        */
  307. /*                                                                           */
  308. /*****************************************************************************/
  309.  
  310.     for(
  311.          kf = 0;                        /* will start w/1st defk2f entry     */
  312.          kf < KEYNUMSOC;                /* stay within defk2f                */
  313.          kf++                           /* bump to next defk2f entry         */
  314.        )
  315.       if ( defk2f[kf].scode == key2code[k].scode ) /* find scan code match ? */
  316.         break;                          /* then we are done looking          */
  317.  
  318.       if ( kf == KEYNUMSOC )            /* did we not find the scan code ?   */
  319.       {                                 /* this is a problem!                */
  320.         ErrorCode = NOKEYERROR;                                         /*808*/
  321.         goto error;                                                     /*808*/
  322.       }                                 /* end this is a problem             */
  323.       defk2f[kf].fcode = func2code[f].fcode; /* put in the func def code     */
  324.   }                                     /* end process key/func definitions  */
  325.  
  326.  
  327. /*****************************************************************************/
  328. /*                                                                           */
  329. /* Now we can process the attribute to colors area.  We next try to find an  */
  330. /* attribute definition in the file and see if it is in the vaTypes table.   */
  331. /*                                                                           */
  332. /*****************************************************************************/
  333.  
  334.  if( !strnicmp(newtext, "Start_Of_Colors", 15 ) )
  335. colordef:                                                               /*308*/
  336.   while( (newtext = strtok( NULL, " \n" )) &&                           /*808*/
  337.          strnicmp(newtext, "Start_Of_Exceptions", 19 ))
  338.                                         /* and not yet Start_Of_Exceptions308*/
  339.   {                                     /* process key/func definitions      */
  340.     if( *newtext == 0x0d )              /* skip blank lines.              808*/
  341.       goto colordef;                                                    /*808*/
  342.  
  343.     if( *newtext == 0x1a )              /* if end of file break.          808*/
  344.       break;                                                            /*808*/
  345.  
  346.     if ( newtext[0] == '/' &&           /* did we find the start of a        */
  347.          newtext[1] == '*'    )         /*   comment ?                       */
  348.     {                                   /* begin processing comment          */
  349.       while( !strstr( newtext, "*/" ) && /* not found comment end yet and we */
  350.              newtext  )                   /*   still have room to read ?     */
  351.       {                                                                 /*808*/
  352.         newtext = strtok( NULL, " \n" );  /* read in potential end of cmt 808*/
  353.         if( strstr( newtext, "/*" ) )                                   /*808*/
  354.         {                                                               /*808*/
  355.           ErrorCode = NESTEDCMT;                                        /*808*/
  356.           goto error;                                                   /*808*/
  357.         }                                                               /*808*/
  358.       }
  359.       goto colordef;                    /* try to get a key definition       */
  360.     }                                   /* end processing comment            */
  361.  
  362. /*****************************************************************************/
  363. /*                                                                           */
  364. /* Now we see if the attribute matches any of our attribute names in the     */
  365. /* vaTypes table.  If it does, we know the index for the attribute.          */
  366. /*                                                                           */
  367. /*****************************************************************************/
  368.  
  369.    for(
  370.         k = 1;                          /* will start w/1st vaTypes entry    */
  371.         k <= MAXVIDEOATR &&             /* stay within vaTypes, and          */
  372.         stricmp(newtext, vaTypes[k]);
  373.         k++                             /* bump to next vaTypes entry        */
  374.       ){;}
  375.  
  376.    if ( k > MAXVIDEOATR )               /* did we not find this attr def?    */
  377.    {                                    /* this is a problem!                */
  378.      ErrorCode = NOATTRERROR;                                           /*808*/
  379.      goto error;                                                        /*808*/
  380.    }                                    /* end this is a problem             */
  381.  
  382. /*****************************************************************************/
  383. /*                                                                           */
  384. /* Now we try to find a background color to match up with our attribute      */
  385. /* index.  We need to ensure that this background color is legit, too.       */
  386. /*                                                                           */
  387. /*****************************************************************************/
  388.  
  389.   while( (newtext = strtok( NULL, " \n" )) &&                           /*808*/
  390.       newtext[0] == '/' &&              /* did we find the start of a        */
  391.       newtext[1] == '*'    )            /*   comment ?                       */
  392.     while( !strstr( newtext, "*/" ) &&  /* while not found end of comment    */
  393.             newtext )                                                   /*808*/
  394.       {                                                                 /*808*/
  395.         newtext = strtok( NULL, " \n" );                                /*808*/
  396.         if( strstr( newtext, "/*" ) )                                   /*808*/
  397.         {                                                               /*808*/
  398.           ErrorCode = NESTEDCMT;                                        /*808*/
  399.           goto error;                                                   /*808*/
  400.         }                                                               /*808*/
  401.       }
  402.  
  403. /*****************************************************************************/
  404. /*                                                                           */
  405. /* Now we see if the bg color matches any of our bg color names in the       */
  406. /* BGColors table.  If it does, we know the index for the bg color.          */
  407. /*                                                                           */
  408. /*****************************************************************************/
  409.  
  410.    for(
  411.         bg = 0;                         /* start w/1st BGColors entry        */
  412.         bg < MAXBGCOLOR &&              /* stay within BGColors, and         */
  413.         strnicmp(newtext, BGColors[bg], strlen( BGColors[bg] ));
  414.         bg++                            /* bump to next BGColors entry       */
  415.       ){;}
  416.  
  417.    if ( bg == MAXBGCOLOR )              /* did we not find this bg color?    */
  418.    {                                    /* this is a problem!                */
  419.      ErrorCode = NOBGCLRERROR;                                          /*808*/
  420.      goto error;                                                        /*808*/
  421.    }                                    /* end this is a problem             */
  422.  
  423. /*****************************************************************************/
  424. /*                                                                           */
  425. /* Now we try to find a foreground color to match up with our attribute      */
  426. /* index.  We need to ensure that this foreground color is legit, too.       */
  427. /*                                                                           */
  428. /*****************************************************************************/
  429.  
  430.   while( (newtext = strtok( NULL, " \n" )) &&                           /*808*/
  431.       newtext[0] == '/' &&              /* did we find the start of a        */
  432.       newtext[1] == '*'    )            /*   comment ?                       */
  433.     while( !strstr( newtext, "*/" ) &&  /* while not found end of comment    */
  434.             newtext )                                                   /*808*/
  435.       {                                                                 /*808*/
  436.         newtext = strtok( NULL, " \n" );                                /*808*/
  437.         if( strstr( newtext, "/*" ) )                                   /*808*/
  438.         {                                                               /*808*/
  439.           ErrorCode = NESTEDCMT;                                        /*808*/
  440.           goto error;                                                   /*808*/
  441.         }                                                               /*808*/
  442.       }
  443.  
  444. /*****************************************************************************/
  445. /*                                                                           */
  446. /* Now we see if the fg color matches any of our fg color names in the       */
  447. /* FGColors table.  If it does, we know the index for the fg color.          */
  448. /*                                                                           */
  449. /*****************************************************************************/
  450.  
  451.    for(
  452.         fg = 0;                         /* start w/1st FGColors entry        */
  453.         fg < MAXFGCOLOR &&              /* stay within FGColors, and         */
  454.         strnicmp(newtext, FGColors[fg], strlen( FGColors[fg] ));
  455.         fg++                            /* bump to next FGColors entry       */
  456.       ){;}
  457.  
  458.    if ( fg == MAXFGCOLOR )              /* did we not find this fg color?    */
  459.    {                                    /* this is a problem!                */
  460.      ErrorCode = NOFGCLRERROR;                                          /*808*/
  461.      goto error;                                                        /*808*/
  462.    }                                    /* end this is a problem             */
  463.  
  464. /*****************************************************************************/
  465. /*                                                                           */
  466. /* At this point we have attribute, background, and foreground indices that  */
  467. /* user wants associated.  We now assign the background and foreground       */
  468. /* colors to the attribute indexed into the VideoMap table.                  */
  469. /*                                                                           */
  470. /*****************************************************************************/
  471.  
  472.    VideoMap[k] = ( uchar )(( bg << 4 ) + fg);/* Assign clrs to attribute     */
  473.   }                                     /* end process attr/color defs       */
  474.  
  475. /*****************************************************************************/
  476. /* Now we can process the notifications of the exceptions                 308*/
  477. /*****************************************************************************/
  478.  
  479.  if( !strnicmp(newtext, "Start_Of_Exceptions", 19 ))
  480.   for ( ; ; )                           /* Loop until end of file            */
  481.   {                                     /* process attr/color definitions    */
  482.    while( (newtext = strtok( NULL, " \n" ) ) &&                         /*808*/
  483.       newtext[0] == '/' &&              /* did we find the start of a        */
  484.       newtext[1] == '*'    )            /*   comment ?                       */
  485.     while( !strstr( newtext, "*/" ) &&  /* while not found end of comment    */
  486.             newtext )                                                   /*808*/
  487.       {                                                                 /*808*/
  488.         newtext = strtok( NULL, " \n" );                                /*808*/
  489.         if( strstr( newtext, "/*" ) )                                   /*808*/
  490.         {                                                               /*808*/
  491.           ErrorCode = NESTEDCMT;                                        /*808*/
  492.           goto error;                                                   /*808*/
  493.         }                                                               /*808*/
  494.       }
  495.  
  496.     if( newtext == NULL )                                               /*913*/
  497.      break;                                                             /*913*/
  498.  
  499.     if( *newtext == 0x1a )              /* if end of file break.          808*/
  500.       break;                                                            /*808*/
  501.  
  502.     if( *newtext == 0x0d )              /* skip blank lines.            /*808*/
  503.       continue;
  504.  
  505.    if( !newtext )                       /* if no more attributes to read  808*/
  506.     break;                              /* exit loop and close file          */
  507.  
  508. /*****************************************************************************/
  509. /*                                                                           */
  510. /* Now we see if the exception type matches any of our exception types in the*/
  511. /* Excepypes table.  If it does, we know the index for the ExceptionType.    */
  512. /*                                                                           */
  513. /*****************************************************************************/
  514.  
  515.    for(
  516.         k = 0;                          /* will start w/1st vaTypes entry    */
  517.         k <  MAXEXCEPTIONS &&           /* stay within vaTypes, and          */
  518.         strnicmp(newtext, ExcepTypes[k], strlen( ExcepTypes[k] ));
  519.         k++                             /* bump to next vaTypes entry        */
  520.       ){;}
  521.  
  522.    if ( k >= MAXEXCEPTIONS )            /* did we not find this attr def?    */
  523.    {                                    /* this is a problem!                */
  524.      ErrorCode = NOEXTYPERROR;                                          /*808*/
  525.      goto error;                                                        /*808*/
  526.    }                                    /* end this is a problem             */
  527.  
  528. /*****************************************************************************/
  529. /*                                                                           */
  530. /* Now we try to find notification choice for the exception type.            */
  531. /* We need to ensure that notification choice is legal too.                  */
  532. /*                                                                           */
  533. /*****************************************************************************/
  534.  
  535.   while( (newtext = strtok( NULL, " \n" ) ) &&                          /*808*/
  536.       newtext[0] == '/' &&              /* did we find the start of a        */
  537.       newtext[1] == '*'    )            /*   comment ?                       */
  538.     while( !strstr( newtext, "*/" ) &&  /* while not found end of comment    */
  539.             newtext )                                                   /*808*/
  540.       {                                                                 /*808*/
  541.         newtext = strtok( NULL, " \n" );                                /*808*/
  542.         if( strstr( newtext, "/*" ) )                                   /*808*/
  543.         {                                                               /*808*/
  544.           ErrorCode = NESTEDCMT;                                        /*808*/
  545.           goto error;                                                   /*808*/
  546.         }                                                               /*808*/
  547.       }
  548.  
  549. /*****************************************************************************/
  550. /*                                                                           */
  551. /* Now verify that the notification is in the ExcepSel table. If it does     */
  552. /* we know the index for it.                                                 */
  553. /*                                                                           */
  554. /*****************************************************************************/
  555.  
  556.    for(
  557.         n  = 0;                         /* start w/1st entry                 */
  558.         n < 2 &&                        /* stay within bounds, and           */
  559.         strnicmp(newtext, ExcepSel[n], strlen( ExcepSel[n] ));
  560.         n++                             /* bump to next entry                */
  561.       ){;}
  562.  
  563.    if ( n == 2 )                        /* did we not find this entry        */
  564.    {                                    /* this is a problem!                */
  565.      ErrorCode = NOEXCEPERROR;                                          /*808*/
  566.      goto error;                                                        /*808*/
  567.    }                                    /* end this is a problem             */
  568.  
  569. /*****************************************************************************/
  570. /*                                                                           */
  571. /* At this point we have exception type and its notification choice indices  */
  572. /* that user wants associated.  We now assign the notification choice into   */
  573. /* the ExceptionMap table.                                                   */
  574. /*                                                                           */
  575. /*****************************************************************************/
  576.  
  577.    ExceptionMap[k] = n;                 /* Assign the notification choice    */
  578.   }                                     /* end exception notifications       */
  579.   close( fh );                          /* proper handshaking with close  808*/
  580.   Tfree( BufferStart );                                                  /*808*/
  581.   xSetExceptions(ExceptionMap,sizeof(ExceptionMap) );
  582.   return;
  583.  
  584. error:                                                                  /*808*/
  585.   {                                                                     /*808*/
  586.     char *BufferScan = BufferStart;                                     /*808*/
  587.     long  i;                                                            /*808*/
  588.  
  589.     CurrentChar = newtext - BufferStart;                                /*808*/
  590.     for( LineNum = 1, i = 0; i < CurrentChar; i++ )                     /*808*/
  591.       if( BufferScan[i] == 0xd )                                        /*808*/
  592.         LineNum++;                                                      /*808*/
  593.  
  594.     /*************************************************************************/
  595.     /* At this point, newtext may contain a 0x0D at the end. It shouldn't... */
  596.     /* but it might and rather than go back and try to fix the logic         */
  597.     /* flaw, we'll just filter the damn thing out. Thank you...Selwyn.       */
  598.     /*************************************************************************/
  599.     {
  600.      char *cp = strchr(newtext,0x0D );
  601.  
  602.      if( cp ) *cp = ' ';
  603.     }
  604.     sprintf(LineNumStr,"%d",LineNum);
  605.     close( fh );
  606.     Tfree( BufferStart );
  607.     switch( ErrorCode )                                                 /*808*/
  608.     {                                                                   /*808*/
  609.       case READERROR:                                                   /*808*/
  610.         Error(ERR_PROFILE_READERROR,TRUE,0);
  611.         break;                                                          /*808*/
  612.  
  613.       case VERSIONERROR:                                                /*808*/
  614.         Error(ERR_PROFILE_VERSION,TRUE,0);
  615.         break;                                                          /*808*/
  616.  
  617.       case DEFSECERROR:                                                 /*808*/
  618.         Error(ERR_PROFILE_KEY_DEFS,TRUE,0);
  619.         break;                                                          /*808*/
  620.  
  621.       case NOFUNCERROR:                                                 /*808*/
  622.         Error(ERR_PROFILE_INVALID_FUNCTION,TRUE,2,newtext,LineNumStr);
  623.         break;
  624.  
  625.       case NOATTRERROR:                                                 /*808*/
  626.         Error(ERR_PROFILE_INVALID_ATTRIBUTE,TRUE,2,newtext,LineNumStr);
  627.         break;                                                          /*808*/
  628.  
  629.       case NOBGCLRERROR:                                                /*808*/
  630.         Error(ERR_PROFILE_BG_COLOR,TRUE,2,newtext,LineNumStr);
  631.         break;                                                          /*808*/
  632.  
  633.       case NOFGCLRERROR:                                                /*808*/
  634.         Error(ERR_PROFILE_FG_COLOR,TRUE,2,newtext,LineNumStr);
  635.         break;                                                          /*808*/
  636.  
  637.       case NOEXTYPERROR:                                                /*808*/
  638.         Error(ERR_PROFILE_EXCEPTION_TYPE,TRUE,2,newtext,LineNumStr);
  639.         break;                                                          /*808*/
  640.  
  641.       case NOEXCEPERROR:                                                /*808*/
  642.         Error(ERR_PROFILE_EXCEPTION,TRUE,2,newtext,LineNumStr);
  643.         break;                                                          /*808*/
  644.  
  645.       case NOKEYERROR:                                                  /*808*/
  646.         Error(ERR_PROFILE_INVALID_KEY,TRUE,2,newtext,LineNumStr);
  647.         break;                                                          /*808*/
  648.  
  649.       case NESTEDCMT:                                                   /*808*/
  650.         Error(ERR_PROFILE_NESTED_COMMENT,TRUE,1,LineNumStr);
  651.         break;                                                          /*808*/
  652.  
  653.       default:                                                          /*808*/
  654.         Error(ERR_PROFILE_GENERAL,TRUE,NULL,0);
  655.         break;                                                          /*808*/
  656.     }                                                                   /*808*/
  657.   }
  658. }                                       /* end Profile                       */
  659.  
  660. /*****************************************************************************/
  661. /* HelpScreen                                                                */
  662. /*                                                                           */
  663. /* Description:                                                              */
  664. /*                                                                           */
  665. /*   Build and display a scrollable help panel box.  Scroll is accomplished  */
  666. /*   by using UPCURSOR, DOWNCURSOR, PGDOWN, and PGUP.  ACTIONBAR returns you */
  667. /*   to the caller.                                                          */
  668. /*                                                                           */
  669. /* Parameters:                                                               */
  670. /*                                                                           */
  671. /* Return:                                                                   */
  672. /*                                                                           */
  673. /*****************************************************************************/
  674. void HelpScreen( void )
  675. {
  676.  DisplayDialog( &Dia_Help, TRUE );
  677.  ProcessDialog( &Dia_Help, &Dia_Help_Choices, TRUE, NULL );
  678.  RemoveDialog( &Dia_Help );
  679. }
  680.  
  681. /*****************************************************************************/
  682. /* DisplayHelpChoice()                                                    701*/
  683. /*                                                                           */
  684. /* Description:                                                              */
  685. /*                                                                           */
  686. /*   Displays the help information for the key assignments.                  */
  687. /*                                                                           */
  688. /* Parameters:                                                               */
  689. /*                                                                           */
  690. /*   shell   ->  pointer to a dialog shell structure.                        */
  691. /*   ptr     ->  pointer to a dialog choice structure.                       */
  692. /*                                                                           */
  693. /* Return:                                                                   */
  694. /*          None                                                             */
  695. /*                                                                           */
  696. /*****************************************************************************/
  697. #define KEYFIELDSIZE 15
  698. void  DisplayHelpChoice( DIALOGSHELL *shell, DIALOGCHOICE *ptr )
  699. {
  700.   int idx, i;
  701.  
  702.   idx = ptr->SkipRows;
  703.   for( i = 0; i < ptr->MaxRows; i++, idx++ )
  704.   {
  705.     int StrLength, k, f;
  706.  
  707.     k = index[idx][0];
  708.     f = index[idx][1];
  709.  
  710.     ClearField[1] = KEYFIELDSIZE;
  711.     putrc( shell->row + i + shell->SkipLines, shell->col + 1, ClearField );
  712.     putrc( shell->row + i + shell->SkipLines, shell->col + 2, key2code[k].key );
  713.  
  714.     StrLength = strlen( func2code[f].func );
  715.     ClearField[1] = shell->width - 6 - StrLength;
  716.     putrc( shell->row + i + shell->SkipLines, shell->col + 2 + StrLength,
  717.            ClearField );
  718.     putrc( shell->row + i + shell->SkipLines, shell->col + 2 + KEYFIELDSIZE,
  719.            func2code[f].func );
  720.   }
  721. }
  722.  
  723. /*****************************************************************************/
  724. /*                                                                           */
  725. /* HelpDialogFunction()                                                      */
  726. /*                                                                           */
  727. /* Description:                                                              */
  728. /*                                                                           */
  729. /* This is the function called by ProcessDialog (in pulldown.c) whenever an  */
  730. /* event occurs in the dialog. This fuction handles the events in a way      */
  731. /* specific to this dialog.                                                  */
  732. /*                                                                           */
  733. /* Parameters:                                                               */
  734. /*                                                                           */
  735. /*   shell         input  - Pointer to DIALOGSHELL structure.                */
  736. /*   ptr           input  - Pointer to DIALOGCHOICE structure.               */
  737. /*   nEvent        input  - Pointer to EVENT structure.                      */
  738. /*                                                                           */
  739. /* Return:                                                                   */
  740. /*        = 0     - The caller has to continue processing the dialog.        */
  741. /*       != 0     - The caller can terminate processing the dialog.          */
  742. /*****************************************************************************/
  743. uint  HelpDialogFunction( DIALOGSHELL *shell, DIALOGCHOICE *ptr,
  744.                           EVENT *nEvent, void *ParamBlock )
  745. {
  746.   switch( nEvent->Value )
  747.   {
  748.     case INIT_DIALOG:
  749.     {
  750.       int   idx, k, f, kf;
  751.  
  752.       for( idx = 0, k = 0; k < USERKEYS; k++ )
  753.       {
  754.         for( kf = 0; kf < KEYNUMSOC; kf++ )
  755.         {
  756.           if( defk2f[kf].scode == key2code[k].scode )
  757.             break;
  758.         }
  759.         if( defk2f[kf].fcode == DONOTHING )
  760.          continue;
  761.  
  762.         for( f = 0; f < USERFUNCS; f++ )
  763.         {
  764.           if( defk2f[kf].fcode == func2code[f].fcode )
  765.             break;
  766.         }
  767.         index[idx][0] = k;
  768.         index[idx][1] = f;
  769.         idx++;
  770.       }
  771.       ptr->entries = idx;
  772.       hilite[1] = normal[1] = KEYFIELDSIZE;
  773.       return( 0 );
  774.     }
  775.  
  776.     case ESC:
  777.       return( ESC );
  778.  
  779.     case ENTER:
  780.     {
  781.       int  i;
  782.  
  783.       for( i = 0; i < 9; i++ )
  784.       {
  785.         PULLDOWN  *PullPtr;
  786.         uchar     *FuncCode;
  787.         int        j;
  788.  
  789.         PullPtr  = GetPullPointer( i );
  790.         FuncCode = PullPtr->funccodes;
  791.         for( j = 0; j < PullPtr->entries; j++ )
  792.         {
  793.           if( func2code[index[ptr->SkipRows + shell->CurrentField - 1][1]].fcode
  794.               == *(FuncCode + j) )
  795.           {
  796.             uchar *HelpMsg;
  797.             ULONG  HelpId;
  798.  
  799.             HelpId  = *(PullPtr->help + j);
  800.             HelpMsg = GetHelpMsg( HelpId, NULL,0 );
  801.             CuaShowHelpBox( HelpMsg );
  802.             return( 0 );
  803.           }
  804.         }
  805.       }
  806.  
  807.       for( i = 0; i < NUMKEYSHELP; i++ )
  808.       {
  809.         if( key2code[index[ptr->SkipRows + shell->CurrentField - 1][0]].scode
  810.             == KeysHelp[i].key )
  811.         {
  812.           uchar *HelpMsg;
  813.           ULONG  HelpId;
  814.  
  815.           HelpId  = KeysHelp[i].helpid;
  816.           HelpMsg = GetHelpMsg( HelpId, NULL,0);
  817.           CuaShowHelpBox( HelpMsg );
  818.           return( 0 );
  819.         }
  820.       }
  821.       beep();
  822.       return( 0 );
  823.     }
  824.  
  825.     case F1:
  826.     {
  827.       uchar *HelpMsg;
  828.  
  829.       HelpMsg = GetHelpMsg( HELP_DLG_KEYSHELP, NULL,0 );
  830.       CuaShowHelpBox( HelpMsg );
  831.       return( 0 );
  832.     }
  833.  
  834.     default:
  835.       return( 0 );
  836.   }
  837. }
  838.