continued restructure for dpmdk and updated default behaviour
This commit is contained in:
137
dpmdk/include/CommonModuleAPI.hpp
Normal file
137
dpmdk/include/CommonModuleAPI.hpp
Normal file
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* @file CommonModuleAPI.hpp
|
||||
* @brief Common module interface for DPM modules
|
||||
*
|
||||
* Defines the required interface that all DPM modules must implement,
|
||||
* including the function declarations and constants that every module needs.
|
||||
*
|
||||
* @copyright Copyright (c) 2025 SILO GROUP LLC
|
||||
* @author Chris Punches <chris.punches@silogroup.org>
|
||||
*
|
||||
* Part of the Dark Horse Linux Package Manager (DPM)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For bug reports or contributions, please contact the dhlp-contributors
|
||||
* mailing list at: https://lists.darkhorselinux.org/mailman/listinfo/dhlp-contributors
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief Fatal log level constant
|
||||
*
|
||||
* Used for critical errors that require immediate attention and
|
||||
* typically result in program termination.
|
||||
*/
|
||||
const int LOG_FATAL = 0;
|
||||
|
||||
/**
|
||||
* @brief Error log level constant
|
||||
*
|
||||
* Used for error conditions that may allow the program to continue
|
||||
* execution but indicate a failure in some operation.
|
||||
*/
|
||||
const int LOG_ERROR = 1;
|
||||
|
||||
/**
|
||||
* @brief Warning log level constant
|
||||
*
|
||||
* Used for potentially harmful situations that don't affect normal
|
||||
* program execution but may indicate problems.
|
||||
*/
|
||||
const int LOG_WARN = 2;
|
||||
|
||||
/**
|
||||
* @brief Informational log level constant
|
||||
*
|
||||
* Used for general informational messages about program execution.
|
||||
*/
|
||||
const int LOG_INFO = 3;
|
||||
|
||||
/**
|
||||
* @brief Debug log level constant
|
||||
*
|
||||
* Used for detailed debugging information during development or
|
||||
* troubleshooting.
|
||||
*/
|
||||
const int LOG_DEBUG = 4;
|
||||
|
||||
// Required functions that every DPM module must implement
|
||||
extern "C" {
|
||||
/**
|
||||
* @brief Required module execution entry point
|
||||
*
|
||||
* Main entry point that is called by the DPM core when the module
|
||||
* is executed. Modules must implement this function to handle
|
||||
* commands and perform their specific functionality.
|
||||
*
|
||||
* @param command The command string to execute
|
||||
* @param argc Number of arguments
|
||||
* @param argv Array of argument strings
|
||||
* @return 0 on success, non-zero on failure
|
||||
*/
|
||||
int dpm_module_execute(const char* command, int argc, char** argv);
|
||||
|
||||
/**
|
||||
* @brief Module version information function
|
||||
*
|
||||
* Returns the version information for the module. This information
|
||||
* is displayed when listing available modules.
|
||||
*
|
||||
* @return A string containing the module's version
|
||||
*/
|
||||
const char* dpm_module_get_version(void);
|
||||
|
||||
/**
|
||||
* @brief Module description function
|
||||
*
|
||||
* Returns a human-readable description of the module's functionality.
|
||||
* This information is displayed when listing available modules.
|
||||
*
|
||||
* @return A string containing the module's description
|
||||
*/
|
||||
const char* dpm_get_description(void);
|
||||
}
|
||||
|
||||
// DPM core functions available for modules to call
|
||||
extern "C" {
|
||||
/**
|
||||
* @brief Configuration access function
|
||||
*
|
||||
* Allows modules to access DPM's configuration values by section and key.
|
||||
*
|
||||
* @param section The configuration section name
|
||||
* @param key The configuration key within the section
|
||||
* @return The configuration value as a string, or NULL if not found
|
||||
*/
|
||||
const char* dpm_get_config(const char* section, const char* key);
|
||||
|
||||
/**
|
||||
* @brief Logging function
|
||||
*
|
||||
* Allows modules to log messages through DPM's logging system.
|
||||
*
|
||||
* @param level The log level (LOG_FATAL, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG)
|
||||
* @param message The message to log
|
||||
*/
|
||||
void dpm_log(int level, const char* message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DPM core version definition
|
||||
*
|
||||
* Defines the version string for the DPM core system.
|
||||
*/
|
||||
#define DPM_VERSION "0.1.0"
|
||||
37
dpmdk/src/CommonModuleAPI.cpp
Normal file
37
dpmdk/src/CommonModuleAPI.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @file CommonModuleAPI.cpp
|
||||
* @brief Implementation stub for DPM module interface
|
||||
*
|
||||
* This file serves primarily as a documentation reference for the module
|
||||
* interface. The actual implementations of dpm_get_config and dpm_log are
|
||||
* provided by the DPM core, while dpm_module_execute, dpm_module_get_version,
|
||||
* and dpm_get_description must be implemented by each module.
|
||||
*
|
||||
* @copyright Copyright (c) 2025 SILO GROUP LLC
|
||||
* @author Chris Punches <chris.punches@silogroup.org>
|
||||
*
|
||||
* Part of the Dark Horse Linux Package Manager (DPM)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For bug reports or contributions, please contact the dhlp-contributors
|
||||
* mailing list at: https://lists.darkhorselinux.org/mailman/listinfo/dhlp-contributors
|
||||
*/
|
||||
|
||||
#include "module.hpp"
|
||||
|
||||
/**
|
||||
* @note The implementation of dpm_get_config and dpm_log are provided by the DPM core.
|
||||
* Each module must implement dpm_module_execute, dpm_module_get_version, and dpm_get_description.
|
||||
*/
|
||||
Reference in New Issue
Block a user