sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * FUNCTION sl@0: * <>---find character in memory sl@0: * INDEX sl@0: * memchr sl@0: * ANSI_SYNOPSIS sl@0: * #include sl@0: * void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>); sl@0: * TRAD_SYNOPSIS sl@0: * #include sl@0: * void *memchr(<[src]>, <[c]>, <[length]>) sl@0: * void *<[src]>; sl@0: * void *<[c]>; sl@0: * size_t <[length]>; sl@0: * This function searches memory starting at <<*<[src]>>> for the sl@0: * character <[c]>. The search only ends with the first sl@0: * occurrence of <[c]>, or after <[length]> characters; in sl@0: * particular, <> does not terminate the search. sl@0: * RETURNS sl@0: * If the character <[c]> is found within <[length]> characters sl@0: * of <<*<[src]>>>, a pointer to the character is returned. If sl@0: * <[c]> is not found, then <> is returned. sl@0: * PORTABILITY sl@0: * <>> is ANSI C. sl@0: * <> requires no supporting OS subroutines. sl@0: * QUICKREF sl@0: * memchr ansi pure sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include <_ansi.h> sl@0: #include sl@0: sl@0: /** sl@0: Search buffer for a character. sl@0: Searches the first num bytes of memory block pointed by src_void for character c. sl@0: @return A pointer to the first occurrence of c in buffer. sl@0: If character is not found the function returns NULL. sl@0: @param src_void Pointer to buffer. sl@0: @param c Key character to look for. sl@0: @param length Number of characters to check from buffer. sl@0: */ sl@0: EXPORT_C void * sl@0: memchr (const void* src_void, int c, size_t length) sl@0: { sl@0: const unsigned char *src = (const unsigned char *) src_void; sl@0: sl@0: while (length--) sl@0: { sl@0: if (*src == c) sl@0: return (char *) src; sl@0: src++; sl@0: } sl@0: return NULL; sl@0: }