4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * Good ROcking Metal Altar for Chronical Sinners
33 static char *SRCID_binio_h = "$Id$";
39 #ident "@(#) binio.h 1.5 11/23/92"
40 #endif /* HAVE_IDENT */
47 * Module to binary write and read.
52 * @ @ @ @@@ @@ @@@ @@ @@ @@@ @@ @@ @@ @@
53 * @ @ @ @ @ @@ @ @@ @ @ @@ @ @ @@
54 * @ @ @ @ @ @ @ @ @ @ @ @ @
55 * @@ @@ @@@@@ @ @ @ @ @ @ @ @
56 * @ @ @ @ @ @ @ @ @ @ @ @
57 * @ @ @ @@ @ @ @ @ @ @ @ @@
58 * @ @ @@@ @@ @@@@ @@@ @@@ @@@@@ @@@ @@@ @@ @
63 * Use this module only to write and read simple types or array(s)
64 * of simple types. STRUCTURES ARE DEFINITELY NOT ALLOWED.
67 #define nblockwrite(fp,nelem,data) \
68 _blockwrite(fp,nelem,sizeof(*data),(data),#data,__FILE__,__LINE__)
69 #define blockwrite(fp,data) \
70 _blockwrite(fp,1,sizeof(data),&(data),#data,__FILE__,__LINE__)
71 #define cblockwrite(fp,ptr,nchars) \
72 _blockwrite(fp,1,(nchars),(ptr),#ptr,__FILE__,__LINE__)
73 #define nblockread(fp,nelem,data) \
74 _blockread(fp,nelem,sizeof(*data),(data),#data,__FILE__,__LINE__)
75 #define blockread(fp,data) \
76 _blockread(fp,1,sizeof(data),&(data),#data,__FILE__,__LINE__)
77 #define cblockread(fp,ptr,nchars) \
78 _blockread(fp,1,(nchars),(ptr),#ptr,__FILE__,__LINE__)
80 #define patch(fp,fpos,write) \
86 if ((result=fseek(fp,fpos,SEEK_SET))!=0) \
87 fatal_error(errno,"could not seek to position %d from file %s, " \
88 "line %d, result=%d",(fpos),__FILE__,__LINE__,result); \
90 if ((result=fseek(fp,fhere,SEEK_SET))!=0) \
91 fatal_error(errno,"could not seek back to %d from file %s, line %d," \
92 " result=%d",fhere,__FILE__,__LINE__,result); \
96 extern void _blockwrite(FILE *fp,int nelem,int size,void *data,
97 char *what,char *file,int line);
99 extern void _blockread(FILE *fp,int nelem,int size,void *data,
100 char *what,char *file,int line);
102 #endif /* _binio_h */