TinyMUSH 3.3
TinyMUSH Server
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
comsys.c File Reference

Module implementing DarkZone-style channel system. More...

#include "config.h"
#include "constants.h"
#include "typedefs.h"
#include "macros.h"
#include "externs.h"
#include "prototypes.h"
#include <ctype.h>
#include <string.h>
Include dependency graph for comsys.c:

Classes

struct  mod_comsys_confstorage
 
struct  com_player
 
struct  com_channel
 
struct  com_alias
 
struct  com_list
 

Macros

#define NO_CHAN_MSG   "That is not a valid channel name."
 
#define CHAN_FLAG_PUBLIC   0x00000010
 
#define CHAN_FLAG_LOUD   0x00000020
 
#define CHAN_FLAG_P_JOIN   0x00000040
 
#define CHAN_FLAG_P_TRANS   0x00000080
 
#define CHAN_FLAG_P_RECV   0x00000100
 
#define CHAN_FLAG_O_JOIN   0x00000200
 
#define CHAN_FLAG_O_TRANS   0x00000400
 
#define CHAN_FLAG_O_RECV   0x00000800
 
#define CHAN_FLAG_SPOOF   0x00001000
 
#define CBOOT_QUIET   1 /* No boot message, just has left */
 
#define CEMIT_NOHEADER   1 /* Channel emit without header */
 
#define CHANNEL_SET   1 /* Set channel flag */
 
#define CHANNEL_CHARGE   2 /* Set channel charge */
 
#define CHANNEL_DESC   4 /* Set channel desc */
 
#define CHANNEL_LOCK   8 /* Set channel lock */
 
#define CHANNEL_OWNER   16 /* Set channel owner */
 
#define CHANNEL_JOIN   32 /* Channel lock: join */
 
#define CHANNEL_TRANS   64 /* Channel lock: transmit */
 
#define CHANNEL_RECV   128 /* Channel lock: receive */
 
#define CHANNEL_HEADER   256 /* Set channel header */
 
#define CLIST_FULL   1 /* Full listing of channels */
 
#define CLIST_HEADER   2 /* Header listing of channels */
 
#define CWHO_ALL   1 /* Show disconnected players on channel */
 
#define MAX_CHAN_NAME_LEN   20
 
#define MAX_CHAN_ALIAS_LEN   10
 
#define MAX_CHAN_DESC_LEN   256
 
#define MAX_CHAN_HEAD_LEN   64
 
#define check_owned_channel(p, c)
 
#define find_channel(d, n, p)
 
#define lookup_channel(s)   ((CHANNEL *)hashfind((s), &mod_comsys_comsys_htab))
 
#define lookup_clist(d)    ((COMLIST *)nhashfind((int)(d), &mod_comsys_comlist_htab))
 
#define ok_joinchannel(d, c)    ok_chanperms((d), (c), CHAN_FLAG_P_JOIN, CHAN_FLAG_O_JOIN, (c)->join_lock)
 
#define ok_recvchannel(d, c)    ok_chanperms((d), (c), CHAN_FLAG_P_RECV, CHAN_FLAG_O_RECV, (c)->recv_lock)
 
#define ok_sendchannel(d, c)    ok_chanperms((d), (c), CHAN_FLAG_P_TRANS, CHAN_FLAG_O_TRANS, (c)->trans_lock)
 
#define clear_chan_alias(n, a)
 
#define Grab_Channel(p)
 
#define Comsys_User(p, t)
 
#define Grab_Alias(p, n)
 

Typedefs

typedef struct com_player CHANWHO
 
typedef struct com_channel CHANNEL
 
typedef struct com_alias COMALIAS
 
typedef struct com_list COMLIST
 

Functions

COMALIASlookup_calias (dbref player, char *alias_str)
 
void join_channel (dbref player, char *chan_name, char *alias_str, char *title_str)
 
void channel_clr (dbref player)
 
void mod_comsys_announce_connect (dbref player, const char *reason __attribute__((unused)), int num __attribute__((unused)))
 
