Searching.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
Search Functions for <string.h>.
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Uefi.h>
#include <Library/BaseMemoryLib.h>
#include <LibConfig.h>
#include <limits.h>
#include <string.h>
/** The memchr function locates the first occurrence of c (converted to an
unsigned char) in the initial n characters (each interpreted as
unsigned char) of the object pointed to by s.
@return The memchr function returns a pointer to the located character,
or a null pointer if the character does not occur in the object.
**/
void *
{
}
/** The strchr function locates the first occurrence of c (converted to a char)
in the string pointed to by s. The terminating null character is considered
to be part of the string.
@return The strchr function returns a pointer to the located character,
or a null pointer if the character does not occur in the string.
**/
char *
strchr(const char *s, int c)
{
char tgt = (char)c;
do {
if( *s == tgt) {
return (char *)s;
}
} while(*s++ != '\0');
return NULL;
}
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
};
#define WHICH8(c) ((unsigned char)(c) >> 3)
static
void
{
unsigned char bit;
int index;
// Initialize bitmap. Bit 0 is always 1 which corresponds to '\0'
// Set bits in bitmap corresponding to the characters in s2
}
}
/** The strcspn function computes the length of the maximum initial segment of
the string pointed to by s1 which consists entirely of characters not from
the string pointed to by s2.
@return The strcspn function returns the length of the segment.
**/
{
const char *str;
int index;
if(*s1 == '\0') return 0;
break;
}
}
/** The strpbrk function locates the first occurrence in the string pointed to
by s1 of any character from the string pointed to by s2.
@return The strpbrk function returns a pointer to the character, or a
null pointer if no character from s2 occurs in s1.
**/
char *
{
int index;
return (char *)s1;
}
}
return NULL;
}
/** The strrchr function locates the last occurrence of c (converted to a char)
in the string pointed to by s. The terminating null character is considered
to be part of the string.
@return The strrchr function returns a pointer to the character, or a
null pointer if c does not occur in the string.
**/
char *
strrchr(const char *s, int c)
{
char tgt = (char)c;
do {
} while( *s++ != '\0');
return found;
}
/** The strspn function computes the length of the maximum initial segment of
the string pointed to by s1 which consists entirely of characters from the
string pointed to by s2.
@return The strspn function returns the length of the segment.
**/
{
int index;
++length;
}
return length;
}
/** The strstr function locates the first occurrence in the string pointed to
by s1 of the sequence of characters (excluding the terminating null
character) in the string pointed to by s2.
@return The strstr function returns a pointer to the located string, or a
null pointer if the string is not found. If s2 points to a string
with zero length, the function returns s1.
**/
char *
{
}
/** A sequence of calls to the strtok function breaks the string pointed to by
s1 into a sequence of tokens, each of which is delimited by a character
from the string pointed to by s2. The first call in the sequence has a
non-null first argument; subsequent calls in the sequence have a null first
argument. The separator string pointed to by s2 may be different from call
to call.
The first call in the sequence searches the string pointed to by s1 for the
first character that is not contained in the current separator string
pointed to by s2. If no such character is found, then there are no tokens
in the string pointed to by s1 and the strtok function returns a null
pointer. If such a character is found, it is the start of the first token.
The strtok function then searches from there for a character that is
contained in the current separator string. If no such character is found,
the current token extends to the end of the string pointed to by s1, and
subsequent searches for a token will return a null pointer. If such a
character is found, it is overwritten by a null character, which terminates
the current token. The strtok function saves a pointer to the following
character, from which the next search for a token will start.
Each subsequent call, with a null pointer as the value of the first
argument, starts searching from the saved pointer and behaves as
described above.
@return The strtok function returns a pointer to the first character of a
token, or a null pointer if there is no token.
**/
char *
{
int index;
{
return NULL;
}
// s2 can be different on each call, so build the bitmap each time.
// skip leading delimiters: all chars in s2
}
if( *s1 != 0)
{
// Remember this point, it is the start of the token
// find the next delimiter and replace it with a '\0'
*s1++ = '\0';
return Token;
}
}
}
return Token;
}