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: * <<strstr>>---find string segment
sl@0: * INDEX
sl@0: * strstr
sl@0: * ANSI_SYNOPSIS
sl@0: * #include <string.h>
sl@0: * char *strstr(const char *<[s1]>, const char *<[s2]>);
sl@0: * TRAD_SYNOPSIS
sl@0: * #include <string.h>
sl@0: * char *strstr(<[s1]>, <[s2]>)
sl@0: * char *<[s1]>;
sl@0: * char *<[s2]>;
sl@0: * Locates the first occurence in the string pointed to by <[s1]> of
sl@0: * the sequence of characters in the string pointed to by <[s2]>
sl@0: * (excluding the terminating null  character).
sl@0: * RETURNS
sl@0: * Returns a pointer to the located string segment, or a null
sl@0: * pointer if the string <[s2]> is not found. If <[s2]> points to
sl@0: * a string with zero length, the <[s1]> is returned.
sl@0: * PORTABILITY
sl@0: * <<strstr>> is ANSI C.
sl@0: * <<strstr>> requires no supporting OS subroutines.
sl@0: * QUICKREF
sl@0: * strstr ansi pure
sl@0: * 
sl@0: *
sl@0: */
sl@0: 
sl@0: 
sl@0: 
sl@0: #include <string.h>
sl@0: 
sl@0: /**
sl@0: Find substring.
sl@0: Scans string1 for the first occurrence of string2.
sl@0: The search does not include terminating null-characters.
sl@0: @return A pointer to the first occurrence of lookfor in searchee.
sl@0: If lookfor is not found in searchee the function returns NULL.
sl@0: @param searchee Null-terminated string to search. 
sl@0: @param lookfor Null-terminated string containing the substring to search for.
sl@0: */
sl@0: EXPORT_C char *
sl@0: strstr (const char *searchee, const char *lookfor)
sl@0: {
sl@0:   if (*searchee == 0)
sl@0:     {
sl@0:       if (*lookfor)
sl@0: 	return (char *) NULL;
sl@0:       return (char *) searchee;
sl@0:     }
sl@0: 
sl@0:   while (*searchee)
sl@0:     {
sl@0:       size_t i;
sl@0:       i = 0;
sl@0: 
sl@0:       for (;;)
sl@0: 	{
sl@0: 	  if (lookfor[i] == 0)
sl@0: 	    {
sl@0: 	      return (char *) searchee;
sl@0: 	    }
sl@0: 
sl@0: 	  if (lookfor[i] != searchee[i])
sl@0: 	    {
sl@0: 	      break;
sl@0: 	    }
sl@0: 	  i++;
sl@0: 	}
sl@0:       searchee++;
sl@0:     }
sl@0: 
sl@0:   return (char *) NULL;
sl@0: }