void mod_comsys_announce_disconnect (dbref player, const char *reason __attribute__((unused)), int num __attribute__((unused)))
 
void update_comwho_all (void)
 
void comsys_chown (dbref from_player, dbref to_player)
 
void do_ccreate (dbref player, dbref cause __attribute__((unused)), int key __attribute__((unused)), char *name)
 
void do_cdestroy (dbref player, dbref cause __attribute__((unused)), int key __attribute__((unused)), char *name)
 
void do_channel (dbref player, dbref cause __attribute__((unused)), int key, char *chan_name, char *arg)
 
void do_cboot (dbref player, dbref cause __attribute__((unused)), int key, char *name, char *objstr)
 
void do_cemit (dbref player, dbref cause __attribute__((unused)), int key, char *chan_name, char *str)
 
void do_cwho (dbref player, dbref cause __attribute__((unused)), int key, char *chan_name)
 
void do_addcom (dbref player, dbref cause __attribute__((unused)), int key __attribute__((unused)), char *alias_str, char *args[], int nargs)
 
void do_delcom (dbref player, dbref cause __attribute__((unused)), int key __attribute__((unused)), char *alias_str)
 
void do_clearcom (dbref player, dbref cause __attribute__((unused)), int key __attribute__((unused)))
 
void do_comtitle (dbref player, dbref cause __attribute__((unused)), int key __attribute__((unused)), char *alias_str, char *title)
 
void do_clist (dbref player, dbref cause __attribute__((unused)), int key, char *chan_name)
 
void do_comlist (dbref player, dbref cause __attribute__((unused)), int key __attribute__((unused)))
 
void do_allcom (dbref player, dbref cause __attribute__((unused)), int key __attribute__((unused)), char *cmd)
 
int mod_comsys_process_command (dbref player, dbref cause __attribute__((unused)), int interactive __attribute__((unused)), char *in_cmd, char *args[] __attribute__((unused)), int nargs __attribute__((unused)))
 
void mod_comsys_dump_database (FILE *fp)
 
void mod_comsys_make_minimal (void)
 
void mod_comsys_load_database (FILE *fp)
 
void fun_comlist (char *buff, char **bufc, dbref player, dbref caller, dbref cause, char *fargs[], int nfargs, char *cargs[], int ncargs)
 
void fun_cwho (char *buff, char **bufc, dbref player, dbref caller __attribute__((unused)), dbref cause __attribute__((unused)), char *fargs[], int nfargs __attribute__((unused)), char *cargs[] __attribute__((unused)), int ncargs __attribute__((unused)))
 
void fun_cwhoall (char *buff, char **bufc, dbref player, dbref caller __attribute__((unused)), dbref cause __attribute__((unused)), char *fargs[], int nfargs __attribute__((unused)), char *cargs[] __attribute__((unused)), int ncargs __attribute__((unused)))
 
void fun_comowner (char *buff, char **bufc, dbref player, dbref caller __attribute__((unused)), dbref cause __attribute__((unused)), char *fargs[], int nfargs __attribute__((unused)), char *cargs[] __attribute__((unused)), int ncargs __attribute__((unused)))
 
void fun_comdesc (char *buff, char **bufc, dbref player, dbref caller __attribute__((unused)), dbref cause __attribute__((unused)), char *fargs[], int nfargs __attribute__((unused)), char *cargs[] __attribute__((unused)), int ncargs __attribute__((unused)))
 
void fun_comheader (char *buff, char **bufc, dbref player, dbref caller __attribute__((unused)), dbref cause __attribute__((unused)), char *fargs[], int nfargs __attribute__((unused)), char *cargs[] __attribute__((unused)), int ncargs __attribute__((unused)))
 
void fun_comalias (char *buff, char **bufc, dbref player, dbref caller __attribute__((unused)), dbref cause __attribute__((unused)), char *fargs[], int nfargs __attribute__((unused)), char *cargs[] __attribute__((unused)), int ncargs __attribute__((unused)))
 
