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

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

Dokumentacja funkcji

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_alias_exec ( 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

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
static int cmd_conference ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
int cmd_dcc ( 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
static int cmd_debug_queries ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_debug_query ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_debug_watches ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_del ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
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.
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
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
int cmd_exec ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static void cmd_exec_child_handler ( GPid  pid,
gint  status,
gpointer  data 
)
static
static int cmd_exec_watch_handler ( int  type,
int  fd,
const char *  watch,
void *  data 
)
static
static int cmd_for ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_help ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_ignore ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_last ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
int cmd_list ( 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 
)
static
static int cmd_play ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
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
static int cmd_query ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
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
static int cmd_quit ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_reload ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_save ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_say ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_set ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_status ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_tabclear ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_test_addtab ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_test_debug ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_test_debug_dump ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_test_debug_theme ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_test_deltab ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_test_dns2 ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_test_dns2_watch ( int  type,
int  fd,
watch_type_t  watch,
void *  data 
)
static
static int cmd_test_fds ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
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
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
static int cmd_test_send ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static
static int cmd_version ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static

cmd_version()

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

Zwraca
0
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.
static gint command_compare ( gconstpointer  a,
gconstpointer  b 
)
static
int command_exec ( const char *  target,
session_t session,
const char *  xline,
int  quiet 
)
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.
int command_exec_params ( const char *  target,
session_t session,
int  quiet,
const char *  command,
  ... 
)
void command_init ( )
int command_remove ( plugin_t plugin,
const char *  name 
)
static void commands_add ( command_t c)
static
void commands_destroy ( )
void commands_remove ( command_t c)
static void list_command_free ( void *  _data)
static
int match_arg ( const char *  arg,
char  shortopt,
const char *  longopt,
int  longoptlen 
)
void tabnick_add ( const char *  nick)
static void tabnick_flush ( )
static
void tabnick_remove ( const char *  nick)

Dokumentacja zmiennych

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