您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ weechat_string_split函数代码示例

51自学网 2021-06-03 09:54:56
  C++
这篇教程C++ weechat_string_split函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中weechat_string_split函数的典型用法代码示例。如果您正苦于以下问题:C++ weechat_string_split函数的具体用法?C++ weechat_string_split怎么用?C++ weechat_string_split使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了weechat_string_split函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: exec_buffer_input_cb

intexec_buffer_input_cb (const void *pointer, void *data,                      struct t_gui_buffer *buffer,                      const char *input_data){    char **argv, **argv_eol;    int argc;    /* make C compiler happy */    (void) pointer;    (void) data;    /* close buffer */    if (strcmp (input_data, "q") == 0)    {        weechat_buffer_close (buffer);        return WEECHAT_RC_OK;    }    argv = weechat_string_split (input_data, " ", 0, 0, &argc);    argv_eol = weechat_string_split (input_data, " ", 1, 0, NULL);    if (argv && argv_eol)        exec_command_run (buffer, argc, argv, argv_eol, 0);    if (argv)        weechat_string_free_split (argv);    if (argv_eol)        weechat_string_free_split (argv_eol);    return WEECHAT_RC_OK;}
开发者ID:Evalle,项目名称:weechat,代码行数:32,


示例2: irc_notify_new_for_server

voidirc_notify_new_for_server (struct t_irc_server *server){    const char *notify;    char **items, *pos_params, **params;    int i, j, num_items, num_params, check_away;    irc_notify_free_all (server);    notify = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_NOTIFY);    if (!notify || !notify[0])        return;    items = weechat_string_split (notify, ",",                                  WEECHAT_STRING_SPLIT_STRIP_LEFT                                  | WEECHAT_STRING_SPLIT_STRIP_RIGHT                                  | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,                                  0, &num_items);    if (items)    {        for (i = 0; i < num_items; i++)        {            check_away = 0;            pos_params = strchr (items[i], ' ');            if (pos_params)            {                pos_params[0] = '/0';                pos_params++;                while (pos_params[0] == ' ')                {                    pos_params++;                }                params = weechat_string_split (                    pos_params,                    "/",                    WEECHAT_STRING_SPLIT_STRIP_LEFT                    | WEECHAT_STRING_SPLIT_STRIP_RIGHT                    | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,                    0,                    &num_params);                if (params)                {                    for (j = 0; j < num_params; j++)                    {                        if (weechat_strcasecmp (params[j], "away") == 0)                            check_away = 1;                    }                    weechat_string_free_split (params);                }            }            irc_notify_new (server, items[i], check_away);        }        weechat_string_free_split (items);    }    /* if we are using MONITOR, send it now with new nicks monitored */    if (server->is_connected && (server->monitor > 0))        irc_notify_send_monitor (server);}
开发者ID:weechat,项目名称:weechat,代码行数:59,


示例3: script_config_unhold

voidscript_config_unhold (const char *name_with_extension){    char **items, *hold;    int num_items, i, length;    length = strlen (weechat_config_string (script_config_scripts_hold)) + 1;    hold = malloc (length);    if (hold)    {        hold[0] = '/0';        items = weechat_string_split (weechat_config_string (script_config_scripts_hold),                                      ",", 0, 0, &num_items);        if (items)        {            for (i = 0; i < num_items; i++)            {                if (strcmp (items[i], name_with_extension) != 0)                {                    if (hold[0])                        strcat (hold, ",");                    strcat (hold, items[i]);                }            }            weechat_string_free_split (items);        }        weechat_config_option_set (script_config_scripts_hold, hold, 0);        free (hold);    }}
开发者ID:FauxFaux,项目名称:weechat_old,代码行数:32,


示例4: rmodifier_hook_modifiers

voidrmodifier_hook_modifiers (struct t_rmodifier *rmodifier){    char **argv, str_modifier[128];    int argc, i;    argv = weechat_string_split (rmodifier->modifiers, ",", 0, 0, &argc);    if (argv)    {        rmodifier->hooks = malloc (sizeof (*rmodifier->hooks) * argc);        if (rmodifier->hooks)        {            for (i = 0; i < argc; i++)            {                /*                 * we use a high priority here, so that other modifiers                 * (from other plugins) will be called after this one                 */                snprintf (str_modifier, sizeof (str_modifier) - 1,                          "5000|%s", argv[i]);                rmodifier->hooks[i] = weechat_hook_modifier (str_modifier,                                                             &rmodifier_modifier_cb,                                                             rmodifier);            }            rmodifier->hooks_count = argc;        }        weechat_string_free_split (argv);    }}
开发者ID:jameslord,项目名称:weechat,代码行数:30,


示例5: weechat_aspell_speller_check_dictionaries

voidweechat_aspell_speller_check_dictionaries (const char *dict_list){    char **argv;    int argc, i;    if (dict_list)    {        argv = weechat_string_split (dict_list, ",", 0, 0, &argc);        if (argv)        {            for (i = 0; i < argc; i++)            {                if (!weechat_aspell_speller_dict_supported (argv[i]))                {                    weechat_printf (NULL,                                    _("%s: warning: dictionary /"%s/" is not "                                      "available on your system"),                                    ASPELL_PLUGIN_NAME, argv[i]);                }            }            weechat_string_free_split (argv);        }    }}
开发者ID:lp0,项目名称:weechat,代码行数:25,


示例6: weechat_aspell_create_spellers

voidweechat_aspell_create_spellers (struct t_gui_buffer *buffer){    const char *dict_list;    char **argv;    int argc, i;    if (buffer)    {        dict_list = weechat_aspell_get_dict (buffer);        if (!weechat_aspell_spellers_already_ok (dict_list))        {            weechat_aspell_speller_free_all ();            if (dict_list)            {                argv = weechat_string_split (dict_list, ",", 0, 0, &argc);                if (argv)                {                    for (i = 0; i < argc; i++)                    {                        weechat_aspell_speller_new (argv[i]);                    }                    weechat_string_free_split (argv);                }            }        }    }}
开发者ID:jameslord,项目名称:weechat,代码行数:28,


示例7: weechat_aspell_spellers_already_ok

intweechat_aspell_spellers_already_ok (const char *dict_list){    char **argv;    int argc, rc, i;    struct t_aspell_speller *ptr_speller;    if (!dict_list && !weechat_aspell_spellers)        return 1;    if (!dict_list || !weechat_aspell_spellers)        return 0;    rc = 0;    argv = weechat_string_split (dict_list, ",", 0, 0, &argc);    if (argv)    {        ptr_speller = weechat_aspell_spellers;        for (i = 0; (i < argc) && ptr_speller; i++)        {            if (strcmp (ptr_speller->lang, argv[i]) == 0)            {                rc = 1;                break;            }            ptr_speller = ptr_speller->next_speller;        }        weechat_string_free_split (argv);    }    return rc;}
开发者ID:jameslord,项目名称:weechat,代码行数:33,


