g_free(data);
}
-static struct linestack_marker *wrap_linestack_marker(struct linestack_context *ctx, void *data)
-{
- struct linestack_marker *mrk;
- if (data == NULL)
- return NULL;
-
- mrk = g_new0(struct linestack_marker, 1);
- mrk->data = data;
- mrk->free_fn = g_free;
- return mrk;
-}
-
struct irc_network_state *linestack_get_state(
- struct linestack_context *nd, struct linestack_marker *lm)
+ struct linestack_context *nd, linestack_marker to_index)
{
struct irc_network_state *ret;
- gint64 *to_index, t, state_index;
- struct linestack_marker m1, m2;
+ gint64 t;
+ guint64 state_index;
GError *error = NULL;
GIOStatus status;
char *data_file;
g_assert(nd != NULL);
- to_index = lm?lm->data:NULL;
if (nd == NULL)
return NULL;
if (!marshall_network_state(MARSHALL_PULL, state_file, ret))
return NULL;
- m1.free_fn = NULL;
- m1.data = &state_index;
- m2.free_fn = NULL;
- m2.data = to_index;
- linestack_replay(nd, &m1, &m2, ret);
+ linestack_replay(nd, &state_index, to_index, ret);
g_io_channel_unref(state_file);
}
gboolean linestack_traverse(struct linestack_context *nd,
- struct linestack_marker *lm_from, struct linestack_marker *lm_to,
+ linestack_marker lm_from, linestack_marker lm_to,
linestack_traverse_fn handler, void *userdata)
{
gint64 start_index, end_index;
char *raw;
struct irc_line *l;
guint64 i;
- void *mf, *mt;
- mf = lm_from?lm_from->data:NULL;
- mt = lm_to?lm_to->data:NULL;
if (nd == NULL)
return FALSE;
g_io_channel_flush(nd->index_file, &error);
- if (mf == NULL) {
+ if (lm_from == NULL) {
start_index = 0;
} else {
- start_index = *((guint64 *)mf);
+ start_index = *lm_from;
}
- if (mt == NULL) {
+ if (lm_to == NULL) {
end_index = nd->count;
} else {
- end_index = *((guint64 *)mt);
+ end_index = *((guint64 *)lm_to);
}
raw = NULL;
gboolean linestack_traverse_object(
struct linestack_context *ctx,
const char *obj,
- struct linestack_marker *lm_from,
- struct linestack_marker *lm_to, linestack_traverse_fn hl,
+ linestack_marker lm_from,
+ linestack_marker lm_to, linestack_traverse_fn hl,
void *userdata)
{
struct traverse_object_data d;
return linestack_traverse(ctx, lm_from, lm_to, traverse_object_handler, &d);
}
-void linestack_free_marker(struct linestack_marker *lm)
+void linestack_free_marker(linestack_marker lm)
{
- if (lm == NULL)
- return;
-
- if (lm->free_fn != NULL)
- lm->free_fn(lm->data);
g_free(lm);
}
-struct linestack_marker *linestack_get_marker(struct linestack_context *nd)
+linestack_marker linestack_get_marker(struct linestack_context *nd)
{
- gint64 *pos;
+ guint64 *pos;
if (nd == NULL)
return NULL;
- pos = g_new0(gint64, 1);
+ pos = g_new0(guint64, 1);
(*pos) = nd->count;
- return wrap_linestack_marker(nd, pos);
+ return pos;
}
static const char *linestack_messages[] = {
return client_send_line(privdata->client, l, NULL);
}
-gboolean linestack_send(struct linestack_context *ctx, struct linestack_marker *mf, struct linestack_marker *mt, struct irc_client *c, gboolean dataonly, gboolean timed, int time_offset)
+gboolean linestack_send(struct linestack_context *ctx, linestack_marker mf, linestack_marker mt, struct irc_client *c, gboolean dataonly, gboolean timed, int time_offset)
{
struct send_line_privdata privdata;
linestack_traverse_fn trav_fn;
return linestack_traverse(ctx, mf, mt, trav_fn, &privdata);
}
-gboolean linestack_send_object(struct linestack_context *ctx, const char *obj, struct linestack_marker *mf, struct linestack_marker *mt, struct irc_client *c, gboolean dataonly, gboolean timed, int time_offset)
+gboolean linestack_send_object(struct linestack_context *ctx, const char *obj, linestack_marker mf, linestack_marker mt, struct irc_client *c, gboolean dataonly, gboolean timed, int time_offset)
{
struct send_line_privdata privdata;
linestack_traverse_fn trav_fn;
}
gboolean linestack_replay(struct linestack_context *ctx,
- struct linestack_marker *mf,
- struct linestack_marker *mt,
+ linestack_marker mf,
+ linestack_marker mt,
struct irc_network_state *st)
{
return linestack_traverse(ctx, mf, mt, replay_line, st);
#include "hooks.h"
struct irc_network_state;
-struct linestack_marker;
-struct ctrlproxy_config;
-
/**
* Mark set a specific point in time in a linestack.
*/
-struct linestack_marker {
- void *data;
- void (*free_fn) (void *);
-};
+typedef guint64 *linestack_marker;
+struct ctrlproxy_config;
/* linestack.c */
typedef gboolean (*linestack_traverse_fn) (struct irc_line *, time_t, void *);
-G_MODULE_EXPORT struct linestack_marker *linestack_get_marker_numlines (
+G_MODULE_EXPORT linestack_marker linestack_get_marker_numlines (
struct linestack_context *,
int lines);
G_MODULE_EXPORT struct irc_network_state *linestack_get_state (
struct linestack_context *,
- struct linestack_marker *);
+ linestack_marker );
G_MODULE_EXPORT gboolean linestack_traverse (
struct linestack_context *,
- struct linestack_marker *from,
- struct linestack_marker *to, /* Can be NULL for 'now' */
+ linestack_marker from,
+ linestack_marker to, /* Can be NULL for 'now' */
linestack_traverse_fn,
void *userdata);
G_MODULE_EXPORT gboolean linestack_traverse_object (
struct linestack_context *,
const char *object,
- struct linestack_marker *from,
- struct linestack_marker *to, /* Can be NULL for 'now' */
+ linestack_marker from,
+ linestack_marker to, /* Can be NULL for 'now' */
linestack_traverse_fn,
void *userdata);
G_MODULE_EXPORT gboolean linestack_send (
struct linestack_context *,
- struct linestack_marker *from,
- struct linestack_marker *to, /* Can be NULL for 'now' */
+ linestack_marker from,
+ linestack_marker to, /* Can be NULL for 'now' */
struct irc_client *,
gboolean dataonly,
gboolean timed,
G_MODULE_EXPORT gboolean linestack_send_object (
struct linestack_context *,
const char *object,
- struct linestack_marker *from,
- struct linestack_marker *to, /* Can be NULL for 'now' */
+ linestack_marker from,
+ linestack_marker to, /* Can be NULL for 'now' */
struct irc_client *,
gboolean dataonly,
gboolean timed,
G_MODULE_EXPORT gboolean linestack_replay (
struct linestack_context *,
- struct linestack_marker *from,
- struct linestack_marker *to,/* Can be NULL for 'now' */
+ linestack_marker from,
+ linestack_marker to,/* Can be NULL for 'now' */
struct irc_network_state *st);
G_MODULE_EXPORT gboolean linestack_insert_line(
enum data_direction dir,
const struct irc_network_state *);
-G_MODULE_EXPORT void linestack_free_marker(struct linestack_marker *);
-G_MODULE_EXPORT struct linestack_marker *linestack_get_marker(struct linestack_context *);
+G_MODULE_EXPORT void linestack_free_marker(linestack_marker );
+G_MODULE_EXPORT linestack_marker linestack_get_marker(struct linestack_context *);
/**
* Create a new linestack context
static void cmd_backlog(admin_handle h, const char * const *args, void *userdata)
{
- struct linestack_marker *lm;
+ linestack_marker lm;
struct irc_network *n;
if (admin_get_client(h) == NULL) {
static void highlight_replicate(struct irc_client *c)
{
- struct linestack_marker *lm = g_hash_table_lookup(markers, c->network);
+ linestack_marker lm = g_hash_table_lookup(markers, c->network);
if (c->network->external_state) {
client_send_state(c, c->network->external_state);
static void lastdisconnect_replicate(struct irc_client *c)
{
- struct linestack_marker *lm = g_hash_table_lookup(lastdisconnect_backlog, c->network);
+ linestack_marker lm = g_hash_table_lookup(lastdisconnect_backlog, c->network);
struct irc_network_state *ns;
if (c->network->linestack == NULL)
static void simple_replicate(struct irc_client *c)
{
- struct linestack_marker *m;
+ linestack_marker m;
struct irc_network_state *ns;
if (c->network->linestack == NULL)
START_TEST(test_msg)
struct irc_network_state *ns1;
struct linestack_context *ctx;
- struct linestack_marker *lm;
+ linestack_marker lm;
struct irc_client *cl;
GIOChannel *ch1, *ch2;
START_TEST(test_join_part)
struct irc_network_state *ns1;
struct linestack_context *ctx;
- struct linestack_marker *lm;
+ linestack_marker lm;
struct irc_client *cl;
GIOChannel *ch1, *ch2;
START_TEST(test_skip_msg)
struct irc_network_state *ns1;
struct linestack_context *ctx;
- struct linestack_marker *lm;
+ linestack_marker lm;
struct irc_client *cl;
GIOChannel *ch1, *ch2;
START_TEST(test_object_msg)
struct irc_network_state *ns1;
struct linestack_context *ctx;
- struct linestack_marker *lm;
+ linestack_marker lm;
struct irc_client *cl;
GIOChannel *ch1, *ch2;
START_TEST(test_object_open)
struct irc_network_state *ns1;
struct linestack_context *ctx;
- struct linestack_marker *lm;
+ linestack_marker lm;
struct irc_client *cl;
GIOChannel *ch1, *ch2;
START_TEST(bench_lots_of_lines)
struct irc_network_state *ns1;
struct linestack_context *ctx;
- struct linestack_marker *marker;
+ linestack_marker marker;
int i;
ns1 = network_state_init("bla", "Gebruikersnaam", "Computernaam");