ekg/stuff.h File Reference

#include <sys/types.h>
#include <sys/time.h>
#include "win32.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdbool.h>
#include <time.h>
#include "dynstuff.h"
#include "plugins.h"
#include "sessions.h"
#include "userlist.h"

Go to the source code of this file.

Data Structures

struct  child_s
struct  alias
struct  timer
struct  conference
struct  newconference
struct  buffer
struct  buffer_info
struct  color_map

Defines

#define DEBUG_MAX_LINES   50
#define TIMER(x)   int x(int type, void *data)
#define TIMER_SESSION(x)   int x(int type, session_t *s)
#define xisxdigit(c)   isxdigit((int) (unsigned char) c)
#define xisdigit(c)   isdigit((int) (unsigned char) c)
#define xisalpha(c)   isalpha_pl((int) (unsigned char) c)
#define xisalnum(c)   isalnum((int) (unsigned char) c)
#define xisspace(c)   isspace((int) (unsigned char) c)
#define xtolower(c)   tolower((int) (unsigned char) c)
#define xtoupper(c)   toupper((int) (unsigned char) c)
#define ekg_update_status_n(a)   ekg_update_status(session_find(a))

Typedefs

typedef void(*) child_handler_t (struct child_s *c, pid_t pid, const char *name, int status, void *data)
typedef child_s child_t
typedef alias alias_t
typedef newconference newconference_t

Enumerations

enum  mesg_t { MESG_CHECK = -1, MESG_OFF, MESG_ON, MESG_DEFAULT }

Functions

child_tchild_add (plugin_t *plugin, pid_t pid, const char *name, child_handler_t handler, void *private)
child_tchildren_removei (child_t *c)
void children_destroy (void)
void windows_save ()
int alias_add (const char *string, int quiet, int append)
int alias_remove (const char *name, int quiet)
void aliases_destroy ()
char * base64_encode (const char *buf, size_t len)
char * base64_decode (const char *buf)
int buffer_add (struct buffer_info *type, const char *target, const char *line)
int buffer_add_str (struct buffer_info *type, const char *target, const char *str)
char * buffer_tail (struct buffer_info *type)
void buffer_free (struct buffer_info *type)
void changed_auto_save (const char *var)
void changed_display_blinking (const char *var)
void changed_make_window (const char *var)
void changed_mesg (const char *var)
void changed_theme (const char *var)
const char * compile_time ()
conferenceconference_add (session_t *session, const char *string, const char *nicklist, int quiet)
int conference_remove (const char *name, int quiet)
conferenceconference_create (session_t *session, const char *nicks)
conferenceconference_find (const char *name)
conferenceconference_find_by_uids (session_t *s, const char *from, const char **recipients, int count, int quiet)
int conference_set_ignore (const char *name, int flag, int quiet)
int conference_rename (const char *oldname, const char *newname, int quiet)
int conference_participant (struct conference *c, const char *uid)
void conferences_destroy ()
userlist_tnewconference_member_add (newconference_t *conf, const char *uid, const char *nick)
userlist_tnewconference_member_find (newconference_t *conf, const char *uid)
int newconference_member_remove (newconference_t *conf, userlist_t *u)
newconference_tnewconference_create (session_t *s, const char *name, int create_wnd)
newconference_tnewconference_find (session_t *s, const char *name)
void newconference_destroy (newconference_t *conf, int kill_wnd)
void newconferences_destroy ()
int ekg_hash (const char *name)
FILE * help_path (char *name, char *plugin)
int mesg_set (int what)
void iso_to_ascii (unsigned char *buf)
char * strip_spaces (char *line)
int strncasecmp_pl (const char *cs, const char *ct, size_t count)
int strcasecmp_pl (const char *cs, const char *ct)
int mkdir_recursive (const char *pathname, int isdir)
char * saprintf (const char *format,...)
int play_sound (const char *sound_path)
const char * prepare_path (const char *filename, int do_mkdir)
const char * prepare_pathf (const char *filename,...)
const char * prepare_path_user (const char *path)
char * read_file (FILE *f, int alloc)
const char * timestamp (const char *format)
const char * timestamp_time (const char *format, time_t t)
int on_off (const char *value)
char * xstrmid (const char *str, int start, int length)
void xstrtr (char *text, char from, char to)
char color_map (unsigned char r, unsigned char g, unsigned char b)
char * strcasestr (const char *haystack, const char *needle)
int msg_all (session_t *s, const char *function, const char *what)
int say_it (const char *str)
char * split_line (char **ptr)
int isalpha_pl (unsigned char c)
timertimer_add (plugin_t *plugin, const char *name, unsigned int period, int persistent, int(*function)(int, void *), void *data)
timertimer_add_ms (plugin_t *plugin, const char *name, unsigned int period, int persist, int(*function)(int, void *), void *data)
timertimer_add_session (session_t *session, const char *name, unsigned int period, int persist, int(*function)(int, session_t *))
timertimer_find_session (session_t *session, const char *name)
int timer_remove (plugin_t *plugin, const char *name)
int timer_remove_session (session_t *session, const char *name)
int timer_remove_user ()
void timers_remove (struct timer *t)
timertimers_removei (struct timer *t)
void timers_destroy ()
int timer_handle_command (int type, void *data)
const char * ekg_status_label (const int status, const char *descr, const char *prefix)
void ekg_update_status (session_t *session)
const char * ekg_status_string (const int status, const int cmd)
int ekg_status_int (const char *text)
char * ekg_draw_descr (const int status)
uint32_t * ekg_sent_message_format (const char *text)
void ekg_yield_cpu ()
void * ekg_convert_string_init (const char *from, const char *to, void **rev)
void ekg_convert_string_destroy (void *ptr)
char * ekg_convert_string_p (const char *ps, void *ptr)
char * ekg_convert_string (const char *ps, const char *from, const char *to)
string_t ekg_convert_string_t_p (string_t s, void *ptr)
string_t ekg_convert_string_t (string_t s, const char *from, const char *to)
int ekg_converters_display (int quiet)
char * ekg_locale_to_cp (char *buf)
char * ekg_cp_to_locale (char *buf)
char * ekg_locale_to_latin2 (char *buf)
char * ekg_latin2_to_locale (char *buf)
char * ekg_locale_to_utf8 (char *buf)
char * ekg_utf8_to_locale (char *buf)
char * ekg_any_to_locale (char *buf, char *inp)
char * ekg_locale_to_any (char *buf, char *inp)
char * password_input (const char *prompt, const char *rprompt, const bool norepeat)
void ekg_exit ()
void ekg_debug_handler (int level, const char *format, va_list ap)
int ekg_close (int fd)
int ekg_write (int fd, const char *buf, int len)
int ekg_writef (int fd, const char *format,...)

