home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / xnut1.exe / XNUT1.C next >
Text File  |  1994-08-19  |  5KB  |  212 lines

  1. /****************************************************************************
  2. **    File:    XNUT1.C
  3. **
  4. **    Desc:    Example of a NUT menu.
  5. **
  6. **    Disclaimer:
  7. **
  8. **        Novell, Inc. makes no representations or warranties with respect to
  9. **        any NetWare software, and specifically disclaims any express or
  10. **        implied warranties of merchantability, title, or fitness for a
  11. **        particular purpose.  
  12. **
  13. **        Distribution of any NetWare software is forbidden without the
  14. **        express written consent of Novell, Inc.  Further, Novell reserves
  15. **        the right to discontinue distribution of any NetWare software.
  16. **
  17. **        Novell is not responsible for lost profits or revenue, loss of use
  18. **        of the software, loss of data, costs of re-creating lost data, the
  19. **        cost of any substitute equipment or program, or claims by any party
  20. **        other than you.  Novell strongly recommends a backup be made before
  21. **        any software is installed.   Technical support for this software
  22. **        may be provided at the discretion of Novell.
  23. **
  24. **
  25. **    QMK386 options used:
  26. **
  27. **        /in - Include import statement for NWSNUT symbols.
  28. **        /x  - No default screen for NLM.
  29. **        /z  - Generate NLMLINKx version of def file.
  30. **
  31. **    Programmers:
  32. **
  33. **        Ini    Who                        Firm
  34. **        -----------------------------------------------------------------------
  35. **        ABJ    Adam B. Jerome            Novell Developer Support.
  36. **
  37. **    History:
  38. **
  39. **        When        Who    What
  40. **        -----------------------------------------------------------------------
  41. **        08-19-94    ABJ    First code.
  42. */
  43.  
  44. /****************************************************************************
  45. **    Include headers, macros, function prototypes, etc.
  46. */
  47.     /*------------------------------------------------------------------------
  48.     **    ANSI
  49.     */
  50.     #include <stdlib.h>    /*    exit()    */
  51.     #include <conio.h>      /* CreateScreen(), DestroyScreen() */
  52.     #include <process.h>    /* GetNLMHandle(), AtUnload()    */
  53.  
  54.     /*------------------------------------------------------------------------
  55.     **    NetWare
  56.     */
  57.     #include <advanced.h>/* AllocatResourceTag() */
  58.     #include <nwsnut.h>    /* NWSRestoreNut(), NWSPushList(), ...*/
  59.  
  60.     /*------------------------------------------------------------------------
  61.     **    XNUT1
  62.     */
  63.     #include "XNUT1.mlc"    /* File maintained by MSGLIB.EXE */
  64.     #include "XNUT1.mlh"    /* File maintained by MSGLIB.EXE */
  65.  
  66. /****************************************************************************
  67. **    Global storage
  68. */
  69. int         screenID;
  70. NUTInfo *handle = NULL;
  71.  
  72. /****************************************************************************
  73. ** Registered unload function.
  74. */
  75. void Unload(void)
  76.     {
  77.     if(handle != NULL)     NWSRestoreNut(handle);
  78.     if(screenID != NULL) DestroyScreen(screenID);
  79.     
  80.     return;
  81.     }
  82.  
  83. /****************************************************************************
  84. ** Main menu action procedure.
  85. */
  86. int VerifyProgramExit(void)
  87.     {
  88.     int cCode;
  89.     
  90.     cCode=NWSConfirm(
  91.         /*    header                */    PROGRAM_EXIT,
  92.         /*    centerLine            */    0,
  93.         /*    centerColumn        */    0,
  94.         /*    defaultChoice        */    1,
  95.         /*    actionProcedure    */    NULL,
  96.         /*    handle                */    handle,
  97.         /*    actionParameter    */    NULL
  98.         );
  99.  
  100.     return(cCode);
  101.     }
  102.  
  103. /****************************************************************************
  104. ** Main menu action procedure.
  105. */
  106. int MainMenuAct(int index, void *parm)
  107.     {
  108.     parm=parm;     /* Rid compiler warning. */
  109.  
  110.     switch(index)
  111.         {
  112.         case (-1):
  113.             if(VerifyProgramExit()) return(0);
  114.             break;
  115.  
  116.         case MENU_MAIN_OPTION1:
  117.             NWSTrace(handle, "Insert option #1 here.");
  118.             break;
  119.  
  120.         case MENU_MAIN_OPTION2:
  121.             NWSTrace(handle, "Insert option #2 here.");
  122.             break;
  123.  
  124.         default:
  125.             NWSTrace(handle, "Option not implemented.");
  126.             break;
  127.         }
  128.  
  129.     return((-1));
  130.     }
  131.  
  132. /****************************************************************************
  133. ** Main menu.
  134. */
  135. void MenuMain(void)
  136.     {
  137.     LIST *defaultOption;
  138.  
  139.     NWSPushList(handle);
  140.     NWSInitMenu(handle);
  141.  
  142.     defaultOption = NWSAppendToMenu(MENU_MAIN_OPTION1, MENU_MAIN_OPTION1,
  143.         handle);
  144.  
  145.     NWSAppendToMenu(MENU_MAIN_OPTION2, MENU_MAIN_OPTION2, handle);
  146.  
  147.     NWSMenu(
  148.         /*    header                */    MENU_MAIN__HDR,
  149.         /*    centerLine            */    0,                    /* [0,0] means Center of screen*/
  150.         /*    centerColumn        */    0,
  151.         /*    defaultElement        */    defaultOption,    /* Could use NULL here desired */            
  152.         /*    actionProcedure    */    MainMenuAct,
  153.         /*    handle                */    handle,
  154.         /*    actionParameter    */    NULL
  155.         );
  156.     
  157.     NWSDestroyMenu(handle);
  158.     NWSPopList(handle);
  159.  
  160.     return;
  161.     }
  162.  
  163. /****************************************************************************
  164. ** Program start.
  165. */
  166. void main(void)
  167.     {
  168.     LONG    ccode;
  169.     int    NLMHandle;
  170.     LONG    tagID;
  171.  
  172.     NLMHandle=GetNLMHandle();
  173.     AtUnload(Unload);
  174.  
  175.     screenID=CreateScreen(
  176.         /*    screenName    */    programMesgTable[SCREEN_NAME],
  177.         /*    attributes    */    AUTO_DESTROY_SCREEN
  178.         );
  179.     if(screenID == NULL) goto END;
  180.  
  181.     tagID=AllocateResourceTag(
  182.         /*    NLMHandle            */    NLMHandle,
  183.         /*    descriptionString    */    programMesgTable[RS_TAG_NAME],
  184.         /*    resourceType        */    AllocSignature
  185.         );
  186.     if(tagID == NULL) goto END;
  187.  
  188.     ccode=NWSInitializeNut(
  189.         /*    utility                */    PROGRAM_NAME,
  190.         /*    version                */    PROGRAM_VERSION,
  191.         /*    headerType            */    NORMAL_HEADER,
  192.         /*    compatibilityType    */    NUT_REVISION_LEVEL,
  193.         /*    messageTable        */    programMesgTable,
  194.         /*    helpScreens            */    NULL,
  195.         /*    screenID                */    screenID,
  196.         /*    resourceTag            */    tagID,
  197.         /*    handle                */    &handle
  198.         );
  199.     if(ccode != NULL) goto END;
  200.  
  201.     DisplayScreen(screenID);
  202.  
  203.     MenuMain();
  204.  
  205. END:
  206.     Unload();
  207.     
  208.     exit(0);
  209.     }
  210.  
  211.  
  212.