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