File: dis_xdr1.c

package info (click to toggle)
acm 5.0-23.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 8,364 kB
  • ctags: 4,793
  • sloc: ansic: 42,444; makefile: 706; cpp: 293; perl: 280; sh: 198
file content (206 lines) | stat: -rwxr-xr-x 4,982 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

/*
 *   DIS/x : An implementation of the IEEE 1278.1 protocol
 *
 *   Copyright (C) 1996, Riley Rainey (rainey@netcom.com)
 *
 *   This library is free software; you can redistribute it and/or
 *   modify it under the terms of either:
 *
 *   a) the GNU Library General Public License as published by the Free
 *   Software Foundation; either version 2 of the License, or (at your
 *   option) any later version.  A description of the terms and conditions
 *   of the GLPL may be found in the "COPYING.LIB" file.
 *
 *   b) the "Artistic License" which comes with this Kit.  Information
 *   about this license may be found in the "Artistic" file.
 *
 *   This library is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *   Library General Public License or the Artistic License for more details.
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this library; if not, write to the Free
 *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *   Information describing how to contact the author can be found in the
 *   README file.
 */
/*
 *  This file was manually generated.  It was NOT created by RPCGEN.
 *  It contains xdr definitions for structures that do not fit the
 *  convetional RPCGEN structure model for variable length vectors or
 *  union definitions.
 */

#include <rpc/rpc.h>
#include <dis/dis.h>
#define _DIS_PRIVATE	1
#include <dis/dis_xdr.h>

bool_t
xdr_dis_variable_datum(XDR * xdrs, dis_variable_datum * objp)
{
	static char pad[8];			/* force padding to be zeroes */
	int       padbytes;

	if (!xdr_u_long(xdrs, &objp->datum_id)) {
		return (FALSE);
	}
	if (!xdr_u_long(xdrs, &objp->value_length)) {
		return (FALSE);
	}

	switch (objp->datum_id) {

	/*
	 * Double variable data items
	 */

	case DatumGeocentricCoordinatesX:
	case DatumGeocentricCoordinatesY:
	case DatumGeocentricCoordinatesZ:
		if (!xdr_double(xdrs, &objp->value.double_value)) {
			return (FALSE);
		}
		break;

	/* 
	 * Datum type defaults to String
	 */

	default:
		if (!xdr_vector(xdrs, (char *) &objp->value.ptr_value,
					    (unsigned int) objp->value_length / 8,
					    sizeof(char),
                        (xdrproc_t) xdr_u_char)) {
			return (FALSE);
		}
		break;
	}

	padbytes = 8 - (objp->value_length % 8);
	if (padbytes != 0) {
		if (!xdr_vector(xdrs, pad, padbytes, sizeof(char), (xdrproc_t) xdr_char)) {
			return (FALSE);
		}
	}
	return TRUE;
}

bool_t
xdr_dis_articulation_parm(XDR * xdrs, dis_articulation_parm * objp)
{
	if (!xdr_byte_u_char(xdrs, &objp->type)) {
		return (FALSE);
	}
	if (!xdr_byte_u_char(xdrs, &objp->change)) {
		return (FALSE);
	}
	if (!xdr_byte_short(xdrs, &objp->id)) {
		return (FALSE);
	}
	if (!xdr_byte_long(xdrs, (char *) &objp->type)) {
		return (FALSE);
	}
	switch (objp->type) {
	default:
		objp->value.l[0] = 0;
		objp->value.l[1] = 0;
	}
	return TRUE;
}

bool_t
xdr_dis_timestamp(XDR * xdrs, dis_timestamp * objp)
{
	if (!xdr_u_long(xdrs, (unsigned long *) objp)) {
		return (FALSE);
	}
	return TRUE;
}

bool_t
xdr_dis_pdu(XDR * xdrs, dis_pdu * objp)
{
	u_long    pos;

	if (xdrs->x_op == XDR_DECODE) {

		pos = xdr_getpos(xdrs);

		if (!xdr_dis_pdu_header(xdrs, (dis_pdu_header *) objp)) {
			return (FALSE);
		}

		if (!xdr_setpos(xdrs, pos)) {
			return (FALSE);
		}
	}

	switch (objp->hdr.pdu_type) {
	case PDUTypeEntityState:
		if (!xdr_dis_entity_state_pdu(xdrs, (dis_entity_state_pdu *) objp)) {
			return (FALSE);
		}
		break;
	case PDUTypeCollision:
		if (!xdr_dis_collision_pdu(xdrs, (dis_collision_pdu *) objp)) {
			return (FALSE);
		}
		break;
	case PDUTypeFire:
		if (!xdr_dis_fire_pdu(xdrs, (dis_fire_pdu *) objp)) {
			return (FALSE);
		}
		break;
	case PDUTypeDetonation:
		if (!xdr_dis_detonation_pdu(xdrs, (dis_detonation_pdu *) objp)) {
			return (FALSE);
		}
		break;
	case PDUTypeCreateEntity:
		if (!xdr_dis_create_entity_pdu(xdrs,
									   (dis_create_entity_pdu *) objp)) {
			return (FALSE);
		}
		break;
	case PDUTypeRemoveEntity:
		if (!xdr_dis_remove_entity_pdu(xdrs,
									   (dis_remove_entity_pdu *) objp)) {
			return (FALSE);
		}
		break;
	case PDUTypeStopFreeze:
		if (!xdr_dis_stop_pdu(xdrs, (dis_stop_pdu *) objp)) {
			return (FALSE);
		}
		break;
	case PDUTypeStartResume:
		if (!xdr_dis_start_pdu(xdrs, (dis_start_pdu *) objp)) {
			return (FALSE);
		}
		break;
	case PDUTypeEmission:
		if (xdrs->x_op == XDR_DECODE) {
			((dis_em_emission_pdu *) objp)->system = NULL;
		}
		if (!xdr_dis_em_emission_pdu(xdrs,
									 (dis_em_emission_pdu *) objp)) {
			return (FALSE);
		}
		break;
	case PDUTypeTransferControl:
		if (!xdr_dis_transfer_control_pdu(xdrs, (dis_transfer_control_pdu *) objp)) {
			return (FALSE);
		}
		break;
	case PDUTypeAcknowledge:
		if (!xdr_dis_acknowledge_pdu(xdrs, (dis_acknowledge_pdu *) objp)) {
			return (FALSE);
		}
		break;
	}
	return TRUE;
}