Upload Apkdiff Module Source Code
This commit is contained in:
26
apkdiff/third_party/zlib/contrib/puff/bin-writer.c
vendored
Normal file
26
apkdiff/third_party/zlib/contrib/puff/bin-writer.c
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
/**
|
||||
* Reads hexadecimal values from stdin and writes binary bytes to stdout.
|
||||
* Accepts hex values separated by spaces, newlines, commas, etc.
|
||||
* Handles both uppercase and lowercase hex digits.
|
||||
*/
|
||||
int main(void) {
|
||||
char hexStr[3]; // Two hex digits + null terminator
|
||||
int ch;
|
||||
|
||||
// Read characters until EOF
|
||||
while((ch = getchar()) != EOF) {
|
||||
hexStr[0] = (char)ch;
|
||||
hexStr[1] = (char)getchar();
|
||||
hexStr[2] = '\0'; // Null-terminate string
|
||||
char *endptr;
|
||||
unsigned char byte = (unsigned char)strtol(hexStr, &endptr, 16);
|
||||
fwrite(&byte, 1, 1, stdout);
|
||||
if((ch = getchar()) == EOF) // Read seaparating space
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user