libsc
1.6.0
|
00001 /* 00002 This file is part of the SC Library. 00003 The SC Library provides support for parallel scientific applications. 00004 00005 Copyright (C) 2010 The University of Texas System 00006 00007 The SC Library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 The SC Library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with the SC Library; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00020 02110-1301, USA. 00021 */ 00022 00023 #ifndef SC_IO_H 00024 #define SC_IO_H 00025 00026 #include <sc.h> 00027 #include <sc_containers.h> 00028 00029 SC_EXTERN_C_BEGIN; 00030 00033 typedef enum 00034 { 00035 SC_IO_ERROR_NONE, 00036 SC_IO_ERROR_FATAL = -1, 00037 SC_IO_ERROR_AGAIN = -2 00039 } 00040 sc_io_error_t; 00041 00042 typedef enum 00043 { 00044 SC_IO_MODE_WRITE, 00045 SC_IO_MODE_APPEND, 00046 SC_IO_MODE_LAST 00047 } 00048 sc_io_mode_t; 00049 00050 typedef enum 00051 { 00052 SC_IO_ENCODE_NONE, 00053 SC_IO_ENCODE_LAST 00054 } 00055 sc_io_encode_t; 00056 00057 typedef enum 00058 { 00059 SC_IO_TYPE_BUFFER, 00060 SC_IO_TYPE_FILENAME, 00061 SC_IO_TYPE_FILEFILE, 00062 SC_IO_TYPE_LAST 00063 } 00064 sc_io_type_t; 00065 00066 typedef struct sc_io_sink 00067 { 00068 sc_io_type_t iotype; 00069 sc_io_mode_t mode; 00070 sc_io_encode_t encode; 00071 sc_array_t *buffer; 00072 size_t buffer_bytes; 00073 FILE *file; 00074 size_t bytes_in; 00075 size_t bytes_out; 00076 } 00077 sc_io_sink_t; 00078 00079 typedef struct sc_io_source 00080 { 00081 sc_io_type_t iotype; 00082 sc_io_encode_t encode; 00083 sc_array_t *buffer; 00084 size_t buffer_bytes; 00085 FILE *file; 00086 size_t bytes_in; 00087 size_t bytes_out; 00088 } 00089 sc_io_source_t; 00090 00103 sc_io_sink_t *sc_io_sink_new (sc_io_type_t iotype, 00104 sc_io_mode_t mode, 00105 sc_io_encode_t encode, ...); 00106 00114 int sc_io_sink_destroy (sc_io_sink_t * sink); 00115 00123 int sc_io_sink_write (sc_io_sink_t * sink, 00124 const void *data, size_t bytes_avail); 00125 00144 int sc_io_sink_complete (sc_io_sink_t * sink, 00145 size_t * bytes_in, 00146 size_t * bytes_out); 00147 00157 sc_io_source_t *sc_io_source_new (sc_io_type_t iotype, 00158 sc_io_encode_t encode, ...); 00159 00167 int sc_io_source_destroy (sc_io_source_t * source); 00168 00184 int sc_io_source_read (sc_io_source_t * source, 00185 void *data, size_t bytes_avail, 00186 size_t * bytes_out); 00187 00203 int sc_io_source_complete (sc_io_source_t * source, 00204 size_t * bytes_in, 00205 size_t * bytes_out); 00206 00213 int sc_vtk_write_binary (FILE * vtkfile, char *numeric_data, 00214 size_t byte_length); 00215 00222 int sc_vtk_write_compressed (FILE * vtkfile, 00223 char *numeric_data, 00224 size_t byte_length); 00225 00234 void sc_fwrite (const void *ptr, size_t size, 00235 size_t nmemb, FILE * file, const char *errmsg); 00236 00245 void sc_fread (void *ptr, size_t size, 00246 size_t nmemb, FILE * file, const char *errmsg); 00247 00248 #ifdef SC_ENABLE_MPIIO 00249 00258 void sc_mpi_write (MPI_File mpifile, const void *ptr, 00259 size_t zcount, sc_MPI_Datatype t, 00260 const char *errmsg); 00261 00262 #endif 00263 00264 SC_EXTERN_C_END; 00265 00266 #endif /* SC_IO_H */