home *** CD-ROM | disk | FTP | other *** search
- From: shaw@stortek.stortek.com (Greg Shaw)
- Newsgroups: comp.sources.misc
- Subject: v44i006: rocat - Roman Catacombs BBS System v.0.75, Part06/09
- Date: 1 Aug 1994 12:09:04 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <31ja7g$b17@sparky.sterling.com>
- X-Md4-Signature: 9e72c66bc918cf56d90f029d6093e772
-
- Submitted-by: shaw@stortek.stortek.com (Greg Shaw)
- Posting-number: Volume 44, Issue 6
- Archive-name: rocat/part06
- Environment: Linux, GNU C++/libg++
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: rocat-0.75/config/bbsinfo rocat-0.75/examples/bbs.crontab
- # rocat-0.75/scripts/login.scr rocat-0.75/src/bbs.C
- # rocat-0.75/src/bbshdr.h rocat-0.75/src/bbsinfo.h
- # rocat-0.75/src/bbsipc.C rocat-0.75/src/errlog.C
- # rocat-0.75/src/errlogd.C rocat-0.75/src/filelock.C
- # rocat-0.75/src/filesupdate.C rocat-0.75/src/menu.C
- # rocat-0.75/src/menu.h rocat-0.75/src/moncon.C
- # rocat-0.75/src/user.h rocat-0.75/text/newuser.msg
- # Wrapped by kent@sparky on Mon Jul 11 22:22:52 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 6 (of 9)."'
- if test -f 'rocat-0.75/config/bbsinfo' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/config/bbsinfo'\"
- else
- echo shar: Extracting \"'rocat-0.75/config/bbsinfo'\" \(3899 characters\)
- sed "s/^X//" >'rocat-0.75/config/bbsinfo' <<'END_OF_FILE'
- X# this file contains the bbs pathing and machine information
- X# setup as you desire
- X# it should be in the format: NAME <tab> value
- X# blanks and lines starting with # are ignored
- X
- X# host where error logger is running
- X
- XLOGHOST manwe
- X
- X# host where sysop's watch program is running
- X
- XWATCHHOST manwe
- X
- X# upload to download ratio (7.0 is 7 downloads for each upload)
- X# negative numbers refers to how the ratio is done - if it's
- X# negative, then the ratio is enforced *BEFORE* the user downloads
- X# the ratio number of files (in the case of -7.0, he has to upload
- X# before he can download the 7 files possible.
- X# normal (aka positive) numbers refers to a normal upload ratio.
- X# meaning the ratio won't be enforced until after the even number
- X# of files has been downloaded (e.g. on the 8th file he wouldn't
- X# be able to download.
- X# set below to 1000 or some such number for no ratio.
- X
- XRATIO 7.0
- X
- X# default access level for a new user on the bbs
- X
- XDEFACL 100
- X
- X# default terminal type for new user on BBS
- X
- XDEFTERM ansi
- X
- X# time that a user's time limit is good for.
- X# this is the amount of time that a user may use his 60 minutes for.
- X# ex: if you set it to 24 hours, he gets 60 minutes every 24 hours.
- X
- XWAITTIME 12
- X
- X# credit chat time with sysop?
- X# 0 for false, 1 for true
- X
- XCREDITCHAT 1
- X
- X# credit upload time?
- X
- XCREDITUPLOADS 1
- X
- X# the pager to use on your system (use 'more' or 'less' or whatever
- X# you like. Note that the default user path must have this command
- X# available for it to be accessible. (e.g. if you have 'less' in
- X# /usr/local/bin, /usr/local/bin *MUST* be part of the default login path
- X# Note: Fully qualifying the path won't work. Only 15 chars are allocated
- X# to the 'pager' variable.
- X
- XSYSTEMPAGER more
- X
- X# login name of the sysop
- X
- XSYSOP shaw
- X
- X# the following flags determine whether to show the user the system.X
- X# (where X < 4) messages are shown to the user at each logon or only once
- X# if 1, message will be shown at initial logon only. 0 for every time
- X
- XSYSTEM1MSGONCE 0
- XSYSTEM2MSGONCE 0
- XSYSTEM3MSGONCE 0
- X
- X# sysop's chat hours. If the user hits 'chat' outside of these hours, he
- X# will be told you are not available and to leave a message.
- X# time is in military. 1900 is 7pm, 2200 is 10pm
- X
- XCHATON 0000
- XCHATOFF 2400
- X
- X# the below are the different things you can put on the command prompt
- X# line when at the end of a menu.
- X# turn on SHOWTIMELEFT to show the amount of time the user has left
- X# turn on SHOWVALIDKEYS to show the valid hot keys to the user
- X# USERPROMPT is the text that will prompt the user to hit a key.
- X# ex: with all turned on,
- X# (15 Minutes left) Command? (a,b,d,i,k,t) <--- user prompt here
- X
- XSHOWTIMELEFT 1
- XSHOWVALIDKEYS 1
- XUSERPROMPT Command?
- X
- X# the following determines the default card type for a new user
- XDEFCARD blue
- X
- X# the following determine the amount of time and downloads that a user
- X# may have for different access levels. Define as you wish.
- X# the format is this:
- X# card color, access level, timelimit, additional flags, amount of downloads per day
- X# flags is a hex value that will be added to the user's flags upon logon
- X# (e.g. for flag 12 on for additional access, it would be 400)
- X# a -1 value in a limit field means 'don't enforce'
- XREDCARD 100 20 0 0
- XBLUECARD 200 40 0 500
- XGREENCARD 200 40 1 500
- XWHITECARD 400 60 1 -1
- X# I don't use the below. Use them as you want.
- XGREYCARD 500 0 0 -1
- XPINKCARD 600 0 0 0
- XYELLOWCARD 700 0 0 0
- X# this is the sysop's card
- XBLACKCARD 10000 255 0 -1
- X
- X# location of the mail spool file
- XMAILSPOOL /usr/spool/mail
- X
- X# minimum wait time between new mail checks (in seconds)
- XMAILCHECK 30
- X
- X# 'talk' program for chatting with the SysOp
- XTALKPROG talk
- X
- X# show the user his 'fortune' upon logon?
- XSHOWFORTUNE 1
- X
- X# Number of minutes of inactivity before user logged out
- X# 0 for no inactivity
- XINACTIVITY 5
- X
- X# Max number of K the user may download with one batch
- XMAXK 2500
- X
- X# don't delete this line!
- END_OF_FILE
- if test 3899 -ne `wc -c <'rocat-0.75/config/bbsinfo'`; then
- echo shar: \"'rocat-0.75/config/bbsinfo'\" unpacked with wrong size!
- fi
- # end of 'rocat-0.75/config/bbsinfo'
- fi
- if test -f 'rocat-0.75/examples/bbs.crontab' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/examples/bbs.crontab'\"
- else
- echo shar: Extracting \"'rocat-0.75/examples/bbs.crontab'\" \(365 characters\)
- sed "s/^X//" >'rocat-0.75/examples/bbs.crontab' <<'END_OF_FILE'
- X# bbs crontab -- automatic bbs maintenance
- X#
- X# update file sections for new files
- X0 3 * * * setenv BBSDIR /bbs; /bbs/bin/fileutil -u
- X#
- X# update new files listing
- X1 3 * * * setenv BBSDIR /bbs; /bbs/bin/fileutil -n /bbs/text/system2.msg
- X#
- X# update most popular files listing
- X2 3 * * * setenv BBSDIR /bbs; /bbs/bin/fileutil -m /bbs/text/system3.msg
- END_OF_FILE
- if test 365 -ne `wc -c <'rocat-0.75/examples/bbs.crontab'`; then
- echo shar: \"'rocat-0.75/examples/bbs.crontab'\" unpacked with wrong size!
- fi
- # end of 'rocat-0.75/examples/bbs.crontab'
- fi
- if test -f 'rocat-0.75/scripts/login.scr' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/scripts/login.scr'\"
- else
- echo shar: Extracting \"'rocat-0.75/scripts/login.scr'\" \(4123 characters\)
- sed "s/^X//" >'rocat-0.75/scripts/login.scr' <<'END_OF_FILE'
- X#!/bin/sh
- X# this is the login script to be used for new user login
- X
- X# setup so that interrupt logs user out
- X
- Xtrap exit 2
- Xtrap exit 3
- X
- Xstty erase
- XBBSDIR=/bbs
- XSYSOP="shaw"
- X
- Xexport BBSDIR SYSOP
- X
- Xif [ "$BBSDIR" = "" ]
- Xthen echo "BBSDIR environment variable not set."
- X exit
- Xfi
- X
- Xif [ "$SYSOP" = "" ]
- Xthen echo "SYSOP environment variable not set."
- X exit
- Xfi
- X
- Xecho "Welcome to the Roman Catacombs!"
- X
- X# give them a chance to leave mail to the sysop if they're having problems
- X
- Xecho "Before we begin, do you already have an account and are calling"
- Xecho -n "in due to problems with your account? "
- Xread yesno
- Xcase $yesno
- Xin
- X y|Y|Yes|yes|YES)
- X echo -n "What is your name? "
- X read username
- X echo "Since the SysOp cannot leave you mail that you can read (after all, you can't"
- X echo "log on), please enter a phone number where you may be reached."
- X echo -n "Your phone number? "
- X read phonenum
- X echo "Thank you. "
- X echo "You may enter your message now. Type a <ctrl-d> on a line by itself"
- X echo "to save the message."
- X /usr/bin/mailx -s "$username $phonenum" $SYSOP
- X echo "Thank you for calling! Goodbye!"
- X exit ;; # send mail and exit
- Xesac
- X
- X# give them the welcome message
- X
- Xmore $BBSDIR/text/bbswelcome
- X
- Xecho -n "Would you like to become a participant in the Roman Catacombs? "
- Xread yesno
- Xcase $yesno
- Xin
- X y|Y|Yes|yes|YES)
- X /bin/true ;; # don't do anything
- X *)
- X echo "I'm sorry you chose not to become a participant."
- X echo
- X echo Thank you for calling! Goodbye!
- X sleep 2
- X exit ;;
- Xesac
- X
- Xecho "It would be a good idea to turn your caps lock off for the BBS."
- Xecho "When you type in your name, if you name should be more than two"
- Xecho "words, enter them as two words. Example: John Von Cantle would"
- Xecho "be John VonCantle."
- X
- Xfound="0"
- Xwhile [ "$found" -ne "1" ]
- Xdo
- X echo -n "What is your first name? "
- X read firstname
- X if [ "`grep -i "$firstname" $BBSDIR/text/badwords`" != "" ]
- X then
- X echo -n "You have entered "
- X echo $firstname
- X echo "Which contains a restricted word."
- X echo "Due to this, you will have to log back in with a different name."
- X echo "Goodbye! Call back soon!"
- X sleep 2
- X exit
- X fi
- X found="`echo $firstname | wc -w`"
- Xdone
- X
- Xfound="0"
- Xwhile [ "$found" -ne "1" ]
- Xdo
- X echo -n "What is your last name? "
- X read lastname
- X if [ "`grep -i "$lastname" $BBSDIR/text/badwords`" != "" ]
- X then
- X echo -n "You have entered "
- X echo $lastname
- X echo "Which contains a restricted word."
- X echo "Due to this, you will have to log back in with a different name."
- X echo "Goodbye! Call back soon!"
- X sleep 2
- X exit
- X fi
- X found="`echo $lastname | wc -w`"
- Xdone
- X
- X# now build a user login with parts of the user's name
- X
- Xnumfchars=1
- Xfound="0"
- Xwhile [ "$found" != "" ]
- Xdo
- X firstinit=`echo $firstname | tr "[A-Z]" "[a-z]" | cut -c1-$numfchars`
- X restname=`echo $lastname | tr "[A-Z]" "[a-z]"`
- X userid=`echo $firstinit$restname`
- X tmp=`echo $userid | cut -c1-8`
- X userid=$tmp
- X found=`grep "^$userid:" /etc/passwd`
- X tmp=`echo dummy | awk "{ print ++x }" x=$numfchars -`
- X numfchars=$tmp
- Xdone
- X
- Xfullname="$firstname $lastname"
- X
- Xecho
- Xecho "Your login id for the Roman Catacombs will be:"
- Xecho
- Xecho "$userid"
- Xecho
- Xecho "Please write your login id down."
- Xecho "Note: it must be typed exactly as shown, in lower case."
- Xecho "The next time you log on, instead of typing 'new',"
- Xecho "type in your login id."
- Xecho
- Xecho "Press return when you have written your login down."
- Xread dummy
- X
- X/bbs/scripts/addbbsuser $userid "$fullname" $BBSDIR/bbs
- X
- Xecho
- Xecho "We will now setup a password for your new account."
- Xecho "Please type in your password now."
- Xfound="0"
- X# passwords will be '!' or a encoded password
- X# this assumes that encoded passwords are longer than 1 char
- Xwhile [ "$found" -le "2" ]
- Xdo
- X passwd $userid
- X found=`fgrep $userid /etc/passwd | cut -f2 -d":" | wc -c`
- Xdone
- X
- X# now enter the bbs itself
- X
- Xecho
- Xecho "Now that we have set up your user account, you must"
- Xecho "log in with that account for further access to the"
- Xecho "Roman Catacombs. After I hang up, you may call "
- Xecho "back immediately to access your new account."
- X
- Xecho
- Xecho "Goodbye!"
- X
- X# sleep to allow output to drain
- Xsleep 2
- X
- Xexit
- END_OF_FILE
- echo shar: 1 control character may be missing from \"'rocat-0.75/scripts/login.scr'\"
- if test 4123 -ne `wc -c <'rocat-0.75/scripts/login.scr'`; then
- echo shar: \"'rocat-0.75/scripts/login.scr'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/scripts/login.scr'
- # end of 'rocat-0.75/scripts/login.scr'
- fi
- if test -f 'rocat-0.75/src/bbs.C' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/src/bbs.C'\"
- else
- echo shar: Extracting \"'rocat-0.75/src/bbs.C'\" \(10843 characters\)
- sed "s/^X//" >'rocat-0.75/src/bbs.C' <<'END_OF_FILE'
- X// Filename: bbs.C
- X// Contents: the main bbs program (main)
- X// Author: Greg Shaw
- X// Created: 7/28/93
- X
- X/*
- X This file is free software; you can redistribute it and/or modify it
- Xunder the terms of the GNU General Public License as published by the
- XFree Software Foundation; either version 2, or (at your option) any
- Xlater version.
- X
- XIn addition to the permissions in the GNU General Public License, the
- XFree Software Foundation gives you unlimited permission to link the
- Xcompiled version of this file with other programs, and to distribute
- Xthose programs without any restriction coming from the use of this
- Xfile. (The General Public License restrictions do apply in other
- Xrespects; for example, they cover modification of the file, and
- Xdistribution when not linked into another program.)
- X
- XThis file is distributed in the hope that it will be useful, but
- XWITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- XGeneral Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with this program; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#ifndef _BBS_C_
- X#define _BBS_C_
- X
- X#include "bbshdr.h"
- X
- X// the user object is defined globally so that the menu object can access
- X// it via extern
- Xmoncon mon_obj;
- XUser user;
- X
- X// Function: getout
- X// Purpose: get out of the bbs system. Quick and dirty
- X// Author: Greg Shaw
- X// Created: 8/16/93
- X
- Xvoid getout(int sig)
- X{
- X char tmpstr[255]; // temporary string
- X static int inalready=0; // if already in, don't do again
- X
- X if (sig == SIGINT) // don't exit on interrupt
- X return;
- X if (!inalready)
- X {
- X sprintf(tmpstr,"Got signal %d",sig);
- X user.ap_log(tmpstr);
- X inalready++;
- X user.save(NULL);
- X sprintf(tmpstr,"(hangup) Logoff for %s %s",user.fname,user.lname);
- X user.ap_log(tmpstr);
- X if (mon_obj.watching())
- X {
- X sprintf(tmpstr,"Logoff for %s %s.\n",user.fname,user.lname);
- X mon_obj.send(tmpstr);
- X }
- X exit(0); // exit to OS
- X inalready = 0;
- X }
- X}
- X
- Xmain() // no command line inputs at this time
- X{
- X char tmpstr[255]; // temporary string
- X char *bbsdir; // bbs 'home' directory
- X char curmenu[MENU_NAME_LEN]; // current menu
- X char prevmenu[MENU_NAME_LEN]; // previous menu (should a menu not be found)
- X char menustack[MENU_STACK_SIZE][MENU_NAME_LEN];
- X int stacktop; // current stack top
- X int bootuser; // kick user out?
- X int x; // counter
- X int done; // done inside bbs?
- X int newuser; // is it a the first logon for this user?
- X int credit; // credited minutes for upload
- X float uldlratio; // download/upload ratio
- X files fileobj; // files upload/download object
- X Menu menu;
- X Menuitem *result; // result of menu run
- X time_t now; // current time
- X struct tm *tnow; // current time (structure)
- X User tmpuser; // temporary user object for sysop editing
- X
- X
- X // get the user (or get user's information)
- X stacktop = 0; // stack empty
- X bootuser = 0;
- X if (newuser = user.get(NULL), newuser == -1)
- X {
- X menu.ap_log("Unable to get user.");
- X return(0);
- X }
- X // turn on signal handlers so that hangup and such caught
- X for (x=1; x<15; x++)
- X signal(x,&getout);
- X if (mon_obj.watching())
- X {
- X sprintf(tmpstr,"Logon for %s %s.\n",user.fname,user.lname);
- X mon_obj.send(tmpstr);
- X }
- X // display welcome text file
- X if (bbsdir = getenv("BBSDIR"), bbsdir == NULL)
- X {
- X printf("BBSDIR environment variable not set.\r\n");
- X return(0);
- X }
- X strcpy(tmpstr,bbsdir); // get bbsdir
- X strcat(tmpstr,"/text/welcome"); // get 'welcome file path'
- X menu.display_file(tmpstr,0);
- X user.display_info(1); // display user info with 'Welcome back' msg.
- X if (!newuser)
- X {
- X strcpy(tmpstr,bbsdir); // get bbsdir
- X strcat(tmpstr,"/text/newuser.msg");// get newuser file path
- X menu.display_file(tmpstr,1); // display newuser file
- X }
- X for (x=1; x<4; x++) // display all system messages if applicable
- X {
- X if (!(user.sys_msg_once(x) && ((1<<x | SYSMSGFLAGS) & user.u_flags())))
- X { // not sys_msg_once so show him system message
- X sprintf(tmpstr,"%s/text/system%d.msg",bbsdir,x);
- X menu.display_file(tmpstr,1);
- X }
- X }
- X // check for mail
- X if (user.mailavail())
- X {
- X user.cr();
- X user.sstrcr("You have mail.");
- X user.cr();
- X user.waitcr();
- X // add something here for reading mail at logon
- X }
- X strcpy(prevmenu,"main");
- X strcpy(curmenu,"main");
- X if (menu.open("main") != 0)
- X {
- X menu.ap_log("Unable to open main menu.\r\n");
- X return(0);
- X }
- X if (user.showfortune())
- X {
- X user.sysint("fortune");
- X menu.waitcr();
- X }
- X done = 0;
- X while (!done)
- X {
- X if (user.mailavail())// new mail?
- X {
- X user.clear();
- X user.sstrcr("You have mail.");
- X user.cr();
- X user.waitcr();
- X // add something here to read mail
- X }
- X if (user.u_uploads() == 0)
- X uldlratio = (float)user.u_downloads()/(float)-1;
- X else
- X uldlratio = (float)user.u_downloads()/(float)user.u_uploads();
- X while (result = menu.run(curmenu), result == NULL); // run menu till something selected
- X switch(result->com_type)
- X {
- X default:
- X case -1: // boot the user due to timeout or out of time
- X done++;
- X bootuser++;
- X break;
- X case 0: // do nothing
- X break;
- X case 1: // logout of bbs
- X user.cr();
- X user.sstr("Are you sure you want to log off? ");
- X if (user.yesno())
- X done++;
- X break;
- X case 2: // branch to (another) menu
- X strcpy(prevmenu,curmenu);
- X strcpy(curmenu,result->misc); // get new menu name
- X if (menu.open(curmenu) != 0)
- X {
- X sprintf(tmpstr,"Unable to open menu %s.",result->misc);
- X menu.ap_log(tmpstr);
- X strcpy(curmenu,prevmenu); // get new menu name
- X if (menu.open(curmenu) != 0)
- X {
- X sprintf(tmpstr,"PANIC: Unable to open menu %s.",prevmenu);
- X menu.er_log(tmpstr);
- X }
- X }
- X else
- X {
- X strcpy(menustack[stacktop++],prevmenu);// get new menu name
- X }
- X break;
- X case 3: // exit to previous menu
- X if (stacktop > 0)
- X {
- X strcpy(prevmenu,curmenu);
- X strcpy(curmenu,menustack[--stacktop]);
- X if (menu.open(curmenu) != 0)
- X {
- X sprintf(tmpstr,"Unable to open menu %s.",result->misc);
- X menu.ap_log(tmpstr);
- X strcpy(curmenu,prevmenu); // get last menu
- X if (menu.open(curmenu) != 0)
- X {
- X sprintf(tmpstr,"PANIC: Unable to open menu %s.",prevmenu);
- X menu.er_log(tmpstr);
- X }
- X }
- X }
- X break;
- X case 4: // search userlog for user information
- X user.list(1,0);
- X break;
- X case 5: // list users in userlog
- X user.list(0,0);
- X break;
- X case 6: // display user information and access level
- X user.display_info(0); // display user info w/o 'Welcome back' msg.
- X break;
- X case 7: // modify user setup
- X user.getinfo(0);
- X break;
- X case 8: // chat with sysop (via talk)
- X user.clear();
- X time(&now);
- X tnow = localtime(&now);
- X x = tnow->tm_hour * 100;
- X x += tnow->tm_min;
- X if (user.chat_avail(x))
- X {
- X user.sstrcr("Attempting to chat...");
- X user.cr();
- X user.sstrcr("Press ctrl-C to exit chat.");
- X user.waitcr();
- X sprintf(tmpstr,"%s %s",user.talkprog(), user.sysop());
- X user.sysint(tmpstr);
- X }
- X else
- X {
- X user.sstrcr("I'm sorry, but the sysop is not available for chat.");
- X user.sstrcr("Please try leaving feedback.");
- X user.waitcr();
- X }
- X break;
- X case 10: // display file, paged
- X sprintf(tmpstr,"%s/text/%s",bbsdir,result->misc);
- X menu.display_file(tmpstr,1);
- X break;
- X case 11: // display file, not paged
- X sprintf(tmpstr,"%s/text/%s",bbsdir,result->misc);
- X menu.display_file(tmpstr,0);
- X break;
- X case 21: // call shell to launch external
- X menu.clear();
- X sprintf(tmpstr,"Executing %s\n",result->misc);
- X mon_obj.send(tmpstr);
- X strcpy(tmpstr,result->misc);
- X user.sysint(tmpstr);
- X break;
- X case 25: // list new files with option to download
- X fileobj.open(result->misc,user.usercard());
- X x = fileobj.list(1,user.usercard(),&user.kused,user.last_logon(),uldlratio);
- X if (x > 0)
- X user.inc_downloads(x);
- X break;
- X case 26: // list new files without option to download
- X fileobj.open(result->misc,user.usercard());
- X fileobj.list(0,user.usercard(),&user.kused,user.last_logon(),uldlratio);
- X break;
- X case 27: // list all files with option to download
- X fileobj.open(result->misc,user.usercard());
- X x = fileobj.list(1,user.usercard(),&user.kused,0L,uldlratio);
- X if (x > 0)
- X user.inc_downloads(x);
- X break;
- X case 28: // list all files without option to download
- X fileobj.open(result->misc,user.usercard());
- X fileobj.list(0,user.usercard(),&user.kused,0L,uldlratio);
- X break;
- X case 29: // search for string in files area with option
- X fileobj.open(result->misc,user.usercard());
- X x = fileobj.search(1);
- X if (x > 0)
- X user.inc_downloads(x);
- X break;
- X case 30: // search for string in files area w/o option
- X fileobj.open(result->misc,user.usercard());
- X fileobj.search(0);
- X break;
- X case 31: // view detailed information on file
- X fileobj.open(result->misc,user.usercard());
- X fileobj.info(NULL,NULL,NULL);
- X user.waitcr();
- X break;
- X case 32: // download files
- X fileobj.open(result->misc,user.usercard());
- X x = fileobj.one_download(&user.kused, uldlratio,NULL,1);
- X if (x > 0)
- X user.inc_downloads(x);
- X break;
- X case 33: // upload files
- X fileobj.open(result->misc,user.usercard());
- X x = fileobj.upload(user.logname(),user.editorname(), &credit);
- X if (x > 0)
- X user.inc_uploads(x);
- X if (credit > 0 && user.credituploads())
- X user.inc_credit(x);
- X break;
- X case 34: // delete a file (that you uploaded)
- X break;
- X case 35: // download a particular file (with ratio checking
- X x = fileobj.one_download(&user.kused,uldlratio,result->misc,1);
- X if (x > 0)
- X user.inc_downloads(x);
- X break;
- X case 36: // download a particular file (without ratio checking
- X fileobj.one_download(&user.kused,uldlratio,result->misc,0);
- X break;
- X // sysop specific commands follow
- X case 40: // search for users for edit/delete
- X tmpuser.list(1,1);
- X break;
- X case 41: // delete inactive users from the BBS
- X tmpuser.inactive_delete();
- X break;
- X case 42: // list inactive users
- X tmpuser.inactive_list();
- X break;
- X case 43: // list users for edit/delete
- X tmpuser.list(0,1);
- X break;
- X }
- X }
- X // display logoff message
- X menu.clear();
- X strcpy(tmpstr,bbsdir); // get bbsdir
- X strcat(tmpstr,"/text/logoff"); // get logoff menu
- X if (!bootuser)
- X menu.display_file(tmpstr,0);
- X menu.cr();
- X menu.cr();
- X menu.cr();
- X menu.cr();
- X sprintf(tmpstr,"rocat BBS System for Unix(tm) version %s",VERSION);
- X menu.sstrcr(tmpstr);
- X menu.sstrcr("copyright (C) 1994 by Gregory Shaw and fmSoft, Inc. All Rights Reserved.");
- X menu.sstrcr("rocat BBS support available at The Roman Catacombs (303) 429-8914");
- X user.save(NULL);
- X sprintf(tmpstr,"Logoff for %s %s",user.fname,user.lname);
- X user.ap_log(tmpstr);
- X if (mon_obj.watching())
- X {
- X sprintf(tmpstr,"Logoff for %s %s.\n",user.fname,user.lname);
- X mon_obj.send(tmpstr);
- X }
- X sleep(1);
- X return(0);
- X};
- X
- X#endif // _BBS_C_
- END_OF_FILE
- if test 10843 -ne `wc -c <'rocat-0.75/src/bbs.C'`; then
- echo shar: \"'rocat-0.75/src/bbs.C'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/src/bbs.C'
- # end of 'rocat-0.75/src/bbs.C'
- fi
- if test -f 'rocat-0.75/src/bbshdr.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/src/bbshdr.h'\"
- else
- echo shar: Extracting \"'rocat-0.75/src/bbshdr.h'\" \(3769 characters\)
- sed "s/^X//" >'rocat-0.75/src/bbshdr.h' <<'END_OF_FILE'
- X// Filename: bbshdr.h
- X// Purpose: a general repository for standard and system includes
- X// Author: Greg Shaw
- X// Created: 6/1/93
- X
- X/*
- XThis file is free software; you can redistribute it and/or modify it
- Xunder the terms of the GNU General Public License as published by the
- XFree Software Foundation; either version 2, or (at your option) any
- Xlater version.
- X
- XIn addition to the permissions in the GNU General Public License, the
- XFree Software Foundation gives you unlimited permission to link the
- Xcompiled version of this file with other programs, and to distribute
- Xthose programs without any restriction coming from the use of this
- Xfile. (The General Public License restrictions do apply in other
- Xrespects; for example, they cover modification of the file, and
- Xdistribution when not linked into another program.)
- X
- XThis file is distributed in the hope that it will be useful, but
- XWITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- XGeneral Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with this program; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#ifndef _BBSHDR_H_
- X#define _BBSHDR_H_
- X
- X// bbs definitions
- X
- X
- X#define MAX_FILES 20 // maximum open files available
- X#define MAX_LOCK_TRIES 3 // try 3 times for file lock
- X#define MAX_FILENAMELENGTH 30 // max filename size
- X // most filenames are < 30 chars
- X#define MAX_DL_COMMANDS 15 // max number of dl protocols
- X // found in $BBSDIR/config/protocols
- X#define ERR_LOG_PATH "/bbs/admin/bbserr" // error logger file path
- X
- X// posix doesn't define the u_type shortcuts. internetworking does. So ...
- X
- X#ifndef u_short
- X#define u_short unsigned short
- X#define u_long unsigned long
- X#define u_char unsigned char
- X#define u_float unsigned float
- X#endif
- X
- X// system includes
- X
- X#include <stdio.h> // standard output
- X#include <ctype.h> // standard isxxxx functions
- X#include <stdarg.h> // arguments from command line
- X#include <fcntl.h> // file control
- X#include <assert.h> // assert system call (for sanity checking)
- X#include <termio.h> // non blocking read system calls
- X#include <string.h> // string functions
- X#include <limits.h> // system data limits
- X#include <sys/types.h> // system types
- X#include <sys/time.h> // time and date
- X#include <rpc/types.h> // system rpc types
- X#include <sys/stat.h> // the stat() (status) system call
- X#include <errno.h> // standard errors (+ perror)
- X#include <signal.h> // signal handling routines
- X#include <sys/socket.h> // internet socket ipc interface
- X#include <stdlib.h> // standard libraries
- X#include <sys/wait.h> // wait
- X#include <sys/utsname.h> // system name
- X#include <netinet/in.h> // more socket definitions
- X#include <netdb.h> // ??
- X#include <unistd.h> // standard unix (not covered elsewhere)
- X#include <pwd.h> // password file reading routines
- X#include <dirent.h> // directory reading routines
- X#include <math.h> // math (float) routines
- X
- X// bbs specific includes
- X#include "version.h" // bbs version
- X#include "bbsipc.h" // bbs ipc object
- X#include "bbsinfo.h" // generic bbs information
- X#include "ports.h" // port connection definitions
- X#include "errlog.h" // error logger (object and daemon)
- X#include "filelock.h" // automatic file locking
- X#ifndef _SERVER_
- X#include "sysexec.h" // sub-process execution
- X#include "bbsint.h" // bbs input/output interface
- X#include "user.h" // user object definitions
- X#include "menu.h" // menu system
- X#include "bbs.h" // bbs top level definitions
- X#include "dllist.h" // doubly linked list section
- X#include "files.h" // files section
- X#endif
- X#include "moncon.h" // monitor connection object
- X
- X#endif // _BBSHDR_H_
- END_OF_FILE
- if test 3769 -ne `wc -c <'rocat-0.75/src/bbshdr.h'`; then
- echo shar: \"'rocat-0.75/src/bbshdr.h'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/src/bbshdr.h'
- # end of 'rocat-0.75/src/bbshdr.h'
- fi
- if test -f 'rocat-0.75/src/bbsinfo.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/src/bbsinfo.h'\"
- else
- echo shar: Extracting \"'rocat-0.75/src/bbsinfo.h'\" \(3624 characters\)
- sed "s/^X//" >'rocat-0.75/src/bbsinfo.h' <<'END_OF_FILE'
- X// Filename: bbsinfo.h
- X// Contents: the bbs information object
- X// Author: Greg Shaw
- X// Created: 7/11/93
- X
- X/*
- X
- XThis file is free software; you can redistribute it and/or modify it
- Xunder the terms of the GNU General Public License as published by the
- XFree Software Foundation; either version 2, or (at your option) any
- Xlater version.
- X
- XIn addition to the permissions in the GNU General Public License, the
- XFree Software Foundation gives you unlimited permission to link the
- Xcompiled version of this file with other programs, and to distribute
- Xthose programs without any restriction coming from the use of this
- Xfile. (The General Public License restrictions do apply in other
- Xrespects; for example, they cover modification of the file, and
- Xdistribution when not linked into another program.)
- X
- XThis file is distributed in the hope that it will be useful, but
- XWITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- XGeneral Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with this program; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#ifndef _BBSINFO_H_
- X#define _BBSINFO_H_
- X
- X// Structure: card_color
- X// Contents: the information that defines a card 'level'
- X// Author: Greg Shaw
- X// Created: 7/27/93
- X
- Xtypedef struct
- X{
- X char colr[10]; // card color
- X int acl; // minimum acl for that level
- X int tl; // minimume tl for level
- X int flags; // additional flags for level (or'd into user flags)
- X int kbytes; // how many kbytes per period user may download
- X} CardRec;
- X
- X// Object: bbsinfo
- X// Purpose: return some information that is setup-specific (and could
- X// change, so hard-coding isn't an option)
- X// Attributes: none
- X// Methods:
- X// loghost - return the name of the loghost
- X// watchost - return the name of the sysop watcher daemon
- X// ratio - return the required upload/download ratio
- X// def_acl - return the default BBS access level
- X// def_termtype - return the default terminal type
- X// Author: Greg Shaw
- X// Created: 7/11/93
- X
- Xclass bbsinfo
- X{
- X int findline(char *line, char *word); // find line with keyword
- Xpublic:
- X CardRec *cardinfo(int type); // return card info for card type passed in
- X int creditchat(void); // is chat time credited?
- X int credituploads(void); // is upload time credited?
- X int chat_avail(int tim); // is sysop available for chat?
- X char *loghost(void); // error logging daemon
- X int def_card(void); // default card color
- X char *def_termtype(void); // default terminal type
- X float ratio(void); // upload to download ratio
- X char *sysop(void); // return sysop's name
- X int sys_msg_once(int num); // display (num) system msg once?
- X char *sys_pager(void); // default system pager
- X int waittime(void); // time between logons allowed for users
- X char *watchhost(void); // sysop watcher daemon
- X char *userprompt(void); // the prompt for at the end of a menu
- X char *mailspool(void); // system mail spool file
- X int showtime(void); // show user timeleft
- X int showcoms(void); // show user valid command keys
- X int showfortune(void); // show user fortune upon logon?
- X int inactivity_timeout(void); // time before user booted
- X int maxk(void); // max # of K user can download at one time
- X int mailchecktime(void); // minimum # of seconds between new mail checks
- X char *talkprog(void); // return the system 'talk' program
- X uid_t bbs_uid(void); // return bbs uid
- X gid_t bbs_gid(void); // return bbs uid
- X char *username(void); // return name of current user
- X};
- X
- X#endif // _BBSINFO_H_
- END_OF_FILE
- if test 3624 -ne `wc -c <'rocat-0.75/src/bbsinfo.h'`; then
- echo shar: \"'rocat-0.75/src/bbsinfo.h'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/src/bbsinfo.h'
- # end of 'rocat-0.75/src/bbsinfo.h'
- fi
- if test -f 'rocat-0.75/src/bbsipc.C' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/src/bbsipc.C'\"
- else
- echo shar: Extracting \"'rocat-0.75/src/bbsipc.C'\" \(9008 characters\)
- sed "s/^X//" >'rocat-0.75/src/bbsipc.C' <<'END_OF_FILE'
- X// Filename: bbsipc.C
- X// Contents: the bbs IPC object
- X// Author: Greg Shaw
- X// Created: 6/13/93
- X
- X/*
- XThis file is free software; you can redistribute it and/or modify it
- Xunder the terms of the GNU General Public License as published by the
- XFree Software Foundation; either version 2, or (at your option) any
- Xlater version.
- X
- XIn addition to the permissions in the GNU General Public License, the
- XFree Software Foundation gives you unlimited permission to link the
- Xcompiled version of this file with other programs, and to distribute
- Xthose programs without any restriction coming from the use of this
- Xfile. (The General Public License restrictions do apply in other
- Xrespects; for example, they cover modification of the file, and
- Xdistribution when not linked into another program.)
- X
- XThis file is distributed in the hope that it will be useful, but
- XWITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- XGeneral Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with this program; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#ifndef _BBSIPC_C_
- X#define _BBSIPC_C_
- X
- X#undef DEBUG
- X
- X#include "bbshdr.h" // include *EVERYTHING*
- X
- X// Function: bbsipc constructor
- X// Purpose: initialize the bbs ipc object.
- X// Inputs: none
- X// Outputs: none - constructor may not return values
- X// Author: Greg Shaw
- X// Created: 6/13/93
- X
- Xbbsipc::bbsipc()
- X{
- X server = 0; // server mode
- X hostname[0] = 0; // host name
- X sock_open = 0; // open socket
- X sock_fd = 0; // socket file descriptor
- X serv_sock_fd = 0; // server socket file descriptor
- X sockt = 0; // socket number
- X connected = 0; // not connected
- X}
- X
- X// Function: bbsipc destructor
- X// Purpose: clean up the bbsipc object (close socket)
- X// Inputs: none
- X// Outputs: none
- X// Author: Greg Shaw
- X// Created: 6/16/93
- X
- Xbbsipc::~bbsipc()
- X{
- X close_sock(0);
- X};
- X
- X// Function: close_sock
- X// Purpose: close the sockets (if open)
- X// Inputs: none
- X// Outputs: none
- X// Author: Greg Shaw
- X// Created: 6/16/93
- X
- Xint bbsipc::close_sock(int client_only)
- X{
- X if (sock_open)
- X close(sock_fd);
- X if (!client_only)
- X {
- X if (server)
- X close(serv_sock_fd);
- X server = 0;
- X sock_open = 0;
- X }
- X connected = 0;
- X return(0);
- X};
- X
- X// Function: open_sock
- X// Purpose: open a socket for reading, writing or as a server.
- X// Inputs: name - name of host to contact (NULL for server mode)
- X// socknum - the socket number to contact
- X// Outputs: -1 for error
- X// Author: Greg Shaw
- X// Created: 6/16/93
- X
- Xint bbsipc::open_sock(char *name, int socknum)
- X{
- X char macname[MAXHOSTNAMELEN+1]; // system information
- X struct sockaddr_in sa; // socket information
- X struct hostent *hp; // host entry information
- X
- X sockt = socknum; // save socket number
- X if (name == NULL) // server mode?
- X {
- X#ifdef DEBUG
- X fprintf(stderr,"creating server socket.\r\n");
- X#endif
- X // yup, create socket
- X server = 1;
- X memset(&sa, 0, sizeof(struct sockaddr_in)); // nuke sa contents
- X gethostname(macname,MAXHOSTNAMELEN); // get this host's name
- X hp = gethostbyname(macname); // get host info
- X if (hp == NULL) // no info for me?
- X {
- X fprintf(stderr,"Unable to get host name.\n");
- X return(-1); // get out
- X }
- X sa.sin_family = hp->h_addrtype; // set host address
- X sa.sin_port= htons(socknum); // set port number
- X // create new socket
- X if ((serv_sock_fd = socket(AF_INET, SOCK_STREAM,0)) < 0)
- X {
- X fprintf(stderr,"Unable to open socket.\n");
- X return(-1); // can't create socket
- X }
- X if (bind(serv_sock_fd,(struct sockaddr *)&sa,(int)sizeof(sa)) < 0)
- X {
- X close(serv_sock_fd);
- X fprintf(stderr,"Unable to bind socket.\n");
- X return(-1);
- X }
- X listen(serv_sock_fd,5); // 5 pending connections max
- X sock_open = 1;
- X }
- X else
- X { // connect to socket
- X#ifdef DEBUG
- X printf("attempting to connect client socket.\r\n");
- X#endif
- X strcpy(hostname, name);
- X server = 0;
- X if ((hp = gethostbyname(hostname)) == NULL) // get host addr
- X {
- X#ifdef DEBUG
- X printf("Couldn't get hostname to connect to.\r\n");
- X#endif
- X errno = ECONNREFUSED; // connection refused
- X return(-1);
- X }
- X memset(&sa, 0, sizeof(struct sockaddr_in)); // nuke sa contents
- X memcpy((char *)&sa.sin_addr, (char *)hp->h_addr, hp->h_length);
- X sa.sin_family = hp->h_addrtype;
- X sa.sin_port = htons((unsigned short)socknum);
- X if ((sock_fd = socket(hp->h_addrtype, SOCK_STREAM,0)) < 0)
- X return(-1);
- X if (connect(sock_fd,(struct sockaddr *)&sa,sizeof(sa)) < 0)
- X {
- X#ifdef DEBUG
- X printf("client connect failed.\r\n");
- X#endif
- X close(sock_fd);
- X return(-1);
- X }
- X#ifdef DEBUG
- X printf("client connect successful.\r\n");
- X#endif
- X connected = 1;
- X sock_open = 1;
- X }
- X return(0); // exit normally
- X};
- X
- X// Function: connect
- X// Purpose: connect to another process via server socket
- X// Inputs: none
- X// Outputs: returns true if socket connection successful
- X// Author: Greg Shaw
- X// Created: 6/18/93
- X
- Xint bbsipc::do_connect(void)
- X{
- X struct sockaddr_in isa; // socket address info
- X int i_size; // socket address size
- X
- X i_size = sizeof(isa);
- X getsockname(serv_sock_fd,(struct sockaddr *)&isa,&i_size);
- X
- X if ((sock_fd = accept(serv_sock_fd,(struct sockaddr *)&isa,&i_size)) < 0)// accept connection
- X {
- X#ifdef DEBUG
- X printf("server: accept failed.\r\n");
- X#endif
- X return(-1);
- X }
- X#ifdef DEBUG
- X printf("server: accept succeeded.\r\n");
- X#endif
- X connected = 1;
- X return(0);
- X};
- X
- X// Function: send
- X// Purpose: send a message via the socket
- X// Inputs: msg - the message to send (null terminated string)
- X// Outputs: non-zero for error
- X// Author: Greg Shaw
- X// Created: 6/16/93
- X
- Xint bbsipc::send(char *msg)
- X{
- X int cw;
- X char eom = ETX;
- X
- X // send a message
- X#ifdef DEBUG
- X printf("send: Sending %s.\r\n",msg);
- X#endif
- X if (!sock_open && !connected)
- X {
- X#ifdef DEBUG
- X printf("send: socket not open.\r\n");
- X#endif
- X return(-1);
- X }
- X if (cw = write(sock_fd,msg,strlen(msg)), cw != strlen(msg))
- X {
- X#ifdef DEBUG
- X printf("Unable to write message!\r\n");
- X#endif
- X return(-1);
- X }
- X if (cw = write(sock_fd,&eom,1), cw != 1)
- X {
- X#ifdef DEBUG
- X printf("send: unable to send end of message.\r\n");
- X#endif
- X return(-1);
- X }
- X#ifdef DEBUG
- X printf("send: sent %s.\r\n",msg);
- X#endif
- X
- X return(0);
- X};
- X
- X// Function: receive
- X// Purpose: receive a message from the other end of the socket
- X// Inputs: none
- X// Outputs: msg - the message to be received.
- X// Author: Greg Shaw
- X// Created: 6/22/93
- X
- Xint bbsipc::receive(char *msg)
- X{
- X char c; // character read
- X char eom; // end of message found?
- X int count; // byte counter
- X int byr; // number of bytes read
- X
- X#ifdef DEBUG
- X printf("receive: start\r\n");
- X#endif
- X count = 0;
- X byr = 0;
- X eom = 0;
- X while (!eom)
- X { // look for trailing null
- X if ((byr = read(sock_fd,&c,(unsigned)1)), byr > 0)
- X {
- X#ifdef DEBUG
- X printf("%x char read\r\n",c);
- X#endif
- X if (c == ETX)
- X eom++;
- X else
- X msg[count++] = c; // add to msg
- X }
- X else if (byr == 0) // connection is closed for 0 chars read
- X return(-1);
- X }
- X msg[count] = 0; /* add terminating null */
- X return(count);
- X};
- X
- X// Function: msg_avail
- X// Purpose: poll the socket to determine whether a message is available
- X// for reading.
- X// Input: none
- X// Output: non-zero for a message available
- X// Author: Greg Shaw
- X// Created: 6/22/93
- X
- Xint bbsipc::msg_avail(char wait)
- X{
- X // NOTE: below may be a problem. In a server, it should not be
- X // possible for a particular connection to tie up the server. If the
- X // below is left as is (wait forever for message), it could happen that
- X // the calling process might die before sending the message, hence a
- X // forever wait for a message that will never come. This would cause a
- X // lockup of the server (and that would be a Bad Thing.
- X
- X fd_set pfd; // file descriptor set
- X FD_ZERO(&pfd);
- X FD_SET(sock_fd,&pfd);
- X struct timeval waittime;
- X
- X waittime.tv_sec = 0;
- X waittime.tv_usec = 100; // 100msec
- X if (!wait) // wait?
- X {
- X select(FD_SETSIZE,&pfd,NULL,NULL,&waittime);
- X return(FD_ISSET(sock_fd,&pfd));
- X // don't wait, return immed.
- X }
- X else
- X {
- X select(FD_SETSIZE,&pfd,NULL,NULL,NULL); // wait forever
- X return(FD_ISSET(sock_fd,&pfd));
- X }
- X};
- X
- X
- X// Function: two_connect
- X// Purpose: connect to a server master socket, get socket from server,
- X// disconnect and connect to new socket number.
- X// (a two level socket connect)
- X// Inputs: none
- X// Outputs: ipc object will connect if possible
- X// Notes: this is a client version only. The server version will be
- X// much much more complex.
- X// Author: Greg Shaw
- X// Created: 7/23/93
- X
- Xint bbsipc::two_connect(char *name, int socknum)
- X{
- X char tmpstr[50];
- X
- X // attempt to connect to server to get socket number
- X if (open_sock(name,socknum) == 0)
- X { // gotcha!
- X if (msg_avail(1) < 0) // wait for message
- X return(-1);
- X // now get new socket number
- X receive(tmpstr); // get socket #
- X if (sscanf(tmpstr,"%d",&sockt) != 1)
- X return(-1);
- X else
- X close_sock(0); // close current socket
- X if (open_sock(name,sockt) == 0)
- X { // got new socket
- X return(0);
- X }
- X }
- X return(-1);
- X};
- X#endif // _BBSIPC_C_
- END_OF_FILE
- if test 9008 -ne `wc -c <'rocat-0.75/src/bbsipc.C'`; then
- echo shar: \"'rocat-0.75/src/bbsipc.C'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/src/bbsipc.C'
- # end of 'rocat-0.75/src/bbsipc.C'
- fi
- if test -f 'rocat-0.75/src/errlog.C' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/src/errlog.C'\"
- else
- echo shar: Extracting \"'rocat-0.75/src/errlog.C'\" \(3345 characters\)
- sed "s/^X//" >'rocat-0.75/src/errlog.C' <<'END_OF_FILE'
- X// Filename: errlog.C
- X// Contents: the error logger interface object (for bbs interface)
- X// Author: Greg Shaw
- X// Created: 7/11/93
- X
- X/*
- XThis file is free software; you can redistribute it and/or modify it
- Xunder the terms of the GNU General Public License as published by the
- XFree Software Foundation; either version 2, or (at your option) any
- Xlater version.
- X
- XIn addition to the permissions in the GNU General Public License, the
- XFree Software Foundation gives you unlimited permission to link the
- Xcompiled version of this file with other programs, and to distribute
- Xthose programs without any restriction coming from the use of this
- Xfile. (The General Public License restrictions do apply in other
- Xrespects; for example, they cover modification of the file, and
- Xdistribution when not linked into another program.)
- X
- XThis file is distributed in the hope that it will be useful, but
- XWITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- XGeneral Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with this program; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#ifndef _ERRLOG_C_
- X#define _ERRLOG_C_
- X
- X#include "bbshdr.h" // the world
- X
- X// Method: ap_log
- X// Purpose: send an error message to the error logger daemon
- X// Input: msg - the message to append to the log file
- X// Output: the message will be sent to the logger daemon, or, error
- X// error will be returned
- X// Author: Greg Shaw
- X// Created: 7/11/93
- X
- Xint errlog::ap_log(char *msg)
- X{
- X char ttystr[50];
- X char *u;
- X char sendstr[255];
- X
- X if (ipcobj.open_sock(loghost(),ERRLOG_PORT) == 0) // open socket successful?
- X {
- X if (isatty(fileno(stdout))) // check for valid tty
- X {
- X strcpy(ttystr,ttyname(fileno(stdout))); // get ttyname
- X if (u = strchr(ttystr,'y'), u != NULL)
- X { // chop off /dev/tty
- X strcpy(sendstr,++u); // chop after y
- X strcpy(ttystr,sendstr); // copy back
- X }
- X sprintf(sendstr,"(%s) %s",ttystr,msg);
- X }
- X else
- X strcpy(sendstr,msg);
- X if (ipcobj.send(sendstr) == 0) // send message to error logger
- X {
- X ipcobj.close_sock(0);
- X return(0);
- X }
- X else
- X ipcobj.close_sock(0); // close socket
- X }
- X return(-1);
- X};
- X
- X// Method: er_log
- X// Purpose: send an error message to the error logger daemon then exit
- X// Input: msg - the message to append to the log file
- X// Output: the message will be sent to the logger daemon and, the program
- X// will abort
- X// Author: Greg Shaw
- X// Created: 7/11/93
- X
- Xint errlog::er_log(char *msg)
- X{
- X char ttystr[50];
- X char *u;
- X char sendstr[255];
- X
- X if (ipcobj.open_sock(loghost(),ERRLOG_PORT) == 0) // open socket successful?
- X {
- X if (isatty(fileno(stdout))) // check for valid tty
- X {
- X strcpy(ttystr,ttyname(fileno(stdout))); // get ttyname
- X if (u = strchr(ttystr,'y'), u != NULL)
- X { // chop off /dev/tty
- X strcpy(sendstr,++u); // chop after y
- X strcpy(ttystr,sendstr); // copy back
- X }
- X sprintf(sendstr,"(%s) %s",ttystr,msg);
- X }
- X else
- X strcpy(sendstr,msg);
- X if (ipcobj.send(sendstr) == 0) // send message to error logger
- X ipcobj.close_sock(0);
- X }
- X exit(0); // abort program
- X};
- X
- X#endif // _ERRLOG_C_
- END_OF_FILE
- if test 3345 -ne `wc -c <'rocat-0.75/src/errlog.C'`; then
- echo shar: \"'rocat-0.75/src/errlog.C'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/src/errlog.C'
- # end of 'rocat-0.75/src/errlog.C'
- fi
- if test -f 'rocat-0.75/src/errlogd.C' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/src/errlogd.C'\"
- else
- echo shar: Extracting \"'rocat-0.75/src/errlogd.C'\" \(4957 characters\)
- sed "s/^X//" >'rocat-0.75/src/errlogd.C' <<'END_OF_FILE'
- X// Filename: errlogd.C
- X// Contents: the error logger daemon
- X// Author: Greg Shaw
- X// Created: 7/11/93
- X
- X/*
- XThis file is free software; you can redistribute it and/or modify it
- Xunder the terms of the GNU General Public License as published by the
- XFree Software Foundation; either version 2, or (at your option) any
- Xlater version.
- X
- XIn addition to the permissions in the GNU General Public License, the
- XFree Software Foundation gives you unlimited permission to link the
- Xcompiled version of this file with other programs, and to distribute
- Xthose programs without any restriction coming from the use of this
- Xfile. (The General Public License restrictions do apply in other
- Xrespects; for example, they cover modification of the file, and
- Xdistribution when not linked into another program.)
- X
- XThis file is distributed in the hope that it will be useful, but
- XWITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- XGeneral Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with this program; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#ifndef _ERRLOGD_C_
- X#define _ERRLOGD_C_
- X
- X#include "bbshdr.h"
- X
- X#undef DEBUG
- X
- X// declared global so that the 'getout' function can close the socket
- Xbbsipc ipcobj;
- X
- X// Function: getout
- X// Purpose: get out of the program. Quick and dirty
- X// Author: Greg Shaw
- X// Created: 8/16/93
- X
- Xvoid getout(int sig)
- X{
- X char tmpstr[255]; // temporary string
- X char ttystr[20]; // name of tty
- X char *u; // for strchr
- X static int inalready = 0; // if already in, don't do again
- X time_t now; // current time
- X struct tm *timeinfo; // time information (broken down)
- X char filestr[255]; // string to output to file
- X FILE *outfile; // file to append to
- X
- X if (!inalready)
- X {
- X ipcobj.close_sock(1); // close for exit
- X ipcobj.close_sock(0); // close for exit
- X sprintf(tmpstr,"Errlogd: Got signal %d. Exiting.",sig);
- X if (outfile = fopen(ERR_LOG_PATH,"a"), outfile != NULL)
- X {
- X time(&now); // get current time
- X timeinfo = localtime(&now);
- X strftime(filestr,50,"%D %T: ",timeinfo); // get formatted time
- X strcat(filestr,tmpstr); // add message
- X fprintf(outfile,"%s\n",filestr);// append to file
- X fclose(outfile); // close file so that buffers cleared
- X }
- X inalready++;
- X strcpy(ttystr,ttyname(fileno(stdout))); // get ttyname
- X if (u = strchr(ttystr,'y'), u != NULL)
- X { // chop off /dev/tty
- X strcpy(tmpstr,++u); // chop after y
- X strcpy(ttystr,tmpstr); // copy back
- X }
- X exit(0); // exit to OS
- X }
- X}
- X
- X
- X// Function: main
- X// Purpose: the main calling routine for the error logger daemon
- X// Input: socket connections will connect with program.
- X// Output: all data sent to this daemon will be logged to a generic file
- X// Author: Greg Shaw
- X// Created: 7/11/93
- X
- Xmain() // no arguments
- X{
- X struct timeval waittime;
- X FILE *outfile; // file to append to
- X char msg[255];
- X time_t now; // current time
- X int ret,x; // return from ipc
- X struct tm *timeinfo; // time information (broken down)
- X char filestr[255]; // string to output to file
- X
- X#ifdef DEBUG
- Xprintf("Init...\r\n");
- Xfflush(stdout);
- X#endif
- X for (x=1; x<15; x++)
- X signal(x,&getout);
- X if(ipcobj.open_sock (NULL, ERRLOG_PORT) != 0) // create socket
- X {
- X printf("Unable to open server socket.\r\n");
- X return (0);
- X }
- X ipcobj.do_connect(); // wait for connection
- X waittime.tv_usec = 100; // 100msec
- X waittime.tv_sec = 0;
- X while(1) // loop forever
- X {
- X#ifdef DEBUG
- Xprintf("Got connect ... waiting for message.\r\n");
- Xfflush(stdout);
- X#endif
- X if (ret = ipcobj.msg_avail(1), ret < 0)
- X {
- X#ifdef DEBUG
- Xprintf("Nothing available. Closing socket\r\n");
- Xfflush(stdout);
- X#endif
- X ipcobj.close_sock(1); // close for exit
- X#ifdef DEBUG
- Xprintf("Disconnect.\r\n");
- Xfflush(stdout);
- X#endif
- X ipcobj.do_connect(); // wait for connection
- X }
- X else if (ret > 0)
- X {
- X#ifdef DEBUG
- Xprintf("Something available.\r\n");
- Xfflush(stdout);
- X#endif
- X if (ipcobj.receive(msg)< 0) // connection closed
- X {
- X ipcobj.close_sock(1); // close for exit
- X#ifdef DEBUG
- Xprintf("Disconnect.\r\n");
- Xfflush(stdout);
- X#endif
- X ipcobj.do_connect(); // wait for connection
- X }
- X else // append to output file
- X {
- X if (outfile = fopen(ERR_LOG_PATH,"a"), outfile != NULL)
- X {
- X time(&now); // get current time
- X timeinfo = localtime(&now);
- X strftime(filestr,50,"%D %T: ",timeinfo); // get formatted time
- X strcat(filestr,msg); // add message
- X fprintf(outfile,"%s\n",filestr);// append to file
- X fclose(outfile); // close file so that buffers cleared
- X#ifdef DEBUG
- Xprintf("appended %s.\r\n",filestr);
- Xfflush(stdout);
- X#endif
- X }
- X
- X #ifdef DEBUG
- X else
- X {
- X printf("Unable to open file.\r\n");
- X fflush(stdout);
- X }
- X #endif
- X }
- X }
- X// select(0,NULL,NULL,NULL,&waittime);// delay
- X }
- X ipcobj.close_sock(0); // close for exit
- X}
- X
- X
- X
- X#endif
- X
- END_OF_FILE
- if test 4957 -ne `wc -c <'rocat-0.75/src/errlogd.C'`; then
- echo shar: \"'rocat-0.75/src/errlogd.C'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/src/errlogd.C'
- # end of 'rocat-0.75/src/errlogd.C'
- fi
- if test -f 'rocat-0.75/src/filelock.C' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/src/filelock.C'\"
- else
- echo shar: Extracting \"'rocat-0.75/src/filelock.C'\" \(5213 characters\)
- sed "s/^X//" >'rocat-0.75/src/filelock.C' <<'END_OF_FILE'
- X// Filename: filelock.C
- X// Contents: the methods for the filelock (file locking) object
- X// Author: Greg Shaw
- X// Created: 7/23/93
- X
- X/*
- XThis file is free software; you can redistribute it and/or modify it
- Xunder the terms of the GNU General Public License as published by the
- XFree Software Foundation; either version 2, or (at your option) any
- Xlater version.
- X
- XIn addition to the permissions in the GNU General Public License, the
- XFree Software Foundation gives you unlimited permission to link the
- Xcompiled version of this file with other programs, and to distribute
- Xthose programs without any restriction coming from the use of this
- Xfile. (The General Public License restrictions do apply in other
- Xrespects; for example, they cover modification of the file, and
- Xdistribution when not linked into another program.)
- X
- XThis file is distributed in the hope that it will be useful, but
- XWITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- XGeneral Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with this program; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#ifndef _FLOCK_C_
- X#define _FLOCK_C_
- X
- X#include "bbshdr.h"
- X
- X// Function: set_lock
- X// Purpose: set a lock on a file
- X// Inputs: type - type of file lock. 0 for read, 1 for write
- X// fptr - the pointer to a file
- X// Output: returns non-zero if error
- X// Author: Greg Shaw
- X// Created: 7/24/93
- X
- Xint filelock::set_lock(char type, int fptr)
- X{
- X struct flock flockinfo;
- X int tries;
- X
- X flockinfo.l_start = 0L; // start at byte 0
- X flockinfo.l_len = 0L; // through end of file
- X flockinfo.l_whence = 0; // set to start of file
- X
- X if (type)
- X { // write lock
- X flockinfo.l_type = F_WRLCK; // write lock
- X tries = 0;
- X while (tries < MAX_LOCK_TRIES)
- X {
- X if (fcntl(fptr,F_SETLKW,&flockinfo) != 0)
- X {
- X sleep(1);
- X tries++;
- X if (tries == MAX_LOCK_TRIES)
- X return(-1);
- X }
- X else
- X tries = MAX_LOCK_TRIES; // worked, exit
- X }
- X }
- X else
- X { // read lock
- X flockinfo.l_type = F_RDLCK; // read lock
- X tries = 0;
- X while (tries < MAX_LOCK_TRIES)
- X {
- X if (fcntl(fptr,F_SETLKW,&flockinfo) != 0)
- X {
- X sleep(1);
- X tries++;
- X if (tries == MAX_LOCK_TRIES)
- X return(-1);
- X }
- X else
- X tries = MAX_LOCK_TRIES; // worked, exit
- X }
- X }
- X return(0);
- X};
- X
- X// Function: clear_lock
- X// Purpose: clear a lock on a file
- X// Inputs: fptr - the pointer to a file
- X// Output: returns non-zero if error
- X// Author: Greg Shaw
- X// Created: 7/24/93
- X
- Xint filelock::clear_lock(int fptr)
- X{
- X struct flock flockinfo;
- X
- X flockinfo.l_start = 0; // start at byte 0
- X flockinfo.l_len = 0; // through end of file
- X flockinfo.l_whence = 0; // set to start of file
- X
- X flockinfo.l_type = F_UNLCK; // read lock
- X if (fcntl(fptr,F_SETLKW,&flockinfo) != 0)
- X {
- X return(-1);
- X }
- X return(0);
- X};
- X
- X// Function: bopen
- X// Purpose: open a file, set locks as appropriate for mode
- X// Inputs: path - path to file
- X// mode - the mode of the file
- X// Output: returns valid (open) file descriptor or NULL if error
- X// Author: Greg Shaw
- X// Created: 7/24/93
- X
- XFILE *filelock::bopen(char *path, char *mode)
- X{
- X FILE *fileptr; // pointer to new opened file
- X char tmpstr[255];
- X int x;
- X
- X if (fileptr = fopen(path,mode), fileptr == NULL)
- X {
- X return(NULL);
- X }
- X if (strchr(mode,'w') != NULL || strchr(mode,'a') != NULL)
- X {
- X if (set_lock(1,fileno(fileptr)) != 0)
- X {
- X sprintf(tmpstr,"bopen: able to open file, but unable to set lock %s",path);
- X ap_log(tmpstr);
- X fclose(fileptr);
- X return(NULL);
- X }
- X }
- X else if (strchr(mode,'r') != NULL) // read only
- X {
- X if (set_lock(0,fileno(fileptr)) != 0)
- X {
- X sprintf(tmpstr,"bopen: able to open file, but unable to set lock %s",path);
- X ap_log(tmpstr);
- X fclose(fileptr);
- X return(NULL);
- X }
- X }
- X else
- X {
- X sprintf(tmpstr,"filelock: Unable to determine read/write of file %s, mode %s",path,mode);
- X ap_log(tmpstr);
- X fclose(fileptr);
- X return(NULL);
- X }
- X x = 0;
- X while (file_list[x] != NULL && x < MAX_FILES)
- X x++;
- X if (x < MAX_FILES)
- X file_list[x] = fileptr;
- X else
- X {
- X ap_log("filelock: Out of file storage. Please increase MAX_FILES");
- X }
- X return(fileptr);
- X};
- X
- X// Function: bclose
- X// Purpose: close a file, clear locks
- X// Inputs: fptr - the pointer to the file
- X// Output: returns non zero for failure
- X// Author: Greg Shaw
- X// Created: 7/24/93
- X
- Xint filelock::bclose(FILE *fptr)
- X{
- X int x;
- X
- X clear_lock(fileno(fptr));
- X x=0;
- X while (file_list[x] != fptr && x < MAX_FILES)
- X x++;
- X if (x < MAX_FILES)
- X file_list[x] = NULL;
- X else
- X {
- X ap_log("filelock: Unable to find file in open file list.");
- X }
- X fclose(fptr);
- X return(0);
- X};
- X
- X// Function: constructor
- X// Purpose: initialize the lists
- X// Inputs: none
- X// Output: none
- X// Author: Greg Shaw
- X// Created: 4/23/94
- X
- Xfilelock::filelock()
- X{
- X int x;
- X
- X for (x=0; x<MAX_FILES; x++)
- X file_list[x] = NULL;
- X};
- X
- X// Function: destructor
- X// Purpose: close all open files and clear locks
- X// Inputs: none
- X// Output: none
- X// Author: Greg Shaw
- X// Created: 4/23/94
- X
- Xfilelock::~filelock()
- X{
- X int x;
- X
- X for (x = 0; x< MAX_FILES; x++)
- X if (file_list[x] != NULL)
- X bclose(file_list[x]);
- X
- X};
- X
- X#endif // _FLOCK_C_
- X
- END_OF_FILE
- if test 5213 -ne `wc -c <'rocat-0.75/src/filelock.C'`; then
- echo shar: \"'rocat-0.75/src/filelock.C'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/src/filelock.C'
- # end of 'rocat-0.75/src/filelock.C'
- fi
- if test -f 'rocat-0.75/src/filesupdate.C' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/src/filesupdate.C'\"
- else
- echo shar: Extracting \"'rocat-0.75/src/filesupdate.C'\" \(4087 characters\)
- sed "s/^X//" >'rocat-0.75/src/filesupdate.C' <<'END_OF_FILE'
- X// Filename: filesupdate
- X// Contents: the conversion program to update the files sections to the
- X// new format.
- X// Created: 6/17/94
- X// Author: Greg Shaw
- X
- X#ifndef _FILESUPDATE_C_
- X#define _FILESUPDATE_C_
- X
- X#include <stdio.h>
- X#include <string.h>
- X#include <unistd.h>
- X#include <stdlib.h>
- X
- X// Function: convert
- X// Purpose: convert a files section
- X// Input: path - the name of the bbs section to read
- X// Output: none. setup function only.
- X// Author: Greg Shaw
- X// Created: 6/17/94
- X
- Xint convert(char *sname)
- X{
- X FILE *infile,*outfile;
- X char name[100];
- X char uploader[100];
- X int numdls;
- X char tmpstr[255];
- X char tmpstr2[255];
- X int off;
- X int line;
- X char *bbsdir;// used for bbsdir environment var
- X char c;
- X
- X if (bbsdir = getenv("BBSDIR"), bbsdir == NULL)
- X {
- X printf("Unable to get BBSDIR\r\n");
- X exit(1);
- X }
- X sprintf(tmpstr,"%s/filehdr/%s",bbsdir,sname); // tack on files header
- X if (infile = fopen(tmpstr,"r"), infile == NULL)
- X {
- X printf("Unable to open files section %s\r\n",sname);
- X return(0);// empty files section
- X }
- X sprintf(tmpstr,"%s/filehdr/%s.new",bbsdir,sname); // tack on files header
- X if (outfile = fopen(tmpstr,"w"), infile == NULL)
- X {
- X printf("Unable to open new files header.\r\n");
- X return(0);
- X }
- X // ok. now read everything into dllist object
- X line = 0;
- X while (!feof(infile))
- X {
- X while (c=fgetc(infile), c != '[' && !feof(infile));
- X if (feof(infile))
- X continue;
- X switch(line)
- X {
- X case 0: // line 1
- X if (c = fgetc(infile), c == 'A')
- X {
- X if (fscanf(infile,"%s %*ld %*ld %d %s", name, &numdls,uploader) != 3)
- X {
- X printf("%s: Error on line A\r\n",sname);
- X return(0);
- X }
- X line++;
- X fprintf(outfile,"[A %s %d %s ]\n",uploader, numdls, name);
- X }
- X break;
- X case 1: // line 2
- X if (c = fgetc(infile), c == 'B')
- X {
- X off = 0;
- X while (c = fgetc(infile), c != '\r' && c != '\n' && !feof(infile))
- X tmpstr[off++] = c;
- X tmpstr[off] = 0;
- X fprintf(outfile,"[B %s\n",tmpstr);
- X line++;
- X }
- X break;
- X case 2: // line 3
- X if (c = fgetc(infile), c == 'C')
- X {
- X off = 0;
- X while (c = fgetc(infile), c != '\r' && c != '\n' && !feof(infile))
- X tmpstr[off++] = c;
- X tmpstr[off] = 0;
- X fprintf(outfile,"[C %s\n",tmpstr);
- X line++;
- X }
- X break;
- X case 3: // line 4
- X if (c = fgetc(infile), c == 'D')
- X {
- X off = 0;
- X while (c = fgetc(infile), c != '\r' && c != '\n' && !feof(infile))
- X tmpstr[off++] = c;
- X tmpstr[off] = 0;
- X fprintf(outfile,"[D %s\n",tmpstr);
- X line++;
- X }
- X break;
- X case 4: // line 5
- X if (c = fgetc(infile), c == 'E')
- X {
- X off = 0;
- X while (c = fgetc(infile), c != '\r' && c != '\n' && !feof(infile))
- X tmpstr[off++] = c;
- X tmpstr[off] = 0;
- X fprintf(outfile,"[E %s\n",tmpstr);
- X line++;
- X }
- X break;
- X case 5: // line 6
- X if (c = fgetc(infile), c == 'F')
- X {
- X off = 0;
- X while (c = fgetc(infile), c != '\r' && c != '\n' && !feof(infile))
- X tmpstr[off++] = c;
- X tmpstr[off] = 0;
- X fprintf(outfile,"[F %s\n",tmpstr);
- X line = 0;
- X }
- X break;
- X }
- X }
- X fclose(infile);
- X fclose(outfile);
- X sprintf(tmpstr,"%s/filehdr/%s",getenv("BBSDIR"),sname);
- X sprintf(tmpstr2,"%s/filehdr/%s.old",getenv("BBSDIR"),sname);
- X rename(tmpstr,tmpstr2); // rename file
- X sprintf(tmpstr,"%s/filehdr/%s.new",getenv("BBSDIR"),sname);
- X sprintf(tmpstr2,"%s/filehdr/%s",getenv("BBSDIR"),sname);
- X rename(tmpstr,tmpstr2); // rename file
- X return(0);
- X};
- X
- Xmain()
- X{
- X char *bbsdir;// used for bbsdir environment var
- X char c;
- X FILE *hdrfile;
- X char tmpstr[120];
- X
- X if (bbsdir = getenv("BBSDIR"), bbsdir == NULL)
- X {
- X printf("Unable to get BBSDIR\r\n");
- X exit(1);
- X }
- X sprintf(tmpstr,"%s/filehdr/bbs_files_hdr",bbsdir);
- X if (hdrfile = fopen(tmpstr,"r"), hdrfile == NULL)
- X {
- X printf("Unable to open main files header.\r\n");
- X exit(1);
- X }
- X while (!feof(hdrfile))
- X {
- X while(c = fgetc(hdrfile), c != '[' && !feof(hdrfile));
- X if (fscanf(hdrfile,"%s",tmpstr) == 1)
- X {
- X printf("Converting %s\r\n",tmpstr);
- X convert(tmpstr);
- X }
- X }
- X fclose(hdrfile);
- X}
- X
- X#endif // _FILESUPDATE_C_
- END_OF_FILE
- if test 4087 -ne `wc -c <'rocat-0.75/src/filesupdate.C'`; then
- echo shar: \"'rocat-0.75/src/filesupdate.C'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/src/filesupdate.C'
- # end of 'rocat-0.75/src/filesupdate.C'
- fi
- if test -f 'rocat-0.75/src/menu.C' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/src/menu.C'\"
- else
- echo shar: Extracting \"'rocat-0.75/src/menu.C'\" \(13516 characters\)
- sed "s/^X//" >'rocat-0.75/src/menu.C' <<'END_OF_FILE'
- X// Filename: menu.C
- X// Contents: the methods for the menu object
- X// Author: Greg Shaw
- X// Created: 7/22/93
- X
- X/*
- XThis file is free software; you can redistribute it and/or modify it
- Xunder the terms of the GNU General Public License as published by the
- XFree Software Foundation; either version 2, or (at your option) any
- Xlater version.
- X
- XIn addition to the permissions in the GNU General Public License, the
- XFree Software Foundation gives you unlimited permission to link the
- Xcompiled version of this file with other programs, and to distribute
- Xthose programs without any restriction coming from the use of this
- Xfile. (The General Public License restrictions do apply in other
- Xrespects; for example, they cover modification of the file, and
- Xdistribution when not linked into another program.)
- X
- XThis file is distributed in the hope that it will be useful, but
- XWITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- XGeneral Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with this program; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#ifndef _MENU_C_
- X#define _MENU_C_
- X
- X#include "bbshdr.h"
- X
- X// Function: can_view
- X// Purpose: return true if the user has access based on the information
- X// passed in
- X// Input: acl - the access level of the user
- X// flags - the flags of the user
- X// am - the access level modifier for the user's acccess level
- X// fm - the flags modifier
- X// Output: true if user has access
- X// Author: Greg Shaw
- X// Created: 7/27/93
- X
- Xint Menu::can_view(int acl, int flags, char am, char fm)
- X{
- X int uacl; // user's acl
- X int uflags; // user's flags
- X
- X uacl = user.u_acl();
- X uflags = user.u_flags();
- X if (!((uacl >= acl && am == '>' ) || (uacl < acl && am == '<') ||
- X (acl == uacl && am == '=')))
- X return(0); // no access
- X if (flags != 0)
- X {
- X if ((flags & uflags) && fm == '=')
- X return(1);
- X if (!(flags & uflags) && fm == '!')
- X return(1);
- X return(0);
- X }
- X return(1); // access
- X};
- X
- X// Function: get_chat_msg
- X// Purpose: get a chat message from the chat object (if connected)
- X// Input: none
- X// Output: chat message is read into internal space
- X// Author: Greg Shaw
- X// Created: 7/22/93
- X
- Xint Menu::get_chat_msg(void)
- X{
- X int x;
- X if (x = msg_avail(0), x <0) // message avail?
- X connected = 0;
- X else if (x > 0 && receive(chat_msg) == -1)
- X connected = 0;
- X return(0);
- X};
- X
- X// Function: constructor
- X// Purpose: initialize values to sane states
- X// Input: none
- X// Output: (internal object changes)
- X// Author: Greg Shaw
- X// Created: 7/22/93
- X
- XMenu::Menu()
- X{
- X prompt = userprompt();
- X menu_path[0] = 0; // erase menu path
- X numitems = 0; // no items yet
- X connected = 0; // not connected
- X socknum = 0; // no socket yet
- X last_try = 0L; // haven't tried yet
- X chat_msg[0] = 0;// no chat message yet
- X};
- X
- X// Function: open
- X// Purpose: read the commands for the menu from the menu file
- X// Input: path - the path to the menu file
- X// Output: the menu is read into the object or a non-zero result is returned
- X// Author: Greg Shaw
- X// Created: 7/22/93
- X
- Xint Menu::open(char *path)
- X{
- X FILE *infile; // input file
- X char tmpstr[255]; // temporary string
- X char state; // state of input
- X char num; // offset into word
- X char comnum; // command number in array
- X char c; // input char
- X
- X// open_chat(); // attempt to connect to chat server
- X if (strcpy(tmpstr,getenv("BBSDIR")), tmpstr == NULL)
- X {
- X sprintf(tmpstr,"BBSDIR env var not set for %s",username());
- X ap_log(tmpstr);
- X return(-1);
- X }
- X strcat(tmpstr,"/menus/"); // add slash
- X strcat(tmpstr,path); // add path
- X if (infile = bopen(tmpstr,"r"), infile == NULL)
- X {
- X sprintf(tmpstr,"Unable to open menu file %s",path);
- X ap_log(tmpstr);
- X return(-1);
- X }
- X comnum = 0; // start at 0
- X while (!feof(infile))
- X {
- X state = 0;
- X num = 0;
- X c = 0;
- X while (c != '\r' && c != '\n' && !feof(infile))
- X {
- X c = fgetc(infile);
- X if (c != '|' && c != '\r' && c != '\n')
- X tmpstr[num++] = c; // add char
- X else
- X {
- X tmpstr[num] = 0; // add null
- X state++;
- X switch(state)
- X {
- X case 1: // command number
- X if (sscanf(tmpstr,"%d",&items[comnum].com_type) != 1 )
- X continue; // we've hit end of menu file
- X break;
- X case 2: // hot key
- X if (num != 0)
- X {
- X items[comnum].key = tmpstr[0];
- X }
- X else
- X items[comnum].key = 0;
- X break;
- X case 3: // access level
- X if (num != 0) // empty?
- X {
- X if (sscanf(tmpstr,"%d",&items[comnum].acl) != 1)
- X {
- X sprintf(tmpstr,"menu.acl: %s has an error.",path);
- X ap_log(tmpstr);
- X bclose(infile);
- X return(-1);
- X }
- X }
- X else
- X items[comnum].acl = 0;
- X break;
- X case 4: // access level modifier
- X if (num != 0) // modifier not null?
- X {
- X if (tmpstr[0] != '>' && tmpstr[0] != '=' &
- X tmpstr[0] != '<')
- X {
- X sprintf(tmpstr,"menu.aclmo: %s has an error.",path);
- X ap_log(tmpstr);
- X bclose(infile);
- X return(-1);
- X }
- X else
- X items[comnum].acl_mod = tmpstr[0];
- X }
- X else
- X items[comnum].acl_mod = '>'; // default to
- X break;
- X case 5: // flags
- X if (num != 0) // flags not null?
- X {
- X if (sscanf(tmpstr,"%d",&items[comnum].flags) != 1)
- X {
- X sprintf(tmpstr,"menu.flags: %s has an error.",path);
- X ap_log(tmpstr);
- X bclose(infile);
- X return(-1);
- X }
- X }
- X else
- X items[comnum].flags = 0; // no flags is default
- X break;
- X case 6: // flags mod
- X if (num != 0) // modifier not null?
- X {
- X if (tmpstr[0] != '=' && tmpstr[0] != '!')
- X {
- X sprintf(tmpstr,"menu.flagsmod: %s has an error.",path);
- X ap_log(tmpstr);
- X bclose(infile);
- X return(-1);
- X }
- X else
- X items[comnum].flags_mod = tmpstr[0];
- X }
- X else
- X items[comnum].flags_mod = '='; // default to =
- X break;
- X case 7: // misc text
- X strcpy(items[comnum].misc,tmpstr);
- X break;
- X case 8: // command text - skip to end of line
- X if (items[comnum].com_type != 0) // don't care about text out commands
- X comnum++;
- X if (comnum > 49) // at the end?
- X {
- X ap_log("menu: menu has too many items (> 50)");
- X bclose(infile);
- X return(-1);
- X }
- X while (c != '\r' && c != '\n' && !feof(infile))
- X c = fgetc(infile);
- X break;
- X default: // error
- X sprintf(tmpstr,"Invalid switch %d in menu open.",state);
- X ap_log(tmpstr);
- X }
- X num = 0; // start at next word
- X }
- X }
- X }
- X numitems = comnum;
- X bclose(infile);
- X return(0);
- X};
- X
- X// Function: open_chat
- X// Purpose: attempt to open a connection to the chat process
- X// Inputs: none
- X// Outputs: connected changes state if connection successful
- X// Author: Greg Shaw
- X// Created: 7/23/93
- X
- Xint Menu::open_chat(void)
- X{
- X time_t now; // current time
- X char hname[30]; // this host's name (where chat runs)
- X
- X // attempt to connect to chat object
- X if (!connected)
- X {
- X if (time(&now), now - last_try > 10) // more than 10 secs?
- X {
- X if (gethostname(hname,29), hname == NULL)
- X {
- X ap_log("menu.open: Unable to get current host name");
- X }
- X else
- X {
- X if (two_connect(hname,CHAT_MASTER_PORT) == 0)
- X { // got new socket
- X connected = 1;
- X }
- X }
- X }
- X }
- X return(0);
- X};
- X
- X// Function: run
- X// Purpose: run the menu
- X// Input: (from user)
- X// Output: the command that has been selected by the user is returned
- X// Author: Greg Shaw
- X// Created: 7/25/93
- X
- XMenuitem *Menu::run(char *path)
- X{
- X char c,d; // dumb char
- X char line[255]; // line
- X char valkeys[150]; // valid keys in menu
- X char timeleft[50]; // amount of time left to user
- X char offset; // offset into string
- X char numbracks; // number of |'s found
- X char boogie; // get out of function -- guy has selected
- X char tmpstr[255]; // stupid string
- X FILE *infile; // menu file
- X int x; // counter
- X int charsfound; // number of chars found after command info
- X int acl; // acl
- X int flags; // flags
- X int inactivity; // how long to wait before inactivity logoff
- X char am; // acl mod
- X char fm; // flags mod
- X unsigned long tl; // timeleft
- X time_t now; // current time
- X time_t rightnow; // current time
- X
- X clear(); // clear screen if possible
- X// if (connected) // connect to chat obj
- X// get_chat_msg(); // get chat message (if available)
- X// if (strlen(chat_msg) != 0) // message not null
- X// sstrcr(chat_msg); // send message
- X if (strcpy(tmpstr,getenv("BBSDIR")), tmpstr == NULL)
- X {
- X sprintf(tmpstr,"BBSDIR env var not set for %s",username());
- X ap_log(tmpstr);
- X return(NULL);
- X }
- X strcat(tmpstr,"/menus/"); // add slash
- X strcat(tmpstr,path); // add path
- X if (infile = bopen(tmpstr,"r"), infile == NULL)
- X {
- X sprintf(tmpstr,"Unable to open menu file %s",path);
- X ap_log(tmpstr);
- X }
- X boogie = 0;
- X while (!feof(infile) && !boogie)
- X {
- X numbracks = 0;
- X offset = 0; // offset into line
- X while (numbracks < 7 && !feof(infile)) // nuke all of the command info
- X {
- X c = fgetc(infile);
- X if (c != '|' && c != '\r' && c != '\n')
- X {
- X line[offset++] = c;
- X }
- X else // got info. process
- X {
- X line[offset] = 0;
- X if (c == '|')
- X {
- X numbracks++;
- X switch(numbracks)
- X {
- X case 1: // command number
- X continue;
- X break;
- X case 2: // hot key
- X case 7: // misc text
- X break;
- X case 3: // access level
- X if (offset != 0) // empty?
- X {
- X sscanf(line,"%d",&acl);
- X }
- X else
- X acl = 0;
- X break;
- X case 4: // access level modifier
- X if (offset != 0) // modifier not null?
- X {
- X am = line[0];
- X }
- X else
- X am = '>'; // default to >
- X break;
- X case 5: // flags
- X if (offset != 0) // flags not null?
- X {
- X sscanf(line,"%d",&flags);
- X }
- X else
- X flags = 0; // no flags is default
- X break;
- X case 6: // flags mod
- X if (offset != 0) // modifier not null?
- X {
- X fm = line[0];
- X }
- X else
- X fm = '='; // default to =
- X break;
- X default: // error
- X ap_log("Invalid switch in menu run.");
- X }
- X }
- X offset = 0;
- X }
- X } // ok, that's gone. Now the meat is left.
- X if (!can_view(acl, flags, am, fm)) // no access, skip.
- X {
- X while (c = fgetc(infile), c != '\r' && c != '\n' && !feof(infile));
- X acl = 32767; // avoid lockup if stray \r or \n at end of file
- X continue;
- X }
- X charsfound = 0;
- X offset=0;
- X while (d = fgetc(infile), d != '\r' && d != '\n' && !feof(infile))
- X {
- X if (offset % 50 == 0 && offset > 0)
- X {
- X tmpstr[offset] = 0;
- X sstr(tmpstr);
- X offset = 0;
- X tmpstr[offset++] = d;
- X }
- X else
- X tmpstr[offset++] = d;
- X charsfound++;
- X }
- X if (charsfound > 0)
- X {
- X tmpstr[offset] = 0;
- X sstr(tmpstr);
- X cr();
- X }
- X if (c = valid_char(), c != -1) // check for char and return true
- X {
- X bclose(infile);
- X if (c == 100) // 100 means he hit return only (for screen refresh)
- X return(NULL);
- X else
- X return(&items[c]);// if hot key for menu item
- X }
- X }
- X bclose(infile);
- X // ok, he didn't hit anything. Give him a prompt.
- X if (showcoms()) // show command keys?
- X { // build string with valid keys
- X offset = 0;
- X valkeys[offset++] = '[';
- X for (x=0; x<numitems; x++)
- X if (items[x].key != 0 && can_view(items[x].acl,
- X items[x].flags, items[x].acl_mod, items[x].flags_mod))
- X {
- X valkeys[offset++] = items[x].key;
- X valkeys[offset++] = ',';
- X }
- X valkeys[offset-1] = ']'; // add right bracket
- X valkeys[offset++] = ' '; // add trailing space
- X valkeys[offset] = 0; // add null
- X }
- X else
- X valkeys[0] = 0;
- X time(&now);
- X // see how much time he has left
- X tl = (user.u_timelimit()*60 - (now - user.user_logon()))/60;
- X // subtract time used prior to this logon
- X tl -= user.prevtimeused(); // subtract previous time used
- X if (user.credituploads())
- X tl += user.credit(); // add credited minutes
- X if (tl <= 0) // should he be gone?
- X {
- X items[0].com_type = -1; // boot the user
- X return(&items[0]);
- X }
- X if (showtime()) // show time left?
- X {
- X if (tl == 1)
- X strcpy(timeleft,"[ 1 Minute left ] ");
- X else if (tl < 1)
- X strcpy(timeleft,"[ <1 Minute left ] ");
- X else
- X sprintf(timeleft,"[%d Minutes left] ",tl);
- X }
- X else
- X timeleft[0] = 0;
- X sstr(timeleft);
- X if (prompt != NULL)
- X {
- X sstr(prompt);
- X }
- X sstr(valkeys);
- X inactivity = inactivity_timeout();
- X while (c = valid_char(), c == -1) // check for char and return true
- X {
- X time(&rightnow); // look for inactivity timeout
- X if ((rightnow - now) /60 > inactivity)
- X {
- X sstrcr("Inactivity timeout ... ");
- X items[0].com_type = -1; // boot the user
- X ap_log("Inactivity timeout.");
- X return(&items[0]);
- X }
- X }
- X cr();
- X if (c == 100) // 100 means he hit return only (for screen refresh)
- X return(NULL);
- X else
- X return(&items[c]); // if hot key for menu item
- X};
- X
- X// Function: valid_char
- X// Purpose: look for a character from the user. If available, check
- X// char against list, return array index into list if found.
- X// Input: none
- X// Output: the array index of the matching command record
- X// Author: Greg Shaw
- X
- Xint Menu::valid_char(void)
- X{
- X char c;
- X char x;
- X
- X c = 0;
- X if (char_avail(0,0) || char_avail(1,1))
- X c = gch(0);
- X if (c > 0) // error or zero for no char
- X {
- X for (x=0; x < numitems; x++)
- X {
- X if ( c == items[x].key && can_view(items[x].acl,
- X items[x].flags, items[x].acl_mod, items[x].flags_mod))
- X return(x);
- X else if (c == '\r' || c == '\n')
- X return(100);
- X }
- X }
- X return(-1);
- X};
- X
- X#endif // _MENU_C_
- END_OF_FILE
- if test 13516 -ne `wc -c <'rocat-0.75/src/menu.C'`; then
- echo shar: \"'rocat-0.75/src/menu.C'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/src/menu.C'
- # end of 'rocat-0.75/src/menu.C'
- fi
- if test -f 'rocat-0.75/src/menu.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/src/menu.h'\"
- else
- echo shar: Extracting \"'rocat-0.75/src/menu.h'\" \(3664 characters\)
- sed "s/^X//" >'rocat-0.75/src/menu.h' <<'END_OF_FILE'
- X// Filename: menu.h
- X// Contents: the menu system object
- X// Author: Greg Shaw
- X// Created: 7/22/93
- X
- X/*
- XThis file is free software; you can redistribute it and/or modify it
- Xunder the terms of the GNU General Public License as published by the
- XFree Software Foundation; either version 2, or (at your option) any
- Xlater version.
- X
- XIn addition to the permissions in the GNU General Public License, the
- XFree Software Foundation gives you unlimited permission to link the
- Xcompiled version of this file with other programs, and to distribute
- Xthose programs without any restriction coming from the use of this
- Xfile. (The General Public License restrictions do apply in other
- Xrespects; for example, they cover modification of the file, and
- Xdistribution when not linked into another program.)
- X
- XThis file is distributed in the hope that it will be useful, but
- XWITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- XGeneral Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with this program; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#ifndef _MENU_H_
- X#define _MENU_H_
- X
- X#include "bbshdr.h" // file that includes everything
- X
- Xextern User user; // need this for access level, flags, timelimit, etc.
- X
- X// Structure: Menuitem
- X// Contents: the pertinent information for each menu item.
- X// command type (number)
- X// misc text
- X// access level
- X// access level modifier
- X// flags
- X// flags modifier
- X// Author: Greg Shaw
- X// Created: 7/22/93
- X
- Xtypedef struct {
- X int com_type; // command type
- X char key; // hot key
- X char misc[91]; // miscellaneous text
- X int acl; // access level of command
- X char acl_mod; // access level modifier
- X int flags; // flags (32)
- X char flags_mod; // flags modifier
- X} Menuitem;
- X
- X// Object: Menu
- X// Purpose: Encapsulate the menu operations for the BBS. Everything
- X// relating to how the bbs (aka user) operates the menu system
- X// is contained within this object.
- X// Attributes: path - path to menu
- X// 1..n of struct item (see above for item description)
- X// numitems - the number of command items in menu
- X// connected - has connect to chat object been successful?
- X// socknum - the socket to connect to chat object (in step 2)
- X// last_try - the last try (time) to connect to chat object
- X// (10 seconds between attempts minimum)
- X// Methods: open - open a menu file (read commands from file)
- X// run - run the (already read) menu. Return selected command
- X// number
- X// dump - dump contents of menu object to screen (for debugging)
- X// chat_con - attempt to connect to chat object
- X// Author: Greg Shaw
- X// Created: 7/22/93
- X
- Xclass Menu:public bbsint // inherited from bbs interface
- X{
- X char *prompt; // command prompt
- X char menu_path[255]; // path to menu
- X char numitems; // number of items in menu
- X char chat_msg[81]; // last chat message
- X time_t user_logon; // time of user logon (for timeleft prompt)
- X Menuitem items[50]; // 50 menu items at this point
- X char connected; // connected to chat object?
- X int socknum; // socket to use when talking to chat object
- X time_t last_try; // last connected attempt - time
- X get_chat_msg(void); // get chat message (if available)
- Xpublic:
- X Menu(); // constructor
- X open_chat(void); // connect to chat object
- X open(char *path); // read commands from menu
- X Menuitem *run(char *path); // run the menu
- X dump(void); // dump contents of menu object
- X valid_char(void); // get char (if available) and check against items
- X can_view(int acl, int flags, char am, char fm); // can user view this item?
- X};
- X
- X#endif // _MENU_H_
- END_OF_FILE
- if test 3664 -ne `wc -c <'rocat-0.75/src/menu.h'`; then
- echo shar: \"'rocat-0.75/src/menu.h'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/src/menu.h'
- # end of 'rocat-0.75/src/menu.h'
- fi
- if test -f 'rocat-0.75/src/moncon.C' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/src/moncon.C'\"
- else
- echo shar: Extracting \"'rocat-0.75/src/moncon.C'\" \(5163 characters\)
- sed "s/^X//" >'rocat-0.75/src/moncon.C' <<'END_OF_FILE'
- X// Filename: moncon.C
- X// Contents: the methods for the monitor connection object
- X// Author: Greg Shaw
- X// Created: 8/26/93
- X
- X/*
- XThis file is free software; you can redistribute it and/or modify it
- Xunder the terms of the GNU General Public License as published by the
- XFree Software Foundation; either version 2, or (at your option) any
- Xlater version.
- X
- XIn addition to the permissions in the GNU General Public License, the
- XFree Software Foundation gives you unlimited permission to link the
- Xcompiled version of this file with other programs, and to distribute
- Xthose programs without any restriction coming from the use of this
- Xfile. (The General Public License restrictions do apply in other
- Xrespects; for example, they cover modification of the file, and
- Xdistribution when not linked into another program.)
- X
- XThis file is distributed in the hope that it will be useful, but
- XWITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- XGeneral Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with this program; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#ifndef _MONCON_C_
- X#define _MONCON_C_
- X
- X#include "bbshdr.h"
- X
- X
- X// Method: constructor
- X// Purpose: initialize all variables and attempt to connect to sysop process
- X// Input: none
- X// Output: none
- X// Author: Greg Shaw
- X// Created: 8/26/93
- X
- Xmoncon::moncon()
- X{
- X
- X cstart = cend = 0; // setup buffer pointers
- X costart = coend = 0;
- X watch_on = 0; // not watching
- X mon_connected = 0;
- X last_attempt = 0L; // last attempt = 0;
- X};
- X
- X// Method: connected
- X// Purpose: return true if monitor connected
- X// Input: none
- X// Output: internal object status is updated
- X// Author: Greg Shaw
- X// Created: 8/26/93
- X
- Xint moncon::connected(void)
- X{
- X return(mon_connected);
- X};
- X
- X// Method: connect_mon
- X// Purpose: try to connect to the sysop monitor program
- X// Input: none
- X// Output: internal object status is updated
- X// Author: Greg Shaw
- X// Created: 8/26/93
- X
- Xint moncon::connect_mon(void)
- X{
- X char watchname[30];
- X char msg[30];
- X time_t now;
- X
- X if (!mon_connected) // only connect if not connected
- X {
- X time(&now); // set for next attempt
- X if (abs(now - last_attempt) > 10)// space tries to 10 seconds minimum
- X {
- X time(&last_attempt);
- X if (strcpy(watchname,watchhost()), watchname != NULL)
- X if (open_sock(watchname,MONITOR_PORT) == 0)// try to open socket
- X {
- X mon_connected = 1;
- X last_attempt = 0;
- X }
- X }
- X }
- X if (mon_connected)
- X {
- X if (receive(msg), strcmp(msg,MONITOR_ON) == 0)
- X {
- X watch_on = 1;
- X }
- X }
- X return(0);
- X};
- X
- X// Method: send_monitor
- X// Purpose: send a string to the monitor process
- X// Input: none
- X// Output: none
- X// Author: Greg Shaw
- X// Created: 8/26/93
- X
- Xint moncon::send_monitor(char *str)
- X{
- X if (watch_on)
- X if (send(str) != 0) // error?
- X { // yes - close socket
- X watch_on = 0;
- X mon_connected = 0;
- X }
- X return(0);
- X};
- X
- X// Method: watching
- X// Purpose: return true if sysop monitor is watching this BBS process
- X// Input: none
- X// Output: none
- X// Author: Greg Shaw
- X// Created: 8/26/93
- X
- Xint moncon::watching(void)
- X{
- X return(watch_on);
- X};
- X
- X// Method: get_command
- X// Purpose: attempt to get a command from the monitor process
- X// Input: none
- X// Output: a character, should one be found
- X// Author: Greg Shaw
- X// Created: 8/27/93
- X
- Xint moncon::get_command(void)
- X{
- X char msg[255]; // message from monitor
- X int x;
- X
- X if (watch_on)
- X {
- X if (costart != coend) // empty buffer first
- X {
- X x = costart++;
- X costart %= COMMANDS_MAX;
- X return(commands[x]);
- X }
- X if (msg_avail(0))
- X {
- X // look for command string
- X if (receive(msg) == -1)
- X { // receive failed - socket closed
- X mon_connected = 0;
- X watch_on = 0;
- X } else
- X {
- X if (strstr(msg,COMMAND_MSG) != NULL)
- X { // command message
- X return(msg[4]);
- X }
- X else
- X {
- X for (x=0; x<strlen(msg); x++)
- X {
- X cbuf[cend++] = msg[x];
- X cend %= CBUF_MAX;
- X if (cstart == cend)// full?
- X break; // disregard
- X //rest of message
- X }
- X }
- X }
- X }
- X }
- X return(0);
- X};
- X
- X
- X
- X// Method: get_char
- X// Purpose: attempt to get a character from the monitor process
- X// Input: none
- X// Output: a character, should one be found
- X// Author: Greg Shaw
- X// Created: 8/27/93
- X
- Xchar moncon::get_char(void)
- X{
- X char msg[255]; // message from monitor
- X int x;
- X
- X if (watch_on)
- X {
- X if (cstart != cend) // empty buffer first
- X {
- X x = cstart++;
- X cstart %= CBUF_MAX;
- X return(cbuf[cstart++]);
- X }
- X if (msg_avail(1))
- X {
- X // look for command string
- X if (receive(msg) == -1)
- X { // receive failed - socket closed
- X mon_connected = 0;
- X watch_on = 0;
- X } else
- X {
- X if (strstr(msg,COMMAND_MSG) != NULL)
- X { // command message
- X commands[coend++] = msg[4];// 5th byte
- X coend %= COMMANDS_MAX;
- X }
- X else
- X {
- X for (x=0; x<strlen(msg); x++)
- X {
- X cbuf[cend++] = msg[x];
- X cend %= CBUF_MAX;
- X if (cstart == cend)// full?
- X break; // disregard
- X //rest of message
- X }
- X x = cstart++;
- X cstart %= CBUF_MAX;
- X return(cbuf[x]);
- X }
- X }
- X }
- X }
- X return(0);
- X};
- X
- X
- X
- X#endif // _MONCON_C_
- X
- X
- END_OF_FILE
- if test 5163 -ne `wc -c <'rocat-0.75/src/moncon.C'`; then
- echo shar: \"'rocat-0.75/src/moncon.C'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/src/moncon.C'
- # end of 'rocat-0.75/src/moncon.C'
- fi
- if test -f 'rocat-0.75/src/user.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/src/user.h'\"
- else
- echo shar: Extracting \"'rocat-0.75/src/user.h'\" \(6118 characters\)
- sed "s/^X//" >'rocat-0.75/src/user.h' <<'END_OF_FILE'
- X// Filename: user.h
- X// Contents: the user interface object
- X// Author: Greg Shaw
- X// Created: 5/30/93
- X
- X/*
- XThis file is free software; you can redistribute it and/or modify it
- Xunder the terms of the GNU General Public License as published by the
- XFree Software Foundation; either version 2, or (at your option) any
- Xlater version.
- X
- XIn addition to the permissions in the GNU General Public License, the
- XFree Software Foundation gives you unlimited permission to link the
- Xcompiled version of this file with other programs, and to distribute
- Xthose programs without any restriction coming from the use of this
- Xfile. (The General Public License restrictions do apply in other
- Xrespects; for example, they cover modification of the file, and
- Xdistribution when not linked into another program.)
- X
- XThis file is distributed in the hope that it will be useful, but
- XWITHOUT ANY WARRANTY; without even the implied warranty of
- XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- XGeneral Public License for more details.
- X
- XYou should have received a copy of the GNU General Public License
- Xalong with this program; see the file COPYING. If not, write to
- Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#ifndef _USER_H_
- X#define _USER_H_
- X
- X// Object: user
- X// Purpose: encapsulate all of the user funtions into one object.
- X// Attributes:
- X// fname, lname - the user's name
- X// login_name - the user's logon
- X// city - city where user from
- X// state - two character state
- X// uterm - terminal type
- X// last_logon - the last time the user logged on (in seconds)
- X// logins - the number of times the user has logged on
- X// downloads - number of downloads by the user
- X// uploads - the number of uploads by user
- X// priv_msgs - the number of private messages by user (unused)
- X// pub_msgs - the number of public messages by user (unused)
- X// credited - credited time (for chat or uploads)
- X// flags - user access flags
- X// tmpflags - temporary flags (if authorized by sysop)
- X// acl - the access level of user
- X// tmpacl - the temporary access level of user
- X// timelimit - the timelimit for this user
- X// temptl - temporary timelimit (if authorized by sysop)
- X// timeused - the amount of time used on last call
- X// msgflags - flags for when user has seen message (true/false)
- X// Methods:
- X// get - load the user object with user info, or, get user info from user
- X// list - list the users in the user list
- X// change_acl - change the user's access level
- X// change_tl - change user's timelimit
- X// change_flags - change user's flags
- X// u_flags - return user's flags
- X// u_acl - return user's access level
- X// u_timelimit - return user's timelimit
- X// Author: Greg Shaw
- X// Created: 7/13/93
- X
- Xclass User: public bbsint // inherited from user output function
- X{
- X char login_name[11]; // login name
- X char alias[21]; // user's alias (for chatting)
- X char city[21]; // city
- X char state[15]; // state
- X char uterm[21]; // terminal type
- X char has_color; // has color?
- X char editor[15]; // favorite editor
- X char lines; // lines on screen
- X char cols; // columns on screen
- X CardRec *card; // card information for user
- X time_t last_login; // last login
- X time_t login_time; // login time
- X time_t anniversary; // date of first logon (for anniversary calculations)
- X time_t mail_check; // time of last mail check
- X int card_color; // color (ord) of card
- X int logins; // number of logins
- X int downloads; // number of downloads
- X int uploads; // number of uploads
- X int priv_msgs; // private messages
- X int pub_msgs; // private messages
- X int credited; // credited time
- X unsigned long mail_size; // size of mail file on last check
- X unsigned long flags; // flags
- X unsigned long tmpflags; // temp flags
- X unsigned int acl; // access level
- X unsigned int tmpacl; // temp access level
- X unsigned int timelimit; // time limit
- X unsigned int tmptl; // temporary time limit
- X unsigned int timeused; // time used during last call
- Xpublic:
- X unsigned int kused; // number of kbytes downloaded last call
- X char fname[21]; // user's first name
- X char lname[21]; // user's last
- X User(); // constructor
- X ~User(); // destructor
- X int append(void); // append user to userlog
- X int check_card(void); // check card color vs. access level
- X int check_info(void); // ask user about term, lines, cols and such
- X int delete_user(char *name); // delete user with login name
- X int sysop_edit(void); // sysop's editor for users
- X int export(void); // export important variables to environment
- X int getinfo(char firsttime);// (re)get user's setup and information
- X int get(char *name); // get user - load user record or create new
- X int save(char *name); // save the current user to the user file
- X int list(int search,int sysop); // generate a list of users
- X int change_acl(int acl, char perm); // change access level - perm true for perm.
- X int change_tl(int tl, char perm); // change timelimit - perm true for perm.
- X int change_flags(unsigned long fl, char perm, char or); // change flags - perm true for perm.
- X int display_info(int logon); // display user information
- X unsigned long u_flags(void) { if (tmpflags != flags) return tmpflags; else return flags; };
- X unsigned int u_acl(void) { if (tmpacl != acl) return tmpacl; else return acl;};
- X unsigned int u_timelimit(void) { if (tmptl!=timelimit) return tmptl; else return timelimit;};
- X int prevtimeused() { return(timeused); };
- X int credit() { return(credited); };
- X time_t user_logon(void) { return(login_time);};
- X time_t last_logon(void) { return(last_login);};
- X char *logname(void) { return(login_name); };
- X char *editorname(void) { return(editor); };
- X CardRec *usercard(void) { return(card); };
- X int mailavail(void); // is mail available?
- X void inc_uploads(int num) { uploads += num; }; // increment number of uploads
- X void inc_downloads(int num) { downloads += num; }; // increment number of downloads
- X void inc_credit(int num) { credited += num; }; // increment credited minutes
- X int u_uploads(void) { return(uploads); };
- X int u_downloads(void){ return(downloads); };
- X int inactive_delete(void);
- X int inactive_list(void);
- X};
- X
- X#endif // _USER_H_
- END_OF_FILE
- if test 6118 -ne `wc -c <'rocat-0.75/src/user.h'`; then
- echo shar: \"'rocat-0.75/src/user.h'\" unpacked with wrong size!
- fi
- chmod +x 'rocat-0.75/src/user.h'
- # end of 'rocat-0.75/src/user.h'
- fi
- if test -f 'rocat-0.75/text/newuser.msg' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rocat-0.75/text/newuser.msg'\"
- else
- echo shar: Extracting \"'rocat-0.75/text/newuser.msg'\" \(3824 characters\)
- sed "s/^X//" >'rocat-0.75/text/newuser.msg' <<'END_OF_FILE'
- XWelcome to the Roman Catacombs!
- X
- XYou will see this file only once, so pay attention:
- X
- X(you will be able to view this file later if you wish)
- X
- XThe Roman Catacombs is a new BBS being put together to run under Unix.
- X
- XThe BBS offers the following to its users:
- X
- X Online multi-person chat.
- X Batch upload/download of files.
- X Mac/PC/Unix/Windows/pictures files sections.
- X Access to unix (but only if you request it).
- X Access to netnews (usenet) messages. (~3 meg per day)
- X
- X
- XCurrently, the BBS has the following statistics:
- X
- X over 1.2 gig of disk space
- X over 400 meg of adult files
- X the full Linux Slackware distribution
- X a partial news feed
- X
- X*NOTE* TRC does *NOT* have a direct internet connection. You will NOT be able
- Xto 'ftp' from here to some site on the internet!
- X
- XIn the future, the BBS will be getting more disk space as well as a FIDO
- Xinterface and a CD-ROM system.
- X
- XLet me explain the focus of TRC. TRC is an 'open' system. Persons may do
- Xwhat they wish here. The main focus of the bbs is:
- X
- X 1. Usenet conversation.
- X 2. Files areas.
- X 3. Online games.
- X 3. Multi-user chat. (not supported as yet)
- X
- XCurrently, we have a partial usenet feed. This means that we don't get
- Xevery article that comes over the internet. There is a good reason for
- Xthis: Currently, a full internet feed is over 50 MEGABYTES per day of
- Xnews. Because of this (and because we have to pay for transfer time), we
- Xhave a partial feed. This is being explained to you, a new user, for one
- Xvery good reason. That is, we're very flexible about those groups that we
- Xdo get. We may delete those that we find no interest in, and, we may add
- Xthose that people are interested in.
- X
- XThe partial internet news feed has the following 'groups':
- X
- X Microsoft Windows groups (comp.os.ms-windows.*)
- X Macintosh groups (comp.sys.mac.*)
- X Unix groups (comp.unix.*, comp.os.*)
- X MS-DOS (pc) groups (comp.sys.ibm.pc.*)
- X Local groups (miscellaneous discussion)
- X And MANY MANY more. (there are over 2000 total groups)
- X
- XThe list of newsgroups is available for public view. (and download) You
- Xmay choose any group from that list that you wish. Report it to the sysop,
- Xand you should see new articles in that group the next day.
- X
- XNow, I would like to explain how new users may access the bbs and how they
- Xmay increase their access. TRC has the following access levels:
- X
- XCard Type Timelimit Downloads per day (kbytes) card description
- X--------- --------- -------------------------- ------
- XBlue 40 min 1000K TRC Charter Member
- XGreen 60 min unlimited TRC Constituent
- XBlack unlimited unlimited Sub-Op or Investor
- X
- XEverybody at TRC has a membership card. From the above, you can see there
- Xare 3 major colors: Blue, Green and Black. You start with a Blue card.
- XTo advance to a Green (or higher) card, you must donate to TRC. Note that
- Xall donations are tax-deductible and will be used in BBS upgrades. (an
- Xexample would be the purchase of a CD-ROM drive) The rate schedule is
- Xsuch:
- X
- XCard Type Donation Valid Until
- X--------- -------- ---------
- XBlue none forever -- or until user account deleted
- XGreen $20.00 one year from receiving date
- XBlack $35.00 one year from receiving date
- X
- XNotes:
- X Adult file section access is $10.00 per year.
- X User accounts are deleted approximately every 90 days. If you do
- X not log in in 90 days, your account will disappear.
- X
- XFor those interested in Sub-Oping: TRC is always looking for competent
- Xpersons to sub-operate sections of the BBS. In particular, each machine
- Xarea needs someone with a compatible machine that can test and maintain
- Xthe files areas. Please leave a note to the sysop if you're interested.
- XUnix experience prior to sub-oping is recommended.
- X
- END_OF_FILE
- if test 3824 -ne `wc -c <'rocat-0.75/text/newuser.msg'`; then
- echo shar: \"'rocat-0.75/text/newuser.msg'\" unpacked with wrong size!
- fi
- # end of 'rocat-0.75/text/newuser.msg'
- fi
- echo shar: End of archive 6 \(of 9\).
- cp /dev/null ark6isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 9 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-