1 /* $Id: element.h,v 1.5 2003/05/16 21:48:14 fredette Exp $ */ 2 3 /* tme/element.h - public header file for elements: */ 4 5 /* 6 * Copyright (c) 2003 Matt Fredette 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by Matt Fredette. 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 #ifndef _TME_ELEMENT_H 37 #define _TME_ELEMENT_H 38 39 #include <tme/common.h> 40 _TME_RCSID("$Id: element.h,v 1.5 2003/05/16 21:48:14 fredette Exp $"); 41 42 /* includes: */ 43 #include <tme/connection.h> 44 #include <tme/module.h> 45 #include <tme/log.h> 46 47 /* macros: */ 48 49 /* these make exported element new function symbol names: */ 50 #define TME_ELEMENT_NEW_SYM(module) TME_MODULE_SYM(module,new) 51 #define TME_ELEMENT_SUB_NEW_SYM(module,sub) TME_MODULE_SUB_SYM(module,sub,_new) 52 #define TME_ELEMENT_X_NEW_SYM(class,agg,sub) TME_MODULE_X_SYM(class,agg,sub,_new) 53 54 /* these make exported element new function prototypes: */ 55 #define _TME_ELEMENT_NEW_P(sym) \ 56 int sym _TME_P((struct tme_element *, _tme_const char * _tme_const *, const void *, char **)) 57 #define TME_ELEMENT_NEW_P(module) \ 58 _TME_ELEMENT_NEW_P(TME_ELEMENT_NEW_SYM(module)) 59 #define TME_ELEMENT_SUB_NEW_P(module,sub) \ 60 _TME_ELEMENT_NEW_P(TME_ELEMENT_SUB_NEW_SYM(module,sub)) 61 #define TME_ELEMENT_X_NEW_P(class,agg,sub) \ 62 _TME_ELEMENT_NEW_P(TME_ELEMENT_X_NEW_SYM(class,agg,sub)) 63 64 /* these declare exported new functions: */ 65 #ifdef __STDC__ 66 #define _TME_ELEMENT_NEW_DECL(sym) \ 67 _TME_ELEMENT_NEW_P(sym); \ 68 int sym(struct tme_element *element, const char * const *args, const void *extra, char **_output) 69 #else /* !__STDC__ */ 70 #define _TME_ELEMENT_NEW_DECL(sym) \ 71 _TME_ELEMENT_NEW_P(sym); \ 72 int sym(element, args, extra, _output) \ 73 struct tme_element *element; \ 74 const char **args; \ 75 const void *extra; \ 76 char **_output; 77 #endif /* !__STDC__ */ 78 #define TME_ELEMENT_NEW_DECL(module) \ 79 _TME_ELEMENT_NEW_DECL(TME_ELEMENT_NEW_SYM(module)) 80 #define TME_ELEMENT_SUB_NEW_DECL(module,sub) \ 81 _TME_ELEMENT_NEW_DECL(TME_ELEMENT_SUB_NEW_SYM(module,sub)) 82 #define TME_ELEMENT_X_NEW_DECL(class,agg,sub) \ 83 _TME_ELEMENT_NEW_DECL(TME_ELEMENT_X_NEW_SYM(class,agg,sub)) 84 85 /* structures: */ 86 struct tme_connection; 87 88 /* an element: */ 89 struct tme_element { 90 91 /* elements can be kept in a list: */ 92 struct tme_element *tme_element_next; 93 94 /* the module implementing the element: */ 95 void *tme_element_module; 96 97 /* the element's private data structure: */ 98 void *tme_element_private; 99 100 /* the logging handle: */ 101 struct tme_log_handle tme_element_log_handle; 102 103 /* this function returns the possible new connection sides to the 104 element: */ 105 int (*tme_element_connections_new) _TME_P((struct tme_element *, 106 _tme_const char * _tme_const *, 107 struct tme_connection **, 108 char **)); 109 110 /* the element command function: */ 111 int (*tme_element_command) _TME_P((struct tme_element *, 112 _tme_const char * _tme_const *, 113 char **)); 114 }; 115 116 /* prototypes: */ 117 int tme_element_new _TME_P((struct tme_element *, 118 _tme_const char * _tme_const *, 119 void *, 120 char **)); 121 int tme_element_connect _TME_P((struct tme_element *, 122 _tme_const char * _tme_const *, 123 struct tme_element *, 124 _tme_const char * _tme_const *, 125 char **, int *)); 126 127 #endif /* !_TME_ELEMENT_H */ 128