Add helper functions and files for gpt tests.

Review URL: http://codereview.chromium.org/1729006
diff --git a/cgptlib/cgpt.c b/cgptlib/cgpt.c
index 4504a61..4865473 100644
--- a/cgptlib/cgpt.c
+++ b/cgptlib/cgpt.c
@@ -4,24 +4,42 @@
  */
 
 #include "cgpt.h"
+#include <string.h>
+#include "gpt.h"
+#include "utility.h"
 
 /* stub code */
 static int start[] = { 34, 10034 };
 
-int GPTInit(GPTData_t *gpt) {
+int GptInit(GptData_t *gpt) {
+  int valid_headers[2] = {1, 1};
+
+  /* check header signature */
+  if (Memcmp(gpt->primary_header, GPT_HEADER_SIGNATURE,
+                                  GPT_HEADER_SIGNATURE_SIZE))
+    valid_headers[0] = 0;
+  if (Memcmp(gpt->secondary_header, GPT_HEADER_SIGNATURE,
+                                  GPT_HEADER_SIGNATURE_SIZE))
+    valid_headers[1] = 0;
+
+  if (!valid_headers[0] && !valid_headers[1])
+    return GPT_ERROR_INVALID_HEADERS;
+
   gpt->current_kernel = 1;
-  return 0;
+  return GPT_SUCCESS;
 }
 
-int GPTNextKernelEntry(GPTData_t *gpt, uint64_t *start_sector, uint64_t *size) {
+int GptNextKernelEntry(GptData_t *gpt, uint64_t *start_sector, uint64_t *size) {
+  /* FIXME: the following code is not really code, just returns anything */
   gpt->current_kernel ^= 1;
   if (start_sector) *start_sector = start[gpt->current_kernel];
   if (size) *size = 10000;
-  return 0;
+  return GPT_SUCCESS;
 }
 
-int GPTUpdateKernelEntry(GPTData_t *gpt, uint32_t update_type) {
+int GptUpdateKernelEntry(GptData_t *gpt, uint32_t update_type) {
+  /* FIXME: the following code is not really code, just return anything */
   gpt->modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1) <<
                    gpt->current_kernel;
-  return 0;
+  return GPT_SUCCESS;
 }