void fun_cominfo (char *buff, char **bufc, dbref player, dbref caller __attribute__((unused)), dbref cause __attribute__((unused)), char *fargs[], int nfargs __attribute__((unused)), char *cargs[] __attribute__((unused)), int ncargs __attribute__((unused)))
 
void fun_comtitle (char *buff, char **bufc, dbref player, dbref caller __attribute__((unused)), dbref cause __attribute__((unused)), char *fargs[], int nfargs __attribute__((unused)), char *cargs[] __attribute__((unused)), int ncargs __attribute__((unused)))
 
void fun_cemit (char *buff, char **bufc, dbref player, dbref caller __attribute__((unused)), dbref cause __attribute__((unused)), char *fargs[], int nfargs __attribute__((unused)), char *cargs[] __attribute__((unused)), int ncargs __attribute__((unused)))
 
void mod_comsys_cleanup_startup (void)
 
void mod_comsys_create_player (dbref creator __attribute__((unused)), dbref player, int isrobot __attribute__((unused)), int isguest)
 
void mod_comsys_destroy_obj (dbref player __attribute__((unused)), dbref obj)
 
void mod_comsys_destroy_player (dbref player, dbref victim)
 
void mod_comsys_init (void)
 

Variables

struct mod_comsys_confstorage mod_comsys_config
 
CONF mod_comsys_conftable []
 
HASHTAB mod_comsys_comsys_htab
 
HASHTAB mod_comsys_calias_htab
 
HASHTAB mod_comsys_comlist_htab
 
MODHASHES mod_comsys_hashtable []
 
MODHASHES mod_comsys_nhashtable []
 
MODVER mod_comsys_version
 
NAMETAB cboot_sw []
 
NAMETAB cemit_sw []
 
NAMETAB channel_sw []
 
NAMETAB clist_sw []
 
NAMETAB cwho_sw []
 
CMDENT mod_comsys_cmdtable []
 
FUN mod_comsys_functable []
 

Detailed Description

Module implementing DarkZone-style channel system.

Author
TinyMUSH development team (https://github.com/TinyMUSH)
Version
3.3
Date
2020-12-28

Macro Definition Documentation

◆ check_owned_channel

#define check_owned_channel (   p,
 
)
Value:
if (!Comm_All((p)) && ((p) != (c)->owner)) \
{ \
notify((p), NOPERM_MESSAGE); \
return; \
}

◆ clear_chan_alias

#define clear_chan_alias (   n,
 
)
Value:
XFREE((a)->alias); \
if ((a)->title) \
XFREE((a)->title); \
XFREE((a)); \
hashdelete((n), &mod_comsys_calias_htab)

◆ Comsys_User

#define Comsys_User (   p,
 
)
Value:
t = lookup_player(p, fargs[0], 1); \
if (!Good_obj(t) || (!Controls(p, t) && !Comm_All(p))) \
{ \
SAFE_LB_STR((char *)"#-1 NO PERMISSION TO USE", buff, bufc); \
return; \
}

◆ find_channel

#define find_channel (   d,
  n,
 
)
Value:
(p) = ((CHANNEL *)hashfind((n), &mod_comsys_comsys_htab)); \
if (!(p)) \
{ \
notify((d), NO_CHAN_MSG); \
return; \
}
Definition: comsys.c:109

◆ Grab_Alias

#define Grab_Alias (   p,
 
)
Value:
cap = lookup_calias(p, n); \
if (!cap) \
{ \
SAFE_LB_STR((char *)"#-1 NO SUCH ALIAS", buff, bufc); \
return; \
}

◆ Grab_Channel

#define Grab_Channel (   p)
Value:
chp = lookup_channel(fargs[0]); \
if (!chp) \
{ \
SAFE_LB_STR((char *)"#-1 CHANNEL NOT FOUND", buff, bufc); \
return; \
} \
if ((!Comm_All(p) && ((p) != chp->owner))) \
{ \
SAFE_LB_STR((char *)"#-1 NO PERMISSION TO USE", buff, bufc); \
return; \
}

