mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 06:16:40 +02:00
core: add "hdata" (direct access to WeeChat/plugin data)
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -39,6 +40,10 @@
|
||||
#include "irc-input.h"
|
||||
|
||||
|
||||
struct t_hdata *irc_channel_hdata_channel = NULL;
|
||||
struct t_hdata *irc_channel_hdata_channel_speaking = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* irc_channel_valid: check if a channel pointer exists for a server
|
||||
* return 1 if channel exists
|
||||
@@ -832,6 +837,81 @@ irc_channel_free_all (struct t_irc_server *server)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_hdata_channel_cb: return hdata for channel
|
||||
*/
|
||||
|
||||
struct t_hdata *
|
||||
irc_channel_hdata_channel_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (irc_channel_hdata_channel)
|
||||
return irc_channel_hdata_channel;
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_channel", "next_channel");
|
||||
if (hdata)
|
||||
{
|
||||
irc_channel_hdata_channel = hdata;
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, type, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, name, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, topic, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, modes, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, limit, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, key, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, checking_away, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, away_message, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, has_quit_server, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, cycle, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, part, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, display_creation_date, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, nick_completion_reset, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, pv_remote_nick_color, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, hook_autorejoin, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, nicks_count, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, nicks, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, last_nick, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, nicks_speaking, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, nicks_speaking_time, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, last_nick_speaking_time, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, buffer, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, buffer_as_string, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, prev_channel, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel, next_channel, POINTER);
|
||||
}
|
||||
return irc_channel_hdata_channel;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_hdata_channel_speaking_cb: return hdata for channel_speaking
|
||||
*/
|
||||
|
||||
struct t_hdata *
|
||||
irc_channel_hdata_channel_speaking_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (irc_channel_hdata_channel_speaking)
|
||||
return irc_channel_hdata_channel_speaking;
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick");
|
||||
if (hdata)
|
||||
{
|
||||
irc_channel_hdata_channel_speaking = hdata;
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel_speaking, nick, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel_speaking, time_last_message, TIME);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel_speaking, prev_nick, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_channel_speaking, next_nick, POINTER);
|
||||
}
|
||||
return irc_channel_hdata_channel_speaking;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_add_to_infolist: add a channel in an infolist
|
||||
* return 1 if ok, 0 if error
|
||||
|
||||
@@ -118,6 +118,10 @@ extern int irc_channel_autorejoin_cb (void *data, int remaining_calls);
|
||||
extern void irc_channel_display_nick_back_in_pv (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick,
|
||||
const char *nickname);
|
||||
extern struct t_hdata *irc_channel_hdata_channel_cb (void *data,
|
||||
const char *hdata_name);
|
||||
extern struct t_hdata *irc_channel_hdata_channel_speaking_cb (void *data,
|
||||
const char *hdata_name);
|
||||
extern int irc_channel_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_channel *channel);
|
||||
extern void irc_channel_print_log (struct t_irc_channel *channel);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
@@ -34,6 +35,8 @@
|
||||
struct t_irc_ignore *irc_ignore_list = NULL; /* list of ignore */
|
||||
struct t_irc_ignore *last_irc_ignore = NULL; /* last ignore in list */
|
||||
|
||||
struct t_hdata *irc_ignore_hdata_ignore = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* irc_ignore_valid: check if an ignore pointer exists
|
||||
@@ -301,6 +304,38 @@ irc_ignore_free_all ()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_hdata_ignore_cb: return hdata for ignore
|
||||
*/
|
||||
|
||||
struct t_hdata *
|
||||
irc_ignore_hdata_ignore_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (irc_ignore_hdata_ignore)
|
||||
return irc_ignore_hdata_ignore;
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_ignore", "next_ignore");
|
||||
if (hdata)
|
||||
{
|
||||
irc_ignore_hdata_ignore = hdata;
|
||||
WEECHAT_HDATA_VAR(struct t_irc_ignore, number, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_ignore, mask, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_ignore, regex_mask, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_ignore, server, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_ignore, channel, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_ignore, prev_ignore, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_ignore, next_ignore, POINTER);
|
||||
WEECHAT_HDATA_LIST(irc_ignore_list);
|
||||
WEECHAT_HDATA_LIST(last_irc_ignore);
|
||||
}
|
||||
return irc_ignore_hdata_ignore;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_add_to_infolist: add an ignore in an infolist
|
||||
* return 1 if ok, 0 if error
|
||||
|
||||
@@ -51,6 +51,8 @@ extern int irc_ignore_check (struct t_irc_server *server,
|
||||
const char *host);
|
||||
extern void irc_ignore_free (struct t_irc_ignore *ignore);
|
||||
extern void irc_ignore_free_all ();
|
||||
extern struct t_hdata *irc_ignore_hdata_ignore_cb (void *data,
|
||||
const char *hdata_name);
|
||||
extern int irc_ignore_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_ignore *ignore);
|
||||
extern void irc_ignore_print_log ();
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* irc-info.c: info and infolist hooks for IRC plugin
|
||||
* irc-info.c: info, infolist and hdata hooks for IRC plugin
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "irc-nick.h"
|
||||
#include "irc-notify.h"
|
||||
#include "irc-protocol.h"
|
||||
#include "irc-redirect.h"
|
||||
#include "irc-server.h"
|
||||
|
||||
|
||||
@@ -626,4 +627,22 @@ irc_info_init ()
|
||||
N_("notify pointer (optional)"),
|
||||
N_("server name (can start or end with \"*\" as wildcard) (optional)"),
|
||||
&irc_info_get_infolist_cb, NULL);
|
||||
|
||||
/* hdata hooks */
|
||||
weechat_hook_hdata ("irc_nick", N_("irc nick"),
|
||||
&irc_nick_hdata_nick_cb, NULL);
|
||||
weechat_hook_hdata ("irc_channel", N_("irc channel"),
|
||||
&irc_channel_hdata_channel_cb, NULL);
|
||||
weechat_hook_hdata ("irc_channel_speaking", N_("irc channel_speaking"),
|
||||
&irc_channel_hdata_channel_speaking_cb, NULL);
|
||||
weechat_hook_hdata ("irc_ignore", N_("irc ignore"),
|
||||
&irc_ignore_hdata_ignore_cb, NULL);
|
||||
weechat_hook_hdata ("irc_notify", N_("irc notify"),
|
||||
&irc_notify_hdata_notify_cb, NULL);
|
||||
weechat_hook_hdata ("irc_redirect_pattern", N_("pattern for irc redirect"),
|
||||
&irc_redirect_hdata_redirect_pattern_cb, NULL);
|
||||
weechat_hook_hdata ("irc_redirect", N_("irc redirect"),
|
||||
&irc_redirect_hdata_redirect_cb, NULL);
|
||||
weechat_hook_hdata ("irc_server", N_("irc server"),
|
||||
&irc_server_hdata_server_cb, NULL);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
@@ -36,6 +37,9 @@
|
||||
#include "irc-channel.h"
|
||||
|
||||
|
||||
struct t_hdata *irc_nick_hdata_nick = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* irc_nick_valid: check if a nick pointer exists for a channel
|
||||
* return 1 if nick exists
|
||||
@@ -927,6 +931,37 @@ irc_nick_color_for_pv (struct t_irc_channel *channel, const char *nickname)
|
||||
return IRC_COLOR_CHAT_NICK_OTHER;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_hdata_nick_cb: return hdata for nick
|
||||
*/
|
||||
|
||||
struct t_hdata *
|
||||
irc_nick_hdata_nick_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (irc_nick_hdata_nick)
|
||||
return irc_nick_hdata_nick;
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick");
|
||||
if (hdata)
|
||||
{
|
||||
irc_nick_hdata_nick = hdata;
|
||||
WEECHAT_HDATA_VAR(struct t_irc_nick, name, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_nick, host, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_nick, prefixes, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_nick, prefix, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_nick, away, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_nick, color, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_nick, prev_nick, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_nick, next_nick, POINTER);
|
||||
}
|
||||
return irc_nick_hdata_nick;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_add_to_infolist: add a nick in an infolist
|
||||
* return 1 if ok, 0 if error
|
||||
|
||||
@@ -90,6 +90,8 @@ extern char *irc_nick_as_prefix (struct t_irc_server *server,
|
||||
const char *force_color);
|
||||
extern const char * irc_nick_color_for_pv (struct t_irc_channel *channel,
|
||||
const char *nickname);
|
||||
extern struct t_hdata *irc_nick_hdata_nick_cb (void *data,
|
||||
const char *hdata_name);
|
||||
extern int irc_nick_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_nick *nick);
|
||||
extern void irc_nick_print_log (struct t_irc_nick *nick);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -42,6 +43,8 @@ struct t_hook *irc_notify_timer_whois = NULL; /* timer for "whois" */
|
||||
/* hsignal for redirected commands */
|
||||
struct t_hook *irc_notify_hsignal = NULL;
|
||||
|
||||
struct t_hdata *irc_notify_hdata_notify = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* irc_notify_valid: check if a notify pointer exists for a server
|
||||
@@ -808,6 +811,37 @@ irc_notify_timer_whois_cb (void *data, int remaining_calls)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_notify_hdata_notify_cb: return hdata for notify
|
||||
*/
|
||||
|
||||
struct t_hdata *
|
||||
irc_notify_hdata_notify_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (irc_notify_hdata_notify)
|
||||
return irc_notify_hdata_notify;
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_notify", "next_notify");
|
||||
if (hdata)
|
||||
{
|
||||
irc_notify_hdata_notify = hdata;
|
||||
WEECHAT_HDATA_VAR(struct t_irc_notify, server, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_notify, nick, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_notify, check_away, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_notify, is_on_server, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_notify, away_message, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_notify, ison_received, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_notify, prev_notify, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_notify, next_notify, POINTER);
|
||||
}
|
||||
return irc_notify_hdata_notify;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_notify_add_to_infolist: add a notify in an infolist
|
||||
* return 1 if ok, 0 if error
|
||||
|
||||
@@ -55,6 +55,8 @@ extern void irc_notify_free_all (struct t_irc_server *server);
|
||||
extern void irc_notify_display_list (struct t_irc_server *server);
|
||||
extern int irc_notify_timer_ison_cb (void *data, int remaining_calls);
|
||||
extern int irc_notify_timer_whois_cb (void *data, int remaining_calls);
|
||||
extern struct t_hdata *irc_notify_hdata_notify_cb (void *data,
|
||||
const char *hdata_name);
|
||||
extern int irc_notify_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_notify *notify);
|
||||
extern void irc_notify_print_log (struct t_irc_server *server);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
@@ -36,6 +37,9 @@
|
||||
struct t_irc_redirect_pattern *irc_redirect_patterns = NULL;
|
||||
struct t_irc_redirect_pattern *last_irc_redirect_pattern = NULL;
|
||||
|
||||
struct t_hdata *irc_redirect_hdata_redirect_pattern = NULL;
|
||||
struct t_hdata *irc_redirect_hdata_redirect = NULL;
|
||||
|
||||
/* default redirect patterns */
|
||||
struct t_irc_redirect_pattern irc_redirect_patterns_default[] =
|
||||
{
|
||||
@@ -951,6 +955,81 @@ irc_redirect_free_all (struct t_irc_server *server)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_redirect_hdata_redirect_pattern_cb: return hdata for redirect pattern
|
||||
*/
|
||||
|
||||
struct t_hdata *
|
||||
irc_redirect_hdata_redirect_pattern_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (irc_redirect_hdata_redirect_pattern)
|
||||
return irc_redirect_hdata_redirect_pattern;
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect");
|
||||
if (hdata)
|
||||
{
|
||||
irc_redirect_hdata_redirect_pattern = hdata;
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect_pattern, name, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect_pattern, temp_pattern, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect_pattern, timeout, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect_pattern, cmd_start, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect_pattern, cmd_stop, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect_pattern, cmd_extra, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect_pattern, prev_redirect, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect_pattern, next_redirect, POINTER);
|
||||
WEECHAT_HDATA_LIST(irc_redirect_patterns);
|
||||
WEECHAT_HDATA_LIST(last_irc_redirect_pattern);
|
||||
}
|
||||
return irc_redirect_hdata_redirect_pattern;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_redirect_hdata_redirect_cb: return hdata for redirect
|
||||
*/
|
||||
|
||||
struct t_hdata *
|
||||
irc_redirect_hdata_redirect_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (irc_redirect_hdata_redirect)
|
||||
return irc_redirect_hdata_redirect;
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect");
|
||||
if (hdata)
|
||||
{
|
||||
irc_redirect_hdata_redirect = hdata;
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, server, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, pattern, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, signal, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, count, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, current_count, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, string, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, timeout, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, command, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, start_time, TIME);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, cmd_start, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, cmd_stop, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, cmd_extra, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, cmd_start_received, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, cmd_stop_received, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, cmd_filter, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, output, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, output_size, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, prev_redirect, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_redirect, next_redirect, POINTER);
|
||||
}
|
||||
return irc_redirect_hdata_redirect;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_redirect_pattern_add_to_infolist: add a redirect pattern in an infolist
|
||||
* return 1 if ok, 0 if error
|
||||
|
||||
@@ -108,6 +108,10 @@ extern int irc_redirect_message (struct t_irc_server *server,
|
||||
const char *arguments);
|
||||
extern void irc_redirect_free (struct t_irc_redirect *redirect);
|
||||
extern void irc_redirect_free_all (struct t_irc_server *server);
|
||||
extern struct t_hdata *irc_redirect_hdata_redirect_pattern_cb (void *data,
|
||||
const char *hdata_name);
|
||||
extern struct t_hdata *irc_redirect_hdata_redirect_cb (void *data,
|
||||
const char *hdata_name);
|
||||
extern int irc_redirect_pattern_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_redirect_pattern *redirect_pattern);
|
||||
extern int irc_redirect_add_to_infolist (struct t_infolist *infolist,
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
@@ -64,6 +65,8 @@ struct t_irc_server *last_irc_server = NULL;
|
||||
struct t_irc_message *irc_recv_msgq = NULL;
|
||||
struct t_irc_message *irc_msgq_last_msg = NULL;
|
||||
|
||||
struct t_hdata *irc_server_hdata_server = NULL;
|
||||
|
||||
char *irc_server_option_string[IRC_SERVER_NUM_OPTIONS] =
|
||||
{ "addresses", "proxy", "ipv6",
|
||||
"ssl", "ssl_cert", "ssl_priorities", "ssl_dhkey_size", "ssl_verify",
|
||||
@@ -3934,6 +3937,92 @@ irc_server_xfer_send_accept_resume_cb (void *data, const char *signal,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_server_hdata_server_cb: return hdata for server
|
||||
*/
|
||||
|
||||
struct t_hdata *
|
||||
irc_server_hdata_server_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (irc_server_hdata_server)
|
||||
return irc_server_hdata_server;
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_server", "next_server");
|
||||
if (hdata)
|
||||
{
|
||||
irc_server_hdata_server = hdata;
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, name, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, options, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, temp_server, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, reloading_from_config, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, reloaded_from_config, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, addresses_count, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, addresses_array, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, ports_array, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, index_current_address, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, current_address, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, current_ip, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, current_port, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, sock, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, hook_connect, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, hook_fd, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, hook_timer_connection, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, hook_timer_sasl, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, is_connected, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, ssl_connected, INTEGER);
|
||||
#ifdef HAVE_GNUTLS
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, gnutls_sess, OTHER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, tls_cert, OTHER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, tls_cert_key, OTHER);
|
||||
#endif
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, unterminated_message, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, nicks_count, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, nicks_array, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, nick_first_tried, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, nick, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, nick_modes, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, isupport, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, prefix_modes, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, prefix_chars, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, reconnect_delay, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, reconnect_start, TIME);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, command_time, TIME);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, reconnect_join, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, disable_autojoin, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, is_away, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, away_message, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, away_time, TIME);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, lag, INTEGER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, lag_check_time, OTHER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, lag_next_check, TIME);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, lag_last_refresh, TIME);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, cmd_list_regexp, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, last_user_message, TIME);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, last_away_check, TIME);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, outqueue, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, last_outqueue, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, redirects, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, last_redirect, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, notify_list, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, last_notify, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, manual_joins, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, buffer, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, buffer_as_string, STRING);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, channels, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, last_channel, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, prev_server, POINTER);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, next_server, POINTER);
|
||||
WEECHAT_HDATA_LIST(irc_servers);
|
||||
WEECHAT_HDATA_LIST(last_irc_server);
|
||||
}
|
||||
return irc_server_hdata_server;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_server_add_to_infolist: add a server in an infolist
|
||||
* return 1 if ok, 0 if error
|
||||
|
||||
@@ -272,6 +272,8 @@ extern int irc_server_xfer_resume_ready_cb (void *data, const char *signal,
|
||||
extern int irc_server_xfer_send_accept_resume_cb (void *data, const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data);
|
||||
extern struct t_hdata *irc_server_hdata_server_cb (void *data,
|
||||
const char *hdata_name);
|
||||
extern int irc_server_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_server *server);
|
||||
extern void irc_server_print_log ();
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include "../core/weechat.h"
|
||||
#include "../core/wee-config.h"
|
||||
#include "../core/wee-hashtable.h"
|
||||
#include "../core/wee-hook.h"
|
||||
#include "../core/wee-infolist.h"
|
||||
#include "../core/wee-input.h"
|
||||
@@ -47,6 +48,7 @@
|
||||
#include "../gui/gui-bar-window.h"
|
||||
#include "../gui/gui-buffer.h"
|
||||
#include "../gui/gui-chat.h"
|
||||
#include "../gui/gui-completion.h"
|
||||
#include "../gui/gui-color.h"
|
||||
#include "../gui/gui-filter.h"
|
||||
#include "../gui/gui-history.h"
|
||||
@@ -56,6 +58,7 @@
|
||||
#include "../gui/gui-nicklist.h"
|
||||
#include "../gui/gui-window.h"
|
||||
#include "plugin.h"
|
||||
#include "plugin-api.h"
|
||||
#include "plugin-config.h"
|
||||
|
||||
|
||||
@@ -1046,4 +1049,80 @@ plugin_api_init ()
|
||||
N_("window pointer (optional)"),
|
||||
N_("window name (can start or end with \"*\" as wildcard) (optional)"),
|
||||
&plugin_api_infolist_get_internal, NULL);
|
||||
|
||||
/* WeeChat core hdata */
|
||||
hook_hdata (NULL, "bar", N_("bar"),
|
||||
&gui_bar_hdata_bar_cb, NULL);
|
||||
hook_hdata (NULL, "bar_item", N_("bar item"),
|
||||
&gui_bar_item_hdata_bar_item_cb, NULL);
|
||||
hook_hdata (NULL, "buffer", N_("buffer"),
|
||||
&gui_buffer_hdata_buffer_cb, NULL);
|
||||
hook_hdata (NULL, "completion", N_("completion"),
|
||||
&gui_completion_hdata_completion_cb, NULL);
|
||||
hook_hdata (NULL, "completion_partial", N_("partial completion"),
|
||||
&gui_completion_hdata_completion_partial_cb, NULL);
|
||||
hook_hdata (NULL, "config_file", N_("config file"),
|
||||
&config_file_hdata_config_file_cb, NULL);
|
||||
hook_hdata (NULL, "config_section", N_("config section"),
|
||||
&config_file_hdata_config_section_cb, NULL);
|
||||
hook_hdata (NULL, "config_option", N_("config option"),
|
||||
&config_file_hdata_config_option_cb, NULL);
|
||||
hook_hdata (NULL, "filter", N_("filter"),
|
||||
&gui_filter_hdata_filter_cb, NULL);
|
||||
hook_hdata (NULL, "history", N_("history of commands in buffer"),
|
||||
&gui_history_hdata_history_cb, NULL);
|
||||
hook_hdata (NULL, "hook", N_("hook (variables common to all hook types)"),
|
||||
&hook_hdata_hook_cb, NULL);
|
||||
hook_hdata (NULL, "hook_command", N_("hook of type \"command\""),
|
||||
&hook_hdata_hook_command_cb, NULL);
|
||||
hook_hdata (NULL, "hook_command_run", N_("hook of type \"command_run\""),
|
||||
&hook_hdata_hook_command_run_cb, NULL);
|
||||
hook_hdata (NULL, "hook_timer", N_("hook of type \"timer\""),
|
||||
&hook_hdata_hook_timer_cb, NULL);
|
||||
hook_hdata (NULL, "hook_fd", N_("hook of type \"fd\""),
|
||||
&hook_hdata_hook_fd_cb, NULL);
|
||||
hook_hdata (NULL, "hook_process", N_("hook of type \"process\""),
|
||||
&hook_hdata_hook_process_cb, NULL);
|
||||
hook_hdata (NULL, "hook_connect", N_("hook of type \"connect\""),
|
||||
&hook_hdata_hook_connect_cb, NULL);
|
||||
hook_hdata (NULL, "hook_print", N_("hook of type \"print\""),
|
||||
&hook_hdata_hook_print_cb, NULL);
|
||||
hook_hdata (NULL, "hook_signal", N_("hook of type \"signal\""),
|
||||
&hook_hdata_hook_signal_cb, NULL);
|
||||
hook_hdata (NULL, "hook_hsignal", N_("hook of type \"hsignal\""),
|
||||
&hook_hdata_hook_hsignal_cb, NULL);
|
||||
hook_hdata (NULL, "hook_config", N_("hook of type \"config\""),
|
||||
&hook_hdata_hook_config_cb, NULL);
|
||||
hook_hdata (NULL, "hook_completion", N_("hook of type \"completion\""),
|
||||
&hook_hdata_hook_completion_cb, NULL);
|
||||
hook_hdata (NULL, "hook_modifier", N_("hook of type \"modifier\""),
|
||||
&hook_hdata_hook_modifier_cb, NULL);
|
||||
hook_hdata (NULL, "hook_info", N_("hook of type \"info\""),
|
||||
&hook_hdata_hook_info_cb, NULL);
|
||||
hook_hdata (NULL, "hook_info_hashtable", N_("hook of type \"info_hashtable\""),
|
||||
&hook_hdata_hook_info_hashtable_cb, NULL);
|
||||
hook_hdata (NULL, "hook_infolist", N_("hook of type \"infolist\""),
|
||||
&hook_hdata_hook_infolist_cb, NULL);
|
||||
hook_hdata (NULL, "hook_hdata", N_("hook of type \"hdata\""),
|
||||
&hook_hdata_hook_hdata_cb, NULL);
|
||||
hook_hdata (NULL, "input_undo", N_("undo for input line"),
|
||||
&gui_buffer_hdata_input_undo_cb, NULL);
|
||||
hook_hdata (NULL, "key", N_("key"),
|
||||
&gui_keyboard_hdata_key_cb, NULL);
|
||||
hook_hdata (NULL, "lines", N_("lines"),
|
||||
&gui_line_hdata_lines_cb, NULL);
|
||||
hook_hdata (NULL, "line", N_("line"),
|
||||
&gui_line_hdata_line_cb, NULL);
|
||||
hook_hdata (NULL, "line_data", N_("line data"),
|
||||
&gui_line_hdata_line_data_cb, NULL);
|
||||
hook_hdata (NULL, "nick_group", N_("group in nicklist"),
|
||||
&gui_nicklist_hdata_nick_group_cb, NULL);
|
||||
hook_hdata (NULL, "nick", N_("nick in nicklist"),
|
||||
&gui_nicklist_hdata_nick_cb, NULL);
|
||||
hook_hdata (NULL, "window", N_("window"),
|
||||
&gui_window_hdata_window_cb, NULL);
|
||||
hook_hdata (NULL, "window_scroll", N_("scroll info in window"),
|
||||
&gui_window_hdata_window_scroll_cb, NULL);
|
||||
hook_hdata (NULL, "window_tree", N_("tree of windows"),
|
||||
&gui_window_hdata_window_tree_cb, NULL);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
#ifndef __WEECHAT_PLUGIN_API_H
|
||||
#define __WEECHAT_PLUGIN_API_H 1
|
||||
|
||||
struct t_plugin_api_hdata
|
||||
{
|
||||
char *name; /* hdata name */
|
||||
struct t_hdata *(*callback_get_hdata)(); /* callback to get hdata */
|
||||
};
|
||||
|
||||
/* strings */
|
||||
extern void plugin_api_charset_set (struct t_weechat_plugin *plugin,
|
||||
const char *charset);
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "../core/weechat.h"
|
||||
#include "../core/wee-config.h"
|
||||
#include "../core/wee-hashtable.h"
|
||||
#include "../core/wee-hdata.h"
|
||||
#include "../core/wee-hook.h"
|
||||
#include "../core/wee-infolist.h"
|
||||
#include "../core/wee-list.h"
|
||||
@@ -604,6 +605,7 @@ plugin_load (const char *filename)
|
||||
new_plugin->hook_info = &hook_info;
|
||||
new_plugin->hook_info_hashtable = &hook_info_hashtable;
|
||||
new_plugin->hook_infolist = &hook_infolist;
|
||||
new_plugin->hook_hdata = &hook_hdata;
|
||||
new_plugin->unhook = &unhook;
|
||||
new_plugin->unhook_all = &unhook_all_plugin;
|
||||
|
||||
@@ -680,6 +682,24 @@ plugin_load (const char *filename)
|
||||
new_plugin->infolist_buffer = &plugin_api_infolist_buffer;
|
||||
new_plugin->infolist_time = &plugin_api_infolist_time;
|
||||
new_plugin->infolist_free = &plugin_api_infolist_free;
|
||||
|
||||
new_plugin->hdata_new = &hdata_new;
|
||||
new_plugin->hdata_new_var = &hdata_new_var;
|
||||
new_plugin->hdata_new_list = &hdata_new_list;
|
||||
new_plugin->hdata_get = &hook_hdata_get;
|
||||
new_plugin->hdata_get_var_offset = &hdata_get_var_offset;
|
||||
new_plugin->hdata_get_var_type = &hdata_get_var_type;
|
||||
new_plugin->hdata_get_var_type_string = &hdata_get_var_type_string;
|
||||
new_plugin->hdata_get_var = &hdata_get_var;
|
||||
new_plugin->hdata_get_var_at_offset = &hdata_get_var_at_offset;
|
||||
new_plugin->hdata_get_list = &hdata_get_list;
|
||||
new_plugin->hdata_move = &hdata_move;
|
||||
new_plugin->hdata_integer = &hdata_integer;
|
||||
new_plugin->hdata_long = &hdata_long;
|
||||
new_plugin->hdata_string = &hdata_string;
|
||||
new_plugin->hdata_pointer = &hdata_pointer;
|
||||
new_plugin->hdata_time = &hdata_time;
|
||||
new_plugin->hdata_get_string = &hdata_get_string;
|
||||
|
||||
new_plugin->upgrade_new = &upgrade_file_new;
|
||||
new_plugin->upgrade_write_object = &upgrade_file_write_object;
|
||||
|
||||
@@ -40,21 +40,24 @@
|
||||
|
||||
#define LUA_RETURN_OK return 1
|
||||
#define LUA_RETURN_ERROR return 0
|
||||
#define LUA_RETURN_EMPTY \
|
||||
lua_pushstring (lua_current_interpreter, ""); \
|
||||
#define LUA_RETURN_EMPTY \
|
||||
lua_pushstring (lua_current_interpreter, ""); \
|
||||
return 0
|
||||
#define LUA_RETURN_STRING(__string) \
|
||||
lua_pushstring (lua_current_interpreter, \
|
||||
(__string) ? __string : ""); \
|
||||
#define LUA_RETURN_STRING(__string) \
|
||||
lua_pushstring (lua_current_interpreter, \
|
||||
(__string) ? __string : ""); \
|
||||
return 1;
|
||||
#define LUA_RETURN_STRING_FREE(__string) \
|
||||
lua_pushstring (lua_current_interpreter, \
|
||||
(__string) ? __string : ""); \
|
||||
if (__string) \
|
||||
free (__string); \
|
||||
#define LUA_RETURN_STRING_FREE(__string) \
|
||||
lua_pushstring (lua_current_interpreter, \
|
||||
(__string) ? __string : ""); \
|
||||
if (__string) \
|
||||
free (__string); \
|
||||
return 1;
|
||||
#define LUA_RETURN_INT(__int) \
|
||||
lua_pushnumber (lua_current_interpreter, __int); \
|
||||
#define LUA_RETURN_INT(__int) \
|
||||
lua_pushnumber (lua_current_interpreter, __int); \
|
||||
return 1;
|
||||
#define LUA_RETURN_LONG(__long) \
|
||||
lua_pushnumber (lua_current_interpreter, __long); \
|
||||
return 1;
|
||||
|
||||
|
||||
@@ -7187,7 +7190,390 @@ weechat_lua_api_infolist_free (lua_State *L)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_new: create a new configuration file
|
||||
* weechat_lua_api_hdata_get: get hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_hdata_get (lua_State *L)
|
||||
{
|
||||
const char *name;
|
||||
char *result;
|
||||
int n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hdata_get");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hdata_get");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
name = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_get (name));
|
||||
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_hdata_get_var_type_string: get type of variable as string in
|
||||
* hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_hdata_get_var_type_string (lua_State *L)
|
||||
{
|
||||
const char *hdata, *name, *result;
|
||||
int n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hdata_get_var_type_string");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hdata_get_var_type_string");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = lua_tostring (lua_current_interpreter, -2);
|
||||
name = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = weechat_hdata_get_var_type_string (script_str2ptr (hdata), name);
|
||||
|
||||
LUA_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_hdata_get_list: get list pointer in hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_hdata_get_list (lua_State *L)
|
||||
{
|
||||
const char *hdata, *name;
|
||||
char *result;
|
||||
int n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hdata_get_list");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hdata_get_list");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = lua_tostring (lua_current_interpreter, -2);
|
||||
name = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_get_list (script_str2ptr (hdata),
|
||||
name));
|
||||
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_hdata_move: move pointer to another element in list
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_hdata_move (lua_State *L)
|
||||
{
|
||||
const char *hdata, *pointer;
|
||||
char *result;
|
||||
int count, n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hdata_move");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hdata_move");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = lua_tostring (lua_current_interpreter, -3);
|
||||
pointer = lua_tostring (lua_current_interpreter, -2);
|
||||
count = lua_tonumber (lua_current_interpreter, -1);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_move (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
count));
|
||||
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_hdata_integer: get integer value of a variable in structure
|
||||
* using hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_hdata_integer (lua_State *L)
|
||||
{
|
||||
const char *hdata, *pointer, *name;
|
||||
int n, value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hdata_integer");
|
||||
LUA_RETURN_INT(0);
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hdata_integer");
|
||||
LUA_RETURN_INT(0);
|
||||
}
|
||||
|
||||
hdata = lua_tostring (lua_current_interpreter, -3);
|
||||
pointer = lua_tostring (lua_current_interpreter, -2);
|
||||
name = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
value = weechat_hdata_integer (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
|
||||
LUA_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_hdata_long: get long value of a variable in structure using
|
||||
* hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_hdata_long (lua_State *L)
|
||||
{
|
||||
const char *hdata, *pointer, *name;
|
||||
long value;
|
||||
int n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hdata_long");
|
||||
LUA_RETURN_LONG(0);
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hdata_long");
|
||||
LUA_RETURN_LONG(0);
|
||||
}
|
||||
|
||||
hdata = lua_tostring (lua_current_interpreter, -3);
|
||||
pointer = lua_tostring (lua_current_interpreter, -2);
|
||||
name = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
value = weechat_hdata_long (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
|
||||
LUA_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_hdata_string: get string value of a variable in structure
|
||||
* using hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_hdata_string (lua_State *L)
|
||||
{
|
||||
const char *hdata, *pointer, *name, *result;
|
||||
int n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hdata_string");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hdata_string");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = lua_tostring (lua_current_interpreter, -3);
|
||||
pointer = lua_tostring (lua_current_interpreter, -2);
|
||||
name = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = weechat_hdata_string (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
|
||||
LUA_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_hdata_pointer: get pointer value of a variable in structure
|
||||
* using hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_hdata_pointer (lua_State *L)
|
||||
{
|
||||
const char *hdata, *pointer, *name;
|
||||
char *result;
|
||||
int n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hdata_pointer");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hdata_pointer");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = lua_tostring (lua_current_interpreter, -3);
|
||||
pointer = lua_tostring (lua_current_interpreter, -2);
|
||||
name = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_pointer (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name));
|
||||
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_hdata_time: get time value of a variable in structure using
|
||||
* hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_hdata_time (lua_State *L)
|
||||
{
|
||||
const char *hdata, *pointer, *name;
|
||||
time_t time;
|
||||
char timebuffer[64], *result;
|
||||
int n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hdata_time");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hdata_time");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = lua_tostring (lua_current_interpreter, -3);
|
||||
pointer = lua_tostring (lua_current_interpreter, -2);
|
||||
name = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
time = weechat_hdata_time (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
result = strdup (timebuffer);
|
||||
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_hdata_get_string: get hdata property as string
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_hdata_get_string (lua_State *L)
|
||||
{
|
||||
const char *hdata, *property, *result;
|
||||
int n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hdata_get_string");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hdata_get_string");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = lua_tostring (lua_current_interpreter, -2);
|
||||
property = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = weechat_hdata_get_string (script_str2ptr (hdata), property);
|
||||
|
||||
LUA_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_upgrade_new: create an upgrade file
|
||||
*/
|
||||
|
||||
static int
|
||||
@@ -7931,6 +8317,16 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
|
||||
{ "infolist_pointer", &weechat_lua_api_infolist_pointer },
|
||||
{ "infolist_time", &weechat_lua_api_infolist_time },
|
||||
{ "infolist_free", &weechat_lua_api_infolist_free },
|
||||
{ "hdata_get", &weechat_lua_api_hdata_get },
|
||||
{ "hdata_get_var_type_string", &weechat_lua_api_hdata_get_var_type_string },
|
||||
{ "hdata_get_list", &weechat_lua_api_hdata_get_list },
|
||||
{ "hdata_move", &weechat_lua_api_hdata_move },
|
||||
{ "hdata_integer", &weechat_lua_api_hdata_integer },
|
||||
{ "hdata_long", &weechat_lua_api_hdata_long },
|
||||
{ "hdata_string", &weechat_lua_api_hdata_string },
|
||||
{ "hdata_pointer", &weechat_lua_api_hdata_pointer },
|
||||
{ "hdata_time", &weechat_lua_api_hdata_time },
|
||||
{ "hdata_get_string", &weechat_lua_api_hdata_get_string },
|
||||
{ "upgrade_new", &weechat_lua_api_upgrade_new },
|
||||
{ "upgrade_write_object", &weechat_lua_api_upgrade_write_object },
|
||||
{ "upgrade_read", &weechat_lua_api_upgrade_read },
|
||||
|
||||
@@ -39,29 +39,32 @@
|
||||
#define PERL_RETURN_OK XSRETURN_YES
|
||||
#define PERL_RETURN_ERROR XSRETURN_NO
|
||||
#define PERL_RETURN_EMPTY XSRETURN_EMPTY
|
||||
#define PERL_RETURN_STRING(__string) \
|
||||
if (__string) \
|
||||
{ \
|
||||
XST_mPV (0, __string); \
|
||||
XSRETURN (1); \
|
||||
} \
|
||||
XST_mPV (0, ""); \
|
||||
#define PERL_RETURN_STRING(__string) \
|
||||
if (__string) \
|
||||
{ \
|
||||
XST_mPV (0, __string); \
|
||||
XSRETURN (1); \
|
||||
} \
|
||||
XST_mPV (0, ""); \
|
||||
XSRETURN (1)
|
||||
#define PERL_RETURN_STRING_FREE(__string) \
|
||||
if (__string) \
|
||||
{ \
|
||||
XST_mPV (0, __string); \
|
||||
free (__string); \
|
||||
XSRETURN (1); \
|
||||
} \
|
||||
XST_mPV (0, ""); \
|
||||
#define PERL_RETURN_STRING_FREE(__string) \
|
||||
if (__string) \
|
||||
{ \
|
||||
XST_mPV (0, __string); \
|
||||
free (__string); \
|
||||
XSRETURN (1); \
|
||||
} \
|
||||
XST_mPV (0, ""); \
|
||||
XSRETURN (1)
|
||||
#define PERL_RETURN_INT(__int) \
|
||||
XST_mIV (0, __int); \
|
||||
#define PERL_RETURN_INT(__int) \
|
||||
XST_mIV (0, __int); \
|
||||
XSRETURN (1);
|
||||
#define PERL_RETURN_OBJ(__obj) \
|
||||
ST (0) = newRV_inc((SV *)__obj); \
|
||||
if (SvREFCNT(ST(0))) sv_2mortal(ST(0)); \
|
||||
#define PERL_RETURN_LONG(__long) \
|
||||
XST_mIV (0, __long); \
|
||||
XSRETURN (1);
|
||||
#define PERL_RETURN_OBJ(__obj) \
|
||||
ST (0) = newRV_inc((SV *)__obj); \
|
||||
if (SvREFCNT(ST(0))) sv_2mortal(ST(0)); \
|
||||
XSRETURN (1);
|
||||
|
||||
|
||||
@@ -6501,6 +6504,358 @@ XS (XS_weechat_api_infolist_free)
|
||||
PERL_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::hdata_get: get hdata
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_hdata_get)
|
||||
{
|
||||
char *result, *name;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hdata_get");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hdata_get");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
name = SvPV (ST (0), PL_na);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_get (name));
|
||||
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::hdata_get_var_type_string: get type of variable as string in hdata
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_hdata_get_var_type_string)
|
||||
{
|
||||
const char *result;
|
||||
char *hdata, *name;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hdata_get_var_type_string");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hdata_get_var_type_string");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = SvPV (ST (0), PL_na);
|
||||
name = SvPV (ST (1), PL_na);
|
||||
|
||||
result = weechat_hdata_get_var_type_string (script_str2ptr (hdata), name);
|
||||
|
||||
PERL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::hdata_get_list: get list pointer in hdata
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_hdata_get_list)
|
||||
{
|
||||
char *hdata, *name;
|
||||
char *result;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hdata_get_list");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hdata_get_list");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = SvPV (ST (0), PL_na);
|
||||
name = SvPV (ST (1), PL_na);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_get_list (script_str2ptr (hdata),
|
||||
name));
|
||||
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::hdata_move: move pointer to another element in list
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_hdata_move)
|
||||
{
|
||||
char *result, *hdata, *pointer;
|
||||
int count;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hdata_move");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hdata_move");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = SvPV (ST (0), PL_na);
|
||||
pointer = SvPV (ST (1), PL_na);
|
||||
count = SvIV(ST (2));
|
||||
|
||||
result = script_ptr2str (weechat_hdata_move (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
count));
|
||||
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::hdata_integer: get integer value of a variable in structure using
|
||||
* hdata
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_hdata_integer)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
int value;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hdata_integer");
|
||||
PERL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hdata_integer");
|
||||
PERL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
hdata = SvPV (ST (0), PL_na);
|
||||
pointer = SvPV (ST (1), PL_na);
|
||||
name = SvPV (ST (2), PL_na);
|
||||
|
||||
value = weechat_hdata_integer (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
|
||||
PERL_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::hdata_long: get long value of a variable in structure using hdata
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_hdata_long)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
long value;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hdata_long");
|
||||
PERL_RETURN_LONG(0);
|
||||
}
|
||||
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hdata_long");
|
||||
PERL_RETURN_LONG(0);
|
||||
}
|
||||
|
||||
hdata = SvPV (ST (0), PL_na);
|
||||
pointer = SvPV (ST (1), PL_na);
|
||||
name = SvPV (ST (2), PL_na);
|
||||
|
||||
value = weechat_hdata_long (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
|
||||
PERL_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::hdata_string: get string value of a variable in structure using
|
||||
* hdata
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_hdata_string)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
const char *result;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hdata_string");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hdata_string");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = SvPV (ST (0), PL_na);
|
||||
pointer = SvPV (ST (1), PL_na);
|
||||
name = SvPV (ST (2), PL_na);
|
||||
|
||||
result = weechat_hdata_string (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
|
||||
PERL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::hdata_pointer: get pointer value of a variable in structure using
|
||||
* hdata
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_hdata_pointer)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
char *result;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hdata_pointer");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hdata_pointer");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = SvPV (ST (0), PL_na);
|
||||
pointer = SvPV (ST (1), PL_na);
|
||||
name = SvPV (ST (2), PL_na);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_pointer (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name));
|
||||
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::hdata_time: get time value of a variable in structure using hdata
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_hdata_time)
|
||||
{
|
||||
time_t time;
|
||||
char timebuffer[64], *result, *hdata, *pointer, *name;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hdata_time");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hdata_time");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = SvPV (ST (0), PL_na);
|
||||
pointer = SvPV (ST (1), PL_na);
|
||||
name = SvPV (ST (2), PL_na);
|
||||
|
||||
time = weechat_hdata_time (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
result = strdup (timebuffer);
|
||||
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::hdata_get_string: get hdata property as string
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_hdata_get_string)
|
||||
{
|
||||
char *hdata, *property;
|
||||
const char *result;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hdata_get_string");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hdata_get_string");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = SvPV (ST (0), PL_na);
|
||||
property = SvPV (ST (1), PL_na);
|
||||
|
||||
result = weechat_hdata_get_string (script_str2ptr (hdata), property);
|
||||
|
||||
PERL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::upgrade_new: create an upgrade file
|
||||
*/
|
||||
@@ -6857,6 +7212,16 @@ weechat_perl_api_init (pTHX)
|
||||
newXS ("weechat::infolist_pointer", XS_weechat_api_infolist_pointer, "weechat");
|
||||
newXS ("weechat::infolist_time", XS_weechat_api_infolist_time, "weechat");
|
||||
newXS ("weechat::infolist_free", XS_weechat_api_infolist_free, "weechat");
|
||||
newXS ("weechat::hdata_get", XS_weechat_api_hdata_get, "weechat");
|
||||
newXS ("weechat::hdata_get_var_type_string", XS_weechat_api_hdata_get_var_type_string, "weechat");
|
||||
newXS ("weechat::hdata_get_list", XS_weechat_api_hdata_get_list, "weechat");
|
||||
newXS ("weechat::hdata_move", XS_weechat_api_hdata_move, "weechat");
|
||||
newXS ("weechat::hdata_integer", XS_weechat_api_hdata_integer, "weechat");
|
||||
newXS ("weechat::hdata_long", XS_weechat_api_hdata_long, "weechat");
|
||||
newXS ("weechat::hdata_string", XS_weechat_api_hdata_string, "weechat");
|
||||
newXS ("weechat::hdata_pointer", XS_weechat_api_hdata_pointer, "weechat");
|
||||
newXS ("weechat::hdata_time", XS_weechat_api_hdata_time, "weechat");
|
||||
newXS ("weechat::hdata_get_string", XS_weechat_api_hdata_get_string, "weechat");
|
||||
newXS ("weechat::upgrade_new", XS_weechat_api_upgrade_new, "weechat");
|
||||
newXS ("weechat::upgrade_write_object", XS_weechat_api_upgrade_write_object, "weechat");
|
||||
newXS ("weechat::upgrade_read", XS_weechat_api_upgrade_read, "weechat");
|
||||
|
||||
@@ -36,23 +36,25 @@
|
||||
|
||||
#define PYTHON_RETURN_OK return Py_BuildValue ("i", 1);
|
||||
#define PYTHON_RETURN_ERROR return Py_BuildValue ("i", 0);
|
||||
#define PYTHON_RETURN_EMPTY \
|
||||
Py_INCREF(Py_None); \
|
||||
#define PYTHON_RETURN_EMPTY \
|
||||
Py_INCREF(Py_None); \
|
||||
return Py_None;
|
||||
#define PYTHON_RETURN_STRING(__string) \
|
||||
if (__string) \
|
||||
return Py_BuildValue ("s", __string); \
|
||||
#define PYTHON_RETURN_STRING(__string) \
|
||||
if (__string) \
|
||||
return Py_BuildValue ("s", __string); \
|
||||
return Py_BuildValue ("s", "")
|
||||
#define PYTHON_RETURN_STRING_FREE(__string) \
|
||||
if (__string) \
|
||||
{ \
|
||||
object = Py_BuildValue ("s", __string); \
|
||||
free (__string); \
|
||||
return object; \
|
||||
} \
|
||||
#define PYTHON_RETURN_STRING_FREE(__string) \
|
||||
if (__string) \
|
||||
{ \
|
||||
object = Py_BuildValue ("s", __string); \
|
||||
free (__string); \
|
||||
return object; \
|
||||
} \
|
||||
return Py_BuildValue ("s", "")
|
||||
#define PYTHON_RETURN_INT(__int) \
|
||||
#define PYTHON_RETURN_INT(__int) \
|
||||
return Py_BuildValue("i", __int);
|
||||
#define PYTHON_RETURN_LONG(__long) \
|
||||
return Py_BuildValue("l", __long);
|
||||
|
||||
|
||||
/*
|
||||
@@ -6841,6 +6843,364 @@ weechat_python_api_infolist_free (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_hdata_get: get hdata
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hdata_get (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *name, *result;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script || !python_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hdata_get");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
name = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hdata_get");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str (weechat_hdata_get (name));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_hdata_get_var_type_string: get type of variable as string
|
||||
* in hdata
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hdata_get_var_type_string (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *hdata, *name;
|
||||
const char *result;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script || !python_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hdata_get_var_type_string");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = NULL;
|
||||
name = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ss", &hdata, &name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hdata_get_var_type_string");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = weechat_hdata_get_var_type_string (script_str2ptr (hdata), name);
|
||||
|
||||
PYTHON_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_hdata_get_list: get list pointer in hdata
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hdata_get_list (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *hdata, *name, *result;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script || !python_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hdata_get_list");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = NULL;
|
||||
name = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ss", &hdata, &name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hdata_get_list");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str (weechat_hdata_get_list (script_str2ptr (hdata),
|
||||
name));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_hdata_move: move pointer to another element in list
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hdata_move (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *result, *hdata, *pointer;
|
||||
int count;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script || !python_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hdata_move");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = NULL;
|
||||
pointer = NULL;
|
||||
count = 0;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ssi", &hdata, &pointer, &count))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hdata_move");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str (weechat_hdata_move (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
count));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_hdata_integer: get integer value of a variable in
|
||||
* structure using hdata
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hdata_integer (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
int value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script || !python_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hdata_integer");
|
||||
PYTHON_RETURN_INT(0);
|
||||
}
|
||||
|
||||
hdata = NULL;
|
||||
pointer = NULL;
|
||||
name = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "sss", &hdata, &pointer, &name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hdata_integer");
|
||||
PYTHON_RETURN_INT(0);
|
||||
}
|
||||
|
||||
value = weechat_hdata_integer (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
|
||||
PYTHON_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_hdata_long: get long value of a variable in structure
|
||||
* using hdata
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hdata_long (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
long value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script || !python_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hdata_long");
|
||||
PYTHON_RETURN_LONG(0);
|
||||
}
|
||||
|
||||
hdata = NULL;
|
||||
pointer = NULL;
|
||||
name = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "sss", &hdata, &pointer, &name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hdata_long");
|
||||
PYTHON_RETURN_LONG(0);
|
||||
}
|
||||
|
||||
value = weechat_hdata_long (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
|
||||
PYTHON_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_hdata_string: get string value of a variable in structure
|
||||
* using hdata
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hdata_string (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
const char *result;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script || !python_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hdata_string");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = NULL;
|
||||
pointer = NULL;
|
||||
name = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "sss", &hdata, &pointer, &name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hdata_string");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = weechat_hdata_string (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
|
||||
PYTHON_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_hdata_pointer: get pointer value of a variable in
|
||||
* structure using hdata
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hdata_pointer (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *hdata, *pointer, *name, *result;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script || !python_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hdata_pointer");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = NULL;
|
||||
pointer = NULL;
|
||||
name = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "sss", &hdata, &pointer, &name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hdata_pointer");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str (weechat_hdata_pointer (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_hdata_time: get time value of a variable in structure
|
||||
* using hdata
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hdata_time (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *hdata, *pointer, *name, timebuffer[64], *result;
|
||||
time_t time;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script || !python_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hdata_time");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = NULL;
|
||||
pointer = NULL;
|
||||
name = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "sss", &hdata, &pointer, &name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hdata_time");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
time = weechat_hdata_time (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
result = strdup (timebuffer);
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_hdata_get_string: get hdata property as string
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hdata_get_string (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *hdata, *property;
|
||||
const char *result;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script || !python_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hdata_get_string");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = NULL;
|
||||
property = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ss", &hdata, &property))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hdata_get_string");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = weechat_hdata_get_string (script_str2ptr (hdata), property);
|
||||
|
||||
PYTHON_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_upgrade_new: create an upgrade file
|
||||
*/
|
||||
@@ -7194,6 +7554,16 @@ PyMethodDef weechat_python_funcs[] =
|
||||
{ "infolist_pointer", &weechat_python_api_infolist_pointer, METH_VARARGS, "" },
|
||||
{ "infolist_time", &weechat_python_api_infolist_time, METH_VARARGS, "" },
|
||||
{ "infolist_free", &weechat_python_api_infolist_free, METH_VARARGS, "" },
|
||||
{ "hdata_get", &weechat_python_api_hdata_get, METH_VARARGS, "" },
|
||||
{ "hdata_get_var_type_string", &weechat_python_api_hdata_get_var_type_string, METH_VARARGS, "" },
|
||||
{ "hdata_get_list", &weechat_python_api_hdata_get_list, METH_VARARGS, "" },
|
||||
{ "hdata_move", &weechat_python_api_hdata_move, METH_VARARGS, "" },
|
||||
{ "hdata_integer", &weechat_python_api_hdata_integer, METH_VARARGS, "" },
|
||||
{ "hdata_long", &weechat_python_api_hdata_long, METH_VARARGS, "" },
|
||||
{ "hdata_string", &weechat_python_api_hdata_string, METH_VARARGS, "" },
|
||||
{ "hdata_pointer", &weechat_python_api_hdata_pointer, METH_VARARGS, "" },
|
||||
{ "hdata_time", &weechat_python_api_hdata_time, METH_VARARGS, "" },
|
||||
{ "hdata_get_string", &weechat_python_api_hdata_get_string, METH_VARARGS, "" },
|
||||
{ "upgrade_new", &weechat_python_api_upgrade_new, METH_VARARGS, "" },
|
||||
{ "upgrade_write_object", &weechat_python_api_upgrade_write_object, METH_VARARGS, "" },
|
||||
{ "upgrade_read", &weechat_python_api_upgrade_read, METH_VARARGS, "" },
|
||||
|
||||
@@ -36,20 +36,22 @@
|
||||
#define RUBY_RETURN_OK return INT2FIX (1);
|
||||
#define RUBY_RETURN_ERROR return INT2FIX (0);
|
||||
#define RUBY_RETURN_EMPTY return Qnil;
|
||||
#define RUBY_RETURN_STRING(__string) \
|
||||
if (__string) \
|
||||
return rb_str_new2 (__string); \
|
||||
#define RUBY_RETURN_STRING(__string) \
|
||||
if (__string) \
|
||||
return rb_str_new2 (__string); \
|
||||
return rb_str_new2 ("")
|
||||
#define RUBY_RETURN_STRING_FREE(__string) \
|
||||
if (__string) \
|
||||
{ \
|
||||
return_value = rb_str_new2 (__string); \
|
||||
free (__string); \
|
||||
return return_value; \
|
||||
} \
|
||||
#define RUBY_RETURN_STRING_FREE(__string) \
|
||||
if (__string) \
|
||||
{ \
|
||||
return_value = rb_str_new2 (__string); \
|
||||
free (__string); \
|
||||
return return_value; \
|
||||
} \
|
||||
return rb_str_new2 ("")
|
||||
#define RUBY_RETURN_INT(__int) \
|
||||
#define RUBY_RETURN_INT(__int) \
|
||||
return INT2FIX(__int);
|
||||
#define RUBY_RETURN_LONG(__long) \
|
||||
return LONG2FIX(__long);
|
||||
|
||||
|
||||
/*
|
||||
@@ -7454,6 +7456,407 @@ weechat_ruby_api_infolist_free (VALUE class, VALUE infolist)
|
||||
RUBY_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hdata_get: get hdata
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_get (VALUE class, VALUE name)
|
||||
{
|
||||
char *c_name, *result;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hdata_get");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (NIL_P (name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hdata_get");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (name, T_STRING);
|
||||
|
||||
c_name = StringValuePtr (name);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_get (c_name));
|
||||
|
||||
RUBY_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hdata_get_var_type_string: get type of variable as string
|
||||
* in hdata
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_get_var_type_string (VALUE class, VALUE hdata,
|
||||
VALUE name)
|
||||
{
|
||||
char *c_hdata, *c_name;
|
||||
const char *result;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hdata_get_var_type_string");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (NIL_P (hdata) || NIL_P (name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hdata_get_var_type_string");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (hdata, T_STRING);
|
||||
Check_Type (name, T_STRING);
|
||||
|
||||
c_hdata = StringValuePtr (hdata);
|
||||
c_name = StringValuePtr (name);
|
||||
|
||||
result = weechat_hdata_get_var_type_string (script_str2ptr (c_hdata), c_name);
|
||||
|
||||
RUBY_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hdata_get_list: get list pointer in hdata
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_get_list (VALUE class, VALUE hdata, VALUE name)
|
||||
{
|
||||
char *c_hdata, *c_name, *result;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hdata_get_list");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (NIL_P (hdata) || NIL_P (name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hdata_get_list");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (hdata, T_STRING);
|
||||
Check_Type (name, T_STRING);
|
||||
|
||||
c_hdata = StringValuePtr (hdata);
|
||||
c_name = StringValuePtr (name);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_get_list (script_str2ptr (c_hdata),
|
||||
c_name));
|
||||
|
||||
RUBY_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hdata_move: move pointer to another element in list
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_move (VALUE class, VALUE hdata, VALUE pointer,
|
||||
VALUE count)
|
||||
{
|
||||
char *c_hdata, *c_pointer, *result;
|
||||
int c_count;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hdata_move");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (count))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hdata_move");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (hdata, T_STRING);
|
||||
Check_Type (pointer, T_STRING);
|
||||
Check_Type (count, T_FIXNUM);
|
||||
|
||||
c_hdata = StringValuePtr (hdata);
|
||||
c_pointer = StringValuePtr (pointer);
|
||||
c_count = FIX2INT (count);
|
||||
|
||||
result = weechat_hdata_move (script_str2ptr (c_hdata),
|
||||
script_str2ptr (c_pointer),
|
||||
c_count);
|
||||
|
||||
RUBY_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hdata_integer: get integer value of a variable in structure
|
||||
* using hdata
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_integer (VALUE class, VALUE hdata, VALUE pointer,
|
||||
VALUE name)
|
||||
{
|
||||
char *c_hdata, *c_pointer, *c_name;
|
||||
int value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hdata_integer");
|
||||
RUBY_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hdata_integer");
|
||||
RUBY_RETURN_INT(0);
|
||||
}
|
||||
|
||||
Check_Type (hdata, T_STRING);
|
||||
Check_Type (pointer, T_STRING);
|
||||
Check_Type (name, T_STRING);
|
||||
|
||||
c_hdata = StringValuePtr (hdata);
|
||||
c_pointer = StringValuePtr (pointer);
|
||||
c_name = StringValuePtr (name);
|
||||
|
||||
value = weechat_hdata_integer (script_str2ptr (c_hdata),
|
||||
script_str2ptr (c_pointer),
|
||||
c_name);
|
||||
|
||||
RUBY_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hdata_long: get long value of a variable in structure using
|
||||
* hdata
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_long (VALUE class, VALUE hdata, VALUE pointer,
|
||||
VALUE name)
|
||||
{
|
||||
char *c_hdata, *c_pointer, *c_name;
|
||||
long value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hdata_long");
|
||||
RUBY_RETURN_LONG(0);
|
||||
}
|
||||
|
||||
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hdata_long");
|
||||
RUBY_RETURN_LONG(0);
|
||||
}
|
||||
|
||||
Check_Type (hdata, T_STRING);
|
||||
Check_Type (pointer, T_STRING);
|
||||
Check_Type (name, T_STRING);
|
||||
|
||||
c_hdata = StringValuePtr (hdata);
|
||||
c_pointer = StringValuePtr (pointer);
|
||||
c_name = StringValuePtr (name);
|
||||
|
||||
value = weechat_hdata_long (script_str2ptr (c_hdata),
|
||||
script_str2ptr (c_pointer),
|
||||
c_name);
|
||||
|
||||
RUBY_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hdata_string: get string value of a variable in structure
|
||||
* using hdata
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_string (VALUE class, VALUE hdata, VALUE pointer,
|
||||
VALUE name)
|
||||
{
|
||||
char *c_hdata, *c_pointer, *c_name;
|
||||
const char *result;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hdata_string");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hdata_string");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (hdata, T_STRING);
|
||||
Check_Type (pointer, T_STRING);
|
||||
Check_Type (name, T_STRING);
|
||||
|
||||
c_hdata = StringValuePtr (hdata);
|
||||
c_pointer = StringValuePtr (pointer);
|
||||
c_name = StringValuePtr (name);
|
||||
|
||||
result = weechat_hdata_string (script_str2ptr (c_hdata),
|
||||
script_str2ptr (c_pointer),
|
||||
c_name);
|
||||
|
||||
RUBY_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hdata_pointer: get pointer value of a variable in structure
|
||||
* using hdata
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_pointer (VALUE class, VALUE hdata, VALUE pointer,
|
||||
VALUE name)
|
||||
{
|
||||
char *c_hdata, *c_pointer, *c_name, *result;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hdata_pointer");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hdata_pointer");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (hdata, T_STRING);
|
||||
Check_Type (pointer, T_STRING);
|
||||
Check_Type (name, T_STRING);
|
||||
|
||||
c_hdata = StringValuePtr (hdata);
|
||||
c_pointer = StringValuePtr (pointer);
|
||||
c_name = StringValuePtr (name);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_pointer (script_str2ptr (c_hdata),
|
||||
script_str2ptr (c_pointer),
|
||||
c_name));
|
||||
|
||||
RUBY_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hdata_time: get time value of a variable in structure using
|
||||
* hdata
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer,
|
||||
VALUE name)
|
||||
{
|
||||
char *c_hdata, *c_pointer, *c_name, timebuffer[64], *result;
|
||||
time_t time;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hdata_time");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (name))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hdata_time");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (hdata, T_STRING);
|
||||
Check_Type (pointer, T_STRING);
|
||||
Check_Type (name, T_STRING);
|
||||
|
||||
c_hdata = StringValuePtr (hdata);
|
||||
c_pointer = StringValuePtr (pointer);
|
||||
c_name = StringValuePtr (name);
|
||||
|
||||
time = weechat_hdata_time (script_str2ptr (c_hdata),
|
||||
script_str2ptr (c_pointer),
|
||||
c_name);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
result = strdup (timebuffer);
|
||||
|
||||
RUBY_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hdata_get_string: get hdata property as string
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_get_string (VALUE class, VALUE hdata, VALUE property)
|
||||
{
|
||||
char *c_hdata, *c_property;
|
||||
const char *result;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hdata_get_string");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (NIL_P (hdata) || NIL_P (property))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hdata_get_string");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (hdata, T_STRING);
|
||||
Check_Type (property, T_STRING);
|
||||
|
||||
c_hdata = StringValuePtr (hdata);
|
||||
c_property = StringValuePtr (property);
|
||||
|
||||
result = weechat_hdata_get_var_type_string (script_str2ptr (c_hdata),
|
||||
c_property);
|
||||
|
||||
RUBY_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_upgrade_new: create an upgrade file
|
||||
*/
|
||||
@@ -7869,6 +8272,16 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "infolist_pointer", &weechat_ruby_api_infolist_pointer, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "infolist_time", &weechat_ruby_api_infolist_time, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "infolist_free", &weechat_ruby_api_infolist_free, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "hdata_get", &weechat_ruby_api_hdata_get, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "hdata_get_var_type_string", &weechat_ruby_api_hdata_get_var_type_string, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "hdata_get_list", &weechat_ruby_api_hdata_get_list, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "hdata_move", &weechat_ruby_api_hdata_move, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "hdata_integer", &weechat_ruby_api_hdata_integer, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "hdata_long", &weechat_ruby_api_hdata_long, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "hdata_string", &weechat_ruby_api_hdata_string, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "hdata_pointer", &weechat_ruby_api_hdata_pointer, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "hdata_time", &weechat_ruby_api_hdata_time, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "hdata_get_string", &weechat_ruby_api_hdata_get_string, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "upgrade_new", &weechat_ruby_api_upgrade_new, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "upgrade_write_object", &weechat_ruby_api_upgrade_write_object, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "upgrade_read", &weechat_ruby_api_upgrade_read, 3);
|
||||
|
||||
@@ -36,130 +36,145 @@
|
||||
#include "../script-callback.h"
|
||||
#include "weechat-tcl.h"
|
||||
|
||||
#define TCL_RETURN_OK \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
Tcl_SetIntObj (objp, 1); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
Tcl_SetIntObj (objp, 1); \
|
||||
return TCL_OK; \
|
||||
#define TCL_RETURN_OK \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
Tcl_SetIntObj (objp, 1); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
Tcl_SetIntObj (objp, 1); \
|
||||
return TCL_OK; \
|
||||
}
|
||||
#define TCL_RETURN_ERROR \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
Tcl_SetIntObj (objp, 0); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
Tcl_SetIntObj (objp, 0); \
|
||||
return TCL_ERROR; \
|
||||
#define TCL_RETURN_ERROR \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
Tcl_SetIntObj (objp, 0); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
Tcl_SetIntObj (objp, 0); \
|
||||
return TCL_ERROR; \
|
||||
}
|
||||
#define TCL_RETURN_EMPTY \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
Tcl_SetStringObj (objp, "", -1); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
Tcl_SetStringObj (objp, "", -1); \
|
||||
return TCL_OK; \
|
||||
#define TCL_RETURN_EMPTY \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
Tcl_SetStringObj (objp, "", -1); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
Tcl_SetStringObj (objp, "", -1); \
|
||||
return TCL_OK; \
|
||||
}
|
||||
#define TCL_RETURN_STRING(__string) \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
if (__string) \
|
||||
{ \
|
||||
Tcl_SetStringObj (objp, __string, -1); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
return TCL_OK; \
|
||||
} \
|
||||
Tcl_SetStringObj (objp, "", -1); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
if (__string) \
|
||||
{ \
|
||||
Tcl_SetStringObj (objp, __string, -1); \
|
||||
return TCL_OK; \
|
||||
} \
|
||||
Tcl_SetStringObj (objp, "", -1); \
|
||||
} \
|
||||
return TCL_OK; \
|
||||
#define TCL_RETURN_STRING(__string) \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
if (__string) \
|
||||
{ \
|
||||
Tcl_SetStringObj (objp, __string, -1); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
return TCL_OK; \
|
||||
} \
|
||||
Tcl_SetStringObj (objp, "", -1); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
if (__string) \
|
||||
{ \
|
||||
Tcl_SetStringObj (objp, __string, -1); \
|
||||
return TCL_OK; \
|
||||
} \
|
||||
Tcl_SetStringObj (objp, "", -1); \
|
||||
} \
|
||||
return TCL_OK; \
|
||||
}
|
||||
#define TCL_RETURN_STRING_FREE(__string) \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
if (__string) \
|
||||
{ \
|
||||
Tcl_SetStringObj (objp, __string, -1); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
free (__string); \
|
||||
return TCL_OK; \
|
||||
} \
|
||||
Tcl_SetStringObj (objp, "", -1); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
if (__string) \
|
||||
{ \
|
||||
Tcl_SetStringObj (objp, __string, -1); \
|
||||
free (__string); \
|
||||
return TCL_OK; \
|
||||
} \
|
||||
Tcl_SetStringObj (objp, "", -1); \
|
||||
} \
|
||||
return TCL_OK; \
|
||||
#define TCL_RETURN_STRING_FREE(__string) \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
if (__string) \
|
||||
{ \
|
||||
Tcl_SetStringObj (objp, __string, -1); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
free (__string); \
|
||||
return TCL_OK; \
|
||||
} \
|
||||
Tcl_SetStringObj (objp, "", -1); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
if (__string) \
|
||||
{ \
|
||||
Tcl_SetStringObj (objp, __string, -1); \
|
||||
free (__string); \
|
||||
return TCL_OK; \
|
||||
} \
|
||||
Tcl_SetStringObj (objp, "", -1); \
|
||||
} \
|
||||
return TCL_OK; \
|
||||
}
|
||||
#define TCL_RETURN_INT(__int) \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
Tcl_SetIntObj (objp, __int); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
Tcl_SetIntObj (objp, __int); \
|
||||
return TCL_OK; \
|
||||
#define TCL_RETURN_INT(__int) \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
Tcl_SetIntObj (objp, __int); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
Tcl_SetIntObj (objp, __int); \
|
||||
return TCL_OK; \
|
||||
}
|
||||
#define TCL_RETURN_OBJ(__obj) \
|
||||
{ \
|
||||
Tcl_SetObjResult (interp, __obj); \
|
||||
return TCL_OK; \
|
||||
#define TCL_RETURN_LONG(__long) \
|
||||
{ \
|
||||
objp = Tcl_GetObjResult (interp); \
|
||||
if (Tcl_IsShared (objp)) \
|
||||
{ \
|
||||
objp = Tcl_DuplicateObj (objp); \
|
||||
Tcl_IncrRefCount (objp); \
|
||||
Tcl_SetLongObj (objp, __long); \
|
||||
Tcl_SetObjResult (interp, objp); \
|
||||
Tcl_DecrRefCount (objp); \
|
||||
} \
|
||||
else \
|
||||
Tcl_SetLongObj (objp, __long); \
|
||||
return TCL_OK; \
|
||||
}
|
||||
#define TCL_RETURN_OBJ(__obj) \
|
||||
{ \
|
||||
Tcl_SetObjResult (interp, __obj); \
|
||||
return TCL_OK; \
|
||||
}
|
||||
|
||||
|
||||
@@ -7234,6 +7249,393 @@ weechat_tcl_api_infolist_free (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hdata_get: get hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hdata_get (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *result, *name;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hdata_get");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hdata_get");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
name = Tcl_GetStringFromObj (objv[1], &i);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_get (name));
|
||||
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hdata_get_var_type_string: get type of variable as string in
|
||||
* hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hdata_get_var_type_string (ClientData clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *hdata, *name;
|
||||
const char *result;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hdata_get_var_type_string");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hdata_get_var_type_string");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = Tcl_GetStringFromObj (objv[1], &i);
|
||||
name = Tcl_GetStringFromObj (objv[2], &i);
|
||||
|
||||
result = weechat_hdata_get_var_type_string (script_str2ptr (hdata), name);
|
||||
|
||||
TCL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hdata_get_list: get list pointer in hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hdata_get_list (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *hdata, *name, *result;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hdata_get_list");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hdata_get_list");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = Tcl_GetStringFromObj (objv[1], &i);
|
||||
name = Tcl_GetStringFromObj (objv[2], &i);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_get_list (script_str2ptr (hdata),
|
||||
name));
|
||||
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hdata_move: move pointer to another element in list
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hdata_move (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *hdata, *pointer, *result;
|
||||
int i, count;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hdata_move");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 4)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hdata_move");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = Tcl_GetStringFromObj (objv[1], &i);
|
||||
pointer = Tcl_GetStringFromObj (objv[2], &i);
|
||||
|
||||
if (Tcl_GetIntFromObj (interp, objv[3], &count) != TCL_OK)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hdata_move");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str (weechat_hdata_move (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
count));
|
||||
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hdata_integer: get integer value of a variable in structure
|
||||
* using hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hdata_integer (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *hdata, *pointer, *name;
|
||||
int result, i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hdata_integer");
|
||||
TCL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (objc < 4)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hdata_integer");
|
||||
TCL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
hdata = Tcl_GetStringFromObj (objv[1], &i);
|
||||
pointer = Tcl_GetStringFromObj (objv[2], &i);
|
||||
name = Tcl_GetStringFromObj (objv[3], &i);
|
||||
|
||||
result = weechat_hdata_integer (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
|
||||
TCL_RETURN_INT(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hdata_long: get long value of a variable in structure using
|
||||
* hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hdata_long (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *hdata, *pointer, *name;
|
||||
int result, i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hdata_long");
|
||||
TCL_RETURN_LONG(0);
|
||||
}
|
||||
|
||||
if (objc < 4)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hdata_long");
|
||||
TCL_RETURN_LONG(0);
|
||||
}
|
||||
|
||||
hdata = Tcl_GetStringFromObj (objv[1], &i);
|
||||
pointer = Tcl_GetStringFromObj (objv[2], &i);
|
||||
name = Tcl_GetStringFromObj (objv[3], &i);
|
||||
|
||||
result = weechat_hdata_long (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
|
||||
TCL_RETURN_LONG(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hdata_string: get string value of a variable in structure
|
||||
* using hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hdata_string (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *hdata, *pointer, *name;
|
||||
const char *result;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hdata_string");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 4)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hdata_string");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = Tcl_GetStringFromObj (objv[1], &i);
|
||||
pointer = Tcl_GetStringFromObj (objv[2], &i);
|
||||
name = Tcl_GetStringFromObj (objv[3], &i);
|
||||
|
||||
result = weechat_hdata_string (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
|
||||
TCL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hdata_pointer: get pointer value of a variable in structure
|
||||
* using hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hdata_pointer (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *hdata, *pointer, *name, *result;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hdata_pointer");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 4)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hdata_pointer");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = Tcl_GetStringFromObj (objv[1], &i);
|
||||
pointer = Tcl_GetStringFromObj (objv[2], &i);
|
||||
name = Tcl_GetStringFromObj (objv[3], &i);
|
||||
|
||||
result = script_ptr2str (weechat_hdata_pointer (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name));
|
||||
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hdata_time: get time value of a variable in structure using
|
||||
* hdata
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hdata_time (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
time_t time;
|
||||
char timebuffer[64], *result, *hdata, *pointer, *name;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hdata_time");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 4)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hdata_time");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = Tcl_GetStringFromObj (objv[1], &i);
|
||||
pointer = Tcl_GetStringFromObj (objv[2], &i);
|
||||
name = Tcl_GetStringFromObj (objv[3], &i);
|
||||
|
||||
time = weechat_hdata_time (script_str2ptr (hdata),
|
||||
script_str2ptr (pointer),
|
||||
name);
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
|
||||
|
||||
result = strdup (timebuffer);
|
||||
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hdata_get_string: get hdata property as string
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hdata_get_string (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *hdata, *property;
|
||||
const char *result;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hdata_get_string");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hdata_get_string");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
hdata = Tcl_GetStringFromObj (objv[1], &i);
|
||||
property = Tcl_GetStringFromObj (objv[2], &i);
|
||||
|
||||
result = weechat_hdata_get_string (script_str2ptr (hdata), property);
|
||||
|
||||
TCL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_upgrade_new: create an upgrade file
|
||||
*/
|
||||
@@ -7862,6 +8264,26 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
weechat_tcl_api_infolist_time, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::infolist_free",
|
||||
weechat_tcl_api_infolist_free, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::hdata_get",
|
||||
weechat_tcl_api_hdata_get, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::hdata_get_var_type_string",
|
||||
weechat_tcl_api_hdata_get_var_type_string, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::hdata_get_list",
|
||||
weechat_tcl_api_hdata_get_list, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::hdata_move",
|
||||
weechat_tcl_api_hdata_move, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::hdata_integer",
|
||||
weechat_tcl_api_hdata_integer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::hdata_long",
|
||||
weechat_tcl_api_hdata_long, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::hdata_string",
|
||||
weechat_tcl_api_hdata_string, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::hdata_pointer",
|
||||
weechat_tcl_api_hdata_pointer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::hdata_time",
|
||||
weechat_tcl_api_hdata_time, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::hdata_get_string",
|
||||
weechat_tcl_api_hdata_get_string, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::upgrade_new",
|
||||
weechat_tcl_api_upgrade_new, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::upgrade_write_object",
|
||||
|
||||
@@ -37,6 +37,7 @@ struct t_infolist;
|
||||
struct t_infolist_item;
|
||||
struct t_weelist;
|
||||
struct t_hashtable;
|
||||
struct t_hdata;
|
||||
struct timeval;
|
||||
|
||||
/*
|
||||
@@ -45,7 +46,7 @@ struct timeval;
|
||||
*/
|
||||
|
||||
/* API version (used to check that plugin has same API and can be loaded) */
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20110428-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20110613-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@@ -102,6 +103,14 @@ struct timeval;
|
||||
#define WEECHAT_HASHTABLE_BUFFER "buffer"
|
||||
#define WEECHAT_HASHTABLE_TIME "time"
|
||||
|
||||
/* types for hdata */
|
||||
#define WEECHAT_HDATA_OTHER 0
|
||||
#define WEECHAT_HDATA_INTEGER 1
|
||||
#define WEECHAT_HDATA_LONG 2
|
||||
#define WEECHAT_HDATA_STRING 3
|
||||
#define WEECHAT_HDATA_POINTER 4
|
||||
#define WEECHAT_HDATA_TIME 5
|
||||
|
||||
/* buffer hotlist */
|
||||
#define WEECHAT_HOTLIST_LOW "0"
|
||||
#define WEECHAT_HOTLIST_MESSAGE "1"
|
||||
@@ -569,6 +578,12 @@ struct t_weechat_plugin
|
||||
void *pointer,
|
||||
const char *arguments),
|
||||
void *callback_data);
|
||||
struct t_hook *(*hook_hdata) (struct t_weechat_plugin *plugin,
|
||||
const char *hdata_name,
|
||||
const char *description,
|
||||
struct t_hdata *(*callback)(void *data,
|
||||
const char *hdata_name),
|
||||
void *callback_data);
|
||||
void (*unhook) (struct t_hook *hook);
|
||||
void (*unhook_all) (struct t_weechat_plugin *plugin);
|
||||
|
||||
@@ -745,7 +760,39 @@ struct t_weechat_plugin
|
||||
int *size);
|
||||
time_t (*infolist_time) (struct t_infolist *infolist, const char *var);
|
||||
void (*infolist_free) (struct t_infolist *infolist);
|
||||
|
||||
|
||||
/* hdata */
|
||||
struct t_hdata *(*hdata_new) (const char *hdata_name, const char *var_prev,
|
||||
const char *var_next);
|
||||
void (*hdata_new_var) (struct t_hdata *hdata, const char *name, int offset,
|
||||
int type);
|
||||
void (*hdata_new_list) (struct t_hdata *hdata, const char *name,
|
||||
void *pointer);
|
||||
struct t_hdata *(*hdata_get) (struct t_weechat_plugin *plugin,
|
||||
const char *hdata_name);
|
||||
int (*hdata_get_var_offset) (struct t_hdata *hdata, const char *name);
|
||||
int (*hdata_get_var_type) (struct t_hdata *hdata, const char *name);
|
||||
const char *(*hdata_get_var_type_string) (struct t_hdata *hdata,
|
||||
const char *name);
|
||||
void *(*hdata_get_var) (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
void *(*hdata_get_var_at_offset) (struct t_hdata *hdata, void *pointer,
|
||||
int offset);
|
||||
void *(*hdata_get_list) (struct t_hdata *hdata, const char *name);
|
||||
void *(*hdata_move) (struct t_hdata *hdata, void *pointer, int count);
|
||||
int (*hdata_integer) (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
long (*hdata_long) (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
const char *(*hdata_string) (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
void *(*hdata_pointer) (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
time_t (*hdata_time) (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
const char *(*hdata_get_string) (struct t_hdata *hdata,
|
||||
const char *property);
|
||||
|
||||
/* upgrade */
|
||||
struct t_upgrade_file *(*upgrade_new) (const char *filename,
|
||||
int write);
|
||||
@@ -1227,6 +1274,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
__description, __pointer_description, \
|
||||
__args_description, __callback, \
|
||||
__data)
|
||||
#define weechat_hook_hdata(__hdata_name, __description, __callback, \
|
||||
__data) \
|
||||
weechat_plugin->hook_hdata(weechat_plugin, __hdata_name, \
|
||||
__description, __callback, __data)
|
||||
#define weechat_unhook(__hook) \
|
||||
weechat_plugin->unhook( __hook)
|
||||
#define weechat_unhook_all() \
|
||||
@@ -1424,6 +1475,48 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
#define weechat_infolist_free(__list) \
|
||||
weechat_plugin->infolist_free(__list)
|
||||
|
||||
/* hdata */
|
||||
#define weechat_hdata_new(__hdata_name, __var_prev, __var_next) \
|
||||
weechat_plugin->hdata_new(__hdata_name, __var_prev, __var_next)
|
||||
#define weechat_hdata_new_var(__hdata, __name, __offset, __type) \
|
||||
weechat_plugin->hdata_new_var(__hdata, __name, __offset, __type)
|
||||
#define WEECHAT_HDATA_VAR(__struct, __name, __type) \
|
||||
weechat_hdata_new_var (hdata, #__name, offsetof (__struct, __name), \
|
||||
WEECHAT_HDATA_##__type);
|
||||
#define weechat_hdata_new_list(__hdata, __name, __pointer) \
|
||||
weechat_plugin->hdata_new_list(__hdata, __name, __pointer)
|
||||
#define WEECHAT_HDATA_LIST(__name) \
|
||||
weechat_hdata_new_list (hdata, #__name, &(__name));
|
||||
#define weechat_hdata_get(__hdata_name) \
|
||||
weechat_plugin->hdata_get(weechat_plugin, __hdata_name)
|
||||
#define weechat_hdata_get_var_offset(__hdata, __name) \
|
||||
weechat_plugin->hdata_get_var_offset(__hdata, __name)
|
||||
#define weechat_hdata_get_var_type(__hdata, __name) \
|
||||
weechat_plugin->hdata_get_var_type(__hdata, __name)
|
||||
#define weechat_hdata_get_var_type_string(__hdata, __name) \
|
||||
weechat_plugin->hdata_get_var_type_string(__hdata, __name)
|
||||
#define weechat_hdata_get_var(__hdata, __pointer, __name) \
|
||||
weechat_plugin->hdata_get_var(__hdata, __pointer, __name)
|
||||
#define weechat_hdata_get_var_at_offset(__hdata, __pointer, __offset) \
|
||||
weechat_plugin->hdata_get_var_at_offset(__hdata, __pointer, \
|
||||
__offset)
|
||||
#define weechat_hdata_get_list(__hdata, __name) \
|
||||
weechat_plugin->hdata_get_list(__hdata, __name)
|
||||
#define weechat_hdata_move(__hdata, __pointer, __count) \
|
||||
weechat_plugin->hdata_move(__hdata, __pointer, __count)
|
||||
#define weechat_hdata_integer(__hdata, __pointer, __name) \
|
||||
weechat_plugin->hdata_integer(__hdata, __pointer, __name)
|
||||
#define weechat_hdata_long(__hdata, __pointer, __name) \
|
||||
weechat_plugin->hdata_long(__hdata, __pointer, __name)
|
||||
#define weechat_hdata_string(__hdata, __pointer, __name) \
|
||||
weechat_plugin->hdata_string(__hdata, __pointer, __name)
|
||||
#define weechat_hdata_pointer(__hdata, __pointer, __name) \
|
||||
weechat_plugin->hdata_pointer(__hdata, __pointer, __name)
|
||||
#define weechat_hdata_time(__hdata, __pointer, __name) \
|
||||
weechat_plugin->hdata_time(__hdata, __pointer, __name)
|
||||
#define weechat_hdata_get_string(__hdata, __property) \
|
||||
weechat_plugin->hdata_get_string(__hdata, __property)
|
||||
|
||||
/* upgrade */
|
||||
#define weechat_upgrade_new(__filename, __write) \
|
||||
weechat_plugin->upgrade_new(__filename, __write)
|
||||
|
||||
Reference in New Issue
Block a user