/*
    slforum version 1.x - Simple chat room usable via telnet.
    Copyright (C) 1998-2008 Jeremy D. Monin, Dan Chin, Matt Lochansky
	(forum@shadowlands.org).
    Based on jdkchat version 1.3, J.D.Koftinoff Software, Ltd. (GPL'd)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/


#ifndef __SLFPREFS_H
#define	__SLFPREFS_H


/**********************/
/*    Your system.    */
/**********************/


#define PATH_SEP '/'


/* If you need shadow password support, uncomment this line */
/* #define USE_SHADOW   */


/* If you get "please enter a positive number" when you try the slforum
 * command  !roll 15  (or any other number), uncomment this line.
 */
/* #define EGCS_ATOI_BUG_WORKAROUND */




/* see also passwd.h, where UT_LINE_FMT sets the name of
 *	the login tty displayed in "last".
 * see also slforumuser.cc, where the list of commands and
 *	the list of random commands is stored, and the default
 *	command (the !<tab> expansion).
 */

/* if slfhomedir not defined */
#define LOGIN_ISSUE_BANNER_FALLBACK_DIR "/etc"  /* no trailing / please */
#define LOGIN_ISSUE_BANNER_FILENAME "issue.forum"
#define LOGIN_ISSUE_BANNER_FALLBACK "issue.net"

/* Where does the inbox live?  %s is the username. */
#define MSGCHK_INBOXFNAME "/var/spool/mail/%s"

/* where to write user log?  System defines default. */
/* #define WTMPLOG "/var/log/wtmp" */
#ifndef WTMP_FILE
	#define WTMP_FILE _PATH_WTMP
#endif
#define WTMPLOG WTMP_FILE
#define WTMPLOG_fallback "%s%cslforum-wtmp-%d"
	/* "${slfhomedir}/slforum-wtmp-${port}" */

/* where is the slforum home dir if none specified? */
#define SLFHOMEDIR "/var/lib/slforum"
#define SLFHOMEDIR_fallback "%s%c.slforum-%d"   /* ${home}/.slforum-${portnum} */
#define SLFHOMEDIR_fullback "/tmp"  /* substituted into above (fallback):
				     * /tmp/.slforum-${portnum}
				     */

/* where are forum user prefs stored? (in slfhomedir) */
#define SLFUSERDIR	"userpref"
#define PREFSPATH          "%s%c%s%cslforum-%s"   /* ${slfprefsdir}/${userpref}/slf-${username} */
#define PREFSPATH_fallback "/tmp/.slforum-%s"

/* how about the file of users allowed to use !lockout ? */
#define LOCKOUTUSERS_FILE "lockout-users"

/* what's the gid of slf admins?  Any user in this group will be an admin. */
#define SLF_ADMIN_GID  0

/* if slforum is running as a user (not root) process with uid >= this number,
 * and the process owner logs in, they're admin.
 */
#define SLF_MIN_REAL_USERID 100

/* virtual users? */
#define USE_VIRTUSERS  1

#define SLF_VIRTUSER_DIR "/var/lib/slforum"
#define SLF_VIRTUSER_DB   "virtuser"

/* banners */

#define DFLT_BANNERSDIR "%s%cbanners"  /* "${slfhomedir}/banners" */
#define DFLT_BANNERSDIR_fallback "/tmp/.banners"
#define MAX_BANNER_SIZE 4096       /* no more than this much will be spammed */
#define MAX_BANNER_LINES  50       /* no more than this many will be spammed */
                                   /* (longer banners are truncated)         */

/* recap at login */

/* Do we want the recap feature? */
#define USE_RECAP 1

/* Length of recap, in lines (ignored unless USE_RECAP) */
#define RECAP_LINES 20

/* Idle warning (room's been quiet) */
#define RECAP_IDLE_WARN_MINUTES 20


/** User-count file */
#define USERCOUNT_UPDATE_SECONDS 150 /* Also updated when user enters/leaves */
#define USE_USERCOUNT_FILE 1


/* Also, be sure to define LINUX_UTMP, SOLARIS_UTMP, or OSX_UTMP... 
 * (use -D flag to gcc, see makefiles)
 */



/**********************/
/*    Preferences.    */
/**********************/

/* what's the default port? */
#define SLF_DEFAULT_PORT 7777

/* what character are all commands preceded by?  (IRC uses '/') 
 * If you change this, be sure to change the entry for c_toall
 * in the usercmd table in slforumuser.cc, to make sure it's still
 * in the proper place alphabetically.
 */
#define SLF_CMD_ESC_CHAR '!'

/* what is the prompt character?
 * Hardcoded to '>' before 20060520.
 * May eventually make this a user pref like cmd-char (TODO).
 */
#define SLF_PROMPT_CHAR '>'

/* Do you allow high-bit characters (over ASCII 127)? 
 * If not, comment this out.
 */
#define SLF_ALLOW_HIGHBITS


/* for !here, how many minutes should the idle_here threshold be? */
#define SLF_IDLE_HERE_THRESHOLD 20