Variables

child_tchildren
alias_taliases
list_t autofinds
timertimers
conferenceconferences
newconference_tnewconferences
buffer_info buffer_debug
buffer_info buffer_speech
time_t last_save
char * config_profile
int config_changed
int reason_changed
pid_t speech_pid
int no_mouse
int old_stderr
int mesg_startup
char * config_audio_device
char * config_away_reason
int config_auto_save
int config_auto_user_add
char * config_back_reason
int config_beep
int config_beep_msg
int config_beep_chat
int config_beep_notify
int config_completion_notify
char * config_completion_char
int config_debug
int config_default_status_window
int config_display_ack
int config_display_blinking
int config_display_color
char * config_display_color_map
int config_display_crap
int config_display_day_changed
int config_display_notify
int config_display_pl_chars
int config_display_sent
int config_display_welcome
int config_emoticons
int config_events_delay
int config_expert_mode
int config_history_savedups
int config_keep_reason
int config_last
int config_last_size
int config_lastlog_case
int config_lastlog_noitems
int config_lastlog_display_all
int config_make_window
int config_mesg
int config_query_commands
int config_slash_messages
char * config_quit_reason
int config_reason_limit
int config_save_password
int config_save_quit
char * config_session_default
int config_sessions_save
int config_sort_windows
char * config_sound_app
char * config_sound_chat_file
char * config_sound_msg_file
char * config_sound_sysmsg_file
char * config_sound_notify_file
char * config_sound_mail_file
char * config_speech_app
char * config_subject_prefix
char * config_subject_reply_prefix
char * config_tab_command
char * config_theme
int config_time_deviation
char * config_timestamp
int config_timestamp_show
int config_use_unicode
int config_use_iso
char * config_console_charset
int config_window_session_allow
char * config_windows_layout
int config_windows_save
char * config_dcc_dir
int config_version
char * config_exit_exec
int config_session_locks
char * config_nickname
char * home_dir
char * config_dir
char * console_charset
int in_autoexec
int ekg_watches_removed
time_t ekg_started
int quit_message_send
int batch_mode
char * batch_line
color_map color_map_default [16+10]


