irctk

libircclient binding for scripts
git clone https://a3nm.net/git/irctk/
Log | Files | Refs | README

commit 9b5d8f3e633985d631f5b9c31e30bb9e16c6c374
parent 1969331400e4c56373c16ec5cfcbd9aaceb069a8
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Mon, 25 Jun 2012 15:01:32 +0200

start to debug fifo_set

Diffstat:
irctk.c | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 53 insertions(+), 4 deletions(-)

diff --git a/irctk.c b/irctk.c @@ -606,9 +606,12 @@ int empty_fifo_set(fifo_set *s) { void realloc_chans(fifo_set *s) { s->allocated *= 2; - assert(!realloc(s->chans, s->allocated*sizeof(char*))); - assert(!realloc(s->was_pushed, s->allocated*sizeof(char*))); - assert(!realloc(s->fifos, s->allocated*sizeof(fifo*))); + s->chans = realloc(s->chans, s->allocated*sizeof(char*)); + s->was_pushed = realloc(s->was_pushed, s->allocated*sizeof(char*)); + s->fifos = realloc(s->fifos, s->allocated*sizeof(fifo)); + assert(s->chans); + assert(s->was_pushed); + assert(s->fifos); } int push_chan(fifo_set *s, char *chan) { @@ -735,7 +738,7 @@ int mark_sendable_line(line *l) { return 1; l->is_sendable = 1; // TODO TODO TODO lift this when we have real deps - debug("i am %p depending on %p", l, l->next_dep); + debug("i am (%p) %s depending on (%p) %s", l, l->line, l->next_dep, l->next_dep->line); assert(l->next_dep == l); return mark_sendable_line(l->next_dep); } @@ -1396,6 +1399,50 @@ int start (int max_wait) return 0; } +int test_fifo_set() { + int n_results; + action *results; + int cont = 1; + int i; + char msga1[100]; + char msga2[100]; + char msga3[100]; + char msgb1[100]; + char msgc13[100]; + strcpy(msga1, "round A1 message"); + strcpy(msga2, "round A2 message"); + strcpy(msga3, "round A3 message"); + strcpy(msgb1, "round B1 message"); + strcpy(msgc13, "round C13 message"); + char chan1[100]; + char chan2[100]; + char chan3[100]; + char chan13[100]; + strcpy(chan1, "chan1"); + strcpy(chan2, "chan2"); + strcpy(chan3, "chan3"); + strcpy(chan13, "chan1,chan3"); + + push_fifo_set(&fifos, msga1, chan1, NULL); + push_fifo_set(&fifos, msga2, chan2, NULL); + push_fifo_set(&fifos, msga3, chan3, NULL); + push_fifo_set(&fifos, msgb1, chan1, NULL); + //push_fifo_set(&fifos, msgc13, chan13, NULL); + push_fifo_set(&fifos, NULL, "", NULL); + + while (cont) { + n_results = pop_fifo_set(&fifos, &results); + for (i=0; i<n_results; i++) { + if (!results[i].line) { + cont = 0; + } + printf("%s\n", results[i].line); + } + } + printf("finished\n"); + return 0; +} + int main (int argc, char **argv) { // initialize the default option values @@ -1407,6 +1454,8 @@ int main (int argc, char **argv) // initialize the fifo init_fifo_set(&fifos); + return test_fifo_set(); + // start trying to connet with the initial retry interval return start(args.retry_after); }