coan 4.2.4
|
00001 #ifndef IO_H 00002 #define IO_H 00003 00004 /*************************************************************************** 00005 * Copyright (C) 2004, 2006 Symbian Software Ltd. * 00006 * All rights reserved. * 00007 * Copyright (C) 2007-2011 Mike Kinghan, imk@strudl.org * 00008 * All rights reserved. * 00009 * * 00010 * Contributed originally by Mike Kinghan, imk@strudl.org * 00011 * * 00012 * Redistribution and use in source and binary forms, with or without * 00013 * modification, are permitted provided that the following conditions * 00014 * are met: * 00015 * * 00016 * Redistributions of source code must retain the above copyright * 00017 * notice, this list of conditions and the following disclaimer. * 00018 * * 00019 * Redistributions in binary form must reproduce the above copyright * 00020 * notice, this list of conditions and the following disclaimer in the * 00021 * documentation and/or other materials provided with the distribution. * 00022 * * 00023 * Neither the name of Symbian Software Ltd. nor the names of its * 00024 * contributors may be used to endorse or promote products derived from * 00025 * this software without specific prior written permission. * 00026 * * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 00028 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 00029 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * 00030 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 00031 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * 00032 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * 00033 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * 00034 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * 00035 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,* 00036 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * 00037 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 00038 * DAMAGE. * 00039 * * 00040 **************************************************************************/ 00041 #include <stdio.h> 00042 00051 #define STDIN_NAME "[stdin]" 00052 00054 #define LINE_START GET_PUBLIC(io,line_start) 00055 00057 #define LINE_END (GET_PUBLIC(io,line_start) + GET_PUBLIC(io,line_len)) 00058 00060 #define LINE_OFF(addr) (addr - LINE_START) 00061 00063 #define INSOURCE (GET_PUBLIC(io,line_num) != 0) 00064 00065 00071 extern 00072 char * read_filename(void); 00073 00080 extern 00081 FILE * open_file(const char *file, const char *mode); 00082 00089 extern void 00090 open_io(char const *filename); 00091 00105 extern void 00106 close_io(int error); 00107 00109 extern void 00110 close_input(void); 00111 00115 extern bool 00116 get_line(void); 00117 00131 extern char * 00132 read_more(char const *readpos); 00133 00136 extern bool 00137 input_opened(void); 00138 00144 extern void 00145 ensure_buf(size_t extra); 00146 00155 extern void 00156 save_read_pos(char const *cp); 00157 00166 extern char * 00167 saved_read_pos(void); 00168 00170 extern void 00171 io_toplevel(void); 00172 00174 extern size_t 00175 read_offset(char const *readpos); 00176 00178 extern char * 00179 read_pos(size_t readoff); 00180 00181 00185 /*@(*/ 00186 00188 PUBLIC_STATE_DEF(io) 00189 { 00190 int line_num; 00191 const char *filename; 00192 char *line_start; 00193 char *pristine_line; 00195 size_t line_len; 00197 FILE * output; 00198 unsigned extension_lines; 00200 } 00201 PUBLIC_STATE_T(io); 00202 00206 /*@(*/ 00207 IMPORT(io); 00211 #endif /* EOF*/