Created
September 22, 2020 10:12
-
-
Save Hermann-SW/c6ecb46b6727e60bdc866756d9b4e164 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <assert.h> | |
#define N (32768+18580480) | |
int main(int argc, char* argv[]) | |
{ | |
FILE *src; | |
char c, *buf; | |
assert( argc == 2 ); | |
assert( (src = fopen(argv[1], "rb")) ); | |
assert( (buf = malloc(N)) ); | |
assert( buf == memcpy(buf, "BRCM", 4) ); | |
while (1) | |
{ | |
while (!feof(src) && fgetc(src) != 'B') {} | |
if (feof(src)) return 1; | |
if ((c = fgetc(src)) == 'R') | |
if ((c = fgetc(src)) == 'C') | |
if ((c = fgetc(src)) == 'M') | |
{ | |
assert(1 == fread(buf+4, N-4, 1, src)); | |
assert(1 == fwrite(buf, N, 1, stdout)); | |
return 0; | |
} | |
assert(c == ungetc(c, src)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=286001&p=1730777#p1730777