13 #include <sys/select.h>
16 #define MAX_ARRAY(x) (x ? x : 20000)
17 #define CHECK(x) if (!x) {fprintf(stderr,"xdr failed"); exit(1);}
24 struct value
*constants
;
32 a
->v
.cmplx_val
.real
= r
;
33 a
->v
.cmplx_val
.imag
= i
;
47 xdr_read_values(xdrsp
,length
,result
)
48 struct value
**result
;
54 CHECK(xdr_int(xdrsp
,&n
));
56 *result
= ans
= (void *)malloc(sizeof(struct value
)*n
);
58 { xdr_int(type
,&type
);
60 { CHECK(xdr_double(xdrsp
,&(ans
->v
.cmplx_val
.real
)));
61 CHECK(xdr_double(xdrsp
,&(ans
->v
.cmplx_val
.imag
)));
66 { CHECK(xdr_int(xdrsp
,&(ans
->v
.int_val
)));
71 { CHECK(xdr_double(xdrsp
,&(ans
->v
.cmplx_val
.real
)));
72 ans
->v
.cmplx_val
.imag
= 0.0 ;
86 xdrstdio_create(&xdrs
, stdin
, XDR_DECODE
);
88 xdrstdio_create(&xdrs
, stdin
, XDR_DECODE
);
90 { struct value_function f
;
93 CHECK(xdr_bytes(&xdrs
,&f
.body
,&f
.length
,MAX_ARRAY(0)));
94 CHECK(xdr_read_values(&xdrs
,&length
,&f
.constants
));
96 /* invoke the function */
97 push(complex(&a
,atod(argv
[1]),atod(argv
[2])));