home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / iwftech.zip / samples / WKFInfo / wkfinfo.c next >
Text File  |  1994-07-05  |  31KB  |  935 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /* PROGRAM NAME: WKFInfo                                                    */
  4. /*                                                                          */
  5. /* COPYRIGHT:                                                               */ 
  6. /* ----------                                                               */ 
  7. /* Copyright (C) International Business Machines Corp., 1991,1992,1993,1994 */
  8. /*                                                                          */ 
  9. /* DISCLAIMER OF WARRANTIES:                                                */ 
  10. /* -------------------------                                                */ 
  11. /* The following [enclosed] code is sample code created by IBM              */ 
  12. /* Corporation.  This sample code is not part of any standard IBM product   */ 
  13. /* and is provided to you solely for the purpose of assisting you in the    */ 
  14. /* development of your applications.  The code is provided "AS IS",         */ 
  15. /* without warranty of any kind.  IBM shall not be liable for any damages   */ 
  16. /* arising out of your use of the sample code, even if they have been       */ 
  17. /* advised of the possibility of such damages.                              */ 
  18. /*                                                                          */ 
  19. /* REVISION LEVEL: 2.1                                                      */ 
  20. /* -------------------                                                      */ 
  21. /*                                                                          */
  22. /* This program illustrates using the project and actions profile APIs to   */
  23. /* obtain information about a project and its actions.                      */
  24. /*                                                                          */
  25. /****************************************************************************/
  26. /*                                                                          */
  27. /* NOTES:                                                                   */
  28. /*                                                                          */
  29. /****************************************************************************/
  30.  
  31. #pragma strings(readonly)
  32.  
  33. #define INCL_DOSERRORS
  34. #define INCL_DOS
  35. #define INCL_WIN
  36. #include <os2.h>
  37.  
  38. #include <stdarg.h>
  39. #include <stdlib.h>
  40. #include <stdio.h>
  41. #include <string.h>
  42.  
  43. #include "wkfinfo.h"
  44. #include "wkf.h"
  45.                             
  46.  
  47. /*                                                                                  
  48. ** Local function declarations                                                      
  49. */                                                                                  
  50. static MRESULT OpenFile( HWND hwndDlg );
  51. static MRESULT SaveFile( HWND hwndDlg );                                            
  52. static MRESULT WMCommand( HWND hwndDlg, USHORT usCommand, USHORT usType );          
  53. static MRESULT WMInitDlg( HWND hwndDlg );                                           
  54. static MRESULT WMInitMenu( HWND hwndDlg, SHORT sMenuID, HWND hwndMenu );            
  55. static MRESULT _System DlgProc( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 );  
  56. static VOID CheckSpaces( HWND hwndMLE, PSZ pszText );                               
  57. static VOID InitMLE( HWND hwndMLE );                                                
  58. static VOID Output( HWND hwndMLE, PSZ pszFormat, ... );                             
  59. static VOID OutputActionScope( HWND hwndMLE, ULONG ulActionScope );                 
  60. static VOID OutputActionType( HWND hwndMLE, ULONG ulActionType );                   
  61. static VOID OutputList( HWND hwndMLE, PSZ pszIndent, PSZ pszList );                 
  62. static VOID OutputMenuScope( HWND hwndMLE, ULONG ulMenuScope );                     
  63. static VOID OutputMsgScope( HWND hwndMLE, ULONG ulMsgScope );                       
  64. static VOID OutputProfileInfo( HWND hwndMLE, WKF_ACTIONS *pwkfActionsList );        
  65. static VOID OutputProjectInfo( HWND hwndMLE, WKFBASEPROJECT *pbpProject );          
  66. static VOID OutputRunMode( HWND hwndMLE, ULONG ulRunmode );                         
  67. static VOID ProcessProject( HWND hwndMLE, PSZ pszProjectFilename );                 
  68. static VOID WriteFile( HWND hwndDlg, PSZ pszFilename );                             
  69.  
  70.  
  71.  
  72. /****************************************************************************/
  73. /* MAIN                                                                     */
  74. /*                                                                          */
  75. /****************************************************************************/
  76.  
  77. int main(int argc, char *argv[])
  78. {
  79.    HMQ  hmq;
  80.    HAB  hab;
  81.    HWND hwndDlg;
  82.  
  83.    /*
  84.    ** Connect to Presentation Manager
  85.    */
  86.    hab = WinInitialize( 0 );
  87.    if ( hab == NULLHANDLE )
  88.    {
  89.       WinAlarm( HWND_DESKTOP, WA_ERROR );
  90.       return( ERROR_GEN_FAILURE );
  91.    }
  92.  
  93.    hmq = WinCreateMsgQueue( hab, 0 );
  94.    if( hmq == NULLHANDLE )
  95.    {
  96.       WinAlarm( HWND_DESKTOP, WA_ERROR );
  97.       WinTerminate( hab );
  98.       return( ERROR_GEN_FAILURE );
  99.    }
  100.  
  101.    /*
  102.    ** Create MAIN window.
  103.    */
  104.  
  105.    hwndDlg = WinLoadDlg( HWND_DESKTOP,
  106.                          HWND_DESKTOP,
  107.                          DlgProc,
  108.                          NULLHANDLE,     /* Load the resources from the exe */
  109.                          IDD_DLG,
  110.                          NULL );
  111.    if( hwndDlg == NULLHANDLE )
  112.    {
  113.       WinGetLastError( hab );
  114.       WinAlarm( HWND_DESKTOP, WA_ERROR );
  115.       WinDestroyMsgQueue( hmq );
  116.       WinTerminate( hab );
  117.       return( ERROR_GEN_FAILURE );
  118.    }
  119.  
  120.    /*
  121.    ** Fetch and dispatch PM messages.
  122.    */
  123.    WinProcessDlg( hwndDlg );
  124.    WinDestroyWindow( hwndDlg );
  125.  
  126.    WinDestroyMsgQueue( hmq );
  127.    WinTerminate( hab );
  128.    return( NO_ERROR );
  129. }
  130.  
  131.  
  132.  
  133.  
  134. /****************************************************************************/
  135. /* DlgProc()                                                                */
  136. /*                                                                          */
  137. /****************************************************************************/
  138.  
  139. static MRESULT _System DlgProc( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 )
  140. {
  141.    switch (msg)
  142.    {
  143.       case WM_INITDLG:
  144.          return( WMInitDlg( hwndDlg ) );
  145.  
  146.       case WM_INITMENU:
  147.          return( WMInitMenu( hwndDlg, 
  148.                              SHORT1FROMMP( mp1 ),
  149.                              (HWND) mp2 ) );
  150.  
  151.       case WM_COMMAND:
  152.          return( WMCommand( hwndDlg,
  153.                             SHORT1FROMMP( mp1 ),
  154.                             SHORT1FROMMP( mp2 ) ) );
  155.  
  156.    } /* endswitch */
  157.  
  158.  
  159.    return( WinDefDlgProc( hwndDlg, msg, mp1, mp2 ));
  160. }
  161.  
  162.  
  163.  
  164. /****************************************************************************/
  165. /* WMInitDlg()                                                              */
  166. /*                                                                          */
  167. /****************************************************************************/
  168.  
  169. static MRESULT WMInitDlg( HWND hwndDlg )
  170. {
  171.    HWND   hwndMenu;
  172.  
  173.    /*
  174.    ** There is no selected project yet
  175.    */
  176.    WinSetWindowPtr( hwndDlg, QWL_USER, PVOIDFROMMP( NULL ));
  177.  
  178.    /*
  179.    ** Create an action bar
  180.    */
  181.    hwndMenu = WinLoadMenu( hwndDlg,
  182.                            NULLHANDLE,
  183.                            IDM_DLG_ACTIONBAR );
  184.  
  185.    WinSetParent( hwndMenu,
  186.                  hwndDlg,
  187.                  FALSE );
  188.  
  189.    /*
  190.    ** Now update the frame
  191.    */
  192.    WinDefDlgProc( hwndDlg,
  193.                   WM_UPDATEFRAME,
  194.                   MPFROMLONG( FCF_MENU ),
  195.                   MPVOID );
  196.  
  197.  
  198.    return( MRFROMLONG( FALSE ));
  199. }
  200.  
  201.  
  202.  
  203. /****************************************************************************/
  204. /* WMInitMenu()                                                             */
  205. /*                                                                          */
  206. /****************************************************************************/
  207.  
  208. static MRESULT WMInitMenu( HWND hwndDlg, SHORT sMenuID, HWND hwndMenu )
  209. {
  210.  
  211.    switch (sMenuID)
  212.    {
  213.       case IDM_FILE:
  214.       {
  215.          PSZ pszProjectFilename;
  216.  
  217.          /*
  218.          ** Only enable the save menuitem if a project has been selected
  219.          */
  220.          pszProjectFilename = WinQueryWindowPtr( hwndDlg, QWL_USER );
  221.       
  222.          if( pszProjectFilename )
  223.             WinEnableMenuItem( hwndMenu, IDM_FILE_SAVE, TRUE );
  224.          else
  225.             WinEnableMenuItem( hwndMenu, IDM_FILE_SAVE, FALSE );
  226.       }
  227.       break;
  228.  
  229.    } /* endswitch */
  230.  
  231.    return( MRFROMLONG( FALSE ) );
  232. }
  233.  
  234.  
  235.  
  236.  
  237. /****************************************************************************/
  238. /* WMCommand()                                                              */
  239. /*                                                                          */
  240. /****************************************************************************/
  241.  
  242. static MRESULT WMCommand( HWND hwndDlg, USHORT usCommand, USHORT usType )
  243. {
  244.    switch (usType)
  245.    {
  246.       case CMDSRC_MENU:
  247.       {
  248.          switch (usCommand)
  249.          {
  250.             case IDM_FILE_OPEN:
  251.                return( OpenFile( hwndDlg ) );
  252.  
  253.             case IDM_FILE_SAVE:
  254.                return( SaveFile( hwndDlg ) );
  255.  
  256.          } /* endswitch */
  257.       }
  258.       break;
  259.  
  260.    } /* endswitch */
  261.  
  262.    return( MRFROMLONG( FALSE ) );
  263. }
  264.  
  265.  
  266.  
  267. /****************************************************************************/
  268. /* OpenFile() - Display Open File dialog to let user select a project       */
  269. /*              to open                                                     */
  270. /****************************************************************************/
  271.  
  272. static MRESULT OpenFile( HWND hwndDlg )
  273. {
  274.    FILEDLG FileDlg;
  275.    PSZ     pszProjectFilename;
  276.  
  277.    pszProjectFilename = WinQueryWindowPtr( hwndDlg, QWL_USER );
  278.  
  279.    /*
  280.    ** Display the open file dialog
  281.    */
  282.    memset( &FileDlg, 0, sizeof( FileDlg ) );
  283.    FileDlg.cbSize   =  sizeof( FileDlg );
  284.    FileDlg.fl       =  FDS_OPEN_DIALOG;
  285.    FileDlg.pszIType = "WorkFrame/2 Project";
  286.  
  287.    if( pszProjectFilename )
  288.       strcpy( FileDlg.szFullFile, pszProjectFilename );
  289.  
  290.    WinFileDlg( HWND_DESKTOP,
  291.                hwndDlg,
  292.               &FileDlg );
  293.  
  294.    if( FileDlg.lReturn == DID_OK )
  295.    {
  296.       /*
  297.       ** Clean up the MLE
  298.       */
  299.       InitMLE( WinWindowFromID( hwndDlg, IDD_MLE ) );
  300.  
  301.       /*
  302.       ** A project was selected -- process it
  303.       */
  304.       ProcessProject( WinWindowFromID( hwndDlg, IDD_MLE ), 
  305.                       FileDlg.szFullFile );
  306.  
  307.       /*
  308.       ** Free the old, and save the new project filename
  309.       */
  310.       free( pszProjectFilename );
  311.  
  312.       pszProjectFilename = strdup( FileDlg.szFullFile );
  313.       WinSetWindowPtr( hwndDlg, QWL_USER, pszProjectFilename );
  314.    }
  315.  
  316.    return( MRFROMLONG( FALSE ) );
  317. }
  318.  
  319.  
  320.  
  321. /****************************************************************************/
  322. /* SaveFile() - Save information in a text file                             */
  323. /*                                                                          */
  324. /****************************************************************************/
  325. static MRESULT SaveFile( HWND hwndDlg )
  326. {
  327.    FILEDLG FileDlg;
  328.    CHAR    szName[CCHMAXPATH];
  329.    PSZ     pszProjectFilename;
  330.  
  331.    pszProjectFilename = WinQueryWindowPtr( hwndDlg, QWL_USER );
  332.  
  333.    DosEditName( 1,   /* Use OS/2 1.2 semantics */
  334.                 pszProjectFilename,
  335.                 "*.TXT",
  336.                 szName,
  337.                 sizeof( szName ) );
  338.  
  339.    /*
  340.    ** Display the open file dialog
  341.    */
  342.    memset( &FileDlg, 0, sizeof( FileDlg ) );
  343.    FileDlg.cbSize   =  sizeof( FileDlg );
  344.    FileDlg.fl       =  FDS_SAVEAS_DIALOG;
  345.  
  346.    if( pszProjectFilename )
  347.       strcpy( FileDlg.szFullFile, szName );
  348.  
  349.    WinFileDlg( HWND_DESKTOP,
  350.                hwndDlg,
  351.               &FileDlg );
  352.  
  353.    if( FileDlg.lReturn == DID_OK )
  354.       WriteFile( hwndDlg, FileDlg.szFullFile );
  355.  
  356.    return( MRFROMLONG( FALSE ) );
  357. }
  358.  
  359.  
  360.  
  361.  
  362. /****************************************************************************/
  363. /* WriteFile() - Get data from MLE and write to the file                    */
  364. /*                                                                          */
  365. /****************************************************************************/
  366. static VOID WriteFile( HWND hwndDlg, PSZ pszFilename )
  367. {
  368.    LONG  lLen;
  369.    IPT   ipt=0;
  370.    HWND  hwndMLE;
  371.    PSZ   pszData;
  372.    BOOL  fOK = FALSE;
  373.  
  374.    hwndMLE = WinWindowFromID( hwndDlg, IDD_MLE );
  375.  
  376.    lLen = (LONG)WinSendMsg( hwndMLE,
  377.                             MLM_QUERYTEXTLENGTH,
  378.                             MPFROMP(NULL),
  379.                             MPFROMP(NULL) );
  380.  
  381.    pszData = malloc( lLen );
  382.    if( pszData )
  383.    {
  384.       WinSendMsg( hwndMLE,            
  385.                   MLM_SETIMPORTEXPORT,
  386.                   MPFROMP( pszData ),
  387.                   MPFROMLONG( lLen ) );
  388.  
  389.       lLen = (LONG)WinSendMsg( hwndMLE,
  390.                                MLM_EXPORT,      
  391.                                MPFROMP( &ipt ),
  392.                                MPFROMP( &lLen ) );
  393.  
  394.       /*
  395.       ** If we actually exported the data from the MLE ok, open the file
  396.       */
  397.       if( lLen )
  398.       {
  399.          FILE *fOutput;
  400.          
  401.          fOutput = fopen( pszFilename, "w" );
  402.  
  403.          if( fOutput )
  404.          {
  405.             lLen = fwrite( pszData,
  406.                            lLen,
  407.                            1,           /* count */
  408.                            fOutput );
  409.       
  410.             if (lLen == 1)    /* 1 block of data written */
  411.                fOK = TRUE;
  412.       
  413.             fclose( fOutput );
  414.          }
  415.       }
  416.  
  417.       free( pszData );
  418.    }
  419.  
  420.  
  421.    if( fOK )
  422.       WinAlarm( HWND_DESKTOP, WA_NOTE );
  423.    else
  424.       WinAlarm( HWND_DESKTOP, WA_ERROR );
  425. }
  426.  
  427.  
  428.  
  429. /****************************************************************************/
  430. /* ProcessProject() - Do actual work of reading project information         */
  431. /*                                                                          */
  432. /****************************************************************************/
  433. static VOID ProcessProject( HWND hwndMLE, PSZ pszProjectFilename )
  434. {
  435.    WKFBASEPROJECT bpProject;          /* Base project structure */
  436.    WKF_ACTIONS   *pwkfActionsList;    /* Actions list structure */
  437.    APIRET         rc;
  438.    LHANDLE        hProject;           /* Project handle */
  439.  
  440.    /*
  441.    ** Start querying the project information, and dumping 
  442.    ** it to the listbox
  443.    */
  444.  
  445.    Output( hwndMLE, "\"%s\"", pszProjectFilename );
  446.    CheckSpaces( hwndMLE, pszProjectFilename );
  447.  
  448.    /* Open project file for reading */
  449.  
  450.    hProject = WkfOpenProjectFile( NULLHANDLE,
  451.                                   pszProjectFilename,
  452.                                   WKF_ACCESS_READ);
  453.  
  454.    /* Read project data into bpProject buffer */
  455.  
  456.    if (hProject != NULLHANDLE)    /* Project opened successfully */
  457.       rc = WkfReadProject( pszProjectFilename,
  458.                            &bpProject );
  459.    else              
  460.       return;         
  461.  
  462.       
  463.    /* Write data to MLE */
  464.  
  465.    Output( hwndMLE, "WkfReadProject() = %d\n", rc );
  466.    if( rc )       
  467.       return;     /* Error reading project */
  468.  
  469.    /*
  470.    ** Disable the MLE while inputing the data
  471.    ** (to speed it up)
  472.    */
  473.    WinShowWindow( hwndMLE, FALSE );
  474.  
  475.  
  476.    OutputProjectInfo( hwndMLE, &bpProject );
  477.    Output( hwndMLE, "\n" );
  478.  
  479.    /* Finished with project file, so close it */
  480.    WkfCloseProjectFile ( hProject );
  481.  
  482.  
  483.    /*
  484.    ** Read the actions profile, and output that information
  485.    */
  486.    rc = WkfQueryActionList( bpProject.szProfile, 
  487.                            &pwkfActionsList );
  488.  
  489.    Output( hwndMLE, "WkfQueryActionList() = %d\n", rc );
  490.  
  491.    if( rc == NO_ERROR )
  492.    {
  493.       OutputProfileInfo( hwndMLE, pwkfActionsList );
  494.  
  495.       /* Always call this after calling WkfQueryActionList or WkfQueryActions */
  496.       WkfFreeActions( pwkfActionsList );
  497.    }
  498.  
  499.  
  500.    WinShowWindow( hwndMLE, TRUE );
  501.  
  502. }
  503.  
  504.  
  505.  
  506.  
  507. /****************************************************************************/
  508. /* OutputProjectInfo()                                                      */
  509. /*                                                                          */
  510. /****************************************************************************/
  511. static VOID OutputProjectInfo( HWND hwndMLE, WKFBASEPROJECT *pbpProject )
  512. {
  513.  
  514.    /*
  515.    ** Output the project information
  516.    */
  517.    Output( hwndMLE, "    Access method module = \"%s\"", pbpProject->szPAM );
  518.    CheckSpaces( hwndMLE, pbpProject->szPAM );
  519.  
  520.    Output( hwndMLE, "    Project directory list:\n" );
  521.    OutputList( hwndMLE, "        ", pbpProject->szDirectory );
  522.  
  523.    Output( hwndMLE, "    File mask list:\n" );
  524.    OutputList( hwndMLE, "        ", pbpProject->szMask );
  525.  
  526.    Output( hwndMLE, "    Target program file name = \"%s\"", pbpProject->szTargetName );
  527.    CheckSpaces( hwndMLE, pbpProject->szTargetName );
  528.  
  529.    Output( hwndMLE, "    Target program parameters = \"%s\"", pbpProject->szTargetParm );
  530.    CheckSpaces( hwndMLE, pbpProject->szTargetParm );
  531.  
  532.    Output( hwndMLE, "    Target prompt required = %s\n", (pbpProject->fTargetPrompt ? "Yes" : "No" ) );
  533.                                                                                                                       
  534.    Output( hwndMLE, "    Target program type = " );
  535.    OutputRunMode( hwndMLE, pbpProject->ulTargetType );
  536.  
  537.    Output( hwndMLE, "    Monitor option flags:\n" );
  538.    Output( hwndMLE, "        Multiple concurrent: %s\n", ( (pbpProject->flMonitorFlags & WKF_MTR_MULTIPLE)
  539.                                                            ? "Yes" : "No" ) ); 
  540.    Output( hwndMLE, "        Close on completion: %s\n", ( (pbpProject->flMonitorFlags & WKF_MTR_AUTOCLOSE)
  541.                                                            ? "Yes" : "No" ) ); 
  542.    Output( hwndMLE, "        Start minimized: %s\n", ( (pbpProject->flMonitorFlags & WKF_MTR_MINIMIZE)
  543.                                                        ? "Yes" : "No" ) ); 
  544.  
  545.    Output( hwndMLE, "    Target path name = \"%s\"", pbpProject->szTargetPath );
  546.    CheckSpaces( hwndMLE, pbpProject->szTargetPath );
  547.  
  548.    Output( hwndMLE, "    Make file name = \"%s\"", pbpProject->szMakeFile );
  549.    CheckSpaces( hwndMLE, pbpProject->szMakeFile );
  550.  
  551.    Output( hwndMLE, "    Action profile file name = \"%s\"", pbpProject->szProfile );
  552.    CheckSpaces( hwndMLE, pbpProject->szProfile );
  553.  
  554.    Output( hwndMLE, "    File-scope menu = %s\n", (pbpProject->fFileDetailMenu ? "Yes" : "No" ) );
  555.  
  556.    Output( hwndMLE, "    Project-scope menu = %s\n", (pbpProject->fProjDetailMenu ? "Yes" : "No" ) );
  557.  
  558.    Output( hwndMLE, "    Default open action class = \"%s\"", pbpProject->szOpenAction );
  559.    CheckSpaces( hwndMLE, pbpProject->szOpenAction );
  560.  
  561.    Output( hwndMLE, "    Default exec action class = \"%s\"", pbpProject->szExecAction );
  562.    CheckSpaces( hwndMLE, pbpProject->szExecAction );
  563.  
  564.    return;
  565. }
  566.  
  567.  
  568.  
  569.  
  570.  
  571. /****************************************************************************/
  572. /* OutputProfileInfo()                                                      */
  573. /*                                                                          */
  574. /****************************************************************************/
  575. static VOID OutputProfileInfo( HWND hwndMLE, WKF_ACTIONS *pwkfActionsList )
  576. {                                                                                           
  577.    ULONG i;
  578.  
  579.    Output( hwndMLE, "%d Actions defined\n", pwkfActionsList->ulCount );
  580.  
  581.    for (i=0; i<pwkfActionsList->ulCount; i++ )
  582.    {
  583.       /*
  584.       ** Output the project information
  585.       */
  586.       Output( hwndMLE, "    Action name = \"%s\"", pwkfActionsList->apActions[i]->pszActionName );
  587.       CheckSpaces( hwndMLE, pwkfActionsList->apActions[i]->pszActionName );
  588.    
  589.       Output( hwndMLE, "    Action class = \"%s\"", pwkfActionsList->apActions[i]->pszActionClass );
  590.       CheckSpaces( hwndMLE, pwkfActionsList->apActions[i]->pszActionClass );
  591.    
  592.       Output( hwndMLE, "        Command = \"%s\"", pwkfActionsList->apActions[i]->pszCommand );
  593.       CheckSpaces( hwndMLE, pwkfActionsList->apActions[i]->pszCommand );
  594.    
  595.       Output( hwndMLE, "        Source masks:\n" );
  596.       OutputList( hwndMLE, "            ", pwkfActionsList->apActions[i]->pszSrcMask );
  597.    
  598.       Output( hwndMLE, "        Target masks:\n" );
  599.       OutputList( hwndMLE, "            ", pwkfActionsList->apActions[i]->pszTgtMask );
  600.    
  601.       Output( hwndMLE, "        DLL name = \"%s\"", pwkfActionsList->apActions[i]->pszDllName );
  602.       CheckSpaces( hwndMLE, pwkfActionsList->apActions[i]->pszDllName );
  603.    
  604.       Output( hwndMLE, "        DLL entry point = \"%s\"", pwkfActionsList->apActions[i]->pszDllEntryName );
  605.       CheckSpaces( hwndMLE, pwkfActionsList->apActions[i]->pszDllEntryName );
  606.    
  607.       Output( hwndMLE, "        Action type = " );
  608.       OutputActionType( hwndMLE, pwkfActionsList->apActions[i]->ucActionType );
  609.  
  610.       Output( hwndMLE, "        Action scope = " );
  611.       OutputActionScope( hwndMLE, pwkfActionsList->apActions[i]->ucActionScope );
  612.  
  613.       Output( hwndMLE, "        Menu scope = " );
  614.       OutputMenuScope( hwndMLE, pwkfActionsList->apActions[i]->ucMenuScope );
  615.  
  616.       Output( hwndMLE, "        Run mode = " );
  617.       OutputRunMode( hwndMLE, pwkfActionsList->apActions[i]->ucRunMode );
  618.  
  619.       /*
  620.       ** Extra fields if this action is a message
  621.       */
  622.       if( pwkfActionsList->apActions[i]->ucActionType & WKF_ACTIONMSG_ENABLED )
  623.       {
  624.          Output( hwndMLE, "        Message enabled\n" );
  625.  
  626.          Output( hwndMLE, "            Execution host = \"%s\"", pwkfActionsList->apActions[i]->pszExecHost );
  627.          CheckSpaces( hwndMLE, pwkfActionsList->apActions[i]->pszExecHost );
  628.    
  629.          Output( hwndMLE, "            Message action = \"%s\"", pwkfActionsList->apActions[i]->pszMsgAction );
  630.          CheckSpaces( hwndMLE, pwkfActionsList->apActions[i]->pszMsgAction );
  631.    
  632.          Output( hwndMLE, "            Message data = \"%s\"", pwkfActionsList->apActions[i]->pszMsgData );
  633.          CheckSpaces( hwndMLE, pwkfActionsList->apActions[i]->pszMsgData );
  634.    
  635.          Output( hwndMLE, "            Message scope = " );
  636.          OutputMsgScope( hwndMLE, pwkfActionsList->apActions[i]->ucMsgScope );
  637.       }
  638.  
  639.    } /* endfor */
  640. }
  641.  
  642.  
  643.  
  644.  
  645. /****************************************************************************/
  646. /* OutputRunMode()                                                          */
  647. /*                                                                          */
  648. /****************************************************************************/
  649. static VOID OutputRunMode( HWND hwndMLE, ULONG ulRunmode )
  650. {
  651.    switch( ulRunmode )
  652.    {
  653.       case WKF_RUNMODE_FULLSCREEN:
  654.          Output( hwndMLE, "Fullscreen\n" );
  655.          break;
  656.  
  657.       case WKF_RUNMODE_WINDOW:
  658.          Output( hwndMLE, "Window\n" );
  659.          break;
  660.  
  661.       case WKF_RUNMODE_MONITOR:
  662.          Output( hwndMLE, "Monitor\n" );
  663.          break;
  664.  
  665.       case WKF_RUNMODE_MESSAGE:
  666.          Output( hwndMLE, "Message\n" );
  667.          break;
  668.  
  669.       case WKF_RUNMODE_DEFAULT:
  670.          Output( hwndMLE, "Default\n" );
  671.          break;
  672.  
  673.       default:
  674.          Output( hwndMLE, "Invalid (0x%x)\n", ulRunmode );
  675.  
  676.    } /* endswitch */
  677.  
  678.    return;
  679. }
  680.  
  681.  
  682.  
  683.  
  684. /****************************************************************************/
  685. /* OutputActionType()                                                       */
  686. /*                                                                          */
  687. /****************************************************************************/
  688. static VOID OutputActionType( HWND hwndMLE, ULONG ulActionType )
  689. {
  690.    /*
  691.    ** Ignore the message enablement bit
  692.    */
  693.    switch( ulActionType & ~WKF_ACTIONMSG_ENABLED )
  694.    {
  695.       case WKF_ACTIONTYPE_CMD:
  696.          Output( hwndMLE, "Command\n" );
  697.          break;
  698.  
  699.       case WKF_ACTIONTYPE_MSG:
  700.          Output( hwndMLE, "Message\n" );
  701.          break;
  702.  
  703.       default:
  704.          Output( hwndMLE, "Invalid (0x%x)", ulActionType );
  705.    } /* endswitch */
  706.  
  707.    return;
  708. }  
  709.  
  710.  
  711.  
  712.  
  713. /****************************************************************************/
  714. /* OutputActionScope()                                                      */
  715. /*                                                                          */
  716. /****************************************************************************/
  717. static VOID OutputActionScope( HWND hwndMLE, ULONG ulActionScope )
  718. {
  719.    switch( ulActionScope )
  720.    {
  721.       case WKF_ACTIONSCOPE_PROJECT:
  722.          Output( hwndMLE, "Project\n" );
  723.          break;
  724.  
  725.       case WKF_ACTIONSCOPE_FILE:
  726.          Output( hwndMLE, "File\n" );
  727.          break;
  728.  
  729.       case WKF_ACTIONSCOPE_BOTH:
  730.          Output( hwndMLE, "Both\n" );
  731.          break;
  732.  
  733.       case WKF_ACTIONSCOPE_NONE:
  734.          Output( hwndMLE, "None\n" );
  735.          break;
  736.  
  737.       default:
  738.          Output( hwndMLE, "Invalid (0x%x)", ulActionScope );
  739.    } /* endswitch */
  740.  
  741.    return;
  742. }  
  743.  
  744.  
  745.  
  746.  
  747.  
  748. /****************************************************************************/
  749. /* OutputMenuScope()                                                        */
  750. /*                                                                          */
  751. /****************************************************************************/
  752. static VOID OutputMenuScope( HWND hwndMLE, ULONG ulMenuScope )
  753. {
  754.    switch( ulMenuScope )
  755.    {
  756.       case WKF_MENUSCOPE_DETAIL:
  757.          Output( hwndMLE, "Detailed\n" );
  758.          break;
  759.  
  760.       case WKF_MENUSCOPE_SHORT:
  761.          Output( hwndMLE, "Short\n" );
  762.          break;
  763.  
  764.       default:
  765.          Output( hwndMLE, "Invalid (0x%x)", ulMenuScope );
  766.    } /* endswitch */
  767.  
  768.    return;
  769. }  
  770.  
  771.  
  772.  
  773.  
  774.  
  775. /****************************************************************************/
  776. /* OutputMsgScope()                                                         */
  777. /*                                                                          */
  778. /****************************************************************************/
  779. static VOID OutputMsgScope( HWND hwndMLE, ULONG ulMsgScope )
  780. {
  781.    switch( ulMsgScope )
  782.    {
  783.       case WKF_MSGSCOPE_HOST:
  784.          Output( hwndMLE, "Host\n" );
  785.          break;
  786.  
  787.       case WKF_MSGSCOPE_DIR:
  788.          Output( hwndMLE, "Dir\n" );
  789.          break;
  790.  
  791.       case WKF_MSGSCOPE_NET:
  792.          Output( hwndMLE, "Net\n" );
  793.          break;
  794.  
  795.       case WKF_MSGSCOPE_OPERAND:
  796.          Output( hwndMLE, "Operand\n" );
  797.          break;
  798.  
  799.       default:
  800.          Output( hwndMLE, "Invalid (0x%x)", ulMsgScope );
  801.    } /* endswitch */
  802.  
  803.    return;
  804. }  
  805.  
  806.  
  807.  
  808.  
  809. /****************************************************************************/
  810. /* InitMLE()                                                                */
  811. /*                                                                          */
  812. /****************************************************************************/
  813. static VOID InitMLE( HWND hwndMLE )
  814. {
  815.    LONG lMLESize;
  816.  
  817.    lMLESize = (LONG)WinSendMsg( hwndMLE,
  818.                                 MLM_QUERYTEXTLENGTH,
  819.                                 MPFROMP(NULL),
  820.                                 MPFROMP(NULL) );
  821.  
  822.    WinSendMsg( hwndMLE,     
  823.                MLM_DELETE,  
  824.                MPFROMLONG(0),
  825.                MPFROMLONG( lMLESize ) );
  826.  
  827.    WinSendMsg( hwndMLE,           
  828.                MLM_FORMAT,        
  829.                MPFROMLONG( MLFIE_NOTRANS ),
  830.                MPFROMP(NULL) );
  831.  
  832.    return;
  833. }
  834.  
  835.  
  836.  
  837.  
  838. /****************************************************************************/
  839. /* Output()                                                                 */
  840. /*                                                                          */
  841. /****************************************************************************/
  842. static VOID Output( HWND hwndMLE, PSZ pszFormat, ... )
  843. {
  844.    va_list args;
  845.    CHAR    szBuffer[ MAX_LINE_LENGTH ];
  846.    ULONG   ulLen;
  847.    IPT     ipt;
  848.  
  849.    va_start( args, pszFormat );
  850.    vsprintf( szBuffer, pszFormat, args );
  851.    va_end( args );
  852.  
  853.    ulLen = strlen( szBuffer );
  854.  
  855.    /*
  856.    ** Setup a buffer to import text to the MLE
  857.    */
  858.    WinSendMsg( hwndMLE,            
  859.                MLM_SETIMPORTEXPORT,
  860.                MPFROMP( szBuffer ),
  861.                MPFROMLONG( ulLen ) );
  862.  
  863.    /*
  864.    ** Make sure we insert the text at the end of the MLE
  865.    */
  866.    ipt = (IPT)WinSendMsg( hwndMLE,
  867.                           MLM_QUERYTEXTLENGTH,
  868.                           MPFROMP(NULL),
  869.                           MPFROMP(NULL) );
  870.  
  871.    WinSendMsg( hwndMLE,         
  872.                MLM_IMPORT,      
  873.                MPFROMP( &ipt ),
  874.                MPFROMLONG( ulLen ) );
  875.  
  876.    return;
  877. }
  878.  
  879.  
  880.  
  881. /****************************************************************************/
  882. /* OutputList()                                                             */
  883. /*                                                                          */
  884. /****************************************************************************/
  885. static VOID OutputList( HWND hwndMLE, PSZ pszIndent, PSZ pszList )
  886. {
  887.    PSZ pszNext;
  888.  
  889.    if( pszList[0] )
  890.    {
  891.       do
  892.       {
  893.          pszNext = strchr( pszList, WKF_LIST_DELIM );
  894.          if( pszNext )
  895.             pszNext[0] = '\0';
  896.  
  897.          Output( hwndMLE, "%s\"%s\"", pszIndent, pszList );
  898.          CheckSpaces( hwndMLE, pszList );
  899.  
  900.          if( pszNext )
  901.          {
  902.             pszList = &(pszNext[1]);
  903.             pszNext[0] = WKF_LIST_DELIM;
  904.          }
  905.  
  906.       } while ( pszNext ); /* enddo */
  907.    }
  908.    else
  909.    {
  910.       Output( hwndMLE, "%s<none>\n", pszIndent );
  911.    }
  912.  
  913.    return;
  914. }
  915.  
  916.  
  917.  
  918. /****************************************************************************/
  919. /* CheckSpaces()                                                            */
  920. /*                                                                          */
  921. /****************************************************************************/
  922. static VOID CheckSpaces( HWND hwndMLE, PSZ pszText )
  923. {
  924.    ULONG ulLen;
  925.  
  926.    if( pszText[0] == ' ' )
  927.       Output( hwndMLE, " (Leading blank)" );
  928.  
  929.    ulLen = max( 0, strlen( pszText )-1 );
  930.    if( pszText[ ulLen ] == ' ' )
  931.       Output( hwndMLE, " (Trailing blank)" );
  932.  
  933.    Output( hwndMLE, "\n" );
  934. }
  935.