Hi,
Thanks to pbos help and its program (published here, for xoring a big file), I performed some tests and I see that I have another problem: having changed the mask by another one of 128-bit, there is no default type as big as needed.
I think a solution can be to include a library to increase available integer types... but rather that I prefer to interpret each 128 bits values such as strings. Is this possible without loosing performance?
Here is the current program (with the bug "integer constant is too large for its type"):
#include <stdio.h>
#include <stdlib.h>
#define BLOCKSIZE 128
#define MASK 0xA37c54f173f02889a64be02f2bc44112 /* a 128 bits constant */
void
usage(const char *cmd)
{
fprintf(stderr, "Usage: %s <in-file> [<out-file>]\n", cmd);
exit (EXIT_FAILURE);
}
int
main(int argc, char *argv[])
{
if (argc < 3) usage(argv[0]);
FILE *in = fopen(argv[1], "rb");
if (in == NULL)
{
printf("Cannot open: %s", argv[2]);
return EXIT_FAILURE;
}
FILE *out = fopen(argv[2], "wb");
if (out == NULL)
{
fclose(in);
printf("Unable to open '%s' for writing.", argv[2]);
}
char buffer[BLOCKSIZE];
int count;
while (count = fread(buffer, 1, BLOCKSIZE, in))
{
int i;
for (i = 0; i < count; i++)
{
((unsigned long *)buffer)[i] ^= MASK; /* this line is bugged */
}
if (fwrite(buffer, 1, count, out) != count)
{
fclose(in);
fclose(out);
printf("Cannot write, disk full?\n");
return EXIT_FAILURE;
}
}
fclose(in);
fclose(out);
return EXIT_SUCCESS;
}
Thank for any suggestions.
Doug