Removed refs to charmm files in share/top/Makefile.am
[gromacs/qmmm-gamess-us.git] / include / gmx_system_xdr.h
blobaffa69b5057288058812cd71b502868972893a68
1 /*
2 *
3 * This source code is part of
4 *
5 * G R O M A C S
6 *
7 * GROningen MAchine for Chemical Simulations
8 *
9 * VERSION 3.2.0
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
32 * And Hey:
33 * Gromacs Runs On Most of All Computer Systems
36 #ifndef _gmx_system_xdr_h
37 #define _gmx_system_xdr_h
39 #include <limits.h>
40 #include <stdio.h>
41 #include <stdlib.h>
45 * This header file is ONLY used on windows systems, since these do
46 * not include the XDR routines present on a unix machine. It will
47 * most probably work on other platforms too, but make sure you
48 * test that the xtc files produced are ok before using it.
50 * This header file contains Gromacs versions of the definitions for
51 * Sun External Data Representation (XDR) headers and routines.
53 * On most UNIX systems this is already present as part of your
54 * system libraries, but since we want to make Gromacs portable to
55 * platforms like Microsoft Windows we have created a private version
56 * of the necessary routines and distribute them with the Gromacs source.
58 * Although the rest of Gromacs is GPL, you can copy and use the XDR
59 * routines in any way you want as long as you obey Sun's license:
61 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
62 * unrestricted use provided that this legend is included on all tape
63 * media and as a part of the software program in whole or part. Users
64 * may copy or modify Sun RPC without charge, but are not authorized
65 * to license or distribute it to anyone else except as part of a product or
66 * program developed by the user.
68 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
69 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
70 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
72 * Sun RPC is provided with no support and without any obligation on the
73 * part of Sun Microsystems, Inc. to assist in its use, correction,
74 * modification or enhancement.
76 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
77 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
78 * OR ANY PART THEREOF.
80 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
81 * or profits or other special, indirect and consequential damages, even if
82 * Sun has been advised of the possibility of such damages.
84 * Sun Microsystems, Inc.
85 * 2550 Garcia Avenue
86 * Mountain View, California 94043
87 */
90 * Xdr operations. XDR_ENCODE causes the type to be encoded into the
91 * stream. XDR_DECODE causes the type to be extracted from the stream.
92 * XDR_FREE can be used to release the space allocated by an
93 * XDR_DECODE request.
96 /* We already have a boolean type in Gromacs, but the XDR library
97 * one has a slightly different name (the calls should be identical).
99 typedef int bool_t;
102 * Aninteger type that is 32 bits wide. Check if int,
103 * long or short is 32 bits and die if none of them is :-)
105 #if (INT_MAX == 2147483647)
106 typedef int xdr_int32_t;
107 typedef unsigned int xdr_uint32_t;
108 #elif (LONG_MAX == 2147483647L)
109 typedef long xdr_int32_t;
110 typedef unsigned long xdr_uint32_t;
111 #elif (SHRT_MAX == 2147483647)
112 typedef short xdr_int32_t;
113 typedef unsigned short xdr_uint32_t;
114 #else
115 # error ERROR: No 32 bit wide integer type found!
116 #endif
118 enum xdr_op {
119 XDR_ENCODE = 0,
120 XDR_DECODE = 1,
121 XDR_FREE = 2
124 #ifndef FALSE
125 # define FALSE (0)
126 #endif
127 #ifndef TRUE
128 # define TRUE (1)
129 #endif
132 #define BYTES_PER_XDR_UNIT (4)
133 /* Macro to round up to units of 4. */
134 #define XDR_RNDUP(x) (((x) + BYTES_PER_XDR_UNIT - 1) & ~(BYTES_PER_XDR_UNIT - 1))
138 * The XDR handle.
139 * Contains operation which is being applied to the stream,
140 * an operations vector for the particular implementation (e.g. see xdr_mem.c),
141 * and two private fields for the use of the particular implementation.
143 typedef struct XDR XDR;
144 struct XDR
146 enum xdr_op x_op; /* operation; fast additional param */
147 struct xdr_ops
149 bool_t (*x_getbytes) (XDR *__xdrs, char *__addr, unsigned int __len);
150 /* get some bytes from " */
151 bool_t (*x_putbytes) (XDR *__xdrs, char *__addr, unsigned int __len);
152 /* put some bytes to " */
153 unsigned int (*x_getpostn) (XDR *__xdrs);
154 /* returns bytes off from beginning */
155 bool_t (*x_setpostn) (XDR *__xdrs, unsigned int __pos);
156 /* lets you reposition the stream */
157 xdr_int32_t *(*x_inline) (XDR *__xdrs, int __len);
158 /* buf quick ptr to buffered data */
159 void (*x_destroy) (XDR *__xdrs);
160 /* free privates of this xdr_stream */
161 bool_t (*x_getint32) (XDR *__xdrs, xdr_int32_t *__ip);
162 /* get a int from underlying stream */
163 bool_t (*x_putint32) (XDR *__xdrs, xdr_int32_t *__ip);
164 /* put a int to " */
165 bool_t (*x_getuint32) (XDR *__xdrs, xdr_uint32_t *__ip);
166 /* get a unsigned int from underlying stream */
167 bool_t (*x_putuint32) (XDR *__xdrs, xdr_uint32_t *__ip);
168 /* put a int to " */
170 *x_ops;
171 char *x_public; /* users' data */
172 char *x_private; /* pointer to private data */
173 char *x_base; /* private used for position info */
174 int x_handy; /* extra private word */
178 * A xdrproc_t exists for each data type which is to be encoded or decoded.
180 * The second argument to the xdrproc_t is a pointer to an opaque pointer.
181 * The opaque pointer generally points to a structure of the data type
182 * to be decoded. If this pointer is 0, then the type routines should
183 * allocate dynamic storage of the appropriate size and return it.
186 typedef bool_t (*xdrproc_t) (XDR *, void *,...);
189 * Operations defined on a XDR handle
191 * XDR *xdrs;
192 * xdr_int32_t *int32p;
193 * long *longp;
194 * char *addr;
195 * unsigned int len;
196 * unsigned int pos;
200 #define xdr_getint32(xdrs, int32p) \
201 (*(xdrs)->x_ops->x_getint32)(xdrs, int32p)
203 #define xdr_putint32(xdrs, int32p) \
204 (*(xdrs)->x_ops->x_putint32)(xdrs, int32p)
206 #define xdr_getuint32(xdrs, uint32p) \
207 (*(xdrs)->x_ops->x_getuint32)(xdrs, uint32p)
209 #define xdr_putuint32(xdrs, uint32p) \
210 (*(xdrs)->x_ops->x_putuint32)(xdrs, uint32p)
212 #define xdr_getbytes(xdrs, addr, len) \
213 (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
215 #define xdr_putbytes(xdrs, addr, len) \
216 (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
218 #define xdr_getpos(xdrs) \
219 (*(xdrs)->x_ops->x_getpostn)(xdrs)
221 #define xdr_setpos(xdrs, pos) \
222 (*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
224 #define xdr_inline(xdrs, len) \
225 (*(xdrs)->x_ops->x_inline)(xdrs, len)
227 #define xdr_destroy(xdrs) \
228 do { \
229 if ((xdrs)->x_ops->x_destroy) \
230 (*(xdrs)->x_ops->x_destroy)(xdrs); \
231 } while (0)
234 extern bool_t xdr_int (XDR *__xdrs, int *__ip);
235 extern bool_t xdr_u_int (XDR *__xdrs, unsigned int *__ip);
236 extern bool_t xdr_short (XDR *__xdrs, short *__ip);
237 extern bool_t xdr_u_short (XDR *__xdrs, unsigned short *__ip);
238 extern bool_t xdr_bool (XDR *__xdrs, int *__bp);
239 extern bool_t xdr_opaque (XDR *__xdrs, char *__cp, unsigned int __cnt);
240 extern bool_t xdr_string (XDR *__xdrs, char **__cpp, unsigned int __maxsize);
241 extern bool_t xdr_char (XDR *__xdrs, char *__cp);
242 extern bool_t xdr_u_char (XDR *__xdrs, unsigned char *__cp);
243 extern bool_t xdr_vector (XDR *__xdrs, char *__basep, unsigned int __nelem,
244 unsigned int __elemsize, xdrproc_t __xdr_elem);
245 extern bool_t xdr_float (XDR *__xdrs, float *__fp);
246 extern bool_t xdr_double (XDR *__xdrs, double *__dp);
247 extern void xdrstdio_create (XDR *__xdrs, FILE *__file, enum xdr_op __xop);
249 /* free memory buffers for xdr */
250 extern void xdr_free (xdrproc_t __proc, char *__objp);
253 #endif /* _gmx_system_xdr_h */