Variable Documentation

◆ cboot_sw

NAMETAB cboot_sw[]
Initial value:
= {
{(char *)"quiet", 1, CA_PUBLIC, CBOOT_QUIET},
{NULL, 0, 0, 0}}
#define CA_PUBLIC
Command permission flags.
Definition: constants.h:373

◆ cemit_sw

NAMETAB cemit_sw[]
Initial value:
= {
{(char *)"noheader", 1, CA_PUBLIC, CEMIT_NOHEADER},
{NULL, 0, 0, 0}}

◆ channel_sw

NAMETAB channel_sw[]
Initial value:
= {
{(char *)"charge", 1, CA_PUBLIC, CHANNEL_CHARGE},
{(char *)"desc", 1, CA_PUBLIC, CHANNEL_DESC},
{(char *)"header", 1, CA_PUBLIC, CHANNEL_HEADER},
{(char *)"lock", 1, CA_PUBLIC, CHANNEL_LOCK},
{(char *)"owner", 1, CA_PUBLIC, CHANNEL_OWNER},
{(char *)"set", 1, CA_PUBLIC, CHANNEL_SET},
{(char *)"join", 1, CA_PUBLIC, CHANNEL_JOIN | SW_MULTIPLE},
{(char *)"transmit", 1, CA_PUBLIC, CHANNEL_TRANS | SW_MULTIPLE},
{(char *)"receive", 1, CA_PUBLIC, CHANNEL_RECV | SW_MULTIPLE},
{NULL, 0, 0, 0}}
#define SW_MULTIPLE
Definition: constants.h:417

◆ clist_sw

NAMETAB clist_sw[]
Initial value:
= {
{(char *)"full", 1, CA_PUBLIC, CLIST_FULL},
{(char *)"header", 1, CA_PUBLIC, CLIST_HEADER},
{NULL, 0, 0, 0}}

◆ cwho_sw

NAMETAB cwho_sw[]
Initial value:
= {
{(char *)"all", 1, CA_PUBLIC, CWHO_ALL},
{NULL, 0, 0, 0}}

◆ mod_comsys_cmdtable

CMDENT mod_comsys_cmdtable[]
Initial value:
= {
{(char *)"@cboot", cboot_sw, CA_NO_SLAVE | CA_NO_GUEST, 0, CS_TWO_ARG, NULL, NULL, NULL, {do_cboot}},
{(char *)"@ccreate", NULL, CA_NO_SLAVE | CA_NO_GUEST, 0, CS_ONE_ARG, NULL, NULL, NULL, {do_ccreate}},
{(char *)"@cdestroy", NULL, CA_NO_SLAVE | CA_NO_GUEST, 0, CS_ONE_ARG, NULL, NULL, NULL, {do_cdestroy}},
{(char *)"@cemit", cemit_sw, CA_NO_SLAVE | CA_NO_GUEST, 0, CS_TWO_ARG, NULL, NULL, NULL, {do_cemit}},
{(char *)"@channel", channel_sw, CA_NO_SLAVE | CA_NO_GUEST, 0, CS_TWO_ARG | CS_INTERP, NULL, NULL, NULL, {do_channel}},
{(char *)"@clist", clist_sw, CA_NO_SLAVE, 0, CS_ONE_ARG, NULL, NULL, NULL, {do_clist}},
{(char *)"@cwho", cwho_sw, CA_NO_SLAVE, 0, CS_ONE_ARG, NULL, NULL, NULL, {do_cwho}},
{(char *)"addcom", NULL, CA_NO_SLAVE, 0, CS_TWO_ARG | CS_ARGV, NULL, NULL, NULL, {do_addcom}},
{(char *)"allcom", NULL, CA_NO_SLAVE, 0, CS_ONE_ARG, NULL, NULL, NULL, {do_allcom}},
{(char *)"comlist", NULL, CA_NO_SLAVE, 0, CS_NO_ARGS, NULL, NULL, NULL, {do_comlist}},
{(char *)"comtitle", NULL, CA_NO_SLAVE, 0, CS_TWO_ARG, NULL, NULL, NULL, {do_comtitle}},
{(char *)"clearcom", NULL, CA_NO_SLAVE, 0, CS_NO_ARGS, NULL, NULL, NULL, {do_clearcom}},
{(char *)"delcom", NULL, CA_NO_SLAVE, 0, CS_ONE_ARG, NULL, NULL, NULL, {do_delcom}},
{(char *)NULL, NULL, 0, 0, 0, NULL, NULL, NULL, {NULL}}}
#define CA_NO_GUEST
Definition: constants.h:389
#define CS_INTERP
Definition: constants.h:354
#define CA_NO_SLAVE
Definition: constants.h:387
#define CS_TWO_ARG
Definition: constants.h:351
#define CS_ARGV
Definition: constants.h:353
#define CS_ONE_ARG
Definition: constants.h:350
#define CS_NO_ARGS
Command handler call conventions.
Definition: constants.h:349