/* are guests allowed? (if not, 0. else, 1.) */
#define ALLOW_GUESTS 1

/* are guest auto-accepted? (if not, 0, else 1.)
 * If so, you may want to set GUEST_HOWTO_MESSAGE (below) to 1 as well.
 * You should also carefully check the settings for MIN_NON_REMOTE and
 * MIN_NON_GUEST, they're there for your protection.  Check your firewall
 * settings as well, that's the only way to keep folks out for now...
 * Note that this may be overridden on the command line with -aa or +aa.
 */
#define AUTO_ACCEPT_GUESTS 0


/* If you want a guest login message to appear
 * (e.g., "Guests may log on with the username 'guest'.")
 * then set GUEST_HOWTO_MESSAGE to 1.
 * 		jer 980911.2300
 */
#define GUEST_HOWTO_MESSAGE 0


/* How often to check for new mail? */
#define AUTO_MSGCHK_INTERVAL 3


/* Beyond what threshold should they auto-away? (user can override this)
 *  (Minutes of idle time before going auto-away)
 */
#define AUTO_AWAY_TIME  45


/* How many seconds before AUTO_AWAY_TIME should it warn them they will soon
 * go autoaway?  AUTO_AWAY_TIME is minutes, but AUTO_AWAY_WARN_SEC is seconds.
 */
#define AUTO_AWAY_WARN_SEC 90   /* must be above 60: timer resolution issue */



/* can guests !roll?  If not, uncomment this.  dan chin 19990124.0110 */
/* #define GUESTS_CANNOT_ROLL 1 */

/* can guests !banner?  If not, uncomment this.  jer 19990920.1745 */
/* #define GUESTS_CANNOT_BANNER 1 */


/* are topics enabled?  If not, comment this. (Don't define to 0 or 1) */
#define ALLOW_TOPICS

/* Note: if ALLOW_TOPICS is defined, you may use !admin topics off and
 * !admin topics on to toggle at runtime
 */
/* Are topics on (1) or off (0) when the program starts?  Ignored unless
 * ALLOW_TOPICS is defined.
 */
#define TOPICS_ON_AT_START 0


/* can guests set the topic?  If not, uncomment this.  Jer 19990731.2245 */
#define GUESTS_CANNOT_SET_TOPIC 1


/* can guests comment on the topic?  If not, uncomment this. */
#define GUESTS_CANNOT_COMMENT_TOPIC 1


/* Should room announce when it is the top of the hour?  If not,
comment this out */
#define HOURLY_CHIME		1


/* for the hourly chime: after how many idle hours should it shut up,
 * instead of logging a chime to an empty room?  (Chimes normally go
 * in the log as a timestamp; but if the room's normally idle, no need
 * to have a logfile keep getting bigger while no activity's going on.)
 * The chime will still be said in the room for the benefit of users there,
 * but it won't go in the log after this threshold.
 */
#define CHIME_MAX_QUIET_HOURS 	2



/* for !roll: use star wars RPG rules?  If so, uncomment this. */
/* #define ROLL_SWRPG */


/* is !lockout enabled? */
#define ALLOW_LOCKOUT
/* and if so, only for users listed in LOCKOUTUSERS_FILE? */
#define LOCKOUT_ONLY_LOCKOUTUSERS


/* are !macros enabled? */
#define ALLOW_MACROS


/* do all messages beep?  If so, uncomment this. */
/* #define ALL_MESSAGES_BEEP */


/* do all messages come with a timestamp?  If so, uncomment this. */
/* #define ALL_MESSAGES_TIMESTAMP */



/**********************/
/*      Tunables.     */
/**********************/

/** This must be less than the number of bits in the userfield_t type
 *  typedef'd in slforumuser.h, or !to-many won't work.
 */
#define MAX_CHAT_USERS 60


/* how many blank lines in a row, maximum?  Prevents annoyance by a user
 * accidentally holding down the Enter key and scrolling everyone's stuff
 * off the screen.
 */
#define MAX_BLANK_LINES	 3

/* How many levels of nested macros can we run? */
#define MAX_MACRO_CALL_LEVEL 16

/* How many characters, max, in one macro? */
#define MAX_MACRO_LENGTH   1024

/* security: how many slots reserved for local users? */
#define MIN_NON_REMOTE 5

/* security: how many slots reserved for non-guest "real" users? */
#define MIN_NON_GUEST  5

/* how many previous topics are remembered?  This is for the command
 * that lists previous topics and comments.
 */
#define NUM_REMEMBERED_TOPICS 12


/* for !roll: max # dice to roll */
#define ROLL_MAXDICE	1600

/* for !roll: max # dice to individually show.
 * If using ROLL_SWRPG, this is the max # dice to roll at all.
 */
#define ROLL_MAXDSHOW	16


/** for !listen : max size of a user's listen list, to prevent D.O.S. attack */
#define LISTENLIST_MAXSIZE 25
/** whisper ban list max size */
#define WBLIST_MAXSIZE 25