Define Documentation

#define DEBUG_MAX_LINES   50

#define ekg_update_status_n (  )     ekg_update_status(session_find(a))

#define TIMER (  )     int x(int type, void *data)

#define TIMER_SESSION (  )     int x(int type, session_t *s)

#define xisalnum (  )     isalnum((int) (unsigned char) c)

#define xisalpha (  )     isalpha_pl((int) (unsigned char) c)

#define xisdigit (  )     isdigit((int) (unsigned char) c)

#define xisspace (  )     isspace((int) (unsigned char) c)

#define xisxdigit (  )     isxdigit((int) (unsigned char) c)

#define xtolower (  )     tolower((int) (unsigned char) c)

#define xtoupper (  )     toupper((int) (unsigned char) c)


Typedef Documentation

typedef struct alias alias_t

typedef void(*) child_handler_t(struct child_s *c, pid_t pid, const char *name, int status, void *data)

typedef struct child_s child_t

typedef struct newconference newconference_t


Enumeration Type Documentation

enum mesg_t

Enumerator:
MESG_CHECK 
MESG_OFF 
MESG_ON 
MESG_DEFAULT 


Function Documentation

int alias_add ( const char *  string,
int  quiet,
int  append 
)

int alias_remove ( const char *  name,
int  quiet 
)

void aliases_destroy (  ) 

char* base64_decode ( const char *  buf  ) 

char* base64_encode ( const char *  buf,
size_t  len 
)

int buffer_add ( struct buffer_info type,
const char *  target,
const char *  line 
)

int buffer_add_str ( struct buffer_info type,
const char *  target,
const char *  str 
)

void buffer_free ( struct buffer_info type  ) 

char* buffer_tail ( struct buffer_info type  ) 

void changed_auto_save ( const char *  var  ) 

void changed_display_blinking ( const char *  var  ) 

void changed_make_window ( const char *  var  ) 

void changed_mesg ( const char *  var  ) 

void changed_theme ( const char *  var  ) 

child_t* child_add ( plugin_t plugin,
pid_t  pid,
const char *  name,
child_handler_t  handler,
void *  private 
)

void children_destroy ( void   ) 

child_t* children_removei ( child_t c  ) 

char color_map ( unsigned char  r,
unsigned char  g,
unsigned char  b 
)

const char* compile_time (  ) 

struct conference* conference_add ( session_t session,
const char *  string,
const char *  nicklist,
int  quiet 
)

struct conference* conference_create ( session_t session,
const char *  nicks 
)

struct conference* conference_find ( const char *  name  ) 

struct conference* conference_find_by_uids ( session_t s,
const char *  from,
const char **  recipients,
int  count,
int  quiet 
)

int conference_participant ( struct conference c,
const char *  uid 
)

int conference_remove ( const char *  name,
int  quiet 
)

int conference_rename ( const char *  oldname,
const char *  newname,
int  quiet 
)

int conference_set_ignore ( const char *  name,
int  flag,
int  quiet 
)

void conferences_destroy (  ) 

char* ekg_any_to_locale ( char *  buf,
char *  inp 
)

int ekg_close ( int  fd  ) 

ekg_close()

close fd and all watches associated with that fd

Note:
This _should_ be used as replacement for close() (especially in protocol plugins)

char* ekg_convert_string ( const char *  ps,
const char *  from,
const char *  to 
)

ekg_convert_string()

Converts string to specified encoding, replacing invalid chars with question marks.

