return talk(tpm_cst, sizeof(tpm_cst), tpm_errcode);
}
+static void versioninfo(void)
+{
+ printf(
+"TPM emulator BIOS emulator version %d.%d.%d, Copyright (c) 2015 IBM Corp.\n"
+,SWTPM_VER_MAJOR, SWTPM_VER_MINOR, SWTPM_VER_MICRO);
+}
+
static void print_usage(const char *prgname)
{
+ versioninfo();
printf(
-"TPM emulator BIOS emulator version %d.%d.%d, Copyright (c) 2015 IBM Corp.\n"
"\n"
"%s [options]\n"
"\n"
"\t-d startup deactivate\n"
"\t-n no startup\n"
"\t-o startup only\n"
-"\t-cs run TPM_ContinueSelfTest\n",
-SWTPM_VER_MAJOR, SWTPM_VER_MINOR, SWTPM_VER_MICRO, prgname);
- return;
+"\t-cs run TPM_ContinueSelfTest\n"
+"\t-v display version and exit\n"
+"\t-h display this help screen and exit\n"
+, prgname);
}
int main(int argc, char *argv[])
} else if (strcmp(argv[i],"-h") == 0) {
print_usage(argv[0]);
exit(EXIT_SUCCESS);
+ } else if (strcmp(argv[i],"-v") == 0) {
+ versioninfo();
+ exit(EXIT_SUCCESS);
} else if (strcmp(argv[i],"-n") == 0) {
startupparm = 0xff;
do_more = 1;
ASN1_TYPE _tpm_asn;
static void
-usage(const char *prg)
+versioninfo(const char *prg)
{
fprintf(stdout,
"TPM certificate tool version %d.%d.%d, Copyright (c) 2015 IBM Corp.\n"
- "\n"
- "Usage: %s [options]\n"
+ ,SWTPM_VER_MAJOR, SWTPM_VER_MINOR, SWTPM_VER_MICRO);
+}
+
+static void
+usage(const char *prg)
+{
+ versioninfo(prg);
+ fprintf(stdout,
+ "\nUsage: %s [options]\n"
"\n"
"Create TPM certificates without requiring the EK private key.\n"
"\n"
"--platform-version <version> : The Platform version (firmware version)\n"
"--subject <subject> : Subject such as location in format\n"
" C=US,ST=NY,L=NewYork\n"
+ "--version : Display version and exit\n"
"--help : Display this help screen and exit\n"
"\n",
- SWTPM_VER_MAJOR, SWTPM_VER_MINOR, SWTPM_VER_MICRO, prg);
+ prg);
}
static char
platf_version = argv[i];
} else if (!strcmp(argv[i], "--pem")) {
write_pem = true;
+ } else if (!strcmp(argv[i], "--version")) {
+ versioninfo(argv[0]);
+ exit(0);
} else if (!strcmp(argv[i], "--help")) {
usage(argv[0]);
exit(0);
return 0;
}
-static void usage(const char *prgname)
+static void versioninfo(const char *prgname)
{
fprintf(stdout,
"TPM emulator control tool version %d.%d.%d, Copyright (c) 2015 IBM Corp.\n"
+,SWTPM_VER_MAJOR, SWTPM_VER_MINOR, SWTPM_VER_MICRO);
+}
+
+static void usage(const char *prgname)
+{
+ versioninfo(prgname);
+ fprintf(stdout,
"\n"
"Usage: %s command <device path>\n"
"\n"
"--load <type> <file> : load the TPM state blob of given type from a file;\n"
" type may be one of volatile, permanent, or savestate\n"
"-g : get configuration flags indicating which keys are in use\n"
+"--version: display version and exit\n"
+"-h|--help: display help screen and exit\n"
"\n"
-,SWTPM_VER_MAJOR, SWTPM_VER_MINOR, SWTPM_VER_MICRO, prgname);
+, prgname);
}
int main(int argc, char *argv[])
return 1;
}
+ if (!strcmp(argv[1], "--version")) {
+ versioninfo(argv[0]);
+ exit(0);
+ } else if (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
+ usage(argv[0]);
+ exit(0);
+ }
+
if (!strcmp(argv[1], "--save") ||
!strcmp(argv[1], "--load")) {
devindex = 4;
userid = argv[i];
} else if (!strcmp("--help", argv[i]) || !strcmp("-h", argv[i])) {
show_help = true;
+ } else if (!strcmp("--version", argv[i])) {
+ show_help = true;
}
for (j = 0; one_arg_params[j] != NULL; j++) {
if (!strcmp(one_arg_params[j], argv[i])) {
return 0
}
-usage()
+versioninfo()
{
cat <<EOF
TPM emulator setup tool version @SWTPM_VER_MAJOR@.@SWTPM_VER_MINOR@.@SWTPM_VER_MICRO@
+EOF
+}
+
+usage()
+{
+ versioninfo
+ cat <<EOF
Usage: $1 [options]
This parameter will be passed to the TPM using
'--key pwdfile=<file>'.
+--verion : Display version and exit
+
--help,-h,-? : Display this help screen
EOF
}
--pwdfile) shift; pwdfile="$1";;
--runas) shift;; # ignore here
--logfile) shift; LOGFILE="$1";;
+ --version) versioninfo $0; exit 0;;
--help|-h|-?) usage $0; exit 0;;
*) logerr "Unknown option $1"; usage $0; exit 1;;
esac