xolatilization/xop.c

44 lines
797 B
C
Executable File

#include <xolatile/xtandard.h>
static procedure echo_byte (natural_8 byte) {
output ("0123456789ABCDEF" + byte / 16, 1);
output ("0123456789ABCDEF" + byte % 16, 1);
output (" ", 1);
}
integer main (integer argc, character * * argv) {
integer file = 0;
caliber size = 0;
natural_8 * buffer = null;
if (argc != 2) {
print ("> xop input_file\n");
return (log_failure);
}
file = file_open (argv [1], file_flag_read);
size = file_size (argv [1]);
buffer = allocate (size * sizeof (* buffer));
file_read (file, buffer, size);
file = file_close (file);
for (caliber offset = 0; offset < size; ++offset) {
if (buffer [offset] == 0x90) {
echo ("\n");
}
echo_byte (buffer [offset]);
}
echo ("\n");
buffer = deallocate (buffer);
return (log_success);
}