#include #include #include #include #include #include #include "../php_screw.h" #include "../my_screw.h" main(int argc, char**argv) { FILE *fp; struct stat stat_buf; char *datap, *newdatap; int datalen, newdatalen; int cryptkey_len = sizeof pm9screw_mycryptkey / 2; char oldfilename[256]; int i; if (argc != 2) { fprintf(stderr, "Usage: filename.\n"); exit(0); } fp = fopen(argv[1], "r"); if (fp == NULL) { fprintf(stderr, "File not found(%s)\n", argv[1]); exit(0); } fstat(fileno(fp), &stat_buf); datalen = stat_buf.st_size; datap = (char*)malloc(datalen + PM9SCREW_LEN); fread(datap, datalen, 1, fp); fclose(fp); sprintf(oldfilename, "%s.screw", argv[1]); if (memcmp(datap, PM9SCREW, PM9SCREW_LEN) == 0) { fprintf(stderr, "Already Crypted(%s)\n", argv[1]); exit(0); } fp = fopen(oldfilename, "w"); if (fp == NULL) { fprintf(stderr, "Can not create backup file(%s)\n", oldfilename); exit(0); } fwrite(datap, datalen, 1, fp); fclose(fp); newdatap = zencode(datap, datalen, &newdatalen); for(i=0; i