cppModule.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. cppModule.cpp - Create a simple AppWeb dynamically loadable module in C++
  3. Copyright (c) All Rights Reserved. See copyright notice at the bottom of the file.
  4. */
  5. /******************************* Includes *****************************/
  6. #include "appweb.h"
  7. /********************************* Code *******************************/
  8. /*
  9. Parse any module specific configuration directives from the appweb.conf config file.
  10. */
  11. static int customConfig(MaState *state, cchar *key, cchar *value)
  12. {
  13. /*
  14. Do something with value.
  15. */
  16. printf("Key \"%s\" = \"%s\"\n", key, value);
  17. fflush(stdout);
  18. return 0;
  19. }
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /*
  24. Module load initialization. This is called when the module is first loaded.
  25. */
  26. int httpSimpleModuleInit(Http *http, MprModule *mp)
  27. {
  28. HttpStage *stage;
  29. /*
  30. Create a stage so we can process configuration file data
  31. */
  32. if ((stage = httpCreateStage("simpleModule", HTTP_STAGE_MODULE, mp)) == 0) {
  33. return MPR_ERR_CANT_CREATE;
  34. }
  35. /*
  36. Create an appweb.conf custom directive
  37. */
  38. maAddDirective("CustomConfig", customConfig);
  39. return 0;
  40. }
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. /*
  45. Copyright (c) Embedthis Software. All Rights Reserved.
  46. This software is distributed under commercial and open source licenses.
  47. You may use the Embedthis Open Source license or you may acquire a
  48. commercial license from Embedthis Software. You agree to be fully bound
  49. by the terms of either license. Consult the LICENSE.md distributed with
  50. this software for full details and other copyrights.
  51. */