hqlplugins.hpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #ifndef __HQLPLUGIN_INCL
  14. #define __HQLPLUGIN_INCL
  15. #include "platform.h"
  16. #define PLUGIN_VERSION 2
  17. #define PLUGIN_IMPLICIT_MODULE 1
  18. #define PLUGIN_DLL_MODULE 4
  19. #define PLUGIN_MULTIPLE_VERSIONS 8
  20. #define ZOMBIE_MODULE 32
  21. #define PLUGIN_SAVEMASK 0x0ff
  22. struct ECLPluginDefinitionBlock
  23. {
  24. unsigned size; // Size of passed in structure, filled in by caller
  25. unsigned magicVersion; // Filled in by plugin - must be PLUGIN_VERSION
  26. const char *moduleName;
  27. const char *ECL;
  28. unsigned flags;
  29. const char *version;
  30. const char *description;
  31. };
  32. struct ECLPluginDefinitionBlockEx : public ECLPluginDefinitionBlock
  33. {
  34. const char **compatibleVersions;
  35. };
  36. typedef bool (*EclPluginDefinition) (ECLPluginDefinitionBlock *);
  37. //Enable DLL to call host to process memory allocation
  38. struct IPluginContext
  39. {
  40. virtual void * ctxMalloc(size_t size) =0;
  41. virtual void * ctxRealloc(void * memblock, size_t size) =0;
  42. virtual void ctxFree(void * memblock)=0;
  43. virtual char * ctxStrdup(char * str)=0;
  44. };
  45. struct IPluginContextEx : public IPluginContext
  46. {
  47. virtual int ctxGetPropInt(const char *propName, int defaultValue) const = 0;
  48. virtual const char *ctxQueryProp(const char *propName) const = 0;
  49. };
  50. typedef bool (*EclPluginSetCtx) (IPluginContext *);
  51. typedef bool (*EclPluginSetCtxEx) (IPluginContextEx *);
  52. #define CTXMALLOC(ctx,l) (ctx ? ctx->ctxMalloc(l) : malloc(l))
  53. #define CTXREALLOC(ctx,p,l) (ctx ? ctx->ctxRealloc(p,l) : realloc(p,l))
  54. #define CTXFREE(ctx,p) (ctx ? ctx->ctxFree(p) : free(p))
  55. #define CTXSTRDUP(ctx,p) (ctx ? ctx->ctxStrdup((char*)p) : strdup((char*)p))
  56. inline void * ctxDup(IPluginContext * ctx, const void * data, unsigned len)
  57. {
  58. void * tgt = CTXMALLOC(ctx, len);
  59. if (tgt)
  60. memcpy(tgt, data, len);
  61. return tgt;
  62. }
  63. #define CTXDUP(ctx,p,l) (ctxDup(ctx, p, l))
  64. #endif //__HQLPLUGIN_INCL