1 /*=========================================================================== 2 * Filename : scmport-str.h 3 * About : A ScmBytePort implementation for string 4 * 5 * Copyright (C) 2005-2006 YAMAMOTO Kengo <yamaken AT bp.iij4u.or.jp> 6 * Copyright (c) 2007-2008 SigScheme Project <uim-en AT googlegroups.com> 7 * 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. Neither the name of authors nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS 24 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 25 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR 27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 30 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 31 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 32 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 ===========================================================================*/ 35 36 /* 37 * This file is intended to be portable. Don't depend on SigScheme and don't 38 * merge into another file. 39 */ 40 41 #ifndef __SCM_SCMPORT_STR_H 42 #define __SCM_SCMPORT_STR_H 43 44 #include "scmport.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /*======================================= 51 Macro Definitions 52 =======================================*/ 53 54 /*======================================= 55 Type Definitions 56 =======================================*/ 57 typedef void (*ScmInputStrPort_finalizer)(char **str, scm_bool ownership, 58 void **opaque); 59 typedef void (*ScmOutputStrPort_finalizer)(char **str, size_t buf_size, 60 void **opaque); 61 62 /*======================================= 63 Variable Declarations 64 =======================================*/ 65 SCM_EXTERN(const ScmBytePortVTbl *const ScmInputStrPort_vptr); 66 SCM_EXTERN(const ScmBytePortVTbl *const ScmOutputStrPort_vptr); 67 68 /*======================================= 69 Function Declarations 70 =======================================*/ 71 SCM_EXPORT void scm_strport_init(void); 72 73 SCM_EXPORT ScmBytePort *ScmInputStrPort_new(char *str, ScmInputStrPort_finalizer finalize); 74 SCM_EXPORT ScmBytePort *ScmInputStrPort_new_copying(const char *str, ScmInputStrPort_finalizer finalize); 75 SCM_EXPORT ScmBytePort *ScmInputStrPort_new_const(const char *str, ScmInputStrPort_finalizer finalize); 76 SCM_EXPORT void **ScmInputStrPort_ref_opaque(ScmBytePort *bport); 77 78 SCM_EXPORT ScmBytePort *ScmOutputStrPort_new(ScmOutputStrPort_finalizer finalize); 79 SCM_EXPORT const char *ScmOutputStrPort_str(ScmBytePort *bport); 80 SCM_EXPORT size_t ScmOutputStrPort_c_strlen(ScmBytePort *bport); 81 SCM_EXPORT void **ScmOutputStrPort_ref_opaque(ScmBytePort *bport); 82 83 #ifdef __cplusplus 84 } 85 #endif 86 87 #endif /* __SCM_SCMPORT_STR_H */ 88