2
Copyright (C) 1994 W. Schelter
4
This file is part of GNU Common Lisp, herein referred to as GCL
6
GCL is free software; you can redistribute it and/or modify it under
7
the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE as published by
8
the Free Software Foundation; either version 2, or (at your option)
11
GCL is distributed in the hope that it will be useful, but WITHOUT
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14
License for more details.
21
#include <sys/select.h>
25
extern short aet_sizes[];
30
object ar= alloc_simple_string(sizeof(XDR));
31
array_allocself(ar,1,0);
32
xdrs= (XDR *) ar->a.a_self;
33
if (f->sm.sm_fp == 0) FEerror("stream not ok for xdr io",0);
34
xdrstdio_create(xdrs, f->sm.sm_fp,
35
(f->sm.sm_mode == smm_input ? XDR_DECODE :
36
f->sm.sm_mode == smm_output ? XDR_ENCODE :
37
(FEerror("stream not input or output",0),XDR_ENCODE)))
43
FFN(siGxdr_write)(object str,object elt) {
45
XDR *xdrp= (XDR *) str->ust.ust_self;
48
switch (type_of(elt)) {
50
if(!xdr_long(xdrp,&fix(elt))) goto error;
53
if(!xdr_double(xdrp,&lf(elt))) goto error;
56
if(!xdr_float(xdrp,&sf(elt))) goto error;
60
switch(elt->v.v_elttype) {
62
e=(xdrproc_t)xdr_double;
65
e=(xdrproc_t)xdr_float;
68
e=(xdrproc_t)xdr_long;
71
e=(xdrproc_t)xdr_short;
74
FEerror("unsupported xdr size",0);
78
if(!xdr_array(xdrp,(char **)&elt->v.v_self,
81
aet_sizes[elt->v.v_elttype],
86
FEerror("unsupported xdr ~a",1,elt);
91
FEerror("bad xdr read",0);
96
FFN(siGxdr_read)(object str,object elt) {
98
XDR *xdrp= (XDR *) str->ust.ust_self;
101
switch (type_of(elt)) {
104
if(!xdr_long(xdrp,&l)) goto error;
105
return make_fixnum(l);}
109
if(!xdr_double(xdrp,&x)) goto error;
110
return make_longfloat(x);}
113
if(!xdr_float(xdrp,&x)) goto error;
114
return make_shortfloat(x);}
116
switch(elt->v.v_elttype) {
118
e=(xdrproc_t)xdr_double;
121
e=(xdrproc_t)xdr_float;
124
e=(xdrproc_t)xdr_long;
127
e=(xdrproc_t)xdr_short;
130
FEerror("unsupported xdr size",0);
135
if(!xdr_array(xdrp,(char **)&elt->v.v_self,
138
aet_sizes[elt->v.v_elttype],
144
FEerror("unsupported xdr ~a",1,elt);
149
FEerror("bad xdr read",0);
154
{ make_si_sfun("XDR-WRITE",siGxdr_write,
155
ARGTYPE2(f_object,f_object)|RESTYPE(f_object));
157
make_si_sfun("XDR-READ",siGxdr_read,
158
ARGTYPE2(f_object,f_object)|RESTYPE(f_object));
159
make_si_sfun("XDR-OPEN",siGxdr_open,
160
ARGTYPE1(f_object)|RESTYPE(f_object));
164
static void gcl_init_xdrfuns(void) {;}