ekg2
GIT master
|
#include "ekg2.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <sched.h>
#include <pwd.h>
#include <signal.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
Struktury danych | |
struct | ekg_status_info |
Definicje | |
#define | __sq(x) ((x)*(x)) |
Funkcje | |
void | windows_save () |
static void | list_alias_free (alias_t *data) |
static void | aliases_add (alias_t *new_) |
static alias_t * | aliases_removei (alias_t *elem) |
void | aliases_destroy (void) |
int | alias_add (const char *string, int quiet, int append) |
int | alias_remove (const char *name, int quiet) |
static void | list_buffer_free (struct buffer *data) |
static void | buffers_add (struct buffer **lista, struct buffer *new_) |
static struct buffer * | buffers_removei (struct buffer **lista, struct buffer *elem) |
static void | buffers_destroy (struct buffer **lista) |
static int | buffers_count (struct buffer *lista) |
static struct buffer * | buffers_get_nth (struct buffer *lista, int id) |
static void | buffer_add_common (struct buffer_info *type, const char *target, const char *line, time_t ts) |
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_make_window (const char *var) |
void | changed_mesg (const char *var) |
static gint | auto_save_timer (gint type, gpointer data) |
void | changed_auto_save (const char *var) |
void | changed_display_blinking (const char *var) |
void | changed_theme (const char *var) |
void | changed_config_timestamp (const char *var) |
const char * | compile_time () |
static void | newconference_free_item (newconference_t *data) |
static void | newconferences_add (newconference_t *new_) |
static void | newconferences_remove (newconference_t *elem) |
void | newconferences_destroy (void) |
userlist_t * | newconference_member_find (newconference_t *conf, const char *uid) |
userlist_t * | newconference_member_add (newconference_t *conf, const char *uid, const char *nick) |
int | newconference_member_remove (newconference_t *conf, userlist_t *u) |
newconference_t * | newconference_find (session_t *s, const char *name) |
newconference_t * | newconference_create (session_t *s, const char *name, int create_wnd) |
void | newconference_destroy (newconference_t *conf, int kill_wnd) |
static void | conference_free_item (struct conference *data) |
static void | conferences_add (struct conference *new_) |
static struct conference * | conferences_removei (struct conference *elem) |
void | conferences_destroy (void) |
struct conference * | conference_add (session_t *session, const char *name, const char *nicklist, int quiet) |
int | conference_remove (const char *name, int quiet) |
struct conference * | conference_create (session_t *session, const char *nicks) |
struct conference * | conference_find (const char *name) |
int | conference_participant (struct conference *c, const char *uid) |
struct conference * | conference_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) |
GDataInputStream * | help_open (const gchar *name, const gchar *plugin) |
int | ekg_hash (const char *name) |
int | mesg_set (int what) |
char * | strip_spaces (char *line) |
int | play_sound (const char *sound_path) |
int | mkdir_recursive (const char *pathname, int isdir) |
const char * | prepare_pathf (const char *filename,...) |
const char * | prepare_path (const char *filename, int do_mkdir) |
const char * | prepare_path_user (const char *path) |
static char * | random_line (const char *path) |
char * | read_file_utf (FILE *f, int alloc) |
char * | read_file (FILE *f, int alloc) |
gchar * | read_line (GDataInputStream *f) |
const char * | timestamp (const char *format) |
const char * | timestamp_time (const char *format, time_t t) |
char * | xstrmid (const char *str, int start, int length) |
char | color_map (unsigned char r, unsigned char g, unsigned char b) |
int | isalpha_pl (unsigned char c) |
void | ignore_result_helper (int __attribute__((unused)) dummy,...) |
char * | strcasestr (const char *haystack, const char *needle) |
int | msg_all (session_t *s, const char *function, const char *what) |
static void | speech_child_handler (GPid pid, gint status, gpointer data) |
int | say_it (const char *str) |
void | debug_ext (debug_level_t level, const char *format,...) |
void | debug (const char *format,...) |
char * | base64_encode (const char *buf, size_t len) |
char * | base64_decode (const char *buf) |
char * | split_line (char **ptr) |
const char * | ekg_status_label (const int status, const char *descr, const char *prefix) |
char * | ekg_draw_descr (const int status) |
void | ekg_update_status (session_t *session) |
static const struct ekg_status_info * | status_find (const int status) |
const char * | ekg_status_string (const int status, const int cmd) |
int | ekg_status_int (const char *text) |
guint32 * | ekg_sent_message_format (const char *text) |
int | strncasecmp_pl (const char *cs, const char *ct, size_t count) |
char * | saprintf (const char *format,...) |
void | xstrtr (char *text, char from, char to) |
void | ekg_yield_cpu () |
int | ekg_write (int fd, const char *buf, int len) |
int | ekg_writef (int fd, const char *format,...) |
int | ekg_close (int fd) |
char * | password_input (const char *prompt, const char *rprompt, const bool norepeat) |
int | is_utf8_string (const char *txt) |
static char * | get_variable_value (variable_t *v) |
void | variable_display (variable_t *v, int quiet) |
static variable_t * | get_fake_sess_variable (session_t *s, const char *name) |
int | session_variable_display (session_t *s, const char *name, int quiet) |
void | session_variable_info (session_t *s, const char *name, int quiet) |
#define __sq | ( | x | ) | ((x)*(x)) |
int alias_add | ( | const char * | string, |
int | quiet, | ||
int | append | ||
) |
int alias_remove | ( | const char * | name, |
int | quiet | ||
) |
|
static |
void aliases_destroy | ( | void | ) |
|
static |
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 | ||
) |
Add new line to given buffer_t, if max_lines > 0 than it maintain list that we can have max: max_lines items on it.
type | - pointer to buffer beginning ptr |
target | - name of target.. or just name of smth we want to keep in b->target |
line | - line which we want to save. |
|
static |
int buffer_add_str | ( | struct buffer_info * | type, |
const char * | target, | ||
const char * | str | ||
) |
Add new line to given buffer_t, if max_lines > 0 than it maintain list that we can have max: max_lines items on it.
type | - pointer to buffer beginning ptr |
target | - name of target, or just name of smth we want to keep in b->target |
str | - string in format: [time_when_it_happen proper line... blah, blah] time_when_it_happen should be in digits. |
void buffer_free | ( | struct buffer_info * | type | ) |
Free memory after given buffer.
After it set *type to NULL
type | - pointer to buffer beginning ptr |
char* buffer_tail | ( | struct buffer_info * | type | ) |
Return oldest b->line, free b->target and remove whole buffer_t from list
type | - pointer to buffer beginning ptr |
|
static |
|
static |
void changed_auto_save | ( | const char * | var | ) |
void changed_config_timestamp | ( | 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 | ) |
char color_map | ( | unsigned char | r, |
unsigned char | g, | ||
unsigned char | b | ||
) |
const char* compile_time | ( | ) |
Return compilation date, and time..
Used by /version command and ekg2 –version
struct conference* conference_add | ( | session_t * | session, |
const char * | name, | ||
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 | ||
) |
|
static |
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 | ||
) |
|
static |
void conferences_destroy | ( | void | ) |
|
static |
void debug | ( | const char * | format, |
... | |||
) |
void debug_ext | ( | debug_level_t | level, |
const char * | format, | ||
... | |||
) |
int ekg_close | ( | int | fd | ) |
close fd and all watches associated with that fd
char* ekg_draw_descr | ( | const int | status | ) |
int ekg_hash | ( | const char * | name | ) |
guint32* 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 | ) |
int ekg_write | ( | int | fd, |
const char * | buf, | ||
int | len | ||
) |
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))
int ekg_writef | ( | int | fd, |
const char * | format, | ||
... | |||
) |
|
inline |
releases cpu meant to be called while busy-looping
|
static |
|
static |
GDataInputStream* help_open | ( | const gchar * | name, |
const gchar * | plugin | ||
) |
Open the help file in best language available.
name | - help file basename. |
plugin | - plugin name or NULL if core help is requested. |
void ignore_result_helper | ( | int __attribute__((unused)) | dummy, |
... | |||
) |
int is_utf8_string | ( | const char * | txt | ) |
int isalpha_pl | ( | unsigned char | c | ) |
|
static |
|
static |
int mesg_set | ( | int | what | ) |
int mkdir_recursive | ( | const char * | pathname, |
int | isdir | ||
) |
Create directory pathname and all needed parent directories.
pathname | - path to directory or file (see isdir comment) |
isdir | - if isdir is set, than we should also create dir specified by full pathname path, else we shouldn't do it, because it's filename and we want to create directory only to last '/' char |
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 | ||
) |
void newconference_destroy | ( | newconference_t * | conf, |
int | kill_wnd | ||
) |
newconference_t* newconference_find | ( | session_t * | s, |
const char * | name | ||
) |
|
static |
userlist_t* newconference_member_add | ( | newconference_t * | conf, |
const char * | uid, | ||
const char * | nick | ||
) |
userlist_t* newconference_member_find | ( | newconference_t * | conf, |
const char * | uid | ||
) |
int newconference_member_remove | ( | newconference_t * | conf, |
userlist_t * | u | ||
) |
|
static |
void newconferences_destroy | ( | void | ) |
|
static |
char* password_input | ( | const char * | prompt, |
const char * | rprompt, | ||
const bool | norepeat | ||
) |
Try to get password through UI_PASSWORD_INPUT, printing error messages if needed.
int play_sound | ( | const char * | sound_path | ) |
const char* prepare_path | ( | const char * | filename, |
int | do_mkdir | ||
) |
const char* prepare_path_user | ( | const char * | path | ) |
Converts path given by user to absolute path.
path | - input path. |
const char* prepare_pathf | ( | const char * | filename, |
... | |||
) |
Return path to configdir/profiledir (~/.ekg2 or ~/.ekg2/$PROFILE) and append filename (formated using vsnprintf()) If length of this string is larger than PATH_MAX (4096 on Linux) than unlike prepare_path() it'll return NULL
|
static |
Open file specified by path and select by random one line from file specified by path
path | - path to file. |
char* read_file | ( | FILE * | f, |
int | alloc | ||
) |
Read next line from file f, if needed alloc memory for it.
Remove \r and \n chars from end of line if needed.
f | - opened FILE * |
alloc |
|
char* read_file_utf | ( | FILE * | f, |
int | alloc | ||
) |
gchar* read_line | ( | GDataInputStream * | f | ) |
Read a single line from GDataInputStream.
f | - GDataInputStream to read from. |
char* saprintf | ( | const char * | format, |
... | |||
) |
int say_it | ( | const char * | str | ) |
int session_variable_display | ( | session_t * | s, |
const char * | name, | ||
int | quiet | ||
) |
void session_variable_info | ( | session_t * | s, |
const char * | name, | ||
int | quiet | ||
) |
|
static |
char* split_line | ( | char ** | ptr | ) |
|
static |
char* strcasestr | ( | const char * | haystack, |
const char * | needle | ||
) |
char* strip_spaces | ( | char * | line | ) |
strips spaces from the begining and the end of string line
line | - given string |
int strncasecmp_pl | ( | const char * | cs, |
const char * | ct, | ||
size_t | count | ||
) |
const char* timestamp | ( | const char * | format | ) |
It returns static buffer with formated current time.
format | - format to pass to strftime() [man 3 strftime] |
const char* timestamp_time | ( | const char * | format, |
time_t | t | ||
) |
void variable_display | ( | variable_t * | v, |
int | quiet | ||
) |
void windows_save | ( | ) |
char* xstrmid | ( | const char * | str, |
int | start, | ||
int | length | ||
) |
void xstrtr | ( | char * | text, |
char | from, | ||
char | to | ||
) |
char* batch_line = NULL |
int batch_mode = 0 |
struct buffer_info buffer_debug = { NULL, 0, 50 } |
debug buffer
struct buffer_info buffer_speech = { NULL, 0, 50 } |
speech buffer
struct color_map color_map_default[26] |
struct conference* conferences = NULL |
int config_auto_save = 0 |
int config_auto_user_add = 0 |
char* config_away_reason = NULL |
char* config_back_reason = NULL |
int config_beep = 1 |
int config_beep_chat = 1 |
int config_beep_msg = 1 |
int config_beep_notify = 1 |
int config_changed = 0 |
char* config_completion_char = NULL |
int config_completion_notify = 1 |
char* config_dcc_dir |
int config_debug = 1 |
int config_default_status_window = 0 |
int config_display_ack = 12 |
int config_display_blinking = 1 |
int config_display_color = 1 |
char* config_display_color_map = NULL |
int config_display_notify = 1 |
int config_display_sent = 1 |
int config_display_welcome = 1 |
int config_events_delay = 3 |
char* config_exit_exec = NULL |
int config_expert_mode = 0 |
int config_history_savedups = 1 |
int config_keep_reason = 1 |
int config_make_window = 6 |
int config_mesg = MESG_DEFAULT |
char* config_nickname = NULL |
char* config_profile = NULL |
int config_query_commands = 0 |
char* config_quit_reason = NULL |
int config_save_password = 1 |
int config_save_quit = 1 |
int config_send_white_lines = 0 |
char* config_session_default = NULL |
int config_session_locks = 0 |
int config_sessions_save = 0 |
int config_slash_messages = 0 |
int config_sort_windows = 1 |
char* config_sound_app = NULL |
char* config_sound_chat_file = NULL |
char* config_sound_mail_file = NULL |
char* config_sound_msg_file = NULL |
char* config_sound_notify_file = NULL |
char* config_sound_sysmsg_file = NULL |
char* config_speech_app = NULL |
char* config_subject_prefix |
char* config_subject_reply_prefix |
char* config_tab_command = NULL |
char* config_theme = NULL |
int config_time_deviation = 300 |
char* config_timestamp = NULL |
int config_timestamp_show = 1 |
int config_version = 0 |
int config_window_session_allow = 0 |
char* config_windows_layout = NULL |
int config_windows_save = 0 |
int ekg2_reason_changed = 0 |
time_t ekg_started = 0 |
const struct ekg_status_info ekg_statuses[] |
char* formated_config_timestamp = NULL |
char* home_dir = NULL |
int in_autoexec = 0 |
char* last_search_first_name = NULL |
char* last_search_last_name = NULL |
char* last_search_nickname = NULL |
char* last_search_uid = 0 |
newconference_t* newconferences = NULL |
int old_stderr |
int quit_message_send = 0 |