1 /* $NetBSD: citrus_stdenc_local.h,v 1.2 2003/06/26 12:09:57 tshiozak Exp $ */ 2 3 /*- 4 * Copyright (c)2003 Citrus Project, 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 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 */ 29 30 #ifndef _CITRUS_STDENC_LOCAL_H_ 31 #define _CITRUS_STDENC_LOCAL_H_ 32 33 #define _CITRUS_STDENC_GETOPS_FUNC_BASE(n) \ 34 int n(struct _citrus_stdenc_ops *, size_t, u_int32_t) 35 #define _CITRUS_STDENC_GETOPS_FUNC(_e_) \ 36 _CITRUS_STDENC_GETOPS_FUNC_BASE(_citrus_##_e_##_stdenc_getops) 37 typedef _CITRUS_STDENC_GETOPS_FUNC_BASE((*_citrus_stdenc_getops_t)); 38 39 40 #define _CITRUS_STDENC_DECLS(_e_) \ 41 static int _citrus_##_e_##_stdenc_init \ 42 (struct _citrus_stdenc * __restrict, const void * __restrict, \ 43 size_t, struct _citrus_stdenc_traits * __restrict); \ 44 static void _citrus_##_e_##_stdenc_uninit(struct _citrus_stdenc *); \ 45 static int _citrus_##_e_##_stdenc_init_state \ 46 (struct _citrus_stdenc * __restrict, void * __restrict); \ 47 static int _citrus_##_e_##_stdenc_mbtocs \ 48 (struct _citrus_stdenc * __restrict, \ 49 _citrus_csid_t * __restrict, _citrus_index_t * __restrict, \ 50 const char ** __restrict, size_t, \ 51 void * __restrict, size_t * __restrict); \ 52 static int _citrus_##_e_##_stdenc_cstomb \ 53 (struct _citrus_stdenc * __restrict, char * __restrict, \ 54 size_t, _citrus_csid_t, _citrus_index_t, \ 55 void * __restrict, size_t * __restrict); \ 56 static int _citrus_##_e_##_stdenc_mbtowc \ 57 (struct _citrus_stdenc * __restrict, \ 58 _citrus_wc_t * __restrict, \ 59 const char ** __restrict, size_t, \ 60 void * __restrict, size_t * __restrict); \ 61 static int _citrus_##_e_##_stdenc_wctomb \ 62 (struct _citrus_stdenc * __restrict, char * __restrict, size_t, \ 63 _citrus_wc_t, void * __restrict, size_t * __restrict); \ 64 static int _citrus_##_e_##_stdenc_put_state_reset \ 65 (struct _citrus_stdenc * __restrict, char * __restrict, size_t, \ 66 void * __restrict, size_t * __restrict) 67 68 #define _CITRUS_STDENC_DEF_OPS(_e_) \ 69 struct _citrus_stdenc_ops _citrus_##_e_##_stdenc_ops = { \ 70 /* eo_abi_version */ _CITRUS_STDENC_ABI_VERSION, \ 71 /* eo_init */ &_citrus_##_e_##_stdenc_init, \ 72 /* eo_uninit */ &_citrus_##_e_##_stdenc_uninit, \ 73 /* eo_init_state */ &_citrus_##_e_##_stdenc_init_state, \ 74 /* eo_mbtocs */ &_citrus_##_e_##_stdenc_mbtocs, \ 75 /* eo_cstomb */ &_citrus_##_e_##_stdenc_cstomb, \ 76 /* eo_mbtowc */ &_citrus_##_e_##_stdenc_mbtowc, \ 77 /* eo_wctomb */ &_citrus_##_e_##_stdenc_wctomb, \ 78 /* eo_put_state_reset */&_citrus_##_e_##_stdenc_put_state_reset \ 79 } 80 81 typedef int (*_citrus_stdenc_init_t) 82 (struct _citrus_stdenc * __reatrict, const void * __restrict , size_t, 83 struct _citrus_stdenc_traits * __restrict); 84 typedef void (*_citrus_stdenc_uninit_t)(struct _citrus_stdenc * __restrict); 85 typedef int (*_citrus_stdenc_init_state_t) 86 (struct _citrus_stdenc * __restrict, void * __restrict); 87 typedef int (*_citrus_stdenc_mbtocs_t) 88 (struct _citrus_stdenc * __restrict, 89 _citrus_csid_t * __restrict, _citrus_index_t * __restrict, 90 const char ** __restrict, size_t, 91 void * __restrict, size_t * __restrict); 92 typedef int (*_citrus_stdenc_cstomb_t) 93 (struct _citrus_stdenc *__restrict, char * __restrict, size_t, 94 _citrus_csid_t, _citrus_index_t, void * __restrict, 95 size_t * __restrict); 96 typedef int (*_citrus_stdenc_mbtowc_t) 97 (struct _citrus_stdenc * __restrict, 98 _citrus_wc_t * __restrict, 99 const char ** __restrict, size_t, 100 void * __restrict, size_t * __restrict); 101 typedef int (*_citrus_stdenc_wctomb_t) 102 (struct _citrus_stdenc *__restrict, char * __restrict, size_t, 103 _citrus_wc_t, void * __restrict, size_t * __restrict); 104 typedef int (*_citrus_stdenc_put_state_reset_t) 105 (struct _citrus_stdenc *__restrict, char * __restrict, size_t, 106 void * __restrict, size_t * __restrict); 107 108 /* 109 * ABI version change log 110 * 0x00000001 111 * initial version 112 */ 113 #define _CITRUS_STDENC_ABI_VERSION 0x00000001 114 struct _citrus_stdenc_ops { 115 u_int32_t eo_abi_version; 116 /* version 0x00000001 */ 117 _citrus_stdenc_init_t eo_init; 118 _citrus_stdenc_uninit_t eo_uninit; 119 _citrus_stdenc_init_state_t eo_init_state; 120 _citrus_stdenc_mbtocs_t eo_mbtocs; 121 _citrus_stdenc_cstomb_t eo_cstomb; 122 _citrus_stdenc_mbtowc_t eo_mbtowc; 123 _citrus_stdenc_wctomb_t eo_wctomb; 124 _citrus_stdenc_put_state_reset_t eo_put_state_reset; 125 }; 126 127 struct _citrus_stdenc_traits { 128 /* version 0x00000001 */ 129 size_t et_state_size; 130 size_t et_mb_cur_max; 131 }; 132 133 struct _citrus_stdenc { 134 /* public */ 135 /* version 0x00000001 */ 136 struct _citrus_stdenc_ops *ce_ops; 137 void *ce_closure; 138 /* private */ 139 _citrus_module_t ce_module; 140 struct _citrus_stdenc_traits *ce_traits; 141 }; 142 143 #define _CITRUS_DEFAULT_STDENC_NAME "NONE" 144 145 #endif 146