home *** CD-ROM | disk | FTP | other *** search
- #include "ckit.h" /* Include CKIT Header file! */
- #include "ckitdemo.h" /* Include file for demo */
- #pragma check_stack (off)
-
-
- /******************************************************************************
- * Start of Main Program *
- *****************************************************************************/
- /* The main function MUST be prototyped as below using C's argc and
- * argv array in your door program for use with CKIT.LIB.
- */
-
- main(int argc, char **argv) { /* MUST HAVE MAIN PROTOTYPED AS SHOWN! */
-
- /******************************************************************************
- * USER adjustments *
- * You will need to set these according to how you want CKIT to handle certain *
- * options. See the CKIT.DOC for more information *
- * Also see CKITDEMO.H for program name *
- *******************************************************************************/
- FORCEOFFHOOK = TRUE; /* Force modem off-hook on dropped carrier */
- USERSFILE = FALSE; /* optional, set to TRUE if user file info desired */
-
- if (argc > 0) {
- debug_on();
- logoff_color = (green); /* Logoff message equals green */
- strcpy(logoff_msg, "Returning to system, Please wait...");
-
- /* The 1st arg. must be the system file. */
- /* If you do want user file info for */
- /* your door, you should set */
- /* the USERSFILE=TRUE, and pass the */
- /* users path\name as argv[2] to open_ */
- /* door. i.e open_door(argv[1],argv[2]); */
- open_door(argv[1], argv[2]); /* The portnumber could be any argument */
- /* except the first argv[1], (must be */
- /* the system file), the second arg[2] */
- /* could be the users file or port */
- /* change, or the third argument would */
- /* be a port change if the users file */
- /* was needed to be opened. */
- /* Below is some examples of how your program would/could be called up */
- /* and how the open_door() function would be called. Notice PORT is always */
- /* the second or third (last) argument to be passed if a user of your door */
- /* program wanted to use it. */
- /* Note also it does not matter which order on the cmd line the arguments */
- /* are listed. The only thing that matters is which order they are passed */
- /* to the open_door() function itself. */
-
- /* ckitdemo PORT:03F8:4 c:\pcb\pcboard.sys d:\main\users */
- /* open_door(argv[2], argv[3], argv[1]); */
-
- /* ckitdemo pcboard.sys port03F8:04 */
- /* open_door(argv[1], argv[2]; */
-
- /* ckitdemo door.cfg pcboard.sys */
- /* open_door(argv[2]); */
-
- /* ckitdemo pcboard.sys users */
- /* open_door(argv[1], argv[2]; */
-
- /* Passing a config file for your door as the second arg. and some other */
- /* parameter as the 3rd parameter on the cmd line and port as 4th */
-
- /* ckitdemo pcboard.sys door.cfg door.inf PORT:03F8:4 */
- /* open_door(argv[1], argv[4]; */
-
- display_info(); /* Display user information */
- errmsg_ptr = &error_msg11[0]; /* File error msg pointer */
- menu(); /* Main program loop */
- close_door(); /* Close file, reset vectors */
- exit(0); /* Back to DOS */
- }
- }
- /******************************************************************************
- * End of Main Program *
- ******************************************************************************/
-
- /******************************************************************************
- * Main Menu *
- ******************************************************************************/
- void menu(void) {
-
- newline();
- if(display_file("ckit.m")) { /* If error display_file() return NON_ZERO */
- newline();
- }
- force_enter();
- /* main command loop */
- while(DUMP_USER != TRUE) {
- /* prompt for input only if there is not a stacked command pending */
- if ( strlen(cmdline) == 0) {
- color(white);
- newline();
- s_puts("Main menu:\r\n");
- color(red);
- s_puts(" (I) Display system information\r\n");
- color(green);
- s_puts(" (C) Take a chance for more time online\r\n");
- color(magenta);
- s_puts(" (T) Display a test pattern\r\n");
- color(cyan);
- s_puts(" (A) Ansi graphics demo\r\n");
- color(violet);
- s_puts(" (D) Display information on CKIT\r\n");
- color(green);
- s_puts(" (F) Download CKIT.DOC using Zmodem \r\n");
- color(yellow);
- s_puts(" (M) Graphics Mode On/Off \r\n");
- color(red);
- s_puts(" (Q) Return to PCBoard\r\n");
- color(green);
- s_puts(" (G) Logoff (Disconnect)\r\n");
- color(cyan);
- s_puts("\r\n\
- While you are sitting here at the command line. Press some extended key\
- board \r\nkeys. If you are on the remote end using Qmodem, go into the DOORWAY\r\n\
- mode. Remember this is just a demo/usage for scan_code, so it's nothing \
- fancy.\r\n");
- color(yellow);
- do {
- newline();
- display_time();
- color(green);
- s_puts("Command? ");
- get_cmdline(); /* read input into 'cmdline' */
-
- } while((DUMP_USER != TRUE) && (strlen(cmdline) == 0) && (scan_code == 0));
- }
- if (DUMP_USER == TRUE) {
- close_door();
- exit(1);
- }
- if (scan_code != 0) {
- color(white);
- read_scancode();
- newline();
- }
- if (get_nextpar()) { /* scan next parameter from cmdline into par */
- newline();
- /* process commands */
- switch ( par[0] ) {
- case 'A':
- ansi_demo();
- break;
- case 'C':
- take_chance();
- break;
- case 'I':
- display_info();
- break;
- case 'T':
- test_pattern();
- break;
- case 'D':
- color(cyan);
- strcpy(error_msg11, "\a\nUnable to locate CKIT.DOC");
- if(display_file(doc_filename)) {
- newline();
- };
- *errmsg_ptr = '\0'; /* Switch back to standard error msg */
- break;
- case 'F':
- color(cyan);
- filexfer();
- break;
- case 'M':
- graphics = graphics ^ TRUE;
- break;
- case 'Q':
- option = EXITDOOR;
- close_door();
- exit(0);
- break;
- case 'G':
- option = LOGOFF;
- logoff();
- close_door();
- exit(0);
- break;
- default:
- newline();
- color(magenta);
- s_putv("(",par,") is not allowed! Try again:", NULL);
- *cmdline = 0;
- break;
- }
- }
- }
- }
-
- /******************************************************************************
- * Display User information *
- ******************************************************************************/
- void display_info(void) {
-
- char s_out_str[34]; /* Temp. work buffer for itoa function */
- clr_screen();
- newline();
- color(white);
- s_putv(firstname,", Here is your User information:",NULL);
- color(green);
- newline();
- s_putv(" Fullname = ",fullname,"\r\n",NULL);
-
- /* if(!GENERIC) { */
- if (!PCB) {
- s_puts(" Phone number(s) = ");
- }
- if (!WILDCAT && !PCB) {
- s_putv(user.bphone," \ ",NULL);
- }
- if (!PCB) {
- s_puts(user.phone);
- newline();
- s_putv(" City = ",user.city,"\r\n",NULL);
- }
- s_putv(" Modem Baud Rate = ",baud_rate,"\r\n",NULL);
- s_putv(" DTE Baud Rate = ",bps_open,"\r\n",NULL);
- s_putv(" Minutes left = ",itoa(min_left+time_credit,s_out_str,10),"\r\n",NULL);
-
- if (!PCB) {
- s_putv(" Protocol is = ",protocol,"\r\n",NULL);
- }
-
- if (!WILDCAT && !PCB) {
- s_putv(" Last call date = ",user.last_date,"\r\n",NULL);
- }
-
- if (!PCB && !WILDCAT) {
- s_putv(" Event runs at = ",event_time,"\r\n",NULL);
- s_putv(" Total K bytes = ",download_Kbytes,NULL);
- newline();
- s_putv(" Total K bytes = ",upload_Kbytes,"\r\n",NULL);
- }
- if (!PCB) {
- s_putv(" # of Downloads = ",dload_total, NULL);
- s_putv(" Today's K bytes = ",daily_bytes,"\r\n",NULL);
- s_putv(" Allowed K bytes = ",itoa(dload_limit,s_out_str,10),"\r\n",NULL);
- s_putv(" # of Uploads = ",upload_total,"\r\n", NULL);
- s_putv(" Your birthday = ",caller_bday,"\r\n", NULL);
- s_putv(" Last file scan = ", last_file_scan,"\r\n", NULL);
- }
- if (WILDCAT) {
- s_putv(" Monitor type = ", monitor_type,"\r\n",NULL);
- s_putv(" High msg. read = ", high_msg,"\r\n", NULL);
- s_putv(" Door opened = ", door_opened, "\r\n", NULL);
- }
- s_puts(" Graphic = ");
- if (graphics) {
- s_puts("ON");
- } else {
- s_puts("OFF");
- }
- newline();
- s_putv(" Connected to port ", aport, NULL);
- newline();
- s_puts(" Error correction = ");
- if (error_connection) {
- s_puts("YES");
- } else {
- s_puts("NO");
- }
- newline();
- s_putv(" Page length = ", \
- itoa(page_length,s_out_str,10),"\r\n", NULL);
- color(yellow);
- newline();
- force_enter();
- /*
- * *cmdline = NULL; Use this if you don't want cmd stacking
- */
-
- /* } */
- }
-
- /******************************************************************************
- * ANSI Demo *
- ******************************************************************************/
- void ansi_demo(void) {
-
- short x,y;
- register short i;
-
- if (graphics) { /* Check if user is in graphics mode */
- clr_screen();
- for (y=2; y < 24; y++) {
- pos_cursor(y,1);
- s_puts("│");
- pos_cursor(y,79);
- s_puts("│");
- }
- x = 2;
- pos_cursor(1,x);
- for(i = 0; i <= 1; i++) {
- while(x < 79) {
- s_puts("─");
- x++;
- }
- x = 2;
- pos_cursor(23,x);
- }
- pos_cursor(1,1);
- s_puts("┌");
- pos_cursor(1,79);
- s_puts("┐");
- pos_cursor(23,1);
- s_puts("└");
- pos_cursor(23,79);
- s_puts("┘");
-
- for(i = blue; i <= white; i++) {
- color(i);
- pos_cursor(i-8+3,11);
- s_puts("ANSI Color display");
- }
- for(i = grey; i >= dkblue; i--) {
- color(i);
- pos_cursor(i+3, 50);
- s_puts("ANSI Color display");
- }
- color(red);
- pos_cursor(13,34);
- s_puts("C - K I T");
- color(yellow);
- pos_cursor(16,14);
- s_puts("This is only a SMALL sample of what C-Kit can do! ");
- color(red);
- pos_cursor(20,26);
- } else {
- newline();
- s_puts("ANSI demo available only in GRAPHICS mode.\r\n");
- }
- force_enter();
-
- /*
- * *cmdline = NULL; Use this if you don't want cmd stacking
- */
- clr_screen();
- }
-
- /*****************************************************************************
- * Open door *
- *****************************************************************************/
- void test_pattern(void) {
- int i;
-
- newline();
- for (i = 1; i < 21; i++) {
- s_puts("(1234567890-abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789)\r\n");
- }
- /*
- * *cmdline = NULL; Use this if you don't want cmd stacking
- */
-
- }
-
-
- /*****************************************************************************
- * Filexfer doc file *
- *****************************************************************************/
- void filexfer(void) {
- char xfer_file[46];
- strcpy(xfer_file, zmodem_send);
- strcat(xfer_file, doc_filename);
- color(green);
- s_putv("\nReady to send ", doc_filename, ". Press <ENTER> to begin.", NULL);
- while(DUMP_USER != TRUE) {
- if( check_CR() ) {
- break;
- }
- }
- if(dos_shell(xfer_file)) {
- s_puts("\n\aTransfer aborted");
- } else {
- s_puts("\nTransfer complete");
- }
- /*
- * *cmdline = NULL; Use this if you don't want cmd stacking
- */
- }
-
- /******************************************************************************
- * Demostrate scan_code usage *
- ******************************************************************************/
- void read_scancode(void) {
-
- newline();
- newline();
- /* process scancodes */
- switch(scan_code) {
- case 0x3B00:
- s_puts("You pressed F1");
- break;
- case 0x3C00:
- s_puts("You pressed F2");
- break;
- case 0x3D00:
- s_puts("You pressed F3");
- break;
- case 0x3E00:
- s_puts("You pressed F4");
- break;
- case 0x3F00:
- s_puts("You pressed F5");
- break;
- case 0x4000:
- s_puts("You pressed F6");
- break;
- case 0x4100:
- s_puts("You pressed F7");
- break;
- case 0x4200:
- s_puts("You pressed F8");
- break;
- case 0x4300:
- s_puts("You pressed F9");
- break;
- case 0x4400:
- s_puts("You pressed F10");
- break;
- case 0x4800:
- s_puts("You pressed UP Arrow");
- break;
- case 0x5000:
- s_puts("You pressed Dn Arrow");
- break;
- case 0x4D00:
- s_puts("You pressed R Arrow");
- break;
- case 0x4B00:
- s_puts("You pressed L Arrow");
- break;
- case 0x4900:
- s_puts("You pressed PgUp");
- break;
- case 0x5100:
- s_puts("You pressed PgDn");
- break;
- case 0x5200:
- s_puts("You pressed Insert");
- break;
- case 0x5300:
- s_puts("You pressed Delete");
- break;
- case 0x4700:
- s_puts("You pressed Home");
- break;
- case 0x4F00:
- s_puts("You pressed End");
- break;
- case 0x4A00:
- s_puts("You pressed Grey - ");
- break;
- case 0x4E00:
- s_puts("You pressed Grey + ");
- break;
- default:
- break;
- }
- newline();
- s_puts(" - Press a key to continue - ");
- newline();
- while(!(wait_keypress())) {
- }
- }
-
-
- /*****************************************************************************
- * Take a chance on on-line time *
- *****************************************************************************/
- void take_chance(void) {
- char thinking_of[5];
-
- if(PCB) {
- *cmdline = 0;
- itoa(random(10),thinking_of,10);
- if ( strlen(cmdline) == 0) {
- color(cyan);
- s_puts("I'm thinking of a number from 0 to 9. If you guess the\r\n");
- s_puts("number, you will be given an extra 10 minutes online. If you\r\n");
- s_puts("get it wrong, your time will be reduced by 2 minutes.\r\n");
- newline();
- color(yellow);
- s_puts("What's your guess? ");
- get_cmdline();
- newline();
- }
- if (get_nextpar()) { /* scan next parameter from cmdline into par */
- if (!strcmpi(thinking_of, par)) {
- color(green);
- s_puts("That's right! You get a 10 minute bonus!");
- adjust_time_allowed(10);
- } else {
- color(blue);
- s_putv("Wrong! You lose 2 minutes! I was thinking of ", thinking_of,".",NULL);
- adjust_time_allowed(-2);
- }
- }
- } else {
- newline();
- s_puts("Take chance only available with PCBOARD.SYS usage.\r\n");
- }
- }
-
-
- /****************************************************************************
- * IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF *
- * This #if is needed since TURBOC has it's own random() function *
- * This is needed for this demo source code only. *
- ****************************************************************************/
- #if COMPILER == MICROSOFT
- int random(short Modulo) {
- short seed;
- check_time_left();
- seed = system_time_HHMMSS[7] - 0x30; /* Strip ASCII off */
- return(RAND(seed));
- }
- #endif
-
- /****************************************************************************
- * ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF *
- ****************************************************************************/
-
- /****************************************************************************/
- /************************ E N D O F M O D U L E **************************/
-