◆ mod_comsys_conftable

CONF mod_comsys_conftable[]
Initial value:
= {
{(char *)"guests_calias", cf_string, CA_STATIC, CA_PUBLIC, (int *)&mod_comsys_config.guests_calias, SBUF_SIZE},
{(char *)"guests_channel", cf_string, CA_STATIC, CA_PUBLIC, (int *)&mod_comsys_config.guests_channel, SBUF_SIZE},
{(char *)"public_calias", cf_string, CA_STATIC, CA_PUBLIC, (int *)&mod_comsys_config.public_calias, SBUF_SIZE},
{(char *)"public_channel", cf_string, CA_STATIC, CA_PUBLIC, (int *)&mod_comsys_config.public_channel, SBUF_SIZE},
{NULL, NULL, 0, 0, NULL, 0}}
CF_Result cf_string(int *vp, char *str, long extra, dbref player, char *cmd)
Set string parameter.
Definition: conf.c:722
#define SBUF_SIZE
Definition: constants.h:23
#define CA_STATIC
Definition: constants.h:409

◆ mod_comsys_functable

FUN mod_comsys_functable[]
Initial value:
= {
{"CEMIT", fun_cemit, 2, 0, CA_PUBLIC, NULL},
{"COMALIAS", fun_comalias, 1, 0, CA_PUBLIC, NULL},
{"COMDESC", fun_comdesc, 1, 0, CA_PUBLIC, NULL},
{"COMHEADER", fun_comheader, 1, 0, CA_PUBLIC, NULL},
{"COMINFO", fun_cominfo, 2, 0, CA_PUBLIC, NULL},
{"COMLIST", fun_comlist, 0, FN_VARARGS, CA_PUBLIC, NULL},
{"COMOWNER", fun_comowner, 1, 0, CA_PUBLIC, NULL},
{"COMTITLE", fun_comtitle, 2, 0, CA_PUBLIC, NULL},
{"CWHO", fun_cwho, 1, 0, CA_PUBLIC, NULL},
{"CWHOALL", fun_cwhoall, 1, 0, CA_PUBLIC, NULL},
{NULL, NULL, 0, 0, 0, NULL}}
#define FN_VARARGS
Definition: constants.h:765

◆ mod_comsys_hashtable

MODHASHES mod_comsys_hashtable[]
Initial value:
= {
{"Channels", &mod_comsys_comsys_htab, 15, 8},
{"Channel aliases", &mod_comsys_calias_htab, 500, 16},
{NULL, NULL, 0, 0}}

◆ mod_comsys_nhashtable

MODHASHES mod_comsys_nhashtable[]
Initial value:
= {
{"Channel lists", &mod_comsys_comlist_htab, 100, 16},
{NULL, NULL, 0, 0}}