os/ossrv/genericopenlibs/cstdlib/LCHAR/STRCHR.C
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LCHAR/STRCHR.C	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,75 @@
     1.4 +/*
     1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +* FUNCTION
    1.19 +* <<strchr>>---search for character in string
    1.20 +* INDEX
    1.21 +* strchr
    1.22 +* ANSI_SYNOPSIS
    1.23 +* #include <string.h>
    1.24 +* char * strchr(const char *<[string]>, int <[c]>);
    1.25 +* TRAD_SYNOPSIS
    1.26 +* #include <string.h>
    1.27 +* char * strchr(<[string]>, <[c]>);
    1.28 +* char *<[string]>;
    1.29 +* int *<[c]>;
    1.30 +* This function finds the first occurence of <[c]> (converted to
    1.31 +* a char) in the string pointed to by <[string]> (including the
    1.32 +* terminating null character).
    1.33 +* RETURNS
    1.34 +* Returns a pointer to the located character, or a null pointer
    1.35 +* if <[c]> does not occur in <[string]>.
    1.36 +* PORTABILITY
    1.37 +* <<strchr>> is ANSI C.
    1.38 +* <<strchr>> requires no supporting OS subroutines.
    1.39 +* QUICKREF
    1.40 +* strchr ansi pure
    1.41 +* 
    1.42 +*
    1.43 +*/
    1.44 +
    1.45 +
    1.46 +
    1.47 +#include <string.h>
    1.48 +
    1.49 +/**
    1.50 +Find character in string.
    1.51 +Returns the first occurrence of i in string.
    1.52 +The null-terminating character is included as part of the string 
    1.53 +and can also be searched.
    1.54 +@return a pointer to the first occurrence of i in string is returned.
    1.55 +otherwise NULL is returned.
    1.56 +@param s Null-terminated string scanned in the search. 
    1.57 +@param i Character to be found.
    1.58 +*/
    1.59 +EXPORT_C char *
    1.60 +strchr (const char *s, int i)
    1.61 +{
    1.62 +	i = (char)i;
    1.63 +
    1.64 +	for (;;)
    1.65 +	{
    1.66 +		int c = *s++;
    1.67 +		if (c == i)
    1.68 +			return (char *) (s - 1);
    1.69 +		if (c == 0)
    1.70 +			return NULL;
    1.71 +	}
    1.72 +}
    1.73 +
    1.74 +EXPORT_C char *
    1.75 +index (const char *s, int i)
    1.76 +{
    1.77 +    return strchr(s, i);
    1.78 +}