summaryrefslogtreecommitdiffstats
path: root/src/lib/string.C
diff options
context:
space:
mode:
authorMike Jones <mjjones@us.ibm.com>2011-11-10 12:37:48 -0600
committerMIKE J. JONES <mjjones@us.ibm.com>2011-11-10 14:46:24 -0600
commit3038d54f6ca6a2ad945bc072aa34a2a64811829d (patch)
tree4b00ec7bb963efde3cdab04c7e855e2c964962b7 /src/lib/string.C
parentbad2d60def0b66079eacb7ef7c11e2f0dd5420c0 (diff)
downloadtalos-hostboot-3038d54f6ca6a2ad945bc072aa34a2a64811829d.tar.gz
talos-hostboot-3038d54f6ca6a2ad945bc072aa34a2a64811829d.zip
Import ecmdDataBufferBase into HostBoot
Change-Id: I518319bcc06c4f89ee8000762f0e34e9e2af92c3 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/492 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com> Reviewed-by: Thi N. Tran <thi@us.ibm.com>
Diffstat (limited to 'src/lib/string.C')
-rw-r--r--src/lib/string.C36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/lib/string.C b/src/lib/string.C
index fdfa06280..0e1095c63 100644
--- a/src/lib/string.C
+++ b/src/lib/string.C
@@ -122,6 +122,42 @@ extern "C" int memcmp(const void *p1, const void *p2, size_t len)
return 0;
}
+extern "C" void *memmem(const void *haystack, size_t haystacklen,
+ const void *needle, size_t needlelen)
+{
+ const void * result = NULL;
+
+ if (haystacklen >= needlelen)
+ {
+ const char * c_haystack = static_cast<const char *>(haystack);
+ const char * c_needle = static_cast<const char *>(needle);
+ bool match = false;
+
+ for (size_t i = 0; i <= (haystacklen - needlelen); i++)
+ {
+ match = true;
+
+ for (size_t j = 0; j < needlelen; j++)
+ {
+ if (*(c_haystack + i + j) != *(c_needle + j))
+ {
+ match = false;
+ break;
+ }
+ }
+
+ if (match)
+ {
+ result = (c_haystack + i);
+ break;
+ }
+ }
+ }
+
+ return const_cast<void *>(result);
+}
+
+
extern "C" char* strcpy(char* d, const char* s)
{
char* d1 = d;
OpenPOWER on IntegriCloud