fixed multiple values in msg_*
authorJiří Filipovič <fila@ics.muni.cz>
Fri, 27 May 2011 11:59:40 +0000 (11:59 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Fri, 27 May 2011 11:59:40 +0000 (11:59 +0000)
org.glite.lb.server/src/bkserverd.c
org.glite.lb.server/src/lb_text.c

index 83f902a..dde7568 100644 (file)
@@ -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; npref<totpref; npref++) 
                ctx->msg_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; npref<totpref; npref++) 
                ctx->msg_brokers[npref]=strdup(msg_brokers[npref]);
 
index 75ddf44..9913e0d 100644 (file)
@@ -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;