diff options
author | 2006-07-23 11:19:09 +0000 | |
---|---|---|
committer | 2006-07-23 11:19:09 +0000 | |
commit | 3eced7694bc36a666bb9c105528e6673af4df8a5 (patch) | |
tree | 38967dc3aefc92720d578a819c846b80eace8c81 | |
parent | Charsets are now checked when set by /charset command (diff) | |
download | weechat-3eced7694bc36a666bb9c105528e6673af4df8a5.tar.xz weechat-3eced7694bc36a666bb9c105528e6673af4df8a5.zip |
Splited weechat.c into weechat.c and util.c
48 files changed, 758 insertions, 600 deletions
diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 78d82d531..e858f0368 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -42,4 +42,6 @@ lib_weechat_main_a_SOURCES = weechat.c \ session.c \ session.h \ utf8.c \ - utf8.h + utf8.h \ + util.c \ + util.h diff --git a/src/common/command.c b/src/common/command.c index 73c6b5d0c..72eac51a3 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -34,6 +34,7 @@ #include "log.h" #include "session.h" #include "utf8.h" +#include "util.h" #include "weelist.h" #include "weeconfig.h" #include "../irc/irc.h" diff --git a/src/common/completion.c b/src/common/completion.c index 836d96bf3..2a8cf5069 100644 --- a/src/common/completion.c +++ b/src/common/completion.c @@ -32,6 +32,7 @@ #include "command.h" #include "log.h" #include "utf8.h" +#include "util.h" #include "weelist.h" #include "weeconfig.h" #include "../irc/irc.h" diff --git a/src/common/history.c b/src/common/history.c index eb889ab66..6b7348a8f 100644 --- a/src/common/history.c +++ b/src/common/history.c @@ -29,6 +29,7 @@ #include "weechat.h" #include "history.h" +#include "util.h" #include "weeconfig.h" #include "../gui/gui.h" diff --git a/src/common/util.c b/src/common/util.c new file mode 100644 index 000000000..6f0742230 --- /dev/null +++ b/src/common/util.c @@ -0,0 +1,322 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* util.c: some useful functions for WeeChat */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> +#include <string.h> + +#ifdef HAVE_ICONV +#include <iconv.h> +#endif + +#include "weechat.h" +#include "weeconfig.h" + + +/* + * ascii_tolower: locale independant string conversion to lower case + */ + +void +ascii_tolower (char *string) +{ + while (string && string[0]) + { + if ((string[0] >= 'A') && (string[0] <= 'Z')) + string[0] += ('a' - 'A'); + string++; + } +} + +/* + * ascii_toupper: locale independant string conversion to upper case + */ + +void +ascii_toupper (char *string) +{ + while (string && string[0]) + { + if ((string[0] >= 'a') && (string[0] <= 'z')) + string[0] -= ('a' - 'A'); + string++; + } +} + +/* + * ascii_strcasecmp: locale and case independent string comparison + */ + +int +ascii_strcasecmp (char *string1, char *string2) +{ + int c1, c2; + + if (!string1 || !string2) + return (string1) ? 1 : ((string2) ? -1 : 0); + + while (string1[0] && string2[0]) + { + c1 = (int)((unsigned char) string1[0]); + c2 = (int)((unsigned char) string2[0]); + + if ((c1 >= 'A') && (c1 <= 'Z')) + c1 += ('a' - 'A'); + + if ((c2 >= 'A') && (c2 <= 'Z')) + c2 += ('a' - 'A'); + + if ((c1 - c2) != 0) + return c1 - c2; + + string1++; + string2++; + } + + return (string1[0]) ? 1 : ((string2[0]) ? -1 : 0); +} + +/* + * ascii_strncasecmp: locale and case independent string comparison + * with max length + */ + +int +ascii_strncasecmp (char *string1, char *string2, int max) +{ + int c1, c2, count; + + if (!string1 || !string2) + return (string1) ? 1 : ((string2) ? -1 : 0); + + count = 0; + while ((count < max) && string1[0] && string2[0]) + { + c1 = (int)((unsigned char) string1[0]); + c2 = (int)((unsigned char) string2[0]); + + if ((c1 >= 'A') && (c1 <= 'Z')) + c1 += ('a' - 'A'); + + if ((c2 >= 'A') && (c2 <= 'Z')) + c2 += ('a' - 'A'); + + if ((c1 - c2) != 0) + return c1 - c2; + + string1++; + string2++; + count++; + } + + if (count >= max) + return 0; + else + return (string1[0]) ? 1 : ((string2[0]) ? -1 : 0); +} + +/* + * ascii_strcasestr: locale and case independent string search + */ + +char * +ascii_strcasestr (char *string, char *search) +{ + int length_search; + + length_search = strlen (search); + + if (!string || !search || (length_search == 0)) + return NULL; + + while (string[0]) + { + if (ascii_strncasecmp (string, search, length_search) == 0) + return string; + + string++; + } + + return NULL; +} + +/* + * weechat_iconv: convert string to another charset + */ + +char * +weechat_iconv (char *from_code, char *to_code, char *string) +{ + char *outbuf; + +#ifdef HAVE_ICONV + iconv_t cd; + char *inbuf; + ICONV_CONST char *ptr_inbuf; + char *ptr_outbuf; + size_t inbytesleft, outbytesleft; + + if (from_code && from_code[0] && to_code && to_code[0] + && (ascii_strcasecmp(from_code, to_code) != 0)) + { + cd = iconv_open (to_code, from_code); + if (cd == (iconv_t)(-1)) + outbuf = strdup (string); + else + { + inbuf = strdup (string); + ptr_inbuf = inbuf; + inbytesleft = strlen (inbuf); + outbytesleft = inbytesleft * 4; + outbuf = (char *) malloc (outbytesleft + 2); + ptr_outbuf = outbuf; + iconv (cd, &ptr_inbuf, &inbytesleft, &ptr_outbuf, &outbytesleft); + if (inbytesleft != 0) + { + free (outbuf); + outbuf = strdup (string); + } + else + ptr_outbuf[0] = '\0'; + free (inbuf); + iconv_close (cd); + } + } + else + outbuf = strdup (string); +#else + /* make gcc happy */ + (void) from_code; + (void) to_code; + outbuf = strdup (string); +#endif /* HAVE_ICONV */ + + return outbuf; +} + +/* + * weechat_iconv_check: check a charset + * if a charset is NULL, internal charset is used + */ + +int +weechat_iconv_check (char *from_code, char *to_code) +{ +#ifdef HAVE_ICONV + iconv_t cd; + + if (!from_code || !from_code[0]) + from_code = (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? + cfg_look_charset_internal : local_charset; + + if (!to_code || !to_code[0]) + to_code = (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? + cfg_look_charset_internal : local_charset; + + cd = iconv_open (to_code, from_code); + if (cd == (iconv_t)(-1)) + return 0; + iconv_close (cd); + return 1; +#else + return 1; +#endif +} + +/* + * weechat_strreplace: replace a string by new one in a string + * note: returned value has to be free() after use + */ + +char * +weechat_strreplace (char *string, char *search, char *replace) +{ + char *pos, *new_string; + int length1, length2, length_new, count; + + if (!string || !search || !replace) + return NULL; + + length1 = strlen (search); + length2 = strlen (replace); + + /* count number of strings to replace */ + count = 0; + pos = string; + while (pos && pos[0] && (pos = strstr (pos, search))) + { + count++; + pos += length1; + } + + /* easy: no string to replace! */ + if (count == 0) + return strdup (string); + + /* compute needed memory for new string */ + length_new = strlen (string) - (count * length1) + (count * length2) + 1; + + /* allocate new string */ + new_string = (char *)malloc (length_new * sizeof (char)); + if (!new_string) + return strdup (string); + + /* replace all occurences */ + new_string[0] = '\0'; + while (string && string[0]) + { + pos = strstr (string, search); + if (pos) + { + strncat (new_string, string, pos - string); + strcat (new_string, replace); + pos += length1; + } + else + strcat (new_string, string); + string = pos; + } + return new_string; +} + +/* + * get_timeval_diff: calculates difference between two times (return in milliseconds) + */ + +long +get_timeval_diff (struct timeval *tv1, struct timeval *tv2) +{ + long diff_sec, diff_usec; + + diff_sec = tv2->tv_sec - tv1->tv_sec; + diff_usec = tv2->tv_usec - tv1->tv_usec; + + if (diff_usec < 0) + { + diff_usec += 1000000; + diff_sec--; + } + return ((diff_usec / 1000) + (diff_sec * 1000)); +} diff --git a/src/common/util.h b/src/common/util.h new file mode 100644 index 000000000..3e1add637 --- /dev/null +++ b/src/common/util.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __WEECHAT_UTIL_H +#define __WEECHAT_UTIL_H 1 + +extern void ascii_tolower (char *); +extern void ascii_toupper (char *); +extern int ascii_strcasecmp (char *, char *); +extern int ascii_strncasecmp (char *, char *, int); +extern char *ascii_strcasestr (char *, char *); +extern char *weechat_iconv (char *, char *, char *); +extern int weechat_iconv_check (char *, char *); +extern char *weechat_strreplace (char *, char *, char *); +extern long get_timeval_diff (struct timeval *, struct timeval *); + +#endif /* util.h */ diff --git a/src/common/weechat.c b/src/common/weechat.c index 2e0d22755..9b7dca78c 100644 --- a/src/common/weechat.c +++ b/src/common/weechat.c @@ -51,10 +51,6 @@ #include <gnutls/gnutls.h> #endif -#ifdef HAVE_ICONV -#include <iconv.h> -#endif - #ifdef HAVE_LANGINFO_CODESET #include <langinfo.h> #endif @@ -66,6 +62,7 @@ #include "log.h" #include "session.h" #include "utf8.h" +#include "util.h" #include "weeconfig.h" #include "../irc/irc.h" #include "../gui/gui.h" @@ -94,292 +91,6 @@ gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */ /* - * ascii_tolower: locale independant string conversion to lower case - */ - -void -ascii_tolower (char *string) -{ - while (string && string[0]) - { - if ((string[0] >= 'A') && (string[0] <= 'Z')) - string[0] += ('a' - 'A'); - string++; - } -} - -/* - * ascii_toupper: locale independant string conversion to upper case - */ - -void -ascii_toupper (char *string) -{ - while (string && string[0]) - { - if ((string[0] >= 'a') && (string[0] <= 'z')) - string[0] -= ('a' - 'A'); - string++; - } -} - -/* - * ascii_strcasecmp: locale and case independent string comparison - */ - -int -ascii_strcasecmp (char *string1, char *string2) -{ - int c1, c2; - - if (!string1 || !string2) - return (string1) ? 1 : ((string2) ? -1 : 0); - - while (string1[0] && string2[0]) - { - c1 = (int)((unsigned char) string1[0]); - c2 = (int)((unsigned char) string2[0]); - - if ((c1 >= 'A') && (c1 <= 'Z')) - c1 += ('a' - 'A'); - - if ((c2 >= 'A') && (c2 <= 'Z')) - c2 += ('a' - 'A'); - - if ((c1 - c2) != 0) - return c1 - c2; - - string1++; - string2++; - } - - return (string1[0]) ? 1 : ((string2[0]) ? -1 : 0); -} - -/* - * ascii_strncasecmp: locale and case independent string comparison - * with max length - */ - -int -ascii_strncasecmp (char *string1, char *string2, int max) -{ - int c1, c2, count; - - if (!string1 || !string2) - return (string1) ? 1 : ((string2) ? -1 : 0); - - count = 0; - while ((count < max) && string1[0] && string2[0]) - { - c1 = (int)((unsigned char) string1[0]); - c2 = (int)((unsigned char) string2[0]); - - if ((c1 >= 'A') && (c1 <= 'Z')) - c1 += ('a' - 'A'); - - if ((c2 >= 'A') && (c2 <= 'Z')) - c2 += ('a' - 'A'); - - if ((c1 - c2) != 0) - return c1 - c2; - - string1++; - string2++; - count++; - } - - if (count >= max) - return 0; - else - return (string1[0]) ? 1 : ((string2[0]) ? -1 : 0); -} - -/* - * ascii_strcasestr: locale and case independent string search - */ - -char * -ascii_strcasestr (char *string, char *search) -{ - int length_search; - - length_search = strlen (search); - - if (!string || !search || (length_search == 0)) - return NULL; - - while (string[0]) - { - if (ascii_strncasecmp (string, search, length_search) == 0) - return string; - - string++; - } - - return NULL; -} - -/* - * weechat_iconv: convert string to another charset - */ - -char * -weechat_iconv (char *from_code, char *to_code, char *string) -{ - char *outbuf; - -#ifdef HAVE_ICONV - iconv_t cd; - char *inbuf; - ICONV_CONST char *ptr_inbuf; - char *ptr_outbuf; - size_t inbytesleft, outbytesleft; - - if (from_code && from_code[0] && to_code && to_code[0] - && (ascii_strcasecmp(from_code, to_code) != 0)) - { - cd = iconv_open (to_code, from_code); - if (cd == (iconv_t)(-1)) - outbuf = strdup (string); - else - { - inbuf = strdup (string); - ptr_inbuf = inbuf; - inbytesleft = strlen (inbuf); - outbytesleft = inbytesleft * 4; - outbuf = (char *) malloc (outbytesleft + 2); - ptr_outbuf = outbuf; - iconv (cd, &ptr_inbuf, &inbytesleft, &ptr_outbuf, &outbytesleft); - if (inbytesleft != 0) - { - free (outbuf); - outbuf = strdup (string); - } - else - ptr_outbuf[0] = '\0'; - free (inbuf); - iconv_close (cd); - } - } - else - outbuf = strdup (string); -#else - /* make gcc happy */ - (void) from_code; - (void) to_code; - outbuf = strdup (string); -#endif /* HAVE_ICONV */ - - return outbuf; -} - -/* - * weechat_iconv_check: check a charset - * if a charset is NULL, internal charset is used - */ - -int -weechat_iconv_check (char *from_code, char *to_code) -{ -#ifdef HAVE_ICONV - iconv_t cd; - - if (!from_code || !from_code[0]) - from_code = (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? - cfg_look_charset_internal : local_charset; - - if (!to_code || !to_code[0]) - to_code = (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? - cfg_look_charset_internal : local_charset; - - cd = iconv_open (to_code, from_code); - if (cd == (iconv_t)(-1)) - return 0; - iconv_close (cd); - return 1; -#else - return 1; -#endif -} - -/* - * weechat_strreplace: replace a string by new one in a string - * note: returned value has to be free() after use - */ - -char * -weechat_strreplace (char *string, char *search, char *replace) -{ - char *pos, *new_string; - int length1, length2, length_new, count; - - if (!string || !search || !replace) - return NULL; - - length1 = strlen (search); - length2 = strlen (replace); - - /* count number of strings to replace */ - count = 0; - pos = string; - while (pos && pos[0] && (pos = strstr (pos, search))) - { - count++; - pos += length1; - } - - /* easy: no string to replace! */ - if (count == 0) - return strdup (string); - - /* compute needed memory for new string */ - length_new = strlen (string) - (count * length1) + (count * length2) + 1; - - /* allocate new string */ - new_string = (char *)malloc (length_new * sizeof (char)); - if (!new_string) - return strdup (string); - - /* replace all occurences */ - new_string[0] = '\0'; - while (string && string[0]) - { - pos = strstr (string, search); - if (pos) - { - strncat (new_string, string, pos - string); - strcat (new_string, replace); - pos += length1; - } - else - strcat (new_string, string); - string = pos; - } - return new_string; -} - -/* - * get_timeval_diff: calculates difference between two times (return in milliseconds) - */ - -long -get_timeval_diff (struct timeval *tv1, struct timeval *tv2) -{ - long diff_sec, diff_usec; - - diff_sec = tv2->tv_sec - tv1->tv_sec; - diff_usec = tv2->tv_usec - tv1->tv_usec; - - if (diff_usec < 0) - { - diff_usec += 1000000; - diff_sec--; - } - return ((diff_usec / 1000) + (diff_sec * 1000)); -} - -/* * weechat_display_usage: display WeeChat usage */ diff --git a/src/common/weechat.h b/src/common/weechat.h index c84c29a7b..9d0844a7d 100644 --- a/src/common/weechat.h +++ b/src/common/weechat.h @@ -104,16 +104,7 @@ extern char *local_charset; extern gnutls_certificate_credentials gnutls_xcred; #endif -extern void ascii_tolower (char *); -extern void ascii_toupper (char *); -extern int ascii_strcasecmp (char *, char *); -extern int ascii_strncasecmp (char *, char *, int); -extern char *ascii_strcasestr (char *, char *); -extern char *weechat_iconv (char *, char *, char *); -extern int weechat_iconv_check (char *, char *); -extern char *weechat_strreplace (char *, char *, char *); extern void weechat_dump (int); -extern long get_timeval_diff (struct timeval *, struct timeval *); extern void weechat_shutdown (int, int); #endif /* weechat.h */ diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c index 2150a3814..11d05ce70 100644 --- a/src/common/weeconfig.c +++ b/src/common/weeconfig.c @@ -41,6 +41,7 @@ #include "fifo.h" #include "log.h" #include "utf8.h" +#include "util.h" #include "../irc/irc.h" #include "../gui/gui.h" diff --git a/src/common/weelist.c b/src/common/weelist.c index 9b2d0cb2c..97edd8bde 100644 --- a/src/common/weelist.c +++ b/src/common/weelist.c @@ -30,6 +30,7 @@ #include "weechat.h" #include "weelist.h" #include "log.h" +#include "util.h" /* diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index a180fee41..3a3d7c0b6 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -30,6 +30,7 @@ #include "../../common/weechat.h" #include "../gui.h" +#include "../../common/util.h" #include "../../common/weeconfig.h" #include "gui-curses.h" diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index 2c863fe54..5e3c4425e 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -34,6 +34,7 @@ #include "../gui.h" #include "../../common/fifo.h" #include "../../common/utf8.h" +#include "../../common/util.h" #include "../../common/weeconfig.h" #include "gui-curses.h" diff --git a/src/gui/gtk/gui-gtk-color.c b/src/gui/gtk/gui-gtk-color.c index 3536e6649..82785f266 100644 --- a/src/gui/gtk/gui-gtk-color.c +++ b/src/gui/gtk/gui-gtk-color.c @@ -30,6 +30,7 @@ #include "../../common/weechat.h" #include "../gui.h" +#include "../../common/util.h" #include "../../common/weeconfig.h" #include "gui-gtk.h" diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c index 5325e8a1f..1717ae2ab 100644 --- a/src/gui/gui-keyboard.c +++ b/src/gui/gui-keyboard.c @@ -32,6 +32,7 @@ #include "gui.h" #include "../common/command.h" #include "../common/log.h" +#include "../common/util.h" #ifdef PLUGINS #include "../plugins/plugins.h" diff --git a/src/gui/gui-log.c b/src/gui/gui-log.c index 086528c30..0a3da4a09 100644 --- a/src/gui/gui-log.c +++ b/src/gui/gui-log.c @@ -31,6 +31,7 @@ #include "../common/weechat.h" #include "gui.h" #include "../common/log.h" +#include "../common/util.h" #include "../common/weeconfig.h" diff --git a/src/irc/irc-channel.c b/src/irc/irc-channel.c index ec5458337..25b481aa7 100644 --- a/src/irc/irc-channel.c +++ b/src/irc/irc-channel.c @@ -32,6 +32,7 @@ #include "irc.h" #include "../common/log.h" #include "../common/utf8.h" +#include "../common/util.h" #include "../common/weeconfig.h" #include "../gui/gui.h" diff --git a/src/irc/irc-dcc.c b/src/irc/irc-dcc.c index 73b260c1d..c51b6cb12 100644 --- a/src/irc/irc-dcc.c +++ b/src/irc/irc-dcc.c @@ -41,6 +41,7 @@ #include "irc.h" #include "../common/log.h" #include "../common/hotlist.h" +#include "../common/util.h" #include "../common/weeconfig.h" #include "../gui/gui.h" diff --git a/src/irc/irc-ignore.c b/src/irc/irc-ignore.c index cb80bd52b..3ef189c4c 100644 --- a/src/irc/irc-ignore.c +++ b/src/irc/irc-ignore.c @@ -31,6 +31,7 @@ #include "irc.h" #include "../common/command.h" #include "../common/log.h" +#include "../common/util.h" char *ignore_types[] = diff --git a/src/irc/irc-nick.c b/src/irc/irc-nick.c index a29132f71..5dd299a52 100644 --- a/src/irc/irc-nick.c +++ b/src/irc/irc-nick.c @@ -31,6 +31,7 @@ #include "../common/weechat.h" #include "irc.h" #include "../common/log.h" +#include "../common/util.h" #include "../common/weeconfig.h" diff --git a/src/irc/irc-recv.c b/src/irc/irc-recv.c index f679f3d48..56e1de775 100644 --- a/src/irc/irc-recv.c +++ b/src/irc/irc-recv.c @@ -39,6 +39,7 @@ #include "irc.h" #include "../common/command.h" #include "../common/hotlist.h" +#include "../common/util.h" #include "../common/weeconfig.h" #include "../gui/gui.h" diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c index 6aba63a95..236c5d9e6 100644 --- a/src/irc/irc-send.c +++ b/src/irc/irc-send.c @@ -39,6 +39,7 @@ #include "../common/weechat.h" #include "irc.h" #include "../common/command.h" +#include "../common/util.h" #include "../common/weeconfig.h" #include "../gui/gui.h" diff --git a/src/plugins/plugins-config.c b/src/plugins/plugins-config.c index c959262d2..20688eecb 100644 --- a/src/plugins/plugins-config.c +++ b/src/plugins/plugins-config.c @@ -33,6 +33,7 @@ #include "../common/weechat.h" #include "weechat-plugin.h" #include "plugins-config.h" +#include "../common/util.h" #include "../irc/irc.h" diff --git a/src/plugins/plugins-interface.c b/src/plugins/plugins-interface.c index 567347870..16a49ebbb 100644 --- a/src/plugins/plugins-interface.c +++ b/src/plugins/plugins-interface.c @@ -36,6 +36,7 @@ #include "plugins-config.h" #include "../common/command.h" #include "../common/log.h" +#include "../common/util.h" #include "../common/weeconfig.h" #include "../irc/irc.h" #include "../gui/gui.h" diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index 49e4771b0..c99b16895 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -38,6 +38,7 @@ #include "plugins.h" #include "plugins-config.h" #include "../common/command.h" +#include "../common/util.h" #include "../common/weeconfig.h" #include "../irc/irc.h" #include "../gui/gui.h" diff --git a/weechat/src/common/Makefile.am b/weechat/src/common/Makefile.am index 78d82d531..e858f0368 100644 --- a/weechat/src/common/Makefile.am +++ b/weechat/src/common/Makefile.am @@ -42,4 +42,6 @@ lib_weechat_main_a_SOURCES = weechat.c \ session.c \ session.h \ utf8.c \ - utf8.h + utf8.h \ + util.c \ + util.h diff --git a/weechat/src/common/command.c b/weechat/src/common/command.c index 73c6b5d0c..72eac51a3 100644 --- a/weechat/src/common/command.c +++ b/weechat/src/common/command.c @@ -34,6 +34,7 @@ #include "log.h" #include "session.h" #include "utf8.h" +#include "util.h" #include "weelist.h" #include "weeconfig.h" #include "../irc/irc.h" diff --git a/weechat/src/common/completion.c b/weechat/src/common/completion.c index 836d96bf3..2a8cf5069 100644 --- a/weechat/src/common/completion.c +++ b/weechat/src/common/completion.c @@ -32,6 +32,7 @@ #include "command.h" #include "log.h" #include "utf8.h" +#include "util.h" #include "weelist.h" #include "weeconfig.h" #include "../irc/irc.h" diff --git a/weechat/src/common/history.c b/weechat/src/common/history.c index eb889ab66..6b7348a8f 100644 --- a/weechat/src/common/history.c +++ b/weechat/src/common/history.c @@ -29,6 +29,7 @@ #include "weechat.h" #include "history.h" +#include "util.h" #include "weeconfig.h" #include "../gui/gui.h" diff --git a/weechat/src/common/util.c b/weechat/src/common/util.c new file mode 100644 index 000000000..6f0742230 --- /dev/null +++ b/weechat/src/common/util.c @@ -0,0 +1,322 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* util.c: some useful functions for WeeChat */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> +#include <string.h> + +#ifdef HAVE_ICONV +#include <iconv.h> +#endif + +#include "weechat.h" +#include "weeconfig.h" + + +/* + * ascii_tolower: locale independant string conversion to lower case + */ + +void +ascii_tolower (char *string) +{ + while (string && string[0]) + { + if ((string[0] >= 'A') && (string[0] <= 'Z')) + string[0] += ('a' - 'A'); + string++; + } +} + +/* + * ascii_toupper: locale independant string conversion to upper case + */ + +void +ascii_toupper (char *string) +{ + while (string && string[0]) + { + if ((string[0] >= 'a') && (string[0] <= 'z')) + string[0] -= ('a' - 'A'); + string++; + } +} + +/* + * ascii_strcasecmp: locale and case independent string comparison + */ + +int +ascii_strcasecmp (char *string1, char *string2) +{ + int c1, c2; + + if (!string1 || !string2) + return (string1) ? 1 : ((string2) ? -1 : 0); + + while (string1[0] && string2[0]) + { + c1 = (int)((unsigned char) string1[0]); + c2 = (int)((unsigned char) string2[0]); + + if ((c1 >= 'A') && (c1 <= 'Z')) + c1 += ('a' - 'A'); + + if ((c2 >= 'A') && (c2 <= 'Z')) + c2 += ('a' - 'A'); + + if ((c1 - c2) != 0) + return c1 - c2; + + string1++; + string2++; + } + + return (string1[0]) ? 1 : ((string2[0]) ? -1 : 0); +} + +/* + * ascii_strncasecmp: locale and case independent string comparison + * with max length + */ + +int +ascii_strncasecmp (char *string1, char *string2, int max) +{ + int c1, c2, count; + + if (!string1 || !string2) + return (string1) ? 1 : ((string2) ? -1 : 0); + + count = 0; + while ((count < max) && string1[0] && string2[0]) + { + c1 = (int)((unsigned char) string1[0]); + c2 = (int)((unsigned char) string2[0]); + + if ((c1 >= 'A') && (c1 <= 'Z')) + c1 += ('a' - 'A'); + + if ((c2 >= 'A') && (c2 <= 'Z')) + c2 += ('a' - 'A'); + + if ((c1 - c2) != 0) + return c1 - c2; + + string1++; + string2++; + count++; + } + + if (count >= max) + return 0; + else + return (string1[0]) ? 1 : ((string2[0]) ? -1 : 0); +} + +/* + * ascii_strcasestr: locale and case independent string search + */ + +char * +ascii_strcasestr (char *string, char *search) +{ + int length_search; + + length_search = strlen (search); + + if (!string || !search || (length_search == 0)) + return NULL; + + while (string[0]) + { + if (ascii_strncasecmp (string, search, length_search) == 0) + return string; + + string++; + } + + return NULL; +} + +/* + * weechat_iconv: convert string to another charset + */ + +char * +weechat_iconv (char *from_code, char *to_code, char *string) +{ + char *outbuf; + +#ifdef HAVE_ICONV + iconv_t cd; + char *inbuf; + ICONV_CONST char *ptr_inbuf; + char *ptr_outbuf; + size_t inbytesleft, outbytesleft; + + if (from_code && from_code[0] && to_code && to_code[0] + && (ascii_strcasecmp(from_code, to_code) != 0)) + { + cd = iconv_open (to_code, from_code); + if (cd == (iconv_t)(-1)) + outbuf = strdup (string); + else + { + inbuf = strdup (string); + ptr_inbuf = inbuf; + inbytesleft = strlen (inbuf); + outbytesleft = inbytesleft * 4; + outbuf = (char *) malloc (outbytesleft + 2); + ptr_outbuf = outbuf; + iconv (cd, &ptr_inbuf, &inbytesleft, &ptr_outbuf, &outbytesleft); + if (inbytesleft != 0) + { + free (outbuf); + outbuf = strdup (string); + } + else + ptr_outbuf[0] = '\0'; + free (inbuf); + iconv_close (cd); + } + } + else + outbuf = strdup (string); +#else + /* make gcc happy */ + (void) from_code; + (void) to_code; + outbuf = strdup (string); +#endif /* HAVE_ICONV */ + + return outbuf; +} + +/* + * weechat_iconv_check: check a charset + * if a charset is NULL, internal charset is used + */ + +int +weechat_iconv_check (char *from_code, char *to_code) +{ +#ifdef HAVE_ICONV + iconv_t cd; + + if (!from_code || !from_code[0]) + from_code = (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? + cfg_look_charset_internal : local_charset; + + if (!to_code || !to_code[0]) + to_code = (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? + cfg_look_charset_internal : local_charset; + + cd = iconv_open (to_code, from_code); + if (cd == (iconv_t)(-1)) + return 0; + iconv_close (cd); + return 1; +#else + return 1; +#endif +} + +/* + * weechat_strreplace: replace a string by new one in a string + * note: returned value has to be free() after use + */ + +char * +weechat_strreplace (char *string, char *search, char *replace) +{ + char *pos, *new_string; + int length1, length2, length_new, count; + + if (!string || !search || !replace) + return NULL; + + length1 = strlen (search); + length2 = strlen (replace); + + /* count number of strings to replace */ + count = 0; + pos = string; + while (pos && pos[0] && (pos = strstr (pos, search))) + { + count++; + pos += length1; + } + + /* easy: no string to replace! */ + if (count == 0) + return strdup (string); + + /* compute needed memory for new string */ + length_new = strlen (string) - (count * length1) + (count * length2) + 1; + + /* allocate new string */ + new_string = (char *)malloc (length_new * sizeof (char)); + if (!new_string) + return strdup (string); + + /* replace all occurences */ + new_string[0] = '\0'; + while (string && string[0]) + { + pos = strstr (string, search); + if (pos) + { + strncat (new_string, string, pos - string); + strcat (new_string, replace); + pos += length1; + } + else + strcat (new_string, string); + string = pos; + } + return new_string; +} + +/* + * get_timeval_diff: calculates difference between two times (return in milliseconds) + */ + +long +get_timeval_diff (struct timeval *tv1, struct timeval *tv2) +{ + long diff_sec, diff_usec; + + diff_sec = tv2->tv_sec - tv1->tv_sec; + diff_usec = tv2->tv_usec - tv1->tv_usec; + + if (diff_usec < 0) + { + diff_usec += 1000000; + diff_sec--; + } + return ((diff_usec / 1000) + (diff_sec * 1000)); +} diff --git a/weechat/src/common/util.h b/weechat/src/common/util.h new file mode 100644 index 000000000..3e1add637 --- /dev/null +++ b/weechat/src/common/util.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __WEECHAT_UTIL_H +#define __WEECHAT_UTIL_H 1 + +extern void ascii_tolower (char *); +extern void ascii_toupper (char *); +extern int ascii_strcasecmp (char *, char *); +extern int ascii_strncasecmp (char *, char *, int); +extern char *ascii_strcasestr (char *, char *); +extern char *weechat_iconv (char *, char *, char *); +extern int weechat_iconv_check (char *, char *); +extern char *weechat_strreplace (char *, char *, char *); +extern long get_timeval_diff (struct timeval *, struct timeval *); + +#endif /* util.h */ diff --git a/weechat/src/common/weechat.c b/weechat/src/common/weechat.c index 2e0d22755..9b7dca78c 100644 --- a/weechat/src/common/weechat.c +++ b/weechat/src/common/weechat.c @@ -51,10 +51,6 @@ #include <gnutls/gnutls.h> #endif -#ifdef HAVE_ICONV -#include <iconv.h> -#endif - #ifdef HAVE_LANGINFO_CODESET #include <langinfo.h> #endif @@ -66,6 +62,7 @@ #include "log.h" #include "session.h" #include "utf8.h" +#include "util.h" #include "weeconfig.h" #include "../irc/irc.h" #include "../gui/gui.h" @@ -94,292 +91,6 @@ gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */ /* - * ascii_tolower: locale independant string conversion to lower case - */ - -void -ascii_tolower (char *string) -{ - while (string && string[0]) - { - if ((string[0] >= 'A') && (string[0] <= 'Z')) - string[0] += ('a' - 'A'); - string++; - } -} - -/* - * ascii_toupper: locale independant string conversion to upper case - */ - -void -ascii_toupper (char *string) -{ - while (string && string[0]) - { - if ((string[0] >= 'a') && (string[0] <= 'z')) - string[0] -= ('a' - 'A'); - string++; - } -} - -/* - * ascii_strcasecmp: locale and case independent string comparison - */ - -int -ascii_strcasecmp (char *string1, char *string2) -{ - int c1, c2; - - if (!string1 || !string2) - return (string1) ? 1 : ((string2) ? -1 : 0); - - while (string1[0] && string2[0]) - { - c1 = (int)((unsigned char) string1[0]); - c2 = (int)((unsigned char) string2[0]); - - if ((c1 >= 'A') && (c1 <= 'Z')) - c1 += ('a' - 'A'); - - if ((c2 >= 'A') && (c2 <= 'Z')) - c2 += ('a' - 'A'); - - if ((c1 - c2) != 0) - return c1 - c2; - - string1++; - string2++; - } - - return (string1[0]) ? 1 : ((string2[0]) ? -1 : 0); -} - -/* - * ascii_strncasecmp: locale and case independent string comparison - * with max length - */ - -int -ascii_strncasecmp (char *string1, char *string2, int max) -{ - int c1, c2, count; - - if (!string1 || !string2) - return (string1) ? 1 : ((string2) ? -1 : 0); - - count = 0; - while ((count < max) && string1[0] && string2[0]) - { - c1 = (int)((unsigned char) string1[0]); - c2 = (int)((unsigned char) string2[0]); - - if ((c1 >= 'A') && (c1 <= 'Z')) - c1 += ('a' - 'A'); - - if ((c2 >= 'A') && (c2 <= 'Z')) - c2 += ('a' - 'A'); - - if ((c1 - c2) != 0) - return c1 - c2; - - string1++; - string2++; - count++; - } - - if (count >= max) - return 0; - else - return (string1[0]) ? 1 : ((string2[0]) ? -1 : 0); -} - -/* - * ascii_strcasestr: locale and case independent string search - */ - -char * -ascii_strcasestr (char *string, char *search) -{ - int length_search; - - length_search = strlen (search); - - if (!string || !search || (length_search == 0)) - return NULL; - - while (string[0]) - { - if (ascii_strncasecmp (string, search, length_search) == 0) - return string; - - string++; - } - - return NULL; -} - -/* - * weechat_iconv: convert string to another charset - */ - -char * -weechat_iconv (char *from_code, char *to_code, char *string) -{ - char *outbuf; - -#ifdef HAVE_ICONV - iconv_t cd; - char *inbuf; - ICONV_CONST char *ptr_inbuf; - char *ptr_outbuf; - size_t inbytesleft, outbytesleft; - - if (from_code && from_code[0] && to_code && to_code[0] - && (ascii_strcasecmp(from_code, to_code) != 0)) - { - cd = iconv_open (to_code, from_code); - if (cd == (iconv_t)(-1)) - outbuf = strdup (string); - else - { - inbuf = strdup (string); - ptr_inbuf = inbuf; - inbytesleft = strlen (inbuf); - outbytesleft = inbytesleft * 4; - outbuf = (char *) malloc (outbytesleft + 2); - ptr_outbuf = outbuf; - iconv (cd, &ptr_inbuf, &inbytesleft, &ptr_outbuf, &outbytesleft); - if (inbytesleft != 0) - { - free (outbuf); - outbuf = strdup (string); - } - else - ptr_outbuf[0] = '\0'; - free (inbuf); - iconv_close (cd); - } - } - else - outbuf = strdup (string); -#else - /* make gcc happy */ - (void) from_code; - (void) to_code; - outbuf = strdup (string); -#endif /* HAVE_ICONV */ - - return outbuf; -} - -/* - * weechat_iconv_check: check a charset - * if a charset is NULL, internal charset is used - */ - -int -weechat_iconv_check (char *from_code, char *to_code) -{ -#ifdef HAVE_ICONV - iconv_t cd; - - if (!from_code || !from_code[0]) - from_code = (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? - cfg_look_charset_internal : local_charset; - - if (!to_code || !to_code[0]) - to_code = (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? - cfg_look_charset_internal : local_charset; - - cd = iconv_open (to_code, from_code); - if (cd == (iconv_t)(-1)) - return 0; - iconv_close (cd); - return 1; -#else - return 1; -#endif -} - -/* - * weechat_strreplace: replace a string by new one in a string - * note: returned value has to be free() after use - */ - -char * -weechat_strreplace (char *string, char *search, char *replace) -{ - char *pos, *new_string; - int length1, length2, length_new, count; - - if (!string || !search || !replace) - return NULL; - - length1 = strlen (search); - length2 = strlen (replace); - - /* count number of strings to replace */ - count = 0; - pos = string; - while (pos && pos[0] && (pos = strstr (pos, search))) - { - count++; - pos += length1; - } - - /* easy: no string to replace! */ - if (count == 0) - return strdup (string); - - /* compute needed memory for new string */ - length_new = strlen (string) - (count * length1) + (count * length2) + 1; - - /* allocate new string */ - new_string = (char *)malloc (length_new * sizeof (char)); - if (!new_string) - return strdup (string); - - /* replace all occurences */ - new_string[0] = '\0'; - while (string && string[0]) - { - pos = strstr (string, search); - if (pos) - { - strncat (new_string, string, pos - string); - strcat (new_string, replace); - pos += length1; - } - else - strcat (new_string, string); - string = pos; - } - return new_string; -} - -/* - * get_timeval_diff: calculates difference between two times (return in milliseconds) - */ - -long -get_timeval_diff (struct timeval *tv1, struct timeval *tv2) -{ - long diff_sec, diff_usec; - - diff_sec = tv2->tv_sec - tv1->tv_sec; - diff_usec = tv2->tv_usec - tv1->tv_usec; - - if (diff_usec < 0) - { - diff_usec += 1000000; - diff_sec--; - } - return ((diff_usec / 1000) + (diff_sec * 1000)); -} - -/* * weechat_display_usage: display WeeChat usage */ diff --git a/weechat/src/common/weechat.h b/weechat/src/common/weechat.h index c84c29a7b..9d0844a7d 100644 --- a/weechat/src/common/weechat.h +++ b/weechat/src/common/weechat.h @@ -104,16 +104,7 @@ extern char *local_charset; extern gnutls_certificate_credentials gnutls_xcred; #endif -extern void ascii_tolower (char *); -extern void ascii_toupper (char *); -extern int ascii_strcasecmp (char *, char *); -extern int ascii_strncasecmp (char *, char *, int); -extern char *ascii_strcasestr (char *, char *); -extern char *weechat_iconv (char *, char *, char *); -extern int weechat_iconv_check (char *, char *); -extern char *weechat_strreplace (char *, char *, char *); extern void weechat_dump (int); -extern long get_timeval_diff (struct timeval *, struct timeval *); extern void weechat_shutdown (int, int); #endif /* weechat.h */ diff --git a/weechat/src/common/weeconfig.c b/weechat/src/common/weeconfig.c index 2150a3814..11d05ce70 100644 --- a/weechat/src/common/weeconfig.c +++ b/weechat/src/common/weeconfig.c @@ -41,6 +41,7 @@ #include "fifo.h" #include "log.h" #include "utf8.h" +#include "util.h" #include "../irc/irc.h" #include "../gui/gui.h" diff --git a/weechat/src/common/weelist.c b/weechat/src/common/weelist.c index 9b2d0cb2c..97edd8bde 100644 --- a/weechat/src/common/weelist.c +++ b/weechat/src/common/weelist.c @@ -30,6 +30,7 @@ #include "weechat.h" #include "weelist.h" #include "log.h" +#include "util.h" /* diff --git a/weechat/src/gui/curses/gui-curses-color.c b/weechat/src/gui/curses/gui-curses-color.c index a180fee41..3a3d7c0b6 100644 --- a/weechat/src/gui/curses/gui-curses-color.c +++ b/weechat/src/gui/curses/gui-curses-color.c @@ -30,6 +30,7 @@ #include "../../common/weechat.h" #include "../gui.h" +#include "../../common/util.h" #include "../../common/weeconfig.h" #include "gui-curses.h" diff --git a/weechat/src/gui/curses/gui-curses-main.c b/weechat/src/gui/curses/gui-curses-main.c index 2c863fe54..5e3c4425e 100644 --- a/weechat/src/gui/curses/gui-curses-main.c +++ b/weechat/src/gui/curses/gui-curses-main.c @@ -34,6 +34,7 @@ #include "../gui.h" #include "../../common/fifo.h" #include "../../common/utf8.h" +#include "../../common/util.h" #include "../../common/weeconfig.h" #include "gui-curses.h" diff --git a/weechat/src/gui/gtk/gui-gtk-color.c b/weechat/src/gui/gtk/gui-gtk-color.c index 3536e6649..82785f266 100644 --- a/weechat/src/gui/gtk/gui-gtk-color.c +++ b/weechat/src/gui/gtk/gui-gtk-color.c @@ -30,6 +30,7 @@ #include "../../common/weechat.h" #include "../gui.h" +#include "../../common/util.h" #include "../../common/weeconfig.h" #include "gui-gtk.h" diff --git a/weechat/src/gui/gui-keyboard.c b/weechat/src/gui/gui-keyboard.c index 5325e8a1f..1717ae2ab 100644 --- a/weechat/src/gui/gui-keyboard.c +++ b/weechat/src/gui/gui-keyboard.c @@ -32,6 +32,7 @@ #include "gui.h" #include "../common/command.h" #include "../common/log.h" +#include "../common/util.h" #ifdef PLUGINS #include "../plugins/plugins.h" diff --git a/weechat/src/gui/gui-log.c b/weechat/src/gui/gui-log.c index 086528c30..0a3da4a09 100644 --- a/weechat/src/gui/gui-log.c +++ b/weechat/src/gui/gui-log.c @@ -31,6 +31,7 @@ #include "../common/weechat.h" #include "gui.h" #include "../common/log.h" +#include "../common/util.h" #include "../common/weeconfig.h" diff --git a/weechat/src/irc/irc-channel.c b/weechat/src/irc/irc-channel.c index ec5458337..25b481aa7 100644 --- a/weechat/src/irc/irc-channel.c +++ b/weechat/src/irc/irc-channel.c @@ -32,6 +32,7 @@ #include "irc.h" #include "../common/log.h" #include "../common/utf8.h" +#include "../common/util.h" #include "../common/weeconfig.h" #include "../gui/gui.h" diff --git a/weechat/src/irc/irc-dcc.c b/weechat/src/irc/irc-dcc.c index 73b260c1d..c51b6cb12 100644 --- a/weechat/src/irc/irc-dcc.c +++ b/weechat/src/irc/irc-dcc.c @@ -41,6 +41,7 @@ #include "irc.h" #include "../common/log.h" #include "../common/hotlist.h" +#include "../common/util.h" #include "../common/weeconfig.h" #include "../gui/gui.h" diff --git a/weechat/src/irc/irc-ignore.c b/weechat/src/irc/irc-ignore.c index cb80bd52b..3ef189c4c 100644 --- a/weechat/src/irc/irc-ignore.c +++ b/weechat/src/irc/irc-ignore.c @@ -31,6 +31,7 @@ #include "irc.h" #include "../common/command.h" #include "../common/log.h" +#include "../common/util.h" char *ignore_types[] = diff --git a/weechat/src/irc/irc-nick.c b/weechat/src/irc/irc-nick.c index a29132f71..5dd299a52 100644 --- a/weechat/src/irc/irc-nick.c +++ b/weechat/src/irc/irc-nick.c @@ -31,6 +31,7 @@ #include "../common/weechat.h" #include "irc.h" #include "../common/log.h" +#include "../common/util.h" #include "../common/weeconfig.h" diff --git a/weechat/src/irc/irc-recv.c b/weechat/src/irc/irc-recv.c index f679f3d48..56e1de775 100644 --- a/weechat/src/irc/irc-recv.c +++ b/weechat/src/irc/irc-recv.c @@ -39,6 +39,7 @@ #include "irc.h" #include "../common/command.h" #include "../common/hotlist.h" +#include "../common/util.h" #include "../common/weeconfig.h" #include "../gui/gui.h" diff --git a/weechat/src/irc/irc-send.c b/weechat/src/irc/irc-send.c index 6aba63a95..236c5d9e6 100644 --- a/weechat/src/irc/irc-send.c +++ b/weechat/src/irc/irc-send.c @@ -39,6 +39,7 @@ #include "../common/weechat.h" #include "irc.h" #include "../common/command.h" +#include "../common/util.h" #include "../common/weeconfig.h" #include "../gui/gui.h" diff --git a/weechat/src/plugins/plugins-config.c b/weechat/src/plugins/plugins-config.c index c959262d2..20688eecb 100644 --- a/weechat/src/plugins/plugins-config.c +++ b/weechat/src/plugins/plugins-config.c @@ -33,6 +33,7 @@ #include "../common/weechat.h" #include "weechat-plugin.h" #include "plugins-config.h" +#include "../common/util.h" #include "../irc/irc.h" diff --git a/weechat/src/plugins/plugins-interface.c b/weechat/src/plugins/plugins-interface.c index 567347870..16a49ebbb 100644 --- a/weechat/src/plugins/plugins-interface.c +++ b/weechat/src/plugins/plugins-interface.c @@ -36,6 +36,7 @@ #include "plugins-config.h" #include "../common/command.h" #include "../common/log.h" +#include "../common/util.h" #include "../common/weeconfig.h" #include "../irc/irc.h" #include "../gui/gui.h" diff --git a/weechat/src/plugins/plugins.c b/weechat/src/plugins/plugins.c index 49e4771b0..c99b16895 100644 --- a/weechat/src/plugins/plugins.c +++ b/weechat/src/plugins/plugins.c @@ -38,6 +38,7 @@ #include "plugins.h" #include "plugins-config.h" #include "../common/command.h" +#include "../common/util.h" #include "../common/weeconfig.h" #include "../irc/irc.h" #include "../gui/gui.h" |