os/ossrv/genericopenlibs/cstdlib/LCHAR/CASECMP.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LCHAR/CASECMP.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,53 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Implement case-insensitive comparison using the full folded comparison
    1.18 +// functions of E32
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include <e32std.h>
    1.23 +#include <string.h>
    1.24 +
    1.25 +/**
    1.26 +Compares the null-terminated strings left and right and returns an integer 
    1.27 +greater than,equal to, or less than zero (0), accordingly as left 
    1.28 +is lexicographically greater than,equal to, or less than right after
    1.29 +translation of each corresponding character to lowercase.
    1.30 +@return an integer greater than, equal to, or less than zero (0),
    1.31 +accordingly as the string left is greater than, equal to,
    1.32 +or less than the string right.
    1.33 +@param left The first string to compare.
    1.34 +@param right The second string to compare.
    1.35 +*/
    1.36 +extern "C" EXPORT_C int strcasecmp (const char *left, const char *right)
    1.37 +	{
    1.38 +	TPtrC8 Left((const TText8*)left);
    1.39 +	TPtrC8 Right((const TText8*)right);
    1.40 +	return Left.CompareF(Right);
    1.41 +	}
    1.42 +
    1.43 +extern "C" EXPORT_C int strncasecmp (const char *left, const char *right, size_t length)
    1.44 +	{
    1.45 +	TUint leftlength=strlen(left);
    1.46 +	TUint rightlength=strlen(right);
    1.47 +	// The length parameter is the maximum amount of the string to be searched,
    1.48 +	// so truncate the descriptors appropriately
    1.49 +	if (leftlength>length)
    1.50 +		leftlength=length;
    1.51 +	if (rightlength>length)
    1.52 +		rightlength=length;
    1.53 +	TPtrC8 Left((const TText8*)left,leftlength);
    1.54 +	TPtrC8 Right((const TText8*)right,rightlength);
    1.55 +	return Left.CompareF(Right);
    1.56 +	}