From 45f5e1e6056bdda04c4fc880b9c7ff3d40c02008 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Tue, 16 Jun 2009 23:38:12 +0000 Subject: [PATCH] * use constr structs for our static string arrays * remove unneded macros and stuff * fix leaks --- webcit/roomops.c | 53 +++++++++++++++++++++++++----------------------- webcit/webcit.h | 8 -------- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/webcit/roomops.c b/webcit/roomops.c index bda4375ed..498e7e537 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -11,20 +11,22 @@ char floorlist[MAX_FLOORS][SIZ]; /**< list of our floor names */ char *viewdefs[9]; /**< the different kinds of available views */ /** See GetFloorListHash and GetRoomListHash for info on these. Basically we pull LFLR/LKRA etc. and set up a room HashList with these keys. */ -const char FLOOR_PARAM_NAMES[(FLOOR_PARAM_LEN + 1)][15] = {"ID", - "NAME", - "ROOMS"}; -const char ROOM_PARAM_NAMES[(ROOM_PARAM_LEN + 1)][20] = {"NAME", - "FLAG", - "FLOOR", - "LISTORDER", - "ACL", - "CURVIEW", - "DEFVIEW", - "LASTCHANGE"}; -/* Because avoiding strlen at run time is a Good Thing(TM) */ -const int FLOOR_PARAM_NAMELEN[(FLOOR_PARAM_LEN +1)] = {2, 4, 5}; -const int ROOM_PARAM_NAMELEN[(ROOM_PARAM_LEN +1)] = {4, 4, 5, 9, 3, 7, 7, 8}; + +#define FLOOR_PARAM_LEN 3 +const ConstStr FLOOR_PARAM_NAMES[] = {{HKEY("ID")}, + {HKEY("NAME")}, + {HKEY("ROOMS")}}; + +#define ROOM_PARAM_LEN 8 +const ConstStr ROOM_PARAM_NAMES[] = {{HKEY("NAME")}, + {HKEY("FLAG")}, + {HKEY("FLOOR")}, + {HKEY("LISTORDER")}, + {HKEY("ACL")}, + {HKEY("CURVIEW")}, + {HKEY("DEFVIEW")}, + {HKEY("LASTCHANGE")}}; + void display_whok(void); @@ -3766,17 +3768,18 @@ HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP) { if (GetServerStatus(Buf, NULL) == 1) while(StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err), strcmp(ChrPtr(Buf), "000")) { int a; - const char *floorNum = NULL; + const StrBuf *floorNum = NULL; floor = NewHash(1, NULL); for(a=0; aserv_sock, 0, &Err), strcmp(ChrPtr(buf), "000")) { int i; - const char *rmName = NULL; + StrBuf *rmName = NULL; room = NewHash(1, NULL); for(i=0; i