From 8d2199c705efc8a912c0640b8dbe5cc638546363 Mon Sep 17 00:00:00 2001 From: cheapie Date: Sun, 2 Feb 2014 02:12:47 -0500 Subject: added Sparkles source files --- 4hexchat.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 4hexchat.c (limited to '4hexchat.c') diff --git a/4hexchat.c b/4hexchat.c new file mode 100644 index 0000000..956a4a7 --- /dev/null +++ b/4hexchat.c @@ -0,0 +1,40 @@ +#include +#include +#include + +int main(int argc, char *argv[]) { + if(argc < 3){puts("Syntax: 4Hexchat Input Output"); return -1;} + + FILE *File = fopen(argv[1],"rb"); + if(File == NULL) { + fputs("Couldn't open file for reading",stderr); return 0; + } + fseek(File, 0, SEEK_END); + long FileSize = ftell(File); + rewind(File); + char *Buffer = (char*)malloc(sizeof(char)*FileSize); + if(Buffer == NULL) { + fclose(File); + fputs("Can't allocate memory",stderr); return 0; + } + if(FileSize != fread(Buffer,1,FileSize,File)) { + fclose(File); + fputs("Can't read from file",stderr); return 0; + } + fclose(File); + File = fopen(argv[2],"wb"); + if(File == NULL) { + fputs("Couldn't open file for writing",stderr); return 0; + } + + int i; + for(i=0;i