hqlplugins.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*##############################################################################
  2. Copyright (C) 2011 HPCC Systems.
  3. All rights reserved. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ############################################################################## */
  14. #ifndef __HQLPLUGIN_INCL
  15. #define __HQLPLUGIN_INCL
  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