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

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   ShowDlls.c                                                              */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*                                                                           */
  7. /*  Display names of DLLs                                                    */
  8. /*                                                                           */
  9. /* History:                                                                  */
  10. /*                                                                           */
  11. /*   02/08/91 Creation of 32-bit SD86, from 16-bit version.                  */
  12. /*                                                                           */
  13. /*...Release 1.00 (Pre-release 108 12/05/91)                                 */
  14. /*...                                                                        */
  15. /*... 02/21/92  521   Srinivas  Port to C-Set/2.                             */
  16. /*...                                                                        */
  17. /*...Release 1.01 (04/03/92)                                                 */
  18. /*...                                                                        */
  19. /*... 05/08/92  701   Samuel    Cua Interface.                               */
  20. /**Includes*******************************************************************/
  21. #include "all.h"                        /* SD86 include files                */
  22. #include "diadll.h"                     /* dlls dialog data               701*/
  23.  
  24. /**External declararions******************************************************/
  25. extern uint     VideoRows;              /* # of rows per screen              */
  26. extern uint     VideoCols;              /* # of columns per screen           */
  27. extern uchar    VideoAtr;               /* video attribute                   */
  28. extern KEY2FUNC defk2f[];               /* init key to function lookup table */
  29. extern uint     ProcessID;              /* process id.                       */
  30. extern uchar    VideoAtr;               /* logical screen attribute          */
  31. extern uchar    ScrollShade1[];         /* scroll bar attributes          701*/
  32. extern uchar    ScrollShade2[];         /* scroll bar attributes          701*/
  33. extern uchar    hilite[];               /* high light field attributes    701*/
  34. extern uchar    normal[];               /* normal field attributes        701*/
  35. extern uchar    ClearField[];           /* clear field attributes         701*/
  36. extern uchar    InScrollMode;           /* flag to tell we are in scrollmode */
  37. extern CmdParms cmd;
  38. extern PROCESS_NODE *pnode;                                             /*827*/
  39.  
  40. /*****************************************************************************/
  41. /* ShowDlls()                                                             701*/
  42. /*                                                                           */
  43. /* Description:                                                              */
  44. /*                                                                           */
  45. /*   show names of DLLs linked to EXE file in the new cua format.            */
  46. /*                                                                           */
  47. /* Parameters:                                                               */
  48. /*   none.                                                                   */
  49. /*                                                                           */
  50. /* Return:                                                                   */
  51. /*   none.                                                                   */
  52. /*                                                                           */
  53. /* Assumptions:                                                              */
  54. /*   1. The node for EXE file always exists (i.e. pdf is never NULL)         */
  55. /*****************************************************************************/
  56. void ShowDlls()
  57. {
  58.  
  59.   /***************************************************************************/
  60.   /* As the actual dimensions of the dialog box is determined at a later     */
  61.   /* point of time, the display of the dialog is also deferred until that    */
  62.   /* point (INIT_DIALOG in the dialog function of the dialog).               */
  63.   /***************************************************************************/
  64.   ProcessDialog( &Dia_Dll, &Dia_Dll_Choices, TRUE, NULL );
  65.   RemoveDialog( &Dia_Dll );
  66. }
  67.  
  68. /*****************************************************************************/
  69. /*                                                                           */
  70. /* DllDialogFunction()                                                       */
  71. /*                                                                           */
  72. /* Description:                                                              */
  73. /*                                                                           */
  74. /* This is the function called by ProcessDialog (in pulldown.c) whenever an  */
  75. /* event occurs in the dialog. This fuction handles the events in a way      */
  76. /* specific to this dialog.                                                  */
  77. /*                                                                           */
  78. /* Parameters:                                                               */
  79. /*                                                                           */
  80. /*   shell         input  - Pointer to DIALOGSHELL structure.                */
  81. /*   ptr           input  - Pointer to DIALOGCHOICE structure.               */
  82. /*   nEvent        input  - Pointer to EVENT structure.                      */
  83. /*                                                                           */
  84. /* Return:                                                                   */
  85. /*        = 0     - The caller has to continue processing the dialog.        */
  86. /*       != 0     - The caller can terminate processing the dialog.          */
  87. /*****************************************************************************/
  88. uint  DllDialogFunction( DIALOGSHELL *shell, DIALOGCHOICE *ptr,
  89.                          EVENT *nEvent, void *ParamBlock )
  90. {
  91.   switch( nEvent->Value )
  92.   {
  93.     case INIT_DIALOG:
  94.     {
  95.       /*********************************************************************/
  96.       /* This message is sent before displaying elements in display area.  */
  97.       /* It is to initialise the locals in the dialog function.            */
  98.       /*  - Set the length of the field highlite bar in normal and hilite  */
  99.       /*    arrays (used in the call to putrc).                            */
  100.       /*  - Return zero to denote continue dialog processing.              */
  101.       /*********************************************************************/
  102.       int      NumOfDll, StrLen, MaxStrLen = 0;
  103.       DEBFILE *cur_dll;
  104.       DEBFILE *pdf;
  105.  
  106.       pdf = pnode->ExeStruct;
  107.  
  108.       cur_dll = pdf->next;
  109.       NumOfDll = 0;
  110.       while( cur_dll != NULL )
  111.       {
  112.         NumOfDll++;
  113.         StrLen = strlen( cur_dll->DebFilePtr->fn );
  114.         MaxStrLen = MaxStrLen > StrLen ? MaxStrLen : StrLen;
  115.         cur_dll = cur_dll->next;
  116.       }
  117.  
  118.       shell->width = (MaxStrLen > (MAXSHDLLWINSIZE - 6)) ? MAXSHDLLWINSIZE : (MaxStrLen + 6);
  119.  
  120.       shell->col = (VideoCols - shell->width) / 2;
  121.  
  122.       if( shell->Buttons )
  123.         shell->Buttons[0].col = shell->col +
  124.                                 (shell->width - shell->Buttons[0].length)/2;
  125.  
  126.       ptr->entries = NumOfDll;
  127.  
  128.       hilite[1] = normal[1] = (UCHAR)shell->width - SCROLLBARCOLOFFSET - 2;
  129.       DisplayDialog( shell, TRUE );
  130.     }
  131.     return( 0 );
  132.  
  133.     case ESC:
  134.     case F10:
  135.     case ENTER:
  136.     {
  137.       /*********************************************************************/
  138.       /* This message is sent if the user clicks on the ENTER button or    */
  139.       /* presses the ENTER key.                                            */
  140.       /*  - Return non zero value to denote the end of dialog processing.  */
  141.       /*********************************************************************/
  142.       ptr->SkipRows = 0;
  143.       return( ENTER );
  144.     }
  145.  
  146.     default:
  147.       return( 0 );
  148.   }
  149. }
  150.  
  151. /*****************************************************************************/
  152. /* DisplayDllChoice()                                                     701*/
  153. /*                                                                           */
  154. /* Description:                                                              */
  155. /*                                                                           */
  156. /*   Displays the dll names in the dialog window.                            */
  157. /*                                                                           */
  158. /* Parameters:                                                               */
  159. /*                                                                           */
  160. /*   shell   ->  pointer to a dialog shell structure.                        */
  161. /*   ptr     ->  pointer to a dialog choice structure.                       */
  162. /*                                                                           */
  163. /* Return:                                                                   */
  164. /*   none                                                                    */
  165. /*****************************************************************************/
  166. void  DisplayDllChoice (DIALOGSHELL *shell,DIALOGCHOICE *ptr)
  167. {
  168.   uint    i;
  169.   uint    StartIndex = 1;               /*                                   */
  170.   uint    StrLength;                    /*                                   */
  171.   char    buffer[80], *buf;             /*                                   */
  172.   DEBFILE *cur_dll;                     /* pointer to the EXE file info      */
  173.   DEBFILE *pdf;                         /* pointer to debug file struct      */
  174.   uint    BorderCols;
  175.  
  176.   BorderCols = 6;
  177.  
  178.   pdf = pnode->ExeStruct;               /* get -> to Exe structure.          */
  179.   cur_dll = pdf->next;                  /* set ptr to 1st DLL node           */
  180.  
  181.   /***************************************************************************/
  182.   /* Advance the startindex and -> the dll depending on the skip rows.       */
  183.   /***************************************************************************/
  184.   for( i = 0; i < ptr-> SkipRows; i++ )
  185.   {
  186.     StartIndex++;
  187.     cur_dll = cur_dll->next;
  188.   }
  189.  
  190.   /***************************************************************************/
  191.   /* Display the names that can fit in the window.                           */
  192.   /***************************************************************************/
  193.   for( i = 0; i < ptr->MaxRows; i++ )
  194.   {
  195.     if( StartIndex <= ptr->entries )
  196.     {
  197.       ClearField[1] = 1;
  198.       putrc( shell->row + i + shell->SkipLines, shell->col + 1, ClearField );
  199.       StrLength = strlen( cur_dll->DebFilePtr->fn );
  200.       if( StrLength > (shell->width - BorderCols) )
  201.       {
  202.         buf = cur_dll->DebFilePtr->fn;
  203.         buf = buf + (StrLength - (shell->width - BorderCols));
  204.         strcpy( buffer, buf );
  205.         buffer[0] = '~';
  206.         putrc( shell->row + i + shell->SkipLines, shell->col + 2, buffer );
  207.         StrLength = strlen( buffer );
  208.       }
  209.       else
  210.         putrc( shell->row + i + shell->SkipLines, shell->col + 2,
  211.                cur_dll->DebFilePtr->fn );
  212.       StartIndex++;
  213.       ClearField[1] = shell->width - BorderCols - StrLength;
  214.       putrc( shell->row + i + shell->SkipLines, shell->col + 2 + StrLength,
  215.              ClearField );
  216.       cur_dll = cur_dll->next;
  217.     }
  218.     else
  219.     {
  220.       ClearField[1] = shell->width-2-SCROLLBARCOLOFFSET;
  221.       putrc( shell->row + i + shell->SkipLines, shell->col + 1, ClearField );
  222.     }
  223.   }
  224. }
  225.