Exemplo n.º 1
0
struct t_infolist *
irc_info_infolist_irc_notify_cb (void *data, const char *infolist_name,
                                 void *pointer, const char *arguments)
{
    struct t_infolist *ptr_infolist;
    struct t_irc_server *ptr_server;
    struct t_irc_notify *ptr_notify;

    /* make C compiler happy */
    (void) data;
    (void) infolist_name;

    if (pointer && !irc_notify_valid (NULL, pointer))
        return NULL;

    ptr_infolist = dogechat_infolist_new ();
    if (!ptr_infolist)
        return NULL;

    if (pointer)
    {
        /* build list with only one notify */
        if (!irc_notify_add_to_infolist (ptr_infolist, pointer))
        {
            dogechat_infolist_free (ptr_infolist);
            return NULL;
        }
        return ptr_infolist;
    }
    else
    {
        /* build list with notify list of all servers matching arguments */
        for (ptr_server = irc_servers; ptr_server;
             ptr_server = ptr_server->next_server)
        {
            if (!arguments || !arguments[0]
                || dogechat_string_match (ptr_server->name, arguments, 0))
            {
                for (ptr_notify = ptr_server->notify_list; ptr_notify;
                     ptr_notify = ptr_notify->next_notify)
                {
                    if (!irc_notify_add_to_infolist (ptr_infolist,
                                                     ptr_notify))
                    {
                        dogechat_infolist_free (ptr_infolist);
                        return NULL;
                    }
                }
            }
        }
        return ptr_infolist;
    }

    return NULL;
}
Exemplo n.º 2
0
struct t_infolist *
alias_info_infolist_alias_cb (void *data, const char *infolist_name,
                              void *pointer, const char *arguments)
{
    struct t_infolist *ptr_infolist;
    struct t_alias *ptr_alias;

    /* make C compiler happy */
    (void) data;
    (void) infolist_name;
    (void) arguments;

    if (pointer && !alias_valid (pointer))
        return NULL;

    ptr_infolist = dogechat_infolist_new ();
    if (!ptr_infolist)
        return NULL;

    if (pointer)
    {
        /* build list with only one alias */
        if (!alias_add_to_infolist (ptr_infolist, pointer))
        {
            dogechat_infolist_free (ptr_infolist);
            return NULL;
        }
        return ptr_infolist;
    }
    else
    {
        /* build list with all aliases matching arguments */
        for (ptr_alias = alias_list; ptr_alias;
             ptr_alias = ptr_alias->next_alias)
        {
            if (!arguments || !arguments[0]
                || dogechat_string_match (ptr_alias->name, arguments, 0))
            {
                if (!alias_add_to_infolist (ptr_infolist, ptr_alias))
                {
                    dogechat_infolist_free (ptr_infolist);
                    return NULL;
                }
            }
        }
        return ptr_infolist;
    }
    return NULL;
}
Exemplo n.º 3
0
struct t_infolist *
logger_info_infolist_logger_buffer_cb (void *data, const char *infolist_name,
                                       void *pointer, const char *arguments)
{
    struct t_infolist *ptr_infolist;
    struct t_logger_buffer *ptr_logger_buffer;

    /* make C compiler happy */
    (void) data;
    (void) infolist_name;
    (void) arguments;

    if (pointer && !logger_buffer_valid (pointer))
        return NULL;

    ptr_infolist = dogechat_infolist_new ();
    if (!ptr_infolist)
        return NULL;

    if (pointer)
    {
        /* build list with only one logger buffer */
        if (!logger_buffer_add_to_infolist (ptr_infolist, pointer))
        {
            dogechat_infolist_free (ptr_infolist);
            return NULL;
        }
        return ptr_infolist;
    }
    else
    {
        /* build list with all logger buffers */
        for (ptr_logger_buffer = logger_buffers; ptr_logger_buffer;
             ptr_logger_buffer = ptr_logger_buffer->next_buffer)
        {
            if (!logger_buffer_add_to_infolist (ptr_infolist,
                                                ptr_logger_buffer))
            {
                dogechat_infolist_free (ptr_infolist);
                return NULL;
            }
        }
        return ptr_infolist;
    }

    return NULL;
}
Exemplo n.º 4
0
struct t_infolist *
irc_info_infolist_irc_ignore_cb (void *data, const char *infolist_name,
                                 void *pointer, const char *arguments)
{
    struct t_infolist *ptr_infolist;
    struct t_irc_ignore *ptr_ignore;

    /* make C compiler happy */
    (void) data;
    (void) infolist_name;
    (void) arguments;

    if (pointer && !irc_ignore_valid (pointer))
        return NULL;

    ptr_infolist = dogechat_infolist_new ();
    if (!ptr_infolist)
        return NULL;

    if (pointer)
    {
        /* build list with only one ignore */
        if (!irc_ignore_add_to_infolist (ptr_infolist, pointer))
        {
            dogechat_infolist_free (ptr_infolist);
            return NULL;
        }
        return ptr_infolist;
    }
    else
    {
        /* build list with all ignore */
        for (ptr_ignore = irc_ignore_list; ptr_ignore;
             ptr_ignore = ptr_ignore->next_ignore)
        {
            if (!irc_ignore_add_to_infolist (ptr_infolist, ptr_ignore))
            {
                dogechat_infolist_free (ptr_infolist);
                return NULL;
            }
        }
        return ptr_infolist;
    }

    return NULL;
}
Exemplo n.º 5
0
struct t_infolist *
irc_info_infolist_irc_color_dogechat_cb (void *data, const char *infolist_name,
                                        void *pointer, const char *arguments)
{
    struct t_infolist *ptr_infolist;

    /* make C compiler happy */
    (void) data;
    (void) infolist_name;
    (void) pointer;
    (void) arguments;

    ptr_infolist = dogechat_infolist_new ();
    if (!ptr_infolist)
        return NULL;

    /* build list with all IRC colors */
    if (!irc_color_dogechat_add_to_infolist (ptr_infolist))
    {
        dogechat_infolist_free (ptr_infolist);
        return NULL;
    }
    return ptr_infolist;
}
Exemplo n.º 6
0
int
relay_upgrade_save_all_data (struct t_upgrade_file *upgrade_file)
{
    struct t_infolist *infolist;
    struct t_relay_server *ptr_server;
    struct t_relay_client *ptr_client;
    struct t_relay_raw_message *ptr_raw_message;
    int rc;

    /* save servers */
    for (ptr_server = relay_servers; ptr_server;
         ptr_server = ptr_server->next_server)
    {
        infolist = dogechat_infolist_new ();
        if (!infolist)
            return 0;
        if (!relay_server_add_to_infolist (infolist, ptr_server))
        {
            dogechat_infolist_free (infolist);
            return 0;
        }
        rc = dogechat_upgrade_write_object (upgrade_file,
                                           RELAY_UPGRADE_TYPE_SERVER,
                                           infolist);
        dogechat_infolist_free (infolist);
        if (!rc)
            return 0;
    }

    /* save clients */
    for (ptr_client = last_relay_client; ptr_client;
         ptr_client = ptr_client->prev_client)
    {
        infolist = dogechat_infolist_new ();
        if (!infolist)
            return 0;
        if (!relay_client_add_to_infolist (infolist, ptr_client))
        {
            dogechat_infolist_free (infolist);
            return 0;
        }
        rc = dogechat_upgrade_write_object (upgrade_file,
                                           RELAY_UPGRADE_TYPE_CLIENT,
                                           infolist);
        dogechat_infolist_free (infolist);
        if (!rc)
            return 0;
    }

    /* save raw messages */
    for (ptr_raw_message = relay_raw_messages; ptr_raw_message;
         ptr_raw_message = ptr_raw_message->next_message)
    {
        infolist = dogechat_infolist_new ();
        if (!infolist)
            return 0;
        if (!relay_raw_add_to_infolist (infolist, ptr_raw_message))
        {
            dogechat_infolist_free (infolist);
            return 0;
        }
        rc = dogechat_upgrade_write_object (upgrade_file,
                                           RELAY_UPGRADE_TYPE_RAW_MESSAGE,
                                           infolist);
        dogechat_infolist_free (infolist);
        if (!rc)
            return 0;
    }

    return 1;
}
Exemplo n.º 7
0
struct t_infolist *
irc_info_infolist_irc_nick_cb (void *data, const char *infolist_name,
                               void *pointer, const char *arguments)
{
    struct t_infolist *ptr_infolist;
    struct t_irc_server *ptr_server;
    struct t_irc_channel *ptr_channel;
    struct t_irc_nick *ptr_nick;
    char **argv;
    int argc;

    /* make C compiler happy */
    (void) data;
    (void) infolist_name;

    if (!arguments || !arguments[0])
        return NULL;

    ptr_server = NULL;
    ptr_channel = NULL;
    argv = dogechat_string_split (arguments, ",", 0, 0, &argc);
    if (!argv)
        return NULL;

    if (argc >= 2)
    {
        ptr_server = irc_server_search (argv[0]);
        if (!ptr_server)
        {
            dogechat_string_free_split (argv);
            return NULL;
        }
        ptr_channel = irc_channel_search (ptr_server, argv[1]);
        if (!ptr_channel)
        {
            dogechat_string_free_split (argv);
            return NULL;
        }
        if (!pointer && (argc >= 3))
        {
            pointer = irc_nick_search (ptr_server, ptr_channel,
                                       argv[2]);
            if (!pointer)
            {
                dogechat_string_free_split (argv);
                return NULL;
            }
        }
    }
    dogechat_string_free_split (argv);

    if (!ptr_server || !ptr_channel)
        return NULL;

    if (pointer && !irc_nick_valid (ptr_channel, pointer))
        return NULL;

    ptr_infolist = dogechat_infolist_new ();
    if (!ptr_infolist)
        return NULL;

    if (pointer)
    {
        /* build list with only one nick */
        if (!irc_nick_add_to_infolist (ptr_infolist,
                                       pointer))
        {
            dogechat_infolist_free (ptr_infolist);
            return NULL;
        }
        return ptr_infolist;
    }
    else
    {
        /* build list with all nicks of channel */
        for (ptr_nick = ptr_channel->nicks; ptr_nick;
             ptr_nick = ptr_nick->next_nick)
        {
            if (!irc_nick_add_to_infolist (ptr_infolist,
                                           ptr_nick))
            {
                dogechat_infolist_free (ptr_infolist);
                return NULL;
            }
        }
        return ptr_infolist;
    }

    return NULL;
}