home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Jason Aller Floppy Collection
/
267.img
/
RESIDNTC.ZIP
/
DEMOS.ZIP
/
RES_HOLD.C
< prev
next >
Wrap
Text File
|
1990-03-07
|
4KB
|
201 lines
/* RES_HOLD.C */
#include "stdlib.h"
#include "tsr.h"
#include "resproto.h"
#include "stdio.h"
#include "string.h"
#include "conio.h"
#include "isr.h"
#include "dos.h"
#ifdef M_I86 /* Microsoft internal define , otherwise Turbo C */
#define disable _disable
#define enable _enable
#define getvect _dos_getvect
#define setvect _dos_setvect
#define inportb inp
#endif
/* scan code for H key used with CTRL here */
#define SCAN_H 0x23
/* window save buffer declared globally */
char scrnbuf[4000];
unsigned *share_vecs_ptr;
char default_drive[128] = "C:\\";
char drive_str[80] = "Temporary Storage Drive = ";
char err[40]= "ERROR IN LOAD: ";
void resprog(void);
int holdev(char *path, int mem, char *prg);
void main(int argc, char **argv)
{
int rc; /* return code variable */
/* declare function to execute when we get
control in TSR (when hotkey is hit) */
/* unique signature function number for
identification in tsrloaded() */
unsigned int r_hello = 0x1261;
if(argc > 1)
{
if((argv[1][0] == 'U' || argv[1][0] == 'u') && argv[1][1] == '\0')
{
if (!tsrloaded(r_hello))
{
puts("Program Not Loaded!");
exit(1);
}
else
{
rc = tsrfree(r_hello,1);
if(rc == 0)
{
puts("Program Unloaded!");
exit(0);
}
else
{
puts("Error Unloading");
exit(1);
}
}
}else /* reach here to change default drive */
{
strcpy(default_drive,argv[1]);
}
}
/* test if our TSR is already loaded */
if (!tsrloaded(r_hello))
{
save_ints_before();
if ((rc = inittsr(RIGHT_SHIFT, SCAN_H, resprog,
20, r_hello, SIG, (void far *)&share_vecs_ptr)) != 0)
{
puts("Could Not Load. ");
exit(1);
}
}
else
puts("Already Loaded!");
}
/* this function gets control when popped up */
void resprog()
{
int page; /* video page */
int mode; /* video mode */
int i;
char retcodes[2];
int *x;
char buf[80];
/* retrieve video mode and video page */
getvmod(&mode,&page);
x = (int *) retcodes;
/* see if we are in 80 column text modes */
if ( mode != 2 && mode != 3 && mode != 7 )
{
putch(7); /* if yes, beep and exit */
return;
}
/* save screen */
savwindo(0,0,24,79,scrnbuf);
savcur();
save_ints_after();
menu:
/* clear a window in reverse video */
scroll_vid(0,0,7,10,28,14,60,1);
loc_cur(11,31); /* locate cursor in window */
puts(" Hit Q to Quit ");
loc_cur(12,31); /* locate cursor in window */
puts("Enter command to execute: ");
loc_cur(13,31); /* locate cursor in window */
puts(" ");
loc_cur(13,31); /* locate cursor in window */
gets( buf );
if(buf[0] == '\0')
{
scroll_vid(0,7,0,0,0,24,79,0); /* clear screen */
loc_cur(0,0);
puts("Loading a DOS SHELL - Type 'EXIT' to return");
}
if(buf[0] == 'q' || buf[0] =='Q')
{
if(buf[1] == '\0')
{
goto noholdev;
}
}
scroll_vid(0,7,0,0,0,24,79,0); /* clear screen */
loc_cur(0,0);
*x = holdev(default_drive,0, buf);
if(*x != 0)
{
putch(7);
scroll_vid(0,0,7,10,28,14,60,1);
loc_cur(11,31); /* locate cursor in window */
itoa(*x,buf,16);
i = strlen(err);
strcat(err,buf);
puts(err);
err[i] = '\0'; /* reset err length before number */
loc_cur(12,31); /* locate cursor in window */
puts("Hit any key to resume");
getch();
goto menu;
}
noholdev:
restore_ints_after();
rstwindo(0,0,24,79,scrnbuf);
rstcur();
return;
}
void tsrpre()
{
scroll_vid(0,7,0,0,0,24,79,0); /* clear screen */
loc_cur(0,0);
puts("Hold Everything! (tm) TSR Demonstration");
puts("");
puts(" by South Mountain Software");
puts("");
puts("Program Loaded - Hit RIGHT_SHIFT-H to pop it up");
puts("");
puts("Type \"RES_HOLD U\" to UNLOAD this TSR");
puts("");
strcat(drive_str,default_drive);
puts(drive_str);
}