applayerprotocols/ftpengine/ftptest/FTPTEST.H
changeset 0 b16258d2340f
child 30 b7f26243ec94
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     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 // PG: Hacked from eustd.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __FTPTEST_H
       
    19 #define __FTPTEST_H
       
    20 
       
    21 #ifndef __EPOC32__
       
    22 #define PDD_NAME _L("ECDRV")
       
    23 #define LDD_NAME _L("ECOMM")
       
    24 #else
       
    25 #define PDD_NAME _L("EUART1")
       
    26 #define LDD_NAME _L("ECOMM")
       
    27 #endif
       
    28 
       
    29 #include <e32cons.h>
       
    30 
       
    31 // public
       
    32 LOCAL_D CConsoleBase* __FTPDebugConsole; // write all your messages to this
       
    33 LOCAL_C void doExampleL(); // code this function for the real example
       
    34 
       
    35 // private
       
    36 LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example
       
    37 
       
    38 GLDEF_C TInt E32Main() // main function called by E32
       
    39     {
       
    40 	__UHEAP_MARK;
       
    41 	CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
       
    42 	TRAPD(error,callExampleL()); // more initialization, then do example
       
    43 	__ASSERT_ALWAYS(!error,User::Panic(_L("EPOC32EX"),error));
       
    44 	delete cleanup; // destroy clean-up stack
       
    45 	__UHEAP_MARKEND;
       
    46 	return 0; // and return
       
    47     }
       
    48 LOCAL_C void InitCommsL()
       
    49 	{
       
    50 	TInt err;
       
    51 
       
    52 	err=User::LoadPhysicalDevice(PDD_NAME);
       
    53 	if (err!=KErrNone && err!=KErrAlreadyExists)
       
    54 		User::Leave(err);
       
    55 
       
    56 	err=User::LoadLogicalDevice(LDD_NAME);
       
    57 	if (err!=KErrNone && err!=KErrAlreadyExists)
       
    58 		User::Leave(err);
       
    59 	}
       
    60 
       
    61 LOCAL_C void callExampleL() // initialize and call example code under cleanup stack
       
    62     {
       
    63 	__FTPDebugConsole=Console::NewL(_L("FTP Test Code"),
       
    64 		TSize(KConsFullScreen,KConsFullScreen));
       
    65 	CleanupStack::PushL(__FTPDebugConsole);
       
    66 	InitCommsL();
       
    67 	TRAPD(error,doExampleL()); // perform example function
       
    68 	if (error) __FTPDebugConsole->Printf(_L("failed: leave code=%d"), error);
       
    69 	else __FTPDebugConsole->Printf(_L("ok"));
       
    70 	__FTPDebugConsole->Printf(_L(" [press any key]"));
       
    71 	__FTPDebugConsole->Getch(); // get and ignore character
       
    72 	CleanupStack::PopAndDestroy(); // close console
       
    73     }
       
    74 
       
    75 #endif