1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Eclipse Public License v1.0" |
5 * under the terms of the License "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
31 #include "talon_process.h" |
31 #include "talon_process.h" |
32 #include "sema.h" |
32 #include "sema.h" |
33 #include "buffer.h" |
33 #include "buffer.h" |
34 #include "../config.h" |
34 #include "../config.h" |
35 |
35 |
|
36 #ifdef HAS_GETCOMMANDLINE |
|
37 #include "chomp.h" |
|
38 #endif |
|
39 |
36 /* The output semaphore. */ |
40 /* The output semaphore. */ |
37 sbs_semaphore talon_sem; |
41 sbs_semaphore talon_sem; |
38 |
42 |
39 #define TALON_ATTEMPT_STRMAX 32 |
43 #define TALON_ATTEMPT_STRMAX 32 |
40 #define RECIPETAG_STRMAX 2048 |
44 #define RECIPETAG_STRMAX 2048 |
41 #define STATUS_STRMAX 100 |
45 #define STATUS_STRMAX 120 |
42 |
46 |
43 #define TALONDELIMITER '|' |
47 #define TALONDELIMITER '|' |
44 #define VARNAMEMAX 100 |
48 #define VARNAMEMAX 100 |
45 #define VARVALMAX 1024 |
49 #define VARVALMAX 1024 |
46 |
50 |
229 char *recipe = NULL; |
233 char *recipe = NULL; |
230 int talon_returncode = 0; |
234 int talon_returncode = 0; |
231 |
235 |
232 #ifdef HAS_GETCOMMANDLINE |
236 #ifdef HAS_GETCOMMANDLINE |
233 char *commandline= GetCommandLine(); |
237 char *commandline= GetCommandLine(); |
234 DEBUG(("talon: commandline: %s\n", commandline)); |
|
235 /* |
238 /* |
236 * The command line should be either, |
239 * The command line should be either, |
237 * talon -c "some shell commands" |
240 * talon -c "some shell commands" |
238 * or |
241 * or |
239 * talon shell_script_file |
242 * talon shell_script_file |
240 * |
243 * |
241 * talon could be an absolute path and may have a .exe extension. |
244 * talon could be an absolute path and may have a .exe extension. |
242 */ |
245 */ |
243 recipe = strstr(commandline, "-c"); |
246 |
|
247 |
|
248 recipe = chompCommand(commandline); |
244 if (recipe) |
249 if (recipe) |
245 { |
250 { |
246 /* there was a -c so extract the quoted commands */ |
251 /* there was a -c so extract the quoted commands */ |
247 |
252 |
248 while (*recipe != '"' && *recipe != '\0') |
|
249 recipe++; |
|
250 |
|
251 if (*recipe != '"') /* we found -c but no following quote */ |
|
252 { |
|
253 error("talon: error: unquoted recipe in shell call '%s'\n", commandline); |
|
254 return 1; |
|
255 } |
|
256 recipe++; |
|
257 |
|
258 int recipelen = strlen(recipe); |
253 int recipelen = strlen(recipe); |
259 if (recipelen > 0 && recipe[recipelen - 1] == '"') |
254 if (recipelen > 0 && recipe[recipelen - 1] == '"') |
260 recipe[recipelen - 1] = '\0'; /* remove trailing quote */ |
255 recipe[recipelen - 1] = '\0'; /* remove trailing quote */ |
261 } |
256 } |
262 else |
257 else |
547 |
542 |
548 talon_returncode = p->returncode; |
543 talon_returncode = p->returncode; |
549 |
544 |
550 if (dotagging) |
545 if (dotagging) |
551 { |
546 { |
552 char *forcesuccessstr = force_success == 0 ? "" : " forcesuccess='FORCESUCCESS'"; |
547 char *flagsstr = force_success == 0 ? "" : " flags='FORCESUCCESS'"; |
|
548 char *reasonstr = "" ; |
|
549 |
|
550 if (p->causeofdeath == PROC_TIMEOUTDEATH) |
|
551 reasonstr = " reason='timeout'"; |
553 |
552 |
554 if (p->returncode != 0) |
553 if (p->returncode != 0) |
555 { |
554 { |
556 char *exitstr = retries > 0 ? "retry" : "failed"; |
555 char *exitstr = retries > 0 ? "retry" : "failed"; |
557 snprintf(status, STATUS_STRMAX - 1, "\n<status exit='%s' code='%d' attempt='%d'%s />", exitstr, p->returncode, attempt, forcesuccessstr ); |
556 snprintf(status, STATUS_STRMAX - 1, "\n<status exit='%s' code='%d' attempt='%d'%s%s />", exitstr, p->returncode, attempt, flagsstr, reasonstr ); |
558 } else { |
557 } else { |
559 snprintf(status, STATUS_STRMAX - 1, "\n<status exit='ok' attempt='%d'%s />", attempt, forcesuccessstr ); |
558 snprintf(status, STATUS_STRMAX - 1, "\n<status exit='ok' attempt='%d'%s%s />", attempt, flagsstr, reasonstr ); |
560 } |
559 } |
561 status[STATUS_STRMAX-1] = '\0'; |
560 status[STATUS_STRMAX-1] = '\0'; |
562 |
561 |
563 snprintf(timestat, STATUS_STRMAX - 1, "<time start='%.5f' elapsed='%.3f' />",start_time, end_time-start_time ); |
562 snprintf(timestat, STATUS_STRMAX - 1, "<time start='%.5f' elapsed='%.3f' />",start_time, end_time-start_time ); |
564 timestat[STATUS_STRMAX-1] = '\0'; |
563 timestat[STATUS_STRMAX-1] = '\0'; |