libcmo21/Unvirt/StructFormatter.cpp

58 lines
2.1 KiB
C++
Raw Normal View History

2023-02-14 16:28:37 +08:00
#include "StructFormatter.hpp"
#include "AccessibleValue.hpp"
#include "TerminalHelper.hpp"
namespace Unvirt {
namespace StructFormatter {
static FILE* fout = stdout;
2023-02-26 21:48:03 +08:00
void PrintCKFileInfo(const LibCmo::CK2::CKFileInfo& fileinfo) {
2023-02-14 16:28:37 +08:00
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKFileInfo\n")), fout);
2023-02-28 14:04:38 +08:00
fprintf(fout, "FileVersion: %" PRIu32 "\n", fileinfo.FileVersion);
fprintf(fout, "CKVersion: %02" PRIX32 "/%02" PRIX32 "/%04" PRIX32 "\n",
2023-02-25 22:58:28 +08:00
(fileinfo.CKVersion >> 24) & 0xFF,
(fileinfo.CKVersion >> 16) & 0xFF,
(fileinfo.CKVersion >> 0) & 0xFFFF
2023-02-14 16:28:37 +08:00
);
2023-02-26 21:48:03 +08:00
LibCmo::CK2::CKDWORD product_series[4]{
2023-02-14 16:28:37 +08:00
(fileinfo.ProductBuild >> 24) & 0xFF,
(fileinfo.ProductBuild >> 16) & 0xFF,
(fileinfo.ProductBuild >> 8) & 0xFF,
(fileinfo.ProductBuild >> 0) & 0xFF,
};
fprintf(fout, "Product (Version / Build): %" PRIu32 " / %" PRIu32 ".%" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n",
fileinfo.ProductVersion, product_series[0], product_series[1], product_series[2], product_series[3]
);
2023-03-03 16:05:32 +08:00
fprintf(fout, "Save Flags: %s\n", Unvirt::AccessibleValue::GetFlagEnumName<LibCmo::CK2::CK_FILE_WRITEMODE>(
Unvirt::AccessibleValue::EnumDesc::CK_FILE_WRITEMODE, fileinfo.FileWriteMode
).c_str());
2023-02-14 16:28:37 +08:00
2023-03-03 16:05:32 +08:00
fprintf(fout, "File Size: %s\n", Unvirt::AccessibleValue::GetAccessibleFileSize(fileinfo.FileSize).c_str());
2023-02-14 16:28:37 +08:00
fprintf(fout, "Crc: 0x%" PRIX32 "\n", fileinfo.Crc);
fputc('\n', fout);
fputs("Hdr1 (Pack / UnPack): ", fout);
2023-03-03 16:05:32 +08:00
fprintf(fout, "%s / ", Unvirt::AccessibleValue::GetAccessibleFileSize(fileinfo.Hdr1PackSize).c_str());
fprintf(fout, "%s\n", Unvirt::AccessibleValue::GetAccessibleFileSize(fileinfo.Hdr1UnPackSize).c_str());
2023-02-14 16:28:37 +08:00
fputs("Data (Pack / UnPack): ", fout);
2023-03-03 16:05:32 +08:00
fprintf(fout, "%s / ", Unvirt::AccessibleValue::GetAccessibleFileSize(fileinfo.DataPackSize).c_str());
fprintf(fout, "%s\n", Unvirt::AccessibleValue::GetAccessibleFileSize(fileinfo.DataUnPackSize).c_str());
2023-02-14 16:28:37 +08:00
fputc('\n', fout);
fprintf(fout, "Manager Count: %" PRIu32 "\nObject Count: %" PRIu32 "\nMax ID Saved: %" PRIu32 "\n",
fileinfo.ManagerCount, fileinfo.ObjectCount, fileinfo.MaxIDSaved
);
}
}
}