ekg2  GIT master
Struktury danych | Definicje | Funkcje | Zmienne
Dokumentacja pliku commands.c
#include "ekg2.h"
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/utsname.h>
#include "scripts.h"
#include "internal.h"
#include "net.h"
Wykres zależności załączania dla commands.c:

Struktury danych

struct  cmd_exec_info_t
 

Definicje

#define SHOW_IF_S(x, y)   if (show_##x && (u->status == EKG_STATUS_##y)) show = 1;
 

Funkcje

static gint command_compare (gconstpointer a, gconstpointer b)
 
static void list_command_free (void *_data)
 
static void commands_add (command_t *c)
 
void commands_remove (command_t *c)
 
void commands_destroy ()
 
int match_arg (const char *arg, char shortopt, const char *longopt, int longoptlen)
 
void tabnick_add (const char *nick)
 
void tabnick_remove (const char *nick)
 
static void tabnick_flush ()
 
static int cmd_tabclear (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
int cmd_add (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_alias (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_status (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_del (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_exec_watch_handler (int type, int fd, const char *watch, void *data)
 
static void cmd_exec_child_handler (GPid pid, gint status, gpointer data)
 
int cmd_exec (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_eval (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_for (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_help (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_ignore (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
int cmd_list (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_save (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_set (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_quit (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_version (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_test_segv (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_test_send (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_test_addtab (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_test_deltab (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_test_debug (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_test_debug_dump (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_test_debug_theme (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_debug_plugins (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_debug_watches (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_debug_queries (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_debug_query (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_test_dns2_watch (int type, int fd, watch_type_t watch, void *data)
 
static int cmd_test_dns2 (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_test_mem (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_test_fds (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_beep (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_play (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_say (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_reload (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_query (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_echo (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
int command_exec (const char *target, session_t *session, const char *xline, int quiet)
 
int command_exec_params (const char *target, session_t *session, int quiet, const char *command,...)
 
int command_exec_format (const char *target, session_t *session, int quiet, const char *format,...)
 
int cmd_alias_exec (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_conference (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_last (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_queue (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
int cmd_dcc (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_plugin (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_desc (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
static int cmd_me (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
command_tcommand_add (plugin_t *plugin, const char *name, char *params, command_func_t function, command_flags_t flags, char *possibilities)
 
int command_remove (plugin_t *plugin, const char *name)
 
void command_init ()
 

Zmienne

char * send_nicks [100] = { NULL }
 
int send_nicks_count = 0
 
int send_nicks_index = 0
 
static int quit_command = 0
 
GSList * commands = NULL
 

Dokumentacja definicji

◆ SHOW_IF_S

#define SHOW_IF_S (   x,
 
)    if (show_##x && (u->status == EKG_STATUS_##y)) show = 1;

Dokumentacja funkcji

◆ cmd_add()

int cmd_add ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)

◆ cmd_alias()

static int cmd_alias ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_alias_exec()

int cmd_alias_exec ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)

◆ cmd_beep()

static int cmd_beep ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

cmd_beep()

Beep by emiting UI_BEEP event

Nota
UI-PLUGINS should connect to this event, and when they succesfully beep, returns -1. Cause we may have more than 1 UI-PLUGIN, and I really don't like idea, when after /beep I hear 2 or more beeps.
Zwraca
0

◆ cmd_conference()

static int cmd_conference ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_dcc()

int cmd_dcc ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)

◆ cmd_debug_plugins()

static int cmd_debug_plugins ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_debug_queries()

static int cmd_debug_queries ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_debug_query()

static int cmd_debug_query ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_debug_watches()

static int cmd_debug_watches ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_del()

static int cmd_del ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_desc()

static int cmd_desc ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

cmd_desc()

Changes description (params[0]) without changing status
Handler for: /_desc command

Do zrobienia:
Think about it. think, think, think. Maybe let's use queries for it?
Do zrobienia:
Check if session_unidle() is needed.
Parametry
params[0] New description, if NULL than "" will be used.

◆ cmd_echo()

static int cmd_echo ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

cmd_echo()

printq() params[0] if not NULL, or just ""
Handler for: /echo command

Zwraca
0

◆ cmd_eval()

static int cmd_eval ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

cmd_eval()

Execute space seperated commands from params[0]
If you want add params to command use " " sample: /eval "first_commamnd --first_param --second_param" second_command third_command

Handler for: /eval command.

Parametry
params[0] - commands to execute
Zwraca
0

◆ cmd_exec()

int cmd_exec ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)

◆ cmd_exec_child_handler()

static void cmd_exec_child_handler ( GPid  pid,
gint  status,
gpointer  data 
)
static

◆ cmd_exec_watch_handler()

static int cmd_exec_watch_handler ( int  type,
int  fd,
const char *  watch,
void *  data 
)
static

◆ cmd_for()

static int cmd_for ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_help()

static int cmd_help ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_ignore()

static int cmd_ignore ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_last()

static int cmd_last ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_list()

int cmd_list ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)

◆ cmd_me()

static int cmd_me ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_play()

static int cmd_play ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_plugin()

static int cmd_plugin ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

cmd_plugin()

Manage plugins in ekg2 load/unload/list/change plugin prios
Handler for: /plugin command

Do zrobienia:
see XXX's

◆ cmd_query()

static int cmd_query ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_queue()

static int cmd_queue ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

cmd_queue()

Manage ekg2 message queue list.
Handler for: /queue command.

Zwraca
0

◆ cmd_quit()

static int cmd_quit ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_reload()

static int cmd_reload ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_save()

static int cmd_save ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_say()

static int cmd_say ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_set()

static int cmd_set ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_status()

static int cmd_status ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_tabclear()

static int cmd_tabclear ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_test_addtab()

static int cmd_test_addtab ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_test_debug()

static int cmd_test_debug ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_test_debug_dump()

static int cmd_test_debug_dump ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_test_debug_theme()

static int cmd_test_debug_theme ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_test_deltab()

static int cmd_test_deltab ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_test_dns2()

static int cmd_test_dns2 ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_test_dns2_watch()

static int cmd_test_dns2_watch ( int  type,
int  fd,
watch_type_t  watch,
void *  data 
)
static

◆ cmd_test_fds()

static int cmd_test_fds ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_test_mem()

static int cmd_test_mem ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

cmd_test_mem()

Check and printq() how much memory ekg2 use.
Handler for: /_mem command

Nota
OS currently supported: Linux, Solaris, FreeBSD. If your OS isn't supported please give us info.
Błąd:
Need cleanup/rewritting
Zwraca
Memory used by ekg2

◆ cmd_test_segv()

static int cmd_test_segv ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

cmd_test_segv()

It try do Segmentation fault [By writting one byte to @ 0x41414141]
Sad command :(
Handler for: /_segv command.

Zobacz również
handle_sigsegv() - ekg2's handler for SIGSEGV signal
Zwraca
Shouldn't return, SIGSEGV should be raised before. If SIGSEGV not raised return 0

◆ cmd_test_send()

static int cmd_test_send ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

◆ cmd_version()

static int cmd_version ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

cmd_version()

printq() ekg2 VERSION and emit PLUGIN_PRINT_VERSION
Handler for: /version command.

Zwraca
0

◆ command_add()

command_t* command_add ( plugin_t plugin,
const char *  name,
char *  params,
command_func_t  function,
command_flags_t  flags,
char *  possibilities 
)

command_add()

Add command, and make it known for ekg2.

Nota
About params XXX
flag param, there're two types of it. Informational like:
  • COMMAND_ISALIAS - When it's alias command.
  • COMMAND_ISSCRIPT - When it's script command.
    and
    Conditionals, checked at executing command @ command_exec() like: [XXX, dorobic]
  • COMMAND_ENABLEREQPARAMS -
  • COMMAND_PARAMASTARGET
  • SESSION_MUSTBECONNECTED -
  • SESSION_MUSTBELONG
  • SESSION_MUSTHAS
  • SESSION_MUSTHASPRIVATE
Parametry
plugin- plugin which handle this command
name- name of command
params- space seperated paramlist (read note for more details!)
function- function handler
flags- bitmask from commands.h (read note for more details!)
possibilities- optional space separated list of possible params.. completion useful
Zwraca
Pointer to added command_t *, or NULL if name was NULL.

◆ command_compare()

static gint command_compare ( gconstpointer  a,
gconstpointer  b 
)
static

◆ command_exec()

int command_exec ( const char *  target,
session_t session,
const char *  xline,
int  quiet 
)

◆ command_exec_format()

int command_exec_format ( const char *  target,
session_t session,
int  quiet,
const char *  format,
  ... 
)

command_exec_format()

Format string in format and execute formated command Equivalent to:
char *tmp = saprintf(format, ...);
command_exec(target, session, tmp, quiet);
xfree(tmp);

Nota
For more details about string formating functions read man 3 vsnprintf
Zobacz również
command_exec() - If you want/can use non-formating function.. Watch for swaped params! (quiet with format)
Zwraca
0 - If format was NULL
-1 - If command was not found [It's result of command_exec()]
else it returns result of command handler.

◆ command_exec_params()

int command_exec_params ( const char *  target,
session_t session,
int  quiet,
const char *  command,
  ... 
)

◆ command_init()

void command_init ( )

◆ command_remove()

int command_remove ( plugin_t plugin,
const char *  name 
)

◆ commands_add()

static void commands_add ( command_t c)
static

◆ commands_destroy()

void commands_destroy ( )

◆ commands_remove()

void commands_remove ( command_t c)

◆ list_command_free()

static void list_command_free ( void *  _data)
static

◆ match_arg()

int match_arg ( const char *  arg,
char  shortopt,
const char *  longopt,
int  longoptlen 
)

◆ tabnick_add()

void tabnick_add ( const char *  nick)

◆ tabnick_flush()

static void tabnick_flush ( )
static

◆ tabnick_remove()

void tabnick_remove ( const char *  nick)

Dokumentacja zmiennych

◆ commands

GSList* commands = NULL

◆ quit_command

int quit_command = 0
static

◆ send_nicks

char* send_nicks[100] = { NULL }

◆ send_nicks_count

int send_nicks_count = 0

◆ send_nicks_index

int send_nicks_index = 0