summaryrefslogtreecommitdiffstats
path: root/heimdall/source/Interface.h
diff options
context:
space:
mode:
authorBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2012-10-01 04:43:05 +0200
committerBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2012-10-01 17:41:25 +0200
commit6cd6b35c737e0e4042a8fd79af1decc9f10ed84b (patch)
tree89625119662474ef30c84f410c056343d412121b /heimdall/source/Interface.h
parentUpdated version to 1.3.2 and copyright notices to 2012. (diff)
downloadHeimdall-6cd6b35c737e0e4042a8fd79af1decc9f10ed84b.tar
Heimdall-6cd6b35c737e0e4042a8fd79af1decc9f10ed84b.tar.gz
Heimdall-6cd6b35c737e0e4042a8fd79af1decc9f10ed84b.tar.bz2
Heimdall-6cd6b35c737e0e4042a8fd79af1decc9f10ed84b.tar.lz
Heimdall-6cd6b35c737e0e4042a8fd79af1decc9f10ed84b.tar.xz
Heimdall-6cd6b35c737e0e4042a8fd79af1decc9f10ed84b.tar.zst
Heimdall-6cd6b35c737e0e4042a8fd79af1decc9f10ed84b.zip
Diffstat (limited to '')
-rw-r--r--heimdall/source/Interface.h281
1 files changed, 30 insertions, 251 deletions
diff --git a/heimdall/source/Interface.h b/heimdall/source/Interface.h
index ddb7f55..ab4b538 100644
--- a/heimdall/source/Interface.h
+++ b/heimdall/source/Interface.h
@@ -28,276 +28,55 @@
// libpit
#include "libpit.h"
+// Heimdall
+#include "Heimdall.h"
+
using namespace std;
using namespace libpit;
namespace Heimdall
{
- struct Action
+ namespace Interface
{
- public:
-
- string name;
-
- string *valueArguments;
- string *valueShortArguments;
- unsigned int valueArgumentCount;
+ typedef int (*ActionExecuteFunction)(int, char **);
- string *valuelessArguments;
- string *valuelessShortArguments;
- unsigned int valuelessArgumentCount;
+ typedef struct ActionInfo
+ {
+ ActionExecuteFunction executeFunction;
+ const char *usage;
- Action(const char *name, string *valueArguments, string *valueShortArguments, unsigned int valueArgumentCount,
- string *valuelessArguments, string *valuelessShortArguments, unsigned int valuelessArgumentCount)
+ ActionInfo()
{
- this->name = name;
-
- this->valueArguments = valueArguments;
- this->valueShortArguments = valueShortArguments;
- this->valueArgumentCount = valueArgumentCount;
-
- this->valuelessArguments = valuelessArguments;
- this->valuelessShortArguments = valuelessShortArguments;
- this->valuelessArgumentCount = valuelessArgumentCount;
+ executeFunction = nullptr;
+ usage = nullptr;
}
- };
-
- class Interface
- {
- public:
-
- // Actions
- enum
- {
- kActionFlash = 0,
- kActionClosePcScreen,
- kActionDump,
- kActionPrintPit,
- kActionVersion,
- kActionHelp,
- kActionDetect,
- kActionDownloadPit,
- kActionInfo,
- kActionCount
- };
- // Flash value arguments
- enum
+ ActionInfo(ActionExecuteFunction executeFunction, const char *usage)
{
- kFlashValueArgPit,
- kFlashValueArgFactoryFs,
- kFlashValueArgCache,
- kFlashValueArgDatabaseData,
- kFlashValueArgPrimaryBootloader,
- kFlashValueArgSecondaryBootloader,
- kFlashValueArgSecondaryBootloaderBackup,
- kFlashValueArgParam,
- kFlashValueArgKernel,
- kFlashValueArgRecovery,
- kFlashValueArgEfs,
- kFlashValueArgModem,
-
- kFlashValueArgNormalBoot,
- kFlashValueArgSystem,
- kFlashValueArgUserData,
- kFlashValueArgFota,
- kFlashValueArgHidden,
- kFlashValueArgMovinand,
- kFlashValueArgData,
- kFlashValueArgUms,
- kFlashValueArgEmmc,
-
- kFlashValueArgPartitionIndex,
-
- kFlashValueArgCount
- };
-
- // Flash valueless arguments
- enum
- {
- kFlashValuelessArgRepartition = 0,
-
- kFlashValuelessArgCount
- };
-
- // Close PC Screen value arguments
- enum
- {
- kClosePcScreenValueArgCount = 0
- };
-
- // Close PC Screen valueless arguments
- enum
- {
- kClosePcScreenValuelessArgCount = 0
- };
-
- // Dump value arguments
- enum
- {
- kDumpValueArgChipType = 0,
- kDumpValueArgChipId,
- kDumpValueArgOutput,
-
- kDumpValueArgCount
- };
-
- // Dump valueless arguments
- enum
- {
- kDumpValuelessArgCount = 0
- };
-
- // Print PIT value arguments
- enum
- {
- kPrintPitValueArgCount = 0
- };
-
- // Print PIT valueless arguments
- enum
- {
- kPrintPitValuelessArgCount = 0
- };
-
- // Version value arguments
- enum
- {
- kVersionValueArgCount = 0
- };
-
- // Version valueless arguments
- enum
- {
- kVersionValuelessArgCount = 0
- };
-
- // Help value arguments
- enum
- {
- kHelpValueArgCount = 0
- };
-
- // Help valueless arguments
- enum
- {
- kHelpValuelessArgCount = 0
- };
-
- // Info value arguments
- enum
- {
- kInfoValueArgCount = 0
- };
-
- // Info valueless arguments
- enum
- {
- kInfoValuelessArgCount = 0
- };
-
- // Detect value arguments
- enum
- {
- kDetectValueArgCount = 0
- };
-
- // Detect valueless arguments
- enum
- {
- kDetectValuelessArgCount = 0
- };
-
- // Download PIT value arguments
- enum
- {
- kDownloadPitValueArgOutput = 0,
- kDownloadPitValueArgCount
- };
-
- // Download PIT valueless arguments
- enum
- {
- kDownloadPitValuelessArgCount = 0
- };
-
- // Common value arguments
- enum
- {
- kCommonValueArgDelay = 0,
-
- kCommonValueArgCount
- };
-
- // Comon valueless arguments
- enum
- {
- kCommonValuelessArgVerbose = 0,
- kCommonValuelessArgNoReboot,
- kCommonValuelessArgStdoutErrors,
-
- kCommonValuelessArgCount
- };
-
- private:
-
- static bool stdoutErrors;
-
- static const char *version;
- static const char *usage;
- static const char *releaseInfo;
- static const char *extraInfo;
-
- // Flash arguments
- static string flashValueArguments[kFlashValueArgCount];
- static string flashValueShortArguments[kFlashValueArgCount];
-
- static string flashValuelessArguments[kFlashValuelessArgCount];
- static string flashValuelessShortArguments[kFlashValuelessArgCount];
-
- // Download PIT arguments
- static string downloadPitValueArguments[kDownloadPitValueArgCount];
- static string downloadPitValueShortArguments[kDownloadPitValueArgCount];
-
- // Dump arguments
- static string dumpValueArguments[kDumpValueArgCount];
- static string dumpValueShortArguments[kDumpValueArgCount];
-
- public:
-
- // Common arguments
- static string commonValueArguments[kCommonValueArgCount];
- static string commonValueShortArguments[kCommonValueArgCount];
-
- static string commonValuelessArguments[kCommonValuelessArgCount];
- static string commonValuelessShortArguments[kCommonValuelessArgCount];
-
- static Action actions[kActionCount];
+ this->executeFunction = executeFunction;
+ this->usage = usage;
+ }
- static bool GetArguments(int argc, char **argv, map<string, string>& argumentMap, int *actionIndex);
+ } ActionInfo;
- static void Print(const char *format, ...);
- static void PrintError(const char *format, ...);
- static void PrintErrorSameLine(const char *format, ...);
+ const map<string, ActionInfo>& GetActionMap(void);
- static void PrintVersion(void);
- static void PrintUsage(void);
- static void PrintReleaseInfo(void);
- static void PrintFullInfo(void);
+ void Print(const char *format, ...);
+ void PrintWarning(const char *format, ...);
+ void PrintWarningSameLine(const char *format, ...);
+ void PrintError(const char *format, ...);
+ void PrintErrorSameLine(const char *format, ...);
- static void PrintDeviceDetectionFailed(void);
+ void PrintVersion(void);
+ void PrintUsage(void);
+ void PrintReleaseInfo(void);
+ void PrintFullInfo(void);
- static void PrintPit(const PitData *pitData);
+ void PrintDeviceDetectionFailed(void);
- static string& GetPitArgument(void)
- {
- return (flashValueArguments[kFlashValueArgPit]);
- }
+ void PrintPit(const PitData *pitData);
- static void SetStdoutErrors(bool enabled)
- {
- stdoutErrors = enabled;
- }
+ void SetStdoutErrors(bool enabled);
};
}