equal
deleted
inserted
replaced
|
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // RunPerl.cpp : Defines the entry point for the console application. |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 #include <stdlib.h> |
|
20 #include <string.h> |
|
21 |
|
22 void main(int argc, char* argv[]) |
|
23 { |
|
24 |
|
25 char** args = new char*[argc+3]; |
|
26 int index = 0; |
|
27 |
|
28 char* p = argv[0]; |
|
29 int pl = strlen(p); |
|
30 if((pl >= 4) && |
|
31 (*(p+pl-4)=='.') && |
|
32 (*(p+pl-3)=='e' || *(p+pl-3)=='E') && |
|
33 (*(p+pl-2)=='x' || *(p+pl-2)=='X') && |
|
34 (*(p+pl-1)=='e' || *(p+pl-1)=='E')) |
|
35 *(p+pl-4)='\0'; |
|
36 char* cmd = new char[strlen(p)+4]; |
|
37 strcpy(cmd,p); |
|
38 strcat(cmd,".pl"); |
|
39 |
|
40 args[index++] = "perl"; |
|
41 args[index++] = "-S"; |
|
42 args[index++] = cmd; |
|
43 |
|
44 for(int i=1; i<argc; i++) |
|
45 { |
|
46 args[index++] = argv[i]; |
|
47 } |
|
48 |
|
49 args[index] = NULL; |
|
50 |
|
51 int sz = 0; |
|
52 |
|
53 for(i=0; args[i]; i++) |
|
54 { |
|
55 sz += strlen(args[i]) + 3; |
|
56 } |
|
57 |
|
58 char *s = new char[sz]; |
|
59 strcpy(s,args[0]); |
|
60 strcat(s," "); |
|
61 strcat(s,args[1]); |
|
62 strcat(s," "); |
|
63 strcat(s,args[2]); |
|
64 |
|
65 for(i=3; args[i]; i++) |
|
66 { |
|
67 strcat(s," \""); |
|
68 strcat(s,args[i]); |
|
69 strcat(s,"\""); |
|
70 } |
|
71 |
|
72 int r = system(s); |
|
73 |
|
74 delete[] s; |
|
75 delete[] args; |
|
76 delete[] cmd; |
|
77 |
|
78 exit (r); |
|
79 } |
|
80 |