示例8: relay_config_change_irc_backlog_tags

voidrelay_config_change_irc_backlog_tags (void *data,                                      struct t_config_option *option){    char **items;    int num_items, i;    /* make C compiler happy */    (void) data;    (void) option;    if (!relay_config_hashtable_irc_backlog_tags)    {        relay_config_hashtable_irc_backlog_tags = weechat_hashtable_new (32,                                                                         WEECHAT_HASHTABLE_STRING,                                                                         WEECHAT_HASHTABLE_STRING,                                                                         NULL,                                                                         NULL);    }    else        weechat_hashtable_remove_all (relay_config_hashtable_irc_backlog_tags);    items = weechat_string_split (weechat_config_string (relay_config_irc_backlog_tags),                                  ";", 0, 0, &num_items);    if (items)    {        for (i = 0; i < num_items; i++)        {            weechat_hashtable_set (relay_config_hashtable_irc_backlog_tags,                                   items[i],                                   NULL);        }        weechat_string_free_split (items);    }}
开发者ID:FauxFaux,项目名称:weechat_old,代码行数:35,


示例9: relay_config_check_irc_backlog_tags

intrelay_config_check_irc_backlog_tags (void *data,                                     struct t_config_option *option,                                     const char *value){    char **tags;    int num_tags, i, rc;    /* make C compiler happy */    (void) data;    (void) option;    rc = 1;    /* "*" means all tags */    if (strcmp (value, "*") == 0)        return rc;    /* split tags and check them */    tags = weechat_string_split (value, ",", 0, 0, &num_tags);    if (tags)    {        for (i = 0; i < num_tags; i++)        {            if (relay_irc_search_backlog_commands_tags (tags[i]) < 0)            {                rc = 0;                break;            }        }        weechat_string_free_split (tags);    }    return rc;}
开发者ID:angrylogic,项目名称:weechat,代码行数:35,


示例10: weechat_aspell_speller_buffer_new

struct t_aspell_speller_buffer *weechat_aspell_speller_buffer_new (struct t_gui_buffer *buffer){    const char *buffer_dicts;    char **dicts;    int num_dicts, i;    struct t_aspell_speller_buffer *new_speller_buffer;    AspellSpeller *ptr_speller;    if (!buffer)        return NULL;    weechat_hashtable_remove (weechat_aspell_speller_buffer, buffer);    new_speller_buffer = malloc (sizeof (*new_speller_buffer));    if (!new_speller_buffer)        return NULL;    new_speller_buffer->spellers = NULL;    new_speller_buffer->modifier_string = NULL;    new_speller_buffer->input_pos = -1;    new_speller_buffer->modifier_result = NULL;    buffer_dicts = weechat_aspell_get_dict (buffer);    if (buffer_dicts)    {        dicts = weechat_string_split (buffer_dicts, ",", 0, 0, &num_dicts);        if (dicts && (num_dicts > 0))        {            new_speller_buffer->spellers =                malloc ((num_dicts + 1) * sizeof (AspellSpeller *));            if (new_speller_buffer->spellers)            {                for (i = 0; i < num_dicts; i++)                {                    ptr_speller = weechat_hashtable_get (weechat_aspell_spellers,                                                         dicts[i]);                    if (!ptr_speller)                        ptr_speller = weechat_aspell_speller_new (dicts[i]);                    new_speller_buffer->spellers[i] = ptr_speller;                }                new_speller_buffer->spellers[num_dicts] = NULL;            }        }        if (dicts)            weechat_string_free_split (dicts);    }    weechat_hashtable_set (weechat_aspell_speller_buffer,                           buffer,                           new_speller_buffer);    weechat_bar_item_update ("aspell_dict");    return new_speller_buffer;}
开发者ID:camilleacey,项目名称:weechat-1,代码行数:56,


示例11: script_config_get_diff_command

const char *script_config_get_diff_command (){    const char *diff_command;    char *dir_separator;    static char result[64];    struct stat st;    char *path, **paths, bin[4096];    int num_paths, i, rc;    diff_command = weechat_config_string (script_config_look_diff_command);    if (!diff_command || !diff_command[0])        return NULL;    if (strcmp (diff_command, "auto") == 0)    {        dir_separator = weechat_info_get ("dir_separator", "");        path = getenv ("PATH");        result[0] = '/0';        if (dir_separator && path)        {            paths = weechat_string_split (path, ":",                                          WEECHAT_STRING_SPLIT_STRIP_LEFT                                          | WEECHAT_STRING_SPLIT_STRIP_RIGHT                                          | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,                                          0, &num_paths);            if (paths)            {                for (i = 0; i < num_paths; i++)                {                    snprintf (bin, sizeof (bin), "%s%s%s",                              paths[i], dir_separator, "git");                    rc = stat (bin, &st);                    if ((rc == 0) && (S_ISREG(st.st_mode)))                    {                        snprintf (result, sizeof (result),                                  "git diff --no-index");                        break;                    }                }                weechat_string_free_split (paths);            }        }        if (dir_separator)            free (dir_separator);        if (!result[0])            snprintf (result, sizeof (result), "diff");        return result;    }    return diff_command;}
开发者ID:weechat,项目名称:weechat,代码行数:52,


示例12: relay_weechat_recv

voidrelay_weechat_recv (struct t_relay_client *client, const char *data){    char *new_partial, *pos, *tmp, **commands;    int num_commands, i;    if (relay_weechat_partial_message)    {        new_partial = realloc (relay_weechat_partial_message,                               strlen (relay_weechat_partial_message) +                               strlen (data) + 1);        if (!new_partial)            return;        relay_weechat_partial_message = new_partial;        strcat (relay_weechat_partial_message, data);    }    else        relay_weechat_partial_message = strdup (data);    pos = strrchr (relay_weechat_partial_message, '/n');    if (pos)    {        pos[0] = '/0';        commands = weechat_string_split (relay_weechat_partial_message, "/n",                                         0, 0, &num_commands);        if (commands)        {            for (i = 0; i < num_commands; i++)            {                relay_weechat_protocol_recv (client, commands[i]);            }            weechat_string_free_split (commands);        }        if (pos[1])        {            tmp = strdup (pos + 1);            free (relay_weechat_partial_message);            relay_weechat_partial_message = tmp;        }        else        {            free (relay_weechat_partial_message);            relay_weechat_partial_message = NULL;        }    }}
开发者ID:munkee,项目名称:weechat,代码行数:46,


示例13: weechat_python_get_python2_bin

