From e0cc5508c771d9d4b4ea4cb6a9ffb8de0ceb0dba Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 11 Nov 2006 05:24:05 +0000 Subject: [PATCH] Load room list for the sieve rules once, and reuse the list in memory for each rule's select box --- webcit/sieve.c | 51 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/webcit/sieve.c b/webcit/sieve.c index be609ced8..20c032d9d 100644 --- a/webcit/sieve.c +++ b/webcit/sieve.c @@ -372,8 +372,30 @@ void create_script(void) { void display_rules_editor_inner_div(void) { - int i; - char buf[256], targ[256]; + int i, j; + char buf[256]; + + struct { + char name[128]; + } *rooms = NULL; + int num_roomnames = 0; + int num_roomnames_alloc = 0; + + + /* load the roomnames */ + serv_puts("LKRA"); + serv_getln(buf, sizeof buf); + if (buf[0] == '1') { + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + ++num_roomnames; + if (num_roomnames > num_roomnames_alloc) { + num_roomnames_alloc += 250; + rooms = realloc(rooms, (num_roomnames_alloc * 128)); + } + extract_token(rooms[num_roomnames-1].name, buf, 0, '|', 128); + } + } + /* * This script should get called by every onChange event... @@ -467,21 +489,17 @@ void display_rules_editor_inner_div(void) { wprintf(""); wprintf("
", i); - wprintf("", i); + for (j=0; j"); + escputs(rooms[j].name); + wprintf("\n"); } wprintf("\n"); wprintf("
"); @@ -515,6 +533,7 @@ void display_rules_editor_inner_div(void) { " \n" ); + free(rooms); } -- 2.30.2