examplelib.cpp 2.6 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. #include <time.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <ctype.h>
  17. #include "examplelib.hpp"
  18. #define EXAMPLELIB_VERSION "EXAMPLELIB 1.0.00"
  19. static const char * HoleDefinition = NULL;
  20. static const char * EclDefinition =
  21. "export ExampleLib := SERVICE\n"
  22. " string EchoString(const string src) : c, pure,fold,entrypoint='elEchoString'; \n"
  23. "END;";
  24. EXAMPLELIB_API bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb)
  25. {
  26. // Warning: This function may be called without the plugin being loaded fully.
  27. // It should not make any library calls or assume that dependent modules
  28. // have been loaded or that it has been initialised.
  29. //
  30. // Specifically: "The system does not call DllMain for process and thread
  31. // initialization and termination. Also, the system does not load
  32. // additional executable modules that are referenced by the specified module."
  33. if (pb->size != sizeof(ECLPluginDefinitionBlock))
  34. return false;
  35. pb->magicVersion = PLUGIN_VERSION;
  36. pb->version = EXAMPLELIB_VERSION " $Revision: 62376 $";
  37. pb->moduleName = "lib_examplelib";
  38. pb->ECL = EclDefinition;
  39. pb->Hole = HoleDefinition;
  40. pb->flags = PLUGIN_IMPLICIT_MODULE;
  41. pb->description = "ExampleLib example services library";
  42. return true;
  43. }
  44. namespace nsExamplelib {
  45. IPluginContext * parentCtx = NULL;
  46. }
  47. using namespace nsExamplelib;
  48. EXAMPLELIB_API void setPluginContext(IPluginContext * _ctx) { parentCtx = _ctx; }
  49. //-------------------------------------------------------------------------------------------------------------------------------------------
  50. EXAMPLELIB_API void EXAMPLELIB_CALL elEchoString(unsigned & tgtLen, char * & tgt, unsigned srcLen, const char * src)
  51. {
  52. tgt = (char *)CTXMALLOC(parentCtx, srcLen);
  53. memcpy(tgt,src,srcLen);
  54. tgtLen = srcLen;
  55. }