serialserver/c32serialserver/CCOMM/CC_UTL.CPP
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 1997-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 //
       
    15 
       
    16 #include <e32std.h>
       
    17 #include <e32svr.h>
       
    18 #include <c32comm.h>
       
    19 #include "COMMIPC.H"
       
    20 #include "C32LOG.H"
       
    21 
       
    22 /** @file
       
    23  *
       
    24  * Implements the StartC32 function, used to start up C32
       
    25  */
       
    26 
       
    27 #ifdef _DEBUG
       
    28 #define STARTC32LOG(a) a
       
    29 #else
       
    30 #define STARTC32LOG(a) 
       
    31 #endif
       
    32 
       
    33 /** File name of the rootserver client DLL.
       
    34 @internalComponent
       
    35 */
       
    36 _LIT(KRootServerDll, "c32root.dll");
       
    37 
       
    38 /** Ordinal number of the StartC32() entrypoint in the rootserver client library.
       
    39 @internalComponent
       
    40 */
       
    41 const TInt StartC32EntryOrdinal=1;
       
    42 
       
    43 //
       
    44 // NOTE: These literals were previously #define'd as _L()
       
    45 //       By using _LIT and functions returning reference to them
       
    46 //       we save some ROM bytes for avoiding the duplicated strings.
       
    47 //
       
    48 
       
    49 
       
    50 const TDesC& KCommServerName(void)
       
    51 /**
       
    52  * returns the name of the Comm Server thread
       
    53  */
       
    54 	{
       
    55 	_LIT(KCommServerNameLit, "!CommServer");
       
    56 
       
    57 	return KCommServerNameLit;
       
    58 	}
       
    59 
       
    60 
       
    61 EXPORT_C TInt StartC32()
       
    62   /**
       
    63    * Start the Rootserver and services, 
       
    64    * this function in C32 is DEPRECATED and will be removed
       
    65    * in the near future.
       
    66    *
       
    67    * Instead one should link to c32root.dll and use the 
       
    68    * StartC32() from that library.
       
    69    *
       
    70    * @return TInt - An error code
       
    71    */
       
    72   	{
       
    73 	C32_STATIC_LOG(KC32Warning,_L8("WARNING: StartC32() CALLED IN C32.DLL. THIS IS DEPRECATED. MUST USE C32ROOT.DLL!!"));
       
    74 
       
    75 	RLibrary library;
       
    76 	TInt res = library.Load(KRootServerDll);
       
    77 
       
    78     if (res!=KErrNone && res!=KErrAlreadyExists)
       
    79 		{
       
    80 		C32_STATIC_LOG2(KC32Warning, _L8("StartC32 from C32.DLL: Unable to load RS DLL %d."), res);
       
    81 
       
    82         return res;
       
    83 		}
       
    84 
       
    85 	C32_STATIC_LOG(KC32Bootup,      _L8("StartC32 from C32.DLL: Loaded RS library."));
       
    86 
       
    87     TLibraryFunction StartC32Entry=library.Lookup(StartC32EntryOrdinal);
       
    88     
       
    89     if (StartC32Entry==NULL)
       
    90 		{
       
    91 		C32_STATIC_LOG2(KC32Warning, _L8("StartC32 from C32.DLL: Unable to load StartC32 ordinal %d."), StartC32EntryOrdinal);
       
    92         return KErrNoMemory;
       
    93 		}
       
    94 
       
    95 	C32_STATIC_LOG(KC32Bootup, _L8("StartC32 from C32.DLL: Calling StartC32 ordinal from RS."));
       
    96 
       
    97 	res = StartC32Entry();
       
    98 	library.Close();
       
    99   	return res;
       
   100 	}
       
   101 
       
   102 
       
   103 // EOF - CC_UTL.CPP