JDL without newlines in text interface.
authorJiří Filipovič <fila@ics.muni.cz>
Thu, 14 Aug 2008 12:15:14 +0000 (12:15 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Thu, 14 Aug 2008 12:15:14 +0000 (12:15 +0000)
org.glite.lb.server/src/lb_proto.c
org.glite.lb.server/src/lb_text.c

index 7440407..e039c2c 100644 (file)
@@ -501,7 +501,7 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx,
                                edg_wll_SetError(ctx,EDG_WLL_ERROR_JOBID_FORMAT,fullid);
                                ret = HTTP_BADREQ;
                        }
-                       else switch (edg_wll_JobStatusServer(ctx,jobId,0,&stat)) {
+                       else switch (edg_wll_JobStatusServer(ctx,jobId,EDG_WLL_STAT_CLASSADS,&stat)) {
                                case 0: if (text) 
                                                edg_wll_JobStatusToText(ctx,stat,&message); 
                                        else if (html)
index 669d370..95089f7 100644 (file)
 #define UNUSED_VAR
 #endif
 
+static char *escape_text(char *text){
+       int len = strlen(text);
+       char *ret = malloc((len+1)*sizeof(char));
+       int reti = 0;
+       int retlen = len;
+       int i;
+       for (i = 0; i < len; i++){
+               // escape '\'
+               if (text[i] == '\\'){
+                       ret[reti] = '\\';
+                       reti++;
+                       retlen++;
+                       ret = realloc(ret, (retlen+1)*sizeof(char));
+               }
+               // replace newline by '\\n'
+               if (text[i] == '\n'){
+                       ret[reti] = '\\';
+                       reti++;
+                       ret[reti] = 'n';
+                       retlen++;
+                        ret = realloc(ret, (retlen+1)*sizeof(char));
+               }
+               else
+                       ret[reti] = text[i];
+               reti++;
+       }
+       ret[reti] = 0;
+       return ret;
+}
+
 int edg_wll_QueryToText(edg_wll_Context ctx UNUSED_VAR, edg_wll_Event *eventsOut UNUSED_VAR, char **message UNUSED_VAR)
 {
 /* not implemented yet */
@@ -108,11 +138,15 @@ int edg_wll_JobStatusToText(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobStat stat
        TR("Done_code","%d",stat.done_code);
        TR("Exit_code","%d",stat.exit_code);
 
-        if (stat.jdl) asprintf(&jdl,">Job_description = %s\n", stat.jdl);
+        if (stat.jdl){
+               char* my_jdl = escape_text(stat.jdl);
+               asprintf(&jdl,"Job_description=%s\n", my_jdl);
+               free(my_jdl);
+       }
 
-       if (stat.rsl) asprintf(&rsl,"RSL = %s\n", stat.rsl);
+       if (stat.rsl) asprintf(&rsl,"RSL=%s\n", stat.rsl);
 
-        asprintf(&a, "Job = %s\n"
+        asprintf(&a, "Job=%s\n"
                        "%s"
                        "%s"
                        "%s",