Index: host/lib/fmap.c |
diff --git a/host/lib/fmap.c b/host/lib/fmap.c |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c2e28ec3deb12823a6b50ddb608204d774c28087 |
--- /dev/null |
+++ b/host/lib/fmap.c |
@@ -0,0 +1,31 @@ |
+/* |
+ * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#include <stdio.h> |
+#include <string.h> |
+ |
+#include "fmap.h" |
+ |
+/* Return NULL if fail */ |
gauravsh
2011/02/10 20:02:05
remove this comment - since you already document t
Che-Liang Chiou
2011/02/14 02:27:53
Done.
|
+const char *FindFmap(const char *ptr, size_t size) |
gauravsh
2011/02/10 20:02:05
const char*
Che-Liang Chiou
2011/02/14 02:27:53
Done.
|
+{ |
+ size_t i; |
+ for (i=0; i<size; i += FMAP_SEARCH_STRIDE) { |
+ if (0 == strncmp(ptr, "__FMAP__", 8)) |
Randall Spangler
2011/02/11 17:26:04
Seems like "__FMAP__" should be a const string or
Che-Liang Chiou
2011/02/14 02:27:53
Done.
|
+ return ptr; |
+ ptr += FMAP_SEARCH_STRIDE; |
+ } |
+ return NULL; |
+} |
+ |
+int FmapAreaIndex(const FmapHeader* fh, const FmapAreaHeader* ah, |
+ const char* name) { |
+ int i; |
+ for (i = 0; i < fh->fmap_nareas; i++) |
+ if (!strcmp((const char*) ah[i].area_name, name)) |
+ return i; |
+ return -1; |
+} |