From 70c1e8e5bae373c4660e460703b577336caac8b0 Mon Sep 17 00:00:00 2001 From: Benjamin Dobell Date: Fri, 8 Jul 2011 23:40:28 +1000 Subject: 1.3 beta --- heimdall/source/Interface.cpp | 80 +++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 25 deletions(-) (limited to 'heimdall/source/Interface.cpp') diff --git a/heimdall/source/Interface.cpp b/heimdall/source/Interface.cpp index 35105bb..6c3c58e 100644 --- a/heimdall/source/Interface.cpp +++ b/heimdall/source/Interface.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna +/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -31,12 +31,16 @@ using namespace std; using namespace libpit; using namespace Heimdall; +bool Interface::stdoutErrors = false; + const char *Interface::version = "v1.3 (beta)"; -const char *Interface::usage = "Usage: heimdall [--verbose] [--no-reboot] [--delay ]\n\ +const char *Interface::usage = "Usage: heimdall \n\ +Common Arguments:\n\ + [--verbose] [--no-reboot] [--stdout-errors] [--delay ]\n\ \n\ -action: flash\n\ -arguments:\n\ +Action: flash\n\ +Arguments:\n\ --repartition --pit [--factoryfs ]\n\ [--cache ] [--dbdata ] [--primary-boot ]\n\ [--secondary-boot ] [--param ] [--kernel ]\n\ @@ -53,31 +57,31 @@ arguments:\n\ [--user-data ] [--fota ] [--hidden ]\n\ [--movinand ] [--data ] [--ums ]\n\ [--emmc ] [-- ]\n\ -description: Flashes firmware files to your phone.\n\ +Description: Flashes firmware files to your phone.\n\ WARNING: If you're repartitioning it's strongly recommended you specify\n\ all files at your disposal, including bootloaders.\n\ \n\ -action: close-pc-screen\n\ -description: Attempts to get rid off the \"connect phone to PC\" screen.\n\ +Action: close-pc-screen\n\ +Description: Attempts to get rid off the \"connect phone to PC\" screen.\n\ \n\ -action: detect\n\ -description: Indicates whether or not a download mode device can be detected.\n\ +Action: detect\n\ +Description: Indicates whether or not a download mode device can be detected.\n\ \n\ -action: dump\n\ -arguments: --chip-type --chip-id --output \n\ -description: Attempts to dump data from the phone corresponding to the\n\ +Action: dump\n\ +Arguments: --chip-type --chip-id --output \n\ +Description: Attempts to dump data from the phone corresponding to the\n\ specified chip type and chip ID.\n\ NOTE: Galaxy S phones don't appear to properly support this functionality.\n\ \n\ -action: print-pit\n\ -description: Dumps the PIT file from the connected device and prints it in\n\ +Action: print-pit\n\ +Description: Dumps the PIT file from the connected device and prints it in\n\ a human readable format.\n\ \n\ -action version\n\ -description: Displays the version number of this binary.\n\ +Action version\n\ +Description: Displays the version number of this binary.\n\ \n\ -action: help\n\ -description: Displays this dialogue.\n"; +Action: help\n\ +Description: Displays this dialogue.\n"; const char *Interface::releaseInfo = "Heimdall %s, Copyright (c) 2010-2011, Benjamin Dobell, Glass Echidna\n\ http://www.glassechidna.com.au\n\n\ @@ -123,11 +127,11 @@ string Interface::commonValueShortArguments[kCommonValueArgCount] = { }; string Interface::commonValuelessArguments[kCommonValuelessArgCount] = { - "-verbose", "-no-reboot" + "-verbose", "-no-reboot", "-stdout-errors" }; string Interface::commonValuelessShortArguments[kCommonValuelessArgCount] = { - "v", "nobt" + "v", "nobt", "err" }; Action Interface::actions[Interface::kActionCount] = { @@ -319,23 +323,49 @@ bool Interface::GetArguments(int argc, char **argv, map& argumen void Interface::Print(const char *format, ...) { va_list args; - va_start(args, format); + vfprintf(stdout, format, args); - va_end(args); + fflush(stdout); - fflush(stdout); // Make sure output isn't buffered. + va_end(args); + } void Interface::PrintError(const char *format, ...) { va_list args; - va_start(args, format); + + fprintf(stderr, "ERROR: "); vfprintf(stderr, format, args); + fflush(stderr); + + if (stdoutErrors) + { + fprintf(stdout, "ERROR: "); + vfprintf(stdout, format, args); + fflush(stdout); + } + va_end(args); +} + +void Interface::PrintErrorSameLine(const char *format, ...) +{ + va_list args; + va_start(args, format); - fflush(stderr); // Make sure output isn't buffered. + vfprintf(stderr, format, args); + fflush(stderr); + + if (stdoutErrors) + { + vfprintf(stdout, format, args); + fflush(stdout); + } + + va_end(args); } void Interface::PrintVersion(void) -- cgit v1.1