examplelib.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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,entrypoint='elEchoString'; \n"
  23. "END;";
  24. EXAMPLELIB_API bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb)
  25. {
  26. if (pb->size != sizeof(ECLPluginDefinitionBlock))
  27. return false;
  28. pb->magicVersion = PLUGIN_VERSION;
  29. pb->version = EXAMPLELIB_VERSION " $Revision: 62376 $";
  30. pb->moduleName = "lib_examplelib";
  31. pb->ECL = EclDefinition;
  32. pb->Hole = HoleDefinition;
  33. pb->flags = PLUGIN_IMPLICIT_MODULE;
  34. pb->description = "ExampleLib example services library";
  35. return true;
  36. }
  37. namespace nsExamplelib {
  38. IPluginContext * parentCtx = NULL;
  39. }
  40. using namespace nsExamplelib;
  41. EXAMPLELIB_API void setPluginContext(IPluginContext * _ctx) { parentCtx = _ctx; }
  42. //-------------------------------------------------------------------------------------------------------------------------------------------
  43. EXAMPLELIB_API void EXAMPLELIB_CALL elEchoString(unsigned & tgtLen, char * & tgt, unsigned srcLen, const char * src)
  44. {
  45. tgt = (char *)CTXMALLOC(parentCtx, srcLen);
  46. memcpy(tgt,src,srcLen);
  47. tgtLen = srcLen;
  48. }