2022-01-02 19:28:16 -05:00
|
|
|
#include "FileIO.h"
|
2022-01-03 14:48:50 -05:00
|
|
|
#include "util.h"
|
2022-01-02 19:28:16 -05:00
|
|
|
|
|
|
|
#include <stdint.h> /* uint8_t */
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include <errno.h> /* errno */
|
|
|
|
#include <string.h> /* strerror */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
rc = 1;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
while (argc-- > 1)
|
|
|
|
{
|
|
|
|
FileIO f (argv[argc], "r");
|
|
|
|
std::string buf = f.ReadToString ();
|
|
|
|
if (IsProbablyAscii (buf.c_str (), buf.size ()))
|
|
|
|
printf ("%s", buf.c_str ());
|
|
|
|
else
|
|
|
|
HexDump (buf.c_str (), buf.size ());
|
|
|
|
rc = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (int err)
|
|
|
|
{
|
|
|
|
puts (strerror (errno));
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|