home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
xkey1.exe
/
UNGETCH.C
next >
Wrap
Text File
|
1995-02-09
|
7KB
|
235 lines
/****************************************************************************
** File: UNGETCH.c
**
** Desc: Tests ability to ungetch() an extended key character.
**
** 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. Developer support for this software
** may be provided at the discretion of Novell.
**
** QMK386 options used:
**
** None
**
** Notes:
**
** As compiled, this source code is specific to NetWare 4.10, and it is
** assumed that the MONITOR.NLM has been loaded previously. The program
** searches for the monitor screen and then simulates an F1 keystroke to
** that screen. If successful, the monitor screen will bring up a help
** screen.
**
** In main(), there is an auto (char *) variable called screenName. You
** will notice that the 3.12 definition of screen name is commented out.
** To run the application on 3.12, the program may be recompiled after
** commenting out the 4.10 version and uncommenting the 3.12 version. Or,
** the screenName may simply be specified on the LOAD command line:
**
** LOAD UNGETCH "Monitor Screen"
**
** Keep in mind that the double quotes are required.
**
** Programmers:
**
** Ini Who Firm
** -----------------------------------------------------------------------
** ABJ Adam B. Jerome Novell Developer Support.
**
** History:
**
** When Who What
** -----------------------------------------------------------------------
** 01-31-95 ABJ First Code.
**
*/
/****************************************************************************
** Compiler setup.
*/
/*------------------------------------------------------------------------
** ANSI
*/
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
/*------------------------------------------------------------------------
** NetWare CLIB
*/
#include <niterror.h>
#include <conio.h>
/****************************************************************************
** Get a handle to an existing screen, or return EFAILURE.
*/
int NLM_GetScreenHandle(char *screenName)
{
int nextScreenID;
int screenHandle;
char name[80+1];
LONG attr;
/*------------------------------------------------------------------------
** Scan through the screens of all NLMs looking for the specified
** screenName. If not found, return EFAILURE.
*/
nextScreenID=ScanScreens(
/* I- LastScreenID */ NULL,
/* -O name */ name,
/* -O attrib */ &attr
);
while(nextScreenID != NULL)
{
if(strcmp(screenName, name) == 0)
break;
nextScreenID=ScanScreens(
/* I- LastScreenID */ nextScreenID,
/* -O name */ name,
/* -O attrib */ &attr
);
}
if(nextScreenID == NULL)
return(EFAILURE);
/*------------------------------------------------------------------------
** Build a duplicate handle to the specified screenName. CreateScreen
** returns EFAILURE if not successful.
*/
screenHandle=CreateScreen((char *)nextScreenID, 0);
return(screenHandle);
}
/****************************************************************************
** Program start.
*/
void main(int argC, char *argV[])
{
int screenHandle = EFAILURE;
int rVal;
int currentScreen = NULL;
char *screenName = "NetWare 4.10 Console Monitor"; /* NetWare 4.10 */
/* char *screenName = "Monitor Screen"; */ /* NetWare 3.12 */
/*------------------------------------------------------------------------
** Sign-on.
*/
fprintf(stderr, "UNGETCH() Testcase / Adam Jerome / Novell Developer Support / x7402\n");
fprintf(stderr, "\n");
/*------------------------------------------------------------------------
** Parse command-line.
*/
if(argC > 1) screenName = argV[1];
/*------------------------------------------------------------------------
** Obtain a reference to the current screen.
*/
currentScreen=GetCurrentScreen();
if(currentScreen == NULL)
{
fprintf(stderr, "ERROR: GetCurrentScreen() indicates NULL.");
goto END_ERR;
}
/*------------------------------------------------------------------------
** Get a handle to the specified screen.
*/
screenHandle=NLM_GetScreenHandle(screenName);
if(screenHandle == EFAILURE)
{
fprintf(stderr, "ERROR: NLM_GetScreenHandle() indicates FAILURE.");
goto END_ERR;
}
/*------------------------------------------------------------------------
** Current screen is the specified screen.
*/
rVal=SetCurrentScreen(screenHandle);
switch(rVal)
{
case ESUCCESS:
break;
case EBADHNDL:
fprintf(stderr, "ERROR: SetCurrentScreen() indicates BAD HANDLE\n");
goto END_ERR;
default:
fprintf(stderr, "ERROR: SetCurrentScreen() indicates %d\n", rVal);
goto END_ERR;
}
/*------------------------------------------------------------------------
** Send an extended keystroke (F1) to the specified screen.
*/
ungetch(0x3B00);
END_ERR:
/*------------------------------------------------------------------------
** Restore our screen.
*/
if(currentScreen != NULL)
{
rVal=SetCurrentScreen(currentScreen);
switch(rVal)
{
case ESUCCESS:
break;
case EBADHNDL:
fprintf(stderr, "ERROR: SetCurrentScreen() indicates BAD HANDLE\n");
break;
default:
fprintf(stderr, "ERROR: SetCurrentScreen() indicates %d\n", rVal);
break;
}
}
/*------------------------------------------------------------------------
** Destroy reference to the specified screen.
*/
if(screenHandle != EFAILURE)
{
rVal=DestroyScreen(screenHandle);
switch(rVal)
{
case ESUCCESS:
break;
case EBADHNDL:
fprintf(stderr, "ERROR: DestroyScreen() indicates BAD HANDLE\n");
break;
default:
fprintf(stderr, "ERROR: DestroyScreen() indicates %d\n", rVal);
break;
}
}
exit(0);
}