Skip to content

Instantly share code, notes, and snippets.

@reportbase
Created March 22, 2015 20:59
Show Gist options
  • Save reportbase/eda77ab2bf95aa9eebea to your computer and use it in GitHub Desktop.
Save reportbase/eda77ab2bf95aa9eebea to your computer and use it in GitHub Desktop.
echo binary file to octal
inline void echo_bin_octal(const char*, const char* path, void* app_, node<message*>** errors)
{
int size;
unsigned char* buffer = load_binary(path, &size, errors);
if(*errors)
{
push_message(errors, 0, 0, 1, __FILE__, __FUNCTION__, __LINE__, "bad path: %s", path);
return;
}
fprintf(stdout, "%s\n", path);
for(unsigned long n = 0; n < size; ++n)
fprintf(stdout, "\\%o", buffer[n]);
fprintf(stdout, "\n\n");
free(buffer);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment