1 #include <stdio.h> 2 #include <stdlib.h> 3 #include "streamio.h" 4 #include "phio_stream.h" 5 #include "phio_posix.h" 6 #include "phio_base.h" 7 8 extern grstream geomRestartStream; 9 10 static struct phio_ops stream_ops = { 11 stream_openfile, 12 stream_closefile, 13 stream_readheader, 14 posix_writeheader, 15 stream_readdatablock, 16 posix_writedatablock, 17 stream_constructname 18 }; 19 20 void streamio_setup_read(phio_fp* f, GRStream* grs) { 21 *f = (phio_fp) malloc(sizeof(struct streamio_file)); 22 stream_fp sf = (stream_fp) *f; 23 sf->ops = &stream_ops; 24 sf->file = (int*) malloc(sizeof(int*)); 25 sf->mode = 'r'; 26 sf->grs = grs; 27 sf->rs = NULL; 28 } 29 30 void streamio_setup_write(phio_fp* f, RStream* rs) { 31 *f = (phio_fp) malloc(sizeof(struct streamio_file)); 32 stream_fp sf = (stream_fp) *f; 33 sf->ops = &stream_ops; 34 sf->file = (int*) malloc(sizeof(int*)); 35 sf->mode = 'w'; 36 sf->grs = NULL; 37 sf->rs = rs; 38 } 39 40 void streamio_set_gr(grstream grs) { 41 geomRestartStream = grs; 42 } 43 44 grstream streamio_get_gr() { 45 return geomRestartStream; 46 } 47