Omega Security Services 0.7.3

cmds.h File Reference

Go to the source code of this file.

Data Structures

struct  CmdBase
struct  CmdHash
struct  HelpEntry

Defines

#define CMD_ERR_OK   0
#define CMD_ERR_INV   1
#define CMD_ERR_ACC   2
#define CMD_ERR_PARAMS   3
#define CMD_ERR_INDEX   4
#define CMD_ERR_HASH   5
#define CMD_ADD_HEAD   1
#define CMD_ADD_TAIL   0
#define CMD_HASH_KEY   1024

Functions

int HELP_FOREACH (User *, User *)
int do_cmd (char *cmd, User *us, User *u, int ac, char *av)
void ACCESS_DENIED (User *, User *)
CmdHash * CmdHashCreate (User *u)
int AddCmd (User *, char *, char *, void(*fnct)(User *, int, char **), void(*hlp)(User *), int)
void DelCmd (User *, char *, void(*fnct)(User *, int, char **), void(*hlp)(User *))
int AddHelp (User *u, void(*helpcmd)(User *))
int DelHelp (User *u, void(*helpcmd)(User *))
char * CmdErr (int)
static void ClientCmdNull (User *u, char *av)

Variables

CmdHash * UserCmdHash [1024]
dlink_list cmd_help [1024]

Define Documentation

#define CMD_ADD_HEAD   1

Definition at line 12 of file cmds.h.

#define CMD_ADD_TAIL   0

Definition at line 13 of file cmds.h.

#define CMD_ERR_ACC   2

Definition at line 7 of file cmds.h.

#define CMD_ERR_HASH   5

Definition at line 10 of file cmds.h.

#define CMD_ERR_INDEX   4

Definition at line 9 of file cmds.h.

Referenced by do_cmd().

#define CMD_ERR_INV   1

Definition at line 6 of file cmds.h.

#define CMD_ERR_OK   0

Definition at line 5 of file cmds.h.

Referenced by do_cmd().

#define CMD_ERR_PARAMS   3

Definition at line 8 of file cmds.h.

#define CMD_HASH_KEY   1024

Definition at line 15 of file cmds.h.

Referenced by AddCmd(), AddHelp(), DelHelp(), and do_cmd().


Function Documentation

void ACCESS_DENIED ( User *  ,
User *   
)

Definition at line 302 of file cmds.c.

int AddCmd ( User *  u,
char *  name,
char *  access,
void(*)(User *, int, char **)  fnct,
void(*)(User *)  hlp,
int  log 
)

Add a command to our clients command hash.

Note:
There is a bit of presumptions we make when issueing this function, for one we assume that u is always our client, since client structuresare the same as user structures except they have been flagged as our clients.
Parameters:
uPointer to our clients structure
nameThe name of the command we are using, this is imporntant becuase the command will be issued and looked up via its name.
accessAccess level required to issue the command.
fnctA pointer to the command's function.
Returns:
True/False - Returns true if everything goes as planned and false if not.

Definition at line 65 of file cmds.c.

References alog(), CMD_HASH_KEY, DEBUG3, dlink_add_tail(), dlink_create(), HASH, strlcpy(), and UserCmdHash.

Referenced by Module_Init().

int AddHelp ( User *  u,
void(*)(User *)  helpcmd 
)

Definition at line 111 of file cmds.c.

References alog(), CMD_HASH_KEY, cmd_help, DEBUG3, dlink_add_tail(), dlink_create(), HASH, and HelpEntry::routine.

Referenced by Module_Init().

static void ClientCmdNull ( User *  u,
char *  av 
) [static]
char* CmdErr ( int  )

Definition at line 305 of file cmds.c.

Referenced by HandleClientCmds().

CmdHash* CmdHashCreate ( User *  u)
void DelCmd ( User *  ,
char *  ,
void(*)(User *, int, char **)  fnct,
void(*)(User *)  hlp 
)

Definition at line 161 of file cmds.c.

References dlink_delete(), DLINK_FOREACH_SAFE, dlink_free(), HASH, and UserCmdHash.

int DelHelp ( User *  u,
void(*)(User *)  helpcmd 
)

Definition at line 132 of file cmds.c.

References CMD_HASH_KEY, cmd_help, dlink_delete(), DLINK_FOREACH, dlink_free(), HASH, and HelpEntry::routine.

Referenced by Module_Close().

int do_cmd ( char *  cmd,
User *  us,
User *  u,
int  argc,
char *  argv 
)

int do_cmd() - Handles a command to a client - do all the santatity checks here.

Parameters:
cmd= The command we are actioning on.
us= A pointer to OUR client struct
u= A pointer to the SRC of the command
ac= The argument count being passed into the command handler - used to see if av is null :)
av= The PARAMATERS to the command - the original command.
Returns:
int 0 = Success 1 = No cmd for it was found. 2 = Access Denied. 3 = Fail something was passed wrong
  • Write this so that it can make more sense in the future
    • Also find a better way to handle user commands, i fear that this isnt the best method of doing this... meh.

Definition at line 220 of file cmds.c.

References alog(), check_access(), CMD_ERR_INDEX, CMD_ERR_OK, CMD_HASH_KEY, cmd_help, debug, DLINK_FOREACH, generictoken(), HASH, LOG_DEBUG2, logcmds, HelpEntry::routine, sendto_logchan(), sendto_one(), and UserCmdHash.

Referenced by HandleClientCmds().

int HELP_FOREACH ( User *  ,
User *   
)

Definition at line 292 of file cmds.c.


Variable Documentation

dlink_list cmd_help[1024]

Definition at line 45 of file cmds.h.

Referenced by AddHelp(), DelHelp(), and do_cmd().

CmdHash* UserCmdHash[1024]

Definition at line 44 of file cmds.h.

Referenced by AddCmd(), DelCmd(), and do_cmd().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines