/*
* $Id: party.h,v 1.6 2002/08/23 13:39:23 howardjp Exp $
*
* Copyright (c) 1990
* Jan Wolter. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Jan Wolter
* and his contributors.
* 4. Neither the name of Jan Wolter nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY JAN WOLTER AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL JAN WOLTER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* PARTY PROGRAM - GLOBAL DECLARATIONS */
/* This file contains installation dependent information about the party
* program. The user should define either SYSIII, SYSV or BSD to get this
* to compile. If none of these seem appropriate, there are lower level
* defines that can be set to mix and match features from this Unixes.
*
* BSD works for SunOS and Mach. SYSV has not been tested in eons.
*
* Defines should be set with -D options in the Makefile, not by editting
* this file. This just sets defaults if you don't define anything. The
* defaults are mostly set up for M-Net.
*/
#include <sys/types.h>
#include <paths.h> /* Comment this out if you ain't got it */
#include <utmp.h>
/* The name of the partytab file must be compiled into the program. This
* is the file that determines the rest of the system configuration.
*/
#ifndef PARTYTAB
#define PARTYTAB "/usr/local/lib/party/partytab"
#endif /*PARTYTAB*/
/* either SUID or SGID should be set, depending on whether the party
* program is to be installed suid or sgid.
*/
#ifndef SUID
#ifndef SGID
#define SUID
#endif /*SGID*/
#endif /*SUID*/
/* MAILDELAY determines how often the program checks for new mail and for
* idleness. The test will be made roughly every 4*MAILDELAY seconds.
*/
#ifndef MAILDELAY
#define MAILDELAY 30
#endif /*MAILDELAY*/
/* UTMP is the location of the utmp file, which varies on some systems */
#ifndef UTMP
#ifdef _PATH_UTMP
#define UTMP _PATH_UTMP
#else
#define UTMP "/etc/utmp"
#endif
#endif
/* The following options give default values for options. All of these can
* be overridden by the partytab file, and most can be overridden by the
* user in various ways.
*/
#ifndef DFLT_CHANTAB
#define DFLT_CHANTAB "/usr/local/lib/party/chantab"
#endif /*DFLT_CHANTAB*/
#ifndef DFLT_DIR
#define DFLT_DIR "/usr/local/lib/party/log"
#endif /*DFLT_DIR*/
#ifndef DFLT_HELP
#define DFLT_HELP "/usr/local/lib/party/partyhlp"
#endif /*DFLT_HELP*/
#ifndef DFLT_MAKENOISE
#define DFLT_MAKENOISE "/usr/local/lib/party/noisetab"
#endif /*DFLT_MAKENOISE*/
#ifndef DFLT_WHOFILE
#define DFLT_WHOFILE "/usr/local/lib/party/partytmp"
#endif /*DFLT_WHOFILE*/
#ifndef DFLT_FULLMESG
#define DFLT_FULLMESG "Sorry, Party is full. Please try again later."
#endif /*DFLT_FULLMESG*/
#ifndef DFLT_INTRO
#define DFLT_INTRO "Welcome to PARTY! Type '?' for help:"
#endif /*DFLT_INTRO*/
#ifndef DFLT_PROMPT
#define DFLT_PROMPT ">"
#endif /*DFLT_PROMPT*/
#ifndef DFLT_TPMORP
#define DFLT_TPMORP ""
#endif /*DFLT_TPMORP*/
#ifndef DFLT_SPACEONLY
#define DFLT_SPACEONLY "Type '?' for help."
#endif /*DFLT_SPACEONLY*/
#ifndef DFLT_SHELL
#define DFLT_SHELL "/bin/sh"
#endif /*DFLT_SHELL*/
#ifndef DFLT_BACK
#define DFLT_BACK "10"
#endif /*DFLT_BACK*/
#ifndef DFLT_COLS
#define DFLT_COLS "80"
#endif /*DFLT_COLS*/
#ifndef DFLT_FILTER
#define DFLT_FILTER ""
#endif /*DFLT_FILTER*/
#ifndef DFLT_START
#define DFLT_START "party"
#endif /*DFLT_START*/
#ifndef DFLT_READLIM
#define DFLT_READLIM "0"
#endif /*DFLT_READLIM*/
#ifndef DFLT_MAILDIR
#define DFLT_MAILDIR "/usr/mail"
#endif /*DFLT_MAILDIR*/
#ifndef DFLT_KNOCKWAIT
#define DFLT_KNOCKWAIT "30"
#endif /*DFLT_KNOCKWAIT*/
#ifndef DFLT_IDLEOUT
#define DFLT_IDLEOUT "10"
#endif /*DFLT_IDLEOUT*/
#ifndef DFLT_CAPACITY
#define DFLT_CAPACITY "50"
#endif /*DFLT_CAPACITY*/
#ifndef DFLT_DEBUG
#define DFLT_DEBUG "party.debug"
#endif /*DFLT_DEBUG*/
/* Recognize some builtin compiler defines */
#ifdef NeXT
#ifndef BSD
#define BSD
#endif
#endif
#if defined(sparc) || defined(bsdi)
#ifndef BSD
#define BSD
#endif
#ifndef POSIX
#define POSIX
#endif
#endif
/* Translate high level defines into lower level defines */
#ifdef SYSIII
#define NOSTRSTR /* Don't use strstr() call */
#define L_LOCKING /* Use locking() to lock files */
#define F_TERMIO /* Use ioctl() to set modes */
typedef int vint; /* No void type on this old machine */
typedef unsigned mtype; /* arg type for malloc() */
#define BFSZ 268 /* in Sys3 can't type more than 256 anyway */
#define CANT_RESET /* can't give up effective uid and take it back */
#define RAND() rand()
#define MAXRAND 32767
#define SEEDRAND(x) srand(x)
#define NOSELECT
#endif /*SYSIII*/
#ifdef SYSV
#define L_LOCKF /* Use lockf() to lock files */
#define F_TERMIO /* Use ioctl() to set modes */
#define NODUP2 /* Don't use dup2() call */
#define BFSZ 1035
#define index strchr
typedef void vint;
typedef unsigned long mtype; /* arg type for malloc() */
#define RAND() rand()
#define MAXRAND 32767
#define SEEDRAND(x) srand(x)
#define VAR_ARGS
#endif /*SYSV*/
#ifdef BSD
#define L_FLOCK /* Use flock() to lock files */
#if defined(bsdi) || defined(linux) || defined(__FreeBSD__)
#define F_TERMIOS /* Use tcsetattr() to set modes */
#else
#define F_STTY /* Use stty() to set modes */
#endif /*bsdi*/
#define WINDOWS /* Get window size from kernel */
#define BFSZ 1035
typedef void vint;
typedef unsigned long mtype; /* arg type for malloc() */
#define RAND() random()
#define MAXRAND 2147483647
#define SEEDRAND(x) srandom(x)
#define VAR_ARGS
#endif /*BSD*/
#ifdef POSIX
#include <unistd.h>
#endif
#ifdef F_TERMIOS
#include <termios.h>
struct termios cooked, cbreak;
#define GTTY(fd, st) tcgetattr(fd, (st))
#ifdef TCSASOFT
#define STTY(fd, st) tcsetattr(fd, TCSASOFT | TCSANOW, (st))
#else
#define STTY(fd, st) tcsetattr(fd, TCSANOW, (st))
#endif
#define EOF_CHAR (cooked.c_cc[VEOF])
#define ERASE_CHAR (cooked.c_cc[VERASE])
#define KILL_CHAR (cooked.c_cc[VKILL])
#ifdef VREPRINT
#define REPRINT_CHAR (cooked.c_cc[VREPRINT])
#else
#define REPRINT_CHAR '\022'
#endif
#ifdef VWERASE
#define WERASE_CHAR (cooked.c_cc[VWERASE])
#else
#define WERASE_CHAR '\027'
#endif
#ifdef VLNEXT
#define LNEXT_CHAR (cooked.c_cc[VLNEXT])
#else
#define LNEXT_CHAR '\026'
#endif
#endif /*F_TERMIOS*/
#ifdef F_TERMIO
#include <termio.h>
struct termio cooked, cbreak;
#define GTTY(fd, st) ioctl(fd, TCGETA, (st))
#define STTY(fd, st) ioctl(fd, TCSETAF, (st))
#define EOF_CHAR (cooked.c_cc[VEOF])
#define ERASE_CHAR (cooked.c_cc[VERASE])
#define KILL_CHAR (cooked.c_cc[VKILL])
#ifdef VREPRINT
#define REPRINT_CHAR (cooked.c_cc[VREPRINT])
#else
#define REPRINT_CHAR '\022'
#endif
#ifdef VWERASE
#define WERASE_CHAR (cooked.c_cc[VWERASE])
#else
#define WERASE_CHAR '\027'
#endif
#ifdef VLNEXT
#define LNEXT_CHAR (cooked.c_cc[VLNEXT])
#else
#define LNEXT_CHAR '\026'
#endif
#endif /*F_TERMIO*/
#ifdef F_STTY
#include <sgtty.h>
struct tchars tch;
struct ltchars ltch;
struct sgttyb cooked, cbreak;
#define GTTY(fd, st) ioctl(fd, TIOCGETP, (st))
#define STTY(fd, st) ioctl(fd, TIOCSETN, (st))
#define EOF_CHAR (tch.t_eofc)
#define ERASE_CHAR (cooked.sg_erase)
#define KILL_CHAR (cooked.sg_kill)
#ifdef TIOCGLTC
#define WERASE_CHAR (ltch.t_werasc)
#define REPRINT_CHAR (ltch.t_rprntc)
#define LNEXT_CHAR (ltch.t_lnextc)
#else
#define WERASE_CHAR '\027'
#define REPRINT_CHAR '\022'
#define LNEXT_CHAR '\026'
#endif
#endif /*F_STTY*/
#ifdef L_FLOCK
#include <sys/file.h>
#define LOCK(file) flock(fileno(file), LOCK_EX)
#define UNLOCK(file) flock(fileno(file), LOCK_UN)
#endif /*L_FLOCK*/
#ifdef L_LOCKF
#define LOCK(file) fseek(file, 0L, 0), lockf(file, 1, 0L)
#define UNLOCK(file) fseek(file, 0L, 0), lockf(file, 0, 0L)
#endif /*L_LOCKF*/
#ifdef L_LOCKING
#define LOCK(file) fseek(file, 0L, 0), chk_lock(file, 1)
#define UNLOCK(file) fseek(file, 0L, 0), chk_lock(file, 0)
#endif /*L_LOCKING*/
#ifdef SUID
#define CHN_MODE 0644
#define DEP_MODE 0600
#define USR_MODE 0600
#ifdef _POSIX_SAVED_IDS
#define be_user() seteuid(real_id)
#define be_party() seteuid(eff_id)
#else
#ifdef CANT_RESET
#define be_user()
#define be_party()
#else
#define be_user() setreuid(eff_id,real_id)
#define be_party() setreuid(real_id,eff_id)
#endif /*CANT_RESET*/
#endif /*_POSIX_SAVED_IDS*/
#endif /*SUID*/
#ifdef SGID
#define CHN_MODE 0664
#define USR_MODE 0664
#define DEP_MODE 0660
#ifdef _POSIX_SAVED_IDS
#define be_user() setegid(real_id)
#define be_party() setegid(eff_id)
#else
#ifdef CANT_RESET
#define be_user()
#define be_party()
#else
#define be_user() setregid(eff_id,real_id)
#define be_party() setregid(real_id,eff_id)
#endif /*CANT_RESET*/
#endif /*_POSIX_SAVED_IDS*/
#endif /*SGID*/
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <fcntl.h>
#include <signal.h>
#include <pwd.h>
#include <ctype.h>
#include <utmp.h>
/* BSDI is only Unix I know of that threatens to change namesize from 8 to
* anything else. Most don't even have a define for it. */
#ifndef UT_NAMESIZE
#define UT_NAMESIZE 8
#endif
#ifndef UT_LINESIZE
#define UT_LINESIZE 8
#endif
/* Option table structure */
struct optent {
char *name; /* Name for this option */
char pf; /* Syntax for this option */
char yes; /* Boolean value of this option 0=no, 1=yes, 2=see */
char *str; /* String value of this option */
};
struct cmdent {
char *name; /* Name for this command */
char abbr; /* Minimum number of characters which must match */
};
/* Option pf flags - how can the option be used? */
#define PF_SYS 0001 /* Can only be set in partytab */
#define PF_NO 0002 /* Can use "option" and "nooption" form */
#define PF_SEE 0004 /* Can use "seeoption" form */
#define PF_STR 0010 /* Can use "option=string" form */
#define PF_NUM 0020 /* Can use "option=number" form */
#define PF_CHN 0040 /* Reset on chn change. Not user settable */
#define PF_SHOW 0100 /* Print even without "all" flag */
extern struct optent opt[]; /* Option structure -- see opttab.c */
extern struct cmdent cmd[]; /* Command structure -- see opttab.c */
extern int rst; /* Party file open for read */
extern FILE *wfd; /* Party file open for write */
extern int out_fd; /* Stream to terminal or filter */
extern char *progname; /* Program name */
extern char *channel; /* Current channel number (NULL is outside)*/
extern long tailed_from; /* File offset we last tailed from */
extern char *version;
extern char name[]; /* User's internal name or alias */
extern char realname[]; /* User's real name (used for mail check) */
extern char logname[]; /* Name user logged in under (utmp) */
extern char logtty[]; /* /dev/ttyXX that user logged into (utmp) */
extern long logtime; /* Time that the user logged in (utmp)*/
extern FILE *debug; /* Debug output file */
extern int real_id, eff_id; /* Real and Effective uid */
/* The following buffer gets used for all sorts of things in all sorts of
* places. Beware!
*/
#define INDENT UT_NAMESIZE+2 /* Just changing this value won't work */
char inbuf[BFSZ+INDENT+2]; /* Text buffer - first 10 for "name: " */
char *txbuf; /* Text buffer - pointer to respose portion */
/* of inbuf */
#define CHN_LEN 12 /* Maximum length of channel name */
/* Data structure used in compiling list of channels for :list command */
struct chnname {
char name[CHN_LEN+1]; /* Name of this command */
int users; /* number of users in this channel */
struct chnname *next; /* Next entry */
};
#ifndef NOIGNORE
/* Structure of linked list of ignored user. Initially null */
struct ign {
struct ign *next;
char name[UT_NAMESIZE+1];
};
extern struct ign *ignoring;
#endif /*NOIGNORE*/
int alrm(), intr(), hup(), term(), setcols();
#ifdef BSD
int susp();
#endif /*BSD*/
vint err(char *, ...), db(char *, ...);
char *getlogin(), *malloc(), *ctime(), *fgets(), *getenv();
char *chn_file_name(), *getline();
char *strchr(), *strpbrk(), *strrchr(), *strstr();
char *firstin(), *firstout();
struct passwd *getpwnam(), *getpwuid();
struct chnname *who_clist(), *addchn();
char *leafname();
long backup();
time_t time();
vint (*oldsigpipe)();
vint (*(signal()))();
FILE *upopen();
#ifndef NOCLOSE
char *usr_file_name();
#endif
syntax highlighted by Code2HTML, v. 0.9.1