diff -r 000000000000 -r bde4ae8d615e os/ossrv/genericopenlibs/cstdlib/LCHAR/STRCHR.C --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/ossrv/genericopenlibs/cstdlib/LCHAR/STRCHR.C Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* FUNCTION +* <>---search for character in string +* INDEX +* strchr +* ANSI_SYNOPSIS +* #include +* char * strchr(const char *<[string]>, int <[c]>); +* TRAD_SYNOPSIS +* #include +* char * strchr(<[string]>, <[c]>); +* char *<[string]>; +* int *<[c]>; +* This function finds the first occurence of <[c]> (converted to +* a char) in the string pointed to by <[string]> (including the +* terminating null character). +* RETURNS +* Returns a pointer to the located character, or a null pointer +* if <[c]> does not occur in <[string]>. +* PORTABILITY +* <> is ANSI C. +* <> requires no supporting OS subroutines. +* QUICKREF +* strchr ansi pure +* +* +*/ + + + +#include + +/** +Find character in string. +Returns the first occurrence of i in string. +The null-terminating character is included as part of the string +and can also be searched. +@return a pointer to the first occurrence of i in string is returned. +otherwise NULL is returned. +@param s Null-terminated string scanned in the search. +@param i Character to be found. +*/ +EXPORT_C char * +strchr (const char *s, int i) +{ + i = (char)i; + + for (;;) + { + int c = *s++; + if (c == i) + return (char *) (s - 1); + if (c == 0) + return NULL; + } +} + +EXPORT_C char * +index (const char *s, int i) +{ + return strchr(s, i); +}