1 /* 2 * Copyright (c) 2013 Hugh Bailey <obs.jim@gmail.com> 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 17 #pragma once 18 19 #include "../util/c99defs.h" 20 21 #include "calldata.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* 28 * Procedure handler 29 * 30 * This handler is used to allow access to one or more procedures that can be 31 * added and called without having to have direct access to declarations or 32 * procedure callback pointers. 33 */ 34 35 struct proc_handler; 36 typedef struct proc_handler proc_handler_t; 37 typedef void (*proc_handler_proc_t)(void *, calldata_t *); 38 39 EXPORT proc_handler_t *proc_handler_create(void); 40 EXPORT void proc_handler_destroy(proc_handler_t *handler); 41 42 EXPORT void proc_handler_add(proc_handler_t *handler, const char *decl_string, 43 proc_handler_proc_t proc, void *data); 44 45 /** 46 * Calls a function in a procedure handler. Returns false if the named 47 * procedure is not found. 48 */ 49 EXPORT bool proc_handler_call(proc_handler_t *handler, const char *name, 50 calldata_t *params); 51 52 #ifdef __cplusplus 53 } 54 #endif 55