char *weechat_python_get_python2_bin (){    const char *dir_separator;    char *py2_bin, *path, **paths, bin[4096];    char *versions[] = { "2.7", "2.6", "2.5", "2.4", "2.3", "2.2", "2", NULL };    int num_paths, i, j, rc;    struct stat stat_buf;    py2_bin = NULL;    dir_separator = weechat_info_get ("dir_separator", "");    path = getenv ("PATH");    if (dir_separator && path)    {        paths = weechat_string_split (path, ":", 0, 0, &num_paths);        if (paths)        {            for (i = 0; i < num_paths; i++)            {                for (j = 0; versions[j]; j++)                {                    snprintf (bin, sizeof (bin), "%s%s%s%s",                              paths[i], dir_separator, "python",                              versions[j]);                    rc = stat (bin, &stat_buf);                    if ((rc == 0) && (S_ISREG(stat_buf.st_mode)))                    {                        py2_bin = strdup (bin);                        break;                    }                }                if (py2_bin)                    break;            }            weechat_string_free_split (paths);        }    }    if (!py2_bin)        py2_bin = strdup ("python");    return py2_bin;}
开发者ID:Petzku,项目名称:weechat,代码行数:45,


示例14: script_config_hold

voidscript_config_hold (const char *name_with_extension){    char **items, *hold;    int num_items, i, length;    length = strlen (weechat_config_string (script_config_scripts_hold)) +        1 + strlen (name_with_extension) + 1;    hold = malloc (length);    if (hold)    {        hold[0] = '/0';        items = weechat_string_split (            weechat_config_string (script_config_scripts_hold),            ",",            WEECHAT_STRING_SPLIT_STRIP_LEFT            | WEECHAT_STRING_SPLIT_STRIP_RIGHT            | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,            0,            &num_items);        if (items)        {            for (i = 0; i < num_items; i++)            {                if (strcmp (items[i], name_with_extension) != 0)                {                    if (hold[0])                        strcat (hold, ",");                    strcat (hold, items[i]);                }            }            weechat_string_free_split (items);        }        if (hold[0])            strcat (hold, ",");        strcat (hold, name_with_extension);        weechat_config_option_set (script_config_scripts_hold, hold, 0);        free (hold);    }}
开发者ID:weechat,项目名称:weechat,代码行数:42,


示例15: weechat_aspell_speller_add_dicts_to_hash

voidweechat_aspell_speller_add_dicts_to_hash (struct t_hashtable *hashtable,                                          const char *dict){    char **dicts;    int num_dicts, i;    if (!dict || !dict[0])        return;    dicts = weechat_string_split (dict, ",", 0, 0, &num_dicts);    if (dicts)    {        for (i = 0; i < num_dicts; i++)        {            weechat_hashtable_set (hashtable, dicts[i], NULL);        }        weechat_string_free_split (dicts);    }}
开发者ID:lp0,项目名称:weechat,代码行数:20,


示例16: weechat_aspell_config_change_commands

voidweechat_aspell_config_change_commands (const void *pointer, void *data,                                       struct t_config_option *option){    const char *value;    int i;    /* make C compiler happy */    (void) pointer;    (void) data;    if (weechat_aspell_commands_to_check)    {        weechat_string_free_split (weechat_aspell_commands_to_check);        weechat_aspell_commands_to_check = NULL;        weechat_aspell_count_commands_to_check = 0;    }    if (weechat_aspell_length_commands_to_check)    {        free (weechat_aspell_length_commands_to_check);        weechat_aspell_length_commands_to_check = NULL;    }    value = weechat_config_string (option);    if (value && value[0])    {        weechat_aspell_commands_to_check = weechat_string_split (value,                                                                 ",", 0, 0,                                                                 &weechat_aspell_count_commands_to_check);        if (weechat_aspell_count_commands_to_check > 0)        {            weechat_aspell_length_commands_to_check = malloc (weechat_aspell_count_commands_to_check *                                                              sizeof (int));            for (i = 0; i < weechat_aspell_count_commands_to_check; i++)            {                weechat_aspell_length_commands_to_check[i] = strlen (weechat_aspell_commands_to_check[i]);            }        }    }}
开发者ID:Evalle,项目名称:weechat,代码行数:41,


示例17: irc_mode_get_arguments

char *irc_mode_get_arguments (const char *arguments){    char **argv, **argv2, *new_arguments;    int argc, i;    if (!arguments || !arguments[0])        return strdup ("");    argv = weechat_string_split (arguments, " ",                                 WEECHAT_STRING_SPLIT_STRIP_LEFT                                 | WEECHAT_STRING_SPLIT_STRIP_RIGHT                                 | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,                                 0, &argc);    if (!argv)        return strdup ("");    argv2 = malloc (sizeof (*argv) * (argc + 1));    if (!argv2)    {        weechat_string_free_split (argv);        return strdup ("");;    }    for (i = 0; i < argc; i++)    {        argv2[i] = (argv[i][0] == ':') ? argv[i] + 1 : argv[i];    }    argv2[argc] = NULL;    new_arguments = weechat_string_build_with_split_string (        (const char **)argv2, " ");    weechat_string_free_split (argv);    free (argv2);    return new_arguments;}
开发者ID:weechat,项目名称:weechat,代码行数:38,


示例18: buflist_config_change_sort

voidbuflist_config_change_sort (const void *pointer, void *data,                            struct t_config_option *option){    /* make C compiler happy */    (void) pointer;    (void) data;    (void) option;    if (buflist_config_sort_fields)        weechat_string_free_split (buflist_config_sort_fields);    buflist_config_sort_fields = weechat_string_split (        weechat_config_string (buflist_config_look_sort),        ",",        WEECHAT_STRING_SPLIT_STRIP_LEFT        | WEECHAT_STRING_SPLIT_STRIP_RIGHT        | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,        0,        &buflist_config_sort_fields_count);    buflist_bar_item_update (0);}
开发者ID:weechat,项目名称:weechat,代码行数:23,


示例19: relay_weechat_protocol_recv

