os/ossrv/genericopenlibs/cstdlib/UCRT/WCRT0.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/UCRT/WCRT0.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,60 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// EPOC32 version of crt0.c for pure C programs, adapted to cause the full Eikon
    1.18 +// environment to come into being and hence only used with WINS.
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include <e32std.h>
    1.23 +#include <e32base.h>
    1.24 +#include <e32svr.h>
    1.25 +#include <estlib.h>
    1.26 +#include <estw32.h>
    1.27 +#include <stdlib.h>
    1.28 +
    1.29 +extern "C" int main (int argc, char *argv[], char *envp[]);
    1.30 +
    1.31 +#ifndef EKA2
    1.32 +IMPORT_C void RegisterWsExe(const TDesC &aName);
    1.33 +#endif
    1.34 +
    1.35 +GLDEF_C TInt E32Main()
    1.36 +	{     
    1.37 +	CTrapCleanup::New();
    1.38 +
    1.39 +	RWin32Stream::StartServer();	// arrange for access to Win32 stdin/stdout/stderr
    1.40 +	SpawnPosixServerThread();	// arrange for multi-threaded operation
    1.41 +
    1.42 +	int argc=0;
    1.43 +	char** argv=0;
    1.44 +	char** envp=0;
    1.45 +
    1.46 +	__crt0(argc,argv,envp);			// get args & environment from somewhere
    1.47 +
    1.48 +#ifndef EKA2
    1.49 +	// Cause the graphical Window Server to come into existence
    1.50 +	RSemaphore sem;
    1.51 +	sem.CreateGlobal(_L("WsExeSem"),0);
    1.52 +	RegisterWsExe(sem.FullName());
    1.53 +#endif
    1.54 +
    1.55 +	int ret=main(argc, argv, envp);		// go
    1.56 +
    1.57 +	// no need to explicitly delete the cleanup stack here as all memory used by
    1.58 +	// the process will be released by RProcess::Terminate(), called from inside exit().
    1.59 +
    1.60 +	exit(ret);	// to get atexit processing, eventually terminates this process
    1.61 +
    1.62 +	return(KErrNone);
    1.63 +	}