2025-02-18 04:10:35 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
#include <cstring>
|
|
|
|
#include <vector>
|
2025-02-23 08:26:49 +00:00
|
|
|
#include "../include/module_interface.hpp"
|
|
|
|
#include <gpgme.h>
|
2025-02-18 04:10:35 +00:00
|
|
|
|
|
|
|
// Implementation of the info module
|
|
|
|
// This module provides information about the DPM system
|
|
|
|
|
2025-02-23 08:26:49 +00:00
|
|
|
// Version information
|
|
|
|
extern "C" const char* dpm_module_get_version(void) {
|
|
|
|
return "0.1.0";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Module description
|
|
|
|
extern "C" const char* dpm_get_description(void) {
|
|
|
|
return "DPM Info Module - Provides information about the DPM system";
|
|
|
|
}
|
|
|
|
|
2025-02-18 04:10:35 +00:00
|
|
|
// Main entry point that will be called by DPM
|
|
|
|
extern "C" int dpm_module_execute(const char* command, int argc, char** argv) {
|
|
|
|
// Handle the case when no command is provided
|
|
|
|
if (command == nullptr || strlen(command) == 0) {
|
|
|
|
std::cout << "DPM Info Module - Provides information about the DPM system\n";
|
|
|
|
std::cout << "Usage: dpm info <command> [args]\n";
|
|
|
|
std::cout << "Available commands:\n";
|
|
|
|
std::cout << " version - Display DPM version information\n";
|
|
|
|
std::cout << " system - Display system information\n";
|
|
|
|
std::cout << " help - Display this help message\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert command to string for easier comparison
|
|
|
|
std::string cmd(command);
|
|
|
|
|
|
|
|
if (cmd == "version") {
|
|
|
|
std::cout << "DPM Version: 0.1.0\n";
|
|
|
|
std::cout << "Build Date: " << __DATE__ << "\n";
|
|
|
|
std::cout << "Build Time: " << __TIME__ << "\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (cmd == "system") {
|
|
|
|
std::cout << "System Information:\n";
|
2025-02-23 08:26:49 +00:00
|
|
|
std::cout << " OS: "
|
2025-02-18 04:10:35 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
"Windows"
|
|
|
|
#elif __APPLE__
|
|
|
|
"macOS"
|
|
|
|
#elif __linux__
|
|
|
|
"Linux"
|
|
|
|
#else
|
|
|
|
"Unknown"
|
|
|
|
#endif
|
|
|
|
<< "\n";
|
2025-02-23 08:26:49 +00:00
|
|
|
std::cout << " Architecture: "
|
2025-02-18 04:10:35 +00:00
|
|
|
#ifdef __x86_64__
|
|
|
|
"x86_64"
|
|
|
|
#elif __i386__
|
|
|
|
"x86"
|
|
|
|
#elif __arm__
|
|
|
|
"ARM"
|
|
|
|
#elif __aarch64__
|
|
|
|
"ARM64"
|
|
|
|
#else
|
|
|
|
"Unknown"
|
|
|
|
#endif
|
|
|
|
<< "\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (cmd == "help") {
|
|
|
|
std::cout << "DPM Info Module - Provides information about the DPM system\n";
|
|
|
|
std::cout << "Available commands:\n";
|
|
|
|
std::cout << " version - Display DPM version information\n";
|
|
|
|
std::cout << " system - Display system information\n";
|
|
|
|
std::cout << " help - Display this help message\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
std::cerr << "Unknown command: " << cmd << "\n";
|
|
|
|
std::cerr << "Run 'dpm info help' for a list of available commands\n";
|
|
|
|
return 1;
|
|
|
|
}
|
2025-02-23 08:26:49 +00:00
|
|
|
}
|