voidrelay_weechat_protocol_recv (struct t_relay_client *client, const char *data){    char *pos, *id, *command, **argv, **argv_eol;    int i, argc, return_code;    struct t_relay_weechat_protocol_cb protocol_cb[] =        { { "init", &relay_weechat_protocol_cb_init },          { "hdata", &relay_weechat_protocol_cb_hdata },          { "info", &relay_weechat_protocol_cb_info },          { "infolist", &relay_weechat_protocol_cb_infolist },          { "nicklist", &relay_weechat_protocol_cb_nicklist },          { "input", &relay_weechat_protocol_cb_input },          { "sync", &relay_weechat_protocol_cb_sync },          { "desync", &relay_weechat_protocol_cb_desync },          { "test", &relay_weechat_protocol_cb_test },          { "ping", &relay_weechat_protocol_cb_ping },          { "quit", &relay_weechat_protocol_cb_quit },          { NULL, NULL }        };    if (!data || !data[0] || RELAY_CLIENT_HAS_ENDED(client))        return;    /* display debug message */    if (weechat_relay_plugin->debug >= 2)    {        weechat_printf (NULL, "%s: recv from client %s%s%s: /"%s/"",                        RELAY_PLUGIN_NAME,                        RELAY_COLOR_CHAT_CLIENT,                        client->desc,                        RELAY_COLOR_CHAT,                        data);    }    /* extract id */    id = NULL;    if (data[0] == '(')    {        pos = strchr (data, ')');        if (pos)        {            id = weechat_strndup (data + 1, pos - data - 1);            data = pos + 1;            while (data[0] == ' ')            {                data++;            }        }    }    /* search end of data */    pos = strchr (data, ' ');    if (pos)        command = weechat_strndup (data, pos - data);    else        command = strdup (data);    if (!command)    {        if (id)            free (id);        return;    }    argc = 0;    argv = NULL;    argv_eol = NULL;    if (pos)    {        while (pos[0] == ' ')        {            pos++;        }        argv = weechat_string_split (pos, " ", 0, 0, &argc);        argv_eol = weechat_string_split (pos, " ", 2, 0, NULL);    }    for (i = 0; protocol_cb[i].name; i++)    {        if (strcmp (protocol_cb[i].name, command) == 0)        {            if ((strcmp (protocol_cb[i].name, "init") != 0)                && (!RELAY_WEECHAT_DATA(client, password_ok)))            {                /*                 * command is not "init" and password is not set?                 * then close connection!                 */                relay_client_set_status (client,                                         RELAY_STATUS_AUTH_FAILED);            }            else            {                return_code = (int) (protocol_cb[i].cmd_function) (client,                                                                   id,                                                                   protocol_cb[i].name,                                                                   argc,                                                                   argv,                                                                   argv_eol);//.........这里部分代码省略.........
开发者ID:lp0,项目名称:weechat,代码行数:101,


示例20: irc_message_split

struct t_hashtable *irc_message_split (struct t_irc_server *server, const char *message){    struct t_hashtable *hashtable;    char **argv, **argv_eol, *tags, *host, *command, *arguments, target[512];    char *pos;    int split_ok, argc, index_args, max_length_nick, max_length_host;    split_ok = 0;    tags = NULL;    host = NULL;    command = NULL;    arguments = NULL;    index_args = 0;    argv = NULL;    argv_eol = NULL;    /* debug message */    if (weechat_irc_plugin->debug >= 2)        weechat_printf (NULL, "irc_message_split: message='%s'", message);    hashtable = weechat_hashtable_new (32,                                       WEECHAT_HASHTABLE_STRING,                                       WEECHAT_HASHTABLE_STRING,                                       NULL,                                       NULL);    if (!hashtable)        return NULL;    if (!message || !message[0])        goto end;    if (message[0] == '@')    {        pos = strchr (message, ' ');        if (pos)        {            tags = weechat_strndup (message, pos - message + 1);            message = pos + 1;        }    }    argv = weechat_string_split (message, " ", 0, 0, &argc);    argv_eol = weechat_string_split (message, " ", 2, 0, NULL);    if (argc < 2)        goto end;    if (argv[0][0] == ':')    {        if (argc < 3)            goto end;        host = argv[0];        command = argv[1];        arguments = argv_eol[2];        index_args = 2;    }    else    {        command = argv[0];        arguments = argv_eol[1];        index_args = 1;    }    max_length_nick = (server && (server->nick_max_length > 0)) ?        server->nick_max_length : 16;    max_length_host = 1 + /* ":"  */        max_length_nick + /* nick */        1 +               /* "!"  */        63 +              /* host */        1;                /* " "  */    if ((weechat_strcasecmp (command, "ison") == 0)        || (weechat_strcasecmp (command, "wallops") == 0))    {        split_ok = irc_message_split_string (hashtable, tags, host, command,                                             NULL, ":",                                             (argv_eol[index_args][0] == ':') ?                                             argv_eol[index_args] + 1 : argv_eol[index_args],                                             NULL, ' ', max_length_host);    }    else if (weechat_strcasecmp (command, "join") == 0)    {        /* split join (if it's more than 510 bytes) */        if (strlen (message) > 510)        {            split_ok = irc_message_split_join (hashtable, tags, host,                                               arguments);        }    }    else if ((weechat_strcasecmp (command, "privmsg") == 0)             || (weechat_strcasecmp (command, "notice") == 0))    {        /* split privmsg/notice */        if (index_args + 1 <= argc - 1)        {            split_ok = irc_message_split_privmsg_notice (hashtable, tags, host,                                                         command,                                                         argv[index_args],                                                         (argv_eol[index_args + 1][0] == ':') ?//.........这里部分代码省略.........
开发者ID:FauxFaux,项目名称:weechat_old,代码行数:101,


示例21: irc_message_split_join

intirc_message_split_join (struct t_hashtable *hashtable,                        const char *tags, const char *host,                        const char *arguments){    int number, channels_count, keys_count, length, length_no_channel;    int length_to_add, index_channel;    char **channels, **keys, *pos, *str;    char msg_to_send[2048], keys_to_add[2048];    number = 1;    channels = NULL;    channels_count = 0;    keys = NULL;    keys_count = 0;    pos = strchr (arguments, ' ');    if (pos)    {        str = weechat_strndup (arguments, pos - arguments);        if (!str)            return 0;        channels = weechat_string_split (str, ",", 0, 0, &channels_count);        free (str);        while (pos[0] == ' ')        {            pos++;        }        if (pos[0])            keys = weechat_string_split (pos, ",", 0, 0, &keys_count);    }    else    {        channels = weechat_string_split (arguments, ",", 0, 0, &channels_count);    }    snprintf (msg_to_send, sizeof (msg_to_send), "%s%sJOIN",              (host) ? host : "",              (host) ? " " : "");    length = strlen (msg_to_send);    length_no_channel = length;    keys_to_add[0] = '/0';    index_channel = 0;    while (index_channel < channels_count)    {        length_to_add = 1 + strlen (channels[index_channel]);        if (index_channel < keys_count)            length_to_add += 1 + strlen (keys[index_channel]);        if ((length + length_to_add < 510) || (length == length_no_channel))        {            if (length + length_to_add < (int)sizeof (msg_to_send))            {                strcat (msg_to_send, (length == length_no_channel) ? " " : ",");                strcat (msg_to_send, channels[index_channel]);            }            if (index_channel < keys_count)            {                if (strlen (keys_to_add) + 1 +                    strlen (keys[index_channel]) < (int)sizeof (keys_to_add))                {                    strcat (keys_to_add, (keys_to_add[0]) ? "," : " ");                    strcat (keys_to_add, keys[index_channel]);                }            }            length += length_to_add;            index_channel++;        }        else        {            strcat (msg_to_send, keys_to_add);            irc_message_split_add (hashtable, number,                                   tags,                                   msg_to_send,                                   msg_to_send + length_no_channel + 1);            number++;            snprintf (msg_to_send, sizeof (msg_to_send), "%s%sJOIN",                      (host) ? host : "",                      (host) ? " " : "");            length = strlen (msg_to_send);            keys_to_add[0] = '/0';        }    }    if (length > length_no_channel)    {        strcat (msg_to_send, keys_to_add);        irc_message_split_add (hashtable, number,                               tags,                               msg_to_send,                               msg_to_send + length_no_channel + 1);    }    if (channels)        weechat_string_free_split (channels);    if (keys)        weechat_string_free_split (keys);    return 1;}
开发者ID:FauxFaux,项目名称:weechat_old,代码行数:100,


示例22: trigger_hook

voidtrigger_hook (struct t_trigger *trigger){    char **argv, **argv_eol, *tags, *message, *error1, *error2, *error3;    int i, argc, strip_colors;    long interval, align_second, max_calls;    trigger_unhook (trigger);    argv = weechat_string_split (weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]),                                 ";", 0, 0, &argc);    argv_eol = weechat_string_split (weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]),                                     ";", 1, 0, NULL);    switch (weechat_config_integer (trigger->options[TRIGGER_OPTION_HOOK]))    {        case TRIGGER_HOOK_SIGNAL:            if (argv && (argc >= 1))            {                trigger->hooks = malloc (argc * sizeof (trigger->hooks[0]));                if (trigger->hooks)                {                    trigger->hooks_count = argc;                    for (i = 0; i < argc; i++)                    {                        trigger->hooks[i] = weechat_hook_signal (                            argv[i],                            &trigger_callback_signal_cb,                            trigger);                    }                }            }            break;        case TRIGGER_HOOK_HSIGNAL:            if (argv && (argc >= 1))            {                trigger->hooks = malloc (argc * sizeof (trigger->hooks[0]));                if (trigger->hooks)                {                    trigger->hooks_count = argc;                    for (i = 0; i < argc; i++)                    {                        trigger->hooks[i] = weechat_hook_hsignal (                            argv[i],                            &trigger_callback_hsignal_cb,                            trigger);                    }                }            }            break;        case TRIGGER_HOOK_MODIFIER:            if (argv && (argc >= 1))            {                trigger->hooks = malloc (argc * sizeof (trigger->hooks[0]));                if (trigger->hooks)                {                    trigger->hooks_count = argc;                    for (i = 0; i < argc; i++)                    {                        trigger->hooks[i] = weechat_hook_modifier (                            argv[i],                            &trigger_callback_modifier_cb,                            trigger);                    }                }            }            break;        case TRIGGER_HOOK_PRINT:            tags = NULL;            message = NULL;            strip_colors = 0;            if (argv && (argc >= 1))            {                if (strcmp (argv[0], "*") != 0)                    trigger->hook_print_buffers = strdup (argv[0]);                if ((argc >= 2) && (strcmp (argv[1], "*") != 0))                    tags = argv[1];                if ((argc >= 3) && (strcmp (argv[2], "*") != 0))                    message = argv[2];                if (argc >= 4)                    strip_colors = (strcmp (argv[3], "0") != 0) ? 1 : 0;            }            trigger->hooks = malloc (sizeof (trigger->hooks[0]));            if (trigger->hooks)            {                trigger->hooks_count = 1;                trigger->hooks[0] = weechat_hook_print (                    NULL,                    tags,                    message,                    strip_colors,                    &trigger_callback_print_cb,                    trigger);            }            break;        case TRIGGER_HOOK_COMMAND:            if (argv && (argc >= 1))            {                trigger->hooks = malloc (sizeof (trigger->hooks[0]));                if (trigger->hooks)//.........这里部分代码省略.........
开发者ID:AlexTalker,项目名称:weechat,代码行数:101,


示例23: irc_mode_channel_set

intirc_mode_channel_set (struct t_irc_server *server,                      struct t_irc_channel *channel,                      const char *modes){    char *pos_args, *str_modes, set_flag, **argv, *pos, *ptr_arg, chanmode_type;    int argc, current_arg, update_channel_modes, channel_modes_updated;    int smart_filter;    struct t_irc_nick *ptr_nick;    if (!server || !channel || !modes)        return 0;    channel_modes_updated = 0;    argc = 0;    argv = NULL;    pos_args = strchr (modes, ' ');    if (pos_args)    {        str_modes = weechat_strndup (modes, pos_args - modes);        if (!str_modes)            return 0;        pos_args++;        while (pos_args[0] == ' ')            pos_args++;        argv = weechat_string_split (pos_args, " ", 0, 0, &argc);    }    else    {        str_modes = strdup (modes);        if (!str_modes)            return 0;    }    current_arg = 0;    smart_filter = (weechat_config_boolean (irc_config_look_smart_filter)                    && weechat_config_string (irc_config_look_smart_filter_mode)                    && weechat_config_string (irc_config_look_smart_filter_mode)[0]) ? 1 : 0;    if (str_modes && str_modes[0])    {        set_flag = '+';        pos = str_modes;        while (pos && pos[0])        {            switch (pos[0])            {                case ':':                case ' ':                    break;                case '+':                    set_flag = '+';                    break;                case '-':                    set_flag = '-';                    break;                default:                    update_channel_modes = 1;                    chanmode_type = irc_mode_get_chanmode_type (server, pos[0]);                    ptr_arg = NULL;                    switch (chanmode_type)                    {                        case 'A': /* always argument */                            update_channel_modes = 0;                            ptr_arg = (current_arg < argc) ?                                argv[current_arg] : NULL;                            break;                        case 'B': /* always argument */                            ptr_arg = (current_arg < argc) ?                                argv[current_arg] : NULL;                            break;                        case 'C': /* argument if set */                            ptr_arg = ((set_flag == '+') && (current_arg < argc)) ?                                argv[current_arg] : NULL;                            break;                        case 'D': /* no argument */                            break;                    }                    if (ptr_arg)                        current_arg++;                    if (smart_filter                        && !irc_mode_smart_filtered (server, pos[0]))                    {                        smart_filter = 0;                    }                    if (pos[0] == 'k')                    {                        /* channel key */                        if (set_flag == '-')                        {                            if (channel->key)                            {                                free (channel->key);                                channel->key = NULL;                            }                        }                        else if ((set_flag == '+')//.........这里部分代码省略.........
开发者ID:AlexTalker,项目名称:weechat,代码行数:101,


示例24: relay_weechat_msg_add_infolist

voidrelay_weechat_msg_add_infolist (struct t_relay_weechat_msg *msg,                                const char *name,                                void *pointer,                                const char *arguments){    struct t_infolist *ptr_infolist;    const char *fields;    char **list_fields;    void *buf_ptr;    int num_fields, i, buf_size;    int pos_count_items, count_items, pos_count_vars, count_vars;    uint32_t count32;    ptr_infolist = weechat_infolist_get (name, pointer, arguments);    if (!ptr_infolist)        return;    /* start infolist in message */    relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_INFOLIST);    relay_weechat_msg_add_string (msg, name);    /* count of items will be set later, with number of items in infolist */    pos_count_items = msg->data_size;    count_items = 0;    relay_weechat_msg_add_int (msg, 0);    while (weechat_infolist_next (ptr_infolist))    {        fields = weechat_infolist_fields (ptr_infolist);        if (fields)        {            list_fields = weechat_string_split (fields, ",", 0, 0, &num_fields);            if (list_fields)            {                count_items++;                pos_count_vars = msg->data_size;                count_vars = 0;                relay_weechat_msg_add_int (msg, 0);                for (i = 0; i < num_fields; i++)                {                    if (strlen (list_fields[i]) > 2)                    {                        count_vars++;                        relay_weechat_msg_add_string (msg, list_fields[i] + 2);                        switch (list_fields[i][0])                        {                            case 'i':                                relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_INT);                                relay_weechat_msg_add_int (msg,                                                           weechat_infolist_integer (ptr_infolist,                                                                                     list_fields[i] + 2));                                break;                            case 's':                                relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_STRING);                                relay_weechat_msg_add_string (msg,                                                              weechat_infolist_string (ptr_infolist,                                                                                       list_fields[i] + 2));                                break;                            case 'p':                                relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_POINTER);                                relay_weechat_msg_add_pointer (msg,                                                               weechat_infolist_pointer (ptr_infolist,                                                                                         list_fields[i] + 2));                                break;                            case 'b':                                relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_BUFFER);                                buf_ptr = weechat_infolist_buffer (ptr_infolist,                                                                   list_fields[i] + 2,                                                                   &buf_size);                                relay_weechat_msg_add_buffer (msg, buf_ptr, buf_size);                                break;                            case 't':                                relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_TIME);                                relay_weechat_msg_add_time (msg,                                                            weechat_infolist_time (ptr_infolist,                                                                                   list_fields[i] + 2));                                break;                        }                    }                }                /* set count of variables in item */                count32 = htonl ((uint32_t)count_vars);                relay_weechat_msg_set_bytes (msg, pos_count_vars, &count32, 4);                weechat_string_free_split (list_fields);            }        }    }    /* set count of items */    count32 = htonl ((uint32_t)count_items);    relay_weechat_msg_set_bytes (msg, pos_count_items, &count32, 4);    weechat_infolist_free (ptr_infolist);}
开发者ID:FauxFaux,项目名称:weechat_old,代码行数:97,


示例25: trigger_command_trigger

inttrigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc,                         char **argv, char **argv_eol){    struct t_trigger *ptr_trigger, *ptr_trigger2;    struct t_trigger_regex *regex;    char *value, **sargv, **items, input[1024], str_pos[16];    int rc, i, type, count, index_option, enable, sargc, num_items, add_rc;    int regex_count, regex_rc;    /* make C compiler happy */    (void) data;    rc = WEECHAT_RC_OK;    sargv = NULL;    /* list all triggers */    if ((argc == 1)        || ((argc == 2) && (weechat_strcasecmp (argv[1], "list") == 0)))    {        trigger_command_list (_("List of triggers:"), 0);        goto end;    }    /* full list of all triggers */    if ((argc == 2) && (weechat_strcasecmp (argv[1], "listfull") == 0))    {        trigger_command_list (_("List of triggers:"), 1);        goto end;    }    /* list of default triggers */    if ((argc == 2) && (weechat_strcasecmp (argv[1], "listdefault") == 0))    {        trigger_command_list_default (1);        goto end;    }    /* add a trigger */    if ((weechat_strcasecmp (argv[1], "add") == 0)        || (weechat_strcasecmp (argv[1], "addoff") == 0)        || (weechat_strcasecmp (argv[1], "addreplace") == 0))    {        sargv = weechat_string_split_shell (argv_eol[2], &sargc);        if (!sargv || (sargc < 2))            goto error;        if (!trigger_name_valid (sargv[0]))        {            weechat_printf_tags (NULL, "no_trigger",                                 _("%s%s: invalid name for trigger"),                                 weechat_prefix ("error"), TRIGGER_PLUGIN_NAME);            goto end;        }        type = trigger_search_hook_type (sargv[1]);        if (type < 0)        {            weechat_printf_tags (NULL, "no_trigger",                                 _("%s%s: invalid hook type /"%s/""),                                 weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,                                 sargv[1]);            goto end;        }        if ((sargc > 4) && sargv[4][0])        {            regex_count = 0;            regex = NULL;            regex_rc = trigger_regex_split (sargv[4], &regex_count, &regex);            trigger_regex_free (&regex_count, &regex);            switch (regex_rc)            {                case 0: /* OK */                    break;                case -1: /* format error */                    weechat_printf (NULL,                                    _("%s%s: invalid format for regular "                                      "expression"),                                    weechat_prefix ("error"),                                    TRIGGER_PLUGIN_NAME);                    goto end;                    break;                case -2: /* regex compilation error */                    weechat_printf (NULL,                                    _("%s%s: invalid regular expression "                                      "(compilation failed)"),                                    weechat_prefix ("error"),                                    TRIGGER_PLUGIN_NAME);                    goto end;                    break;                case -3: /* memory error */                    weechat_printf (NULL,                                    _("%s%s: not enough memory"),                                    weechat_prefix ("error"),                                    TRIGGER_PLUGIN_NAME);                    goto end;                    break;            }        }        if ((sargc > 6) && sargv[6][0]            && (trigger_search_return_code (sargv[6]) < 0))        {//.........这里部分代码省略.........
开发者ID:AlexTalker,项目名称:weechat,代码行数:101,


示例26: relay_weechat_msg_add_hdata

voidrelay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,                             const char *path, const char *keys){    struct t_hdata *ptr_hdata_head, *ptr_hdata;    char *hdata_head, *pos, **list_keys, *keys_types, **list_path;    char *path_returned;    const char *hdata_name, *array_size;    void *pointer, **path_pointers;    long unsigned int value;    int num_keys, num_path, i, type, pos_count, count, rc;    uint32_t count32;    hdata_head = NULL;    list_keys = NULL;    num_keys = 0;    keys_types = NULL;    list_path = NULL;    num_path = 0;    path_returned = NULL;    /* extract hdata name (head) from path */    pos = strchr (path, ':');    if (!pos)        goto end;    hdata_head = weechat_strndup (path, pos - path);    if (!hdata_head)        goto end;    ptr_hdata_head = weechat_hdata_get (hdata_head);    if (!ptr_hdata_head)        goto end;    /* split path */    list_path = weechat_string_split (pos + 1, "/", 0, 0, &num_path);    if (!list_path)        goto end;    /* extract pointer from first path (direct pointer or list name) */    pointer = NULL;    pos = strchr (list_path[0], '(');    if (pos)        pos[0] = '/0';    if (strncmp (list_path[0], "0x", 2) == 0)    {        rc = sscanf (list_path[0], "%lx", &value);        if ((rc != EOF) && (rc != 0))            pointer = (void *)value;    }    else        pointer = weechat_hdata_get_list (ptr_hdata_head, list_path[0]);    if (pos)        pos[0] = '(';    if (!pointer)        goto end;    /*     * build string with path where:     * - counters are removed     * - variable names are replaced by hdata name     */    path_returned = malloc (strlen (path) * 2);    if (!path_returned)        goto end;    ptr_hdata = ptr_hdata_head;    strcpy (path_returned, hdata_head);    hdata_name = hdata_head;    for (i = 1; i < num_path; i++)    {        pos = strchr (list_path[i], '(');        if (pos)            pos[0] = '/0';        hdata_name = weechat_hdata_get_var_hdata (ptr_hdata, list_path[i]);        if (!hdata_name)            goto end;        ptr_hdata = weechat_hdata_get (hdata_name);        if (!ptr_hdata)            goto end;        strcat (path_returned, "/");        strcat (path_returned, hdata_name);        if (pos)            pos[0] = '(';    }    /* split keys */    if (!keys)        keys = weechat_hdata_get_string (ptr_hdata, "var_keys");    list_keys = weechat_string_split (keys, ",", 0, 0, &num_keys);    if (!list_keys)        goto end;    /* build string with list of keys with types: "key1:type1,key2:type2,..." */    keys_types = malloc (strlen (keys) + (num_keys * 8) + 1);    if (!keys_types)        goto end;    keys_types[0] = '/0';    for (i = 0; i < num_keys; i++)    {        type = weechat_hdata_get_var_type (ptr_hdata, list_keys[i]);        if ((type >= 0) && (type != WEECHAT_HDATA_OTHER))        {//.........这里部分代码省略.........
开发者ID:FauxFaux,项目名称:weechat_old,代码行数:101,


示例27: trigger_callback_modifier_cb

//.........这里部分代码省略.........                if (pos > string_no_color)                {                    prefix = weechat_strndup (string_no_color,                                              pos - string_no_color);                    if (prefix)                    {                        weechat_hashtable_set (extra_vars,                                               "tg_prefix_nocolor", prefix);                        free (prefix);                    }                }                pos++;                if (pos[0] == '/t')                    pos++;                weechat_hashtable_set (extra_vars, "tg_message_nocolor", pos);            }            else            {                weechat_hashtable_set (extra_vars,                                       "tg_message_nocolor", string_no_color);            }        }        /*         * extract buffer/tags from modifier data         * (format: "plugin;buffer_name;tags")         */        pos = strchr (modifier_data, ';');        if (pos)        {            plugin_name = weechat_strndup (modifier_data, pos - modifier_data);            if (plugin_name)            {                weechat_hashtable_set (extra_vars, "tg_plugin", plugin_name);                pos++;                pos2 = strchr (pos, ';');                if (pos2)                {                    buffer_name = weechat_strndup (pos, pos2 - pos);                    if (buffer_name)                    {                        buffer = weechat_buffer_search (plugin_name,                                                        buffer_name);                        length = strlen (plugin_name) + 1 + strlen (buffer_name) + 1;                        buffer_full_name = malloc (length);                        if (buffer_full_name)                        {                            snprintf (buffer_full_name, length,                                      "%s.%s", plugin_name, buffer_name);                            weechat_hashtable_set (extra_vars, "tg_buffer",                                                   buffer_full_name);                            free (buffer_full_name);                        }                        free (buffer_name);                    }                    pos2++;                    if (pos2[0])                    {                        tags = weechat_string_split (pos2, ",", 0, 0, &num_tags);                        length = 1 + strlen (pos2) + 1 + 1;                        str_tags = malloc (length);                        if (str_tags)                        {                            snprintf (str_tags, length, ",%s,", pos2);                            weechat_hashtable_set (extra_vars, "tg_tags",                                                   str_tags);                            free (str_tags);                        }                    }                }                free (plugin_name);            }        }        weechat_hashtable_set (pointers, "buffer", buffer);    }    if (tags)    {        if (!trigger_callback_set_tags (buffer, (const char **)tags, num_tags,                                        extra_vars))        {            goto end;        }    }    /* execute the trigger (conditions, regex, command) */    trigger_callback_execute (trigger, buffer, pointers, extra_vars);end:    ptr_string = weechat_hashtable_get (extra_vars, "tg_string");    string_modified = (ptr_string && (strcmp (ptr_string, string) != 0)) ?        strdup (ptr_string) : NULL;    if (tags)        weechat_string_free_split (tags);    if (string_no_color)        free (string_no_color);    TRIGGER_CALLBACK_CB_END(string_modified);}
开发者ID:Petzku,项目名称:weechat,代码行数:101,


示例28: irc_mode_channel_update

voidirc_mode_channel_update (struct t_irc_server *server,                         struct t_irc_channel *channel,                         char set_flag,                         char chanmode,                         const char *argument){    char *pos_args, *str_modes, **argv, *pos, *ptr_arg;    char *new_modes, *new_args, str_mode[2], *str_temp;    int argc, current_arg, chanmode_found, length;    if (!channel->modes)        channel->modes = strdup ("+");    if (!channel->modes)        return;    argc = 0;    argv = NULL;    pos_args = strchr (channel->modes, ' ');    if (pos_args)    {        str_modes = weechat_strndup (channel->modes, pos_args - channel->modes);        if (!str_modes)            return;        pos_args++;        while (pos_args[0] == ' ')            pos_args++;        argv = weechat_string_split (pos_args, " ",                                     WEECHAT_STRING_SPLIT_STRIP_LEFT                                     | WEECHAT_STRING_SPLIT_STRIP_RIGHT                                     | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,                                     0, &argc);    }    else    {        str_modes = strdup (channel->modes);        if (!str_modes)            return;    }    new_modes = malloc (strlen (channel->modes) + 1 + 1);    new_args = malloc (((pos_args) ? strlen (pos_args) : 0)                       + ((argument) ? 1 + strlen (argument) : 0) + 1);    if (new_modes && new_args)    {        new_modes[0] = '/0';        new_args[0] = '/0';        /* loop on current modes and build "new_modes" + "new_args" */        current_arg = 0;        chanmode_found = 0;        pos = str_modes;        while (pos && pos[0])        {            if ((pos[0] == '+') || (pos[0] == '-'))            {                str_mode[0] = pos[0];                str_mode[1] = '/0';                strcat (new_modes, str_mode);            }            else            {                ptr_arg = NULL;                switch (irc_mode_get_chanmode_type (server, pos[0]))                {                    case 'A': /* always argument */                    case 'B': /* always argument */                    case 'C': /* argument if set */                        ptr_arg = (current_arg < argc) ?                            argv[current_arg] : NULL;                        break;                    case 'D': /* no argument */                        break;                }                if (ptr_arg)                    current_arg++;                if (pos[0] == chanmode)                {                    chanmode_found = 1;                    if (set_flag == '+')                    {                        str_mode[0] = pos[0];                        str_mode[1] = '/0';                        strcat (new_modes, str_mode);                        if (argument)                        {                            if (new_args[0])                                strcat (new_args, " ");                            strcat (new_args, argument);                        }                    }                }                else                {                    str_mode[0] = pos[0];                    str_mode[1] = '/0';                    strcat (new_modes, str_mode);                    if (ptr_arg)                    {                        if (new_args[0])//.........这里部分代码省略.........
开发者ID:weechat,项目名称:weechat,代码行数:101,


示例29: irc_upgrade_read_cb

//.........这里部分代码省略.........                    irc_upgrade_current_server->lag = weechat_infolist_integer (infolist, "lag");                    buf = weechat_infolist_buffer (infolist, "lag_check_time", &size);                    if (buf)                        memcpy (&(irc_upgrade_current_server->lag_check_time), buf, size);                    irc_upgrade_current_server->lag_next_check = weechat_infolist_time (infolist, "lag_next_check");                    irc_upgrade_current_server->lag_last_refresh = weechat_infolist_time (infolist, "lag_last_refresh");                    irc_upgrade_current_server->last_user_message = weechat_infolist_time (infolist, "last_user_message");                    irc_upgrade_current_server->last_away_check = weechat_infolist_time (infolist, "last_away_check");                    irc_upgrade_current_server->last_data_purge = weechat_infolist_time (infolist, "last_data_purge");                }                break;            case IRC_UPGRADE_TYPE_CHANNEL:                if (irc_upgrade_current_server)                {                    irc_upgrade_current_channel = irc_channel_new (irc_upgrade_current_server,                                                                   weechat_infolist_integer (infolist, "type"),                                                                   weechat_infolist_string (infolist, "name"),                                                                   0, 0);                    if (irc_upgrade_current_channel)                    {                        str = weechat_infolist_string (infolist, "topic");                        if (str)                            irc_channel_set_topic (irc_upgrade_current_channel, str);                        str = weechat_infolist_string (infolist, "modes");                        if (str)                            irc_upgrade_current_channel->modes = strdup (str);                        irc_upgrade_current_channel->limit = weechat_infolist_integer (infolist, "limit");                        str = weechat_infolist_string (infolist, "key");                        if (str)                            irc_upgrade_current_channel->key = strdup (str);                        str = weechat_infolist_string (infolist, "join_msg_received");                        if (str)                        {                            items = weechat_string_split (str, ",", 0, 0,                                                          &num_items);                            if (items)                            {                                for (i = 0; i < num_items; i++)                                {                                    weechat_hashtable_set (irc_upgrade_current_channel->join_msg_received,                                                           items[i], "1");                                }                                weechat_string_free_split (items);                            }                        }                        irc_upgrade_current_channel->checking_away = weechat_infolist_integer (infolist, "checking_away");                        str = weechat_infolist_string (infolist, "away_message");                        if (str)                            irc_upgrade_current_channel->away_message = strdup (str);                        irc_upgrade_current_channel->has_quit_server = weechat_infolist_integer (infolist, "has_quit_server");                        irc_upgrade_current_channel->cycle = weechat_infolist_integer (infolist, "cycle");                        irc_upgrade_current_channel->part = weechat_infolist_integer (infolist, "part");                        irc_upgrade_current_channel->nick_completion_reset = weechat_infolist_integer (infolist, "nick_completion_reset");                        for (i = 0; i < 2; i++)                        {                            index = 0;                            while (1)                            {                                snprintf (option_name, sizeof (option_name),                                          "nick_speaking%d_%05d", i, index);                                nick = weechat_infolist_string (infolist, option_name);                                if (!nick)                                    break;                                irc_channel_nick_speaking_add (irc_upgrade_current_channel,                                                               nick,                                                               i);
开发者ID:Shawn-Smith,项目名称:weechat,代码行数:67,


示例30: irc_mode_channel_set

intirc_mode_channel_set (struct t_irc_server *server,                      struct t_irc_channel *channel,                      const char *host,                      const char *modes,                      const char *modes_arguments){    const char *pos, *ptr_arg;    char set_flag, **argv, chanmode_type;    int argc, current_arg, update_channel_modes, channel_modes_updated;    int smart_filter, end_modes;    struct t_irc_nick *ptr_nick;    struct t_irc_modelist *ptr_modelist;    struct t_irc_modelist_item *ptr_item;    if (!server || !channel || !modes)        return 0;    channel_modes_updated = 0;    argc = 0;    argv = NULL;    if (modes_arguments)    {        argv = weechat_string_split (modes_arguments, " ",                                     WEECHAT_STRING_SPLIT_STRIP_LEFT                                     | WEECHAT_STRING_SPLIT_STRIP_RIGHT                                     | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,                                     0, &argc);    }    current_arg = 0;    smart_filter = (weechat_config_boolean (irc_config_look_smart_filter)                    && weechat_config_string (irc_config_look_smart_filter_mode)                    && weechat_config_string (irc_config_look_smart_filter_mode)[0]) ? 1 : 0;    end_modes = 0;    set_flag = '+';    pos = modes;    while (pos[0])    {        switch (pos[0])        {            case ':':                break;            case ' ':                end_modes = 1;                break;            case '+':                set_flag = '+';                break;            case '-':                set_flag = '-';                break;            default:                update_channel_modes = 1;                chanmode_type = irc_mode_get_chanmode_type (server, pos[0]);                ptr_arg = NULL;                switch (chanmode_type)                {                    case 'A': /* always argument */                        update_channel_modes = 0;                        ptr_arg = (current_arg < argc) ?                            argv[current_arg] : NULL;                        break;                    case 'B': /* always argument */                        ptr_arg = (current_arg < argc) ?                            argv[current_arg] : NULL;                        break;                    case 'C': /* argument if set */                        ptr_arg = ((set_flag == '+') && (current_arg < argc)) ?                            argv[current_arg] : NULL;                        break;                    case 'D': /* no argument */                        break;                }                if (ptr_arg)                {                    if (ptr_arg[0] == ':')                        ptr_arg++;                    current_arg++;                }                if (smart_filter                    && !irc_mode_smart_filtered (server, pos[0]))                {                    smart_filter = 0;                }                if (pos[0] == 'k')                {                    /* channel key */                    if (set_flag == '-')                    {                        if (channel->key)                        {                            free (channel->key);                            channel->key = NULL;                        }                    }//.........这里部分代码省略.........
开发者ID:weechat,项目名称:weechat,代码行数:101,



注:本文中的weechat_string_split函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ weekday函数代码示例
C++ weechat_strcasecmp函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。