// FIX the code which tests for SE on BBS asking More Y/N if more than // one page of news // Add code to test for being reminded about subscriptions being due. // this is in TOESDIAL, not here ! /////////////////////////////// TOES.SLT //////////////////////////////////// // Version 1.14 - April 1991 // // Written by Ken Ironside of 5:491/1 // Maintained by Allan Marillier of 5:491/1 // PLEASE - read (or at least skim) the docs. There are no user configurable // variables, or anything in this file any more. // // OPUS - Golden City Fido & Silver Express upload and download script. // // This script uses the script TOESDIAL to log-on, which takes you to // the Bulletin menu. From there on this script automates the task of // uploading and downloading mail from an OPUS based BBS, using Silver Express // // REMEMBER to compile any script files that you alter. This file can // be compiled by entering "CS TOES" at the DOS prompt. // // See TOES.DOC for more information on the use of the script, and what // other requirements must be met, as well as the history of TOES, and // a list of files which should be in the distribution package /////////////////////////////////////////////////////////////////////////////// // Possible Enhancements and known bugs : // As suggested by Lester Hanger : shorten waitfor's and tracks to try // to prevent endless looping caused by corrupted strings sent. // Alternatively, make it time based. If no response within the configured // time, hang up automatically // Possibly cater for Expert as well as novice modes - both SX and OPUS // Add a facility to check for any .REP files other than the main one, and // upload them too /////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// // USER SPECIFIC VARIABLES str my_screen_shows_color[1]; str dial_str[10]; str user_name[60]; str toes_msg_file[12]; str toes_rep_file[12]; str my_reply_dir[60]; str my_mail_dir[60]; str make_date_packet[1]; str zmodem_protocol[1]; str auto_zap_opx[1]; str i_send_password[1]; str user_password[50]; // END OF USER SPECIFIC VARIABLES //////////////////////////////////////////////////////////////////////////// int rep_ok; // Set by check_upload_dir() // 0 = no reply file to upload // 1 = there is a reply file to upload int tmark; // a timer for auto bypass in check_dnload_dir str toes_rep_filespec[64]; // moved these here so they will be global str toes_msg_filespec[64]; // to use from both check_upload_dir AND toes_go int t1, t2, t3, t4, t5, t6, t7, t8, stat; // moved here to make them global to allow use in main as well as in toes_go int stat2; // used for tracking no new msgs and too many msgs int clean_exit = 0; // test if we got prompt on attempt to exit str date_name[8] = ""; // global file name in YYMMDD format str screen_buffer[80] = ""; // added to allow concat of message + file // name for display int kount; // general purpose counter str search[80] = ""; // needed to search for existing str search2[80] = ""; // files for copying to date format str filefinder[] = ""; // file names str buffer[80]; // added for the OPUS / XPRESS file int file_handle; // changes str prompt[80]; // added to store expected prompt int chr = 0; int quit = 0; int time_delay, hour, min, shour, smin; str cnf_up_dir[80]; str cnf_down_dir[80]; str small[10]; int protocol; //////////////////////////////////////////////////////////////////////////// main() { get_config(); // check for, and read a config file clear_scr(); prints(" лллллллллллллллл лллллллллллллллл лллллллллллллллл лллллллллллллллл"); prints(" лл лл лл лл лл лл"); prints(" лл лл лл лл лл"); prints(" лл лл лл лл лл"); prints(" лл лл лл лллллллллл лллллллллллллллл"); prints(" лл лл лл лл лл"); prints(" лл Telix лл OPUS лл лл Express Script лл"); prints(" лл лл лл лл лл лл"); prints(" лл лллллллллллллллл лллллллллллллллл лллллллллллллллл"); prints(""); prints(""); prints(" кФФФФФФФФФФФФФФФФФФФФФФФФФФФП"); prints(" Г ver *- 1.14 -* April 1991 Г"); prints(" РФФФФФФФФФФФФФФФФФФФФФФФФФФФй"); prints(""); prints(" Originally written by Ken Ironside of 5:491/1"); prints(""); prints(" Currently maintained by Allan Marillier of 5:491/1"); prints(""); buffer = "Thank you for using TOES - "; strcat(buffer,user_name); strcat(buffer,"."); search = " "; inschrs(search,buffer,0,(80 - strlen(buffer))/2); prints(buffer); prints(" We hope this script is useful to you !"); delay(40); // set up a loop to find if a time delay is required tmark = timer_start(200); // loop for 20 seconds prints("Would you like to set a later time at which the script will begin "); printsc(" polling the BBS ? (Yes / No / Abort) _ "); quit = 0; chr = 0; _scr_chk_key = 0; do { time_delay = toupper(inkey()); if (time_delay == 'Y' || time_delay == 'N' || time_delay == 'A') { quit = 1; printc(time_delay); prints(""); } if (time_delay == 'A') exittelix(); if (time_delay == 'Y') { // get current date date(curtime(),search); printsc("^M^JCurrent date is "); prints(search); // get the start time date(curtime(),search); time(curtime(),search); printsc("Current time is : "); prints(search); prints("Enter the start time to begin polling (24 hour format - HH:MM)"); quit = 0; do { gets(buffer,5); // do validation of time if (strchr(buffer,0,':') == 2) { subchrs(buffer,0,2,search); subchrs(buffer,3,2,search2); shour = stoi(search); smin = stoi(search2); if (shour >= 0 && shour <= 24 && smin >= 0 && smin <= 59) quit = 1; else prints("^M^JInvalid time entered .... try again"); } } while (quit == 0); } } while (quit == 0 && not time_up(tmark)); timer_free(tmark); _scr_chk_key = 1; // do the delay if required if (time_delay == 'Y') { t1 = _back_color; t2 = _fore_color; _back_color = 0; _fore_color = 0; _scr_chk_key = 0; quit = 0; chr = 0; clear_scr(); do { chr = inkey(); if (chr) { chr = 0; _back_color = t1; _fore_color = t2; clear_scr(); printsc("Abort, Continue to delay, Proceed immediately ? ( A / C / P ) "); chr = toupper(inkeyw()); strupper(search); if (chr == 'A') exittelix(); if (chr == 'P') quit = 1; _back_color = 0; _fore_color = 0; chr = 0; } kount = curtime(); hour = thour(kount); min = tmin(kount); if (hour == shour && min == smin) quit = 1; else { // display a character somewhere clear_scr(); gotoxy(tsec(kount),tsec(kount)/4); vputchr(15 + 112 * 256); } } while (!quit); clear_scr(); _back_color = t1; _fore_color = t2; _scr_chk_key = 1; } // end if delay was required strcat(user_name,";y"); if (zmodem_protocol == "D" || zmodem_protocol == "P") // set z modem auto download off if external DSZ or PCZ is to be used _zmod_auto = 0; // save the configured upload and download directories cnf_up_dir = _up_dir; cnf_down_dir = _down_dir; // pick up the user defined mail and reply directories. _up_dir = my_reply_dir; _down_dir = my_mail_dir; toes_rep_filespec = _up_dir; // check for, and add a trailing backslash, if none is found if (subchr(toes_rep_filespec,strlen(toes_rep_filespec) - 1,1) != 92) strcat(toes_rep_filespec,"\"); strcat(toes_rep_filespec,toes_rep_file); // function call to set date_name set_date_name(); terminal(); // Keep processing input from the BBS if (!check_dnload_dir()) // check download directory, check for exist OPX exittelix(0,1); check_upload_dir(); // check for upload files init_capture_file(); // open the log file dial(dial_str,0); // dial the BBS, and logon // TOESDIAL will run here, if configured as the script to use in the // dialling directory. It will take you to the Bulletin Menu on the BBSQyGolden City Fido. if (waitfor("Select:",30)) // Bulletin Menu prompt cputs("Q^M"); // Send "Q" for "Quit" else { hangup(); // If no prompt - bail out exittelix(0,1); } if (waitfor("MAIN:",30)) // Main Opus menu { cputs("E^M"); // Send 'E' for Silver Express toes_go(); // Run the SE procedure } else { hangup(); // If no prompt - bail out exittelix(0,1); } t1 = track("MAIN:",0); t2 = track("Password:",0); // Anything else to be tracked can be put here if necessary tmark = timer_start(600); while (not time_up(tmark)) // wait for a prompt for up to 60 secs { terminal(); stat = track_hit(0); if (stat == t1) { send_req(); // USE TOES.REQ here - note ! this is AFTER sx up/download clean_exit = 1; cputs("G^M"); // Goodbye goodbye_fido(); // Run the Clean Exit From Fido Proc break; // break out of this while loop } if (stat == t2) // cater for the possibility that Dave // re-introduces forced password on re-entry from SE { cputs (_entry_pass); cputs ("^M"); } } timer_free(tmark); // free the timer track_free(0); // free up the tracking if (clean_exit == 0) hangup(); // If no prompt - bail out exittelix(0,1); // exit telix } // End of Main() //////////////////////////////////////////////////////////////////////////// check_dnload_dir() { str buffer[64]; int video_buffer_handle; int pos; int sound_state; // save the state of the sound setting int disp_color; // added this for setting display colours if (my_screen_shows_color == "Y") disp_color = (12 + (16 * 01) ) * 256; // calculate the constant // 12 = Light Red, 16 * 01 = Blue background, vputchr wants this * 256 else disp_color = (15 * 256); // 15 = white, 16 * 0 = black background, * 256 for vputchr if (_zmod_rcrash != 0) // This section is only important if crash recovery is enabled { toes_msg_filespec = _down_dir; // check for, and add a trailing backslash, if none is found if (subchr(toes_msg_filespec,strlen(toes_msg_filespec) - 1,1) != 92) strcat(toes_msg_filespec,"\"); // make it ignore keyboard for Esc to abort script _scr_chk_key = 0; strcat(toes_msg_filespec,toes_msg_file); if (filefind(toes_msg_filespec,0,buffer)) // if the file exists then the user must choose something { if (auto_zap_opx == "Y") fdelete(toes_msg_filespec); // delete the file else { video_buffer_handle = vsavearea(15,7,65,16); // save what is under // the window box(15,7,65,16,1,0,31); // 31 = White on Blue scroll(16,8,64,15,8,7); gotoxy(17,8); buffer = toes_msg_file; strcat(buffer," already exists in download directory"); printsc(buffer); gotoxy(17,10); vputchr('R' + disp_color); // "R" in red on blue gotoxy(18,10); printsc("ename to .BAK (current dir NOT d/l dir (v 3.12))"); gotoxy(17,11); vputchr('D' + disp_color); // "D" in red on blue gotoxy(18,11); printsc("elete it"); gotoxy(17,12); vputchr('I' + disp_color); // "I" in red on blue gotoxy(18,12); printsc("gnore it"); gotoxy(17,13); vputchr('Q' + disp_color); // "Q" in red on blue gotoxy(18,13); printsc("uit the session"); tmark = timer_start(600); // set up for 60 second delay before auto decide what to do chr = 0; do { gotoxy(17,15); printsc("Select: "); gotoxy(25,15); chr = toupper(inkey()); // allow looping to test countdown printc(chr); if ((chr == 82) or (chr == 68) or (chr == 73) or (chr == 81)) { quit = 1; break; // break out of the loop } else if (chr > 0) // turn sound on, and beep { sound_state = _sound_on; _sound_on = 1; tone(659,14); _sound_on = sound_state; } // show user countdown status gotoxy(55,15); if (timer_total(tmark) > 510) { printn(0); gotoxy(56,15); } printn(60 - (timer_total(tmark) / 10)); } while (quit == 0 && not time_up(tmark)); timer_free(tmark); // free the timer variable // must now make it ignore if no manual intervention if (quit == 0) { chr = 73; // put I in, to ignore _zmod_rcrash = 0; // turn z modem crash recovery OFF. This way, if the .OPX file // exists, it will create a files .OP0, .OP1 etc..... but ONLY for // Telix' internal Zmodem. For DSZ / PCZ users, we must get rid of the // file, or DSZ will hang, therefore simulate user requesting Rename if (zmodem_protocol == "D" || zmodem_protocol == "P") chr = 82; } vrstrarea(video_buffer_handle); // Clear the window if (chr == 82) // Rename { buffer = toes_msg_file; pos = strpos(buffer,".",0); delchrs(buffer,(pos+1),3); strcat(buffer,"BAK"); frename(toes_msg_filespec,buffer); // this frename has the effect of MOVING the file to a // .BAK in the current dir with v 3.12. Fixed in v 3.15 return(1); } else if (chr == 68) // Delete { fdelete(toes_msg_filespec); return(1); } else if (chr == 73) // Ignore { // we can't just ignore though, because we will corrupt // the file GCOBBS.OPX. The reason we test here for the file, is // because zmodem crash recovery is on, and that is critical. // If the user manually chooses to Ignore, then we MUST set // zmodem crash recovery off, so the file will be named .OP1, .OP2 ... _zmod_rcrash = 0; return(1); } else // Quit { return(0); } } // end if using internal zmodem } // end if an old opx is found to exist } // end if zmodem crash recovery is on else prints("No mail file currently exists in the download area ...."); // re-enable Esc to allow aborting script by Esc _scr_chk_key = 1; } // end function check_dnload_dir //////////////////////////////////////////////////////////////////////////// check_upload_dir() // This proc checks the upload directory for the reply file. // If it exists, then it sets rep_ok to 1. If not, rep_ok is set to 0 { str buffer[64]; if (filefind(toes_rep_filespec,0,buffer)) // if the file exists then the { rep_ok = 1; prints("There is a reply file to upload..."); } else { rep_ok = 0; prints("There is no reply file to upload..."); } } // end function check_upload_dir //////////////////////////////////////////////////////////////////////////// init_capture_file() // Function to open a capture file in the // format "YYMMDD.LOG" { // replaced original with new code, at Pat Verner's suggestion // to write log file to YYMMDD.LOG, and not CAPnn // note - global variable date_name is set by function set_date_name str s1[16]; // To hold the capture file name str s2[4] = ".LOG"; // Capture File type s1 = date_name; strcat(s1,s2); screen_buffer = "A record of this session will be contained in file "; strcat(screen_buffer,s1); prints(screen_buffer); capture(s1); update_term(); } // end function init_capture_file //////////////////////////////////////////////////////////////////////////// toes_go() // This is the Silver Express Module { int dn_ok = 1; // download flag. 1 = no download has // taken place yet. 0 = download complete int video_buffer_handle; // if we need a message box, this is // required. int sound_stat; // hold temp _sound_on variable str buffer[64]; // needed by FileFind function t1 = track("[ Press Any Key to Continue ]",0); t2 = track("Enter C, D, U, S, H, Q ?",0); // changed for new SX prompts t3 = track("No New Messages to Download!",0); // followed by t1 t4 = track("Message Limit Exceeded",0); t5 = track("Press [CR] Download, [ESC] Abort",0); t6 = track("Enter Flex Select ",0); t7 = track("Enter Selection:",0); t8 = track("More",0); int copy_error = 0; // added as error checking for copy via dos, of // duplicate date named file while (1) { terminal(); stat = track_hit(0); if (stat == t7) cputs("Y^M"); if (stat == t1) cputs("^M"); else if (stat == t2 || stat == t7) // "Enter C, D, U, S, H, Q ?" { if (rep_ok == 1) // There's a file to upload { cputs("U^M"); // Send 'U' for upload delay_scr(40); // Wait 4 seconds if (zmodem_protocol == "D") dos("toesdsnd.bat",0); else if (zmodem_protocol == "P") dos("toespsnd.bat",0); else { kount = send('Z',toes_rep_file); // Send the reply file if (kount == -1) // transfer was aborted - try again with DSZ / PCZ { if (filefind("PCZ.EXE",2,buffer)) { zmodem_protocol = "P"; cputs("U^M"); // Send 'U' for upload delay_scr(40); // Wait 4 seconds dos("toespsnd.bat",0); } else if (filefind("DSZ.EXE",2,buffer)) { zmodem_protocol = "D"; cputs("U^M"); // Send 'U' for upload delay_scr(40); // Wait 4 seconds dos("toesdsnd.bat",0); } else { // neither was available - send Q, and break out search = date_name; strcat(search,".LOG"); file_handle = fopen(search,"a"); fputs("",file_handle); fputs("*********************************************",file_handle); fputs("WARNING ! Reply UPLOAD failed. Internal Zmodem aborted.",file_handle); fputs(" An attempt was made to use either PCZ.EXE or DSZ.EXE.",file_handle); fputs(" but neither program could be found in the current directory.",file_handle); fputs("TOES panic abort !",file_handle); fputs("*********************************************",file_handle); fclose(file_handle); cputs("Q^M"); // send quit to exit Silver Express, back to BBS break; } continue; } if (kount == -2) // carrier was lost { search = date_name; strcat(search,".LOG"); file_handle = fopen(search,"a"); fputs("",file_handle); fputs("*********************************************",file_handle); fputs("WARNING ! Carrier was lost during upload.",file_handle); fputs("TOES panic abort !",file_handle); fputs("*********************************************",file_handle); fclose(file_handle); hangup(); exittelix(); } } if (zmodem_protocol != "I" || waitfor("Successful Transfer!",60)) { rep_ok = 0; // If successful, set rep_ok to 0 so it won't try to send again // and then also delete the file afterwards fdelete(toes_rep_filespec); } continue; } if (dn_ok == 1) // We have not downloaded yet { cputs("D^M"); // Send 'D' to download while(1) { terminal(); stat = track_hit(0); if (stat == t1 || stat == t3 || stat == t4) // no new, or > 500 msgs { cputs("^M"); dn_ok = 0; // Set the download complete flag so it // won't try to download again. break; // break out } else if (stat == t6) { cputs("A^M"); // OK - send A for all break; // break out } } continue; } // If both upload and download are complete, then send quit, and // then break out of the while loop to exit toes_go if (rep_ok == 0 && dn_ok == 0) { cputs("Q^M"); // send quit to exit Silver Express, back to BBS break; } } else if ((stat == t5) and (dn_ok == 1)) // "Press ENTER to start Download or ESC to abort." { cputs("^M"); // Send a cr if (zmodem_protocol == "D") { if (waitfor("Start Your System to Download the File with Z-Modem",15)) { }; // do nothing - just wait for the silly message dos("toesdget.bat",0); cputs("^M^M^M"); // DSZ has a problem returning - possibly // speed related, so send a few CRs, then test // for SX temporarily assigning novice mode } else if (zmodem_protocol == "P") { if (waitfor("Start Your System to Download the File with Z-Modem",15)) { }; // do nothing - just wait for the silly message dos("toespget.bat",0); // cputs("^M^M^M"); // DSZ has a problem returning - possibly // speed related, so send a few CRs, then test // for SX temporarily assigning novice mode } else { if (_zmod_auto == 0 && zmodem_protocol = "I") // if z modem auto { // receive is off, bypass that and initiate a kount = receive('Z',""); // receive from here if (kount == -1) // transfer was aborted - try again with DSZ { if (filefind("PCZ.EXE",2,buffer)) { zmodem_protocol = "P"; // dos("toespget.bat",0); // leave this, as a failed transfer will cause dn_ok to be left at 1, therefore // it will try again } else if (filefind("DSZ.EXE",2,buffer)) { zmodem_protocol = "D"; // dos("toesdget.bat",0); // leave this, as a failed transfer will cause dn_ok to be left at 1, therefore // it will try again } // ALLAN // else ? what if neither is available then I must recover somehow // ie. write a message and hangup continue; } if (kount == -2) // carrier was lost { search = date_name; strcat(search,".LOG"); file_handle = fopen(search,"a"); fputs("",file_handle); fputs("*********************************************",file_handle); fputs("WARNING ! Carrier was lost during download.",file_handle); fputs("TOES panic abort !",file_handle); fputs("*********************************************",file_handle); fclose(file_handle); hangup(); exittelix(); } } } if (waitfor("Successful Transfer!",10) || zmodem_protocol == "D" || zmodem_protocol == "P") // assume that if DSZ is used, then the message will be missed, and // assume that transfer WAS ok. Put simply - if there is a problem // with DSZ, it probably won't return properly anyway. { dn_ok = 0; // Set the download complete flag so it // won't try to download again. // make a backup file if necessary if (make_date_packet == "Y") { // check for existing files kount = 0; search = _down_dir; strcat(search,date_name); search2 = search; strcat(search2,"00.OPX"); while (filefind(search2,0,buffer)) { kount = kount + 1; search2 = search; if (kount < 10) strcat(search2,"0"); itos(kount,buffer); strcat(search2,buffer); strcat(search2,".OPX"); } screen_buffer = "copy "; strcat(screen_buffer,toes_msg_filespec); strcat(screen_buffer," "); strcat(screen_buffer,_down_dir); strcat(screen_buffer,date_name); if (kount < 10) strcat(screen_buffer,"0"); itos(kount,search); strcat(screen_buffer,search); strcat(screen_buffer,".OPX"); copy_error = dos(screen_buffer,0); search = date_name; strcat(search,".LOG"); file_handle = fopen(search,"a"); fputs("",file_handle); fputs("*********************************************",file_handle); // test for not enough memory if (copy_error == -1) { fputs("Can't run a DOS shell to copy the backup file",file_handle); fputs("Either there isn't enough memory, OR command.com",file_handle); fputs("can't be found.",file_handle); } else fputs("Date named backup made successfully ....",file_handle); fputs("*********************************************",file_handle); fputs("",file_handle); fclose(file_handle); } } } } track_free(0); // Free up the tracking } // end function toes_go //////////////////////////////////////////////////////////////////////////// goodbye_fido() // This is the Clean Exit From Fido // Procedure { if (waitfor("Disconnect [Y,n,?=help]?",20)) { cputs("^M"); // Disconnect if (waitfor("Leave a note to Dave Pedler [y,N,?=help]?",20)) { cputs("^M"); // You don't want to talk to Dave do you? delay_scr(60); // If you are not getting the whole logoff // message, increase this value in 1/10ths // of a second, and vice versa. return(1); } else goto gone; } else goto gone; gone: { hangup(); exittelix(0,1); } } // end function goodbye_fido //////////////////////////////////////////////////////////////////////////// set_date_name() // function to read date and set variable date_name in YYMMDD format { str dat[4]; // temp to hold dates int temp; // Temp variable to hold the numeric date value temp = curtime(); itos(tyear(temp),dat); strcat (date_name,dat); delchrs(date_name,0,2); // remove the century digits itos(tmonth(temp),dat); if (tmonth(temp) < 10) // precede 1 to 9 with 0 strcat(date_name,"0"); strcat (date_name,dat); itos(tday(temp),dat); if (tday(temp) < 10) // precede 1 to 9 with 0 strcat(date_name,"0"); strcat (date_name,dat); } // end set_date_name //////////////////////////////////////////////////////////////////////////// get_config() // check for and read the config file. If none exists, create it // using the defaults, and allow editing { if (filefind("TOES.CNF",3,buffer) != 0) { // it exists, so read it // if it doesn't exist, return to main. set_config will create it file_handle = fopen("TOES.CNF","r"); // get value for colour screen buffer = ""; if (fgets(buffer,3,file_handle) == -1) { fclose(file_handle); panic(); } strupper(buffer); if (buffer == "Y" || buffer =="N") my_screen_shows_color = buffer; // get value for dial string buffer = ""; if (fgets(buffer,80,file_handle) == -1) { fclose(file_handle); panic(); } strupper(buffer); dial_str = buffer; // how do I check this ? I think that's the user's responsibility // get value for user_name buffer = ""; if (fgets(buffer,80,file_handle) == -1) { fclose(file_handle); panic(); } strupper(buffer); user_name = buffer; // strcat(user_name,";y"); - only necessary for TOES itself // get value for toes_msg_file buffer = ""; if (fgets(buffer,80,file_handle) == -1) { fclose(file_handle); panic(); } strupper(buffer); toes_msg_file = buffer; // get value for toes_rep_file buffer = ""; if (fgets(buffer,80,file_handle) == -1) { fclose(file_handle); panic(); } strupper(buffer); toes_rep_file = buffer; // get value for my_reply_dir buffer = ""; if (fgets(buffer,80,file_handle) == -1) { fclose(file_handle); panic(); } strupper(buffer); my_reply_dir = buffer; // get value for my_mail_dir buffer = ""; if (fgets(buffer,80,file_handle) == -1) { fclose(file_handle); panic(); } strupper(buffer); my_mail_dir = buffer; // get value for make_date_packet buffer = ""; if (fgets(buffer,3,file_handle) == -1) { fclose(file_handle); panic(); } strupper(buffer); if (buffer == "Y" || buffer == "N") make_date_packet = buffer; // get value for zmodem_protocol buffer = ""; if (fgets(buffer,3,file_handle) == -1) { fclose(file_handle); panic(); } strupper(buffer); if (buffer == "I" || buffer == "D" || buffer == "P") zmodem_protocol = buffer; // get value for auto_zap_opx buffer = ""; if (fgets(buffer,3,file_handle) == -1) { fclose(file_handle); panic(); } strupper(buffer); if (buffer == "Y" || buffer == "N") auto_zap_opx = buffer; // get value for i_send_password buffer = ""; if (fgets(buffer,3,file_handle) == -1) { fclose(file_handle); panic(); } strupper(buffer); if (buffer == "Y" || buffer == "N") i_send_password = buffer; // get value for user_password buffer = ""; if (fgets(buffer,53,file_handle) == -1) { fclose(file_handle); panic(); } strupper(buffer); user_password = buffer; fclose(file_handle); } else { clear_scr(); prints("There is a problem ! The configuration file TOES.CNF does not"); prints("exist. Please enter all relevant details when the configuration"); prints("script is activated."); delay(50); call("TOES_CFG"); if (filefind("TOES.CNF",3,buffer) != 0) get_config(); else panic(); } } // end function get_config //////////////////////////////////////////////////////////////////////////// panic() { // panic exit from get_config - due to corrupt file etc. prints("PANIC exit from TOES script attempting to read the config file"); prints(" TOES.CNF. Something is wrong ! The file is corrupt, or otherwise"); prints(" inaccessible. If it exists, try deleting it. This script will "); prints(" automatically recreate it. If that fails, try viewing it. It "); prints(" should appear in the format shown below :"); prints("N"); prints("1 2"); prints("Jan Pierewiet"); prints("GCOBBS.OPX"); prints("GCOBBS.REP"); prints("C:\XPRESS\REPLY\"); prints("C:\XPRESS\MAIL\"); prints("N"); prints("I"); prints("Y"); prints("N"); prints("Choose_a_password:-50_chars"); prints(""); prints(" If errors persist - please contact Allan Marillier at 5:491/1"); delay(150); fclose(file_handle); exittelix(); } // end function panic //////////////////////////////////////////////////////////////////////////// send_req() // function to check for a request file, read and act on it's contents { int transferring = 0; int bat_handle; // turn auto zmodem transfers back on if Internal Zmodem is used // because it's needed for up/downloads if (zmodem_protocol == "I") _zmod_auto = 1; // reset the upload and download directories _up_dir = cnf_up_dir; _down_dir = cnf_down_dir; if (filefind("TOES.REQ",2) != 0) // check if the file exists { file_handle = fopen("TOES.REQ","r"); // open it and get file handle prompt = "Select:"; buffer = ""; while (buffer != "$FINISHED$") // loop until end of file { if (transferring) { waitfor(prompt,36000); transferring = 0; } else waitfor(prompt,3600); fgets(buffer,80,file_handle); // read the file for request fgets(prompt,80,file_handle); // read again for expected prompt if (buffer != "$FINISHED$") // loop until end of file { if (strpos(buffer,"$FILE_",0) == 0) // file transfer request - activate with relevant protocol { transferring = 1; // now find, is it an upload/download, and which protocol ? if (strpos(buffer,"SEND$",0) == 6) // send a file { delchrs(buffer,0,12); // remove "$FILE_SEND$ " if (subchr(buffer,0) == 'Z' && zmodem_protocol != "I") // Zmodem transfer, NOT internal { delchrs(buffer,0,2); // strip protocol + blank // normal call to dos can't pass parameters // therefore, we must create a batch file with the necessary // commands, to be called directly bat_handle = fopen("TOESTEMP.BAT","w"); if (zmodem_protocol == "D") // DSZ { search = "dsz handshake both port "; itos(get_port(),small); strcat(search,small); strcat(search," speed "); itos(get_baud(),small); strcat(search,small); strcat(search," sz "); strcat(search,buffer); fputs(search,bat_handle); } else // PCZ { search = "pcz "; itos(get_port(),small); strcat(search,small); strcat(search," "); itos(get_baud(),small); strcat(search,small); strcat(search," sz "); strcat(search,buffer); fputs(search,bat_handle); } fclose(bat_handle); dos("TOESTEMP.BAT",0); fdelete("TOESTEMP.BAT"); if (zmodem_protocol == "P") delay(50); // delay 5 seconds after a PCZ transfer, as it // appears to be a bit slow in returning } else // ANY other INTERNAL transfer { copychrs(buffer,small,0,1); // get protocol out delchrs(buffer,0,2); // strip protocol + blank ctoi(); // convert protocol to int send(protocol,buffer); // activate telix transfer } continue; } // end if SEND else // receive a file { delchrs(buffer,0,15); // remove "$FILE_RECEIVE$ " if (subchr(buffer,0) == 'Z' && zmodem_protocol != "I") // Zmodem transfer, NOT internal { delchrs(buffer,0,2); // strip protocol + blank // normal call to dos can't pass parameters // therefore, we must create a batch file with the necessary // commands, to be called directly bat_handle = fopen("TOESTEMP.BAT","w"); if (zmodem_protocol == "D") // DSZ { search = "dsz handshake both port "; itos(get_port(),small); strcat(search,small); strcat(search," speed "); itos(get_baud(),small); strcat(search,small); strcat(search," rz "); strcat(search,_down_dir); strcat(search," "); strcat(search,buffer); // not necessary on receive fputs(search,bat_handle); } else // PCZ { search = "pcz "; itos(get_port(),small); strcat(search,small); strcat(search," "); itos(get_baud(),small); strcat(search,small); strcat(search," rz "); strcat(search,_down_dir); strcat(search," "); strcat(search,buffer); // not necessary on receive fputs(search,bat_handle); } fclose(bat_handle); dos("TOESTEMP.BAT",0); fdelete("TOESTEMP.BAT"); if (zmodem_protocol == "P") delay(50); // delay 5 seconds after a PCZ transfer, as it // appears to be a bit slow in returning continue; } else // ANY other INTERNAL transfer { copychrs(buffer,small,0,1); // get protocol out delchrs(buffer,0,2); // strip protocol + blank ctoi(); // convert protocol to int receive(protocol,buffer); // activate telix transfer } } // end if RECEIVE } // end if file transfer request else { if (buffer == "$ENTER$") { cputs("^M"); } else // normal request - send to BBS as a string { cputs(buffer); // if not eof, then send string to BBS cputs("^M"); } // end if normal request } // end if other than file transfer } // end test for not end of file } // end while not eof fdelete("TOES.REQ"); // now tidy up by deleting the request file } // end if TOES.REQ file exists } // end function send_req //////////////////////////////////////////////////////////////////////////// ctoi() // crude function to convert a character to an integer (ASCII) equivalent { if (small == "A") protocol = 'A'; if (small == "B") protocol = 'B'; if (small == "C") protocol = 'C'; if (small == "D") protocol = 'D'; if (small == "E") protocol = 'E'; if (small == "F") protocol = 'F'; if (small == "G") protocol = 'G'; if (small == "H") protocol = 'H'; if (small == "I") protocol = 'I'; if (small == "J") protocol = 'J'; if (small == "K") protocol = 'K'; if (small == "L") protocol = 'L'; if (small == "M") protocol = 'M'; if (small == "N") protocol = 'N'; if (small == "O") protocol = 'O'; if (small == "P") protocol = 'P'; if (small == "Q") protocol = 'Q'; if (small == "R") protocol = 'R'; if (small == "S") protocol = 'S'; if (small == "T") protocol = 'T'; if (small == "U") protocol = 'U'; if (small == "V") protocol = 'V'; if (small == "W") protocol = 'W'; if (small == "X") protocol = 'X'; if (small == "Y") protocol = 'Y'; if (small == "Z") protocol = 'Z'; } // end function ctoi ////////////////////////////////////////////////////////////////////////////