From c26e8d79419a9e7454769b2c733c4e489cf63b87 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20Filipovi=C4=8D?= Date: Fri, 27 May 2011 11:59:40 +0000 Subject: [PATCH] fixed multiple values in msg_* --- org.glite.lb.server/src/bkserverd.c | 4 ++-- org.glite.lb.server/src/lb_text.c | 43 ++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/org.glite.lb.server/src/bkserverd.c b/org.glite.lb.server/src/bkserverd.c index 83f902a..dde7568 100644 --- a/org.glite.lb.server/src/bkserverd.c +++ b/org.glite.lb.server/src/bkserverd.c @@ -1297,12 +1297,12 @@ int bk_handle_connection(int conn, struct timeval *timeout, void *data) ctx->exclusive_zombies = exclusive_zombies; for (totpref = 0; msg_prefixes[totpref]; totpref++); - ctx->msg_prefixes = (char**) calloc(sizeof(char*), totpref); + ctx->msg_prefixes = (char**) calloc(sizeof(char*), totpref+1); for (npref = 0; nprefmsg_prefixes[npref]=strdup(msg_prefixes[npref]); for (totpref = 0; msg_brokers && msg_brokers[totpref]; totpref++); - ctx->msg_brokers = (char**) calloc(sizeof(char*), totpref); + ctx->msg_brokers = (char**) calloc(sizeof(char*), totpref+1); for (npref = 0; nprefmsg_brokers[npref]=strdup(msg_brokers[npref]); diff --git a/org.glite.lb.server/src/lb_text.c b/org.glite.lb.server/src/lb_text.c index 75ddf44..9913e0d 100644 --- a/org.glite.lb.server/src/lb_text.c +++ b/org.glite.lb.server/src/lb_text.c @@ -87,6 +87,35 @@ int edg_wll_QueryToText(edg_wll_Context ctx UNUSED_VAR, edg_wll_Event *eventsOut free(a); a=NULL; \ } +#define TRS(name,type,field) \ +{ \ + int l; \ + if (field) \ + l = asprintf(&a,"%s=" type "", \ + name, field); \ + else \ + l = asprintf(&a,"%s=", name); \ + b = realloc(b, sizeof(*b)*(pomL+l+1)); \ + strcpy(b+pomL, a); \ + pomL += l; \ + free(a); a=NULL; \ +} + +#define TRA(type,field) \ +{ \ + int l; \ + if (field) \ + l = asprintf(&a,"," type "", \ + field); \ + else \ + l = asprintf(&a,"\n"); \ + b = realloc(b, sizeof(*b)*(pomL+l+1)); \ + strcpy(b+pomL, a); \ + pomL += l; \ + free(a); a=NULL; \ +} + + int edg_wll_UserInfoToText(edg_wll_Context ctx, edg_wlc_JobId *jobsOut, char **message) { char *a = NULL, *b; @@ -250,11 +279,19 @@ int edg_wll_ConfigurationToText(edg_wll_Context ctx, char **message){ b = strdup(""); if (ctx->msg_brokers) - for (i = 0; ctx->msg_brokers[i]; i++) - TR("msg_brokers", "%s", ctx->msg_brokers[i]); + for (i = 0; ctx->msg_brokers[i]; i++){ + if (i == 0) TRS("msg_brokers", "%s", ctx->msg_brokers[i]) + else TRA("%s", ctx->msg_brokers[i]); + } + if (i > 0) + TRA("%s", NULL); + if (ctx->msg_prefixes) for (i = 0; ctx->msg_prefixes[i]; i++) - TR("msg_prefixes", "%s", ctx->msg_prefixes[i]); + if (i == 0) TRS("msg_prefixes", "%s", ctx->msg_prefixes[i]) + else TRA("%s", ctx->msg_prefixes[i]); + if (i > 0) + TRA("%s", NULL); *message = b; -- 1.8.2.3