sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\emul\t_emul_slave.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "t_emul.h" sl@0: sl@0: void TrapExceptionInExe() sl@0: { sl@0: TRAP_IGNORE(User::Leave(KErrGeneral)); sl@0: } sl@0: sl@0: TInt LoadLibraryAndCallFunc() sl@0: { sl@0: RLibrary l; sl@0: TInt r = l.Load(KTEmulDll2Name); sl@0: if (r != KErrNone) sl@0: return r; sl@0: TTrapExceptionInDllFunc func = sl@0: (TTrapExceptionInDllFunc)l.Lookup(KTrapExceptionInDllOrdinal); sl@0: if (func != NULL) sl@0: func(); sl@0: else sl@0: return KErrNotFound; sl@0: l.Close(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: TBuf<8> arg; sl@0: User::CommandLine(arg); sl@0: TLex lex(arg); sl@0: TInt val; sl@0: TInt r = lex.Val(val); sl@0: if (r != KErrNone) sl@0: return r; sl@0: sl@0: r = KErrNone; sl@0: switch(val) sl@0: { sl@0: case ESlaveDoNothing: sl@0: break; sl@0: sl@0: case ESlaveTrapExceptionInExe: sl@0: TrapExceptionInExe(); sl@0: break; sl@0: sl@0: case ESlaveTrapExceptionInLinkedDll: sl@0: TrapExceptionInDll(); sl@0: break; sl@0: sl@0: case ESlaveTrapExceptionInLoadedDll: sl@0: r = LoadLibraryAndCallFunc(); sl@0: break; sl@0: sl@0: default: sl@0: r = KErrNotSupported; sl@0: break; sl@0: } sl@0: sl@0: return r; sl@0: }