proc.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2013 Hugh Bailey <[email protected]>
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #pragma once
  17. #include "../util/c99defs.h"
  18. #include "calldata.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /*
  23. * Dynamic procedure handler
  24. *
  25. * This handler is used to allow dynamic access to one or more procedures
  26. * that can be dynamically added and called without having to have direct
  27. * access to declarations or procedure callback pointers.
  28. */
  29. struct proc_handler;
  30. typedef struct proc_handler *proc_handler_t;
  31. EXPORT proc_handler_t proc_handler_create(void);
  32. EXPORT void proc_handler_destroy(proc_handler_t handler);
  33. EXPORT void proc_handler_add(proc_handler_t handler, const char *name,
  34. void (*proc)(calldata_t, void*), void *data);
  35. /**
  36. * Calls a function in a procedure handler. Returns false if the named
  37. * procedure is not found.
  38. */
  39. EXPORT bool proc_handler_call(proc_handler_t handler, const char *name,
  40. calldata_t params);
  41. #ifdef __cplusplus
  42. }
  43. #endif