changed reading hint
[gromacs/adressmacs.git] / include / binio.h
blob0bff2823430e9226d2960ab499fac7e46af47d90
1 /*
2 * $Id$
3 *
4 * This source code is part of
5 *
6 * G R O M A C S
7 *
8 * GROningen MAchine for Chemical Simulations
9 *
10 * VERSION 2.0
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * Please refer to:
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
23 * or e-mail to:
24 * gromacs@chem.rug.nl
26 * And Hey:
27 * Good ROcking Metal Altar for Chronical Sinners
30 #ifndef _binio_h
31 #define _binio_h
33 static char *SRCID_binio_h = "$Id$";
35 #ifdef HAVE_IDENT
36 #ident "@(#) binio.h 1.5 11/23/92"
37 #endif /* HAVE_IDENT */
39 #include <stdio.h>
40 #include "sysstuff.h"
41 #include "fatal.h"
44 * Module to binary write and read.
46 * @
47 * @@@ @@ @
48 * @ @
49 * @ @ @ @@@ @@ @@@ @@ @@ @@@ @@ @@ @@ @@
50 * @ @ @ @ @ @@ @ @@ @ @ @@ @ @ @@
51 * @ @ @ @ @ @ @ @ @ @ @ @ @
52 * @@ @@ @@@@@ @ @ @ @ @ @ @ @
53 * @ @ @ @ @ @ @ @ @ @ @ @
54 * @ @ @ @@ @ @ @ @ @ @ @ @@
55 * @ @ @@@ @@ @@@@ @@@ @@@ @@@@@ @@@ @@@ @@ @
56 * @
57 * @
58 * @@@
60 * Use this module only to write and read simple types or array(s)
61 * of simple types. STRUCTURES ARE DEFINITELY NOT ALLOWED.
64 #define nblockwrite(fp,nelem,data) \
65 _blockwrite(fp,nelem,sizeof(*data),(data),#data,__FILE__,__LINE__)
66 #define blockwrite(fp,data) \
67 _blockwrite(fp,1,sizeof(data),&(data),#data,__FILE__,__LINE__)
68 #define cblockwrite(fp,ptr,nchars) \
69 _blockwrite(fp,1,(nchars),(ptr),#ptr,__FILE__,__LINE__)
70 #define nblockread(fp,nelem,data) \
71 _blockread(fp,nelem,sizeof(*data),(data),#data,__FILE__,__LINE__)
72 #define blockread(fp,data) \
73 _blockread(fp,1,sizeof(data),&(data),#data,__FILE__,__LINE__)
74 #define cblockread(fp,ptr,nchars) \
75 _blockread(fp,1,(nchars),(ptr),#ptr,__FILE__,__LINE__)
77 #define patch(fp,fpos,write) \
78 do \
79 { \
80 int result,fhere; \
82 fhere=ftell(fp); \
83 if ((result=fseek(fp,fpos,SEEK_SET))!=0) \
84 fatal_error(errno,"could not seek to position %d from file %s, " \
85 "line %d, result=%d",(fpos),__FILE__,__LINE__,result); \
86 write; \
87 if ((result=fseek(fp,fhere,SEEK_SET))!=0) \
88 fatal_error(errno,"could not seek back to %d from file %s, line %d," \
89 " result=%d",fhere,__FILE__,__LINE__,result); \
90 } \
91 while (0)
93 extern void _blockwrite(FILE *fp,int nelem,int size,void *data,
94 char *what,char *file,int line);
96 extern void _blockread(FILE *fp,int nelem,int size,void *data,
97 char *what,char *file,int line);
99 #endif /* _binio_h */