palremap.c 523 B

1234567891011121314151617181920212223242526272829
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. int main(int argc, char **argv) {
  4. if(argc<3) {
  5. fprintf(stderr, "Usage: %s <infile> <outfile>\n", argv[0]);
  6. return 1;
  7. }
  8. FILE *in, *out;
  9. if((in=fopen(argv[1], "rb"))==NULL) {
  10. perror("Could not open input file");
  11. return 1;
  12. }
  13. if((out=fopen(argv[2], "wb"))==NULL) {
  14. perror("Could not open output file");
  15. return 1;
  16. }
  17. while(1) {
  18. uint8_t c=fgetc(in);
  19. if(feof(in))break;
  20. if(c>=1 && c<=43) {
  21. c+=212;
  22. }
  23. fputc(c, out);
  24. }
  25. fclose(out);
  26. fclose(in);
  27. return 0;
  28. }