summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-06-03 10:56:51 +0200
committerSebastien Helleu <flashcode@flashtux.org>2008-06-03 10:56:51 +0200
commit3a53257032a0df8aa5f3b31f14a8e6f4e1f07595 (patch)
tree23d16979c6ee884220afbe148b32981338f7f690 /src/core
parent2b1d7df86c745367cfdf4de13629790197b523b3 (diff)
downloadweechat-3a53257032a0df8aa5f3b31f14a8e6f4e1f07595.zip
Add "const" keyword for some "char *" function arguments (core and plugins API)
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-backtrace.c4
-rw-r--r--src/core/wee-command.c6
-rw-r--r--src/core/wee-config-file.c56
-rw-r--r--src/core/wee-config-file.h63
-rw-r--r--src/core/wee-config.c10
-rw-r--r--src/core/wee-debug.c9
-rw-r--r--src/core/wee-hook.c36
-rw-r--r--src/core/wee-hook.h55
-rw-r--r--src/core/wee-input.c9
-rw-r--r--src/core/wee-input.h4
-rw-r--r--src/core/wee-list.c14
-rw-r--r--src/core/wee-list.h10
-rw-r--r--src/core/wee-log.c4
-rw-r--r--src/core/wee-log.h2
-rw-r--r--src/core/wee-network.c18
-rw-r--r--src/core/wee-network.h2
-rw-r--r--src/core/wee-string.c60
-rw-r--r--src/core/wee-string.h50
-rw-r--r--src/core/wee-upgrade.c8
-rw-r--r--src/core/wee-upgrade.h4
-rw-r--r--src/core/wee-utf8.c78
-rw-r--r--src/core/wee-utf8.h28
-rw-r--r--src/core/wee-util.c12
-rw-r--r--src/core/wee-util.h15
24 files changed, 294 insertions, 263 deletions
diff --git a/src/core/wee-backtrace.c b/src/core/wee-backtrace.c
index 6fff9d7c6..deb85befe 100644
--- a/src/core/wee-backtrace.c
+++ b/src/core/wee-backtrace.c
@@ -50,7 +50,7 @@
*/
void
-weechat_backtrace_printf (char *message, ...)
+weechat_backtrace_printf (const char *message, ...)
{
static char buffer[4096];
va_list argptr;
@@ -69,7 +69,7 @@ weechat_backtrace_printf (char *message, ...)
*/
void
-weechat_backtrace_addr2line (int number, void *address, char *symbol)
+weechat_backtrace_addr2line (int number, void *address, const char *symbol)
{
#ifdef HAVE_BACKTRACE
int rc;
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 7b0ec0576..81b27125d 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -1362,7 +1362,7 @@ command_key (void *data, struct t_gui_buffer *buffer,
*/
void
-command_plugin_list (char *name, int full)
+command_plugin_list (const char *name, int full)
{
struct t_weechat_plugin *ptr_plugin;
struct t_hook *ptr_hook;
@@ -1851,7 +1851,7 @@ command_set_display_section (struct t_config_file *config_file,
void
command_set_display_option (struct t_config_option *option,
- char *message)
+ const char *message)
{
char *color_name;
@@ -1926,7 +1926,7 @@ command_set_display_option (struct t_config_option *option,
*/
int
-command_set_display_option_list (char *message, char *search)
+command_set_display_option_list (const char *message, const char *search)
{
int number_found, section_displayed, length;
struct t_config_file *ptr_config;
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c
index 39604f506..2c7cd8dfa 100644
--- a/src/core/wee-config-file.c
+++ b/src/core/wee-config-file.c
@@ -54,7 +54,7 @@ char *config_boolean_false[] = { "off", "no", "n", "false", "f", "0", NULL };
*/
struct t_config_file *
-config_file_search (char *name)
+config_file_search (const char *name)
{
struct t_config_file *ptr_config;
@@ -77,7 +77,7 @@ config_file_search (char *name)
*/
struct t_config_file *
-config_file_new (struct t_weechat_plugin *plugin, char *name,
+config_file_new (struct t_weechat_plugin *plugin, const char *name,
int (*callback_reload)(void *data,
struct t_config_file *config_file),
void *callback_reload_data)
@@ -149,27 +149,27 @@ config_file_valid_for_plugin (struct t_weechat_plugin *plugin,
*/
struct t_config_section *
-config_file_new_section (struct t_config_file *config_file, char *name,
+config_file_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,
- char *option_name,
- char *value),
+ const char *option_name,
+ const char *value),
void *callback_read_data,
void (*callback_write)(void *data,
struct t_config_file *config_file,
- char *section_name),
+ const char *section_name),
void *callback_write_data,
void (*callback_write_default)(void *data,
struct t_config_file *config_file,
- char *section_name),
+ 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,
- char *option_name,
- char *value),
+ const char *option_name,
+ const char *value),
void *callback_create_option_data)
{
struct t_config_section *new_section;
@@ -215,7 +215,7 @@ config_file_new_section (struct t_config_file *config_file, char *name,
struct t_config_section *
config_file_search_section (struct t_config_file *config_file,
- char *section_name)
+ const char *section_name)
{
struct t_config_section *ptr_section;
@@ -270,7 +270,7 @@ config_file_section_valid_for_plugin (struct t_weechat_plugin *plugin,
*/
struct t_config_option *
-config_file_option_find_pos (struct t_config_section *section, char *name)
+config_file_option_find_pos (struct t_config_section *section, const char *name)
{
struct t_config_option *ptr_option;
@@ -338,13 +338,13 @@ config_file_option_insert_in_section (struct t_config_option *option)
struct t_config_option *
config_file_new_option (struct t_config_file *config_file,
- struct t_config_section *section, char *name,
- char *type, char *description,
- char *string_values, int min, int max,
- char *default_value,
+ struct t_config_section *section, const char *name,
+ const char *type, const char *description,
+ const char *string_values, int min, int max,
+ const char *default_value,
int (*callback_check_value)(void *data,
struct t_config_option *option,
- char *value),
+ const char *value),
void *callback_check_value_data,
void (*callback_change)(void *data,
struct t_config_option *option),
@@ -491,7 +491,7 @@ config_file_new_option (struct t_config_file *config_file,
struct t_config_option *
config_file_search_option (struct t_config_file *config_file,
struct t_config_section *section,
- char *option_name)
+ const char *option_name)
{
struct t_config_section *ptr_section;
struct t_config_option *ptr_option;
@@ -531,7 +531,7 @@ config_file_search_option (struct t_config_file *config_file,
void
config_file_search_section_option (struct t_config_file *config_file,
struct t_config_section *section,
- char *option_name,
+ const char *option_name,
struct t_config_section **section_found,
struct t_config_option **option_found)
{
@@ -579,7 +579,7 @@ config_file_search_section_option (struct t_config_file *config_file,
*/
void
-config_file_search_with_string (char *option_name,
+config_file_search_with_string (const char *option_name,
struct t_config_file **config_file,
struct t_config_section **section,
struct t_config_option **option,
@@ -688,7 +688,7 @@ config_file_option_valid_for_plugin (struct t_weechat_plugin *plugin,
*/
int
-config_file_string_boolean_is_valid (char *text)
+config_file_string_boolean_is_valid (const char *text)
{
int i;
@@ -717,7 +717,7 @@ config_file_string_boolean_is_valid (char *text)
*/
int
-config_file_string_to_boolean (char *text)
+config_file_string_to_boolean (const char *text)
{
int i;
@@ -859,7 +859,7 @@ config_file_option_reset (struct t_config_option *option, int run_callback)
*/
int
-config_file_option_set (struct t_config_option *option, char *value,
+config_file_option_set (struct t_config_option *option, const char *value,
int run_callback)
{
int value_int, i, rc, length_option, new_value_ok;
@@ -1151,7 +1151,8 @@ config_file_option_unset (struct t_config_option *option)
*/
void
-config_file_option_rename (struct t_config_option *option, char *new_name)
+config_file_option_rename (struct t_config_option *option,
+ const char *new_name)
{
if (!new_name || !new_name[0])
return;
@@ -1184,7 +1185,8 @@ config_file_option_rename (struct t_config_option *option, char *new_name)
*/
void *
-config_file_option_get_pointer (struct t_config_option *option, char *property)
+config_file_option_get_pointer (struct t_config_option *option,
+ const char *property)
{
if (string_strcasecmp (property, "config_file") == 0)
return option->config_file;
@@ -1225,7 +1227,7 @@ config_file_option_get_pointer (struct t_config_option *option, char *property)
*/
int
-config_file_option_set_with_string (char *option_name, char *value)
+config_file_option_set_with_string (const char *option_name, const char *value)
{
int rc;
struct t_config_file *ptr_config;
@@ -1275,7 +1277,7 @@ config_file_option_set_with_string (char *option_name, char *value)
*/
int
-config_file_option_unset_with_string (char *option_name)
+config_file_option_unset_with_string (const char *option_name)
{
struct t_config_option *ptr_option;
int rc;
@@ -1437,7 +1439,7 @@ config_file_write_option (struct t_config_file *config_file,
void
config_file_write_line (struct t_config_file *config_file,
- char *option_name, char *value, ...)
+ const char *option_name, const char *value, ...)
{
char buf[4096];
va_list argptr;
diff --git a/src/core/wee-config-file.h b/src/core/wee-config-file.h
index a11829caa..1b2315287 100644
--- a/src/core/wee-config-file.h
+++ b/src/core/wee-config-file.h
@@ -63,24 +63,25 @@ struct t_config_section
(void *data, /* config file (only for some */
struct t_config_file *config_file, /* special sections) */
struct t_config_section *section,
- char *option_name,
- char *value);
+ const char *option_name,
+ const char *value);
void *callback_read_data; /* data sent to read callback */
void (*callback_write) /* called to write options */
(void *data, /* in config file (only for some */
struct t_config_file *config_file, /* special sections) */
- char *section_name);
+ const char *section_name);
void *callback_write_data; /* data sent to write callback */
void (*callback_write_default) /* called to write default */
(void *data, /* options in config file */
struct t_config_file *config_file,
- char *section_name);
+ const char *section_name);
void *callback_write_default_data; /* data sent to write def. callb.*/
int (*callback_create_option) /* called to create option in */
(void *data, /* section */
struct t_config_file *config_file,
struct t_config_section *section,
- char *option_name, char *value);
+ const char *option_name,
+ const char *value);
void *callback_create_option_data; /* data sent to create callback */
struct t_config_option *options; /* options in section */
struct t_config_option *last_option; /* last option in section */
@@ -112,7 +113,7 @@ struct t_config_option
int (*callback_check_value) /* called to check value before */
(void *data, /* assiging new value */
struct t_config_option *option,
- char *value);
+ const char *value);
void *callback_check_value_data; /* data sent to check callback */
void (*callback_change) /* called when value is changed */
(void *data,
@@ -130,52 +131,52 @@ struct t_config_option
extern struct t_config_file *config_files;
extern struct t_config_file *last_config_file;
-extern struct t_config_file *config_file_search (char *name);
+extern struct t_config_file *config_file_search (const char *name);
extern struct t_config_file *config_file_new (struct t_weechat_plugin *plugin,
- char *name,
+ const char *name,
int (*callback_reload)(void *data,
struct t_config_file *config_file),
void *callback_data);
extern int config_file_valid_for_plugin (struct t_weechat_plugin *plugin,
struct t_config_file *config_file);
extern struct t_config_section *config_file_new_section (struct t_config_file *config_file,
- char *name,
+ 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,
- char *option_name,
- char *value),
+ const char *option_name,
+ const char *value),
void *callback_read_data,
void (*callback_write)(void *data,
struct t_config_file *config_file,
- char *section_name),
+ const char *section_name),
void *callback_write_data,
void (*callback_write_default)(void *data,
struct t_config_file *config_file,
- char *section_name),
+ 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,
- char *option_name,
- char *value),
+ const char *option_name,
+ const char *value),
void *callback_create_option_data);
extern struct t_config_section *config_file_search_section (struct t_config_file *config_file,
- char *section_name);
+ const char *section_name);
extern int config_file_section_valid_for_plugin (struct t_weechat_plugin *plugin,
struct t_config_section *);
extern struct t_config_option *config_file_new_option (struct t_config_file *config_file,
struct t_config_section *section,
- char *name, char *type,
- char *description,
- char *string_values,
+ const char *name, const char *type,
+ const char *description,
+ const char *string_values,
int min, int max,
- char *default_value,
+ const char *default_value,
int (*callback_check_value)(void *data,
struct t_config_option *option,
- char *value),
+ const char *value),
void *callback_check_value_data,
void (*callback_change)(void *data,
struct t_config_option *option),
@@ -185,38 +186,38 @@ extern struct t_config_option *config_file_new_option (struct t_config_file *con
void *callback_delete_data);
extern struct t_config_option *config_file_search_option (struct t_config_file *config_file,
struct t_config_section *section,
- char *option_name);
+ const char *option_name);
extern void config_file_search_section_option (struct t_config_file *config_file,
struct t_config_section *section,
- char *option_name,
+ const char *option_name,
struct t_config_section **section_found,
struct t_config_option **option_found);
-extern void config_file_search_with_string (char *option_name,
+extern void config_file_search_with_string (const char *option_name,
struct t_config_file **config_file,
struct t_config_section **section,
struct t_config_option **option,
char **pos_option_name);
extern int config_file_option_valid_for_plugin (struct t_weechat_plugin *plugin,
struct t_config_option *option);
-extern int config_file_string_to_boolean (char *text);
+extern int config_file_string_to_boolean (const char *text);
extern int config_file_option_reset (struct t_config_option *option,
int run_callback);
extern int config_file_option_set (struct t_config_option *option,
- char *value, int run_callback);
+ const char *value, int run_callback);
extern int config_file_option_unset (struct t_config_option *option);
extern void config_file_option_rename (struct t_config_option *option,
- char *new_name);
+ const char *new_name);
extern void *config_file_option_get_pointer (struct t_config_option *option,
- char *property);
-extern int config_file_option_set_with_string (char *option_name, char *value);
-extern int config_file_option_unset_with_string (char *option_name);
+ const char *property);
+extern int config_file_option_set_with_string (const char *option_name, const char *value);
+extern int config_file_option_unset_with_string (const char *option_name);
extern int config_file_option_boolean (struct t_config_option *option);
extern int config_file_option_integer (struct t_config_option *option);
extern char *config_file_option_string (struct t_config_option *option);
extern int config_file_option_color (struct t_config_option *option);
extern void config_file_write_line (struct t_config_file *config_file,
- char *option_name, char *value, ...);
+ const char *option_name, const char *value, ...);
extern int config_file_write (struct t_config_file *config_files);
extern int config_file_read (struct t_config_file *config_file);
extern int config_file_reload (struct t_config_file *config_file);
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 198561248..de77a7fc1 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -528,7 +528,7 @@ config_weechat_reload (void *data, struct t_config_file *config_file)
int
config_weechat_bar_read (void *data, struct t_config_file *config_file,
struct t_config_section *section,
- char *option_name, char *value)
+ const char *option_name, const char *value)
{
char *pos_option, *bar_name;
struct t_gui_bar *ptr_temp_bar;
@@ -599,7 +599,7 @@ int
config_weechat_filter_read (void *data,
struct t_config_file *config_file,
struct t_config_section *section,
- char *option_name, char *value)
+ const char *option_name, const char *value)
{
char **argv, **argv_eol;
int argc;
@@ -635,7 +635,7 @@ config_weechat_filter_read (void *data,
void
config_weechat_filter_write (void *data, struct t_config_file *config_file,
- char *section_name)
+ const char *section_name)
{
struct t_gui_filter *ptr_filter;
@@ -664,7 +664,7 @@ config_weechat_filter_write (void *data, struct t_config_file *config_file,
int
config_weechat_key_read (void *data, struct t_config_file *config_file,
struct t_config_section *section,
- char *option_name, char *value)
+ const char *option_name, const char *value)
{
/* make C compiler happy */
(void) data;
@@ -694,7 +694,7 @@ config_weechat_key_read (void *data, struct t_config_file *config_file,
void
config_weechat_key_write (void *data, struct t_config_file *config_file,
- char *section_name)
+ const char *section_name)
{
struct t_gui_key *ptr_key;
char *expanded_name;
diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c
index 7e09b9a90..53477f215 100644
--- a/src/core/wee-debug.c
+++ b/src/core/wee-debug.c
@@ -99,7 +99,8 @@ debug_dump (int crash)
*/
int
-debug_dump_cb (void *data, char *signal, char *type_data, void *signal_data)
+debug_dump_cb (void *data, const char *signal, const char *type_data,
+ void *signal_data)
{
/* make C compiler happy */
(void) data;
@@ -150,7 +151,8 @@ debug_sigsegv ()
*/
int
-debug_buffer_cb (void *data, char *signal, char *type_data, void *signal_data)
+debug_buffer_cb (void *data, const char *signal, const char *type_data,
+ void *signal_data)
{
/* make C compiler happy */
(void) data;
@@ -229,7 +231,8 @@ debug_windows_tree ()
*/
int
-debug_windows_cb (void *data, char *signal, char *type_data, void *signal_data)
+debug_windows_cb (void *data, const char *signal, const char *type_data,
+ void *signal_data)
{
/* make C compiler happy */
(void) data;
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c
index 43ecb6d8f..98b853e9f 100644
--- a/src/core/wee-hook.c
+++ b/src/core/wee-hook.c
@@ -293,7 +293,7 @@ hook_exec_end ()
*/
struct t_hook *
-hook_search_command (char *command)
+hook_search_command (const char *command)
{
struct t_hook *ptr_hook;
@@ -314,8 +314,10 @@ hook_search_command (char *command)
*/
struct t_hook *
-hook_command (struct t_weechat_plugin *plugin, char *command, char *description,
- char *args, char *args_description, char *completion,
+hook_command (struct t_weechat_plugin *plugin, const char *command,
+ const char *description,
+ const char *args, const char *args_description,
+ const char *completion,
t_hook_callback_command *callback, void *callback_data)
{
struct t_hook *ptr_hook,*new_hook;
@@ -382,7 +384,7 @@ hook_command (struct t_weechat_plugin *plugin, char *command, char *description,
int
hook_command_exec (struct t_gui_buffer *buffer, int any_plugin,
- struct t_weechat_plugin *plugin, char *string)
+ struct t_weechat_plugin *plugin, const char *string)
{
struct t_hook *ptr_hook, *next_hook;
struct t_hook *hook_for_plugin, *hook_for_other_plugin;
@@ -791,8 +793,8 @@ hook_fd_exec (fd_set *read_fds, fd_set *write_fds, fd_set *exception_fds)
*/
struct t_hook *
-hook_connect (struct t_weechat_plugin *plugin, char *address, int port,
- int sock, int ipv6, void *gnutls_sess, char *local_hostname,
+hook_connect (struct t_weechat_plugin *plugin, const char *address, int port,
+ int sock, int ipv6, void *gnutls_sess, const char *local_hostname,
t_hook_callback_connect *callback, void *callback_data)
{
struct t_hook *new_hook;
@@ -847,7 +849,7 @@ hook_connect (struct t_weechat_plugin *plugin, char *address, int port,
struct t_hook *
hook_print (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer,
- char *tags, char *message, int strip_colors,
+ const char *tags, const char *message, int strip_colors,
t_hook_callback_print *callback, void *callback_data)
{
struct t_hook *new_hook;
@@ -892,7 +894,7 @@ hook_print (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer,
void
hook_print_exec (struct t_gui_buffer *buffer, time_t date, int tags_count,
- char **tags_array, char *prefix, char *message)
+ char **tags_array, const char *prefix, const char *message)
{
struct t_hook *ptr_hook, *next_hook;
char *prefix_no_color, *message_no_color;
@@ -987,7 +989,7 @@ hook_print_exec (struct t_gui_buffer *buffer, time_t date, int tags_count,
*/
struct t_hook *
-hook_signal (struct t_weechat_plugin *plugin, char *signal,
+hook_signal (struct t_weechat_plugin *plugin, const char *signal,
t_hook_callback_signal *callback, void *callback_data)
{
struct t_hook *new_hook;
@@ -1022,7 +1024,7 @@ hook_signal (struct t_weechat_plugin *plugin, char *signal,
*/
void
-hook_signal_send (char *signal, char *type_data, void *signal_data)
+hook_signal_send (const char *signal, const char *type_data, void *signal_data)
{
struct t_hook *ptr_hook, *next_hook;
@@ -1054,7 +1056,7 @@ hook_signal_send (char *signal, char *type_data, void *signal_data)
*/
struct t_hook *
-hook_config (struct t_weechat_plugin *plugin, char *option,
+hook_config (struct t_weechat_plugin *plugin, const char *option,
t_hook_callback_config *callback, void *callback_data)
{
struct t_hook *new_hook;
@@ -1086,7 +1088,7 @@ hook_config (struct t_weechat_plugin *plugin, char *option,
*/
void
-hook_config_exec (char *option, char *value)
+hook_config_exec (const char *option, const char *value)
{
struct t_hook *ptr_hook, *next_hook;
@@ -1119,7 +1121,7 @@ hook_config_exec (char *option, char *value)
*/
struct t_hook *
-hook_completion (struct t_weechat_plugin *plugin, char *completion,
+hook_completion (struct t_weechat_plugin *plugin, const char *completion,
t_hook_callback_completion *callback, void *callback_data)
{
struct t_hook *new_hook;
@@ -1154,7 +1156,7 @@ hook_completion (struct t_weechat_plugin *plugin, char *completion,
*/
void
-hook_completion_exec (struct t_weechat_plugin *plugin, char *completion,
+hook_completion_exec (struct t_weechat_plugin *plugin, const char *completion,
struct t_gui_buffer *buffer, struct t_weelist *list)
{
struct t_hook *ptr_hook, *next_hook;
@@ -1191,7 +1193,7 @@ hook_completion_exec (struct t_weechat_plugin *plugin, char *completion,
*/
struct t_hook *
-hook_modifier (struct t_weechat_plugin *plugin, char *modifier,
+hook_modifier (struct t_weechat_plugin *plugin, const char *modifier,
t_hook_callback_modifier *callback, void *callback_data)
{
struct t_hook *new_hook;
@@ -1226,8 +1228,8 @@ hook_modifier (struct t_weechat_plugin *plugin, char *modifier,
*/
char *
-hook_modifier_exec (struct t_weechat_plugin *plugin, char *modifier,
- char *modifier_data, char *string)
+hook_modifier_exec (struct t_weechat_plugin *plugin, const char *modifier,
+ const char *modifier_data, const char *string)
{
struct t_hook *ptr_hook, *next_hook;
char *new_msg, *message_modified;
diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h
index 22d7cf552..ab7e7fa4c 100644
--- a/src/core/wee-hook.h
+++ b/src/core/wee-hook.h
@@ -135,8 +135,8 @@ struct t_hook_connect
typedef int (t_hook_callback_print)(void *data, struct t_gui_buffer *buffer,
time_t date, int tags_count,
- char **tags, char *prefix,
- char *message);
+ char **tags, const char *prefix,
+ const char *message);
struct t_hook_print
{
@@ -148,8 +148,8 @@ struct t_hook_print
int strip_colors; /* strip colors in msg for callback? */
};
-typedef int (t_hook_callback_signal)(void *data, char *signal,
- char *type_data, void *signal_data);
+typedef int (t_hook_callback_signal)(void *data, const char *signal,
+ const char *type_data, void *signal_data);
struct t_hook_signal
{
@@ -158,7 +158,8 @@ struct t_hook_signal
/* with "*", "*" == any signal) */
};
-typedef int (t_hook_callback_config)(void *data, char *option, char *value);
+typedef int (t_hook_callback_config)(void *data, const char *option,
+ const char *value);
struct t_hook_config
{
@@ -167,7 +168,7 @@ struct t_hook_config
/* (NULL = hook for all options) */
};
-typedef int (t_hook_callback_completion)(void *data, char *completion,
+typedef int (t_hook_callback_completion)(void *data, const char *completion,
struct t_gui_buffer *buffer,
struct t_weelist *list);
@@ -177,8 +178,9 @@ struct t_hook_completion
char *completion; /* name of completion */
};
-typedef char *(t_hook_callback_modifier)(void *data, char *modifier,
- char *modifier_data, char *string);
+typedef char *(t_hook_callback_modifier)(void *data, const char *modifier,
+ const char *modifier_data,
+ const char *string);
struct t_hook_modifier
{
@@ -198,13 +200,13 @@ extern int hook_valid (struct t_hook *hook);
extern int hook_valid_for_plugin (struct t_weechat_plugin *plugin,
struct t_hook *hook);
extern struct t_hook *hook_command (struct t_weechat_plugin *plugin,
- char *command, char *description,
- char *args, char *args_description,
- char *completion,
+ const char *command, const char *description,
+ const char *args, const char *args_description,
+ const char *completion,
t_hook_callback_command *callback,
void *callback_data);
extern int hook_command_exec (struct t_gui_buffer *buffer, int any_plugin,
- struct t_weechat_plugin *plugin, char *string);
+ struct t_weechat_plugin *plugin, const char *string);
extern struct t_hook *hook_timer (struct t_weechat_plugin *plugin,
long interval, int align_second,
int max_calls,
@@ -222,46 +224,47 @@ extern int hook_fd_set (fd_set *read_fds, fd_set *write_fds,
extern void hook_fd_exec (fd_set *read_fds, fd_set *write_fds,
fd_set *exception_fds);
extern struct t_hook *hook_connect (struct t_weechat_plugin *plugin,
- char *address, int port,
+ const char *address, int port,
int sock, int ipv6, void *gnutls_session,
- char *local_hostname,
+ const char *local_hostname,
t_hook_callback_connect * callback,
void *callback_data);
extern struct t_hook *hook_print (struct t_weechat_plugin *plugin,
struct t_gui_buffer *buffer,
- char *tags, char *message,
+ const char *tags, const char *message,
int strip_colors,
t_hook_callback_print *callback,
void *callback_data);
extern void hook_print_exec (struct t_gui_buffer *buffer,
time_t date, int tags_count,
- char **tags_array, char *prefix,
- char *message);
+ char **tags_array, const char *prefix,
+ const char *message);
extern struct t_hook *hook_signal (struct t_weechat_plugin *plugin,
- char *signal,
+ const char *signal,
t_hook_callback_signal *callback,
void *callback_data);
-extern void hook_signal_send (char *signal, char *type_data,
+extern void hook_signal_send (const char *signal, const char *type_data,
void *signal_data);
-extern struct t_hook *hook_config (struct t_weechat_plugin *, char *option,
+extern struct t_hook *hook_config (struct t_weechat_plugin *, const char *option,
t_hook_callback_config *callback,
void *callback_data);
-extern void hook_config_exec (char *option, char *value);
+extern void hook_config_exec (const char *option, const char *value);
extern struct t_hook *hook_completion (struct t_weechat_plugin *plugin,
- char *completion,
+ const char *completion,
t_hook_callback_completion *callback,
void *callback_data);
extern void hook_completion_exec (struct t_weechat_plugin *plugin,
- char *completion,
+ const char *completion,
struct t_gui_buffer *buffer,
struct t_weelist *list);
extern struct t_hook *hook_modifier (struct t_weechat_plugin *plugin,
- char *modifier,
+ const char *modifier,
t_hook_callback_modifier *callback,
void *callback_data);
extern char *hook_modifier_exec (struct t_weechat_plugin *plugin,
- char *modifier, char *modifier_data,
- char *string);
+ const char *modifier,
+ const char *modifier_data,
+ const char *string);
extern void unhook (struct t_hook *hook);
extern void unhook_all_plugin (struct t_weechat_plugin *plugin);
extern void unhook_all ();
diff --git a/src/core/wee-input.c b/src/core/wee-input.c
index f2f3adc59..c42a519e9 100644
--- a/src/core/wee-input.c
+++ b/src/core/wee-input.c
@@ -42,7 +42,7 @@
*/
int
-input_is_command (char *line)
+input_is_command (const char *line)
{
char *pos_slash, *pos_space;
@@ -69,7 +69,7 @@ int
input_exec_command (struct t_gui_buffer *buffer,
int any_plugin,
struct t_weechat_plugin *plugin,
- char *string)
+ const char *string)
{
int rc;
char *command, *pos, *ptr_args;
@@ -136,9 +136,10 @@ input_exec_command (struct t_gui_buffer *buffer,
*/
void
-input_data (struct t_gui_buffer *buffer, char *data)
+input_data (struct t_gui_buffer *buffer, const char *data)
{
- char *new_data, *ptr_data, *pos;
+ char *new_data, *pos;
+ const char *ptr_data;
if (!buffer || !data || !data[0] || (data[0] == '\r') || (data[0] == '\n'))
return;
diff --git a/src/core/wee-input.h b/src/core/wee-input.h
index 52420b9cd..0e40b95b4 100644
--- a/src/core/wee-input.h
+++ b/src/core/wee-input.h
@@ -26,7 +26,7 @@ struct t_weechat_plugin;
extern int input_exec_command (struct t_gui_buffer *buffer,
int any_plugin,
struct t_weechat_plugin *plugin,
- char *string);
-extern void input_data (struct t_gui_buffer *buffer, char *data);
+ const char *string);
+extern void input_data (struct t_gui_buffer *buffer, const char *data);
#endif /* wee-input.h */
diff --git a/src/core/wee-list.c b/src/core/wee-list.c
index fc67789f7..7d1c80c36 100644
--- a/src/core/wee-list.c
+++ b/src/core/wee-list.c
@@ -56,7 +56,7 @@ weelist_new ()
*/
struct t_weelist_item *
-weelist_find_pos (struct t_weelist *weelist, char *data)
+weelist_find_pos (struct t_weelist *weelist, const char *data)
{
struct t_weelist_item *ptr_item;
@@ -79,7 +79,7 @@ weelist_find_pos (struct t_weelist *weelist, char *data)
void
weelist_insert (struct t_weelist *weelist, struct t_weelist_item *item,
- char *where)
+ const char *where)
{
struct t_weelist_item *pos_item;
@@ -139,7 +139,7 @@ weelist_insert (struct t_weelist *weelist, struct t_weelist_item *item,
*/
struct t_weelist_item *
-weelist_add (struct t_weelist *weelist, char *data, char *where)
+weelist_add (struct t_weelist *weelist, const char *data, const char *where)
{
struct t_weelist_item *new_item;
@@ -161,7 +161,7 @@ weelist_add (struct t_weelist *weelist, char *data, char *where)
*/
struct t_weelist_item *
-weelist_search (struct t_weelist *weelist, char *data)
+weelist_search (struct t_weelist *weelist, const char *data)
{
struct t_weelist_item *ptr_item;
@@ -183,7 +183,7 @@ weelist_search (struct t_weelist *weelist, char *data)
*/
struct t_weelist_item *
-weelist_casesearch (struct t_weelist *weelist, char *data)
+weelist_casesearch (struct t_weelist *weelist, const char *data)
{
struct t_weelist_item *ptr_item;
@@ -231,7 +231,7 @@ weelist_get (struct t_weelist *weelist, int position)
*/
void
-weelist_set (struct t_weelist_item *item, char *value)
+weelist_set (struct t_weelist_item *item, const char *value)
{
if (!item || !value)
return;
@@ -363,7 +363,7 @@ weelist_free (struct t_weelist *weelist)
*/
void
-weelist_print_log (struct t_weelist *weelist, char *name)
+weelist_print_log (struct t_weelist *weelist, const char *name)
{
struct t_weelist_item *ptr_item;
diff --git a/src/core/wee-list.h b/src/core/wee-list.h
index c992b9b41..01deee6e3 100644
--- a/src/core/wee-list.h
+++ b/src/core/wee-list.h
@@ -36,14 +36,14 @@ struct t_weelist
extern struct t_weelist *weelist_new ();
extern struct t_weelist_item *weelist_add (struct t_weelist *weelist,
- char *data, char *where);
+ const char *data, const char *where);
extern struct t_weelist_item *weelist_search (struct t_weelist *weelist,
- char *data);
+ const char *data);
extern struct t_weelist_item *weelist_casesearch (struct t_weelist *weelist,
- char *data);
+ const char *data);
extern struct t_weelist_item *weelist_get (struct t_weelist *weelist,
int position);
-extern void weelist_set (struct t_weelist_item *item, char *value);
+extern void weelist_set (struct t_weelist_item *item, const char *value);
extern struct t_weelist_item *weelist_next (struct t_weelist_item *item);
extern struct t_weelist_item *weelist_prev (struct t_weelist_item *item);
extern char *weelist_string (struct t_weelist_item *item);
@@ -52,6 +52,6 @@ extern void weelist_remove (struct t_weelist *weelist,
struct t_weelist_item *item);
extern void weelist_remove_all (struct t_weelist *weelist);
extern void weelist_free (struct t_weelist *weelist);
-extern void weelist_print_log (struct t_weelist *weelist, char *name);
+extern void weelist_print_log (struct t_weelist *weelist, const char *name);
#endif /* wee-list.h */
diff --git a/src/core/wee-log.c b/src/core/wee-log.c
index e5cd098d7..0b3e7d420 100644
--- a/src/core/wee-log.c
+++ b/src/core/wee-log.c
@@ -50,7 +50,7 @@ FILE *weechat_log_file = NULL; /* WeeChat log file */
*/
int
-log_open (char *filename, char *mode)
+log_open (const char *filename, const char *mode)
{
int filename_length;
@@ -117,7 +117,7 @@ log_init ()
*/
void
-log_printf (char *message, ...)
+log_printf (const char *message, ...)
{
static char buffer[4096];
char *ptr_buffer;
diff --git a/src/core/wee-log.h b/src/core/wee-log.h
index 2b1936487..e587b0864 100644
--- a/src/core/wee-log.h
+++ b/src/core/wee-log.h
@@ -25,7 +25,7 @@ extern FILE *weechat_log_file;
extern void log_init ();
extern void log_close ();
-extern void log_printf (char *message, ...);
+extern void log_printf (const char *message, ...);
extern int log_crash_rename ();
#endif /* wee-log.h */
diff --git a/src/core/wee-network.c b/src/core/wee-network.c
index 50cc63d02..33c031cca 100644
--- a/src/core/wee-network.c
+++ b/src/core/wee-network.c
@@ -90,7 +90,7 @@ network_end ()
*/
void
-network_convbase64_8x3_to_6x4 (char *from, char *to)
+network_convbase64_8x3_to_6x4 (const char *from, char *to)
{
unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -106,9 +106,10 @@ network_convbase64_8x3_to_6x4 (char *from, char *to)
*/
void
-network_base64encode (char *from, char *to)
+network_base64encode (const char *from, char *to)
{
- char *f, *t;
+ const char *f;
+ char *t;
int from_len;
from_len = strlen (from);
@@ -153,9 +154,8 @@ network_base64encode (char *from, char *to)
*/
int
-network_pass_httpproxy (int sock, char *address, int port)
+network_pass_httpproxy (int sock, const char *address, int port)
{
-
char buffer[256], authbuf[128], authbuf_base64[196];
int n, m;
@@ -204,7 +204,7 @@ network_pass_httpproxy (int sock, char *address, int port)
*/
int
-network_resolve (char *hostname, char *ip, int *version)
+network_resolve (const char *hostname, char *ip, int *version)
{
char ipbuffer[NI_MAXHOST];
struct addrinfo *res;
@@ -248,7 +248,7 @@ network_resolve (char *hostname, char *ip, int *version)
*/
int
-network_pass_socks4proxy (int sock, char *address, int port)
+network_pass_socks4proxy (int sock, const char *address, int port)
{
/*
* socks4 protocol is explained here:
@@ -294,7 +294,7 @@ network_pass_socks4proxy (int sock, char *address, int port)
*/
int
-network_pass_socks5proxy (int sock, char *address, int port)
+network_pass_socks5proxy (int sock, const char *address, int port)
{
/*
* socks5 protocol is explained in RFC 1928
@@ -440,7 +440,7 @@ network_pass_socks5proxy (int sock, char *address, int port)
*/
int
-network_pass_proxy (int sock, char *address, int port)
+network_pass_proxy (int sock, const char *address, int port)
{
int rc;
diff --git a/src/core/wee-network.h b/src/core/wee-network.h
index 1b6e4cf5c..4f8031d57 100644
--- a/src/core/wee-network.h
+++ b/src/core/wee-network.h
@@ -24,7 +24,7 @@ struct t_hook;
extern void network_init ();
extern void network_end ();
-extern int network_pass_proxy (int sock, char *address, int port);
+extern int network_pass_proxy (int sock, const char *address, int port);
extern int network_connect_to (int sock, unsigned long address, int port);
extern void network_connect_with_fork (struct t_hook *);
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index 9c69d7f06..15607d50f 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -59,7 +59,7 @@
*/
char *
-string_strndup (char *string, int length)
+string_strndup (const char *string, int length)
{
char *result;
@@ -111,7 +111,7 @@ string_toupper (char *string)
*/
int
-string_strcasecmp (char *string1, char *string2)
+string_strcasecmp (const char *string1, const char *string2)
{
int diff;
@@ -137,7 +137,7 @@ string_strcasecmp (char *string1, char *string2)
*/
int
-string_strncasecmp (char *string1, char *string2, int max)
+string_strncasecmp (const char *string1, const char *string2, int max)
{
int count, diff;
@@ -167,8 +167,8 @@ string_strncasecmp (char *string1, char *string2, int max)
*/
int
-string_strcmp_ignore_chars (char *string1, char *string2, char *chars_ignored,
- int case_sensitive)
+string_strcmp_ignore_chars (const char *string1, const char *string2,
+ const char *chars_ignored, int case_sensitive)
{
int diff;
@@ -230,7 +230,7 @@ string_strcmp_ignore_chars (char *string1, char *string2, char *chars_ignored,
*/
char *
-string_strcasestr (char *string, char *search)
+string_strcasestr (const char *string, const char *search)
{
int length_search;
@@ -242,7 +242,7 @@ string_strcasestr (char *string, char *search)
while (string[0])
{
if (string_strncasecmp (string, search, length_search) == 0)
- return string;
+ return (char *)string;
string++;
}
@@ -257,7 +257,7 @@ string_strcasestr (char *string, char *search)
*/
int
-string_match (char *string, char *mask, int case_sensitive)
+string_match (const char *string, const char *mask, int case_sensitive)
{
char last, *mask2;
int len_string, len_mask, rc;
@@ -340,9 +340,10 @@ string_match (char *string, char *mask, int case_sensitive)
*/
char *
-string_replace (char *string, char *search, char *replace)
+string_replace (const char *string, const char *search, const char *replace)
{
- char *pos, *new_string;
+ const char *pos;
+ char *new_string;
int length1, length2, length_new, count;
if (!string || !search || !replace)
@@ -398,10 +399,10 @@ string_replace (char *string, char *search, char *replace)
*/
char *
-string_remove_quotes (char *string, char *quotes)
+string_remove_quotes (const char *string, const char *quotes)
{
int length;
- char *pos_start, *pos_end;
+ const char *pos_start, *pos_end;
if (!string || !quotes)
return NULL;
@@ -435,12 +436,13 @@ string_remove_quotes (char *string, char *quotes)
/*
* string_strip: strip chars at beginning and/or end of string
+ * note: returned value has to be free() after use
*/
char *
-string_strip (char *string, int left, int right, char *chars)
+string_strip (const char *string, int left, int right, const char *chars)
{
- char *ptr_start, *ptr_end;
+ const char *ptr_start, *ptr_end;
if (!string)
return NULL;
@@ -476,10 +478,11 @@ string_strip (char *string, int left, int right, char *chars)
/*
* string_convert_hex_chars: convert hex chars (\x??) to value
+ * note: returned value has to be free() after use
*/
char *
-string_convert_hex_chars (char *string)
+string_convert_hex_chars (const char *string)
{
char *output, hex_str[8], *error;
int pos_output;
@@ -550,7 +553,7 @@ string_convert_hex_chars (char *string)
*/
wint_t
-string_get_wide_char (char *string)
+string_get_wide_char (const char *string)
{
int char_size;
wint_t result;
@@ -590,7 +593,7 @@ string_get_wide_char (char *string)
*/
int
-string_is_word_char (char *string)
+string_is_word_char (const char *string)
{
wint_t c = string_get_wide_char (string);
@@ -619,7 +622,7 @@ string_is_word_char (char *string)
*/
int
-string_has_highlight (char *string, char *highlight_words)
+string_has_highlight (const char *string, const char *highlight_words)
{
char *msg, *highlight, *match, *match_pre, *match_post, *msg_pos, *pos, *pos_end;
int end, length, startswith, endswith, wildcard_start, wildcard_end;
@@ -728,7 +731,7 @@ string_has_highlight (char *string, char *highlight_words)
*/
char **
-string_explode (char *string, char *separators, int keep_eol,
+string_explode (const char *string, const char *separators, int keep_eol,
int num_items_max, int *num_items)
{
int i, n_items;
@@ -851,7 +854,7 @@ string_free_exploded (char **exploded_string)
*/
char *
-string_build_with_exploded (char **exploded_string, char *separator)
+string_build_with_exploded (char **exploded_string, const char *separator)
{
int i, length, length_separator;
char *result;
@@ -889,11 +892,12 @@ string_build_with_exploded (char **exploded_string, char *separator)
*/
char **
-string_split_command (char *command, char separator)
+string_split_command (const char *command, char separator)
{
int nb_substr, arr_idx, str_idx, type;
char **array;
- char *buffer, *ptr, *p;
+ char *buffer, *p;
+ const char *ptr;
if (!command || !command[0])
return NULL;
@@ -985,10 +989,12 @@ string_free_splitted_command (char **splitted_command)
/*
* string_iconv: convert string to another charset
+ * note: returned value has to be free() after use
*/
char *
-string_iconv (int from_utf8, char *from_code, char *to_code, char *string)
+string_iconv (int from_utf8, const char *from_code, const char *to_code,
+ const char *string)
{
char *outbuf;
@@ -1090,10 +1096,11 @@ string_iconv (int from_utf8, char *from_code, char *to_code, char *string)
/*
* string_iconv_to_internal: convert user string (input, script, ..) to
* WeeChat internal storage charset
+ * note: returned value has to be free() after use
*/
char *
-string_iconv_to_internal (char *charset, char *string)
+string_iconv_to_internal (const char *charset, const char *string)
{
char *input, *output;
@@ -1127,10 +1134,11 @@ string_iconv_to_internal (char *charset, char *string)
/*
* string_iconv_from_internal: convert internal string to terminal charset,
* for display
+ * note: returned value has to be free() after use
*/
char *
-string_iconv_from_internal (char *charset, char *string)
+string_iconv_from_internal (const char *charset, const char *string)
{
char *input, *output;
@@ -1163,7 +1171,7 @@ string_iconv_from_internal (char *charset, char *string)
*/
void
-string_iconv_fprintf (FILE *file, char *data, ...)
+string_iconv_fprintf (FILE *file, const char *data, ...)
{
va_list argptr;
char *buf, *buf2;
diff --git a/src/core/wee-string.h b/src/core/wee-string.h
index 648599079..62df98f7f 100644
--- a/src/core/wee-string.h
+++ b/src/core/wee-string.h
@@ -20,31 +20,39 @@
#ifndef __WEECHAT_STRING_H
#define __WEECHAT_STRING_H 1
-extern char *string_strndup (char *string, int length);
+extern char *string_strndup (const char *string, int length);
extern void string_tolower (char *string);
extern void string_toupper (char *string);
-extern int string_strcasecmp (char *string1, char *string2);
-extern int string_strncasecmp (char *string1, char *string2, int max);
-extern int string_strcmp_ignore_chars (char *string1, char *string2,
- char *chars_ignored, int case_sensitive);
-extern char *string_strcasestr (char *string, char *search);
-extern int string_match (char *string, char *mask, int case_sensitive);
-extern char *string_replace (char *string, char *search, char *replace);
-extern char *string_remove_quotes (char *string, char *quotes);
-extern char *string_strip (char *string, int left, int right, char *chars);
-extern char *string_convert_hex_chars (char *string);
-extern int string_has_highlight (char *string, char *highlight_words);
-extern char **string_explode (char *string, char *separators, int keep_eol,
- int num_items_max, int *num_items);
+extern int string_strcasecmp (const char *string1, const char *string2);
+extern int string_strncasecmp (const char *string1, const char *string2,
+ int max);
+extern int string_strcmp_ignore_chars (const char *string1,
+ const char *string2,
+ const char *chars_ignored,
+ int case_sensitive);
+extern char *string_strcasestr (const char *string, const char *search);
+extern int string_match (const char *string, const char *mask,
+ int case_sensitive);
+extern char *string_replace (const char *string, const char *search,
+ const char *replace);
+extern char *string_remove_quotes (const char *string, const char *quotes);
+extern char *string_strip (const char *string, int left, int right,
+ const char *chars);
+extern char *string_convert_hex_chars (const char *string);
+extern int string_has_highlight (const char *string,
+ const char *highlight_words);
+extern char **string_explode (const char *string, const char *separators,
+ int keep_eol, int num_items_max, int *num_items);
extern void string_free_exploded (char **exploded_string);
extern char *string_build_with_exploded (char **exploded_string,
- char *separator);
-extern char **string_split_command (char *command, char separator);
+ const char *separator);
+extern char **string_split_command (const char *command, char separator);
extern void string_free_splitted_command (char **splitted_command);
-extern char *string_iconv (int from_utf8, char *from_code, char *to_code,
- char *string);
-extern char *string_iconv_to_internal (char *charset, char *string);
-extern char *string_iconv_from_internal (char *charset, char *string);
-extern void string_iconv_fprintf (FILE *file, char *data, ...);
+extern char *string_iconv (int from_utf8, const char *from_code,
+ const char *to_code, const char *string);
+extern char *string_iconv_to_internal (const char *charset, const char *string);
+extern char *string_iconv_from_internal (const char *charset,
+ const char *string);
+extern void string_iconv_fprintf (FILE *file, const char *data, ...);
#endif /* wee-string.h */
diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c
index a50619e8f..2213fb6ed 100644
--- a/src/core/wee-upgrade.c
+++ b/src/core/wee-upgrade.c
@@ -86,7 +86,7 @@ session_write_int (FILE *file, int id, int value)
*/
int
-session_write_str (FILE *file, int id, char *string)
+session_write_str (FILE *file, int id, const char *string)
{
char type;
int length;
@@ -470,7 +470,7 @@ session_save_hotlist (FILE *file)
*/
/*int
-session_save (char *filename)
+session_save (const char *filename)
{
FILE *file;
int rc;
@@ -499,7 +499,7 @@ session_save (char *filename)
*/
void
-session_crash (FILE *file, char *message, ...)
+session_crash (FILE *file, const char *message, ...)
{
char buf[4096];
va_list argptr;
@@ -1718,7 +1718,7 @@ session_load_hotlist (FILE *file)
*/
/*int
-session_load (char *filename)
+session_load (const char *filename)
{
FILE *file;
char *signature;
diff --git a/src/core/wee-upgrade.h b/src/core/wee-upgrade.h
index 23d5f0dce..3662199ac 100644
--- a/src/core/wee-upgrade.h
+++ b/src/core/wee-upgrade.h
@@ -199,7 +199,7 @@ enum t_session_hotlist
SESSION_HOTL_CREATION_TIME
};
-int session_save (char *filename);
-int session_load (char *filename);
+int session_save (const char *filename);
+int session_load (const char *filename);
#endif /* wee-upgrade.h */
diff --git a/src/core/wee-utf8.c b/src/core/wee-utf8.c
index 7dbb5ac8c..2b4108374 100644
--- a/src/core/wee-utf8.c
+++ b/src/core/wee-utf8.c
@@ -49,7 +49,7 @@ utf8_init ()
*/
int
-utf8_has_8bits (char *string)
+utf8_has_8bits (const char *string)
{
while (string && string[0])
{
@@ -67,7 +67,7 @@ utf8_has_8bits (char *string)
*/
int
-utf8_is_valid (char *string, char **error)
+utf8_is_valid (const char *string, char **error)
{
while (string && string[0])
{
@@ -77,7 +77,7 @@ utf8_is_valid (char *string, char **error)
if (!string[1] || (((unsigned char)(string[1]) & 0xC0) != 0x80))
{
if (error)
- *error = string;
+ *error = (char *)string;
return 0;
}
string += 2;
@@ -90,7 +90,7 @@ utf8_is_valid (char *string, char **error)
|| (((unsigned char)(string[2]) & 0xC0) != 0x80))
{
if (error)
- *error = string;
+ *error = (char *)string;
return 0;
}
string += 3;
@@ -104,7 +104,7 @@ utf8_is_valid (char *string, char **error)
|| (((unsigned char)(string[3]) & 0xC0) != 0x80))
{
if (error)
- *error = string;
+ *error = (char *)string;
return 0;
}
string += 4;
@@ -113,7 +113,7 @@ utf8_is_valid (char *string, char **error)
else if ((unsigned char)(string[0]) >= 0x80)
{
if (error)
- *error = string;
+ *error = (char *)string;
return 0;
}
else
@@ -130,7 +130,7 @@ utf8_is_valid (char *string, char **error)
*/
void
-utf8_normalize (char *string, char replacement)
+utf8_normalize (const char *string, char replacement)
{
char *error;
@@ -148,7 +148,7 @@ utf8_normalize (char *string, char replacement)
*/
char *
-utf8_prev_char (char *string_start, char *string)
+utf8_prev_char (const char *string_start, const char *string)
{
if (!string || (string <= string_start))
return NULL;
@@ -160,28 +160,28 @@ utf8_prev_char (char *string_start, char *string)
/* UTF-8, at least 2 bytes */
string--;
if (string < string_start)
- return string + 1;
+ return (char *)string + 1;
if (((unsigned char)(string[0]) & 0xC0) == 0x80)
{
/* UTF-8, at least 3 bytes */
string--;
if (string < string_start)
- return string + 1;
+ return (char *)string + 1;
if (((unsigned char)(string[0]) & 0xC0) == 0x80)
{
/* UTF-8, 4 bytes */
string--;
if (string < string_start)
- return string + 1;
- return string;
+ return (char *)string + 1;
+ return (char *)string;
}
else
- return string;
+ return (char *)string;
}
else
- return string;
+ return (char *)string;
}
- return string;
+ return (char *)string;
}
/*
@@ -189,7 +189,7 @@ utf8_prev_char (char *string_start, char *string)
*/
char *
-utf8_next_char (char *string)
+utf8_next_char (const char *string)
{
if (!string)
return NULL;
@@ -198,31 +198,31 @@ utf8_next_char (char *string)
if (((unsigned char)(string[0]) & 0xE0) == 0xC0)
{
if (!string[1])
- return string + 1;
- return string + 2;
+ return (char *)string + 1;
+ return (char *)string + 2;
}
/* UTF-8, 3 bytes: 1110vvvv 10vvvvvv 10vvvvvv */
else if (((unsigned char)(string[0]) & 0xF0) == 0xE0)
{
if (!string[1])
- return string + 1;
+ return (char *)string + 1;
if (!string[2])
- return string + 2;
- return string + 3;
+ return (char *)string + 2;
+ return (char *)string + 3;
}
/* UTF-8, 4 bytes: 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv */
else if (((unsigned char)(string[0]) & 0xF8) == 0xF0)
{
if (!string[1])
- return string + 1;
+ return (char *)string + 1;
if (!string[2])
- return string + 2;
+ return (char *)string + 2;
if (!string[3])
- return string + 3;
- return string + 4;
+ return (char *)string + 3;
+ return (char *)string + 4;
}
/* UTF-8, 1 byte: 0vvvvvvv */
- return string + 1;
+ return (char *)string + 1;
}
/*
@@ -230,7 +230,7 @@ utf8_next_char (char *string)
*/
int
-utf8_char_size (char *string)
+utf8_char_size (const char *string)
{
if (!string)
return 0;
@@ -243,7 +243,7 @@ utf8_char_size (char *string)
*/
int
-utf8_strlen (char *string)
+utf8_strlen (const char *string)
{
int length;
@@ -264,7 +264,7 @@ utf8_strlen (char *string)
*/
int
-utf8_strnlen (char *string, int bytes)
+utf8_strnlen (const char *string, int bytes)
{
char *start;
int length;
@@ -272,7 +272,7 @@ utf8_strnlen (char *string, int bytes)
if (!string)
return 0;
- start = string;
+ start = (char *)string;
length = 0;
while (string && string[0] && (string - start < bytes))
{
@@ -288,7 +288,7 @@ utf8_strnlen (char *string, int bytes)
*/
int
-utf8_strlen_screen (char *string)
+utf8_strlen_screen (const char *string)
{
int length, num_char;
wchar_t *wstring;
@@ -320,7 +320,7 @@ utf8_strlen_screen (char *string)
*/
int
-utf8_charcasecmp (char *string1, char *string2)
+utf8_charcasecmp (const char *string1, const char *string2)
{
int length1, length2, i, char1, char2, diff;
@@ -367,7 +367,7 @@ utf8_charcasecmp (char *string1, char *string2)
*/
int
-utf8_char_size_screen (char *string)
+utf8_char_size_screen (const char *string)
{
int char_size;
char utf_char[16];
@@ -390,12 +390,12 @@ utf8_char_size_screen (char *string)
*/
char *
-utf8_add_offset (char *string, int offset)
+utf8_add_offset (const char *string, int offset)
{
int count;
if (!string)
- return string;
+ return NULL;
count = 0;
while (string && string[0] && (count < offset))
@@ -403,7 +403,7 @@ utf8_add_offset (char *string, int offset)
string = utf8_next_char (string);
count++;
}
- return string;
+ return (char *)string;
}
/*
@@ -412,7 +412,7 @@ utf8_add_offset (char *string, int offset)
*/
int
-utf8_real_pos (char *string, int pos)
+utf8_real_pos (const char *string, int pos)
{
int count, real_pos;
char *next_char;
@@ -438,7 +438,7 @@ utf8_real_pos (char *string, int pos)
*/
int
-utf8_pos (char *string, int real_pos)
+utf8_pos (const char *string, int real_pos)
{
int count;
char *limit;
@@ -447,7 +447,7 @@ utf8_pos (char *string, int real_pos)
return real_pos;
count = 0;
- limit = string + real_pos;
+ limit = (char *)string + real_pos;
while (string && string[0] && (string < limit))
{
string = utf8_next_char (string);
diff --git a/src/core/wee-utf8.h b/src/core/wee-utf8.h
index 8dc9d3d90..219a9fd82 100644
--- a/src/core/wee-utf8.h
+++ b/src/core/wee-utf8.h
@@ -33,19 +33,19 @@
extern int local_utf8;
extern void utf8_init ();
-extern int utf8_has_8bits (char *string);
-extern int utf8_is_valid (char *string, char **error);
-extern void utf8_normalize (char *string, char replacement);
-extern char *utf8_prev_char (char *string_start, char *string);
-extern char *utf8_next_char (char *string);
-extern int utf8_char_size (char *string);
-extern int utf8_strlen (char *string);
-extern int utf8_strnlen (char *string, int bytes);
-extern int utf8_strlen_screen (char *string);
-extern int utf8_charcasecmp (char *string1, char *string2);
-extern int utf8_char_size_screen (char *string);
-extern char *utf8_add_offset (char *string, int offset);
-extern int utf8_real_pos (char *string, int pos);
-extern int utf8_pos (char *string, int real_pos);
+extern int utf8_has_8bits (const char *string);
+extern int utf8_is_valid (const char *string, char **error);
+extern void utf8_normalize (const char *string, char replacement);
+extern char *utf8_prev_char (const char *string_start, const char *string);
+extern char *utf8_next_char (const char *string);
+extern int utf8_char_size (const char *string);
+extern int utf8_strlen (const char *string);
+extern int utf8_strnlen (const char *string, int bytes);
+extern int utf8_strlen_screen (const char *string);
+extern int utf8_charcasecmp (const char *string1, const char *string2);
+extern int utf8_char_size_screen (const char *string);
+extern char *utf8_add_offset (const char *string, int offset);
+extern int utf8_real_pos (const char *string, int pos);
+extern int utf8_pos (const char *string, int real_pos);
#endif /* wee-utf8.h */
diff --git a/src/core/wee-util.c b/src/core/wee-util.c
index abac472ea..6407b1ab2 100644
--- a/src/core/wee-util.c
+++ b/src/core/wee-util.c
@@ -106,7 +106,7 @@ util_timeval_add (struct timeval *tv, long interval)
*/
int
-util_get_time_length (char *time_format)
+util_get_time_length (const char *time_format)
{
time_t date;
struct tm *local_time;
@@ -144,7 +144,7 @@ util_catch_signal (int signum, void (*handler)(int))
*/
int
-util_create_dir (char *directory, int permissions)
+util_create_dir (const char *directory, int permissions)
{
if (mkdir (directory, 0755) < 0)
{
@@ -169,8 +169,8 @@ util_create_dir (char *directory, int permissions)
*/
void
-util_exec_on_files (char *directory, void *data,
- int (*callback)(void *data, char *filename))
+util_exec_on_files (const char *directory, void *data,
+ int (*callback)(void *data, const char *filename))
{
char complete_filename[1024];
DIR *dir;
@@ -209,7 +209,7 @@ util_exec_on_files (char *directory, void *data,
*/
char *
-util_search_full_lib_name (char *filename, char *sys_directory)
+util_search_full_lib_name (const char *filename, const char *sys_directory)
{
char *name_with_ext, *final_name;
int length;
@@ -279,7 +279,7 @@ util_search_full_lib_name (char *filename, char *sys_directory)
*/
int
-util_weechat_version_cmp (char *version1, char *version2)
+util_weechat_version_cmp (const char *version1, const char *version2)
{
char *v1, *v2, *ptr_v1, *ptr_v2, *pos1, *pos2, *next1, *next2;
char *error1, *error2;
diff --git a/src/core/wee-util.h b/src/core/wee-util.h
index 1e6ceed4b..c94003f05 100644
--- a/src/core/wee-util.h
+++ b/src/core/wee-util.h
@@ -23,12 +23,15 @@
extern int util_timeval_cmp (struct timeval *tv1, struct timeval *tv2);
extern long util_timeval_diff (struct timeval *tv1, struct timeval *tv2);
extern void util_timeval_add (struct timeval *tv, long interval);
-extern int util_get_time_length (char *time_format);
+extern int util_get_time_length (const char *time_format);
extern void util_catch_signal (int signum, void (*handler)(int));
-extern int util_create_dir (char *directory, int permissions);
-extern void util_exec_on_files (char *directory, void *data,
- int (*callback)(void *data, char *filename));
-extern char *util_search_full_lib_name (char *filename, char *sys_directory);
-extern int util_weechat_version_cmp (char *version1, char *version2);
+extern int util_create_dir (const char *directory, int permissions);
+extern void util_exec_on_files (const char *directory, void *data,
+ int (*callback)(void *data,
+ const char *filename));
+extern char *util_search_full_lib_name (const char *filename,
+ const char *sys_directory);
+extern int util_weechat_version_cmp (const char *version1,
+ const char *version2);
#endif /* wee-util.h */