2 * Written 1999 Jan 29 by Josh Cogliati
3 * Modified by Bradley Bell, 2002, 2003
4 * This program is licensed under the terms of the GPL, version 2 or later
14 #include <sys/types.h>
19 #define SWAPINT(x) (((x)<<24) | (((uint)(x)) >> 24) | (((x) &0x0000ff00) << 8) | (((x) & 0x00ff0000) >> 8))
22 main(int argc, char *argv[])
24 FILE *hogfile, *readfile;
33 printf("Usage: hogcreate hogfile\n"
34 "creates hogfile using all the files in the current directory\n");
37 hogfile = fopen(argv[1], "wb");
38 buf = (char *)malloc(3);
39 strncpy(buf, "DHF", 3);
40 fwrite(buf, 3, 1, hogfile);
41 printf("Creating: %s\n", argv[1]);
45 while ((ep = readdir(dp))) {
46 if (strlen(ep->d_name) > 12) {
47 fprintf(stderr, "error: filename %s too long! (12 chars max!)\n", ep->d_name);
50 memset(filename, 0, 13);
51 strcpy(filename, ep->d_name);
52 stat(filename, &statbuf);
53 if(! S_ISDIR(statbuf.st_mode)) {
54 printf("Filename: %s \tLength: %i\n", filename, (int)statbuf.st_size);
55 readfile = fopen(filename, "rb");
56 buf = (char *)malloc(statbuf.st_size);
58 printf("Unable to allocate memery\n");
60 fwrite(filename, 13, 1, hogfile);
61 tmp = (int)statbuf.st_size;
62 #ifdef WORDS_BIGENDIAN
65 fwrite(&tmp, 4, 1, hogfile);
66 fread(buf, statbuf.st_size, 1, readfile);
67 fwrite(buf, statbuf.st_size, 1, hogfile);