mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
make style
This commit is contained in:
parent
99eadded05
commit
7cd509c77c
3 changed files with 117 additions and 119 deletions
|
@ -149,7 +149,7 @@ bool create_path(const char *dirname) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((strlen(dirname) == 1) && (dirname[0] == '/'))
|
if ((strlen(dirname) == 1) && (dirname[0] == '/'))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ((strlen(dirname) == 2) && (dirname[1] == ':'))
|
if ((strlen(dirname) == 2) && (dirname[1] == ':'))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -51,7 +51,7 @@ int preferences_load(void) {
|
||||||
|
|
||||||
// Set all defaults
|
// Set all defaults
|
||||||
session.client_debug_level = cdbOFF;
|
session.client_debug_level = cdbOFF;
|
||||||
// session.device_debug_level = ddbOFF;
|
// session.device_debug_level = ddbOFF;
|
||||||
session.window_changed = false;
|
session.window_changed = false;
|
||||||
session.plot.x = 10;
|
session.plot.x = 10;
|
||||||
session.plot.y = 30;
|
session.plot.y = 30;
|
||||||
|
@ -69,25 +69,25 @@ int preferences_load(void) {
|
||||||
// setDefaultPath (spDump, "");
|
// setDefaultPath (spDump, "");
|
||||||
// setDefaultPath (spTrace, "");
|
// setDefaultPath (spTrace, "");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// default save path
|
// default save path
|
||||||
if (get_my_user_directory() != NULL) // should return path to .proxmark3 folder
|
if (get_my_user_directory() != NULL) // should return path to .proxmark3 folder
|
||||||
setDefaultPath (spDefault, get_my_user_directory());
|
setDefaultPath (spDefault, get_my_user_directory());
|
||||||
else
|
else
|
||||||
setDefaultPath (spDefault, ".");
|
setDefaultPath (spDefault, ".");
|
||||||
|
|
||||||
// default dump path
|
// default dump path
|
||||||
if (get_my_user_directory() != NULL) // should return path to .proxmark3 folder
|
if (get_my_user_directory() != NULL) // should return path to .proxmark3 folder
|
||||||
setDefaultPath (spDump, get_my_user_directory());
|
setDefaultPath (spDump, get_my_user_directory());
|
||||||
else
|
else
|
||||||
setDefaultPath (spDump, ".");
|
setDefaultPath (spDump, ".");
|
||||||
|
|
||||||
// default dump path
|
// default dump path
|
||||||
if (get_my_user_directory() != NULL) // should return path to .proxmark3 folder
|
if (get_my_user_directory() != NULL) // should return path to .proxmark3 folder
|
||||||
setDefaultPath (spTrace, get_my_user_directory());
|
setDefaultPath (spTrace, get_my_user_directory());
|
||||||
else
|
else
|
||||||
setDefaultPath (spTrace, ".");
|
setDefaultPath (spTrace, ".");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// loadFileJson wants these, so pass in place holder values, though not used
|
// loadFileJson wants these, so pass in place holder values, though not used
|
||||||
// in settings load;
|
// in settings load;
|
||||||
|
@ -156,7 +156,7 @@ void preferences_save_callback(json_t *root) {
|
||||||
JsonSaveStr(root, "show.emoji", "alias");
|
JsonSaveStr(root, "show.emoji", "alias");
|
||||||
break;
|
break;
|
||||||
case EMOJI:
|
case EMOJI:
|
||||||
JsonSaveStr(root,"show.emoji","emoji");
|
JsonSaveStr(root, "show.emoji", "emoji");
|
||||||
break;
|
break;
|
||||||
case ALTTEXT:
|
case ALTTEXT:
|
||||||
JsonSaveStr(root, "show.emoji", "alttext");
|
JsonSaveStr(root, "show.emoji", "alttext");
|
||||||
|
@ -172,9 +172,9 @@ void preferences_save_callback(json_t *root) {
|
||||||
|
|
||||||
JsonSaveBoolean(root, "os.supports.colors", session.supports_colors);
|
JsonSaveBoolean(root, "os.supports.colors", session.supports_colors);
|
||||||
|
|
||||||
// JsonSaveStr(root, "file.default.savepath", session.defaultPaths[spDefault]);
|
// JsonSaveStr(root, "file.default.savepath", session.defaultPaths[spDefault]);
|
||||||
// JsonSaveStr(root, "file.default.dumppath", session.defaultPaths[spDump]);
|
// JsonSaveStr(root, "file.default.dumppath", session.defaultPaths[spDump]);
|
||||||
// JsonSaveStr(root, "file.default.tracepath", session.defaultPaths[spTrace]);
|
// JsonSaveStr(root, "file.default.tracepath", session.defaultPaths[spTrace]);
|
||||||
|
|
||||||
// Plot window
|
// Plot window
|
||||||
JsonSaveInt(root, "window.plot.xpos", session.plot.x);
|
JsonSaveInt(root, "window.plot.xpos", session.plot.x);
|
||||||
|
@ -202,27 +202,27 @@ void preferences_save_callback(json_t *root) {
|
||||||
default:
|
default:
|
||||||
JsonSaveStr(root, "logging.level", "NORMAL");
|
JsonSaveStr(root, "logging.level", "NORMAL");
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
switch (session.device_debug_level) {
|
switch (session.device_debug_level) {
|
||||||
case ddbOFF:
|
case ddbOFF:
|
||||||
JsonSaveStr(root, "device.debug.level", "off");
|
JsonSaveStr(root, "device.debug.level", "off");
|
||||||
break;
|
break;
|
||||||
case ddbERROR:
|
case ddbERROR:
|
||||||
JsonSaveStr(root, "device.debug.level", "error");
|
JsonSaveStr(root, "device.debug.level", "error");
|
||||||
break;
|
break;
|
||||||
case ddbINFO:
|
case ddbINFO:
|
||||||
JsonSaveStr(root, "device.debug.level", "info");
|
JsonSaveStr(root, "device.debug.level", "info");
|
||||||
break;
|
break;
|
||||||
case ddbDEBUG:
|
case ddbDEBUG:
|
||||||
JsonSaveStr(root, "device.debug.level", "debug");
|
JsonSaveStr(root, "device.debug.level", "debug");
|
||||||
break;
|
break;
|
||||||
case ddbEXTENDED:
|
case ddbEXTENDED:
|
||||||
JsonSaveStr(root, "device.debug.level", "extended");
|
JsonSaveStr(root, "device.debug.level", "extended");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
JsonSaveStr(root, "logging.level", "NORMAL");
|
JsonSaveStr(root, "logging.level", "NORMAL");
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void preferences_load_callback(json_t *root) {
|
void preferences_load_callback(json_t *root) {
|
||||||
|
@ -240,19 +240,19 @@ void preferences_load_callback(json_t *root) {
|
||||||
if (strncmp(tempStr, "simple", 6) == 0) session.client_debug_level = cdbSIMPLE;
|
if (strncmp(tempStr, "simple", 6) == 0) session.client_debug_level = cdbSIMPLE;
|
||||||
if (strncmp(tempStr, "full", 4) == 0) session.client_debug_level = cdbFULL;
|
if (strncmp(tempStr, "full", 4) == 0) session.client_debug_level = cdbFULL;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
// default save path
|
// default save path
|
||||||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.savepath", &s1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.savepath", &s1) == 0)
|
||||||
setDefaultPath (spDefault,s1);
|
setDefaultPath (spDefault,s1);
|
||||||
|
|
||||||
// default dump path
|
// default dump path
|
||||||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.dumppath", &s1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.dumppath", &s1) == 0)
|
||||||
setDefaultPath (spDump,s1);
|
setDefaultPath (spDump,s1);
|
||||||
|
|
||||||
// default trace path
|
// default trace path
|
||||||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.tracepath", &s1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "file.default.tracepath", &s1) == 0)
|
||||||
setDefaultPath (spTrace,s1);
|
setDefaultPath (spTrace,s1);
|
||||||
*/
|
*/
|
||||||
// window plot
|
// window plot
|
||||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.xpos", &i1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "window.plot.xpos", &i1) == 0)
|
||||||
session.plot.x = i1;
|
session.plot.x = i1;
|
||||||
|
@ -288,18 +288,18 @@ void preferences_load_callback(json_t *root) {
|
||||||
|
|
||||||
if (json_unpack_ex(root, &up_error, 0, "{s:b}", "os.supports.colors", &b1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:b}", "os.supports.colors", &b1) == 0)
|
||||||
session.supports_colors = b1;
|
session.supports_colors = b1;
|
||||||
/*
|
/*
|
||||||
// Logging Level
|
// Logging Level
|
||||||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "device.debug.level", &s1) == 0) {
|
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "device.debug.level", &s1) == 0) {
|
||||||
strncpy(tempStr, s1, sizeof(tempStr) - 1);
|
strncpy(tempStr, s1, sizeof(tempStr) - 1);
|
||||||
str_lower(tempStr);
|
str_lower(tempStr);
|
||||||
if (strncmp(tempStr, "off", 3) == 0) session.device_debug_level = ddbOFF;
|
if (strncmp(tempStr, "off", 3) == 0) session.device_debug_level = ddbOFF;
|
||||||
if (strncmp(tempStr, "error", 5) == 0) session.device_debug_level = ddbERROR;
|
if (strncmp(tempStr, "error", 5) == 0) session.device_debug_level = ddbERROR;
|
||||||
if (strncmp(tempStr, "info", 4) == 0) session.device_debug_level = ddbINFO;
|
if (strncmp(tempStr, "info", 4) == 0) session.device_debug_level = ddbINFO;
|
||||||
if (strncmp(tempStr, "debug", 5) == 0) session.device_debug_level = ddbDEBUG;
|
if (strncmp(tempStr, "debug", 5) == 0) session.device_debug_level = ddbDEBUG;
|
||||||
if (strncmp(tempStr, "extended", 8) == 0) session.device_debug_level = ddbEXTENDED;
|
if (strncmp(tempStr, "extended", 8) == 0) session.device_debug_level = ddbEXTENDED;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help Functions
|
// Help Functions
|
||||||
|
@ -376,13 +376,12 @@ static int usage_set_savePaths() {
|
||||||
// typedef enum preferenceId {prefNONE,prefHELP,prefEMOJI,prefCOLOR,prefPLOT,prefOVERLAY,prefHINTS,prefCLIENTDEBUG} preferenceId_t;
|
// typedef enum preferenceId {prefNONE,prefHELP,prefEMOJI,prefCOLOR,prefPLOT,prefOVERLAY,prefHINTS,prefCLIENTDEBUG} preferenceId_t;
|
||||||
typedef enum prefShowOpt {prefShowNone, prefShowOLD, prefShowNEW} prefShowOpt_t;
|
typedef enum prefShowOpt {prefShowNone, prefShowOLD, prefShowNEW} prefShowOpt_t;
|
||||||
|
|
||||||
const char *prefShowMsg(prefShowOpt_t Opt)
|
const char *prefShowMsg(prefShowOpt_t Opt) {
|
||||||
{
|
|
||||||
switch (Opt) {
|
switch (Opt) {
|
||||||
case prefShowOLD:
|
case prefShowOLD:
|
||||||
return _YELLOW_("[old]");
|
return _YELLOW_("[old]");
|
||||||
case prefShowNEW:
|
case prefShowNEW:
|
||||||
return _GREEN_("[new]");
|
return _GREEN_("[new]");
|
||||||
case prefShowNone:
|
case prefShowNone:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -463,7 +462,7 @@ void showSavePathState(savePaths_t pathIndex, prefShowOpt_t Opt) {
|
||||||
char tempStr[50];
|
char tempStr[50];
|
||||||
|
|
||||||
switch (pathIndex) {
|
switch (pathIndex) {
|
||||||
case spDefault:
|
case spDefault:
|
||||||
strcpy (tempStr,"default save path......");
|
strcpy (tempStr,"default save path......");
|
||||||
break;
|
break;
|
||||||
case spDump:
|
case spDump:
|
||||||
|
@ -481,7 +480,7 @@ void showSavePathState(savePaths_t pathIndex, prefShowOpt_t Opt) {
|
||||||
PrintAndLogEx(NORMAL, " %s %s "_GREEN_("%s"), prefShowMsg(Opt), tempStr, session.defaultPaths[pathIndex]);
|
PrintAndLogEx(NORMAL, " %s %s "_GREEN_("%s"), prefShowMsg(Opt), tempStr, session.defaultPaths[pathIndex]);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
void showPlotPosState(void){
|
void showPlotPosState(void) {
|
||||||
PrintAndLogEx(NORMAL, " Plot window............ X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
PrintAndLogEx(NORMAL, " Plot window............ X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||||
session.plot.x, session.plot.y, session.plot.h, session.plot.w);
|
session.plot.x, session.plot.y, session.plot.h, session.plot.w);
|
||||||
}
|
}
|
||||||
|
@ -657,7 +656,7 @@ static int setCmdDeviceDebug (const char *Cmd)
|
||||||
char strOpt[50];
|
char strOpt[50];
|
||||||
devicedebugLevel_t newValue = session.device_debug_level;
|
devicedebugLevel_t newValue = session.device_debug_level;
|
||||||
|
|
||||||
if (param_getchar(Cmd, cmdp) == 0x00)
|
if (param_getchar(Cmd, cmdp) == 0x00)
|
||||||
return usage_set_devicedebug ();
|
return usage_set_devicedebug ();
|
||||||
|
|
||||||
while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) {
|
while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) {
|
||||||
|
@ -665,12 +664,12 @@ static int setCmdDeviceDebug (const char *Cmd)
|
||||||
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
|
if (param_getstr(Cmd, cmdp++, strOpt, sizeof(strOpt)) != 0) {
|
||||||
str_lower(strOpt); // convert to lowercase
|
str_lower(strOpt); // convert to lowercase
|
||||||
|
|
||||||
if (strncmp (strOpt,"help",4) == 0)
|
if (strncmp (strOpt,"help",4) == 0)
|
||||||
return usage_set_devicedebug();
|
return usage_set_devicedebug();
|
||||||
if (strncmp (strOpt,"off",3) == 0) {
|
if (strncmp (strOpt,"off",3) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = ddbOFF;
|
newValue = ddbOFF;
|
||||||
}
|
}
|
||||||
if (strncmp (strOpt,"error",5) == 0) {
|
if (strncmp (strOpt,"error",5) == 0) {
|
||||||
validValue = true;
|
validValue = true;
|
||||||
newValue = ddbERROR;
|
newValue = ddbERROR;
|
||||||
|
@ -689,7 +688,7 @@ static int setCmdDeviceDebug (const char *Cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validValue) {
|
if (validValue) {
|
||||||
if (session.device_debug_level != newValue) {// changed
|
if (session.device_debug_level != newValue) {// changed
|
||||||
showDeviceDebugState (prefShowOLD);
|
showDeviceDebugState (prefShowOLD);
|
||||||
session.device_debug_level = newValue;
|
session.device_debug_level = newValue;
|
||||||
showDeviceDebugState (prefShowNEW);
|
showDeviceDebugState (prefShowNEW);
|
||||||
|
@ -715,8 +714,7 @@ static int setCmdDeviceDebug (const char *Cmd)
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
static int setCmdHint (const char *Cmd)
|
static int setCmdHint(const char *Cmd) {
|
||||||
{
|
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
bool validValue = false;
|
bool validValue = false;
|
||||||
|
@ -771,9 +769,9 @@ static int setCmdSavePaths (const char *Cmd) {
|
||||||
char *newValue = NULL;
|
char *newValue = NULL;
|
||||||
bool createDir = false;
|
bool createDir = false;
|
||||||
savePaths_t pathItem = spItemCount;
|
savePaths_t pathItem = spItemCount;
|
||||||
|
|
||||||
|
|
||||||
if (param_getchar(Cmd, cmdp) == 0x00)
|
if (param_getchar(Cmd, cmdp) == 0x00)
|
||||||
return usage_set_savePaths();
|
return usage_set_savePaths();
|
||||||
|
|
||||||
while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) {
|
while ((param_getchar(Cmd, cmdp) != 0x00) && !errors) {
|
||||||
|
@ -784,12 +782,12 @@ static int setCmdSavePaths (const char *Cmd) {
|
||||||
if (param_getstr(Cmd, cmdp++, strOpt, optLen) != 0) {
|
if (param_getstr(Cmd, cmdp++, strOpt, optLen) != 0) {
|
||||||
str_lower(strOpt); // convert to lowercase
|
str_lower(strOpt); // convert to lowercase
|
||||||
|
|
||||||
if (strncmp(strOpt, "help", 4) == 0)
|
if (strncmp(strOpt, "help", 4) == 0)
|
||||||
return usage_set_savePaths();
|
return usage_set_savePaths();
|
||||||
|
|
||||||
if (strncmp(strOpt, "create", 6) == 0) {
|
if (strncmp(strOpt, "create", 6) == 0) {
|
||||||
// check if 2 more options.
|
// check if 2 more options.
|
||||||
if (param_getlength(Cmd, cmdp+1) == 0) // should have min 2 more options
|
if (param_getlength(Cmd, cmdp+1) == 0) // should have min 2 more options
|
||||||
return usage_set_savePaths();
|
return usage_set_savePaths();
|
||||||
createDir = true;
|
createDir = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -820,7 +818,7 @@ static int setCmdSavePaths (const char *Cmd) {
|
||||||
if (strncmp(strOpt, "default", 7) == 0) pathItem = spDefault;
|
if (strncmp(strOpt, "default", 7) == 0) pathItem = spDefault;
|
||||||
if (strncmp(strOpt, "dump", 4) == 0) pathItem = spDump;
|
if (strncmp(strOpt, "dump", 4) == 0) pathItem = spDump;
|
||||||
if (strncmp(strOpt, "trace", 5) == 0) pathItem = spTrace;
|
if (strncmp(strOpt, "trace", 5) == 0) pathItem = spTrace;
|
||||||
|
|
||||||
if (pathItem < spItemCount) {
|
if (pathItem < spItemCount) {
|
||||||
if (strcmp(newValue, session.defaultPaths[pathItem]) != 0) {
|
if (strcmp(newValue, session.defaultPaths[pathItem]) != 0) {
|
||||||
showSavePathState(pathItem, prefShowOLD);
|
showSavePathState(pathItem, prefShowOLD);
|
||||||
|
@ -848,33 +846,33 @@ static int setCmdSavePaths (const char *Cmd) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int getCmdHelp (const char *Cmd) {
|
int getCmdHelp(const char *Cmd) {
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getCmdEmoji (const char *Cmd) {
|
int getCmdEmoji(const char *Cmd) {
|
||||||
|
|
||||||
showEmojiState(prefShowNone);
|
showEmojiState(prefShowNone);
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getCmdHint (const char *Cmd) {
|
int getCmdHint(const char *Cmd) {
|
||||||
|
|
||||||
showHintsState(prefShowNone);
|
showHintsState(prefShowNone);
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getCmdColor (const char *Cmd) {
|
int getCmdColor(const char *Cmd) {
|
||||||
|
|
||||||
showColorState(prefShowNone);
|
showColorState(prefShowNone);
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getCmdDebug (const char *Cmd) {
|
int getCmdDebug(const char *Cmd) {
|
||||||
|
|
||||||
showClientDebugState(prefShowNone);
|
showClientDebugState(prefShowNone);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -885,9 +883,9 @@ static command_t getCommandTable[] = {
|
||||||
{"emoji", getCmdEmoji, AlwaysAvailable, "Get emoji display preference"},
|
{"emoji", getCmdEmoji, AlwaysAvailable, "Get emoji display preference"},
|
||||||
{"hints", getCmdHint, AlwaysAvailable, "Get hint display preference"},
|
{"hints", getCmdHint, AlwaysAvailable, "Get hint display preference"},
|
||||||
{"color", getCmdColor, AlwaysAvailable, "Get color support preference"},
|
{"color", getCmdColor, AlwaysAvailable, "Get color support preference"},
|
||||||
// {"defaultsavepaths", getCmdSavePaths, AlwaysAvailable, "... to be adjusted next ... "},
|
// {"defaultsavepaths", getCmdSavePaths, AlwaysAvailable, "... to be adjusted next ... "},
|
||||||
{"clientdebug", getCmdDebug, AlwaysAvailable, "Get client debug level preference"},
|
{"clientdebug", getCmdDebug, AlwaysAvailable, "Get client debug level preference"},
|
||||||
// {"devicedebug", getCmdDeviceDebug, AlwaysAvailable, "Get device debug level"},
|
// {"devicedebug", getCmdDeviceDebug, AlwaysAvailable, "Get device debug level"},
|
||||||
{NULL, NULL, NULL, NULL}
|
{NULL, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -896,9 +894,9 @@ static command_t setCommandTable[] = {
|
||||||
{"emoji", setCmdEmoji, AlwaysAvailable, "Set emoji display"},
|
{"emoji", setCmdEmoji, AlwaysAvailable, "Set emoji display"},
|
||||||
{"hints", setCmdHint, AlwaysAvailable, "Set hint display"},
|
{"hints", setCmdHint, AlwaysAvailable, "Set hint display"},
|
||||||
{"color", setCmdColor, AlwaysAvailable, "Set color support"},
|
{"color", setCmdColor, AlwaysAvailable, "Set color support"},
|
||||||
// {"defaultsavepaths", setCmdSavePaths, AlwaysAvailable, "... to be adjusted next ... "},
|
// {"defaultsavepaths", setCmdSavePaths, AlwaysAvailable, "... to be adjusted next ... "},
|
||||||
{"clientdebug", setCmdDebug, AlwaysAvailable, "Set client debug level"},
|
{"clientdebug", setCmdDebug, AlwaysAvailable, "Set client debug level"},
|
||||||
// {"devicedebug", setCmdDeviceDebug, AlwaysAvailable, "Set device debug level"},
|
// {"devicedebug", setCmdDeviceDebug, AlwaysAvailable, "Set device debug level"},
|
||||||
{NULL, NULL, NULL, NULL}
|
{NULL, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -924,10 +922,10 @@ int CmdPrefSet(const char *Cmd) {
|
||||||
static int CmdPrefShow(const char *Cmd) {
|
static int CmdPrefShow(const char *Cmd) {
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(NORMAL, _CYAN_("Preferences loaded from %s"),prefGetFilename());
|
PrintAndLogEx(NORMAL, _CYAN_("Preferences loaded from %s"), prefGetFilename());
|
||||||
|
|
||||||
if (!session.preferences_loaded) {
|
if (!session.preferences_loaded) {
|
||||||
PrintAndLogEx (ERR, "Preferneces not loaded");
|
PrintAndLogEx(ERR, "Preferneces not loaded");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -935,11 +933,11 @@ static int CmdPrefShow(const char *Cmd) {
|
||||||
showEmojiState(prefShowNone);
|
showEmojiState(prefShowNone);
|
||||||
showHintsState(prefShowNone);
|
showHintsState(prefShowNone);
|
||||||
showColorState(prefShowNone);
|
showColorState(prefShowNone);
|
||||||
// showPlotPosState ();
|
// showPlotPosState ();
|
||||||
// showOverlayPosState ();
|
// showOverlayPosState ();
|
||||||
// showSavePathState(spDefault, prefShowNone);
|
// showSavePathState(spDefault, prefShowNone);
|
||||||
// showSavePathState(spDump, prefShowNone);
|
// showSavePathState(spDump, prefShowNone);
|
||||||
// showSavePathState(spTrace, prefShowNone);
|
// showSavePathState(spTrace, prefShowNone);
|
||||||
|
|
||||||
showClientDebugState(prefShowNone);
|
showClientDebugState(prefShowNone);
|
||||||
// showDeviceDebugState(prefShowNone);
|
// showDeviceDebugState(prefShowNone);
|
||||||
|
|
|
@ -419,17 +419,17 @@ const char *get_my_user_directory(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_my_user_directory(void) {
|
static void set_my_user_directory(void) {
|
||||||
/* my_user_directory = getenv("HOME");
|
/* my_user_directory = getenv("HOME");
|
||||||
|
|
||||||
// if not found, default to current directory
|
// if not found, default to current directory
|
||||||
if (my_user_directory == NULL) {
|
if (my_user_directory == NULL) {
|
||||||
my_user_directory = GetCurrentDir(_cwd_Buffer, sizeof(_cwd_Buffer));
|
my_user_directory = GetCurrentDir(_cwd_Buffer, sizeof(_cwd_Buffer));
|
||||||
// change all slashs to / (windows should not care...
|
// change all slashs to / (windows should not care...
|
||||||
for (int i = 0; i < strlen(_cwd_Buffer); i++)
|
for (int i = 0; i < strlen(_cwd_Buffer); i++)
|
||||||
if (_cwd_Buffer[i] == '\\') _cwd_Buffer[i] = '/';
|
if (_cwd_Buffer[i] == '\\') _cwd_Buffer[i] = '/';
|
||||||
// my_user_directory = ".";
|
// my_user_directory = ".";
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
my_user_directory = getenv("HOME");
|
my_user_directory = getenv("HOME");
|
||||||
|
|
||||||
// if not found, default to current directory
|
// if not found, default to current directory
|
||||||
|
@ -438,23 +438,23 @@ static void set_my_user_directory(void) {
|
||||||
char *cwd_Buffer = NULL;
|
char *cwd_Buffer = NULL;
|
||||||
uint16_t pathLen = FILENAME_MAX; // should be a good starting point
|
uint16_t pathLen = FILENAME_MAX; // should be a good starting point
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
||||||
cwd_Buffer = (char *)calloc(pathLen, sizeof(uint8_t));
|
cwd_Buffer = (char *)calloc(pathLen, sizeof(uint8_t));
|
||||||
|
|
||||||
while (!error && (GetCurrentDir (cwd_Buffer,pathLen) == NULL)) {
|
while (!error && (GetCurrentDir(cwd_Buffer, pathLen) == NULL)) {
|
||||||
if (errno == ERANGE) { // Need bigger buffer
|
if (errno == ERANGE) { // Need bigger buffer
|
||||||
pathLen += 10; // if buffer was too small add 10 characters and try again
|
pathLen += 10; // if buffer was too small add 10 characters and try again
|
||||||
cwd_Buffer = realloc(cwd_Buffer, pathLen);
|
cwd_Buffer = realloc(cwd_Buffer, pathLen);
|
||||||
} else {
|
} else {
|
||||||
error = true;
|
error = true;
|
||||||
free (cwd_Buffer);
|
free(cwd_Buffer);
|
||||||
cwd_Buffer = NULL;
|
cwd_Buffer = NULL;
|
||||||
}
|
}
|
||||||
printf ("Len... %d\n",pathLen);
|
printf("Len... %d\n", pathLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
|
||||||
for (int i = 0; i < strlen(cwd_Buffer); i++)
|
for (int i = 0; i < strlen(cwd_Buffer); i++)
|
||||||
if (cwd_Buffer[i] == '\\') cwd_Buffer[i] = '/';
|
if (cwd_Buffer[i] == '\\') cwd_Buffer[i] = '/';
|
||||||
|
|
||||||
|
@ -980,7 +980,7 @@ int main(int argc, char *argv[]) {
|
||||||
// Doing this here will ensure other checks and updates are saved to over rule default
|
// Doing this here will ensure other checks and updates are saved to over rule default
|
||||||
// e.g. Linux color use check
|
// e.g. Linux color use check
|
||||||
if (!session.preferences_loaded) {
|
if (!session.preferences_loaded) {
|
||||||
PrintAndLogEx (INFO,"Creating initial preferences file"); // json save reports file name, so just info msg here
|
PrintAndLogEx(INFO, "Creating initial preferences file"); // json save reports file name, so just info msg here
|
||||||
preferences_save(); // Save defaults
|
preferences_save(); // Save defaults
|
||||||
session.preferences_loaded = true;
|
session.preferences_loaded = true;
|
||||||
} /* else {
|
} /* else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue