1 /***************************************************************************** 2 * csri: common subtitle renderer interface 3 ***************************************************************************** 4 * Copyright (C) 2007 David Lamparter 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * - Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * - Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * - The name of the author may not be used to endorse or promote products 17 * derived from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 29 ****************************************************************************/ 30 31 /** \file subhelp.h - subtitle helper API. 32 * $Id$ */ 33 34 #ifndef _SUBHELP_H 35 #define _SUBHELP_H 36 37 #include <stdarg.h> 38 #include <csri/csri.h> 39 #include <csri/logging.h> 40 41 /** \defgroup subhelp subtitle filter helper API. */ 42 /*@{*/ 43 44 /** file opening wrapper. 45 * can be used to implement csri_open_file() by using csri_open_mem(). 46 * \param renderer the renderer handle 47 * \param memopenfunc function pointer to a csri_open_mem() implementation 48 * \param filename name of file to open 49 * \param flags pointer #csri_openflag.\n 50 * subhelp_open_file will fill in csri.openerr if present 51 * \return return value from memopenfunc or NULL on fs error 52 */ 53 extern csri_inst *subhelp_open_file(csri_rend *renderer, 54 csri_inst *(*memopenfunc)(csri_rend *renderer, const void *data, 55 size_t length, struct csri_openflag *flags), 56 const char *filename, struct csri_openflag *flags); 57 58 59 /** logging extension query function. 60 * call from csri_query_ext BEFORE checking whether the renderer. 61 * \code 62 * void *csri_query_ext(csri_rend *rend, csri_ext_id extname) { 63 * void *rv; 64 * if ((rv = subhelp_query_ext_logging(extname))) 65 * return rv; 66 * if (!rend) 67 * return NULL; 68 * ... 69 * \endcode 70 * \param extname the extension name. compared to "csri.logging" by 71 * this function. 72 * \return logging extension pointer, if the extension name matched. 73 * NULL otherwise. 74 */ 75 extern void *subhelp_query_ext_logging(csri_ext_id extname); 76 77 /** configure other renderer with our settings. 78 * \param logext csri.logging from configuree. 79 */ 80 extern void subhelp_logging_pass(struct csri_logging_ext *logext); 81 82 /** logging function. 83 * \param severity severity of this message, as defined by csri.logging 84 * \param msg log message, one line, without \\n at the end. 85 */ 86 extern void subhelp_log(enum csri_logging_severity severity, 87 const char *msg, ...) 88 #ifdef __GNUC__ 89 __attribute__((format(printf, 2, 3))) 90 #endif 91 ; 92 93 /** logging function, varargs version. 94 * \param severity severity of this message, as defined by csri.logging 95 * \param msg log message, one line, without \\n at the end. 96 * \param args argument list 97 */ 98 extern void subhelp_vlog(enum csri_logging_severity severity, 99 const char *msg, va_list args) 100 #ifdef __GNUC__ 101 __attribute__((format(printf, 2, 0))) 102 #endif 103 ; 104 105 /** logging function, fixed string version. 106 * \param severity severity of this message, as defined by csri.logging 107 * \param msg log message, one line, without \\n at the end. 108 */ 109 extern void subhelp_slog(enum csri_logging_severity severity, const char *msg); 110 111 /*@}*/ 112 113 #endif /* _SUBHELP_H */ 114 115