aboutsummaryrefslogtreecommitdiffstats
path: root/bba/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'bba/main.cc')
-rw-r--r--bba/main.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/bba/main.cc b/bba/main.cc
index 32a68c63..b9cf6d8e 100644
--- a/bba/main.cc
+++ b/bba/main.cc
@@ -66,11 +66,17 @@ const char *skipWhitespace(const char *p)
return p;
}
+bool testBigEndian()
+{
+ int n = 1;
+ return !*(const char *)&n;
+}
+
int main(int argc, char **argv)
{
bool debug = false;
bool verbose = false;
- bool bigEndian = false;
+ bool bigEndian;
bool writeC = false;
char buffer[512];
@@ -81,6 +87,7 @@ int main(int argc, char **argv)
options.add_options()("verbose,v", "verbose output");
options.add_options()("debug,d", "debug output");
options.add_options()("be,b", "big endian");
+ options.add_options()("le,l", "little endian");
options.add_options()("c,c", "write c strings");
options.add_options()("files", po::value<std::vector<std::string>>(), "file parameters");
pos.add("files", -1);
@@ -106,6 +113,10 @@ int main(int argc, char **argv)
debug = true;
if (vm.count("be"))
bigEndian = true;
+ else if (vm.count("le"))
+ bigEndian = false;
+ else
+ bigEndian = testBigEndian();
if (vm.count("c"))
writeC = true;