#include #include #include #include #include #include #include "zuncom/common.h" int readline(char *path, size_t size, FILE* fl) { char *pathp; if(!fgets(path, size, fl)) return 1; if(*path) { pathp = path+strlen(path)-1; if(*pathp == '\n') *pathp = '\0'; } return 0; } #define MAX_COUNT 32 #define DATA_SIZE (2+MAX_COUNT*10+2+3) int main(int argc, char** argv) { static char path[MAXPATH+1]; static char names[8*MAX_COUNT]; static int entries[MAX_COUNT+1]; FILE *fl, *fo; int count; int size, stubsize; int pathpos; int i,j; int errval; if(argc != 5) { printf("Usage: zungen zun_stub.bin moveup.bin listfile.txt outfile.bin\n"); return 1; } fl = fopen(argv[3],"r"); if(!fl) { printf("Error: couldn't open listfile: %s\n", strerror(errno)); return 2; } fo = fopen(argv[4],"wb"); if(!fo) { fclose(fl); printf("Error: couldn't open outfile: %s\n", strerror(errno)); return 3; } /* read proc count */ if(readline(path, sizeof(path), fl)) { errval = 4; goto err; } count = atoi(path); if(count < 0 || count > MAX_COUNT) { printf("Error: count is too big!\n"); errval = 5; goto err; } /* write stub and proc count */ append(argv[1], fo); fputw(count, fo); /* read proc names */ memset(names, ' ', sizeof(names)); for(i=0;i