595
|
1
|
|
2
|
|
3 #include <stdio.h>
|
|
4 #include <stdlib.h>
|
|
5 #include <sys/types.h>
|
|
6
|
|
7 #define FALSE 0
|
|
8 #define TRUE 1
|
|
9 typedef int bool_t;
|
|
10 typedef int enum_t;
|
|
11
|
|
12 #include <rpc/xdr.h>
|
|
13
|
|
14 #define CHUNK 1024
|
|
15
|
|
16
|
|
17 int
|
|
18 main()
|
|
19 {
|
|
20 XDR xdrs;
|
|
21 double dp[6];
|
|
22
|
|
23 int size = CHUNK;
|
|
24 char *addr = (char*)malloc(size);
|
|
25 int i;
|
|
26
|
|
27 double d = 0.1;
|
|
28 xdrmem_create(&xdrs, addr, size, XDR_ENCODE);
|
|
29
|
|
30 for (i = 0; i< 6; i++) {
|
|
31 dp[i] = d * i;
|
|
32 xdr_double(&xdrs, &dp[i]);
|
|
33 }
|
596
|
34 int pos = xdr_getpos(&xdrs);
|
|
35 printf("xdr written %d\n",pos);
|
595
|
36
|
|
37 for (i = 0; i< 6; i++) dp[i] = 0.0;
|
|
38
|
|
39 xdrmem_create(&xdrs, addr, size, XDR_DECODE);
|
|
40
|
|
41 for (i = 0; i< 6; i++) {
|
|
42 xdr_double(&xdrs, &dp[i]);
|
|
43 printf("%g ",dp[i]);
|
|
44 }
|
|
45 printf("\n");
|
|
46
|
|
47
|
|
48
|
|
49
|
|
50 }
|
|
51
|
|
52
|