Note:
Deprecated, in favour of ekg_convert_string_p(). Should be used only on single conversions, where charset pair won't be used again.
Parameters:
ps - string to be converted (it won't be freed).
from - input encoding (if NULL, console_charset will be assumed).
to - output encoding (if NULL, console_charset will be assumed).
Returns:
Pointer to allocated result on success, NULL on failure or when both encodings are equal.
See also:
ekg_convert_string_p() - more optimized version.

void ekg_convert_string_destroy ( void *  ptr  ) 

ekg_convert_string_destroy()

Frees internal data associated with given pointer, and uninitalizes iconv, if it's not needed anymore.

Note:
If 'rev' param was used with ekg_convert_string_init(), this functions must be called two times
  • with returned value, and with rev-associated one.
Parameters:
ptr - pointer returned by ekg_convert_string_init().
See also:
ekg_convert_string_init() - init charset conversion.

ekg_convert_string_p() - main charset conversion function.

void* ekg_convert_string_init ( const char *  from,
const char *  to,
void **  rev 
)

ekg_convert_string_init()

Initialize string conversion thing for two given charsets.

Parameters:
from - input encoding (will be duped; if NULL, console_charset will be assumed).
to - output encoding (will be duped; if NULL, console_charset will be assumed).
rev - pointer to assign reverse conversion into; if NULL, no reverse converter will be initialized.
Returns:
Pointer that should be passed to other ekg_convert_string_*(), even if it's NULL.
See also:
ekg_convert_string_destroy() - deinits charset conversion.

ekg_convert_string_p() - main charset conversion function.

char* ekg_convert_string_p ( const char *  ps,
void *  ptr 
)

ekg_convert_string_p()

Converts string to specified encoding, using pointer returned by ekg_convert_string_init(). Invalid characters in input will be replaced with question marks.

Parameters:
ps - string to be converted (won't be freed).
ptr - pointer returned by ekg_convert_string_init().
Returns:
Pointer to allocated result or NULL, if some failure has occured or no conversion is needed (i.e. resulting string would be same as input).
See also:
ekg_convert_string_init() - init charset conversion.

ekg_convert_string_destroy() - deinits charset conversion.

string_t ekg_convert_string_t ( string_t  s,
const char *  from,
const char *  to 
)

string_t ekg_convert_string_t_p ( string_t  s,
void *  ptr 
)

int ekg_converters_display ( int  quiet  ) 

char* ekg_cp_to_locale ( char *  buf  ) 

void ekg_debug_handler ( int  level,
const char *  format,
va_list  ap 
)

ekg_debug_handler()

debug message [if config_debug set] coming direct from libgadu (by libgadu_debug_handler()) or by debug() or by debug_ext()
XXX, doc more. But function now is ok.

See also:
debug_ext()
Bug:
It can happen than internal string_t line will be not freed.
Parameters:
level 
format 
ap 

char* ekg_draw_descr ( const int  status  ) 

void ekg_exit (  ) 

int ekg_hash ( const char *  name  ) 

char* ekg_latin2_to_locale ( char *  buf  ) 

char* ekg_locale_to_any ( char *  buf,
char *  inp 
)

char* ekg_locale_to_cp ( char *  buf  ) 

char* ekg_locale_to_latin2 ( char *  buf  ) 

char* ekg_locale_to_utf8 ( char *  buf  ) 

uint32_t* ekg_sent_message_format ( const char *  text  ) 

int ekg_status_int ( const char *  text  ) 

const char* ekg_status_label ( const int  status,
const char *  descr,
const char *  prefix 
)

const char* ekg_status_string ( const int  status,
const int  cmd 
)

void ekg_update_status ( session_t session  ) 

char* ekg_utf8_to_locale ( char *  buf  ) 

int ekg_write ( int  fd,
const char *  buf,
int  len 
)

ekg_write()

write data to given fd, if it cannot be done [because system buffer is too small. it'll create watch, and write as soon as possible] XXX, for now it'll always create watch. (You can be notified about state of buffer when you call ekg_write(fd, NULL, -1))

Note:
This _should_ be used as replacement for write()

int ekg_writef ( int  fd,
const char *  format,
  ... 
)

void ekg_yield_cpu (  )  [inline]

ekg_yield_cpu()

releases cpu meant to be called while busy-looping

FILE* help_path ( char *  name,
char *  plugin 
)

int isalpha_pl ( unsigned char  c  ) 

void iso_to_ascii ( unsigned char *  buf  ) 

int mesg_set ( int  what  ) 

int mkdir_recursive ( const char *  pathname,
int  isdir 
)

int msg_all ( session_t s,
const char *  function,
const char *  what 
)

newconference_t* newconference_create ( session_t s,
const char *  name,
int  create_wnd 
)

<