/* max # lines per second overall (averaged)   jer 19990922.2100 */
#define MAX_LINES_SEC    3
/* max # lines in any one second (burst mode ;-)) */
#define MAX_LINES_BURST  45
/* how many seconds to track for average */
#define MAX_LINES_SECS_FOR_AVG  15
/* first times third should >= max_lines_burst... */



/**********************/
/*      Timeouts.     */
/**********************/


/* how often to check if users are still connected?
 * This isn't a real ICMP ping, we just send them a space
 * followed by a ctrl-H, and check for write errors
 * that would indicate disconnection.
 *
 */
#define PING_INTERVAL_SEC  150


/* This is the time, in seconds, that the topic must remain static.  This
will give the person who created the topic a chance to have users comment
on the topic without it being changed too fast.
*/
#define TOPIC_RESET_INTERVAL  (2*60*60)  /* currently 2 hrs */



/**********************/
/* messages to users. */
/**********************/

#define GUEST_HOWTO_TXT "Guests may log on with the username 'guest'."
#define ROOM_FULL_TXT	"Sorry, but the room is full.\r\n"
#define NO_COMMENT_TXT  "No one has commented yet."
#define TOPIC_MSG_BRIEF_FMT "Topic set at %s by %s."
#define TOPIC_MSG_NOW_FMT   "Topic set at %s by %s.  Can be changed any time."
#define TOPIC_SET_MSG_FMT   "Topic set at %s by %s.  Can be changed in %d min %d sec."
#define TOPIC_NOT_YET_FMT   "No topic is set yet."
#define TOPIC_PREV_NOT_YET_FMT  "There are not this many previous topics yet."
#define TOPIC_PREV_MSG_FMT  "Old topic #%d set at %s by %s.  (%d %s)"
#define TOPIC_NO_CHANGE_YET_FMT "Topic can't be changed for another %d min %d sec"
#define TOPIC_CHANGE_ANYTIME_MSG "Note: _You_ may change your topic at any time."
#define TOPICS_DISABLED_MSG "Sorry, topics are disabled."
#define TOPICS_ADMIN_ON_MSG "As an admin, you may enable topics: type \177admin topics on"
#define TOO_IDLE_AWAY_MSG   "idle"
#define HINT_DONEWHISPERING_CMD_MSG "Type \"\177\177\" or ESC ESC when you're done whispering :-)"
#define HINT_WHISPERDONE_MSG "Further messages will be sent to all users."
#define RECAP_HEADER    "-- Recap of recent conversation --"
#define RECAP_FOOTER    "-- Recap ends --"
#define RECAP_IGNOREALL	"Your ignore preferences hide all the recapped text."
#define RECAP_NONE	"Forum has just started up, nothing has been said yet."
#define RECAP_FOOTER_IDLE_WARN_MIN "-- Recap ends (IDLE: room quiet for %d minutes) --"
#define RECAP_FOOTER_IDLE_WARN_HR "-- Recap ends (IDLE: room quiet for %d hours) --"

#define LEGAL_HELLO_MSG_TXT "   Shadowlands Forum version 1.9.6.4, Copyright (C) 2008\r\n"	\
"   Jeremy D. Monin, Dan Chin, Matt Lochansky (forum@shadowlands.org)\r\n" \
"   Shadowlands Forum comes with ABSOLUTELY NO WARRANTY.\r\n"	\
"   This is free software, and you are welcome to redistribute it\r\n"	\
"   under the terms of the Free Software Foundation's GNU Public\r\n"	\
"   License.\r\n"

#define LOGIN_HELLO_MSG_TXT	\
"\rWelcome to Shadowlands Forum by Jeremy Monin, Dan Chin, Matt Lochansky\r\n"\
"This is v1.9.6.4 of 4jul(fri)2008 - http://shadowlands.org/forum/\r\n"

#define VERSION_MESSAGE  "Version: This is slforum v1.9.6.4 of 4jul(fri)2008"


/* uncomment the following line to dump core in /tmp for debugging. */
/* #define DUMP_CORE */



#define SYSMSG_FROM_USERNAME  "FORUM"
#define SYSNAME_LCASE         "forum"
#define TOPIC_FROM_USERNAME   "TOPIC"
#define COMMENT_FROM_USERNAME "COMMENT"
#define TIMER_FROM_USERNAME   "TIMER"
#define AWAY_FROM_USERNAME    "AWAY"


/* for tab expansion (990417.0100 dschin) */
#define TAB_WIDTH 8


/* for logging to the room's log from C files...
 * see the Lprintf function in slforummain.cc.
 */
#ifdef __cplusplus
extern "C"
{
#endif
  void Lprintf(const char *fmt, ...);
#ifdef __cplusplus
}
#else
  typedef enum { false=0, true=1 } bool;   /* give C the bool type */
#endif


/* Likewise, this definition is here because it's needed all over. */

typedef struct slf_userinfo
{
    struct passwd u;             /* MUST be first part, for unix_validate */
    bool          u_is_virtual;  /* real user or virt user? */
    const char   *uv_email;      /* virtusers - email addr  */
    const char   *uv_sponsor;     /* virtusers - sponsor     */
} slf_userinfo;




#endif	/* __SLFPREFS_H */

