1ab645d52SCameron Smith #include <stdio.h> 2ab645d52SCameron Smith #include <stdlib.h> 3ab645d52SCameron Smith #include "posixio.h" 4ab645d52SCameron Smith #include "phio_posix.h" 5ab645d52SCameron Smith #include "phio_base.h" 6ab645d52SCameron Smith 7ab645d52SCameron Smith static struct phio_ops posix_ops = { 8ab645d52SCameron Smith posix_openfile, 9ab645d52SCameron Smith posix_closefile, 10ab645d52SCameron Smith posix_readheader, 11ab645d52SCameron Smith posix_writeheader, 12ab645d52SCameron Smith posix_readdatablock, 13*a93de25bSCameron Smith posix_writedatablock, 14*a93de25bSCameron Smith posix_constructname 15ab645d52SCameron Smith }; 16ab645d52SCameron Smith 17ab645d52SCameron Smith void posixio_setup(phio_fp* f, char mode) { 18ab645d52SCameron Smith *f = (phio_fp) malloc(sizeof(struct phio_file)); 19ab645d52SCameron Smith (*f)->ops = &posix_ops; 20ab645d52SCameron Smith if(mode != 'r' && mode != 'w') { 21ab645d52SCameron Smith fprintf(stderr, "ERROR unsupported file mode in %s on line %d" 22ab645d52SCameron Smith "... exiting", __FILE__, __LINE__); 23ab645d52SCameron Smith exit(EXIT_FAILURE); 24ab645d52SCameron Smith } 25ab645d52SCameron Smith (*f)->file = (int*) malloc(sizeof(int*)); 26ab645d52SCameron Smith (*f)->mode = mode; 27ab645d52SCameron Smith } 28