exampleplugin.cpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2016 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. #include "platform.h"
  14. #include "eclrtl.hpp"
  15. #include "jstring.hpp"
  16. #include "exampleplugin.hpp"
  17. #define EXAMPLE_PLUGIN_VERSION "example-plugin plugin 1.0.0"
  18. ECL_EXAMPLE_PLUGIN_API bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb)
  19. {
  20. /* Warning: This function may be called without the plugin being loaded fully.
  21. * It should not make any library calls or assume that dependent modules
  22. * have been loaded or that it has been initialised.
  23. *
  24. * Specifically: "The system does not call DllMain for process and thread
  25. * initialization and termination. Also, the system does not load
  26. * additional executable modules that are referenced by the specified module."
  27. */
  28. if (pb->size != sizeof(ECLPluginDefinitionBlock))
  29. return false;
  30. pb->magicVersion = PLUGIN_VERSION;
  31. pb->version = EXAMPLE_PLUGIN_VERSION;
  32. pb->moduleName = "lib_redis";
  33. pb->ECL = NULL;
  34. pb->flags = PLUGIN_IMPLICIT_MODULE;
  35. pb->description = "ECL plugin library for BLAH BLAH BLAH";
  36. return true;
  37. }
  38. namespace ExamplePlugin {
  39. //--------------------------------------------------------------------------------
  40. // ECL SERVICE ENTRYPOINTS
  41. //--------------------------------------------------------------------------------
  42. ECL_EXAMPLE_PLUGIN_API unsigned ECL_EXAMPLE_PLUGIN_CALL func1(ICodeContext * ctx, const char * param1, const char * param2, unsigned param3)
  43. {
  44. return param3 + 1;
  45. }
  46. ECL_EXAMPLE_PLUGIN_API void ECL_EXAMPLE_PLUGIN_CALL func2 (ICodeContext * _ctx, size32_t & returnLength, char * & returnValue, const char * param1, const char * param2, size32_t param3ValueLength, const char * param3Value)
  47. {
  48. StringBuffer buffer(param3Value);
  49. buffer.toLowerCase();
  50. returnLength = buffer.length();
  51. returnValue = buffer.detach();
  52. return;
  53. }
  54. }//close namespace