|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <stdlib.h> |
|
22 #include <unistd.h> |
|
23 #include <stdio.h> |
|
24 |
|
25 #include <sys/types.h> |
|
26 #include <sys/stat.h> |
|
27 #include <fcntl.h> |
|
28 |
|
29 |
|
30 #include "process.h" |
|
31 |
|
32 int main(int argc, char *argv[]) |
|
33 { |
|
34 char *shell = getenv("TALON_SHELL"); |
|
35 char **args = malloc((argc+2)*sizeof(char *)); |
|
36 int i; |
|
37 proc *p; |
|
38 |
|
39 for (i=1; i < argc; i++) |
|
40 { |
|
41 args[i] = argv[i]; |
|
42 printf("arg: %s\n", args[i]); |
|
43 } |
|
44 args[argc] = NULL; |
|
45 |
|
46 if (! shell) |
|
47 { |
|
48 fprintf(stderr, "error: %s", "TALONSHELL not set in environment\n"); |
|
49 return 1; |
|
50 } |
|
51 |
|
52 args[0] = shell; |
|
53 p = process_run(shell, args, 4000); |
|
54 |
|
55 if (p) |
|
56 { |
|
57 |
|
58 buffer_prepend(p->output, "<recipe>\n<!CDATA<[[\n", 20); |
|
59 buffer_append(p->output, "\n]]></recipe>\n", 13); |
|
60 |
|
61 unsigned int iterator = 0; |
|
62 byteblock *bb; |
|
63 while ((bb = buffer_getbytes(p->output, &iterator))) |
|
64 { |
|
65 write(STDOUT_FILENO, &bb->byte0, bb->fill); |
|
66 } |
|
67 |
|
68 process_free(&p); |
|
69 } else { |
|
70 fprintf(stderr, "error: %s", "failed to run process\n"); |
|
71 return 1; |
|
72 } |
|
73 |
|
74 free(args); |
|
75 return 0; |
|
76 } |