removed trailing spaces ([[:space:]]+$)
[strongswan.git] / src / checksum / checksum_builder.c
index d2c042d..54f4539 100644 (file)
@@ -28,14 +28,14 @@ int main(int argc, char* argv[])
 {
        int i;
        integrity_checker_t *integrity;
-       
+
        /* avoid confusing leak reports in build process */
        setenv("LEAK_DETECTIVE_DISABLE", "1", 0);
        library_init(NULL);
        atexit(library_deinit);
-       
+
        integrity = integrity_checker_create(NULL);
-       
+
        printf("/**\n");
        printf(" * checksums of files and loaded code segments.\n");
        printf(" * created by %s\n", argv[0]);
@@ -44,14 +44,18 @@ int main(int argc, char* argv[])
        printf("#include <library.h>\n");
        printf("\n");
        printf("integrity_checksum_t checksums[] = {\n");
+       fprintf(stderr, "integrity test data:\n");
+       fprintf(stderr, "module name,       file size / checksum   segment size / checksum\n");
        for (i = 1; i < argc; i++)
        {
                char *name, *path, *sname = NULL;
                void *handle, *symbol;
                u_int32_t fsum, ssum;
-               
+               size_t fsize = 0;
+               size_t ssize = 0;
+
                path = argv[i];
-               
+
                if ((name = strstr(path, "libstrongswan-")))
                {
                        name = strdup(name + strlen("libstrongswan-"));
@@ -65,6 +69,10 @@ int main(int argc, char* argv[])
                        name = strdup("libstrongswan\",");
                        sname = "library_init";
                }
+               else if (strstr(path, "pool"))
+               {
+                       name = strdup("pool\",");
+               }
                else if (strstr(path, "charon"))
                {
                        name = strdup("charon\",");
@@ -73,13 +81,25 @@ int main(int argc, char* argv[])
                {
                        name = strdup("pluto\",");
                }
+               else if (strstr(path, "openac"))
+               {
+                       name = strdup("openac\",");
+               }
+               else if (strstr(path, "scepclient"))
+               {
+                       name = strdup("scepclient\",");
+               }
+               else if (strstr(path, "pki"))
+               {
+                       name = strdup("pki\",");
+               }
                else
                {
                        fprintf(stderr, "don't know how to handle '%s', ignored", path);
                        continue;
                }
-               
-               fsum = integrity->build_file(integrity, path);
+
+               fsum = integrity->build_file(integrity, path, &fsize);
                ssum = 0;
                if (sname)
                {
@@ -89,7 +109,7 @@ int main(int argc, char* argv[])
                                symbol = dlsym(handle, sname);
                                if (symbol)
                                {
-                                       ssum = integrity->build_segment(integrity, symbol);
+                                       ssum = integrity->build_segment(integrity, symbol, &ssize);
                                }
                                else
                                {
@@ -102,7 +122,10 @@ int main(int argc, char* argv[])
                                fprintf(stderr, "dlopen failed: %s\n", dlerror());
                        }
                }
-               printf("\t{\"%-20s0x%08x, 0x%08x},\n", name, fsum, ssum);
+               printf("\t{\"%-20s%7u, 0x%08x, %6u, 0x%08x},\n",
+                          name, fsize, fsum, ssize, ssum);
+               fprintf(stderr, "\"%-20s%7u / 0x%08x       %6u / 0x%08x\n",
+                               name, fsize, fsum, ssize, ssum);
                free(name);
        }
        printf("};\n");
@@ -110,7 +133,7 @@ int main(int argc, char* argv[])
        printf("int checksum_count = countof(checksums);\n");
        printf("\n");
        integrity->destroy(integrity);
-       
+
        exit(0);
 }