m_extwarn.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Copyright (C) All Rights Reserved
  2. ** Written by Gottem <support@gottem.nl>
  3. ** Website: https://gitgud.malvager.net/Wazakindjes/unrealircd_mods
  4. ** License: https://gitgud.malvager.net/Wazakindjes/unrealircd_mods/raw/master/LICENSE
  5. */
  6. // One include for all cross-platform compatibility thangs
  7. #include "unrealircd.h"
  8. // Quality fowod declarations
  9. void extwarn_main(void); // Void cuz only throws warnings, so no return value is required =]
  10. // Muh globals
  11. static ModuleInfo *extwarnMI = NULL; // Store ModuleInfo so we can use it to check for errors in MOD_LOAD
  12. // Dat dere module header
  13. ModuleHeader MOD_HEADER(m_extwarn) = {
  14. "m_extwarn", // Module name
  15. "$Id: v1.0 2017/05/18 Gottem$", // Version
  16. "Enables additional configuration error checking", // Description
  17. "3.2-b8-1", // Modversion, not sure wat do
  18. NULL
  19. };
  20. // Initialisation routine (register hooks, commands and modes or create structs etc)
  21. MOD_INIT(m_extwarn) {
  22. extwarnMI = modinfo;
  23. return MOD_SUCCESS; // Let MOD_LOAD handle errors
  24. }
  25. // Actually load the module here (also command overrides as they may not exist in MOD_INIT yet)
  26. MOD_LOAD(m_extwarn) {
  27. // Did the module throw an error during initialisation?
  28. if(ModuleGetError(extwarnMI->handle) != MODERR_NOERROR) {
  29. // Display error string kek
  30. config_error("A critical error occurred when loading module %s: %s", MOD_HEADER(m_extwarn).name, ModuleGetErrorStr(extwarnMI->handle));
  31. return MOD_FAILED; // No good
  32. }
  33. extwarn_main(); // Throws warnings only as to not break shit ;];]
  34. return MOD_SUCCESS;
  35. }
  36. // Called on unload/rehash obv
  37. MOD_UNLOAD(m_extwarn) {
  38. return MOD_SUCCESS; // We good
  39. }
  40. void extwarn_main(void) {
  41. // Check for missing operclasses etc
  42. ConfigItem_oper *oper;
  43. ConfigItem_operclass *operclass;
  44. for(oper = conf_oper; oper; oper = (ConfigItem_oper *)oper->next) { // Checkem configured opers
  45. if(!(operclass = Find_operclass(oper->operclass))) // None found, throw warning yo
  46. config_warn("[extwarn] Unknown operclass '%s' found in oper block for '%s'", oper->operclass, oper->name);
  47. }
  48. }