linklayerprotocols/pppnif/SPPP/PPPCFG.CPP
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     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 "PPPCFG.H"
       
    17 
       
    18 CPppCompConfig::CPppCompConfig()
       
    19 	{
       
    20 	}
       
    21 
       
    22 CPppCompConfig::~CPppCompConfig()
       
    23 	{
       
    24 	delete iName;
       
    25 	delete iOptions;
       
    26 	}
       
    27 
       
    28 TUint8 CPppCompConfig::ID()
       
    29 	{
       
    30 	return iID;
       
    31 	}
       
    32 
       
    33 TPtrC8 CPppCompConfig::Options()
       
    34 	{
       
    35 	return iOptions->Des();
       
    36 	}
       
    37 
       
    38 TInt CPppCompConfig::OptionsLength()
       
    39 	{
       
    40 	return iOptions->Length();
       
    41 	}
       
    42 
       
    43 void CPppCompConfig::AddOptionsL(TPtrC aOptions)
       
    44 //
       
    45 // Read the options field from the file into the Config Class
       
    46 //
       
    47 	{
       
    48 	TInt Length;
       
    49 
       
    50 	//
       
    51 	// This Length is in characters, each byte is two characters
       
    52 	//
       
    53 	Length = aOptions.Length();
       
    54 	Length /= 2;
       
    55 
       
    56 	iOptions = HBufC8::NewMaxL(Length);
       
    57 
       
    58 	TPtr8	Temp = iOptions->Des();
       
    59 
       
    60 
       
    61 #ifdef UNICODE
       
    62 	TUint16* Ptr;
       
    63 	Ptr = CONST_CAST(TUint16*, (aOptions.Ptr()));
       
    64 #else
       
    65 	TUint8* Ptr;
       
    66 	Ptr = CONST_CAST(TUint8*, (aOptions.Ptr()));
       
    67 #endif
       
    68 
       
    69 	TInt i;
       
    70 	TInt Byte=0;
       
    71 	TInt Byte1=0;
       
    72 	Temp.Zero();
       
    73 	for (i=0;i<Length;i++)
       
    74 		{
       
    75 		//
       
    76 		// Read two characters and convert them into a byte
       
    77 		//
       
    78 		Byte = *(Ptr+(i*2));
       
    79 		Byte &= 0xFF;
       
    80 		Byte -= 0x30;
       
    81 		Byte <<= 4;
       
    82 		Byte1 = *(Ptr+(i*2)+1);
       
    83 		Byte1 &= 0xFF;
       
    84 		Byte1 -= 0x30;
       
    85 		Byte |= Byte1;
       
    86 
       
    87 		Temp.Append((TUint8)Byte);
       
    88 		}
       
    89 	}
       
    90 
       
    91 void CPppCompConfig::AddNameL(TPtrC aName)
       
    92 	{
       
    93 
       
    94 	iName = HBufC::NewMaxL(aName.Length());
       
    95 	TPtr temp = iName->Des();
       
    96 	temp.Copy((aName.Ptr()), (aName.Length()));
       
    97 	}
       
    98 
       
    99 TPtrC CPppCompConfig::Name()
       
   100 	{
       
   101 	return *iName;
       
   102 	}
       
   103 
       
   104 
       
   105 CPppCompConfig* CPppCompConfig::NewL()
       
   106 	{
       
   107 	CPppCompConfig * pppComp = new (ELeave) CPppCompConfig();
       
   108 
       
   109 	return pppComp;
       
   110 	}
       
   111 
       
   112 void CPppCompConfig::AddID(TUint8 aID)
       
   113 	{
       
   114 	iID = aID;
       
   115 	}
       
   116