/*
- *
- * program: sanityCheck
+ *
+ * program: sanityCheck
* file: main.c
* author: Todd Naugle
* date: 11/17/2010
- *
+ *
* Desc: Command line version of the sanity check functions found in jack
-*/
+*/
#include <algorithm>
#include <stdio.h>
} testRecord;
static vector<testRecord> gTestSet;
-
+
static vector<string> gValidSwitchList;
static vector<string> gSwitchDescriptionList;
}
OK &= !(system_memlock_amount() == 0);
-
+
return OK;
}
printf(" Options are as follows:\n");
printf("\n");
printf("\n");
-
+
vector<testRecord>::iterator itr;
-
+
for (itr = gTestSet.begin(); itr != gTestSet.end(); ++itr) {
printf("%20s %s :\t%s\n", (*itr).switchText.c_str(), (*itr).swOptionText.c_str(), (*itr).descriptionText.c_str());
}
printf("\n");
-
+
return true;
}
DefineSwitches()
{
testRecord rec;
-
+
// Global switches
rec.switchText = "-a";
rec.swOptionText = "";
vector<testRecord>::iterator itr;
bool OK = true;
int i;
-
+
if (argc == 1) {
gSwitchesReceived.push_back("-a");
}
break;
}
}
-
+
if (OK && itr != gTestSet.end()) {
// Known option switch found
gSwitchesReceived.push_back(tmp);
}
if (OK) {
- // All switches are at least valid, now check to make sure they are all valid to
+ // All switches are at least valid, now check to make sure they are all valid to
// be used together.
-
+
if (gSwitchesReceived.size() > 1) {
// make sure help is not mixed with other options
vector<string>::iterator swItr;
}
else {
fprintf(stderr, "\n");
- fprintf(stderr, "ERROR - Invalid Option: %s\n", (const char *) argv[--i]);
+ fprintf(stderr, "ERROR - Invalid Option: %s\n", (const char *) argv[--i]);
fprintf(stderr, "Check syntax\n");
PrintUsage();
return false;
bool OK = true;
vector<string>::iterator itr;
vector<testRecord>::iterator testItr;
-
+
for (itr = gSwitchesReceived.begin(); itr != gSwitchesReceived.end(); ++itr) {
for (testItr = gTestSet.begin(); testItr != gTestSet.end(); ++testItr) {
if ((*itr) == (*testItr).switchText) {
break;
}
}
-
+
bool result;
if ((*testItr).hasOption) {
result = ((*testItr).opFunctionPtr((*testItr).optionArg) != 0);
OK &= result;
}
-
+
return OK;
}
char **argv)
{
int status = 0;
-
+
DefineSwitches();
if (ParseSwitches(argc, argv)) {