plugin.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #pragma warning (disable : 4786)
  14. //JLib
  15. #include "jliball.hpp"
  16. //SCM Interfaces
  17. #include "esp.hpp"
  18. //ESP Core
  19. #include "espthread.hpp"
  20. #include "espplugin.hpp"
  21. //ESP Bindings
  22. #include "http/platform/httpprot.hpp"
  23. extern "C"
  24. {
  25. esp_http_decl IEspProtocol * http_protocol_factory(const char *name, const char* type, IPropertyTree *cfg, const char *process)
  26. {
  27. if (strcmp(type, "http_protocol")==0)
  28. {
  29. return new CHttpProtocol;
  30. }
  31. else if(strcmp(type, "secure_http_protocol") == 0)
  32. {
  33. IPropertyTree *sslSettings;
  34. sslSettings = cfg->getPropTree(StringBuffer("Software/EspProcess[@name=\"").append(process).append("\"]").append("/EspProtocol[@name=\"").append(name).append("\"]").str());
  35. if(sslSettings != NULL)
  36. {
  37. return new CSecureHttpProtocol(sslSettings);
  38. }
  39. else
  40. {
  41. throw MakeStringException(-1, "can't find ssl settings in the config file");
  42. }
  43. }
  44. else
  45. {
  46. throw MakeStringException(-1, "Unknown protocol %s", name);
  47. }
  48. return NULL;
  49. }
  50. //#ifdef ESP_PLUGIN
  51. ESP_FACTORY IEspProtocol * esp_protocol_factory(const char *name, const char* type, IPropertyTree *cfg, const char *process)
  52. {
  53. return http_protocol_factory(name, type, cfg, process);
  54. }
  55. //#endif //ESP_PLUGIN
  56. };