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 >
Wrap
Text File
|
1994-08-19
|
5KB
|
212 lines
/****************************************************************************
** File: XNUT1.C
**
** Desc: Example of a NUT menu.
**
** Disclaimer:
**
** Novell, Inc. makes no representations or warranties with respect to
** any NetWare software, and specifically disclaims any express or
** implied warranties of merchantability, title, or fitness for a
** particular purpose.
**
** Distribution of any NetWare software is forbidden without the
** express written consent of Novell, Inc. Further, Novell reserves
** the right to discontinue distribution of any NetWare software.
**
** Novell is not responsible for lost profits or revenue, loss of use
** of the software, loss of data, costs of re-creating lost data, the
** cost of any substitute equipment or program, or claims by any party
** other than you. Novell strongly recommends a backup be made before
** any software is installed. Technical support for this software
** may be provided at the discretion of Novell.
**
**
** QMK386 options used:
**
** /in - Include import statement for NWSNUT symbols.
** /x - No default screen for NLM.
** /z - Generate NLMLINKx version of def file.
**
** Programmers:
**
** Ini Who Firm
** -----------------------------------------------------------------------
** ABJ Adam B. Jerome Novell Developer Support.
**
** History:
**
** When Who What
** -----------------------------------------------------------------------
** 08-19-94 ABJ First code.
*/
/****************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------------
** ANSI
*/
#include <stdlib.h> /* exit() */
#include <conio.h> /* CreateScreen(), DestroyScreen() */
#include <process.h> /* GetNLMHandle(), AtUnload() */
/*------------------------------------------------------------------------
** NetWare
*/
#include <advanced.h>/* AllocatResourceTag() */
#include <nwsnut.h> /* NWSRestoreNut(), NWSPushList(), ...*/
/*------------------------------------------------------------------------
** XNUT1
*/
#include "XNUT1.mlc" /* File maintained by MSGLIB.EXE */
#include "XNUT1.mlh" /* File maintained by MSGLIB.EXE */
/****************************************************************************
** Global storage
*/
int screenID;
NUTInfo *handle = NULL;
/****************************************************************************
** Registered unload function.
*/
void Unload(void)
{
if(handle != NULL) NWSRestoreNut(handle);
if(screenID != NULL) DestroyScreen(screenID);
return;
}
/****************************************************************************
** Main menu action procedure.
*/
int VerifyProgramExit(void)
{
int cCode;
cCode=NWSConfirm(
/* header */ PROGRAM_EXIT,
/* centerLine */ 0,
/* centerColumn */ 0,
/* defaultChoice */ 1,
/* actionProcedure */ NULL,
/* handle */ handle,
/* actionParameter */ NULL
);
return(cCode);
}
/****************************************************************************
** Main menu action procedure.
*/
int MainMenuAct(int index, void *parm)
{
parm=parm; /* Rid compiler warning. */
switch(index)
{
case (-1):
if(VerifyProgramExit()) return(0);
break;
case MENU_MAIN_OPTION1:
NWSTrace(handle, "Insert option #1 here.");
break;
case MENU_MAIN_OPTION2:
NWSTrace(handle, "Insert option #2 here.");
break;
default:
NWSTrace(handle, "Option not implemented.");
break;
}
return((-1));
}
/****************************************************************************
** Main menu.
*/
void MenuMain(void)
{
LIST *defaultOption;
NWSPushList(handle);
NWSInitMenu(handle);
defaultOption = NWSAppendToMenu(MENU_MAIN_OPTION1, MENU_MAIN_OPTION1,
handle);
NWSAppendToMenu(MENU_MAIN_OPTION2, MENU_MAIN_OPTION2, handle);
NWSMenu(
/* header */ MENU_MAIN__HDR,
/* centerLine */ 0, /* [0,0] means Center of screen*/
/* centerColumn */ 0,
/* defaultElement */ defaultOption, /* Could use NULL here desired */
/* actionProcedure */ MainMenuAct,
/* handle */ handle,
/* actionParameter */ NULL
);
NWSDestroyMenu(handle);
NWSPopList(handle);
return;
}
/****************************************************************************
** Program start.
*/
void main(void)
{
LONG ccode;
int NLMHandle;
LONG tagID;
NLMHandle=GetNLMHandle();
AtUnload(Unload);
screenID=CreateScreen(
/* screenName */ programMesgTable[SCREEN_NAME],
/* attributes */ AUTO_DESTROY_SCREEN
);
if(screenID == NULL) goto END;
tagID=AllocateResourceTag(
/* NLMHandle */ NLMHandle,
/* descriptionString */ programMesgTable[RS_TAG_NAME],
/* resourceType */ AllocSignature
);
if(tagID == NULL) goto END;
ccode=NWSInitializeNut(
/* utility */ PROGRAM_NAME,
/* version */ PROGRAM_VERSION,
/* headerType */ NORMAL_HEADER,
/* compatibilityType */ NUT_REVISION_LEVEL,
/* messageTable */ programMesgTable,
/* helpScreens */ NULL,
/* screenID */ screenID,
/* resourceTag */ tagID,
/* handle */ &handle
);
if(ccode != NULL) goto END;
DisplayScreen(screenID);
MenuMain();
END:
Unload();
exit(0);
}