os/ossrv/genericopenlibs/cstdlib/UCRT/WCRT0.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1998-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 // EPOC32 version of crt0.c for pure C programs, adapted to cause the full Eikon
    15 // environment to come into being and hence only used with WINS.
    16 // 
    17 //
    18 
    19 #include <e32std.h>
    20 #include <e32base.h>
    21 #include <e32svr.h>
    22 #include <estlib.h>
    23 #include <estw32.h>
    24 #include <stdlib.h>
    25 
    26 extern "C" int main (int argc, char *argv[], char *envp[]);
    27 
    28 #ifndef EKA2
    29 IMPORT_C void RegisterWsExe(const TDesC &aName);
    30 #endif
    31 
    32 GLDEF_C TInt E32Main()
    33 	{     
    34 	CTrapCleanup::New();
    35 
    36 	RWin32Stream::StartServer();	// arrange for access to Win32 stdin/stdout/stderr
    37 	SpawnPosixServerThread();	// arrange for multi-threaded operation
    38 
    39 	int argc=0;
    40 	char** argv=0;
    41 	char** envp=0;
    42 
    43 	__crt0(argc,argv,envp);			// get args & environment from somewhere
    44 
    45 #ifndef EKA2
    46 	// Cause the graphical Window Server to come into existence
    47 	RSemaphore sem;
    48 	sem.CreateGlobal(_L("WsExeSem"),0);
    49 	RegisterWsExe(sem.FullName());
    50 #endif
    51 
    52 	int ret=main(argc, argv, envp);		// go
    53 
    54 	// no need to explicitly delete the cleanup stack here as all memory used by
    55 	// the process will be released by RProcess::Terminate(), called from inside exit().
    56 
    57 	exit(ret);	// to get atexit processing, eventually terminates this process
    58 
    59 	return(KErrNone);
    60 	}