C plugin APIPlugins
Functions to get infos about plugins.
weechat_plugin_get_name
Prototype:
void weechat_plugin_get_name (struct t_weechat_plugin *plugin);
Get plugin name (return "core" for WeeChat - NULL pointer).
Arguments:
: plugin pointer
Example:
const char *name = weechat_plugin_get_name (plugin);Strings
Many string functions below are already available thru standard C
functions, but it's recommended to use functions in this API because
they are ok with UTF-8 and locale.
weechat_charset_set
Prototype:
void weechat_charset_set (const char *charset);
Set new plugin charset.
Arguments:
: new charset to use
Example:
weechat_charset_set (plugin, "iso-8859-1");weechat_iconv_to_internal
Prototype:
char *weechat_iconv_to_internal (const char *charset, const char *string);
Convert string to WeeChat internal charset (UTF-8).
Arguments:
: charset to convert
: string to convert
Return value: converted string.
Result has to be free by a call to "free" after use.
Example:
char *str = weechat_iconv_to_internal (plugin, "iso-8859-1", "iso string: é à");weechat_iconv_from_internal
Prototype:
char *weechat_iconv_from_internal (const char *charset, const char *string);
Convert string from internal WeeChat charset (UTF-8) to another.
Arguments:
: target charset
: string to convert
Return value: converted string.
Result has to be free by a call to "free" after use.
Example:
char *str = weechat_iconv_from_internal ("iso-8859-1", "utf-8 string: é à");weechat_gettext
Prototype:
const char *weechat_gettext (const char *string);
Return translated string (depends on local language).
Arguments:
: string to translate
Return value: translated string.
Example:
char *str = weechat_gettext ("hello !");weechat_ngettext
Prototype:
const char *weechat_ngettext (const char *string, const char *plural, int count);
Return translated string, using single or plural form, according to
count.
Arguments:
: string to translate (single form)
: string to translate (plural form)
: used to choose between single and plural
form
Return value: translated string.
Example:
char *str = weechat_ngettext ("file", "files", num_files);weechat_strndup
Prototype:
char *weechat_strndup (const char *string, int length);
Return duplicated string, with max "length" chars.
Arguments:
: string to duplicate
: max chars to duplicate
Return value: duplicated string.
Result has to be free by a call to "free" after use.
Example:
char *str = weechat_strndup ("abcdef", 3); /* result: "abc" */weechat_string_tolower
Prototype:
void weechat_string_tolower (const char *string);
Convert UTF-8 string to lower case.
Arguments:
: string to convert
Return value: none.
Example:
weechat_string_tolower ("AbCdEé"); /* result: "abcdeé" */weechat_string_toupper
Prototype:
void weechat_string_toupper (const char *string);
Convert UTF-8 string to upper case.
Arguments:
: string to convert
Return value: none.
Example:
weechat_string_toupper ("AbCdEé"); /* result: "ABCDEé" */weechat_strcasecmp
Prototype:
int weechat_strcasecmp (const char *string1, const char *string2);
Locale and case independent string comparison.
Arguments:
: first string for comparison
: second string for comparison
Return value: difference between two strings: negative if
string1 < string2, zero if string1 == string2, positive if
string1 > string2
Example:
int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */ weechat_strncasecmp
Prototype:
int weechat_strncasecmp (const char *string1, const char *string2, int max);
Locale and case independent string comparison, for "max" chars.
Arguments:
: first string for comparison
: second string for comparison
: max number of chars for comparison
Return value: difference between two strings: negative if
string1 < string2, zero if string1 == string2, positive if
string1 > string2
Example:
int diff = weechat_strncasecmp ("aaa", "CCC", 2); /* == -2 */weechat_strcmp_ignore_chars
Prototype:
int weechat_strcmp_ignore_chars (
const char *string1,
const char *string2,
const char *chars_ignored,
int case_sensitive);
Locale (and optionally case independent) string comparison, ignoring
some chars.
Arguments:
: first string for comparison
: second string for comparison
: string with chars to ignore
: 1 for case sensitive comparison,
0 otherwise
Return value: difference between two strings: negative if
string1 < string2, zero if string1 == string2, positive if
string1 > string2
Example:
int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */weechat_strcasestr
Prototype:
char *weechat_strcasestr (const char *string, const char *search);
Locale and case independent string search.
Arguments:
: string
: string to search in "string"
Return value: pointer to string found, or NULL if not found
Example:
char *pos = weechat_strcasestr ("aBcDeF", "de"); /* result: pointer to "DeF" */weechat_string_match
Prototype:
int weechat_string_match (
const char *string,
const char *mask,
int case_sensitive);
Check if a string matches a mask. Mask may begin or end with "*" (no
other "*" are allowed inside mask).
Arguments:
: string
: mask
: 1 for case sensitive search,
otherwise 0
Return value: 1 if string matches mask, otherwise 0.
Examples:
int match1 = weechat_string_match ("abcdef", "abc*", 0); /* == 1 */
int match2 = weechat_string_match ("abcdef", "*dd*", 0); /* == 0 */
int match3 = weechat_string_match ("abcdef", "*def", 0); /* == 1 */
weechat_string_replace
Prototype:
char *weechat_string_replace (const char *string, const char *search,
const char *replace);
Replace "search" string by new one in a string.
Arguments:
: string
: string to replace
: replacement for "search" string
Return value: string with "search" replaced by "replace".
Result has to be free by a call to "free" after use.
Example:
char *str = weechat_string_replace ("test", "s", "x"); /* result: "text" */weechat_string_remove_quotes
Prototype:
char *weechat_string_remove_quotes (const char *string, const char *quotes);
Remove quotes at beginning/end of string (ignore spaces if there are
before first quote or after last quote).
Arguments:
: string
: string with list of quotes
Return value: string without quotes at beginning/end.
Result has to be free by a call to "free" after use.
Example:
char *str = weechat_string_remove_quotes (string, " 'abc' ", "'"); /* result: "abc" */weechat_string_strip
Prototype:
char *weechat_string_strip (
const char *string,
int left,
int right,
const char *chars);
Strip chars at beginning and/or end of string.
Arguments:
: string
: strip left chars if different from 0
: strip right chars if different from 0
: string with chars to strip
Return value: stripped string.
Result has to be free by a call to "free" after use.
Example:
char *str = weechat_strip (string, " ", 0, 1); /* remove spaces at end of string */weechat_string_has_highlight
Prototype:
int weechat_string_has_highlight (
const char *string,
const char highlight_words);
Check if a string has highlights, using list of highlight words.
Arguments:
: string
: list of highlight words,
separated by comma
Return value: 1 if string has one or more highlights, 0 otherwise.
Example:
if (weechat_string_has_highlight (string, "word1,word2")) ...weechat_string_mask_to_regex
Prototype:
char *weechat_string_mask_to_regex (const char *mask);
Return a regex, built with a mask, where only special char is "*".
All special chars for regex are escaped.
Arguments:
: mask
Return value: regex.
Example:
char *regex = weechat_string_mask_to_regex ("test*mask");weechat_string_explode
Prototype:
char **weechat_string_explode (
const char *string,
const char *separators, int keep_eol,
int num_items_max, int *num_items);
Explode a string according to one or more delimiter(s).
Arguments:
: string to explode
: delimiters used for explosion
: if different from 0, then each
argument will contain all string until end of line (see example
below)
: maximum number of items
created (0 = no limit)
: pointer to int which will
contain number of items created
Return value: array of strings, NULL if problem.
Result has to be free by a call to "weechat_string_free_exploded"
after use.
Examples:
char **argv;
int argc;
argv = weechat_string_explode ("abc de fghi", " ", 0, 0, &argc);
/* result: argv[0] == "abc"
argv[1] == "de"
argv[2] == "fghi"
argv[3] == NULL
argc == 3
*/
weechat_string_free_exploded (argv);
argv = weechat_string_explode ("abc de fghi", " ", 1, 0, &argc);
/* result: argv[0] == "abc de fghi"
argv[1] == "de fghi"
argv[2] == "fghi"
argv[3] == NULL
argc == 3
*/
weechat_string_free_exploded (argv);
weechat_string_free_exploded
Prototype:
void weechat_string_free_exploded (char **exploded_string);
Free memory used by a string explosion.
Arguments:
: string exploded by
"weechat_string_explode" function
Return value: none.
Example:
char *argv;
int argc;
argv = weechat_string_explode (string, " ", 0, 0, &argc);
...
weechat_string_free_exploded (, argv);
weechat_string_build_with_exploded
Prototype:
char *weechat_string_build_with_exploded (
char **exploded_string,
const char *separator);
Build a string with exploded string.
Arguments:
: string exploded by
"weechat_string_explode" function
: string used to separate strings
Return value: string built with exploded string.
Result has to be free by a call to "free" after use.
Example:
char **argv;
int argc;
argv = weechat_string_explode ("abc def ghi", " ", 0, 0, &argc);
char *string = weechat_string_build_with_exploded (argv, ";");
/* string == "abc;def;ghi" */
weechat_string_split_command
Prototype:
char **weechat_string_split_command (const char *command, char separator);
Split a list of commands separated by 'separator' (which can be escaped
by '\' in string).
Arguments:
: command to split
: separator
Return value: array of strings, NULL if problem.
Result has to be free by a call to
"weechat_string_free_splitted_command" after use.
Example:
char **argv = weechat_string_split_command ("/command1;/command2", ';');weechat_string_free_splitted_command
Prototype:
void weechat_string_free_splitted_command (char **splitted_command);
Free memory used by a splitted command.
Arguments:
: command splitted by
"weechat_string_split_commaand" function
Return value: none.
Example:
char **argv = weechat_string_split_command ("/command1;/command2", ';');
...
weechat_string_free_splitted_command (argv);
UTF-8
Some UTF-8 string functions.
weechat_utf8_has_8bits
Prototype:
int weechat_utf8_has_8bits (const char *string);
Check if a string has 8-bits chars.
Arguments:
: string
Return value: 1 if string has 8-buts chars, 0 if only 7-bits chars.
Example:
if (weechat_utf8_has_8bits (string)) ...weechat_utf8_is_valid
Prototype:
int weechat_utf8_is_valid (const char *string, char **error);
Check if a string is UTF-8 valid.
Arguments:
: string
: if not NULL, it is set with first non
valid UTF-8 char in string, if any
Return value: 1 if UTF-8 string is valid, 0 otherwise.
Example:
char *error;
if (weechat_utf8_is_valid (string, &error)) ...
weechat_utf8_normalize
Prototype:
void weechat_utf8_normalize (const char *string, char replacement);
Normalize UTF-8 string: remove non UTF-8 chars and replace them by a
char
Arguments:
: string
: replacement char for non UTF-8 chars
Return value: none.
Example:
weechat_utf8_normalize (string, '?');weechat_utf8_prev_char
Prototype:
char *weechat_utf8_prev_char (const char *string_start, const char *string);
Return previous UTF-8 char in a string.
Arguments:
: start of string (function will not
return a char before this pointer)
: pointer to string (must be >=
string_start)
Return value: pointer to previous UTF-8 char, NULL if not found
(start of string reached)
Example:
char *prev_char = weechat_utf8_prev_char (string, ptr_in_string);weechat_utf8_next_char
Prototype:
char *weechat_utf8_next_char (const char *string);
Return next UTF-8 char in a string.
Arguments:
: string
Return value: pointer to next UTF-8 char, NULL if not found
(end of string reached)
Example:
char *next_char = weechat_utf8_next_char (string);weechat_utf8_char_size
Prototype:
int weechat_utf8_char_size (const char *string);
Return UTF-8 char size (in bytes).
Arguments:
: string
Return value: UTF-8 char size (in bytes).
Example:
int char_size = weechat_utf8_char_size ("être"); /* == 2 */weechat_utf8_strlen
Prototype:
int weechat_utf8_strlen (const char *string);
Return UTF-8 string length (multi-byte char is considered as 1 char).
Arguments:
: string
Return value: UTF-8 string length (number of real chars).
Example:
int length = weechat_utf8_strlen ("chêne"); /* == 5 */weechat_utf8_strnlen
Prototype:
int weechat_utf8_strnlen (const char *string, int bytes);
Return UTF-8 string length (multi-byte char is considered as 1 char),
for max bytes in string
Arguments:
: string
: max bytes in string
Return value: UTF-8 string length (number of real chars).
Example:
int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */weechat_utf8_strlen_screen
Prototype:
int weechat_utf8_strlen_screen (const char *string);
Return number of chars needed on screen to display UTF-8 string.
Arguments:
: string
Return value: number of chars needed on screen to display UTF-8 string.
Example:
int length_on_screen = weechat_utf8_strlen_screen ("东"); /* == 2 */weechat_utf8_charcasecmp
Prototype:
int weechat_utf8_charcasecmp (const char *string1, const char *string2);
Compare two UTF-8 chars (case is ignored).
Arguments:
: first string for comparison
: second string for comparison
Return value: difference between first char of each string: negative if
char1 < char2, zero if char1 == char2, positive if char1 > char2
Example:
if (weechat_utf8_charcasecmp (string1, string2) != 0) ...weechat_utf8_char_size_screen
Prototype:
int weechat_utf8_char_size_screen (const char *string);
Return number of chars needed on screen to display UTF-8 char.
Arguments:
: string
Return value: number of chars needed on screen to display UTF-8 char.
Example:
int length_on_screen = weechat_utf8_char_size_screen (string)weechat_utf8_add_offset
Prototype:
char *weechat_utf8_add_offset (const char *string, int offset);
Move forward N chars in an UTF-8 string.
Arguments:
: string
: number of chars
Return value: pointer to string, N chars after (NULL if it's not
reachable).
Example:
char *ptr = weechat_utf8_add_offset ("chêne", 3); /* points to "ne" */weechat_utf8_real_pos
Prototype:
char *weechat_utf8_real_pos (const char *string, int pos);
Get real position in UTF-8 string.
Arguments:
: string
: position in chars
Return value: real position (in bytes) for "pos" chars in string.
Example:
int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */weechat_utf8_pos
Prototype:
char *weechat_utf8_pos (const char *string, int real_pos);
Get position in UTF-8 string.
Arguments:
: string
: position in bytes
Return value: position (in chars) for "real_pos" bytes in string.
Example:
int pos = weechat_utf8_real_pos ("chêne", 4); /* == 3 */weechat_utf8_strndup
Prototype:
char *weechat_utf8_strndup (const char *string, int max_chars);
Return duplicate string, with max N chars.
Arguments:
: string
: max chars
Return value: duplicated string, NULL if error.
Example:
char *string = weechat_utf8_strndup ("chêne", 3); /* returns "chê" */Directories
Some functions related to directories.
weechat_mkdir_home
Prototype:
int weechat_mkdir_home (char *directory, int mode);
Create a directory in WeeChat home.
Arguments:
: directory to create
: mode for new directory
Return value: 1 if directory was successfully created, 0 if an
error occurred.
Example:
if (!weechat_mkdir_home ("temp")) ... weechat_mkdir
Prototype:
int weechat_mkdir (char *directory, int mode);
Create a directory.
Arguments:
: directory to create
: mode for new directory
Return value: 1 if directory was successfully created, 0 if an
error occurred.
Example:
if (!weechat_mkdir ("/tmp/mydir")) ... weechat_mkdir_parents
Prototype:
int weechat_mkdir_parents (char *directory, int mode);
Create a directory and make parent directories as needed.
Arguments:
: directory to create
: mode for new directory (and parents)
Return value: 1 if directory was successfully created, 0 if an
error occurred.
Example:
if (!weechat_mkdir_parents ("/tmp/my/dir")) ... weechat_exec_on_files
Prototype:
void weechat_exec_on_files (
const char *directory,
void *data,
int (*callback)(void *data, const char *filename));
Find files in a directory and execute a callback on each file.
Arguments:
: directory for searching files
: pointer given to callback when calling it
found
: function called for each file
found, arguments:
TypeNameDescriptionvoid *datapointerchar *filenamefilename found
Return value: none.
Example:
int callback (void *data, const char *filename)
{
/* ... */
return 1;
}
...
plugin->exec_on_files (plugin, "/tmp", &callback);
Util
Some useful functions.
weechat_timeval_cmp
Prototype:
int weechat_timeval_cmp (struct timeval *tv1, struct timeval *tv2);
Compare 2 timeval structures.
Arguments:
: first timeval structure
: second timeval structure
Return value: -1 if tv1 < char2, zero if tv1 == tv2, +1 if tv1 >
tv2
Example:
if (weechat_timeval_cmp (&tv1, &tv2) > 0) ...weechat_timeval_diff
Prototype:
long weechat_timeval_diff (struct timeval *tv1, struct timeval *tv2);
Return difference (in milliseconds) between 2 timeval structures.
Arguments:
: first timeval structure
: second timeval structure
Return value: difference in milliseconds.
Example:
long diff = weechat_timeval_diff (&tv1, &tv2);weechat_timeval_add
Prototype:
void weechat_timeval_add (struct timeval *tv, long interval);
Add interval (in milliseconds) to a timeval structure.
Arguments:
: timeval structure
: interval (in milliseconds)
Return value: none.
Example:
weechat_timeval_add (&tv, 2000); /* add 2 seconds */Sorted lists
Sorted list functions.
weechat_list_new
Prototype:
struct t_weelist *weechat_list_new ();
Create a new list.
Return value: pointer to new list.
Example:
struct t_weelist *list = weechat_list_new ();weechat_list_add
Prototype:
struct t_weelist_item *weechat_list_add (
struct t_weelist *weelist,
const char *data,
const char *where);
Add an item in a list.
Arguments:
: list pointer
: data to insert in list
: position in list (constants are:
WEECHAT_LIST_POS_SORT, WEECHAT_LIST_POS_BEGINNING or
WEECHAT_LIST_POS_END)
Return value: pointer to new item.
Example:
weechat_list_add (list, "my data", WEECHAT_LIST_POS_SORT);weechat_list_search
Prototype:
struct t_weelist_item *weechat_list_search (
struct t_weelist *weelist,
const char *data);
Search an item in a list.
Arguments:
: list pointer
: data to search in list
Return value: pointer to item found, NULL if item was not found.
Example:
struct t_weelist_item *item = weechat_list_search (list, "my data");weechat_list_casesearch
Prototype:
struct t_weelist_item *weechat_list_casesearch (
struct t_weelist *weelist,
const char *data);
Search an item in a list (case sensitive search).
Arguments:
: list pointer
: data to search in list
Return value: pointer to item found, NULL if item was not found.
Example:
struct t_weelist_item *item = weechat_list_casesearch (list, "my data");weechat_list_get
Prototype:
struct t_weelist_item *weechat_list_get (
struct t_weelist *weelist,
int position);
Get an item in a list by position.
Arguments:
: list pointer
: position in list (0 is first item)
Return value: pointer to item found, NULL if item position was not
found.
Example:
struct t_weelist_item *item = weechat_list_get (list, 0); /* first item */weechat_list_set
Prototype:
void weechat_list_set (struct t_weelist_item *item, const char *value);
Set new value for an item.
Arguments:
: item pointer
: new value for item
Example:
weechat_list_set (item, "new data");/weechat_list_next
Prototype:
struct t_weelist_item *weechat_list_next (struct t_weelist_item *item);
Get next item in list.
Arguments:
: item pointer
Return value: pointer to next item, NULL if pointer was last item in
list.
Example:
struct t_weelist_item *next_item = weechat_list_next_item (item);/weechat_list_prev
Prototype:
struct t_weelist_item *weechat_list_prev (struct t_weelist_item *item);
Get previous item in list.
Arguments:
: item pointer
Return value: pointer to previous item, NULL if pointer was first item
in list.
Example:
struct t_weelist_item *prev_item = weechat_list_prev_item (item);/weechat_list_string
Prototype:
const char *weechat_list_string (struct t_weelist_item *item);
Get string value of an item.
Arguments:
: item pointer
Return value: string value of item.
Example:
char *value = weechat_list_string (item);/weechat_list_size
Prototype:
char *weechat_list_size (struct t_weelist *weelist);
Get size of list (number of items).
Arguments:
: list pointer
Return value: size of list (number of items), 0 if list is empty.
Example:
int size = weechat_list_size (list);/weechat_list_remove
Prototype:
void weechat_list_remove (
struct t_weelist *weelist,
struct t_weelist_item *item);
Remove an item in a list.
Arguments:
: list pointer
: item pointer
Example:
weechat_list_remove (list, item);/weechat_list_remove_all
Prototype:
void weechat_list_remove_all (struct t_weelist *weelist);
Remove all items in a list.
Arguments:
: list pointer
Example:
weechat_list_remove_all (list);/weechat_list_free
Prototype:
void weechat_list_free (struct t_weelist *weelist);
Free a list.
Arguments:
: list pointer
Example:
weechat_list_free (list);/Configuration files
Functions for configuration files.
weechat_config_new
Prototype:
struct t_config_file *weechat_config_new (
const char *name,
int (*callback_reload)(void *data,
struct t_config_file *config_file),
void *callback_reload_data);
Create a new configuration file.
Arguments:
: name of configuration file (without path
or extension)
: callback called when
configuration file is reloaded with /reload (optional, may be
NULL), arguments:
TypeNameDescriptionvoid *datapointerstruct t_config_file *config_fileconfiguration file pointer
: pointer given to reload
callback when it is called by WeeChat
NULL)
Return value: pointer to new configuration file, NULL if an error
occured.
File is NOT created by this function. It will be created by call to
function (you
should do that only after adding some sections (with
) and
options (with
).
Example:
int
my_config_reload_cb (void *data, struct t_config_file *config_file)
{
/* ... */
return WEECHAT_RC_OK;
}
struct t_config_file *config_file = weechat_config_new ("test",
&my_config_reload_cb,
NULL);
weechat_config_new_section
Prototype:
struct t_config_section *weechat_config_new_section (
struct t_config_file *config_file,
const char *name,
int user_can_add_options,
int user_can_delete_options,
int (*callback_read)(void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value),
void *callback_read_data,
int (*callback_write)(void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name),
void *callback_write_data,
int (*callback_write_default)(void *data,
struct t_config_file *config_file,
const char *section_name);
void *callback_write_default_data,
int (*callback_create_option)(void *data,
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name,
const char *value),
void *callback_create_option_data,
int (*callback_delete_option)(void *data,
struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option),
void *callback_delete_option_data);
Create a new section in configuration file.
Arguments:
: configuration file pointer
: name of section
: 1 if user can add options
in section, or 0 if it is forbidden
: 1 if user can delete
options in section, or 0 if it is forbidden
: callback called when an option
in section is read from disk (should be NULL for most cases,
except if options in your section need custom function),
arguments:
TypeNameDescriptionvoid *datapointerstruct t_config_file *config_fileconfiguration file pointerstruct t_config_section *sectionsection pointerconst char *option_namename of optionconst char *valuevalue
: pointer given to read
callback when it is called by WeeChat
NULL)
: callback called when section
is written in file (should be NULL for most cases, except if your
section needs to be written by a custom function), arguments:
TypeNameDescriptionvoid *datapointerstruct t_config_file *config_fileconfiguration file pointerstruct t_config_section *sectionsection pointerconst char *option_namename of option
: pointer given to write
callback when it is called by WeeChat
NULL)
: callback called when
default values for section must be written in file, arguments:
TypeNameDescriptionvoid *datapointerstruct t_config_file *config_fileconfiguration file pointerchar *section_namename of section
: pointer given to
write_default callback when it is called by WeeChat
NULL)
: callback called when a
new option is created in section (NULL if section does not allow
new options to be created), arguments:
TypeNameDescriptionvoid *datapointerstruct t_config_file *config_fileconfiguration file pointerstruct t_config_section *sectionsection pointerconst char *option_namename of optionconst char *valuevalue
: pointer given to
create_option callback when it is called by WeeChat
NULL)
: callback called when an
option is deleted (NULL if section does not allow options to be
deleted), arguments:
TypeNameDescriptionvoid *datapointerstruct t_config_file *config_fileconfiguration file pointerstruct t_config_section *sectionsection pointerstruct t_config_option *optionoptionoption pointer
: pointer given to
delete_option callback when it is called by WeeChat
NULL)
Return value: pointer to new section in configuration file, NULL if an
error occured.
Example:
int
my_section_read_cb (void *data, struct t_config_file *config_file,
struct t_config_section *section, const char *option_name,
const char *value)
{
/* ... */
return WEECHAT_RC_OK;
}
int
my_section_write_cb (void *data, struct t_config_file *config_file,
const char *section_name)
{
/* ... */
return WEECHAT_RC_OK;
}
int
my_section_write_default_cb (void *data, struct t_config_file *config_file,
const char *section_name)
{
/* ... */
return WEECHAT_RC_OK;
}
int
my_section_create_option_cb (void *data, struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
/* ... */
return WEECHAT_RC_OK;
}
int
my_section_delete_option_cb (void *data, struct t_config_file *config_file,
struct t_config_section *section,
struct t_config_option *option)
{
/* ... */
return WEECHAT_RC_OK;
}
/* standard section, user can not add/delete options */
struct t_config_section *new_section1 =
weechat_config_new ("section1", 0, 0,
NULL, NULL, /* read callback */
NULL, NULL, /* write callback */
NULL, NULL, /* write default callback */
NULL, NULL, /* create option callback */
NULL, NULL); /* delete option callback */
/* special section, user can add/delete options, and options need
callback to be read/written */
struct t_config_section *new_section2 =
weechat_config_new ("section2", 1, 1,
&my_section_read_cb, NULL,
&my_section_write_cb, NULL,
&my_section_write_default_cb, NULL,
&my_section_create_option_cb, NULL,
&my_section_delete_option_cb, NULL);
weechat_config_search_section
Prototype:
struct t_config_section *weechat_config_search_section (
struct t_config_file *config_file,
const char *section_name);
Search a section in a configuration file.
Arguments:
: configuration file pointer
: name of section to search
Return value: pointer to section found, NULL if section was not found.
Example:
struct t_config_section *section = weechat_config_search_section (config_file, "section");
weechat_config_new_option
Prototype:
struct t_config_option *weechat_config_new_option (
struct t_config_file *config_file,
struct t_config_section *section,
const char *name,
const char *type,
const char *description,
const char *string_values,
int min,
int max,
const chat *default_value,
const char *value,
int (*callback_check_value)(void *data,
struct t_config_option *option,
const char *value),
void *callback_check_value_data,
int (*callback_change)(void *data,
struct t_config_option *option),
void *callback_change_data,
int (*callback_delete)(void *data,
struct t_config_option *option),
void *callback_delete_data);
Create a new option in a section of a configuration file.
Arguments:
: configuration file pointer
: section pointer
: name of option
: type of option, one of:
booleanintegerstringcolor
: description of option
: values as string (separated by
"|"), used for type integer (optional)
: minimum value (for integer)
NULL)
: maximum value (for integer)
: default value for option (used
when option is reset)
: value for option
: callback called to check
new value for an option (optional), arguments:
TypeNameDescriptionvoid *datapointerstruct t_config_option *optionoption pointerconst char *valuenew value for option
: pointer given to
check_value callback when it is called by WeeChat
NULL)
: callback called when value of
option has changed (optional), arguments:
TypeNameDescriptionvoid *datapointerstruct t_config_option *optionoption pointer
: pointer given to change
callback when it is called by WeeChat
NULL)
: callback called when option
will be deleted (optional), arguments:
TypeNameDescriptionvoid *datapointerstruct t_config_option *optionoption pointer
: pointer given to delete
callback when it is called by WeeChat
NULL)
Return value: pointer to new option in section, NULL if an error
occured.
Example:
/* boolean */
struct t_config_option *option1 =
weechat_config_new_option (config_file, section,
"option1", "My option, type boolean"
NULL, /* string values */
0, 0, /* min, max */
"on", /* default */
"on", /* value */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
/* integer */
struct t_config_option *option2 =
weechat_config_new_option (config_file, section,
"option2", "My option, type integer"
NULL, /* string values */
0, 100, /* min, max */
"15", /* default */
"15", /* value */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
/* integer (with string values) */
struct t_config_option *option3 =
weechat_config_new_option (config_file, section,
"option3", "My option, type integer (with string values)"
"top|bottom|left|right", /* string values */
0, 0, /* min, max */
"bottom", /* default */
"bottom", /* value */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
/* string */
struct t_config_option *option4 =
weechat_config_new_option (config_file, section,
"option4", "My option, type string"
NULL, /* string values */
0, 0, /* min, max */
"test", /* default */
"test", /* value */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
/* color */
struct t_config_option *option5 =
weechat_config_new_option (config_file, section,
"option5", "My option, type color"
NULL, /* string values */
0, 0, /* min, max */
"lightblue", /* default */
"lightblue", /* value */
NULL, NULL, /* check callback */
NULL, NULL, /* change callback */
NULL, NULL); /* delete callback */
weechat_config_search_option
Prototype:
struct t_config_option *weechat_config_search_option (
struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name);
Search an option in a section of a configuration file.
Arguments:
: configuration file pointer
: section pointer
: name of option to search
Return value: pointer to option found, NULL if option was not found.
Example:
struct t_config_option *option =
weechat_config_search_option (config_file, section, "option");
weechat_config_search_with_string
Prototype:
void weechat_config_search_with_string (
const char *option_name,
struct t_config_file **config_file,
struct t_config_section **section,
struct t_config_option **option);
Search an option in in a configuration file with string.
Arguments:
: full option name (format:
"file.section.option")
: pointer to a configuration file
pointer, will be set to configuration file of option, if found
: pointer to a section pointer, will be
set to section of option, if found
: pointer to an option pointer, will be
set to option pointer, if found
Example:
struct t_config_file *ptr_config_file;
struct t_config_section *ptr_section;
struct t_config_option *ptr_option;
weechat_config_search_with_string ("file.section.option",
&ptr_config_file,
&ptr_section,
&ptr_option);
if (ptr_option)
{
/* option found */
/* ... */
}
else
{
/* option not found */
/* ... */
}
weechat_config_string_to_boolean
Prototype:
int weechat_config_string_to_boolean (const char *text);
Check if a text is "true" or "false".
Arguments:
: text to analyze
Return value: 1 if text is "true" ("on", "yes", "y", "true", "t", "1"),
or 0 if text is "false" ("off", "no", "n", "false", "f", "0").
Example:
if (weechat_config_string_to_boolean ("on"))
{
/* true */
/* ... */
}
else
{
/* false */
/* never executed! */
}
weechat_config_option_reset
Prototype:
int weechat_config_option_reset (
struct t_config_option *option,
int run_callback);
Reset an option to its default value.
Arguments:
: option pointer
: 1 for calling change callback if
option is changed, 0 otherwise
Return value: WEECHAT_CONFIG_OPTION_SET_OK_CHANGED if option value has
been reset, WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE if value was not
changed, WEECHAT_CONFIG_OPTION_SET_ERROR if an error occured.
Example:
switch (weechat_config_option_reset (option, 1))
{
case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
/* .... */
break;
case WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
/* .... */
break;
case WEECHAT_CONFIG_OPTION_SET_ERROR:
/* .... */
break;
}
weechat_config_option_set
Prototype:
int weechat_config_option_set (
struct t_config_option *option,
const char *value, int run_callback);
Set new value for an option.
Arguments:
: option pointer
: new value for option
: 1 for calling change callback if
option is changed, 0 otherwise
Return value: WEECHAT_CONFIG_OPTION_SET_OK_CHANGED if option value has
been reset, WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE if value was not
changed, WEECHAT_CONFIG_OPTION_SET_ERROR if an error occured.
Example:
switch (weechat_config_option_set (option, "new_value", 1))
{
case WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
/* .... */
break;
case WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
/* .... */
break;
case WEECHAT_CONFIG_OPTION_SET_ERROR:
/* .... */
break;
}
weechat_config_option_unset
Prototype:
int weechat_config_option_unset (struct t_config_option *option);
Unset/reset option.
Arguments:
: option pointer
Return value: WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET if option value
has not been reset, WEECHAT_CONFIG_OPTION_UNSET_OK_RESET if option
value has been reset, WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED if option
has been removed, WEECHAT_CONFIG_OPTION_UNSET_ERROR if an error
occured.
Example:
switch (weechat_config_option_unset (option))
{
case WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET:
/* .... */
break;
case WEECHAT_CONFIG_OPTION_UNSET_OK_RESET:
/* .... */
break;
case WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED:
/* .... */
break;
case WEECHAT_CONFIG_OPTION_UNSET_ERROR:
/* .... */
break;
}
weechat_config_option_rename
Prototype:
void weechat_config_option_rename (
struct t_config_option *option,
const char *new_name);
Rename an option.
Arguments:
: option pointer
: new name for option
Example:
weechat_config_option_rename (option, "new_name");
weechat_config_option_get_pointer
Prototype:
void *weechat_config_option_get_pointer (
struct t_config_option *option,
const char *property);
Get a pointer on an option property.
Arguments:
: option pointer
: property name:
PropertyTypeDescriptionconfig_filestruct t_config_file *configuration file pointersectionstruct t_config_section *section pointernamechar *option nametypeintoption typedescriptionchar *option descriptionstring_valueschar **string valuesminintminimum valuemaxintmaximum valuedefault_value(depends on type)default valuevalue(depends on type)current valueprev_optionstruct t_config_option *previous option pointernext_optionstruct t_config_option *next option pointer
Example:
char *description = weechat_config_option_get_pointer (option, "description");
weechat_config_boolean
Prototype:
int weechat_config_boolean (struct t_config_option *option);
Get boolean value of option.
Arguments:
: option pointer
Return value: boolean value of option (0 or 1).
Example:
if (weechat_config_boolean (option))
{
/* true */
}
else
{
/* false */
}
weechat_config_integer
Prototype:
int weechat_config_integer (struct t_config_option *option);
Get integer value of option.
Arguments:
: option pointer
Return value: integer value of option.
Example:
int value = weechat_config_boolean (option);weechat_config_string
Prototype:
const char *weechat_config_string (struct t_config_option *option);
Get string value of option.
Arguments:
: option pointer
Return value: string value of option.
Example:
char *value = weechat_config_string (option);weechat_config_string
Prototype:
const char *weechat_config_color (struct t_config_option *option);
Get color value of option.
Arguments:
: option pointer
Return value: color value of option (string with name of color).
Example:
char *color = weechat_config_color (option);weechat_config_write_line
Prototype:
void weechat_config_write_line (
struct t_config_file *config_file,
const char *option_name,
const char *value, ...);
Write a line in a configuration file (this function should be called
only in "write" or "write_default" callbacks for a section).
Arguments:
: configuration file pointer
: option name
: value
Example:
int
my_section_write_cb (void *data, struct t_config_file *config_file,
const char *section_name)
{
weechat_config_write_line (config_file, "option", "%s;%d",
"value", 123);
return WEECHAT_RC_OK;
}
weechat_config_write
Prototype:
int weechat_config_write (struct t_config_file *config_file);
Write configuration file to disk.
Arguments:
: configuration file pointer
Return value: WEECHAT_CONFIG_WRITE_OK if configuration was written,
WEECHAT_CONFIG_WRITE_ERROR if an error occured,
WEECHAT_CONFIG_WRITE_MEMORY_ERROR if there was not enough memory.
Example:
switch (weechat_config_write (config_file))
{
case WEECHAT_CONFIG_WRITE_OK:
/* ... */
break;
case WEECHAT_CONFIG_WRITE_ERROR:
/* ... */
break;
case WEECHAT_CONFIG_WRITE_MEMORY_ERROR:
/* ... */
break;
}
weechat_config_read
Prototype:
int weechat_config_read (struct t_config_file *config_file);
Read configuration file from disk.
Arguments:
: configuration file pointer
Return value: WEECHAT_CONFIG_READ_OK if configuration was loaded,
WEECHAT_CONFIG_READ_MEMORY_ERROR if there was not enough memory,
WEECHAT_CONFIG_READ_FILE_NOT_FOUND if file was not found.
Example:
switch (weechat_config_read (config_file))
{
case WEECHAT_CONFIG_READ_OK:
/* ... */
break;
case WEECHAT_CONFIG_READ_MEMORY_ERROR:
/* ... */
break;
case WEECHAT_CONFIG_READ_FILE_NOT_FOUND:
/* ... */
break;
}
weechat_config_reload
Prototype:
int weechat_config_reload (struct t_config_file *config_file);
Reload configuration file from disk.
Arguments:
: configuration file pointer
Return value: WEECHAT_CONFIG_READ_OK if configuration was reloaded,
WEECHAT_CONFIG_READ_MEMORY_ERROR if there was not enough memory,
WEECHAT_CONFIG_READ_FILE_NOT_FOUND if file was not found.
Example:
switch (weechat_config_reload (config_file))
{
case WEECHAT_CONFIG_READ_OK:
/* ... */
break;
case WEECHAT_CONFIG_READ_MEMORY_ERROR:
/* ... */
break;
case WEECHAT_CONFIG_READ_FILE_NOT_FOUND:
/* ... */
break;
}
weechat_config_option_free
Prototype:
void weechat_config_option_free (struct t_config_option *option);
Free an option.
Arguments:
: option pointer
Example:
weechat_config_option_free (option);weechat_config_section_free_options
Prototype:
void weechat_config_section_free_options (struct t_config_section *section);
Free all options in a section.
Arguments:
: section pointer
Example:
weechat_config_section_free_options (section);weechat_config_section_free
Prototype:
void weechat_config_section_free (struct t_config_section *section);
Free a section.
Arguments:
: section pointer
Example:
weechat_config_section_free (section);weechat_config_free
Prototype:
void weechat_config_free (struct t_config_file *config_file);
Free a configuration file.
Arguments:
: configuration file pointer
Example:
weechat_config_free (config_file);weechat_config_get
Prototype:
struct t_config_option *weechat_config_get (const char *option_name);
Search an option in in a configuration file with string.
Arguments:
: full option name (format:
"file.section.option")
Return value: pointer to option found, NULL if option was not found.
Example:
struct t_config_option *option = weechat_config_get ("weechat.look.item_time_format");
weechat_config_get_plugin
Prototype:
const char *weechat_config_get_plugin (const char *option_name);
Search an option in plugins configuration file (plugins.conf), by
adding prefix with current plugin name.
Arguments:
: option name, WeeChat will add
prefix "plugins.var.xxxx." (where xxxx is current plugin name).
Return value: pointer to option found, NULL if option was not found.
Example:
/* if current plugin is "test", then look for value of option
"plugins.var.test.option" in plugins.conf file */
char *value = weechat_config_get_plugin ("option");
weechat_config_set_plugin
Prototype:
int weechat_config_set_plugin (const char *option_name, const char *value);
Set value for option in in plugins configuration file (plugins.conf).
Arguments:
: option name, WeeChat will add
prefix "plugins.var.xxxx." (where xxxx is current plugin name).
Return value: 1 if ok, 0 if an error occured.
Example:
weechat_config_set_plugin ("option", "test_value");
Display
Functions to display text in buffers.
weechat_prefix
Prototype:
const char *weechat_prefix (const char *prefix);
Get a prefix.
Arguments:
: name of prefix:
PrefixDefault valueDescriptionerror=!=error messagenetwork--message from networkaction*self actionjoin-->someone joins current chatquit<--someone leaves current chat
Return value: prefix value, empty string if prefix is not found
(not NULL).
Example:
weechat_printf (NULL, "%sThis is an error...",
weechat_prefix ("error"));
weechat_color
Prototype:
const char *weechat_color (const char *color_name);
Get a string color code for display.
Arguments:
: name of color: may be a WeeChat
color name (from weechat.color.xxx), or a color with optional
background (separated by comma).
Return value: string with color code, or a "reset color" code if color
is not found.
Example:
weechat_printf (NULL, "Color: %sblue %schat default %sred on green",
weechat_color ("blue"),
weechat_color ("chat"),
weechat_color ("red,green"));
weechat_printf
Prototype:
void weechat_printf (struct t_gui_buffer *buffer, const char *message, ...);
Display a message on a buffer.
Arguments:
: buffer pointer, if NULL, message is
displayed on WeeChat buffer.
: message to display
Example:
weechat_printf (NULL, "Hello on WeeChat buffer");
weechat_printf (buffer, "Hello on this buffer");
weechat_printf_date
Prototype:
void weechat_printf_date (
struct t_gui_buffer *buffer, time_t date,
const char *message, ...);
Display a message on a buffer, using a custom date.
Arguments:
: buffer pointer, if NULL, message is
displayed on WeeChat buffer.
: date for message
: message to display
Example:
weechat_printf (NULL, time (NULL) - 120, "Hello, 2 minutes ago");
weechat_printf_tags
Prototype:
void weechat_printf_tags (
struct t_gui_buffer *buffer,
const char *tags,
const char *message, ...);
Display a message on a buffer, using a custom tags.
Arguments:
: buffer pointer, if NULL, message is
displayed on WeeChat buffer.
: tags for message, separated by a comma
: message to display
Example:
weechat_printf_tags (NULL, "notify_message", "Hello with a message notify tag");
weechat_printf_date_tags
Prototype:
void weechat_printf_date_tags (
struct t_gui_buffer *buffer,
time_t date,
const char *tags,
const char *message, ...);
Display a message on a buffer, using a custom date and tags.
Arguments:
: buffer pointer, if NULL, message is
displayed on WeeChat buffer.
: date for message
: tags for message, separated by a comma
: message to display
Example:
weechat_printf_date_tags (NULL, time (NULL) - 120, "notify_message",
"Hello, 2 minutes ago, with a message notify tag");
weechat_printf_y
Prototype:
void weechat_printf_y (
struct t_gui_buffer *buffer,
int y,
const char *message, ...);
Display a message on a line of a buffer with free content (see
).
Arguments:
: buffer pointer, if NULL, message is
displayed on WeeChat buffer.
: line number (0 for first line)
: message to display
Example:
weechat_printf_y (buffer, 2, "My message on third line");
Hooks
Functions to hook/unhook something.
weechat_hook_command
Prototype:
struct t_hook *weechat_hook_command (
const char *command,
const char *description,
const char *args,
const char *args_description,
const char *completion,
int (*callback)(void *data,
struct t_gui_buffer *buffer,
int argc, char **argv,
char **argv_eol),
void *callback_data);
Hook a command.
Arguments:
: new command name
: description of command (displayed
with /help command)
: arguments for command (displayed with
/help command)
: description of arguments
(displayed with /help command)
: completion template for command:
list of completions for each arguments, separated by space. Many
completions are possible for one argument, separated by "|".
Default completion codes are:
CodeCompletion%-Stop completion%*Repeat last completion%bBuffers names%cConfiguration files%fFilename%FFilters%hCommands hooked%iInfos hooked%IInfolists hooked%nNick%oConfiguration option%pPlugin name%PPlugin commands%rBar names%vValue of configuration option%wWeeChat commands%(xxx)Custom completion by plugin (xxx is a completion
code added by a plugin)
: function called when command is used,
arguments:
TypeNameDescriptionvoid *datapointerstruct t_gui_buffer *bufferbuffer where command is executedintargcargument countchar **argvargumentschar **argv_eolarguments (until end of line)
For example, if command called is
/command abc def ghi, then argv and argv_eol
contain following values:
argv[0] == "abc"argv[1] == "def"argv[2] == "ghi"argv_eol[0] == "abc def ghi"argv_eol[1] == "def ghi"argv_eol[2] == "ghi"
: pointer given to callback when it
is called by WeeeChat
Example:
int
my_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
/* ... */
return WEECHAT_RC_OK;
}
struct t_hook *my_command = weechat_hook_command ("mycommand",
"description of my command",
"[command [buffer]]",
"command: WeeChat or plugin command\n"
" buffer: buffer name",
"%w|%p %b", &my_command_cb, NULL);
weechat_hook_timer
Prototype:
struct t_hook *weechat_hook_timer (
long interval,
const char *align_second,
const char *max_calls,
int (*callback)(void *data),
void *callback_data);
Hook a timer.
Arguments:
: interval between two calls
(milliseconds, so 1000 = 1 second)
: alignment on a second: align timer
on a second. For example, if current time is 09:00, if
interval = 60000 (60 seconds), and align_second = 60, then timer
is called each minute when second is 00.
: number of calls to timer (if 0, then
timer has no end)
: function called when time is reached,
arguments:
TypeNameDescriptionvoid *datapointer
: pointer given to callback when it
is called by WeeeChat
Example:
int
my_timer_cb (void *data)
{
/* ... */
return WEECHAT_RC_OK;
}
/* timer called each 20 seconds */
struct t_hook *my_timer = weechat_hook_timer (20 * 1000, 0, 0,
&my_timer_cb, NULL);
weechat_hook_fd
Prototype:
struct t_hook *weechat_hook_fd (
int fd,
int flag_read,
int flag_write,
int flag_exception,
int (*callback)(void *data),
void *callback_data);
Hook a file descriptor (file or socket).
Arguments:
: file descriptor
: 1 for catching read event, 0 for
ignoring it
: 1 for catching write event, 0 for
ignoring it
: 1 for catching exception event,
0 for ignoring it
: function called when a selected event
occurs, arguments:
TypeNameDescriptionvoid *datapointer
: pointer given to callback when it
is called by WeeeChat
Example:
int
my_fd_cb (void *data)
{
/* ... */
return WEECHAT_RC_OK;
}
int sock = socket (AF_INET, SOCK_STREAM, 0);
/* set socket options */
/* ... */
/* hook socket */
struct t_hook *my_fd = weechat_hook_fd (sock,
1, 0, 0,
&my_fd_cb, NULL);
weechat_hook_connect
Prototype:
struct t_hook *weechat_hook_connect (
const char *address,
int port,
int sock,
int ipv6,
void *gnutls_sess,
const char *local_hostname,
int (*callback)(void *data,
int status,
const char *ip_address),
void *callback_data);
Hook a connection (background connection to a remote host).
Arguments:
: name or IP address to connect to
: port number
: socket used to connect
: 1 to use IPv6, 0 to use IPv4
: GnuTLS session (optional)
: function called when connection is ok
or failed, arguments:
TypeNameDescriptionvoid *datapointerintstatus
constant with connection status:
WEECHAT_HOOK_CONNECT_OKWEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUNDWEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUNDWEECHAT_HOOK_CONNECT_CONNECTION_REFUSEDWEECHAT_HOOK_CONNECT_PROXY_ERRORWEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERRORWEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERRORWEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERRORWEECHAT_HOOK_CONNECT_MEMORY_ERRORvoid *datapointer
: pointer given to callback when it
is called by WeeeChat
Example:
int
my_connect_cb (void *data, int status, const char *ip_address)
{
switch (status)
{
case WEECHAT_HOOK_CONNECT_OK:
/* ... */
break;
case WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND:
/* ... */
break;
case WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND:
/* ... */
break;
case WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED:
/* ... */
break;
case WEECHAT_HOOK_CONNECT_PROXY_ERROR:
/* ... */
break;
case WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR:
/* ... */
break;
case WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR:
/* ... */
break;
case WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR:
/* ... */
break;
case WEECHAT_HOOK_CONNECT_MEMORY_ERROR:
/* ... */
break;
}
return WEECHAT_RC_OK;
}
struct t_hook *my_connect = weechat_hook_fd (sock,
1, 0, 0,
&my_connect_cb, NULL);
weechat_hook_print
Prototype:
struct t_hook *weechat_hook_print (
struct t_gui_buffer *buffer,
const char *tags,
const char *message,
int strip_colors,
int (*callback)(void *data,
struct t_gui_buffer *buffer,
time_t date,
int tags_count,
const char **tags,
const char *prefix,
const char *message),
void *callback_data);
Hook a message printed.
Arguments:
: buffer pointer, if NULL, messages from
any buffer are caught
: only messages with these tags (comma
separated list) will be caught (optional)
: only messages with this string will be
caught (optional)
: colors will be stripped from
message displayed, before calling callback
: function called when message is
printed, arguments:
TypeNameDescriptionvoid *datapointerstruct t_gui_buffer *bufferbuffer pointertime_tdatedateinttags_countnumber of tags for lineconst char **tagstags for lineconst char *prefixprefixchar *messagemessage
: pointer given to callback when it
is called by WeeeChat
Example:
int
my_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
int tags_count, const char **tags,
const char *prefix, const char *message)
{
/* ... */
return WEECHAT_RC_OK;
}
/* catch all messages, on all buffers, without color */
struct t_hook *my_print = weechat_hook_print (NULL, NULL, NULL, 1,
&my_print_cb, NULL);
Buffers
Functions to create/query/close buffers.
Missing doc!
Nicklist
Functions for buffer nicklist.
Missing doc!
Bars
Functions for bars.
Missing doc!
Commands
Functions for executing WeeChat commands.
Missing doc!
Network
Network functions.
Missing doc!
Infos
Functions to get infos.
Missing doc!
Infolists
Functions for infolists.
Missing doc!
Upgrade
Functions for WeeChat upgrading.
Missing doc!