Definicje | Funkcje | Zmienne

Dokumentacja pliku ekg/commands.c

#include "ekg2-config.h"
#include "win32.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 "bindings.h"
#include "commands.h"
#include "debug.h"
#include "events.h"
#include "configfile.h"
#include "dynstuff.h"
#include "log.h"
#include "metacontacts.h"
#include "msgqueue.h"
#include "protocol.h"
#include "sessions.h"
#include "compat/strlcat.h"
#include "compat/strlcpy.h"
#include "stuff.h"
#include "themes.h"
#include "vars.h"
#include "userlist.h"
#include "scripts.h"
#include "windows.h"
#include "xmalloc.h"
#include "net.h"
#include "queries.h"
#include "dynstuff_inline.h"

Definicje

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

Funkcje

static int command_add_compare (command_t *data1, command_t *data2)
static LIST_FREE_ITEM (list_command_free, command_t *)
 DYNSTUFF_LIST_DECLARE2_SORTED (commands, command_t, command_add_compare, list_command_free, static __DYNSTUFF_LIST_ADD_SORTED, __DYNSTUFF_LIST_REMOVE_SAFE, __DYNSTUFF_LIST_REMOVE_ITER, __DYNSTUFF_LIST_DESTROY) int match_arg(const char *arg
static int cmd_exec_watch_handler (int type, int fd, const char *watch, void *data)
static void cmd_exec_child_handler (child_t *c, int pid, const char *name, int status, void *priv)
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 char * timer_next_call (struct timer *t)
static int cmd_debug_plugins (const char *name, const char **params, session_t *session, const char *target, int quiet)
static int cmd_debug_timers (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_test_iconv (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_at (const char *name, const char **params, session_t *session, const char *target, int quiet)
static int cmd_timer (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 [SEND_NICKS_MAX] = { NULL }
int send_nicks_count = 0
int send_nicks_index = 0
static int quit_command = 0
command_tcommands = NULL
char shortopt
char const char * longopt

Dokumentacja definicji

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

Dokumentacja funkcji

int cmd_alias_exec ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static int cmd_at ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
) [static]
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_timers ( 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_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 ( child_t c,
int  pid,
const char *  name,
int  status,
void *  priv 
) [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_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_iconv ( 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_timer ( 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 int command_add_compare ( command_t data1,
command_t data2 
) [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 
)
DYNSTUFF_LIST_DECLARE2_SORTED ( commands  ,
command_t  ,
command_add_compare  ,
list_command_free  ,
static  __DYNSTUFF_LIST_ADD_SORTED,
__DYNSTUFF_LIST_REMOVE_SAFE  ,
__DYNSTUFF_LIST_REMOVE_ITER  ,
__DYNSTUFF_LIST_DESTROY   
) const
static LIST_FREE_ITEM ( list_command_free  ,
command_t  
) [static]
static char* timer_next_call ( struct timer t  )  [static]

Dokumentacja zmiennych

char const char* longopt
int quit_command = 0 [static]
char* send_nicks[SEND_NICKS_MAX] = { NULL }
char shortopt
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje