1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <cassert> 4 #include "streamio.h" 5 #include "phio_stream.h" 6 #include "phio_posix.h" 7 #include "phio_base.h" 8 9 grstream geomRestartStream; 10 rstream restartStream; 11 12 static struct phio_ops stream_ops = { 13 stream_openfile, 14 stream_closefile, 15 stream_readheader, 16 stream_writeheader, 17 stream_readdatablock, 18 stream_writedatablock, 19 stream_constructname 20 }; 21 22 void streamio_read_r(phio_fp* f, RStream* rs) { 23 assert(f); 24 assert(rs); 25 stream_fp sf = (stream_fp) *f; 26 sf->mode = 'r'; 27 } 28 29 void streamio_setup_read(phio_fp* f, GRStream* grs) { 30 *f = (phio_fp) malloc(sizeof(struct streamio_file)); 31 stream_fp sf = (stream_fp) *f; 32 sf->ops = &stream_ops; 33 sf->mode = 'r'; 34 sf->grs = grs; 35 sf->rs = NULL; 36 } 37 38 void streamio_setup_write(phio_fp* f, RStream* rs) { 39 *f = (phio_fp) malloc(sizeof(struct streamio_file)); 40 stream_fp sf = (stream_fp) *f; 41 sf->ops = &stream_ops; 42 sf->mode = 'w'; 43 sf->grs = NULL; 44 sf->rs = rs; 45 } 46 47 void streamio_set_gr(grstream grs) { 48 geomRestartStream = grs; 49 } 50 51 grstream streamio_get_gr() { 52 return geomRestartStream; 53 } 54 55 void streamio_set_r(rstream rs) { 56 restartStream = rs; 57 } 58 59 rstream streamio_get_r() { 60 return restartStream; 61 } 62