home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-01-30 | 137.1 KB | 4,020 lines |
- ///////////////////////////////////////////////////////////////////////////////
- // //
- // H O S T B B S . S L T //
- // //
- // original source code: HOST.SLT of Telix package //
- // //
- // Commented, modified and enhanced by Chester H. Lin with Telix 3.10 in //
- // September - October, 1989 //
- // //
- // Revised after the release of Telix 3.12 by Chester H. Lin in //
- // January, 1990 //
- // //
- ///////////////////////////////////////////////////////////////////////////////
-
- //-----------------------------------------------------------------------------
- // Parameters which can be configured by sysop
- //-----------------------------------------------------------------------------
- str sysop_password[] = "dummy_1", // The Sysop's password
- shellpass[] = "dummy_2", // the password to Reset & enter DOS shell
- host_downloads[] = "C:\BBSFILES\", // where users may download from
- host_uploads[] = "C:\BBSUPLDS\", // where uploaded files go
- host_message[] = "C:\BBSMSG\", // where messages are stored
- temp_message[] = "C:\TEMP.MSG", // temporary file for message storage
- user_list[] = "USERLIST.TXT", // user list of the system
- bulletin_title[] = "BLTN.MSG", // title screen for bulletins
- tty_bulletin_title[] = "BLTN.TTY",
- knowledge_title[] = "KNLG.MSG", // title screen for knowledge
- tty_knowledge_title[] = "KNLG.TTY",
- logo_file[] = "LOGO.MSG", // BBS logo file name
- tty_logo_file[] = "LOGO.TTY",
- welcome_file[] = "WELCOME.MSG", // Initial welcome screen file
- tty_welcome_file[] = "WELCOME.TTY",
- question_file[] = "QUESTION.MSG", // greeting for first time user
- tty_question_file[] = "QUESTION.TTY",
- goodbye_file[] = "TLXBYE.MSG", // Good bye screen file
- tty_goodbye_file[] = "TLXBYE.TTY",
- help_file[] = "HELP.MSG", // Help display
- tty_help_file[] = "HELP.TTY",
- testansi_file[] = "ASKANSI.TXT", // File to ask for ANSI mode
- logon_file[] = "HOSTBBS.LOG", // Logon record file
- logon_list[] = "LOGON.LST", // Logon user list file
- capfname[] = "HOSTBBS.CAP", // capture file name
- file_list[] = "FILES.DIR", // file listing for files
- fst_lst_msg[] = "FSTLAST.MSG", // first_last message file
- sysop_first[] = "dummy_3", // sysop's first
- sysop_last[] = "dummy_4"; // and last name
-
- //-----------------------------------------------------------------------------
- // The following variables hold current user's personal data
- //-----------------------------------------------------------------------------
- str user_password[23], // user's password
- user_age[4], // user's age
- user_phone[20], // user's phone number
- user_occupation[40], // user's occupation
- user_location[40], // user's location
- current_caller_first[23], // current caller's first name
- current_caller_last[23], // current caller's last name
- current_caller_full[50]; // current caller's full name
-
-
- //-----------------------------------------------------------------------------
- // Default settings of this host BBS
- // For direct computer-to-computer linkage: direct_connect = 1
- // For modem-to-modem linkage through phone line: direct_connect = 0
- // Default baud rate = 2400
- // Default ring count before modem picks up phone hook = 1
- //-----------------------------------------------------------------------------
- int direct_connect = 0,
- def_baud = 2400;
- str ring_count[] = "1",
- conn300[]= "CONNECT^M", // Modem response if linkage
- conn1200[] = "CONNECT 1200", // is established
- conn2400[] = "CONNECT 2400",
- conn9600[] = "CONNECT 9600",
- conn19200[] = "CONNECT 19200";
-
- //-----------------------------------------------------------------------------
- // The following variables are used as temporary storage for message processing
- //-----------------------------------------------------------------------------
- str name_to_reply[50], // name to reply
- topic_to_reply[40], // topic of a reply message
- tmp_fname[64], // used as temporary file name
- linemsg[81], // line buffer of message
- editline[81], // line to edit
- msg_caller_first[23],
- msg_caller_last[23],
- receiver[40],
- topic[40],
- date_str[10],
- time_str[10];
-
- //-----------------------------------------------------------------------------
- // The following variables hold file names of bulletin message files
- //-----------------------------------------------------------------------------
- str bulletin_1[] = "BLTN_1.MSG", // bulletin text file names holder
- bulletin_2[] = "BLTN_2.MSG", // to add a bulletin text file, just
- bulletin_3[] = "BLTN_3.MSG", // change the corresponding string
- bulletin_4[] = "BLTN_4.MSG", // to the file name that is available.
- bulletin_5[] = "BLTN_5.MSG",
- bulletin_6[] = "BLTN_6.MSG",
- bulletin_7[] = "BLTN_7.MSG",
- bulletin_8[] = "BLTN_8.MSG",
- bulletin_9[] = "BLTN_9.MSG",
- bulletin_10[] = "BLTN_10.MSG",
- bulletin_11[] = "BLTN_11.MSG",
- bulletin_12[] = "BLTN_12.MSG",
- bulletin_13[] = "BLTN_13.MSG",
- bulletin_14[] = "BLTN_14.MSG",
- bulletin_15[] = "BLTN_15.MSG",
- bulletin_16[] = "BLTN_16.MSG",
- bulletin_17[] = "BLTN_17.MSG",
- bulletin_18[] = "BLTN_18.MSG",
- bulletin_19[] = "BLTN_19.MSG",
- bulletin_20[] = "BLTN_20.MSG";
-
- //-----------------------------------------------------------------------------
- // The following variables hold system flags indicating various conditions
- //-----------------------------------------------------------------------------
- int finished_caller = 0, // set to TRUE when must return to top
- ansi_mode = 0, // set to TRUE by user if can support ANSI
- first_time_caller = 0, // set to TRUE when caller never came before
- local_mode = 0, // set to TRUE when local test mode
- carrier_counts = 1, // TRUE if Carrier Detect (CD) line is useful
- already_connected = 0, // indicating already connected or not
- sysop_call = 0, // default: assume it is user
- exit_requested = 0, // set to TRUE if Sysop has pressed HOME
- connection_lost = 0, // set to TRUE when carrier lost
- kill_user = 0, // set to TRUE when user must be purged
- warned = 0, // 3-min warning issued flag
- abnormal_logoff = 1; // always assume abnormal logoff
-
- //-----------------------------------------------------------------------------
- // The following variables are for system's house-keeping tasks
- //-----------------------------------------------------------------------------
- int last_read, // caller's last read message#
- last_read_pos, // caller's last read pos in file
- sysop_last_read, // sysop's last read message#
- grand_timer, // grand timer controls total logon time
- start_time, // logon time
- end_time, // logoff time
- f_list, // logon list file
- logon_speed, // logon modem speed
- reply_to, // mes# to reply to
- first_msg, // first and
- last_msg; // last message's number
-
- //-----------------------------------------------------------------------------
- // The following variables are for TELIX's status before this script is called
- //-----------------------------------------------------------------------------
- int old_scr_chk_key, // storage for some system variables
- old_cisb_auto, // which we have to modify and put
- old_zmod_auto, // back to what they were when done
- old_sound;
- str old_down_dir[64],
- old_up_dir[64],
- old_ans_str[64];
-
- //-----------------------------------------------------------------------------
- // system queue holds characters received from communication port
- // (not used in this version of HOSTBBS)
- //-----------------------------------------------------------------------------
- str system_queue[240]; // system queue
- int next_queue_put = 0, // next character pos to put
- next_queue_read = -1; // next character pos to read
-
-
- //-----------------------------------------------------------------------------
- //
- // main function:
- // program starts executing here
- //
- //-----------------------------------------------------------------------------
-
- main()
-
- {
- int c, i, fhandle;
- str fmsg[81] = "", msgnbr[8];
-
- //------------------------------------------
- // check if certain directories existed
- // if not (return value == -1) then exit
- // program.
- //------------------------------------------
- if (chkdir() == -1)
- return -1;
-
- //----------------------------------------------------------
- // Don't let user abort the script when executing
- //----------------------------------------------------------
- old_scr_chk_key = _scr_chk_key;
- _scr_chk_key = 0;
-
- //----------------------------------------------------------
- // Disable CompuServe Quick B auto file transfer
- //----------------------------------------------------------
- old_cisb_auto = _cisb_auto;
- _cisb_auto = 0;
-
- //----------------------------------------------------------
- // Zmodem auto download is disabled
- //----------------------------------------------------------
- old_zmod_auto = _zmod_auto;
- _zmod_auto = 0;
-
- //----------------------------------------------------------
- // All sound is shut off
- //----------------------------------------------------------
- old_sound = _sound_on;
- _sound_on = 0;
-
- //----------------------------------------------------------
- // Set up default upload/download directory
- //----------------------------------------------------------
- old_down_dir = _down_dir;
- _down_dir = host_uploads; // these are reversed because we are now the Host
- old_up_dir = _up_dir;
- _up_dir = host_downloads; // these are reversed because we are now the Host
-
- //----------------------------------------------------------
- // Set up auto answer string for modem
- //----------------------------------------------------------
- old_ans_str = _auto_ans_str;
- _auto_ans_str = "~~~AT S0=";
- strcat(_auto_ans_str, ring_count);
- strcat(_auto_ans_str, "^M~~~");
-
- //----------------------------------------------------------
- // set up communication parameters
- //----------------------------------------------------------
- if (direct_connect) // direct connect with another computer
- carrier_counts = 0; // so we don't care about carrier detect line
- else { // connect through a modem
- carrier_counts = 1; // so we must watch for carrier detect line
- if (carrier()) { // modem connection is established !!!
- already_connected = 1; // so remember it and set to fastest mode
- set_cparams(def_baud, get_parity(), get_datab(), get_stopb());
- }
- else { // not yet connected through a modem...
- clear_scr(); // clear the screen and initialize the modem
- prints("Initializing modem...");
- //--------------------------------
- // set modem to the fastest mode
- // then initialize it.
- //--------------------------------
- set_cparams(def_baud, get_parity(), get_datab(), get_stopb());
- cputs_tr(_mdm_init_str);
- cputs_tr(_auto_ans_str);
- }
- }
-
- set_defprot('Z'); // Zmodem is the default file transfer protocol
- set_terminal("ANSI-BBS"); // set terminal to ANSI mode
- update_term(); // update status bar
-
- initfile(); // create temporary file for entering msg
-
- //----------------------------------------------------------
- // read in first & last message number of message area
- // also read in sysop's last read message
- //----------------------------------------------------------
- fmsg = host_message;
- strcat(fmsg, fst_lst_msg);
- fhandle = fopen(fmsg, "r");
- if (fhandle != 0){ // if open file successfully
- fgets(msgnbr, 5, fhandle); // read first and second message numbers
- first_msg = stoi(msgnbr); // then remember them.
- fgets(msgnbr, 5, fhandle); // also read in sysop's last read msg#
- last_msg = stoi(msgnbr);
- fgets(msgnbr, 5, fhandle);
- sysop_last_read = stoi(msgnbr);
- fclose(fhandle);
- }
- else{ // file open failed
- fhandle = fopen(fmsg, "w+"); // open file for writing
- msgnbr = "0^M^J"; // reset message # to zero
- fwrite(msgnbr, strlen(msgnbr), fhandle); // first msg # written
- fwrite(msgnbr, strlen(msgnbr), fhandle); // last msg # written
- fwrite(msgnbr, strlen(msgnbr), fhandle); // sysop last msg # written
- fclose(fhandle);
- }
-
- clear_scr(); // clear the screen and initialize the modem
-
- //----------------------------------------------------------
- // An endless loop unless sysop press HOME to terminate
- // it. This loop does the following three things:
- // (1) Wait for call patiently
- // (2) Deal with the call when it comes
- // (3) Back to step 1. when call terminate by user or
- // exit if this script is terminated by sysop
- //----------------------------------------------------------
- while (1)
- {
- finished_caller = kill_user = 0;
- abnormal_logoff = 1;
-
- if (direct_connect) // if direct connect with another computer
- carrier_counts = 0; // then we ignore the carrier detect line
- else // if connect through modem
- carrier_counts = 1; // then we will watch out carrier detect line
-
- update_term(); // update status bar
-
- if (!direct_connect) { // if not computer-to-computer direct connection
- printsc_trm("^M^JHost BBS Mode: Waiting for call...");
- printsc_trm("^M^J(Press HOME to exit, 'L'");
- printsc_trm(" for local test mode),^M^J");
- //---------------------------------------------------------
- // repeat until one of the following conditions happens:
- // 1) connection established by modem
- // 2) sysop invokes local test mode by pressing 'L'
- // 3) sysop aborts host by pressing 'HOME' key --> exit_requested = 1
- //---------------------------------------------------------
- do {
- if (carrier()) { // connection established
- local_mode = 0;
- break;
- }
- c = inkey(); // read a character from keyboard buffer
- if (c) { // if keypressed...
- if (c == 0x4700) { // if it is a HOME --> sysop aborts host
- exit_requested = 1;
- break;
- }
- else if (toupper(c) == 'L') { // L --> local test mode
- prints("Local test mode entered");
- local_mode = 1;
- carrier_counts = 0;
- }
- } // if keypressed
- } while (toupper(c) != 'L');
- } // if not direct connect
-
- //--------------------------------------------------------------
- // if sysop did not abort HOST by pressing HOME key
- //--------------------------------------------------------------
- if (!exit_requested) {
- printsc("Incoming call. Sysop: ");
- printsc_trm("press HOME to exit, ");
- printsc_trm("or END to terminate user.");
- prints("");
-
- do_one_caller();
-
- //----------------------------------------------------------
- // adding a record to the user logon list file
- // (users only, not for sysop's call)
- //----------------------------------------------------------
- if (!sysop_call) {
- end_time = curtime();
- f_list = fopen(logon_list, "r+");
- fseek(f_list, 0, 2);
-
- date(start_time, tmp_fname); // logon date
- fputs(tmp_fname, f_list);
- fputs(" ", f_list);
-
- time(start_time, tmp_fname); // logon time
- fputs(tmp_fname, f_list);
- fputs(" ", f_list);
-
- time(end_time, tmp_fname); // logoff time
- fputs(tmp_fname, f_list);
- fputs(" ", f_list);
-
- itos(logon_speed, tmp_fname); // logon speed
- fputs(tmp_fname, f_list);
- fputs(" ", f_list);
-
- if (abnormal_logoff) // goodbye method
- fputc('*', f_list); // Abnormal
- else
- fputc(' ', f_list); // Normal
- fputs(" ", f_list);
-
- if (ansi_mode) // record user's mode
- fputs("ANSI ", f_list);
- else
- fputs(" TTY ", f_list);
-
- fputs(current_caller_full, f_list); // caller's name
- fputs("^M^J", f_list);
-
- fclose(f_list);
- } // if not sysop calling...
-
- current_caller_first = "";
- current_caller_last = "";
- current_caller_full = "";
- sysop_call = 0;
- warned = 0;
-
- //----------------------------------------------------------
- // close logon file so that everything is written down
- //----------------------------------------------------------
- if (!sysop_call)
- usagelog("*CLOSE*"); // close usage log file
-
- if ((connection_lost || kill_user) && carrier_counts && carrier()) {
- hangup(); // make sure nobody sneaks in
- set_cparams(def_baud, get_parity(), get_datab(), get_stopb());
- cputs_tr(_mdm_init_str); // then initialize modem
- }
- } // if sysop did not abort HOST by pressing HOME key
-
- already_connected = 0;
-
- if (exit_requested) { // sysop aborts host
- if (!carrier() && !direct_connect) { // if not connected
- set_cparams(def_baud, get_parity(), get_datab(), get_stopb());
- cputs_tr(_mdm_init_str); // then initialize modem
- cputs_tr(old_ans_str); // and put it back to old answer mode
- }
-
- _scr_chk_key = old_scr_chk_key; // restore all old settings
- _cisb_auto = old_cisb_auto;
- _zmod_auto = old_zmod_auto;
- _sound_on = old_sound;
- _down_dir = old_down_dir;
- _up_dir = old_up_dir;
- _auto_ans_str = old_ans_str;
-
- prints("^M^JHost BBS Mode script finished.");
- return 1; // terminate program
- } // if sysop aborts host
- } // while (an endless loop until HOME is pressed by sysop)
- } // main
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // caller is here so serve him/her
- //
- //////////////////////////////////////////////////////////////////////////////
-
- do_one_caller()
-
- {
- str strn[20], last_rd_buf[8], last_rd_str[8];
- int option, search_code, f_user,
- c, i;
-
- //----------------------------------------------------------
- // start the grand timer which controls total logon time
- // current setting = 1 hour
- //----------------------------------------------------------
- grand_timer = curtime(); // get current time
- start_time = grand_timer;
-
- if (already_connected) // If already connected then do nothing except
- prints("Already Connected!^M^J"); // informing the caller. If not already connected
- else if (carrier_counts) { // but CD line is high then try to determine the
- if (!determine_baud()) // baud rate.
- ;
- }
-
- logon_speed = get_baud();
-
- update_term(); // update status bar
-
- delay(10); // wait for one second (but why?)
-
- type_file(testansi_file); // ask if user's terminal can support ANSI
- ask_ANSI();
-
- if (ansi_mode)
- type_file(logo_file); // display the first title to the caller
- else
- type_file(tty_logo_file);
-
- flushbuf(); // discard all garbage in the remote input buffer
-
- reply_to = 0; // reset msg# to reply to
-
- if (!read_user_name()) // let user input his/her name
- return;
-
- //----------------------------------------------------------
- // open the usage log file if this is not sysop call
- //----------------------------------------------------------
- if (!sysop_call)
- usagelog(logon_file);
-
- if (!strcmpi(current_caller_first, sysop_first) &&
- !strcmpi(current_caller_last, sysop_last)) { // SysOp is calling!!!
- if (!verify_sysop()) { // verification fails! Not a sysop.
- sysop_call = 0; // so that the next caller is a user
- ustamp("User called in the name of sysop but in vain.", 1, 1);
- return; // tries to invade here as a sysop.
- }
- else { // it IS sysop here so get the last read msg#
- sysop_call = 1; // flag it!
- last_read = sysop_last_read;
- }
- }
- else { // It's other users......
- //-------------------------------------------------------------------------
- // search_code == 0 if connection lost
- // 1 if user is found
- // 2 if user is firt-time caller
- // get_access returns:
- // 0 if password is wrong
- // 1 if password is right or first-time caller
- //-------------------------------------------------------------------------
- if (!(search_code = search_user_list())) // search for user list
- return;
- if (!get_access(search_code)) // requesting for access to this board
- return; // but request is denied
- }
-
- if (ansi_mode)
- type_file(welcome_file); // welcome message for caller
- else
- type_file(tty_welcome_file);
-
- host_send("^M^JPress any key to continue...");
- host_input();
-
- showtime();
-
- //--------------------------------------------------------------------------------
- // this is an endless loop unless one of the following conditions happens:
- // 1) connection is lost for every possible reason (sysop kills user, phone
- // line drops, sysop terminate host, or user hangs phone.
- // 2) user chooses (G)oodbye option
- //--------------------------------------------------------------------------------
- while (1) {
-
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
-
- top_level_cmd(); // display top level BBS commands
-
- //---------------------------------------------------------
- // Input the option by user
- //---------------------------------------------------------
- host_input_strn(strn, 15, 0);
- option = toupper(subchr(strn, 0));
- host_send("^M^J");
-
- //---------------------------------------------------------
- // File Menu invoked
- //---------------------------------------------------------
- if (option == 'F') {
- if (!sysop_call)
- ustamp("User invoked File functions.", 1, 1);
- do {
- filecmd();
- } while (do_files() != 'Q' && !finished_caller);
- }
- //---------------------------------------------------------
- // Invoke Message functions
- //---------------------------------------------------------
- else if (option == 'M'){
- if (!sysop_call)
- ustamp("User invoked Message functions.", 1, 1);
- do_message();
- }
- //---------------------------------------------------------
- // System functions
- //---------------------------------------------------------
- else if (option == 'S'){
- if (!sysop_call)
- ustamp("User invoked System functions.", 1, 1);
- do_system();
- }
- //---------------------------------------------------------
- // Bulletins
- //---------------------------------------------------------
- else if (option == 'B'){
- if (!sysop_call)
- ustamp("User invoked Bulletin functions.", 1, 1);
- do_bulletin();
- }
- //---------------------------------------------------------
- //Help screen
- //---------------------------------------------------------
- else if (option == 'H'){
- if (!sysop_call)
- ustamp("User looked at help screen.", 1, 1);
- if (ansi_mode)
- type_file(help_file);
- else
- type_file(tty_help_file);
- host_send("Press any key to continue...");
- host_input();
- if (ansi_mode)
- host_send("^M");
- else
- host_send("^M^J");
- }
- //---------------------------------------------------------
- // Say Goodbye
- //---------------------------------------------------------
- else if (option == 'G') { // Goodbye (Hang-up)
- host_send("^M^JDo you want to disconnect? (Y/N) ");
- host_input_strn(strn, 10, 0);
- host_send("^M^J");
- if (toupper(subchr(strn, 0)) == 'Y') {
- if (!sysop_call) { // sysop does not have last read msg#
- itos(last_read, last_rd_buf); // convert last read msg#
- last_rd_str = ""; // to string
- for (i = 1; i <= (4 - strlen(last_rd_buf)); ++i)
- strcat(last_rd_str, " "); // padding with blanks
- strcat(last_rd_str, last_rd_buf);
- strcat(last_rd_str, "^M^J"); // now last_rd_str ready...
- f_user = fopen(user_list, "r+"); // to update last read msg#
- fseek(f_user, last_read_pos, 0); // move file pointer
- fwrite(last_rd_str, strlen(last_rd_str), f_user);
- fclose(f_user);
- }
-
- host_send("^M^JGoodbye!^M^J");
- if (ansi_mode)
- type_file(goodbye_file); // send the good-bye message
- else
- type_file(tty_goodbye_file);
- abnormal_logoff = 0; // this is a normal logoff
-
- if (!sysop_call){
- ustamp("Logged off by ", 1, 0);
- ustamp(current_caller_full, 0, 0);
- ustamp("", 0, 1);
- }
- if (carrier_counts)
- {
- //------------------------------------------------
- // delay for a whie to let good-bye message be
- // transmitted over modem before hanging up
- //------------------------------------------------
- if (get_baud() == 300) // 300 bps --> wait for 20 seconds
- delay (200);
- else if (get_baud() == 1200) // 1200 bps --> wait for 5 seconds
- delay (50);
- else if (get_baud() == 2400) // 2400 bps --> wait for 2.5 seconds
- delay(25);
- hangup(); // actually hanging up
- delay(15);
- prints("^M^JReset modem...");
- set_cparams(def_baud, get_parity(), get_datab(), get_stopb());
- cputs_tr(_mdm_init_str);
- }
- return;
- } // if confirmed to disconnect
- }
- } // while... endless loop
- } // do_one_caller
-
- //////////////////////////////////////////////////////////////////////////////
- // do_files
- // return value: 'L', `T', 'D', 'U' if one of them selected
- // return value: 'Q' if 'Q' selected
- //////////////////////////////////////////////////////////////////////////////
-
- do_files()
-
- {
- str strn[80], fname[80];
- int status, option;
-
- host_input_strn(strn, 10, 0);
- if (strlen(strn) == 0) { // if only RET pressed
- host_send("^M^J"); // return L to repeat command
- return 'L';
- }
- option = toupper(subchr(strn, 0));
- host_send("^M^J");
-
- //----------------------------------------
- // List files
- //----------------------------------------
- if (option == 'L') {
- if (!sysop_call)
- ustamp("User invoked Listing files functions.", 1, 1);
- if (sysop_call) { // this is a sysop here!
- // no limit to files can be seen
- host_send("Enter 'filespec' or press Return for *.*,^M^J: ");
- host_input_strn(fname, 64, 0);
- host_send("^M^J");
- if (just_filename(fname)) { // if fname is just a file name
- strn = host_downloads; // then look for download area
- strcat(strn, fname); // else look for the specified path
- }
- else // not just a file name (a path...)
- strn = fname; // so make no assumption about path
- }
- else // lower access level, i.e. user
- fname = ""; // empty string means detailed file info
-
- if (strlen(fname) == 0) // if only <RET> is hit
- type_file(file_list); // then display detailed file info
- else{ // else invoke DOS dir type info
- if (local_mode)
- show_directory(strn, 0, carrier_counts); // listing only on screen
- else
- show_directory(strn, 1, carrier_counts); // listing on screen & through modem
- }
- if (ansi_mode)
- host_send("^M");
- else
- host_send("^M^J");
- return 'L';
- }
- //----------------------------------------
- // Type a file
- //----------------------------------------
- else if (option == 'T') {
- host_send("Type what file? ");
- host_input_strn(strn, 64, 0);
- host_send("^M^J");
- if (!sysop_call) // sysop --> full path name allowed
- fnstrip(strn, 3, fname); // user --> only file name & extension
- else
- fname = strn; // typing all related data
- if (just_filename(fname)) { // if fname is just a file name
- strn = host_downloads; // then look for download directory
- strcat(strn, fname);
- fname = strn;
- }
- if (!filefind(fname, 0, strn)) { // file specified can't be found
- host_send("Unable to find ");
- host_send(fname);
- host_send("^M^J");
- }
- else {
- type_file(fname);
- if (!sysop_call){
- ustamp("User Typed file ", 1, 0);
- ustamp(fname, 0, 1);
- }
- }
- if (ansi_mode)
- host_send("^M");
- else
- host_send("^M^J");
- return 'T';
- }
- //----------------------------------------
- // Upload file(s)
- //----------------------------------------
- else if (option == 'U') {
- option = host_get_prot("<Upload>"); // get the protocol used
- if (!option) // if no protocol specified
- return 'U'; // abort uploading
- status = 1;
- if (option == 'T' || option == 'M' || option == 'S' || // auto_receive
- option == 'Y' || option == 'Z' || option == 'E') {
- send_transfer_msg();
- status = receive(option, "");
- }
- else {
- host_send("Upload what file? ");
- host_input_strn(strn, 48, 0);
- host_send("^M^J");
- if (!strn)
- return 'U';
- if (!sysop_call) // if ordinary user only file name & ext allowed
- fnstrip(strn, 3, fname);
- else
- fname = strn; // sysop: any disk drive and path
-
- if (just_filename(fname)) { // only file name in fname, so
- strn = host_uploads; // default is host_uploads
- strcat(strn, fname);
- fname = strn;
- }
-
- if (filefind(fname, 23, strn))
- host_send("File already exists!^M^J");
- else {
- send_transfer_msg();
- status = receive(option, fname);
- }
- }
- if (status == -2) // Carrier lost
- connection_lost = finished_caller = 1;
- else if (status == -1) // File(s) not received.
- host_send("^GOne or more files not received by HOST BBS!^M^J");
- else
- host_send("Uploading succeeds.^M^J");
- return 'U';
- }
- //----------------------------------------
- // Download file(s)
- //----------------------------------------
- else if (option == 'D') {
- option = host_get_prot("<Download>");
- if (!option)
- return 'D';
- host_send("Download what file(s)? ");
- host_input_strn(strn, 48, 0);
- host_send("^M^J");
- if (!strn)
- return 'D';
- if (!sysop_call) // if not sysop, keep only name & ext
- fnstrip(strn, 3, fname);
- else
- fname = strn;
-
- if (just_filename(fname)) {
- strn = host_downloads;
- strcat(strn, fname);
- fname = strn;
- }
-
- if (!filefind(fname, 0, strn)) {
- host_send("Unable to find any matching file(s)!^M^J");
- return 'D';
- }
-
- status = 1;
- send_transfer_msg();
- status = send(option, fname);
- if (status == -2) // Carrier lost
- connection_lost = finished_caller = 1;
- else if (status == -1)
- host_send("^GOne or more files not received by user!^M^J");
- else
- host_send("Downloading succeeds.^M^J");
- return 'D';
- }
- //----------------------------------------
- // Quit file menu
- //----------------------------------------
- else if (option == 'Q') {
- host_send("^M^J");
- return 'Q';
- }
- } // do files
-
- //////////////////////////////////////////////////////////////////////////////
- // do_system
- //////////////////////////////////////////////////////////////////////////////
-
- do_system()
-
- {
- str strn[20];
- int c, i, j, option = 'A', used_time;
-
- do {
- syscmd(); // display system commands
- host_input_strn(strn, 10, 0); // then get input
- if (strlen(strn) == 0) // if only RET pressed then add one
- host_send("^M^J"); // blank line to advance the output
- option = toupper(subchr(strn, 0));
- host_send("^M^J");
- //----------------------------------------
- // Page SysOp
- // Asking for a chat. Sysop may press F1
- // in order to enter the chat mode.
- //----------------------------------------
- if (option == 'P') {
- printsc_trm("^M^JSysop: Press F1 to chat, any other key not to.^M^J");
- c = 0; // initialize keyboard input as 0
- _sound_on = 1; // turn on speaker!
- for (i = 8; i && !c; --i) { // at most 8 beeps to page sysop
- if (carrier_counts && !carrier()) {
- prints("^M^JConnection has been lost, call terminated.^M^J");
- connection_lost = 1;
- finished_caller = 1;
- break;
- }
- cputc('^G'); // send 'BEEP' to comm port
- tone(523, 20); tone(659, 20); // making sound alerting sysop...
- tone(523, 20); tone(659, 20);
- tone(523, 20); tone(659, 20);
- for (j = 30; j && (c = inkey()) == 0; --j) // checks kbd input for 30 times most
- delay(1); // pause for 1/10 second doing nothing
- }
- _sound_on = 0; // turn off speaker...
- if (finished_caller)
- continue;
- if (c != 0x3b00 || !c) { // if response is not F1 or no response
- host_send("^M^JSorry, the Sysop is unavailable^M^J^M^J");
- if (!sysop_call)
- ustamp("User paged Sysop ... but in vain.", 1, 1);
- continue;
- }
- if (!sysop_call)
- ustamp("User paged Sysop and they started chating.", 1, 1);
- used_time = curtime() - grand_timer;
- call("chatmode", local_mode, carrier_counts, capfname);
- grand_timer = curtime() - used_time;
- if (!sysop_call)
- ustamp("Chat ended.", 1, 1);
- }
- //----------------------------------------
- // Logon User List
- //----------------------------------------
- if (option == 'L') {
- if (!sysop_call)
- ustamp("User reviewed user logon list.", 1, 1);
- if (ansi_mode)
- host_send("");
- else
- host_send("^M^J");
- disp_bar(77);
- host_send("^M^JDate Logon Logoff Speed Mode Name^M^J");
- disp_bar(77);
- type_file(logon_list);
- }
- //----------------------------------------
- // Reset computer
- // execute RESET.COM. This program just
- // jumps to ROM BIOS's reset routine
- //----------------------------------------
- else if (option == 'R') {
- if (sysop_call) { // If this call is from sysop
- if (ask_for_pass(3, shellpass) != 0) // still asking for password
- run("RESET", "", 0); // reset computer!!!
- }
- else {
- if (ansi_mode)
- host_send("^M^J^G^GOnly SysOp The Great can reset the computer!^M^J");
- else
- host_send("^M^J^G^GOnly SysOp The Great can reset the computer!^M^J");
- if (!sysop_call)
- ustamp("User tried to reset the computer.", 1, 1);
- }
- }
- //------------------------------------------------------
- // Shell to DOS: two versions, use only one of them.
- // Comment out one version while using another version.
- // Distributed package uses the original version
- //------------------------------------------------------
- else if (option == 'S') {
- if (sysop_call) {
- if (get_port() != 1 && get_port() != 2) { // comm port must be 1 or 2
- host_send("Remote Shell not supported on this comm port due to DOS limits!^M^J");
- continue;
- }
- if (ask_for_pass(3, shellpass) != 0) { // asking for password
-
- //----------------------------------------------------------
- //
- // You may use the following line of code instead of the
- // original one. Using Doorway makes HOSTBBS a more
- // robust system by preventing system lock up if phone
- // line dropped suddenly during DOS shell. You must
- // register to the author of Doorway before you can use
- // that program in your own BBS.
- //
- // COM1 -- use COM1: in Doorway
- // /K:0 -- keyboard timeout is disabled
- // /M:180 -- allow for 180 minutes door time
- // /L: -- add line feed when cursor is at the bottom of
- // the screen
- // /C: -- drop to DOS is desired
- //
- // You may change second parameter listing to change
- // Doorway's behavior when dropping to DOS.
- //
- //----------------------------------------------------------
- // Beginning of DOORWAY version of DOS shell
- //----------------------------------------------------------
-
- // run("DOORWAY", "COM1 /K:0 /M:180 /B:MSZ /L: /J: /C:DOS", 0);
-
- //----------------------------------------------------------
- // Ending of DOORWAY version of DOS shell
- //----------------------------------------------------------
-
- //----------------------------------------------------------
- //
- // Using the following lines of code is like CTTY COM
- // function of DOS. System will be locked up if phone line
- // dropped suddenly during DOS shell.
- //
- //----------------------------------------------------------
- // Beginning of original version of DOS shell
- //----------------------------------------------------------
-
- host_send("^M^JType EXIT and then press Return to come back.^M^J");
- if (get_baud() == 300)
- delay(10);
- strn = "COM";
- setchr(strn, 3, get_port() + '0'); // get right device name for redirect
- if (!local_mode)
- if (redirect_dos(strn) == -1) // redirect DOS input and output
- continue;
- dos("", 0); // actually call the shell
- if (!local_mode) // very important to put things
- redirect_dos(""); // back to norm
-
- //----------------------------------------------------------
- // Ending of original version of DOS shell
- //----------------------------------------------------------
- } // asking for shell password
- } // if caller is sysop....
- else {
- if (ansi_mode)
- host_send("^M^J^G^GOnly SysOp The Great can shell to DOS!^M^J");
- else
- host_send("^M^J^G^GOnly SysOp The Great can shell to DOS!^M^J");
- if (!sysop_call)
- ustamp("User tried to enter DOS shell.", 1, 1);
- }
- } // shell to DOS
- //----------------------------------------
- // Ask for ANSI mode
- //----------------------------------------
- else if (option == 'A') {
- ask_ANSI();
- } // ask for ANSI mode
- } while (option != 'Q' && !finished_caller);
- } // do system
-
- //////////////////////////////////////////////////////////////////////////////
- // do_bulletin
- //////////////////////////////////////////////////////////////////////////////
-
- do_bulletin ()
-
- {
- str bltn_str[15];
- int bltn_nbr;
-
- do {
- if (ansi_mode)
- type_file (bulletin_title);
- else
- type_file (tty_bulletin_title);
- host_send("^M^J Enter desired bulletin number: ");
- host_input_strn(bltn_str, 10, 0);
- if (strlen(bltn_str) == 0) {
- host_send("^M^J^M^J");
- break;
- }
- bltn_nbr = stoi(bltn_str);
- if (bltn_nbr <= 20 && bltn_nbr >= 1){
- if (!sysop_call) {
- ustamp("User reviewed bulletin# ", 1, 0);
- ustamp(bltn_str, 0, 1);
- }
- if (ansi_mode)
- host_send(""); // clear screen before show bulletin
- else
- host_send("^M^J");
- if (bltn_nbr == 1)
- type_file(bulletin_1);
- else if (bltn_nbr == 2)
- type_file(bulletin_2);
- else if (bltn_nbr == 3)
- type_file(bulletin_3);
- else if (bltn_nbr == 4)
- type_file(bulletin_4);
- else if (bltn_nbr == 5)
- type_file(bulletin_5);
- else if (bltn_nbr == 6)
- type_file(bulletin_6);
- else if (bltn_nbr == 7)
- type_file(bulletin_7);
- else if (bltn_nbr == 8)
- type_file(bulletin_8);
- else if (bltn_nbr == 9)
- type_file(bulletin_9);
- else if (bltn_nbr == 10)
- type_file(bulletin_10);
- else if (bltn_nbr == 11)
- type_file(bulletin_11);
- else if (bltn_nbr == 12)
- type_file(bulletin_12);
- else if (bltn_nbr == 13)
- type_file(bulletin_13);
- else if (bltn_nbr == 14)
- type_file(bulletin_14);
- else if (bltn_nbr == 15)
- type_file(bulletin_15);
- else if (bltn_nbr == 16)
- type_file(bulletin_16);
- else if (bltn_nbr == 17)
- type_file(bulletin_17);
- else if (bltn_nbr == 18)
- type_file(bulletin_18);
- else if (bltn_nbr == 19)
- type_file(bulletin_19);
- else if (bltn_nbr == 20)
- type_file(bulletin_20);
- host_send("Press any key to continue...");
- host_input();
- host_send("^M^J");
- } // if bulletin number entered is valid
- } while (1);
- } // do bulletin
-
-
- //////////////////////////////////////////////////////////////////////////////
- // read user's name
- // return value = 0 if aborted (timeout or disconnected)
- // return value = 1 if successful in reading user's name
- //////////////////////////////////////////////////////////////////////////////
-
- read_user_name()
-
- {
- int i, j;
- str answer[15];
-
- do {
-
- //--------------------------------------------
- // ask user to enter his/her first name
- // if name length is zero, repeat the process
- //--------------------------------------------
- do {
- host_send("^M^Jyour FIRST name: ");
- host_input_strn(current_caller_first, 20, 0);
- if (finished_caller)
- return 0;
- } while (strlen(current_caller_first) == 0);
-
- //--------------------------------------------
- // ask user to enter his/her last name
- // if name length is zero, repeat the process
- //--------------------------------------------
- do {
- host_send("^M^Jand your LAST name: ");
- host_input_strn(current_caller_last, 20, 0);
- host_send("^M^J");
- if (finished_caller)
- return 0;
- } while (strlen(current_caller_last) == 0);
-
- //--------------------------------------------
- // set all other char to lower case and
- // replace blank " " with underline "_"
-
- strlower(current_caller_first);
- j = strlen(current_caller_first);
- for (i = 0; i < j; ++i)
- if (subchr(current_caller_first, i) == ' ')
- setchr(current_caller_first, i, '_');
-
- strlower(current_caller_last);
- j = strlen(current_caller_last);
- for (i = 0; i < j; ++i)
- if (subchr(current_caller_last, i) == ' ')
- setchr(current_caller_last, i, '_');
-
- //--------------------------------------------
- // set first char to upper case letter
-
- setchr(current_caller_first, 0, toupper(subchr(current_caller_first, 0)));
- setchr(current_caller_last, 0, toupper(subchr(current_caller_last, 0)));
-
- if (ansi_mode) {
- host_send("^M^JIs your name ");
- host_send(current_caller_first);
- host_send(" ");
- host_send(current_caller_last);
- host_send("");
- }
- else {
- host_send("^M^JIs your name ");
- host_send(current_caller_first);
- host_send(" ");
- host_send(current_caller_last);
- }
- host_send(" ? (Y/N) ");
-
- host_input_strn(answer, 10, 0);
- host_send("^M^J");
-
- //----------------------------------------------------------
- // if caller's name is confirmed by caller then combine it
- // into full name
- //----------------------------------------------------------
- if (subchr(answer, 0) == 'y' || subchr(answer, 0) == 'Y') {
- host_send("^M^J");
- current_caller_full = "";
- strcat(current_caller_full, current_caller_first);
- strcat(current_caller_full, " ");
- strcat(current_caller_full, current_caller_last);
- return 1;
- }
- } while (1);
-
- } // read_user_name
-
- //////////////////////////////////////////////////////////////////////////////
- // search user's name list
- // return value = 0 if aborted (timeout or disconnected)
- // return value = 1 if successful in reading user's name
- // return value = 2 if first time user has entered his/her data
- //////////////////////////////////////////////////////////////////////////////
-
- search_user_list()
-
- {
- int i, f_user, user_found = 0, logon_count, file_pos;
- str user_name[50], name_buf[35], age_buf[10], occupation_buf[45],
- location_buf[25], phone_buf[25], password_buf[25], dummy[25];
- str logon_str[8], logon_buf[8], last_rd_buf[8], last_rd_str[8];
- str answer[5];
-
- user_name = current_caller_full;
-
- f_user = fopen(user_list, "a+"); // open user list file for reading
- // create file if it doesn't exist
- fseek (f_user, 0, 0); // move pointer to the beginning
-
- while (!feof(f_user) && !user_found){
- fgets(name_buf, 31, f_user); // read in user's name
- fgets(age_buf, 5, f_user); // read in user's age
- fgets(occupation_buf, 40, f_user); // read in user's occupation
- fgets(location_buf, 20, f_user); // read in user's place
- fgets(phone_buf, 15, f_user); // read in user's phone number
- fgets(password_buf, 20, f_user); // read in user's password
- file_pos = ftell(f_user); // mark where to find call times
- fgets(logon_buf, 6, f_user); // read logon times of this user
- last_read_pos = ftell(f_user); // mark where to find last read#
- fgets(last_rd_buf, 6, f_user); // read caller's last read msg
- fgets(dummy, 18, f_user); // read past empty line
- if (strcmpi(current_caller_full, name_buf) == 0){ // user found!
- user_found = 1;
- user_age = age_buf;
- user_phone = phone_buf;
- user_occupation = occupation_buf;
- user_password = password_buf;
- user_location = location_buf;
- i = 0; // record logon times
- while (subchr(logon_buf, i) == ' ')
- ++i;
- substr(logon_buf, i, 4, logon_str);
- logon_count = stoi(logon_str);
- logon_count = logon_count + 1; // and increment it
- itos(logon_count, logon_buf);
- logon_str = "";
- for (i = 1; i <= (4 - strlen(logon_buf)); ++i)
- strcat(logon_str, " ");
- strcat(logon_str, logon_buf);
- strcat(logon_str, "^M^J");
- fseek(f_user, file_pos, 0); // move file pointer
- fwrite(logon_str, strlen(logon_str), f_user);
- i = 0; // record last read msg
- while (subchr(last_rd_buf, i) == ' ')
- ++i;
- substr(last_rd_buf, i, 4, last_rd_str);
- last_read = stoi(last_rd_str); // and remember it!
- }
- } // while not the end of user list
-
- fclose(f_user); // close user list file
-
- if (user_found) { // user found
- logon_count = logon_count - 1;
- itos(logon_count, logon_buf);
- if (ansi_mode) {
- host_send("You are ");
- host_send(name_buf);
- host_send("");
- host_send(". You have called ");
- host_send(logon_buf);
- host_send(" times before this call.^M^J^M^J");
- }
- else {
- host_send("^M^JYou are ");
- host_send(name_buf);
- host_send(". You have called ");
- host_send(logon_buf);
- host_send(" times before this call.^M^J^M^J");
- }
- return 1; // and user get a return value 1
- }
- else { // user not found (new user)
- if (ansi_mode)
- host_send("Hi ");
- else
- host_send("^M^JHi ");
- host_send(current_caller_first);
- host_send(",^M^J");
- if (ansi_mode)
- type_file(question_file); // prompt user for questionaire
- else
- type_file(tty_question_file);
- do {
- host_send("^M^J your age: "); // age
- if (ansi_mode)
- host_send(""); // age
- host_input_strn(age_buf, 5, 0);
- if (ansi_mode)
- host_send("");
- if (finished_caller)
- return 0;
-
- host_send("^M^J occupation: "); // job
- if (ansi_mode)
- host_send("");
- host_input_strn(occupation_buf, 40, 0);
- if (ansi_mode)
- host_send("");
- strupper(occupation_buf);
- if (finished_caller)
- return 0;
-
- host_send("^M^J city: "); // location
- if (ansi_mode)
- host_send("");
- host_input_strn(location_buf, 20, 0);
- if (ansi_mode)
- host_send("");
- strupper(location_buf);
- if (finished_caller)
- return 0;
-
- host_send("^M^Jphone number: "); // phone number
- if (ansi_mode)
- host_send("");
- host_input_strn(phone_buf, 15, 0);
- if (ansi_mode)
- host_send("");
- strupper(location_buf);
- if (finished_caller)
- return 0;
-
- host_send("^M^Jnew password: "); // new password
- if (ansi_mode)
- host_send("");
- host_input_strn(password_buf, 20, 0);
- if (ansi_mode)
- host_send("");
- strupper(password_buf);
- if (finished_caller)
- return 0;
-
- host_send("^M^J^M^J");
- host_send(current_caller_first);
- host_send(", your personal data is:^M^J");
- host_send("^M^J age: ");
- if (ansi_mode) {
- host_send(""); host_send(age_buf); host_send("");
- host_send("^M^J occupation: ");
- host_send(""); host_send(occupation_buf); host_send("");
- host_send("^M^J city: ");
- host_send(""); host_send(location_buf); host_send("");
- host_send("^M^J phone number: ");
- host_send(""); host_send(phone_buf); host_send("");
- host_send("^M^J password: ");
- host_send(""); host_send(password_buf); host_send("");
- }
- else {
- host_send(age_buf);
- host_send("^M^J occupation: ");
- host_send(occupation_buf);
- host_send("^M^J city: ");
- host_send(location_buf);
- host_send("^M^J phone number: ");
- host_send(phone_buf);
- host_send("^M^J password: ");
- host_send(password_buf);
- }
- host_send("^M^J^M^JIs this correct (Y/N)? ");
-
- host_input_strn(answer, 4, 0);
- host_send("^M^J");
- if (subchr(answer, 0) == 'y' || subchr(answer, 0) == 'Y') {
-
- user_age = age_buf;
- user_phone = phone_buf;
- user_occupation = occupation_buf;
- user_password = password_buf;
- user_location = location_buf;
-
- host_send("^M^J");
- f_user = fopen(user_list, "a"); // open user list file for appending
- fseek(f_user, 0, 2); // move to end of file
-
- strcat(user_name, "^M^J");
- fwrite(user_name, strlen(user_name), f_user);
-
- strcat(age_buf, "^M^J");
- fwrite(age_buf, strlen(age_buf), f_user);
-
- strcat(occupation_buf, "^M^J");
- fwrite(occupation_buf, strlen(occupation_buf), f_user);
-
- strcat(location_buf, "^M^J");
- fwrite(location_buf, strlen(location_buf), f_user);
-
- strcat(phone_buf, "^M^J");
- fwrite(phone_buf, strlen(phone_buf), f_user);
-
- strcat(password_buf, "^M^J");
- fwrite(password_buf, strlen(password_buf), f_user);
-
- logon_count = 1; // first time to this board
- itos(logon_count, logon_buf);
- logon_str = " "; // add three blanks ahead
- strcat(logon_str, logon_buf); // total four positions for digits
- strcat(logon_str, "^M^J");
- fwrite(logon_str, strlen(logon_str), f_user);
-
- last_read_pos = ftell(f_user); // mark where to find last read#
- last_read = 0; // last read msg is #0
- itos(last_read, last_rd_buf);
- last_rd_str = " ";
- strcat(last_rd_str, last_rd_buf);
- strcat(last_rd_str, "^M^J");
- fwrite(last_rd_str, strlen(last_rd_str), f_user);
-
- fwrite("---------------^M^J", 17, f_user);
-
- fclose(f_user);
- return 2; // first_time user get a return value 2
- } // if
- } while (1);
- }
-
- } // search_user_list
-
- //////////////////////////////////////////////////////////////////////////////
- // get access level
- // enter with level = 2 if this is the first time user
- // all other value if not first time user
- // return value = 1 if access granted
- // 0 if access denied
- //////////////////////////////////////////////////////////////////////////////
-
- get_access(int level)
-
- {
- int access;
-
- if (level != 2) // not first time user
- access = ask_for_pass(3, user_password); // ask for user's previous password
- else
- access = 1; // first time caller is here...
-
- if (!sysop_call) {
- if (access)
- ustamp("Logon by ", 1, 0);
- else
- ustamp("Failed logon attempt by ", 1, 0);
- ustamp("", 0, 0);
- ustamp(current_caller_full, 0, 0);
- ustamp("", 0, 1);
- }
-
- if (!access) {
- host_send("Goodbye!^M^J");
- if (carrier_counts) {
- delay(10);
- hangup();
- }
- return 0; // logon fails
- }
- else
- return 1; // logon succeeds
- }
-
- //////////////////////////////////////////////////////////////////////////////
- // deal with Message functions
- //////////////////////////////////////////////////////////////////////////////
-
- do_message()
-
- {
- str strn[20];
- int option, c, i, j, k, msg_sent;
-
- while (1) {
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
-
- if (sysop_call)
- msgcmd(sysop_last_read);
- else
- msgcmd(last_read);
-
- host_input_strn(strn, 10, 0); // asking for message function
- option = toupper(subchr(strn, 0));
- host_send("^M^J");
-
- //-----------------------------------------------
- // Scan messages
- //-----------------------------------------------
- if (option == 'S'){
- if (!sysop_call)
- ustamp("User scanned messages.", 1, 1);
- reply_to = 0;
- host_send("^M^JScan from message#: ");
- host_input_strn(strn, 10, 0);
- host_send("^M^J");
- if (finished_caller)
- return;
- option = stoi(strn);
- if (option == 0) // if only <RET> pressed then
- option = first_msg; // from the first message
- msg_sent = 0;
- j = 0;
- for (i = option; i <= last_msg; ++i) {
- if (scan_message(i)) // if it does being scanned
- ++msg_sent;
- if (msg_sent == 4) {
- msg_sent = 0;
- host_send("^M^J-- More ?");
- j = host_input();
- host_send("^M ^M");
- }
- if (j == 'N' || j == 'n')
- i = last_msg + 1; // if i > last_msg then end
- }
- }
- //-----------------------------------------------
- // Enter messages
- //-----------------------------------------------
- else if (option == 'E'){ // to enter messge
- reply_to = 0;
- enter_message();
- }
- //-----------------------------------------------
- // Check messages
- //-----------------------------------------------
- else if (option == 'C'){
- if (!sysop_call)
- ustamp("User checked his/her message.", 1, 1);
- reply_to = 0;
- host_send("^M^JYour mail: ");
- msg_sent = 0;
- for (i = first_msg; i <= last_msg; ++i){
- if (check_message(i))
- ++msg_sent;
- if (msg_sent == 10){
- msg_sent = 0;
- host_send("^M^J ");
- }
- }
- host_send("^M^J^M^JMessage# enclosed with [] is from you.^M^J");
- }
- //-----------------------------------------------
- // Non-stop display of messages
- //-----------------------------------------------
- else if (option == 'N'){
- if (!sysop_call)
- ustamp("User invoked non-stop displaying of messages.", 1, 1);
- reply_to = 0;
- host_send("^M^JStarting from message# (<RETURN> = first):");
- host_input_strn(strn, 10, 0);
- host_send("^M^J");
- if (finished_caller)
- return;
- option = stoi(strn);
- if (option == 0) // if only <RET> pressed then
- option = first_msg; // from the first message
- for (i = option; i <= last_msg; ++i) {
- if (display_message(i)) { // if caller see the msg
- last_read = i; // update last read msg#
- if (sysop_call) // if caller is sysop then
- sysop_last_read = i; // update sysop's last read msg#
- host_send("^M^J<ESC> to stop, <CR> to continue...");
- do {
- c = host_input();
- } while (c != 27 && c != 13);
- host_send("^M^J");
- if (c == 27)
- break;
- }
- }
- }
- //-----------------------------------------------
- // Delete a message
- //-----------------------------------------------
- else if (option == 'D'){
- reply_to = 0;
- host_send("^M^JDelete which message#: ");
- host_input_strn(strn, 10, 0);
- host_send("^M^J");
- if (finished_caller)
- return;
- if (stoi(strn)) { // if valid number entered
- i = stoi(strn);
- delete_message(i); // ok, TRY to delete it...
- }
- }
- //-----------------------------------------------
- // Reply to a message
- // only responds when there is something to reply
- // to -- each time finished reading message is the
- // time to reply. any other time will not let
- // user to use Reply.
- //-----------------------------------------------
- else if (option == 'R'){
- if (reply_to)
- reply_message(reply_to);
- }
- //-----------------------------------------------
- // Quit the message functions
- //-----------------------------------------------
- else if (option == 'Q'){
- reply_to = 0;
- if (sysop_call)
- fstlst();
- return;
- }
- //-----------------------------------------------
- // If a message number is entered then display it
- //-----------------------------------------------
- else if (stoi(strn)){ // a number has been typed,
- i = stoi(strn); // i is the number typed
- if (display_message(i)) { // if caller see the msg
- last_read = i; // update last read msg#
- reply_to = i; // update msg# to reply to
- if (sysop_call) // if caller is sysop then
- sysop_last_read = i; // update sysop's last read msg#
- }
- else // nothing displayed, so reset
- reply_to = 0; // msg# to reply_to
- }
- //-----------------------------------------------
- // If only CR is pressed
- //-----------------------------------------------
- else if (strlen(strn) == 0){
- i = last_read + 1;
- do {
- if (i <= last_msg && display_message(i)) {
- last_read = i;
- reply_to = i;
- if (sysop_call) // if caller is sysop then
- sysop_last_read = i; // update sysop's last read msg#
- break;
- }
- else { // nothing displayed, so reset
- ++i; // msg# to reply to
- reply_to = 0;
- }
- } while (i <= last_msg);
- }
- } // while (an endless loop unless 'Q' option is confirmed.
- } // do message
-
- //////////////////////////////////////////////////////////////////////////////
- // get transfer protocol
- //////////////////////////////////////////////////////////////////////////////
-
- host_get_prot(str transfer_way)
-
- {
- str prot[10];
-
- showprot(transfer_way);
-
- host_input_strn(prot, 6, 0);
- host_send("^M^J");
-
- if (strposi("KMSX1GYEZT", prot, 0) == -1) // if illegal prot
- prot = ""; // return 0 since first char
- // of empty string is 0.
- return (toupper(subchr(prot, 0))); // return first char.
- } // host_get_prot
-
- //////////////////////////////////////////////////////////////////////////////
-
- send_transfer_msg()
-
- {
- host_send("Ready to transfer file(s)... Press Ctrl-X at least twice to abort^M^J");
- }
-
- //////////////////////////////////////////////////////////////////////////////
- // Determine the baud rate once a Carrier Detect Signal has been detected
- // Since no characters were read, the 'CONNECT' string should still be
- // in the receive buffer.
- // return value = 0 if failed
- // return value = 1 if succeeded
- //////////////////////////////////////////////////////////////////////////////
-
- determine_baud()
-
- {
- int t3, t12, t24, t96, t192;
- int tmark, stat;
- int new_baud = 0;
-
- printsc("Determining baud... ");
-
- track_free(0); // stop tracking all strings
-
- t3 = track(conn300, 0); // start tracking connect strings
- t12 = track(conn1200, 0); // case is significant (mode 0)
- t24 = track(conn2400, 0);
- t96 = track(conn9600, 0);
- t192 = track(conn19200, 0);
-
- tmark = timer_start(30); // wait up to 3 seconds for string
-
- while (!time_up(tmark)) { // while there is still time
- if (!carrier()) { // if we lost connection
- track_free(0); // stop tracking all strings
- return 0; // zero indicating failure
- }
- if (cinp_cnt()) // if something is in the comm buffer
- track_addchr(cgetc()); // treat incoming char as from terminal handler
-
- stat = track_hit(0); // get the lowest numbered handle of any strings
- if (stat == 0) // none did come, so continue
- continue;
-
- if (stat == t3)
- new_baud = 300;
- else if (stat == t24)
- new_baud = 2400;
- else if (stat == t96)
- new_baud = 9600;
- else if (stat == t192)
- new_baud = 19200;
- else
- new_baud = 1200;
-
- break; // have baud rate, get out
- } // while there is still time
-
- if (!new_baud) // time-up without CONNECT string
- {
- prints("Failed!");
- track_free(0); // stop tracking all strings
- return 0; // zero indicating failure
- }
-
- printn(new_baud);
- prints("");
-
- //---------------------------------------------------------
- // set communication parameters: all the same except
- // the new baud rate.
- //---------------------------------------------------------
- set_cparams(new_baud, get_parity(), get_datab(), get_stopb());
-
- track_free(0); // stop tracking all strings
- return 1; // indicate success
-
- } // determine baud rate
-
- //////////////////////////////////////////////////////////////////////////////
- // open a text file then output it to the terminal emulator and comm port
- // return value = -1 if it failed to open the text file
- // return value = 0 if connection is lost or user inactivity
- // return value = 1 if Ctrl-C is pressed to abort it
- //////////////////////////////////////////////////////////////////////////////
-
- type_file(str fname)
-
- {
- int f;
- str buf[200];
- int k, ichar, lines_sent = 0;
-
- f = fopen(fname, "r"); // open the file for reading
- if (!f) // if it can't be open
- return -1; // -1 indicating failure
-
- host_send("^M^J");
-
- while (1) {
- if (carrier_counts)
- if (!carrier()) { // if carrier detect line is not OK
- connection_lost = 1;
- finished_caller = 1;
- fclose(f);
- return 0;
- }
-
- if (fgets(buf, 195, f) == -1) { // read at most 195 chars (LF stripped)
- fclose(f);
- return 1;
- }
-
- if (feof(f)) { // end-of-file is reached
- if (subchr(buf, strlen(buf) - 1) == 26) // if last char of buf is Ctrl-Z
- setchr(buf, strlen(buf) - 1, 0); // remove Ctrl-Z
- }
- else
- host_send(buf); // output a line to the host & caller
-
- host_send("^M^J"); // add LF explicitly since LF stripped
-
- ++lines_sent;
-
- while (cinp_cnt()) { // if something is in comm buffer
- ichar = cgetc(); // the read it!
- if (ichar == '^C') { // is it a Ctrl-C ?
- host_send("^M^J"); // yes, so stop typing file
- fclose(f);
- return 1;
- } // is it a Ctrl-C ?
- } // while something is in comm buffer
-
-
- if (lines_sent >= 23) { // have we filled the whole screen?
- lines_sent = 0; // yes, so reset the counter
- host_send("-- More ?");
- k = host_input();
- host_send("^M ^M");
- if (finished_caller) { // if user inactivity
- fclose(f);
- return 0;
- }
- if (k == 'N' || k == 'n')
- return 1;
- }
-
- } // while: an endless loop if return not used
- } // type_file
-
- //////////////////////////////////////////////////////////////////////////////
- // host_send sends the specified string through two routes:
- // 1) terminal emulator, so that ANSI codes can be interpreted locally
- // 2) modem port
- //////////////////////////////////////////////////////////////////////////////
-
- host_send(str outstr)
-
- {
-
- if (!local_mode)
- cputs(outstr); // sends to modem port
- printsc_trm(outstr); // sends to screen through terminal emulator
-
- }
-
- //////////////////////////////////////////////////////////////////////////////
- // host_send_c sends the specified character through two routes:
- // 1) screen
- // 2) modem port
- //////////////////////////////////////////////////////////////////////////////
-
- host_send_c(int chr)
-
- {
- str c_str[2];
-
- setchr(c_str, 0, chr);
- setchr(c_str, 1, 0);
- if (!local_mode)
- cputc(chr); // sends to modem port
- printsc_trm(c_str); // sends to terminal emulator of host
-
- // printc(chr); // prints the character on the terminal screen
-
- }
-
- //////////////////////////////////////////////////////////////////////////////
- // host_input_strn waits the sysop/user to input a string or press <CR>
- // return value = 1 if string is not empty
- // 0 if string is empty
- //////////////////////////////////////////////////////////////////////////////
-
- host_input_strn(str buf, int maximum, int start_point)
-
- {
- int i, j, key;
-
- i = start_point;
- while (1) { // endless loop until... lets see...
- key = host_input(); // key is from host or user
- if (!key) { // timeout or user disconnect
- setchr(buf, 0, 0); // set string to empty
- return 0; // indicate there is a problem
- }
- if (key == '^M') { // Carriage return pressed
- break; // so terminate the endless loop
- }
- if (key == 127 || key == 8) { // Backspace or Del
- if (i) { // if something has been typed
- --i;
- host_send_c(key); // erase one character backwards
- }
- continue; // continue the endless loop
- } // if Backspace or Del
- if (key == 9) { // Horizontal Tab is converted to up to
- j = 5; // five blanks.
- while (i < maximum && j > 0){
- setchr(buf, i, ' ');// put char into buffer and
- ++i;
- --j;
- host_send_c(' ');
- }
- continue;
- }
- if (key == 24) { // Ctrl-X key pressed by user
- while (i >= 0) { // move cursor to starting point
- host_send_c(8);
- --i;
- }
- i = 0; // reset i
- continue;
- }
- if (i < maximum) { // if not more than buffer size
- setchr(buf, i, key); // put char into buffer and
- ++i; // take a note about number of characters
- }
- if (i == maximum) // if maximum count is reached
- break;
- } // the while endless loop
-
- setchr(buf, i, '^0'); // mark the end of string
-
- if (subchr(buf, 0)) // if this is not an empty string
- return 1; // then return 1
- else // this is an empty string
- return 0; // so return 0
-
- } // host_input_strn
-
- //////////////////////////////////////////////////////////////////////////////
- // host input function does this:
- // it starts up a timer to 5 minutes then enters an endless loop
- // (No time limit if SysOp is calling this board)
- // waiting for character coming from keyboard or comm port.
- // any character presented in the keyboard or comm port will terminate
- // the endless loop by doing the following:
- // Keyboard character (from SysOp, of course):
- // HOME -- sysop wants to exit the session
- // END -- sysop kicks the user out (kill user)
- // F1 -- sysop initiates chat mode
- // F2 -- sysop terminates chat mode
- // F3 -- sysop check incoming user's basic data
- // All other char except BS & Del -- sends to screen & modem
- // Comm port character (from User, of course):
- // All other char except BS & Del -- sends to screen & modem
- // return value = 0 if inactivity is too long or connection is lost
- // return value = ASCII value
- //////////////////////////////////////////////////////////////////////////////
-
- host_input()
-
- {
- int c, t, curt, capst, used_time;
-
- if (!sysop_call) // if caller is not sysop --> set time-out limit
- t = timer_start(3000); // 5 minutes inactivity allowed for users
-
- while (1) {
- if (!sysop_call && !direct_connect) { // if not a sysop & through modem
- if (time_up(t)) { // inactivity too long...
- host_send("^M^J^M^J");
- host_send("Inactivity period too long. Connection terminated!^M^J");
- if (carrier_counts)
- hangup();
- finished_caller = 1;
- kill_user = 1;
- return 0;
- }
-
- curt = curtime();
-
- if (!warned)
- if ((curt - grand_timer) > 3420) { // only three minutes left
- _sound_on = 1;
- host_send("^G^G^M^J^M^JOnly 3 minutes left.^M^J");
- warned = 1;
- _sound_on = 0;
- }
-
- if ((curt - grand_timer) > 3600) { // total logon time expired.
- host_send("^M^J^M^J");
- host_send("Logon time expired. Please call again.^M^J");
- if (carrier_counts)
- hangup();
- finished_caller = 1;
- kill_user = 1;
- return 0;
- }
- }
-
- if (carrier_counts && !carrier()) {
- prints("^M^JConnection has been lost, call terminated.^M^J");
- connection_lost = 1;
- finished_caller = 1;
- return 0;
- }
-
- if ((c = inkey()) != 0) { // if keyboard buffer is not empty
- if (c <= 255) {
- if (c != 8 && c != 127 && c != 9) // backspace & delete & tab
- host_send_c(c); // sends the character to screen & modem
- return c;
- }
- else if (c == 0x4700) { // HOME key, sysop wants to exit
- finished_caller = 1;
- exit_requested = 1;
- return 0;
- }
- else if (c == 0x4f00) { // END key, temrinate user
- prints("^M^JUser terminated!");
- if (!sysop_call)
- ustamp("Terminated by SysOp", 1, 1);
- if (carrier_counts)
- hangup();
- finished_caller = 1;
- kill_user = 1;
- return 0;
- }
- else if (c == 0x3b00) { // F1 key --> sysop initiates chat
- if (!sysop_call)
- ustamp("Sysop initiated chat mode.", 1, 1);
- used_time = curtime() - grand_timer;
- call("chatmode", local_mode, carrier_counts, capfname);
- if (!sysop_call)
- ustamp("Sysop terminated chat mode.", 1, 1);
- timer_restart(t, 3000); // 5 minutes inactivity allowed for users
- grand_timer = curtime() - used_time; // reset
- }
- // F2 (sysop terminate chat) disabled
-
- else if (c == 0x3d00) { // F3 key --> sysop checks user's personal data
- if (!sysop_call)
- showuser();
- }
- else if (c == 0x3e00) { // F4 key --> capture on/off
- capst = capture_stat();
- if (capst == 0) // capture file is closed
- capture(capfname);
- else if (capst == 1 || capst == 2) // capture file is open
- capture("*CLOSE*");
- update_term();
- }
- else if (c == 0x3f00) { // F5 key --> capture pause/unpause
- capst = capture_stat();
- if (capst == 1) // capture file is open
- capture("*PAUSE*");
- else if (capst == 2) // capture file is open and paused
- capture("*UNPAUSE*");
- update_term();
- }
- else if (c == 0x4000) { // F6 key --> reset user's available time
- if (!sysop_call) {
- warned = 0;
- grand_timer = curtime();
- resetime();
- }
- }
- } // if keyboard buffer is not empty
-
- if (!local_mode) // if this is not a local test
- if (cinp_cnt()) { // and if something is in the comm buffer
- c = cgetc(); // then read that character
- if (c != 8 && c != 127 && c != 9) // backspace & delete & tab
- host_send_c(c); // sends the character to screen & modem (echo)
- return c;
- }
- } // while
- } // host_input
-
- //////////////////////////////////////////////////////////////////////////////
- // verify if it is real sysop by
- // asking for a sysop's password for three times
- //
- // failure --> return 0
- // success --> return 2, this is regarded as level 2 access
- //
- // (level 2 access is the same as sysop_call == 1)
- //
- //////////////////////////////////////////////////////////////////////////////
-
- verify_sysop()
-
- {
- int i;
- str strn[25];
-
- for (i = 0; i < 3; ++i) { // only three times to enter sysop's password
- if (i) // the first time will not show this warning.
- host_send("^M^JWrong! Try again.^M^J");
- host_send("Enter ");
- if (ansi_mode)
- host_send("SysOp's password: ");
- else
- host_send("SysOp's password: ");
- host_input_strn(strn, 20, 0);
- host_send("^M^J");
- if (finished_caller) // connection is lost
- return 0;
- strupper(strn); // change to upper case
- if (!strcmpi(strn, sysop_password)) // check for sysop's password
- return 2; // access
- }
- host_send("^M^JYou are not SysOp. Get out!!!^M^J");
- return 0;
- } // verify_sysop
-
- //////////////////////////////////////////////////////////////////////////////
- // ask for password for maxtries times.
- // return value: 0 --> access denied
- // 1 --> access granted
- //////////////////////////////////////////////////////////////////////////////
-
- ask_for_pass(int maxtries, str password)
-
- {
- int i;
- str strn[23];
-
- for (i = 0; i < maxtries; ++i) {
- if (i)
- host_send("^M^JWrong! Try again.^M^J");
- host_send("Enter password: ");
- host_input_strn(strn, 20, 0);
- host_send("^M^J");
- if (finished_caller) // something is wrong
- return 0; // access is denied
- strupper(strn); // change to upper case
- if (!strcmpi(strn, password)) // if strn is equal to password
- return 1; // access granted
- }
- host_send("^M^JNo more chances. Access denied.^M^J");
- return 0; // access denied
- } // ask_for_pass
-
- //////////////////////////////////////////////////////////////////////////////
- // returns TRUE if passed filespec is just a filename.
- // returns FALSE if passed filespec is not just a filename (is a path...)
- // Also handles the forward slash as a path separator.
- //////////////////////////////////////////////////////////////////////////////
-
- just_filename(str filespec)
-
- {
- int slash, space;
-
- if (strpos(filespec, ":", 0) != -1) // if filespec contains ':' then returns
- return 0; // FALSE indicating not just a file name
- if (strpos(filespec, "\", 0) != -1) // if filespec contains '\' then it
- return 0; // must be containing path
- if ((slash = strpos(filespec, "/")) == -1) // if '/' is not found then it's
- return 1; // a filename
-
- space = strpos(filespec, " "); // if space is not found then it is
- if (space == -1) // a path
- return 0;
- if (space < slash)
- return 1;
-
- return 0; // not just a filename
-
- } // just_filename
-
- //////////////////////////////////////////////////////////////////////////////
- // show top level commands
- //////////////////////////////////////////////////////////////////////////////
-
- top_level_cmd()
-
- {
- int min, sec, time_left;
- str min_str[6], sec_str[6], tmp_str[6];
-
- if (!sysop_call) {
- time_left = 3600 - (curtime() - grand_timer);
- min = time_left / 60; // 60 secs == 1 minute
- sec = time_left - (min * 60);
-
- itos(min, tmp_str); // convert minute to minute string
- if (min < 10) {
- min_str = "0";
- strcat(min_str, tmp_str);
- }
- else
- min_str = tmp_str;
-
- itos(sec, tmp_str); // convert second to second string
- if (sec < 10) {
- sec_str = "0";
- strcat(sec_str, tmp_str);
- }
- else
- sec_str = tmp_str;
- host_send("^M^J");
- host_send("Online time left = ");
- host_send(min_str);
- host_send(" min ");
- host_send(sec_str);
- host_send(" sec ");
- }
-
- topcmd();
-
- } // top_level_command
-
- //////////////////////////////////////////////////////////////////////////////
- // enter message
- //////////////////////////////////////////////////////////////////////////////
-
- enter_message ()
-
- {
- str strn[6], msgnbr[5], date_time_str[15];
- str trail[85], sub_string[85];
- str atchfile[15];
- int security, i, j, k, p, q, r, s, line_count, tmp_file, msg_file;
- int end_enter_option, msg_sent;
-
- itos(last_msg + 1, msgnbr); // display new message number
- host_send("^M^Jmessage# : ");
- host_send(msgnbr);
- host_send("^M^J from : "); // display message writer
- host_send(current_caller_first);
- host_send(" ");
- host_send(current_caller_last);
- host_send("^M^J to : "); // asking for receiver
- host_input_strn(receiver, 30, 0); // receiver is a global string variable
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- if (strlen(receiver) == 0) // no receiver specified
- return; // end enter message function
- else{ // assume first name & last name
- strlower(receiver);
- setchr(receiver, 0, toupper(subchr(receiver, 0)));
- i = 0;
- while (subchr(receiver, i) != ' ' && i < strlen(receiver))
- ++i;
- if (i < strlen(receiver) - 1) { // blank found
- ++i; // make the next char upper case
- setchr(receiver, i, toupper(subchr(receiver, i)));
- }
- }
- host_send(" to : "); // display modified receiver name
- host_send(receiver);
- host_send("^M^J topic : "); // asking for topic
- host_input_strn(topic, 30, 0); // topic is also a global variable
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- if (strlen(topic) == 0) // no topic specified
- return; // so end enter message function
- else
- strupper(topic); // turn topic to upper case
- host_send(" topic : "); // display modified receiver name
- host_send(topic);
- host_send("^M^Jsecurity : "); // asking for security type
- if (ansi_mode)
- host_send("Private or pUblic? ");
- else
- host_send("(P)rivate or p(U)blic? ");
- host_input_strn(strn, 5, 0);
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- if (strlen(strn) == 0) // default security is public
- security = 'U';
- else
- security = toupper(subchr(strn, 0));
- if (security != 'P' && security != 'U') // illegal security code, then
- security = 'U'; // turn it into public
- host_send("^M^J^M^J");
- host_send("Message begins, 80 lines max, empty line to end.^M^J");
- host_send(" [-------------------------------------------------------------------------]");
- tmp_file = fopen(temp_message, "r+");// open file for temporary storage in RAM disk
- trail = ""; // clear garbage in trail
- //-------------------------------
- // entering 80 lines of text
- //-------------------------------
- line_count = 0;
- for (i = 1; i <= 80; ++i){ // entering 80 lines of text
- nextline: // where Continue goto...
- itos(i, msgnbr); // msgnbr is line number
- if (i < 10) // if line number is 0 -- 9 then
- host_send("^M^J "); // add one more space before number
- else
- host_send("^M^J");
- host_send(msgnbr); // write line number
- host_send(": ");
- if (strlen(trail) > 0) { // there is word from previous line
- host_send(trail); // display it and copy it to
- substr(trail, 0, strlen(trail), linemsg); // current line
- host_input_strn(linemsg, 74, strlen(trail)); // read current line
- trail = "";
- }
- else
- host_input_strn(linemsg, 74, 0); // read current line
- if (finished_caller) {
- fclose(tmp_file);
- return;
- }
- if (strlen(linemsg) == 74) { // line buffer is full
- j = strlen(linemsg) - 1; // so remove the last word
- while (subchr(linemsg, j) != ' ' // move before last word
- && j > 0)
- --j; // point j to the first space just before the last word
- k = j; // k also points to space
- substr(linemsg, j + 1, 80, trail); // copy the last word to trail
- while (j < strlen(linemsg)){ // erase the last word
- host_send_c(8); // in current line on screen
- ++j;
- }
- setchr(linemsg, k, '^0'); // mark the end of string
- }
- if (strlen(linemsg) > 0) { // if this line has contents
- strcat(linemsg, "^J"); // add LF to end-read
- fseek(tmp_file, (i - 1) * 80, 0);
- fputs(linemsg, tmp_file); // write to file here
- ++line_count;
- fflush(tmp_file); // write out to disk
- }
- else
- i = 100; // force to end
- } // enter 80 lines of message
-
- while (1) {
- end_enter_option = end_enter_msg(); // display end-enter prompt
- if (end_enter_option == 0) { // if connection lost...
- fclose(tmp_file); // close temporary file
- return; // then end do_message
- }
- //---------------------------------------
- // Abort this msg-entering session
- //---------------------------------------
- if (end_enter_option == 'A') { // Abort this message?
- host_send("^M^JAbort this message ? (Y/N)");
- host_input_strn(strn, 3, 0);
- host_send("^M^J");
- if (toupper(subchr(strn, 0)) == 'Y') {
- fclose(tmp_file);
- return;
- }
- }
- //---------------------------------------
- // Continue this session
- //---------------------------------------
- else if (end_enter_option == 'C') { // Continue?
- host_send("^M^J");
- trail = "";
- i = line_count + 1;
- goto nextline;
- }
- //---------------------------------------
- // Insert a line into the message
- //---------------------------------------
- else if (end_enter_option == 'I') { // Insert a line
- host_send("Insert which line # ");
- host_input_strn(strn, 4, 0);
- host_send("^M^J");
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- i = stoi(strn);
- if (line_count < 80 && i <= line_count && i >= 1) { // valid line number to insert
- if (i < 10)
- host_send("^M^J ");
- else
- host_send("^M^J");
- host_send(strn);
- host_send(": ");
- host_input_strn(trail, 73, 0);
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- strcat(trail, "^J");
- j = line_count; // old number of lines
- while (j >= i) {
- fseek(tmp_file, (j - 1) * 80, 0);
- fgets(linemsg, 80, tmp_file); // read line into linemsg
- strcat(linemsg, "^J"); // add LF to end-of-line
- fseek(tmp_file, j * 80, 0);
- fputs(linemsg, tmp_file); // write to file here
- --j;
- }
- fseek(tmp_file, (i - 1) * 80, 0);
- fputs(trail, tmp_file);
- ++line_count; // increment line count
- host_send("^M^JLine #");
- host_send(strn);
- host_send(" has been inserted.^M^J");
- } // valid line number to delete
- else if (line_count >= 80)
- host_send("^M^JMax lines entered. No insertion allowed.^M^J");
- }
- //---------------------------------------
- // Delete a line in this message
- //---------------------------------------
- else if (end_enter_option == 'D') { // Delete a line
- host_send("Delete which line # ");
- host_input_strn(strn, 4, 0);
- host_send("^M^J");
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- i = stoi(strn);
- if (i <= line_count && i >= 1) { // valid line number to delete
- ++i;
- while (i <= line_count) {
- fseek(tmp_file, (i - 1) * 80, 0);
- fgets(linemsg, 80, tmp_file); // read line into linemsg
- strcat(linemsg, "^J"); // add LF to end-of-line
- fseek(tmp_file, (i - 2) * 80, 0);
- fputs(linemsg, tmp_file); // write to file here
- ++i;
- }
- --line_count; // decrement line count
- host_send("^M^JLine #");
- host_send(strn);
- host_send(" is deleted.^M^J");
- } // valid line number to delete
- }
- //---------------------------------------
- // Edit a line in this message
- //---------------------------------------
- else if (end_enter_option == 'E') { // Edit which line
- host_send("Edit which line # ");
- host_input_strn(strn, 4, 0);
- host_send("^M^J");
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- i = stoi(strn);
- if (i <= line_count && i >= 1) { // valid line number to edit
- fseek(tmp_file, (i - 1) * 80, 0);
- fgets(linemsg, 80, tmp_file); // read line into linemsg
- host_send(strn); // display line# and content
- host_send(": ");
- host_send(linemsg);
- host_send("^M^JEdit with: /original string/new string/^M^J");
- host_input_strn(trail, 74, 0);
- j = 0;
- while (subchr(trail, j) != '/' && j < strlen(trail))
- ++j;
- k = strlen(trail) - 1;
- while (subchr(trail, k) != '/' && k >= 0)
- --k;
- //---------------------------------------
- // j --> first '/'
- // k --> last '/'
- //---------------------------------------
- if (j < k && j < strlen(trail) && k >= 0) {
- p = j + 1;
- while (subchr(trail, p) != '/' && p < k)
- ++p;
- if (p < k){ // p --> middle '/'
- substr(trail, j + 1, p - j - 1, editline);
- q = (strposi(linemsg, editline, 0)); // search old str
- if (q >= 0) { // substring to be changed is found...
- s = strlen(editline); // s = old string length
- editline = "";
- i = 0; // running pointer i
- for (r = 0; r < q; ++r) { // unchanged part 1
- setchr(editline, i, subchr(linemsg, r));
- ++i;
- }
- for (r = p + 1; r < k; ++r) { // new string
- setchr(editline, i, subchr(trail, r));
- ++i;
- }
- for (r = q + s; r < strlen(linemsg); ++r){ // unchanged part 2
- setchr(editline, i, subchr(linemsg, r));
- ++i;
- }
- linemsg = editline;
- host_send("^M^J");
- host_send(linemsg); // edit complete of this line
- i = stoi(strn);
- fseek(tmp_file, (i - 1) * 80, 0);
- fputs(linemsg, tmp_file);
- fputc('^J', tmp_file);
- } // successful search for old string
- } // valid middle slash
- } // valid format
- } // valid line number
- }
- //---------------------------------------
- // Change topic of this message
- //---------------------------------------
- else if (end_enter_option == 'T') { // Topic changed to?
- trail = topic;
- host_send("Old topic : ");
- host_send(topic);
- host_send("^M^JNew topic : ");
- host_input_strn(topic, 30, 0);
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- if (strlen(topic) == 0)
- topic = trail;
- else
- strupper(topic); // turn topic to upper case
- host_send("New topic : "); // display modified receiver name
- host_send(topic);
- }
- //---------------------------------------
- // List this message
- //---------------------------------------
- else if (end_enter_option == 'L') { // List message
- host_send("Starting from line # ");
- host_input_strn(strn, 4, 0);
- host_send("^M^J");
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- i = stoi(strn);
- if (i == 0) // if no number entered
- i = 1; // then start from line# 1
- if (i <= line_count && i >= 1) { // valid line number
- while (i <= line_count) {
- fseek(tmp_file, (i - 1) * 80, 0);
- fgets(linemsg, 80, tmp_file); // read into linemsg
- itos(i, msgnbr); // msgnbr is line number
- if (i < 10) // if line number is 0 -- 9 then
- host_send("^M^J "); // add one more space before number
- else
- host_send("^M^J");
- host_send(msgnbr); // write line number
- host_send(": ");
- host_send(linemsg); // and display it.
- ++i;
- }
- host_send("^M^J");
- }
- }
- //---------------------------------------
- // Save this message
- //---------------------------------------
- else if (end_enter_option == 'S') { // Save this message
- ++last_msg; // increment # of last_msg
- if (last_msg == 1) // this is the very first msg
- first_msg = 1; // of this system!
- itos(last_msg, tmp_fname); // tmp_fname used as temporary str
- if (last_msg < 10) // last_msg == 0..9
- msgnbr = "000"; // so add three leading zeros
- else if (last_msg < 100) // last_msg == 10..99
- msgnbr = "00"; // so add two leading zeros
- else if (last_msg < 1000) // last_msg == 100..999
- msgnbr = "0"; // add one leading zero
- strcat(msgnbr, tmp_fname); // now msgnbr is 4-digit str
- tmp_fname = host_message; // get default msg directory
- strcat(tmp_fname, msgnbr); // then add 4-digit str as file name
-
- msg_file = fopen(tmp_fname, "a"); // open msg file with 4-digit file name
- itos(curtime(), date_time_str);
- fputs(date_time_str, msg_file); fputc('^J', msg_file);
- fputs(current_caller_first, msg_file); fputc('^J', msg_file);
- fputs(current_caller_last, msg_file); fputc('^J', msg_file);
- fputs(receiver, msg_file); fputc('^J', msg_file);
- fputs(topic, msg_file); fputc('^J', msg_file);
- fputc(security, msg_file);
- for (i = 1; i <= line_count; ++i){
- fseek(tmp_file, (i - 1) * 80, 0);
- fgets(linemsg, 80, tmp_file); // read into linemsg
- fputs(linemsg, msg_file);
- fputc('^J', msg_file);
- }
- fclose(msg_file);
- fclose(tmp_file);
-
- fstlst();
-
- return;
- } // msg saved.
- } // while, another endless loop
- } // enter message
-
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // reply message
- // input: reply_number is the message number to which to reply
- //
- //////////////////////////////////////////////////////////////////////////////
-
- reply_message (int reply_number)
-
- {
- str strn[6], msgnbr[5], date_time_str[15];
- str trail[85], sub_string[85];
- str atchfile[15];
- int security, i, j, k, p, q, r, s, line_count, tmp_file, msg_file;
- int idx_file;
- int end_enter_option, msg_sent;
-
- host_send("^M^JThis is reply to msg# ");
- if (ansi_mode)
- host_send("");
- itos(reply_number, msgnbr);
- host_send(msgnbr);
- if (ansi_mode)
- host_send("");
- host_send("^M^J");
- itos(last_msg + 1, msgnbr); // display new message number
- host_send("^M^Jmessage# : ");
- host_send(msgnbr);
- host_send("^M^J from : "); // display message writer
- host_send(current_caller_first);
- host_send(" ");
- host_send(current_caller_last);
-
- host_send("^M^J to : "); // asking for receiver
- receiver = name_to_reply; // get name to reply to
- host_send(receiver);
-
- topic = topic_to_reply; // get old topic to reply to
- host_send("^M^J topic : "); // asking for topic
- host_send(topic); // topic is also a global variable
- host_input_strn(topic, 30, strlen(topic)); // and continue...
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- if (strlen(topic) == 0) // no topic specified
- return; // so end enter message function
- else
- strupper(topic); // turn topic to upper case
- host_send(" topic : "); // display modified receiver name
- host_send(topic);
- host_send("^M^Jsecurity : "); // asking for security type
- if (ansi_mode)
- host_send("Private or pUblic? ");
- else
- host_send("(P)rivate or p(U)blic? ");
- host_input_strn(strn, 5, 0);
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- if (strlen(strn) == 0) // default security is public
- security = 'U';
- else
- security = toupper(subchr(strn, 0));
- if (security != 'P' && security != 'U') // illegal security code, then
- security = 'U'; // turn it into public
- host_send("^M^J^M^J");
- host_send("Message begins, 80 lines max, empty line to end.^M^J");
- host_send(" [-------------------------------------------------------------------------]");
- tmp_file = fopen(temp_message, "r+");// open file for temporary storage in RAM disk
- trail = ""; // clear garbage in trail
- //-------------------------------
- // entering 80 lines of text
- //-------------------------------
- line_count = 0;
- for (i = 1; i <= 80; ++i){ // entering 80 lines of text
- nextline: // where Continue goto...
- itos(i, msgnbr); // msgnbr is line number
- if (i < 10) // if line number is 0 -- 9 then
- host_send("^M^J "); // add one more space before number
- else
- host_send("^M^J");
- host_send(msgnbr); // write line number
- host_send(": ");
- if (strlen(trail) > 0) { // there is word from previous line
- host_send(trail); // display it and copy it to
- substr(trail, 0, strlen(trail), linemsg); // current line
- host_input_strn(linemsg, 74, strlen(trail)); // read current line
- trail = "";
- }
- else
- host_input_strn(linemsg, 74, 0); // read current line
- if (finished_caller) {
- fclose(tmp_file);
- return;
- }
- if (strlen(linemsg) == 74) { // line buffer is full
- j = strlen(linemsg) - 1; // so remove the last word
- while (subchr(linemsg, j) != ' ' // move before last word
- && j > 0)
- --j; // point j to the first space just before the last word
- k = j; // k also points to space
- substr(linemsg, j + 1, 80, trail); // copy the last word to trail
- while (j < strlen(linemsg)){ // erase the last word
- host_send_c(8); // in current line on screen
- ++j;
- }
- setchr(linemsg, k, '^0'); // mark the end of string
- }
- if (strlen(linemsg) > 0) { // if this line has contents
- strcat(linemsg, "^J"); // add LF to end-read
- fseek(tmp_file, (i - 1) * 80, 0);
- fputs(linemsg, tmp_file); // write to file here
- ++line_count;
- fflush(tmp_file); // write out to disk
- }
- else
- i = 100; // force to end
- } // enter 80 lines of message
-
- while (1) {
- end_enter_option = end_enter_msg(); // display end-enter prompt
- if (end_enter_option == 0) { // if connection lost...
- fclose(tmp_file); // close temporary file
- return; // then end do_message
- }
- //---------------------------------------
- // Abort this msg-entering session
- //---------------------------------------
- if (end_enter_option == 'A') { // Abort this message?
- host_send("^M^JAbort this message ? (Y/N)");
- host_input_strn(strn, 3, 0);
- host_send("^M^J");
- if (toupper(subchr(strn, 0)) == 'Y') {
- fclose(tmp_file);
- return;
- }
- }
- //---------------------------------------
- // Continue this session
- //---------------------------------------
- else if (end_enter_option == 'C') { // Continue?
- host_send("^M^J");
- trail = "";
- i = line_count + 1;
- goto nextline;
- }
- //---------------------------------------
- // Insert a line into the message
- //---------------------------------------
- else if (end_enter_option == 'I') { // Insert a line
- host_send("Insert which line # ");
- host_input_strn(strn, 4, 0);
- host_send("^M^J");
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- i = stoi(strn);
- if (line_count < 80 && i <= line_count && i >= 1) { // valid line number to insert
- if (i < 10)
- host_send("^M^J ");
- else
- host_send("^M^J");
- host_send(strn);
- host_send(": ");
- host_input_strn(trail, 73, 0);
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- strcat(trail, "^J");
- j = line_count; // old number of lines
- while (j >= i) {
- fseek(tmp_file, (j - 1) * 80, 0);
- fgets(linemsg, 80, tmp_file); // read line into linemsg
- strcat(linemsg, "^J"); // add LF to end-of-line
- fseek(tmp_file, j * 80, 0);
- fputs(linemsg, tmp_file); // write to file here
- --j;
- }
- fseek(tmp_file, (i - 1) * 80, 0);
- fputs(trail, tmp_file);
- ++line_count; // increment line count
- host_send("^M^JLine #");
- host_send(strn);
- host_send(" has been inserted.^M^J");
- } // valid line number to delete
- else if (line_count >= 80)
- host_send("^M^JMax lines entered. No insertion allowed.^M^J");
- }
- //---------------------------------------
- // Delete a line in this message
- //---------------------------------------
- else if (end_enter_option == 'D') { // Delete a line
- host_send("Delete which line # ");
- host_input_strn(strn, 4, 0);
- host_send("^M^J");
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- i = stoi(strn);
- if (i <= line_count && i >= 1) { // valid line number to delete
- ++i;
- while (i <= line_count) {
- fseek(tmp_file, (i - 1) * 80, 0);
- fgets(linemsg, 80, tmp_file); // read line into linemsg
- strcat(linemsg, "^J"); // add LF to end-of-line
- fseek(tmp_file, (i - 2) * 80, 0);
- fputs(linemsg, tmp_file); // write to file here
- ++i;
- }
- --line_count; // decrement line count
- host_send("^M^JLine #");
- host_send(strn);
- host_send(" is deleted.^M^J");
- } // valid line number to delete
- }
- //---------------------------------------
- // Edit a line in this message
- //---------------------------------------
- else if (end_enter_option == 'E') { // Edit which line
- host_send("Edit which line # ");
- host_input_strn(strn, 4, 0);
- host_send("^M^J");
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- i = stoi(strn);
- if (i <= line_count && i >= 1) { // valid line number to edit
- fseek(tmp_file, (i - 1) * 80, 0);
- fgets(linemsg, 80, tmp_file); // read line into linemsg
- host_send(strn); // display line# and content
- host_send(": ");
- host_send(linemsg);
- host_send("^M^JEdit with: /original string/new string/^M^J");
- host_input_strn(trail, 74, 0);
- j = 0;
- while (subchr(trail, j) != '/' && j < strlen(trail))
- ++j;
- k = strlen(trail) - 1;
- while (subchr(trail, k) != '/' && k >= 0)
- --k;
- //---------------------------------------
- // j --> first '/'
- // k --> last '/'
- //---------------------------------------
- if (j < k && j < strlen(trail) && k >= 0) {
- p = j + 1;
- while (subchr(trail, p) != '/' && p < k)
- ++p;
- if (p < k){ // p --> middle '/'
- substr(trail, j + 1, p - j - 1, editline);
- q = (strposi(linemsg, editline, 0)); // search old str
- if (q >= 0) { // substring to be changed is found...
- s = strlen(editline); // s = old string length
- editline = "";
- i = 0; // running pointer i
- for (r = 0; r < q; ++r) { // unchanged part 1
- setchr(editline, i, subchr(linemsg, r));
- ++i;
- }
- for (r = p + 1; r < k; ++r) { // new string
- setchr(editline, i, subchr(trail, r));
- ++i;
- }
- for (r = q + s; r < strlen(linemsg); ++r){ // unchanged part 2
- setchr(editline, i, subchr(linemsg, r));
- ++i;
- }
- linemsg = editline;
- host_send("^M^J");
- host_send(linemsg); // edit complete of this line
- i = stoi(strn);
- fseek(tmp_file, (i - 1) * 80, 0);
- fputs(linemsg, tmp_file);
- fputc('^J', tmp_file);
- } // successful search for old string
- } // valid middle slash
- } // valid format
- } // valid line number
- }
- //---------------------------------------
- // Change topic of this message
- //---------------------------------------
- else if (end_enter_option == 'T') { // Topic changed to?
- trail = topic;
- host_send("Old topic : ");
- host_send(topic);
- host_send("^M^JNew topic : ");
- host_input_strn(topic, 30, 0);
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- if (strlen(topic) == 0)
- topic = trail;
- else
- strupper(topic); // turn topic to upper case
- host_send("New topic : "); // display modified receiver name
- host_send(topic);
- }
- //---------------------------------------
- // List this message
- //---------------------------------------
- else if (end_enter_option == 'L') { // List message
- host_send("Starting from line # ");
- host_input_strn(strn, 4, 0);
- host_send("^M^J");
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- i = stoi(strn);
- if (i == 0) // if no number entered
- i = 1; // then start from line# 1
- if (i <= line_count && i >= 1) { // valid line number
- while (i <= line_count) {
- fseek(tmp_file, (i - 1) * 80, 0);
- fgets(linemsg, 80, tmp_file); // read into linemsg
- itos(i, msgnbr); // msgnbr is line number
- if (i < 10) // if line number is 0 -- 9 then
- host_send("^M^J "); // add one more space before number
- else
- host_send("^M^J");
- host_send(msgnbr); // write line number
- host_send(": ");
- host_send(linemsg); // and display it.
- ++i;
- }
- host_send("^M^J");
- }
- }
- //---------------------------------------
- // Save this message
- //---------------------------------------
- else if (end_enter_option == 'S') { // Save this message
- ++last_msg; // increment # of last_msg
- if (last_msg == 1) // this is the very first msg
- first_msg = 1; // of this system!
- itos(last_msg, tmp_fname); // tmp_fname used as temporary str
- if (last_msg < 10) // last_msg == 0..9
- msgnbr = "000"; // so add three leading zeros
- else if (last_msg < 100) // last_msg == 10..99
- msgnbr = "00"; // so add two leading zeros
- else if (last_msg < 1000) // last_msg == 100..999
- msgnbr = "0"; // add one leading zero
- strcat(msgnbr, tmp_fname); // now msgnbr is 4-digit str
- tmp_fname = host_message; // get default msg directory
- strcat(tmp_fname, msgnbr); // then add 4-digit str as file name
- msg_file = fopen(tmp_fname, "a"); // open msg file with 4-digit file name
- itos(curtime(), date_time_str);
- fputs(date_time_str, msg_file); fputc('^J', msg_file);
- fputs(current_caller_first, msg_file); fputc('^J', msg_file);
- fputs(current_caller_last, msg_file); fputc('^J', msg_file);
- fputs(receiver, msg_file); fputc('^J', msg_file);
- fputs(topic, msg_file); fputc('^J', msg_file);
- fputc(security, msg_file);
- for (i = 1; i <= line_count; ++i){
- fseek(tmp_file, (i - 1) * 80, 0);
- fgets(linemsg, 80, tmp_file); // read into linemsg
- fputs(linemsg, msg_file);
- fputc('^J', msg_file);
- }
- fclose(msg_file);
- fclose(tmp_file);
-
- fstlst();
-
- strcat(tmp_fname, ".IDX"); // message index
- idx_file = fopen(tmp_fname, "a"); // open index file
- fseek(idx_file, 0, 2); // move to end-of-file
- itos(reply_number, msgnbr); // then write down which msg#
- fputs(msgnbr, idx_file); // is receiving this reply.
- fputc('^J', idx_file);
- fclose(idx_file);
-
- itos(reply_number, tmp_fname); // open the replied msg index
- if (reply_number < 10) // to store forward reference.
- msgnbr = "000"; // For example, if replied msg
- else if (reply_number < 100) // is #3 and replying msg is
- msgnbr = "00"; // #5 then reply_number.IDX has
- else if (reply_number < 1000) // #5 while the new message's
- msgnbr = "0"; // index has #3. So that when
- strcat(msgnbr, tmp_fname); // a msg is diaplayed, system
- tmp_fname = host_message; // can display "Also see..."
- strcat(tmp_fname, msgnbr); // information for convenient
- strcat(tmp_fname, ".IDX"); // reference.
- idx_file = fopen(tmp_fname, "a");
- fseek(idx_file, 0, 2);
- itos(last_msg, msgnbr);
- fputs(msgnbr, idx_file);
- fputc('^J', idx_file);
- fclose(idx_file);
-
- return;
- } // msg saved.
- } // while, another endless loop
- } // reply message
-
- //////////////////////////////////////////////////////////////////////////////
- // end enter message prompt
- // return value: 0 if connection is lost
- // option represented by a letter
- //////////////////////////////////////////////////////////////////////////////
-
- end_enter_msg ()
-
- {
- str strn[10];
- int option;
-
- do {
- endenter();
- host_input_strn(strn, 8, 0);
- } while (strlen(strn) == 0);
-
- option = toupper(subchr(strn, 0));
- host_send("^M^J");
-
- if (finished_caller) // finished_caller is set by host_input if
- return 0; // connection is lost --> return 0.
- else
- return option; // option choose --> return it.
-
- } // end_entering message
-
-
- //////////////////////////////////////////////////////////////////////////////
- // check_message
- //////////////////////////////////////////////////////////////////////////////
-
- check_message (int i)
-
- {
- str msgnbr[5], strn[5], date_time_str[15];
- int msg_file, ismsg = 0;
-
- tmp_fname = host_message; // get message directory
- if (i < 10) // if message number is smaller than 10 then
- msgnbr = "000"; // add three zeros for file name matching.
- else if (i < 100)
- msgnbr = "00";
- else if (i < 1000)
- msgnbr = "0";
- itos(i, strn); // convert message number to number string
- strcat(msgnbr, strn); // add zeros before this number
- strcat(tmp_fname, msgnbr); // now tmp_fname got the path & file name
- msg_file = fopen(tmp_fname, "r"); // open message file for reading only
- if (msg_file != 0){ // file is opened successfully
- fgets(date_time_str, 20, msg_file); // read date/time string
- fgets(msg_caller_first, 20, msg_file); // read sender's first name
- fgets(msg_caller_last, 20, msg_file); // and his/her last name
- fgets(receiver, 35, msg_file); // and receiver's full name
-
- //---------------------------------------------
- // this message is written by current caller
- //---------------------------------------------
- if (!strcmpi(msg_caller_first, current_caller_first) &&
- !strcmpi(msg_caller_last, current_caller_last)) {
- host_send("[");
- host_send(strn);
- host_send("] ");
- ismsg = 1;
- }
- //---------------------------------------------
- // this message is for current caller
- //---------------------------------------------
- else if (!strcmpi(receiver, current_caller_full)) {
- if (i > last_read){ // assume caller never saw this msg
- if (ansi_mode) {
- host_send(""); // so highlighten it.
- host_send(strn);
- host_send(" ");
- }
- else {
- host_send(strn);
- host_send(" ");
- }
- }
- else{
- host_send(strn);
- host_send(" ");
- }
- ismsg = 1;
- }
- fclose(msg_file);
- } // message file open successfully
- return ismsg;
- } // check_message
-
- //////////////////////////////////////////////////////////////////////////////
- // scan_message
- // input value i is message number to scan
- //////////////////////////////////////////////////////////////////////////////
-
- scan_message(int i)
-
- {
- str msgnbr[5], strn[5], date_time_str[20];
- int msg_file, date_time, scanned = 0, security;
-
- tmp_fname = host_message; // get message directory
- if (i < 10) // if message number is smaller than 10 then
- msgnbr = "000"; // add three zeros for file name matching.
- else if (i < 100)
- msgnbr = "00";
- else if (i < 1000)
- msgnbr = "0";
- itos(i, strn); // convert message number to number string
- strcat(msgnbr, strn); // add zeros before this number
- strcat(tmp_fname, msgnbr); // now tmp_fname got the path & file name
- msg_file = fopen(tmp_fname, "r"); // open message file for reading only
- if (msg_file != 0){ // file is opened successfully
- fgets(date_time_str, 20, msg_file); // read msg creating date/time
- date(stoi(date_time_str), date_str);
- time(stoi(date_time_str), time_str);
- fgets(msg_caller_first, 20, msg_file); // read sender's first name
- fgets(msg_caller_last, 20, msg_file); // and his/her last name
- fgets(receiver, 35, msg_file); // and receiver's full name
- fgets(topic, 35, msg_file); // and the topic
- security = fgetc(msg_file); // and security type
- //-------------------------------------------------------
- // Everybody can see this message title in a scan
- //-------------------------------------------------------
- host_send("^M^J");
-
- host_send("Message No: "); // message number, date, and time
- if (ansi_mode)
- host_send("");
- host_send(strn);
- if (ansi_mode)
- host_send(".");
- host_send(" ");
- host_send(date_str); host_send(" "); host_send(time_str);
- host_send(" ");
- if (ansi_mode)
- host_send("");
-
- if ((security & 127) == 'U') // display security status of this msg
- host_send("(Public)");
- else if ((security & 127) == 'P')
- host_send("(Private)");
- if ((security & 128) == 128)
- host_send(" (Received)");
- if (ansi_mode)
- host_send("");
- host_send("^M^J");
- host_send(" From: "); // the sender of the message
- if (ansi_mode)
- host_send("");
- host_send(msg_caller_first); host_send(" ");
- host_send(msg_caller_last);
- if (ansi_mode)
- host_send("");
- host_send("^M^J"); // the receiver
- host_send(" To: ");
- if (ansi_mode)
- host_send("");
- host_send(receiver);
- if (ansi_mode)
- host_send("");
- host_send("^M^J"); // topic of this message
- host_send(" Topic: ");
- if (ansi_mode)
- host_send("");
- host_send(topic);
- if (ansi_mode)
- host_send("");
- host_send("^M^J"); // contents of this message now...
- fclose(msg_file);
- scanned = 1;
- } // message file open successfully
- return scanned;
- } // scan_message
-
- //////////////////////////////////////////////////////////////////////////////
- // delete_message
- // input value i is message number to delete
- //////////////////////////////////////////////////////////////////////////////
-
- delete_message (int i)
-
- {
- str msgnbr[5], strn[5], cmdstr[50], date_time_str[15];
- int msg_file, security, date_time;
- int lines_sent, ichar, isread = 0;
-
- tmp_fname = host_message; // get message directory
- if (i < 10) // if message number is smaller than 10 then
- msgnbr = "000"; // add three zeros for file name matching.
- else if (i < 100)
- msgnbr = "00";
- else if (i < 1000)
- msgnbr = "0";
- itos(i, strn); // convert message number to number string
- strcat(msgnbr, strn); // add zeros before this number
- strcat(tmp_fname, msgnbr); // now tmp_fname got the path & file name
- msg_file = fopen(tmp_fname, "r"); // open message file for reading only
- if (msg_file != 0){ // file is opened successfully
- fgets(date_time_str, 20, msg_file); // read date/time of msg
- fgets(msg_caller_first, 20, msg_file); // read sender's first name
- fgets(msg_caller_last, 20, msg_file); // and his/her last name
- fgets(receiver, 35, msg_file); // and receiver's full name
- fgets(topic, 35, msg_file); // and the topic
- security = fgetc(msg_file); // and security type
- fclose(msg_file);
- //-------------------------------------------
- // only the sender, receiver, and sysop can
- // delete the message
- //-------------------------------------------
- if ((!strcmpi(current_caller_first, msg_caller_first) &&
- !strcmpi(current_caller_last, msg_caller_last)) ||
- (!strcmpi(current_caller_full, receiver)) || sysop_call){
- cmdstr = "ERASE ";
- strcat(cmdstr, tmp_fname);
- dos(cmdstr, 0);
- host_send("^M^JMessage #");
- host_send(strn);
- host_send(" has been deleted.^M^J");
- if (i == first_msg) { // the first message is deleted
- for (i = first_msg + 1; i <= last_msg; ++i)
- if (msg_exist(i)) {
- first_msg = i; // update first_msg
- i = last_msg + 1;
- }
- }
- else if (i == last_msg) { // the last message is deleted
- for (i = last_msg - 1; i >= first_msg; --i)
- if (msg_exist(i)) { // update last_msg
- last_msg = i;
- i = first_msg - 1;
- }
- }
- fstlst();
- } // if this caller can delete this message
- else {
- host_send("^M^JYou have no right to delete other people's message.^M^J");
- }
- } // message file open successfully
- else {
- host_send("^M^JThat message is not here. No way to delete it.^M^J");
- }
- } // delete_message
-
-
- //////////////////////////////////////////////////////////////////////////////
- // display_message
- // input value i is message number to display
- // return value: 0 if not read by caller
- // 1 if read by caller
- //////////////////////////////////////////////////////////////////////////////
-
- display_message(int i)
-
- {
- str msgnbr[5], strn[5], date_time_str[15];
- int msg_file, security, sec_pos, date_time;
- int lines_sent, ichar, isread = 0, k;
-
- tmp_fname = host_message; // get message directory
- if (i < 10) // if message number is smaller than 10 then
- msgnbr = "000"; // add three zeros for file name matching.
- else if (i < 100)
- msgnbr = "00";
- else if (i < 1000)
- msgnbr = "0";
- itos(i, strn); // convert message number to number string
- strcat(msgnbr, strn); // add zeros before this number
- strcat(tmp_fname, msgnbr); // now tmp_fname got the path & file name
- msg_file = fopen(tmp_fname, "r+"); // reading & writing
- if (msg_file != 0){ // file is opened successfully
- fgets(date_time_str, 20, msg_file); // read msg creating date/time
- date(stoi(date_time_str), date_str);
- time(stoi(date_time_str), time_str);
- fgets(msg_caller_first, 20, msg_file); // read sender's first name
- fgets(msg_caller_last, 20, msg_file); // and his/her last name
- fgets(receiver, 35, msg_file); // and receiver's full name
- fgets(topic, 35, msg_file); // and the topic
- sec_pos = ftell(msg_file); // get security code position
- security = fgetc(msg_file); // and security type
- if ((security & 127) == 'U') { // this message can be seen by everybody
- //-------------------------------------------------------
- // Everybody can see this message since it is registered
- // as "pUblic".
- //-------------------------------------------------------
- host_send("^M^J^M^JMessage No: ");
- if (ansi_mode)
- host_send(""); // message number, date, and time
- host_send(strn);
- if (ansi_mode)
- host_send(".");
- host_send(" ");
- host_send(date_str); host_send(" "); host_send(time_str);
- if (ansi_mode)
- host_send(" ");
- else
- host_send(" ");
- host_send("(Public)");
- if ((security & 128) == 128)
- host_send(" (Received)");
- if (ansi_mode)
- host_send("");
- host_send("^M^J From: ");
- if (ansi_mode)
- host_send(""); // public in cyan
- host_send(msg_caller_first); host_send(" ");
- host_send(msg_caller_last);
- if (ansi_mode) {
- host_send("^M^J To: "); // sender
- host_send(receiver);
- host_send("^M^J Topic: ");
- host_send(topic);
- host_send("");
- show_see_also(i);
- host_send("^M^J"); // contents of this message now...
- }
- else {
- host_send("^M^J To: "); // sender
- host_send(receiver);
- host_send("^M^J Topic: ");
- host_send(topic);
- show_see_also(i);
- host_send("^M^J"); // contents of this message now...
- }
- lines_sent = 7;
- fgets(linemsg, 80, msg_file); // read the first line...
- do {
- host_send(linemsg); // display it...
- host_send("^M^J");
- ++lines_sent;
- if (lines_sent >= 23) { // have we filled the whole screen?
- lines_sent = 0; // yes, so reset the counter
- host_send("-- More ?");
- k = host_input();
- host_send("^M ^M");
- if (finished_caller) { // if user inactivity
- fclose(msg_file);
- return;
- }
- if (k == 'N' || k == 'n') {
- fclose(msg_file);
- return;
- }
- }
- while (cinp_cnt()) { // if something is in comm buffer
- ichar = cgetc(); // then read it!
- if (ichar == '^C') { // is it a Ctrl-C ?
- host_send("^M^J"); // yes, so stop typing file
- fclose(msg_file);
- return;
- } // is it a Ctrl-C ?
- } // while something is in comm buffer
- fgets(linemsg, 80, msg_file); // read it...
- } while (!feof(msg_file)); // while not end-of-message
- isread = 1;
- name_to_reply = ""; // get name to reply in Reply
- strcat(name_to_reply, msg_caller_first);
- strcat(name_to_reply, " ");
- strcat(name_to_reply, msg_caller_last);
- topic_to_reply = topic;
- }
- else if ((security & 127) == 'P') { // this message is for private
- //-------------------------------------------------------
- // only if current caller is the sender or receiver can
- // he/she read this private message
- // However, SysOp can see ALL messages...
- //-------------------------------------------------------
- if ((!strcmpi(current_caller_first, msg_caller_first) &&
- !strcmpi(current_caller_last, msg_caller_last)) ||
- (!strcmpi(current_caller_full, receiver)) || sysop_call){
- host_send("^M^J^M^JMessage No: "); // message number, date, and time
- if (ansi_mode)
- host_send("");
- host_send(strn);
- if (ansi_mode)
- host_send(".");
- host_send(" ");
- host_send(date_str); host_send(" "); host_send(time_str); host_send(" ");
- if (ansi_mode)
- host_send("");
- host_send("(Private)");
- if ((security & 128) == 128)
- host_send(" (Received)");
- if (ansi_mode) {
- host_send("^M^J From: "); // private in blue
- host_send(msg_caller_first); host_send(" ");
- host_send(msg_caller_last);
- host_send("^M^J To: "); // the receiver
- host_send(receiver);
- host_send("^M^J Topic: ");
- host_send(topic);
- host_send("");
- show_see_also(i);
- host_send("^M^J"); // contents of this message now...
- }
- else {
- host_send("^M^J From: "); // private in blue
- host_send(msg_caller_first); host_send(" ");
- host_send(msg_caller_last);
- host_send("^M^J To: "); // the receiver
- host_send(receiver);
- host_send("^M^J Topic: ");
- host_send(topic);
- show_see_also(i);
- host_send("^M^J"); // contents of this message now...
- }
- lines_sent = 7;
- fgets(linemsg, 80, msg_file); // read the first line
- do {
- host_send(linemsg); // display it...
- host_send("^M^J");
- ++lines_sent;
- if (lines_sent >= 23) { // have we filled the whole screen?
- lines_sent = 0; // yes, so reset the counter
- host_send("-- More ?");
- k = host_input(); // wait for key press
- host_send("^M ^M");
- if (finished_caller) { // if user inactivity
- fclose(msg_file);
- return;
- }
- if (k == 'N' || k == 'n') {
- fclose(msg_file);
- return;
- }
- }
- while (cinp_cnt()) { // if something is in comm buffer
- ichar = cgetc(); // then read it!
- if (ichar == '^C') { // is it a Ctrl-C ?
- host_send("^M^J"); // yes, so stop typing file
- fclose(msg_file);
- return;
- } // is it a Ctrl-C ?
- } // while something is in comm buffer
- fgets(linemsg, 80, msg_file); // read it...
- } while (!feof(msg_file)); // while not end-of-message
- isread = 1;
- name_to_reply = "";
- strcat(name_to_reply, msg_caller_first);
- strcat(name_to_reply, " ");
- strcat(name_to_reply, msg_caller_last);
- topic_to_reply = topic;
- } // if this caller can read this message
- else { // access to private message is denied
- host_send("^M^JSorry! That's private message #");
- host_send(strn);
- host_send(".^M^J");
- }
- } // if this message is for PRIVATE
- if (security < 128) {
- if (!strcmpi(current_caller_full, receiver)) {
- security = security + 128;
- fseek(msg_file, sec_pos, 0);
- fputc(security, msg_file);
- }
- }
- fclose(msg_file);
- } // message file open successfully
- else {
- if (i < last_msg) {
- host_send("^M^JMessage #");
- host_send(strn);
- host_send(" does not exist.^M^J");
- }
- else
- host_send("^M^JNo more message.^M^J");
- }
- return isread;
- } // display_message
-
- //////////////////////////////////////////////////////////////////////////////
- // exist: test if a file is present
- // entry value: fname must include full path of that file
- // return value: 0 if file is not present
- // 1 if file is there
- //////////////////////////////////////////////////////////////////////////////
-
- exist(str fname)
-
- {
- int fh;
-
- fh = fopen(fname, "r"); // file handle is zero if no such file
- if (fh == 0) // no such file
- return 0;
- else { // file is there
- fclose(fh); // so close it
- return 1; // then return 1
- }
- } // test a file's existence
-
-
- //////////////////////////////////////////////////////////////////////////////
- // msg_exist: test if a message file is present
- // entry value: i
- // return value: 0 if file is not present
- // 1 if file is there
- //////////////////////////////////////////////////////////////////////////////
-
- msg_exist(int i)
-
- {
- str fname[20], nbr[5];
-
- fname = host_message;
- if (i < 10)
- strcat(fname, "000");
- else if (i < 100)
- strcat(fname, "00");
- else if (i < 1000)
- strcat(fname, "0");
- itos(i, nbr);
- strcat(fname, nbr);
- return(exist(fname));
-
- } // test a file's existence
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // show_see_also
- //
- //////////////////////////////////////////////////////////////////////////////
- show_see_also (int i)
-
- {
- str msgnbr[7], strn[7], fname[48];
- int msg_file;
-
- fname = host_message; // get message directory
- if (i < 10) // if message number is smaller than 10 then
- msgnbr = "000"; // add three zeros for file name matching.
- else if (i < 100)
- msgnbr = "00";
- else if (i < 1000)
- msgnbr = "0";
- itos(i, strn); // convert message number to number string
- strcat(msgnbr, strn); // add zeros before this number
- strcat(fname, msgnbr); // now fname got the path & file name
- strcat(fname, ".IDX");
- msg_file = fopen(fname, "r"); // open message file for reading only
- if (msg_file != 0) { // index file open successfully
- host_send("^M^J Also see: ");
- fgets(msgnbr, 5, msg_file);
- if (ansi_mode)
- host_send("");
- host_send(msgnbr); // display first reference
- if (ansi_mode)
- host_send("");
- do {
- if (fgets(msgnbr, 5, msg_file) != -1) {
- host_send(", ");
- if (ansi_mode)
- host_send("");
- host_send(msgnbr);
- if (ansi_mode)
- host_send("");
- }
- else
- break;
- } while (1);
- fclose(msg_file);
- }
- if (ansi_mode)
- host_send("");
- host_send("^M^J");
- } // show_see_also
-
- ask_ANSI()
-
- {
- int c;
- str strn[15];
-
- host_send("^M^JDo you use ANSI code? (Y/N) ");
- host_input_strn(strn, 10, 0);
- if (finished_caller) // finished_caller is set by host_input if
- return; // connection is lost.
- host_send("^M^J^M^JSession is set to ");
- if (toupper(subchr(strn, 0)) == 'Y'){
- ansi_mode = 1;
- host_send("ANSI mode.");
- }
- else if (toupper(subchr(strn, 0)) == 'N'){
- ansi_mode = 0;
- host_send("TTY mode.");
- }
- else {
- ansi_mode = 0;
- host_send("TTY mode.");
- }
- }
-
- disp_bar(int i)
- {
- int c;
- for (c = 0; c < i; ++c)
- host_send("-");
- }
-
-
- ////////////////////////////////////////////////////////////////////////////
- //
- // Check if the three directories of upload, download, and message are
- // there. If not there then return with -1 else return with 1
- //
- ////////////////////////////////////////////////////////////////////////////
-
- chkdir()
-
- {
-
- clear_scr(); // clear the screen
- //---------------------------------------------------------------
- // check the validity of upload, download, and message directory
- // if they are not valid then terminate the whole program
- //---------------------------------------------------------------
- if (!check_directories(host_downloads)) {
- prints("The default download directory is not found.");
- printsc("Please create a default download directory as: ");
- prints(host_downloads);
- prints("");
- prints("HOST terminated...");
- prints("");
- return -1; // this terminates the whole program
- }
-
- if (!check_directories(host_uploads)) {
- prints("The default upload directory is not found.");
- printsc("Please create a default upload directory as: ");
- prints(host_uploads);
- prints("");
- prints("HOST terminated...");
- prints("");
- return -1; // this terminates the whole program
- }
-
- if (!check_directories(host_message)) {
- prints("The default message directory is not found.");
- printsc("Please create a default message directory as: ");
- prints(host_message);
- prints("");
- prints("HOST terminated...");
- prints("");
- return -1; // this terminates the whole program
- }
-
- return 1; // all three directories are there
-
- } // main
-
-
- //////////////////////////////////////////////////////////////////////////////
- // check for the validity of upload/download directories
- // return value: 0 --> the default directories are not found
- // 1 --> the default directories are valid
- //////////////////////////////////////////////////////////////////////////////
-
- check_directories(str directory_name)
-
- {
- str s[64];
- int i, a;
-
- s = directory_name;
- i = strlen(s);
- if (i > 0) // first remove trailing slashes
- if (subchr(s, i - 1) == '\' || subchr(s, i - 1) == '/')
- setchr(s, i - 1, 0);
- //---------------------------------------------------------
- // if host_uploads directory string is not empty
- // and not a root-directory (C:) format then
- // check for file attribute of host_uploads directory...
- // if directory not found or not a directory then return 0
- //---------------------------------------------------------
- if (s && !(strlen(s) == 2 && subchr(s, 1) == ':')) {
- a = fileattr(s);
- if (a == -1 || !(a & 16))
- return 0;
- }
- return 1;
- } // check directories
-
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // initialize temporary storage files for this BBS
- //
- //////////////////////////////////////////////////////////////////////////////
-
- initfile()
-
- {
-
- int fhandle, i;
- str fmsg[100];
-
- //------------------------------------------
- // open a file for temporary storage of
- // message content.
- // fmsg is initialized to a string with 80
- // blanks.
- //------------------------------------------
- fhandle = fopen(temp_message, "w+"); // open file
- fmsg = ""; // set fmsg to exactly 80 characters
- for (i = 1; i <= 80; ++i)
- strcat(fmsg, " ");
- for (i = 1; i <= 80; ++i) // total 6400 characters written to disk
- fputs(fmsg, fhandle);
- fclose(fhandle); // close file
-
- } // initialize temporary storage file for entering message
-
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // show end_entering message function
- //
- //////////////////////////////////////////////////////////////////////////////
-
- endenter()
-
- {
-
- host_send("^M^J^M^J<Message> <Enter>^M^J");
- if (ansi_mode) {
- host_send("Abort ");
- host_send("Continue ");
- host_send("Insert ");
- host_send("Delete ");
- host_send("Edit ");
- host_send("Topic ");
- host_send("List ");
- host_send("Save: ");
- }
- else {
- host_send("(A)bort ");
- host_send("(C)ontinue ");
- host_send("(I)nsert ");
- host_send("(D)elete ");
- host_send("(E)dit ");
- host_send("(T)opic ");
- host_send("(L)ist ");
- host_send("(S)ave: ");
- }
-
- } // end entering message
-
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // show current date and time
- //
- //////////////////////////////////////////////////////////////////////////////
-
- showtime()
-
- {
- int date_time;
- int year, month, day;
- str strn[12];
-
- date_time = curtime();
-
- year = tyear(date_time);
- month = tmonth(date_time);
- day = tday(date_time);
-
- host_send("Today is ");
- if (month == 1)
- host_send("January ");
- else if (month == 2)
- host_send("February ");
- else if (month == 3)
- host_send("March ");
- else if (month == 4)
- host_send("April ");
- else if (month == 5)
- host_send("May ");
- else if (month == 6)
- host_send("June ");
- else if (month == 7)
- host_send("July ");
- else if (month == 8)
- host_send("August ");
- else if (month == 9)
- host_send("September ");
- else if (month == 10)
- host_send("October ");
- else if (month == 11)
- host_send("November ");
- else if (month == 12)
- host_send("December ");
- itos(day, strn);
- host_send(strn); // day
- host_send(", ");
- itos(year, strn);
- host_send(strn); // year
- host_send("^M^J^M^JCurrent time is ");
- time(date_time, strn);
- host_send(strn);
- host_send("^M^J^M^J");
-
- } // show time
-
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // show file command on screen
- //
- //////////////////////////////////////////////////////////////////////////////
-
- filecmd()
-
- {
-
- host_send("^M^J<File> ");
- if (ansi_mode) {
- host_send("List ");
- host_send("Type ");
- host_send("Upload ");
- host_send("Download ");
- host_send("Quit ? ");
- }
- else {
- host_send("(L)ist ");
- host_send("(T)ype ");
- host_send("(U)pload ");
- host_send("(D)ownload ");
- host_send("(Q)uit ? ");
- }
-
- } // file command
-
-
- //////////////////////////////////////////////////////////////////////
- //
- // update first-last-sysopread message number
- //
- //////////////////////////////////////////////////////////////////////
-
- fstlst()
-
- {
-
- str fname[25];
- int fh;
-
- fname = host_message;
- strcat(fname, fst_lst_msg); // fname = full path name of first_last msg file
- fh = fopen(fname, "w+");
-
- itos(first_msg, fname);
- strcat(fname, "^M^J");
- fwrite(fname, strlen(fname), fh); // write first msg number into file
-
- itos(last_msg, fname);
- strcat(fname, "^M^J");
- fwrite(fname, strlen(fname), fh); // write last msg number into file
-
- itos(sysop_last_read, fname);
- strcat(fname, "^M^J");
- fwrite(fname, strlen(fname), fh); // write last msg read number of sysop
-
- fclose(fh);
-
- } // fstlst
-
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // show message command on screen
- //
- //////////////////////////////////////////////////////////////////////////////
-
- msgcmd(int last_read)
-
- {
- str nbrstr[10];
-
- host_send("^M^J<Message> ");
- if (ansi_mode) {
- host_send("Messages are from #"); // display available msg
- itos(first_msg, nbrstr); // numbers from first to
- host_send(nbrstr); // last.
- host_send(" to ");
- itos(last_msg, nbrstr);
- host_send(nbrstr);
- host_send(". ");
- host_send("You last read #");
- itos(last_read, nbrstr);
- host_send(nbrstr);
- host_send(".^M^J");
- host_send("Scan ");
- host_send("Enter ");
- host_send("Check ");
- host_send("Non-stop ");
- host_send("Delete ");
- host_send("Reply ");
- host_send("Quit ");
- host_send("msg# ? ");
- }
- else {
- host_send("Messages are from #");
- itos(first_msg, nbrstr);
- host_send(nbrstr);
- host_send(" to ");
- itos(last_msg, nbrstr);
- host_send(nbrstr);
- host_send(". ");
- host_send("You last read #");
- itos(last_read, nbrstr);
- host_send(nbrstr);
- host_send(".^M^J");
- host_send("(S)can ");
- host_send("(E)nter ");
- host_send("(C)heck ");
- host_send("(N)on-stop ");
- host_send("(D)elete ");
- host_send("(R)eply ");
- host_send("(Q)uit ");
- host_send("msg(#) ? ");
- }
-
- } // msgcmd
-
-
- ////////////////////////////////////////////////////////////////////
- //
- // Reset user's remaining on-line time to 60 minutes
- //
- ////////////////////////////////////////////////////////////////////
- resetime()
-
- {
- printsc_trm("s"); // store cursor position
-
- box(9, 10, 54, 12, 3, 0, 3); // cyan background, double hor lines, single ver lines
-
- printsc_trm(", 13H");
- printsc("User's time has been reset to 60 minutes.");
-
- printsc_trm("u"); // restore cursor position
- } // reset user's time
-
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // This displays file transfer protocol to be used
- //
- ///////////////////////////////////////////////////////////////////////////
-
- showprot(str transfer_way)
-
- {
-
- host_send("^M^J^M^J<File> ");
- host_send(transfer_way);
-
- if (ansi_mode) {
-
- host_send("^M^JModem7 "); // Modem7
- host_send("SEAlink "); // SEALink
- host_send("Xmodem "); // XModem
- host_send("1k-Xmodem "); // 1k-XModem
- host_send("G-1k-Xmodem^M^J"); // 1k-XModem-g
-
- host_send("Ymodem "); // YModem
- host_send("YmodEm-g "); // Ymodem-G
- host_send("Zmodem "); // ZModem
- host_send("Telink "); // Telink
- host_send("Kermit^M^J"); // Kermit
-
- }
- else {
-
- host_send("^M^J(M)odem7 "); // Modem7
- host_send("(S)EAlink "); // SEALink
- host_send("(X)modem "); // XModem
- host_send("(1)k-Xmodem "); // 1k-XModem
- host_send("(G)-1k-Xmodem^M^J"); // 1k-XModem-g
-
- host_send("(Y)modem "); // YModem
- host_send("Ymod(E)m-g "); // Ymodem-G
- host_send("(Z)modem "); // ZModem
- host_send("(T)elink "); // Telink
- host_send("(K)ermit^M^J"); // Kermit
-
- }
- host_send("^M^JWhich protocol? ");
-
- } // show protocols
-
-
- //////////////////////////////////////////////////////////////////////
- //
- // Show user's data in a box
- //
- //////////////////////////////////////////////////////////////////////
-
- showuser()
-
- {
- printsc_trm("s"); // store cursor position
-
- box(9, 10, 50, 16, 3, 0, 3); // cyan background, double hor lines, single ver lines
-
- printsc_trm(", 13H");
- printsc("Name: ");
- printsc(current_caller_full);
-
- printsc_trm(", 13H");
- printsc("Age: ");
- printsc(user_age);
-
- printsc_trm(", 13H");
- printsc("Occupation: ");
- printsc(user_occupation);
-
- printsc_trm(", 13H");
- printsc("Location: ");
- printsc(user_location);
-
- printsc_trm(", 13H");
- printsc("Phone: ");
- printsc(user_phone);
-
- printsc_trm("u"); // restore cursor position
- } // show user's data
-
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // show system command on screen
- //
- //////////////////////////////////////////////////////////////////////////////
-
- syscmd()
-
- {
-
- host_send("^M^J<System> ");
- if (ansi_mode) {
- host_send("Page sysop ");
- host_send("Logon list ");
- host_send("Reset ");
- host_send("Shell ");
- host_send("ANSI ");
- host_send("Quit ? ");
- }
- else {
- host_send("(P)age sysop ");
- host_send("(L)ogon list ");
- host_send("(R)eset ");
- host_send("(S)hell ");
- host_send("(A)NSI ");
- host_send("(Q)uit ? ");
- }
-
- } // system command
-
-
- //////////////////////////////////////////////////////////////////
- //
- // show top level command on screen
- //
- //////////////////////////////////////////////////////////////////
-
- topcmd()
-
- {
- host_send("^M^J");
- if (ansi_mode) {
- host_send("File "); // File
- host_send("Message "); // Message
- host_send("System "); // System
- host_send("Bulletins "); // Bulletins
- host_send("Help "); // Help
- host_send("Goodbye ? "); // Good-bye
- }
- else {
- host_send("(F)ile "); // File
- host_send("(M)essage "); // Message
- host_send("(S)ystem "); // System
- host_send("(B)ulletins "); // Bulletins
- host_send("(H)elp "); // Help
- host_send("(G)oodbye ? "); // Good-bye
- }
- } // top level command
-