diff options
author | cheapie <no-email-for-you@example.com> | 2014-02-02 02:12:47 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2014-02-02 02:12:47 -0500 |
commit | 8d2199c705efc8a912c0640b8dbe5cc638546363 (patch) | |
tree | af7633652801a53c83ac8a3a025e94e61c44f3cc /4hexchat.c | |
parent | c1b95b0468bf79528fe4d165a9c8025684da69da (diff) | |
download | sparkles-8d2199c705efc8a912c0640b8dbe5cc638546363.tar sparkles-8d2199c705efc8a912c0640b8dbe5cc638546363.tar.gz sparkles-8d2199c705efc8a912c0640b8dbe5cc638546363.tar.bz2 sparkles-8d2199c705efc8a912c0640b8dbe5cc638546363.tar.xz sparkles-8d2199c705efc8a912c0640b8dbe5cc638546363.zip |
added Sparkles source files
Diffstat (limited to '4hexchat.c')
-rw-r--r-- | 4hexchat.c | 40 |
1 files changed, 40 insertions, 0 deletions
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 <stdio.h> +#include <string.h> +#include <stdlib.h> + +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<FileSize;i++) { + if(!memcmp(&Buffer[i], "xchat_", 6) && Buffer[i-1] != 'e') fprintf(File, "he"); + if(!memcmp(&Buffer[i], "xchat-", 6) && Buffer[i-1] != 'e') fprintf(File, "he"); + if(!memcmp(&Buffer[i], "XCHAT_", 6) && Buffer[i-1] != 'E') fprintf(File, "HE"); + fputc(Buffer[i], File); + } + fclose(File); + free(Buffer); + return 1; +} |