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 static struct phio_ops stream_ops = { 9 stream_openfile, 10 stream_closefile, 11 posix_readheader, 12 posix_writeheader, 13 posix_readdatablock, 14 posix_writedatablock, 15 stream_constructname 16 }; 17 18 void streamio_setup_read(phio_fp* f, GRStream* grs) { 19 *f = (phio_fp) malloc(sizeof(struct streamio_file)); 20 stream_fp sf = (stream_fp) *f; 21 sf->ops = &stream_ops; 22 sf->file = (int*) malloc(sizeof(int*)); 23 sf->mode = 'r'; 24 sf->grs = grs; 25 sf->rs = NULL; 26 } 27 28 void streamio_setup_write(phio_fp* f, RStream* rs) { 29 *f = (phio_fp) malloc(sizeof(struct streamio_file)); 30 stream_fp sf = (stream_fp) *f; 31 sf->ops = &stream_ops; 32 sf->file = (int*) malloc(sizeof(int*)); 33 sf->mode = 'w'; 34 sf->grs = NULL; 35 sf->rs = rs; 36 } 37