diff options
Diffstat (limited to 'tools/gigabeat.c')
-rw-r--r-- | tools/gigabeat.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/gigabeat.c b/tools/gigabeat.c index 863d0741f2..f4d64ea511 100644 --- a/tools/gigabeat.c +++ b/tools/gigabeat.c | |||
@@ -49,6 +49,7 @@ int gigabeat_code(char *infile, char *outfile) | |||
49 | FILE *in, *out; | 49 | FILE *in, *out; |
50 | unsigned long size = 0; | 50 | unsigned long size = 0; |
51 | unsigned long bytes_read; | 51 | unsigned long bytes_read; |
52 | unsigned char buf[4]; | ||
52 | unsigned long data; | 53 | unsigned long data; |
53 | unsigned long key = 0x19751217; | 54 | unsigned long key = 0x19751217; |
54 | 55 | ||
@@ -56,8 +57,11 @@ int gigabeat_code(char *infile, char *outfile) | |||
56 | out = openoutfile(outfile); | 57 | out = openoutfile(outfile); |
57 | 58 | ||
58 | while (!feof(in)) { | 59 | while (!feof(in)) { |
59 | bytes_read = fread(&data, 1, 4, in); | 60 | bytes_read = fread(buf, 1, 4, in); |
60 | 61 | ||
62 | /* Read in little-endian */ | ||
63 | data = le2int(buf); | ||
64 | |||
61 | data = data ^ key; | 65 | data = data ^ key; |
62 | 66 | ||
63 | key = key + (key << 1); | 67 | key = key + (key << 1); |
@@ -65,7 +69,10 @@ int gigabeat_code(char *infile, char *outfile) | |||
65 | 69 | ||
66 | size += bytes_read; | 70 | size += bytes_read; |
67 | 71 | ||
68 | fwrite(&data, 1, bytes_read, out); | 72 | /* Write out little-endian */ |
73 | int2le(data, buf); | ||
74 | |||
75 | fwrite(buf, 1, bytes_read, out); | ||
69 | } | 76 | } |
70 | 77 | ||
71 | fprintf(stderr, "File processed successfully\n" ); | 78 | fprintf(stderr, "File processed successfully\n" ); |