From b125097a0715da4309b54aee7b32bc9a79f2c01b Mon Sep 17 00:00:00 2001 From: Denis Ahrens Date: Thu, 31 Jan 2013 20:31:11 +0100 Subject: [PATCH] add support for the sp78 format --- smc-command/smc.c | 7 +++++++ smc-command/smc.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/smc-command/smc.c b/smc-command/smc.c index 9b46a1c..9a17e4a 100644 --- a/smc-command/smc.c +++ b/smc-command/smc.c @@ -87,6 +87,11 @@ void printUInt(SMCVal_t val) printf("%u ", (unsigned int) _strtoul(val.bytes, val.dataSize, 10)); } +void printSP78(SMCVal_t val) +{ + printf("%u.%02u ", *val.bytes, (*(val.bytes+1)) * 100 / 256); +} + void printBytesHex(SMCVal_t val) { int i; @@ -108,6 +113,8 @@ void printVal(SMCVal_t val) printUInt(val); else if (strcmp(val.dataType, DATATYPE_FPE2) == 0) printFPE2(val); + else if (strcmp(val.dataType, DATATYPE_SP78) == 0 && val.dataSize == 2) + printSP78(val); printBytesHex(val); } diff --git a/smc-command/smc.h b/smc-command/smc.h index f001abf..b6f57ac 100644 --- a/smc-command/smc.h +++ b/smc-command/smc.h @@ -42,6 +42,7 @@ #define DATATYPE_UINT8 "ui8 " #define DATATYPE_UINT16 "ui16" #define DATATYPE_UINT32 "ui32" +#define DATATYPE_SP78 "sp78" typedef struct { char major; @@ -65,7 +66,7 @@ typedef struct { char dataAttributes; } SMCKeyData_keyInfo_t; -typedef char SMCBytes_t[32]; +typedef unsigned char SMCBytes_t[32]; typedef struct { UInt32 key;