home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
xsnc1.exe
/
DELAY.C
next >
Wrap
Text File
|
1994-09-12
|
5KB
|
139 lines
/****************************************************************************
** File: DELAY.C
**
** Desc: Delay's (the System prompt) a specified amount of time.
**
** Being that NetWare is multi-threaded, this NLM (once loaded)
** would run in it's own thread and the system prompt (colon) would
** become available for a new command. To prevent this, the Link
** directive "SYNCHRONIZE" has been implemented. It is described in
** the NLM Development Tools manual, page 118, as follows:
**
** "When an NLM that includes this option is loaded, the load process
** goes to sleep until the NLM calls the SynchronizeStart function.
** This prevents any other console command from being processed
** (particularly other LOAD commands) while the NLM is being loaded.
** NOTE: It is imperative that the NLM call the SynchronizeStart
** function as soon as possible after being loaded, so that the
** console command process will be started."
**
** 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:
**
** /ns - Synchronize start.
** /x - no default screen for NLM
**
** Programmers:
**
** Ini Who Firm
** -----------------------------------------------------------------------
** ABJ Adam B. Jerome Novell Developer Support.
**
** History:
**
** When Who What
** -----------------------------------------------------------------------
** 07-20-94 ABJ First code.
*/
/****************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------------
** ANSI
*/
#include <stdlib.h> /* exit(), atol() */
#include <time.h> /* difftime(), time() */
#include <stdio.h> /* sprintf() */
/*------------------------------------------------------------------------
** NetWare
*/
#include <process.h> /* delay() */
#include <conio.h> /* ConsolePrintf() */
#include <advanced.h> /* SynchronizeStart() */
/****************************************************************************
** Program Start.
*/
void main(int argc, char *argv[])
{
time_t sTime; /* Start time */
char szTemp[100+1];
double seconds;
double delta; /* Time shift in seconds. */
int barLen;
int barLenOld=0;
char *bar="▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒";
/*------------------------------------------------------------------------
** Check command line args.
*/
if(argc != 2)
{
ConsolePrintf("Usage: LOAD %s {delay}\n\r", argv[0]);
ConsolePrintf("\n\r");
ConsolePrintf(" {delay} This parameter specifies the delay in seconds.\n\r");
ConsolePrintf("\n\r");
goto EXIT;
}
/*------------------------------------------------------------------------
** Calculate delay time in seconds.
*/
seconds=strtod(argv[1], NULL);
sTime=time(NULL);
/*------------------------------------------------------------------------
** Delay as requested.
*/
delta=difftime(time(NULL), sTime);
while(delta < (double)seconds)
{
barLen=79 - (int)((78.0 / seconds) * (delta));
if(barLenOld != barLen)
{
sprintf(szTemp, "%79s", "");
ConsolePrintf("%s\r", szTemp);
sprintf(szTemp, "%.*s", barLen, bar);
ConsolePrintf("%s\r", szTemp);
barLenOld = barLen;
}
ThreadSwitch();
delta=difftime(time(NULL), sTime);
}
/*------------------------------------------------------------------------
** Bye.
*/
EXIT:
/*------------------------------------------------------------------------
** Release the system prompt.
*/
SynchronizeStart();
exit(0);
}