39 #include <sys/types.h>
101 baciol(
int mode,
long int start,
int size,
long int no,
102 long int *nactual,
int *fdes,
const char *fname,
void *datary)
118 *fdes = open(fname, O_RDONLY , S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP);
122 *fdes = open(fname, O_WRONLY | O_CREAT , S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP);
126 *fdes = open(fname, O_WRONLY | O_CREAT | O_TRUNC , S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP);
130 *fdes = open(fname, O_WRONLY | O_CREAT | O_APPEND , S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP);
134 *fdes = open(fname, O_RDWR | O_CREAT , S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP);
152 if (lseek(*fdes, start, SEEK_SET) == -1)
157 printf(
"Massive catastrophe -- datary pointer is NULL\n");
160 *nactual = read(*fdes, (
void *)datary, (
size_t)no);
171 if (lseek(*fdes, start, SEEK_SET) == -1)
176 printf(
"Massive catastrophe -- datary pointer is NULL\n");
179 *nactual = write(*fdes, (
void *) datary, (
size_t)no);
184 if (close(*fdes) != 0)
int baciol(int mode, long int start, int size, long int no, long int *nactual, int *fdes, const char *fname, void *datary)
Do a bacio operation.
Include file to define variables for Fortran to C interface(s) revision history.
#define BA_ECLOSE
Error in close.
#define BA_NOERROR
No error.
#define BA_EFEWDATA
Read or wrote fewer data than requested.
#define BA_EDATANULL
Data pointer is NULL.
#define BA_EROANDWO
Tried to open read only and write only.
#define BA_EFILEOPEN
Failure in opening file.
#define BA_EWANDRO
Tried to write to a read only file.
#define BA_ERANDW
Tried to read and write in the same call.
#define BAOPEN_WONLY
Open or create file for Write only.
#define BAOPEN_WONLY_APPEND
Open or create a file for write only append.
#define BAOPEN_RONLY
Open file read only.
#define BA_ERNOSTART
Failed in read to find the 'start' location.
#define BAWRITE
Write to an open file.
#define BAREAD
Read from an open file.
#define BAOPEN_WONLY_TRUNC
Open or create a file for write only, truncating existing contents.
#define BAOPEN_RW
Open or create file for read/write.
#define BA_ERONWO
Tried to read on a write-only file.
#define NOSEEK
No seek ignore start parameter and do not call lseek().
#define BACLOSE
Close an open file.
#define BA_EWNOSTART
Failed in write to find the 'start' location.