/* * Dump the manifest to a text file. */ void manifest_print (manifest_t *m) { void *cursor; char *path, *link; int filetype, mode, owner, group, major, minor; cursor = 0; while ((filetype = manifest_iterate (m, &cursor, &path, &link, &mode, &owner, &group, &major, &minor)) != 0) { switch (filetype) { case 'd': /* Directory. */ printf ("\ndir %s\n", path); break; case 'f': /* Regular file. */ printf ("\nfile %s\n", path); break; case 'l': /* Hard link to file. */ printf ("\nlink %s\n", path); printf ("target %s\n", link); continue; case 's': /* Symlink. */ printf ("\nsymlink %s\n", path); printf ("target %s\n", link); break; case 'b': /* Block device. */ printf ("\nbdev %s\n", path); printf ("major %u\n", major); printf ("minor %u\n", minor); break; case 'c': /* Character device. */ printf ("\ncdev %s\n", path); printf ("major %u\n", major); printf ("minor %u\n", minor); break; default: /* Ignore all other variants. */ continue; } printf ("mode %#o\n", mode); printf ("owner %u\n", owner); printf ("group %u\n", group); } }
int parseJarFile(const char* name, int attributeCount, char** attributes, char**values) { iterationContext context; int i, rc; context.attributeCount = attributeCount; context.attributes = attributes; context.values = values; for (i=0; i<attributeCount; i++) { values[i] = NULL; } rc = manifest_iterate(name, doAttribute, (void*)&context); return (rc == 0) ? 0 : -1; }