1 | /********************************************************************** |
---|
2 | * |
---|
3 | * MP version 1.1.2 Multi Protocol |
---|
4 | * Kent State University, Kent, OH |
---|
5 | * Authors: S. Gray, N. Kajler, P. Wang |
---|
6 | * (C) 1993, 1994, 1995, 1996, 1997 All Rights Reserved |
---|
7 | * |
---|
8 | * NOTICE |
---|
9 | * |
---|
10 | * Permission to use, copy, modify, and distribute this software and |
---|
11 | * its documentation for non-commercial purposes and without fee is |
---|
12 | * hereby granted provided that the above copyright notice appear in all |
---|
13 | * copies and that both the copyright notice and this permission notice |
---|
14 | * appear in supporting documentation. |
---|
15 | * |
---|
16 | * Neither Kent State University nor the Authors make any representations |
---|
17 | * about the suitability of this software for any purpose. The MP Library |
---|
18 | * is distributed in the hope that it will be useful, but is provided "as |
---|
19 | * is" and without any warranty of any kind and without even the implied |
---|
20 | * warranty of merchantability or fitness for a particular purpose. |
---|
21 | * |
---|
22 | * |
---|
23 | * IMPLEMENTATION FILE: MP_Get.c - All the get routines. |
---|
24 | * |
---|
25 | * Change Log: |
---|
26 | * May 30, 1996 SG - added MP_GetSint8Packet(). |
---|
27 | * June 5, 1995 SG - added MP_GetUint8Packet() |
---|
28 | * - changed IMP_GetOperator() to only output |
---|
29 | * the operator, as a string. That is, it no |
---|
30 | * longer also reads a num_child field, since that |
---|
31 | * job is now done by imp_get_node_header(). |
---|
32 | * IMP_GetMpOperator() is handled in MP_Get.h |
---|
33 | * July 7, 1995 SG - added MP_GetBooleanPacket(), |
---|
34 | * MP_GetCommonConstantPacket(), |
---|
35 | * MP_GetCommonOperatorPacket(), |
---|
36 | * and updated the error constants to reflect |
---|
37 | * the changes to MP_Error .c and .h |
---|
38 | * October 6, 1995 SG - changed imp_get_node_header() to return MP_Failure |
---|
39 | * if it cannot properly retrieve the 4 byte |
---|
40 | * header. MP_Failure is set to 0. We must |
---|
41 | * never define an MP type with an integer |
---|
42 | * representation of 0 or we will be unable do |
---|
43 | * distinguish between success and failure here. |
---|
44 | * 10/18/95 OB - changed GetApInt routines such that |
---|
45 | * only size field is communicated, not the alloc field |
---|
46 | * 10/16/95 OB - changed memory allocation function for ApInt's to |
---|
47 | * _mpz_realloc |
---|
48 | * 12/1/95 SG - fixed bug in routines which have to handle values |
---|
49 | * padded with NULL bytes to get the right alignment |
---|
50 | * 2/28/96 SG - Changed the NodeFlags fields to DictTag to reflect |
---|
51 | * the change in how we identify dictionaries and do |
---|
52 | * semantics.Also changed IMP_GetNodeHeader() so |
---|
53 | * that it now takes arguments for all of the fields |
---|
54 | * in a packet header. BUT - see comment with |
---|
55 | * IMP_GetNodeHeader() regarding dictionary tags. |
---|
56 | * 4/29/96 sgray - Made the GetApInt() routines more generic. They |
---|
57 | * now take a pointer to void. So the sender can |
---|
58 | * send in its "native" bignum format (provided we |
---|
59 | * have the supporting routines in place). New formats |
---|
60 | * can be added as needed without affecting the design. |
---|
61 | * 3/11/97 sgray - Fixed logging of ApInts as recommended by obachman. |
---|
62 | * Also cleaned up logging in the GetString and ApReal |
---|
63 | * functions. |
---|
64 | * |
---|
65 | **************************************************************************/ |
---|
66 | |
---|
67 | #include "MP.h" |
---|
68 | |
---|
69 | |
---|
70 | /* |
---|
71 | * these two defined in MP_Util.c |
---|
72 | */ |
---|
73 | EXTERN char fix_log_msg[]; |
---|
74 | EXTERN char AnnotFlagsStr[]; |
---|
75 | |
---|
76 | static char junk[4]; /* for reading filler bytes */ |
---|
77 | |
---|
78 | /* |
---|
79 | * this is a private version of the IMP_GetNodeHeader() routine |
---|
80 | * IMPORTANT: At this time we have not determined how dictionary |
---|
81 | * tags beyond 255 should be allocated. The code below make NO |
---|
82 | * check to see if dtag is 127 or 255 (the indicators telling us |
---|
83 | * the read in another 4 bytes with the true tag. Once we know |
---|
84 | * how those tags will be disbursed, we can do the proper check |
---|
85 | * here. To be clear. The problem is that if the incoming dtag |
---|
86 | * is > 255, we can't yet identify it as MP-extended or user-extended, |
---|
87 | * so can't know whether to use 127 or 255. It might be a good |
---|
88 | * idea to combine these into a single "extended tag" and just |
---|
89 | * divvy up the 4 byte tags as well. This has to be fixed for |
---|
90 | * imp_get_node_header() as well. |
---|
91 | */ |
---|
92 | |
---|
93 | #ifdef __STDC__ |
---|
94 | static MP_Status_t imp_get_node_header(MP_Link_pt link, |
---|
95 | MP_NodeType_t *ntype, |
---|
96 | MP_DictTag_t *dtag, |
---|
97 | MP_Common_t *cv, |
---|
98 | MP_NumAnnot_t *num_annots, |
---|
99 | MP_NumChild_t *num_child) |
---|
100 | #else |
---|
101 | static MP_Status_t imp_get_node_header(link, ntype, dtag, cv, |
---|
102 | num_annots, num_child) |
---|
103 | MP_Link_pt link; |
---|
104 | MP_NodeType_t *ntype; |
---|
105 | MP_DictTag_t *dtag; |
---|
106 | MP_Common_t *cv; |
---|
107 | MP_NumAnnot_t *num_annots; |
---|
108 | MP_NumChild_t *num_child; |
---|
109 | #endif |
---|
110 | { |
---|
111 | MP_NodeHeader_t hdr; |
---|
112 | MP_NodeType_t ntype_requested = *ntype; |
---|
113 | |
---|
114 | #ifdef MP_DEBUG |
---|
115 | fprintf(stderr, "imp_get_node_header: entering for link %d\n", |
---|
116 | link->link_id); |
---|
117 | #endif |
---|
118 | |
---|
119 | if(!IMP_GetLong(link, (long*)&hdr)) { |
---|
120 | MP_SetError(link, MP_CantGetNodeHeader); |
---|
121 | return MP_Failure; |
---|
122 | } |
---|
123 | |
---|
124 | *ntype = MP_GetNodeFieldType(hdr); |
---|
125 | if (ntype_requested != *ntype && ntype_requested != MP_ANY_TYPE) { |
---|
126 | IMP_Restore(link, sizeof(hdr)); |
---|
127 | sprintf(fix_log_msg,"Wrong packet type. requested %s, received %s", |
---|
128 | IMP_TypeToString(ntype_requested), IMP_TypeToString(*ntype)); |
---|
129 | MP_LogEvent(link, MP_ERROR_EVENT, fix_log_msg); |
---|
130 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
131 | } |
---|
132 | |
---|
133 | *num_annots = MP_GetNodeNumAnnotsField(hdr); |
---|
134 | *num_child = MP_GetNodeNumChildField(hdr); |
---|
135 | *cv = MP_GetNodeCommonValueField(hdr); |
---|
136 | *dtag = MP_GetNodeDictTagField(hdr); |
---|
137 | |
---|
138 | if (*num_annots == MP_ExtraFieldIndicator |
---|
139 | && !IMP_GetLong(link, (long*)num_annots)) |
---|
140 | return MP_SetError(link, MP_CantGetNodeHeader); |
---|
141 | |
---|
142 | if (*num_child == MP_ExtraFieldIndicator |
---|
143 | && !IMP_GetLong(link, (long*)num_child)) |
---|
144 | return MP_SetError(link, MP_CantGetNodeHeader); |
---|
145 | |
---|
146 | #ifdef MP_DEBUG |
---|
147 | fprintf(stderr, |
---|
148 | "imp_get_node_header: exiting - hdr = 0x%X, " |
---|
149 | "\ttype = %d\tnum_child = %d\tnum_annot = %d\n", |
---|
150 | hdr, *ntype, *num_child, *num_annots); |
---|
151 | #endif |
---|
152 | |
---|
153 | return MP_ClearError(link); |
---|
154 | } |
---|
155 | |
---|
156 | |
---|
157 | |
---|
158 | #ifdef __STDC__ |
---|
159 | MP_Status_t IMP_GetNodeHeader(MP_Link_pt link, |
---|
160 | MP_NodeType_t *ntype, |
---|
161 | MP_DictTag_t *dtag, |
---|
162 | MP_Common_t *cv, |
---|
163 | MP_NumAnnot_t *num_annots, |
---|
164 | MP_NumChild_t *num_child) |
---|
165 | #else |
---|
166 | MP_Status_t IMP_GetNodeHeader(link, ntype, dtag, cv, num_annots, num_child) |
---|
167 | MP_Link_pt link; |
---|
168 | MP_NodeType_t *ntype; |
---|
169 | MP_DictTag_t *dtag; |
---|
170 | MP_Common_t *cv; |
---|
171 | MP_NumAnnot_t *num_annots; |
---|
172 | MP_NumChild_t *num_child; |
---|
173 | #endif |
---|
174 | { |
---|
175 | unsigned char t; |
---|
176 | MP_Status_t status; |
---|
177 | #ifdef MP_DEBUG |
---|
178 | fprintf(stderr, "IMP_GetNodeHeader: entering for link %d\n", link->link_id); |
---|
179 | #endif |
---|
180 | /* |
---|
181 | * For now we don't let the programmer in on this little secret (unless, |
---|
182 | * of course, you are looking at the code :-0). Make sure that the |
---|
183 | * internal get node header routine doesn't gag. |
---|
184 | */ |
---|
185 | |
---|
186 | *ntype = MP_ANY_TYPE; |
---|
187 | status = imp_get_node_header(link, ntype, dtag, cv, num_annots, num_child); |
---|
188 | |
---|
189 | #ifdef MP_DEBUG |
---|
190 | fprintf(stderr, |
---|
191 | "IMP_GetNodeHeader: exiting\ttype = %d" |
---|
192 | "\tnum_child = %d\tnum_annot = %d\n", |
---|
193 | *ntype, *num_child, *num_annots); |
---|
194 | #endif |
---|
195 | |
---|
196 | #ifndef NO_LOGGING |
---|
197 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
198 | /* the following is a pain, but we have to do it for HPs so the output |
---|
199 | is displayed correctly *//* |
---|
200 | if (*ntype == MP_Uint8Type){ |
---|
201 | t = (MP_Uint8_t)*cv; |
---|
202 | sprintf(fix_log_msg, |
---|
203 | "%-12s %-11s annots: %lu args: %lu dict: %lu cval: %u", |
---|
204 | "NodePktHdr", IMP_TypeToString(*ntype), |
---|
205 | *num_annots, *num_child, *dtag, t); |
---|
206 | } |
---|
207 | else */ |
---|
208 | if (*ntype == MP_Sint8Type){ |
---|
209 | sprintf(fix_log_msg, |
---|
210 | "%-12s %-11s annots: %lu args: %lu dict: %lu cval: %d", |
---|
211 | "NodePktHdr", IMP_TypeToString(*ntype), |
---|
212 | *num_annots, *num_child, *dtag, t); |
---|
213 | } |
---|
214 | else { |
---|
215 | t = (MP_Uint8_t)*cv; |
---|
216 | sprintf(fix_log_msg, |
---|
217 | "%-12s %-11s annots: %lu args: %lu dict: %lu cval: %u", |
---|
218 | "NodePktHdr", IMP_TypeToString(*ntype), |
---|
219 | *num_annots, *num_child, *dtag, *cv); |
---|
220 | } |
---|
221 | MP_LogEvent(link, MP_READ_EVENT, fix_log_msg); |
---|
222 | } |
---|
223 | #endif |
---|
224 | if (status == MP_Success) |
---|
225 | return MP_ClearError(link); |
---|
226 | else return MP_Failure; |
---|
227 | } |
---|
228 | |
---|
229 | |
---|
230 | |
---|
231 | #ifdef __STDC__ |
---|
232 | MP_Status_t IMP_GetSint32(MP_Link_pt link, MP_Sint32_t *n) |
---|
233 | #else |
---|
234 | MP_Status_t IMP_GetSint32(link, n) |
---|
235 | MP_Link_pt link; |
---|
236 | MP_Sint32_t *n; |
---|
237 | #endif |
---|
238 | { |
---|
239 | if (!IMP_GetLong(link, n)) |
---|
240 | return MP_SetError(link, MP_CantGetDataPacket); |
---|
241 | |
---|
242 | #ifndef NO_LOGGING |
---|
243 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
244 | log_fixnum(link, MP_READ_EVENT, "Sint32_DP", MP_Sint32Type, 0, n); |
---|
245 | #endif |
---|
246 | return MP_ClearError(link); |
---|
247 | } |
---|
248 | |
---|
249 | |
---|
250 | |
---|
251 | #ifdef __STDC__ |
---|
252 | MP_Status_t IMP_GetUint32(MP_Link_pt link, MP_Uint32_t *n) |
---|
253 | #else |
---|
254 | IMP_GetUint32(link, n) |
---|
255 | MP_Link_pt link; |
---|
256 | MP_Uint32_t *n; |
---|
257 | #endif |
---|
258 | { |
---|
259 | if (!IMP_GetLong(link, (long*)n)) |
---|
260 | return MP_SetError(link, MP_CantGetDataPacket); |
---|
261 | |
---|
262 | #ifndef NO_LOGGING |
---|
263 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
264 | log_fixnum(link, MP_READ_EVENT, "Uint32_DP", MP_Uint32Type, 0, n); |
---|
265 | #endif |
---|
266 | |
---|
267 | return MP_ClearError(link); |
---|
268 | } |
---|
269 | |
---|
270 | |
---|
271 | |
---|
272 | |
---|
273 | #ifdef __STDC__ |
---|
274 | MP_Status_t IMP_GetOperator(MP_Link_pt link, char **op) |
---|
275 | #else |
---|
276 | MP_Status_t IMP_GetOperator(link, op) |
---|
277 | MP_Link_pt link; |
---|
278 | char **op; |
---|
279 | #endif |
---|
280 | { |
---|
281 | if (!IMP_GetStringBasedType(link, op)) |
---|
282 | return MP_Failure; |
---|
283 | |
---|
284 | #ifndef NO_LOGGING |
---|
285 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
286 | sprintf(fix_log_msg, "%-12s op: %s", "Operator_DP", *op); |
---|
287 | MP_LogEvent(link, MP_READ_EVENT, fix_log_msg); |
---|
288 | } |
---|
289 | #endif |
---|
290 | |
---|
291 | return MP_ClearError(link); |
---|
292 | } |
---|
293 | |
---|
294 | |
---|
295 | |
---|
296 | #ifdef __STDC__ |
---|
297 | MP_Status_t IMP_GetRaw(MP_Link_pt link, |
---|
298 | char **rawdata, |
---|
299 | MP_Uint32_t *len) |
---|
300 | #else |
---|
301 | MP_Status_t IMP_GetRaw(link, rawdata, len) |
---|
302 | MP_Link_pt link; |
---|
303 | char **rawdata; |
---|
304 | MP_Uint32_t *len; |
---|
305 | #endif |
---|
306 | { |
---|
307 | int extra; |
---|
308 | |
---|
309 | |
---|
310 | if (!IMP_GetLong(link, (long*)len)) |
---|
311 | return MP_SetError(link, MP_CantGetDataPacket); |
---|
312 | |
---|
313 | if (*rawdata == NULL) |
---|
314 | if ((*rawdata = (char*)IMP_RawMemAllocFnc(*len)) == NULL) |
---|
315 | return MP_SetError(link, MP_MemAlloc); |
---|
316 | |
---|
317 | if (!IMP_GetBytes(link, *rawdata, *len)) |
---|
318 | return MP_SetError(link, MP_CantGetDataPacket); |
---|
319 | |
---|
320 | extra = MP_BytesPerMPUnit - (*len % MP_BytesPerMPUnit); |
---|
321 | if (extra != 0 && extra != MP_BytesPerMPUnit) |
---|
322 | if (!IMP_GetBytes(link, junk, extra)) |
---|
323 | return MP_SetError(link, MP_CantGetDataPacket); |
---|
324 | |
---|
325 | #ifndef NO_LOGGING |
---|
326 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
327 | sprintf(fix_log_msg, "%-12s #bytes: %lu (data not shown)", |
---|
328 | "Raw_DP", *len); |
---|
329 | MP_LogEvent(link, MP_READ_EVENT, fix_log_msg); |
---|
330 | } |
---|
331 | #endif |
---|
332 | |
---|
333 | return MP_ClearError(link); |
---|
334 | } |
---|
335 | |
---|
336 | |
---|
337 | |
---|
338 | #ifdef __STDC__ |
---|
339 | MP_Status_t MP_GetAnnotationPacket(MP_Link_pt link, |
---|
340 | MP_DictTag_t *dtag, |
---|
341 | MP_AnnotType_t *atype, |
---|
342 | MP_AnnotFlags_t *flags) |
---|
343 | #else |
---|
344 | MP_Status_t MP_GetAnnotationPacket(link, dtag, atype, flags) |
---|
345 | MP_Link_pt link; |
---|
346 | MP_DictTag_t *dtag; |
---|
347 | MP_AnnotType_t *atype; |
---|
348 | MP_AnnotFlags_t *flags; |
---|
349 | #endif |
---|
350 | { |
---|
351 | MP_AnnotHeader_t annot; |
---|
352 | |
---|
353 | if (!IMP_GetLong(link, (long*)&annot)) |
---|
354 | return MP_SetError(link, MP_CantGetAnnotationPacket); |
---|
355 | |
---|
356 | *atype = MP_GetAnnotFieldType(annot); |
---|
357 | *dtag = MP_GetAnnotDictTagField(annot); |
---|
358 | *flags = MP_GetAnnotFlagsField(annot); |
---|
359 | |
---|
360 | #ifndef NO_LOGGING |
---|
361 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
362 | annot_flags_to_str(*flags); |
---|
363 | /* 3/28/97 - sgray - annotations are spread out through a variety |
---|
364 | of header files, so giving a string version of the annotation |
---|
365 | is not practical at this time. Maybe have they are stable we |
---|
366 | can create function to do a (dtag, atype) mapping to a string. */ |
---|
367 | /* if (*dtag == 0) |
---|
368 | sprintf(fix_log_msg, "%-12s flags: %s dict: %lu ", |
---|
369 | annotations[*atype], AnnotFlagsStr, *dtag); |
---|
370 | else |
---|
371 | sprintf(fix_log_msg, "%-12s flags: %s dict: %lu atype: %u", |
---|
372 | "User_AP", AnnotFlagsStr, *dtag, *atype);*/ |
---|
373 | sprintf(fix_log_msg, "AnnotPkt dict: %lu atype: %u flags: %s", |
---|
374 | *dtag, *atype, AnnotFlagsStr); |
---|
375 | MP_LogEvent(link, MP_READ_EVENT, fix_log_msg); |
---|
376 | } |
---|
377 | #endif |
---|
378 | |
---|
379 | return MP_ClearError(link); |
---|
380 | } |
---|
381 | |
---|
382 | |
---|
383 | #ifdef __STDC__ |
---|
384 | MP_Status_t IMP_GetStringBasedType(MP_Link_pt link, char **s) |
---|
385 | #else |
---|
386 | MP_Status_t IMP_GetStringBasedType(link, s) |
---|
387 | MP_Link_pt link; |
---|
388 | char **s; |
---|
389 | #endif |
---|
390 | { |
---|
391 | unsigned long extra, len; |
---|
392 | char *cp; |
---|
393 | |
---|
394 | if (!IMP_GetLong(link, (long*)&len)) |
---|
395 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
396 | |
---|
397 | if (*s == NULL) |
---|
398 | if ((*s = (char*)IMP_RawMemAllocFnc(len+1)) == NULL) |
---|
399 | return MP_SetError(link, MP_MemAlloc); |
---|
400 | |
---|
401 | if (!IMP_GetBytes(link, *s, len)) |
---|
402 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
403 | |
---|
404 | cp = *s + len; |
---|
405 | *cp = '\0'; |
---|
406 | |
---|
407 | extra = MP_BytesPerMPUnit - (len % MP_BytesPerMPUnit); |
---|
408 | if (extra != 0 && extra != MP_BytesPerMPUnit) |
---|
409 | if (!IMP_GetBytes(link, junk, extra)) |
---|
410 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
411 | |
---|
412 | return MP_ClearError(link); |
---|
413 | } |
---|
414 | |
---|
415 | |
---|
416 | |
---|
417 | #ifdef __STDC__ |
---|
418 | MP_Status_t MP_GetRawPacket(MP_Link_pt link, |
---|
419 | char **s, |
---|
420 | MP_Uint32_t *len, |
---|
421 | MP_NumAnnot_t *num_annots) |
---|
422 | #else |
---|
423 | MP_Status_t MP_GetRawPacket(link, s, len, num_annots) |
---|
424 | MP_Link_pt link; |
---|
425 | char **s; |
---|
426 | MP_Uint32_t *len; |
---|
427 | MP_NumAnnot_t *num_annots; |
---|
428 | #endif |
---|
429 | { |
---|
430 | MP_NumChild_t num_child; |
---|
431 | MP_NodeType_t ntype = MP_RawType; |
---|
432 | MP_DictTag_t dtag; |
---|
433 | MP_Common_t cv; |
---|
434 | int extra; |
---|
435 | |
---|
436 | |
---|
437 | ERR_CHK(imp_get_node_header(link, &ntype, &dtag, &cv, |
---|
438 | num_annots, &num_child)); |
---|
439 | |
---|
440 | if (!IMP_GetLong(link, (long*)len)) |
---|
441 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
442 | |
---|
443 | if (*s == NULL) |
---|
444 | if ((*s = (char*)IMP_RawMemAllocFnc(*len)) == NULL) |
---|
445 | return MP_SetError(link, MP_MemAlloc); |
---|
446 | |
---|
447 | if (!IMP_GetBytes(link, *s, *len)) |
---|
448 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
449 | |
---|
450 | extra = MP_BytesPerMPUnit - (*len % MP_BytesPerMPUnit); |
---|
451 | if (extra != 0 && extra != MP_BytesPerMPUnit) |
---|
452 | if (!IMP_GetBytes(link, junk, extra)) |
---|
453 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
454 | |
---|
455 | #ifndef NO_LOGGING |
---|
456 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
457 | sprintf(fix_log_msg, |
---|
458 | "%-12s annots: %lu #bytes: %lu (data not shown)", |
---|
459 | "Raw_NP", *num_annots, *len); |
---|
460 | MP_LogEvent(link, MP_READ_EVENT, fix_log_msg); |
---|
461 | } |
---|
462 | #endif |
---|
463 | |
---|
464 | return MP_ClearError(link); |
---|
465 | } |
---|
466 | |
---|
467 | |
---|
468 | /* |
---|
469 | * Change Log: May 30, 1995 SG |
---|
470 | * - added this routine. In MP_Types.h I made MP_NodeType_t |
---|
471 | * and MP_AnnotType_t both u_char. This really bothers the |
---|
472 | * IMP_GetLong() and IMP_PutLong() routines. My fix is to |
---|
473 | * declare a local variable of type long, do a get on it |
---|
474 | * and then assign it to the parameter using a typecast. |
---|
475 | */ |
---|
476 | #ifdef __STDC__ |
---|
477 | MP_Status_t MP_GetBooleanPacket(MP_Link_pt link, |
---|
478 | MP_Boolean_t *n, |
---|
479 | MP_NumAnnot_t *num_annots) |
---|
480 | #else |
---|
481 | MP_Status_t MP_GetBooleanPacket(link, n, num_annots) |
---|
482 | MP_Link_pt link; |
---|
483 | MP_Boolean_t *n; |
---|
484 | MP_NumAnnot_t *num_annots; |
---|
485 | #endif |
---|
486 | { |
---|
487 | MP_NumChild_t num_child; |
---|
488 | MP_DictTag_t dtag; |
---|
489 | MP_NodeType_t ntype = MP_BooleanType; |
---|
490 | |
---|
491 | ERR_CHK(imp_get_node_header(link, &ntype, &dtag, n, |
---|
492 | num_annots, &num_child)); |
---|
493 | |
---|
494 | #ifndef NO_LOGGING |
---|
495 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
496 | log_fixnum(link, MP_READ_EVENT, "Boolean_NP", MP_BooleanType, |
---|
497 | *num_annots, n); |
---|
498 | MP_LogEvent(link, MP_READ_EVENT, fix_log_msg); |
---|
499 | } |
---|
500 | #endif |
---|
501 | |
---|
502 | return MP_ClearError(link); |
---|
503 | } |
---|
504 | |
---|
505 | |
---|
506 | |
---|
507 | #ifdef __STDC__ |
---|
508 | MP_Status_t MP_GetSint8Packet(MP_Link_pt link, |
---|
509 | MP_Sint8_t *n, |
---|
510 | MP_NumAnnot_t *num_annots) |
---|
511 | #else |
---|
512 | MP_Status_t MP_GetSint8Packet(link, n, num_annots) |
---|
513 | MP_Link_pt link; |
---|
514 | MP_Sint8_t *n; |
---|
515 | MP_NumAnnot_t *num_annots; |
---|
516 | #endif |
---|
517 | { |
---|
518 | MP_NumChild_t num_child; |
---|
519 | MP_NodeType_t ntype = MP_Sint8Type; |
---|
520 | MP_DictTag_t dtag; |
---|
521 | |
---|
522 | ERR_CHK(imp_get_node_header(link, &ntype, &dtag, (MP_Common_t*)n, |
---|
523 | num_annots, &num_child)); |
---|
524 | |
---|
525 | #ifndef NO_LOGGING |
---|
526 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
527 | log_fixnum(link, MP_READ_EVENT, "Sint8_NP", MP_Sint8Type, |
---|
528 | *num_annots, n); |
---|
529 | #endif |
---|
530 | |
---|
531 | return MP_ClearError(link); |
---|
532 | } |
---|
533 | |
---|
534 | |
---|
535 | |
---|
536 | #ifdef __STDC__ |
---|
537 | MP_Status_t MP_GetUint8Packet(MP_Link_pt link, |
---|
538 | MP_Uint8_t *n, |
---|
539 | MP_NumAnnot_t *num_annots) |
---|
540 | #else |
---|
541 | MP_Status_t MP_GetUint8Packet(link, n, num_annots) |
---|
542 | MP_Link_pt link; |
---|
543 | MP_Uint8_t *n; |
---|
544 | MP_NumAnnot_t *num_annots; |
---|
545 | #endif |
---|
546 | { |
---|
547 | MP_NumChild_t num_child; |
---|
548 | MP_NodeType_t ntype = MP_Uint8Type; |
---|
549 | MP_DictTag_t dtag; |
---|
550 | |
---|
551 | ERR_CHK(imp_get_node_header(link, &ntype, &dtag, n, |
---|
552 | num_annots, &num_child)); |
---|
553 | |
---|
554 | #ifndef NO_LOGGING |
---|
555 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
556 | log_fixnum(link, MP_READ_EVENT, "Uint8_NP", MP_Uint8Type, |
---|
557 | *num_annots, n); |
---|
558 | #endif |
---|
559 | |
---|
560 | return MP_ClearError(link); |
---|
561 | } |
---|
562 | |
---|
563 | |
---|
564 | |
---|
565 | #ifdef __STDC__ |
---|
566 | MP_Status_t IMP_GetBoolean(MP_Link_pt link, MP_Boolean_t *n) |
---|
567 | #else |
---|
568 | MP_Status_t IMP_GetBoolean(link, n) |
---|
569 | MP_Link_pt link; |
---|
570 | MP_Boolean_t *n; |
---|
571 | #endif |
---|
572 | { |
---|
573 | MP_NumAnnot_t num_annots; |
---|
574 | MP_NumChild_t num_child; |
---|
575 | MP_NodeType_t ntype = MP_BooleanType; |
---|
576 | MP_DictTag_t dtag; |
---|
577 | |
---|
578 | ERR_CHK(imp_get_node_header(link, &ntype,&dtag, n,&num_annots,&num_child)); |
---|
579 | |
---|
580 | #ifndef NO_LOGGING |
---|
581 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
582 | log_fixnum(link, MP_READ_EVENT, "Boolean_DP", MP_BooleanType, 0, n); |
---|
583 | #endif |
---|
584 | |
---|
585 | return MP_ClearError(link); |
---|
586 | } |
---|
587 | |
---|
588 | |
---|
589 | #ifdef __STDC__ |
---|
590 | MP_Status_t IMP_GetSint8(MP_Link_pt link, MP_Sint8_t *n) |
---|
591 | #else |
---|
592 | MP_Status_t IMP_GetSint8(link, n) |
---|
593 | MP_Link_pt link; |
---|
594 | MP_Sint8_t *n; |
---|
595 | #endif |
---|
596 | { |
---|
597 | MP_NumChild_t num_child; |
---|
598 | MP_NumAnnot_t num_annots = MP_Sint8Type; |
---|
599 | MP_NodeType_t ntype; |
---|
600 | MP_DictTag_t dtag; |
---|
601 | |
---|
602 | ERR_CHK(imp_get_node_header(link, &ntype, &dtag, (MP_Common_t*)n, |
---|
603 | &num_annots, &num_child)); |
---|
604 | |
---|
605 | #ifndef NO_LOGGING |
---|
606 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
607 | log_fixnum(link, MP_READ_EVENT, "Sint8_DP", MP_Sint8Type, 0, n); |
---|
608 | #endif |
---|
609 | |
---|
610 | return MP_ClearError(link); |
---|
611 | } |
---|
612 | |
---|
613 | |
---|
614 | |
---|
615 | #ifdef __STDC__ |
---|
616 | MP_Status_t IMP_GetUint8(MP_Link_pt link, MP_Uint8_t *n) |
---|
617 | #else |
---|
618 | MP_Status_t IMP_GetUint8(link, n) |
---|
619 | MP_Link_pt link; |
---|
620 | MP_Uint8_t *n; |
---|
621 | #endif |
---|
622 | { |
---|
623 | MP_NumChild_t num_child; |
---|
624 | MP_NumAnnot_t num_annots; |
---|
625 | MP_NodeType_t ntype = MP_Uint8Type; |
---|
626 | MP_DictTag_t dtag; |
---|
627 | |
---|
628 | ERR_CHK(imp_get_node_header(link,&ntype, &dtag,n,&num_annots,&num_child)); |
---|
629 | |
---|
630 | #ifndef NO_LOGGING |
---|
631 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
632 | log_fixnum(link, MP_READ_EVENT, "Uint8_DP", MP_Uint8Type, 0, n); |
---|
633 | #endif |
---|
634 | |
---|
635 | return MP_ClearError(link); |
---|
636 | } |
---|
637 | |
---|
638 | |
---|
639 | |
---|
640 | #ifdef __STDC__ |
---|
641 | MP_Status_t MP_GetSint32Packet(MP_Link_pt link, |
---|
642 | MP_Sint32_t *n, |
---|
643 | MP_NumAnnot_t *num_annots) |
---|
644 | #else |
---|
645 | MP_Status_t MP_GetSint32Packet(link, n, num_annots) |
---|
646 | MP_Link_pt link; |
---|
647 | MP_Sint32_t *n; |
---|
648 | MP_NumAnnot_t *num_annots; |
---|
649 | #endif |
---|
650 | { |
---|
651 | MP_NumChild_t num_child; |
---|
652 | MP_NodeType_t ntype = MP_Sint32Type; |
---|
653 | MP_DictTag_t dtag; |
---|
654 | MP_Common_t cv; |
---|
655 | |
---|
656 | ERR_CHK(imp_get_node_header(link,&ntype, &dtag, &cv, |
---|
657 | num_annots, &num_child)); |
---|
658 | |
---|
659 | if (!IMP_GetLong(link, n)) |
---|
660 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
661 | |
---|
662 | #ifndef NO_LOGGING |
---|
663 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
664 | log_fixnum(link, MP_READ_EVENT,"Sint32_NP", MP_Sint32Type, |
---|
665 | *num_annots, n); |
---|
666 | #endif |
---|
667 | |
---|
668 | return MP_ClearError(link); |
---|
669 | } |
---|
670 | |
---|
671 | |
---|
672 | |
---|
673 | #ifdef __STDC__ |
---|
674 | MP_Status_t MP_GetUint32Packet(MP_Link_pt link, |
---|
675 | MP_Uint32_t *n, |
---|
676 | MP_NumAnnot_t *num_annots) |
---|
677 | #else |
---|
678 | MP_Status_t MP_GetUint32Packet(link, n, num_annots) |
---|
679 | MP_Link_pt link; |
---|
680 | MP_Uint32_t *n; |
---|
681 | MP_NumAnnot_t *num_annots; |
---|
682 | #endif |
---|
683 | { |
---|
684 | MP_NumChild_t num_child; |
---|
685 | MP_NodeType_t ntype = MP_Uint32Type; |
---|
686 | MP_DictTag_t dtag; |
---|
687 | MP_Common_t cv; |
---|
688 | |
---|
689 | ERR_CHK(imp_get_node_header(link, &ntype, &dtag, &cv, |
---|
690 | num_annots, &num_child)); |
---|
691 | |
---|
692 | if (!IMP_GetLong(link, (long*)n)) |
---|
693 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
694 | |
---|
695 | #ifndef NO_LOGGING |
---|
696 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
697 | log_fixnum(link, MP_READ_EVENT, "Uint32_NP", MP_Uint32Type, |
---|
698 | *num_annots, n); |
---|
699 | #endif |
---|
700 | |
---|
701 | return MP_ClearError(link); |
---|
702 | } |
---|
703 | |
---|
704 | |
---|
705 | #ifdef __STDC__ |
---|
706 | MP_Status_t IMP_GetApInt(MP_Link_pt link, MP_ApInt_pt apint) |
---|
707 | #else |
---|
708 | MP_Status_t IMP_GetApInt(link, apint) |
---|
709 | MP_Link_pt link; |
---|
710 | MP_ApInt_pt apint; |
---|
711 | #endif |
---|
712 | { |
---|
713 | if (link->bignum.bigint_ops->get_bigint(link, apint) != MP_Success) |
---|
714 | return MP_SetError(link, MP_CantGetDataPacket); |
---|
715 | |
---|
716 | #ifndef NO_LOGGING |
---|
717 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
718 | int len; |
---|
719 | char *msg = NULL; |
---|
720 | len = link->bignum.bigint_ops->bigint_ascii_size(*apint) + 23; |
---|
721 | msg = IMP_MemAllocFnc(len); |
---|
722 | sprintf(msg, "%-12s value: ", "ApInt_DP"); |
---|
723 | link->bignum.bigint_ops->bigint_to_str(*apint, &(msg[strlen(msg)])); |
---|
724 | MP_LogEvent(link, MP_READ_EVENT, msg); |
---|
725 | IMP_MemFreeFnc(msg, len); |
---|
726 | } |
---|
727 | #endif |
---|
728 | |
---|
729 | return MP_ClearError(link); |
---|
730 | } |
---|
731 | |
---|
732 | |
---|
733 | |
---|
734 | #ifdef __STDC__ |
---|
735 | MP_Status_t MP_GetApIntPacket(MP_Link_pt link, |
---|
736 | MP_ApInt_pt apint, |
---|
737 | MP_NumAnnot_t *num_annots) |
---|
738 | #else |
---|
739 | MP_Status_t MP_GetApIntPacket(link, apint, num_annots) |
---|
740 | MP_Link_pt link; |
---|
741 | MP_ApInt_pt apint; |
---|
742 | MP_NumAnnot_t *num_annots; |
---|
743 | #endif |
---|
744 | { |
---|
745 | MP_NumChild_t num_child; |
---|
746 | MP_NodeType_t ntype = MP_ApIntType; |
---|
747 | MP_DictTag_t dtag; |
---|
748 | MP_Common_t cv; |
---|
749 | |
---|
750 | ERR_CHK(imp_get_node_header(link,&ntype, &dtag, &cv, |
---|
751 | num_annots, &num_child)); |
---|
752 | |
---|
753 | if (link->bignum.bigint_ops->get_bigint(link, apint) != MP_Success) |
---|
754 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
755 | |
---|
756 | #ifndef NO_LOGGING |
---|
757 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
758 | int len; |
---|
759 | char *msg = NULL; |
---|
760 | len = link->bignum.bigint_ops->bigint_ascii_size(*apint) + 45; |
---|
761 | msg = IMP_MemAllocFnc(len); |
---|
762 | sprintf(msg, "%-12s annots: %lu value: ", "ApInt_NP", *num_annots); |
---|
763 | link->bignum.bigint_ops->bigint_to_str(*apint, &(msg[strlen(msg)])); |
---|
764 | MP_LogEvent(link, MP_READ_EVENT, msg); |
---|
765 | IMP_MemFreeFnc(msg, len); |
---|
766 | } |
---|
767 | #endif |
---|
768 | |
---|
769 | return MP_ClearError(link); |
---|
770 | } |
---|
771 | |
---|
772 | |
---|
773 | |
---|
774 | #ifdef __STDC__ |
---|
775 | MP_Status_t IMP_GetApReal(MP_Link_pt link, MP_ApReal_pt apreal) |
---|
776 | #else |
---|
777 | MP_Status_t IMP_GetApReal(link, apreal) |
---|
778 | MP_Link_pt link; |
---|
779 | MP_ApReal_pt apreal; |
---|
780 | #endif |
---|
781 | { |
---|
782 | if (link->bignum.bigreal_ops->get_bigreal(link, apreal) != MP_Success) |
---|
783 | return MP_SetError(link, MP_CantGetDataPacket); |
---|
784 | |
---|
785 | #ifndef NO_LOGGING |
---|
786 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
787 | int len; |
---|
788 | char *msg = NULL; |
---|
789 | len = link->bignum.bigreal_ops->bigreal_ascii_size(*apreal) + 25; |
---|
790 | msg = IMP_MemAllocFnc(len); |
---|
791 | sprintf(msg, "%-12s value: ", "ApReal_DP"); |
---|
792 | link->bignum.bigreal_ops->bigreal_to_str(*apreal, &(msg[strlen(msg)])); |
---|
793 | MP_LogEvent(link, MP_READ_EVENT, msg); |
---|
794 | IMP_MemFreeFnc(msg, len); |
---|
795 | } |
---|
796 | #endif |
---|
797 | |
---|
798 | return MP_ClearError(link); |
---|
799 | } |
---|
800 | |
---|
801 | |
---|
802 | |
---|
803 | #ifdef __STDC__ |
---|
804 | MP_Status_t MP_GetApRealPacket(MP_Link_pt link, |
---|
805 | MP_ApReal_pt apreal, |
---|
806 | MP_NumAnnot_t *num_annots) |
---|
807 | #else |
---|
808 | MP_Status_t MP_GetApRealPacket(link, apreal, num_annots) |
---|
809 | MP_Link_pt link; |
---|
810 | MP_ApReal_pt apreal; |
---|
811 | MP_NumAnnot_t *num_annots; |
---|
812 | #endif |
---|
813 | { |
---|
814 | MP_NumChild_t num_child; |
---|
815 | MP_NodeType_t ntype = MP_ApRealType; |
---|
816 | MP_DictTag_t dtag; |
---|
817 | MP_Common_t cv; |
---|
818 | |
---|
819 | ERR_CHK(imp_get_node_header(link, &ntype, &dtag, &cv, |
---|
820 | num_annots, &num_child)); |
---|
821 | |
---|
822 | if (link->bignum.bigreal_ops->get_bigreal(link, apreal) != MP_Success) |
---|
823 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
824 | |
---|
825 | #ifndef NO_LOGGING |
---|
826 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
827 | int len; |
---|
828 | char *msg = NULL; |
---|
829 | len = link->bignum.bigreal_ops->bigreal_ascii_size(*apreal) + 45; |
---|
830 | msg = IMP_MemAllocFnc(len); |
---|
831 | sprintf(msg, "%-12s annots: %lu value: ", "ApReal_NP", *num_annots); |
---|
832 | link->bignum.bigreal_ops->bigreal_to_str(*apreal, &(msg[strlen(msg)])); |
---|
833 | MP_LogEvent(link, MP_READ_EVENT, msg); |
---|
834 | IMP_MemFreeFnc(msg, len); |
---|
835 | } |
---|
836 | #endif |
---|
837 | |
---|
838 | return MP_ClearError(link); |
---|
839 | } |
---|
840 | |
---|
841 | |
---|
842 | #ifdef __STDC__ |
---|
843 | MP_Status_t MP_GetStringPacket(MP_Link_pt link, |
---|
844 | char **s, |
---|
845 | MP_NumAnnot_t *num_annots) |
---|
846 | #else |
---|
847 | MP_Status_t MP_GetStringPacket(link, s, num_annots) |
---|
848 | MP_Link_pt link; |
---|
849 | char **s; |
---|
850 | MP_NumAnnot_t *num_annots; |
---|
851 | #endif |
---|
852 | { |
---|
853 | MP_NumChild_t num_child; |
---|
854 | MP_NodeType_t ntype = MP_StringType; |
---|
855 | MP_DictTag_t dtag; |
---|
856 | MP_Common_t cv; |
---|
857 | |
---|
858 | ERR_CHK(imp_get_node_header(link, &ntype, &dtag, &cv, |
---|
859 | num_annots, &num_child)); |
---|
860 | |
---|
861 | if (!IMP_GetStringBasedType(link, s)) |
---|
862 | return MP_Failure; |
---|
863 | |
---|
864 | #ifndef NO_LOGGING |
---|
865 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
866 | int len = strlen(*s) + 36; |
---|
867 | char *tmp_msg = IMP_MemAllocFnc(len); |
---|
868 | sprintf(tmp_msg, "%-12s annots: %lu value: %s", "String_NP", |
---|
869 | *num_annots, *s); |
---|
870 | MP_LogEvent(link, MP_READ_EVENT, tmp_msg); |
---|
871 | IMP_MemFreeFnc(tmp_msg, len); |
---|
872 | } |
---|
873 | #endif |
---|
874 | |
---|
875 | return MP_ClearError(link); |
---|
876 | } |
---|
877 | |
---|
878 | |
---|
879 | |
---|
880 | #ifdef __STDC__ |
---|
881 | MP_Status_t MP_GetIdentifierPacket(MP_Link_pt link, |
---|
882 | MP_DictTag_t *dtag, |
---|
883 | char **id, |
---|
884 | MP_NumAnnot_t *num_annots) |
---|
885 | #else |
---|
886 | MP_Status_t MP_GetIdentifierPacket(link, dtag, id, num_annots) |
---|
887 | MP_Link_pt link; |
---|
888 | MP_DictTag_t *dtag; |
---|
889 | char **id; |
---|
890 | MP_NumAnnot_t *num_annots; |
---|
891 | #endif |
---|
892 | { |
---|
893 | MP_NumChild_t num_child; |
---|
894 | MP_NodeType_t ntype = MP_IdentifierType; |
---|
895 | MP_Common_t cv; |
---|
896 | |
---|
897 | ERR_CHK(imp_get_node_header(link, &ntype, dtag, &cv, |
---|
898 | num_annots, &num_child)); |
---|
899 | |
---|
900 | if (!IMP_GetStringBasedType(link, id)) |
---|
901 | return MP_Failure; |
---|
902 | |
---|
903 | #ifndef NO_LOGGING |
---|
904 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
905 | sprintf(fix_log_msg, "%-12s annots: %lu dict: %lu value: %s", |
---|
906 | "Ident_NP", *num_annots, *dtag, *id); |
---|
907 | MP_LogEvent(link, MP_READ_EVENT, fix_log_msg); |
---|
908 | } |
---|
909 | #endif |
---|
910 | |
---|
911 | return MP_ClearError(link); |
---|
912 | } |
---|
913 | |
---|
914 | |
---|
915 | |
---|
916 | #ifdef __STDC__ |
---|
917 | MP_Status_t MP_GetCommonLatinIdentifierPacket(MP_Link_pt link, |
---|
918 | MP_DictTag_t *dtag, |
---|
919 | MP_Common_t *id, |
---|
920 | MP_NumAnnot_t *num_annots) |
---|
921 | #else |
---|
922 | MP_Status_t MP_GetCommonLatinIdentifierPacket(link, dtag, id, num_annots) |
---|
923 | MP_Link_pt link; |
---|
924 | MP_DictTag_t *dtag; |
---|
925 | MP_Common_t *id; |
---|
926 | MP_NumAnnot_t *num_annots; |
---|
927 | #endif |
---|
928 | { |
---|
929 | MP_NumChild_t num_child; |
---|
930 | MP_NodeType_t ntype = MP_CommonLatinIdentifierType; |
---|
931 | |
---|
932 | ERR_CHK(imp_get_node_header(link, &ntype, dtag, id, |
---|
933 | num_annots, &num_child)); |
---|
934 | |
---|
935 | #ifndef NO_LOGGING |
---|
936 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
937 | log_dicttype(link, MP_READ_EVENT, "Latin Id_NP", |
---|
938 | MP_CommonLatinIdentifierType, *num_annots, *dtag, id, 0); |
---|
939 | #endif |
---|
940 | |
---|
941 | return MP_ClearError(link); |
---|
942 | } |
---|
943 | |
---|
944 | |
---|
945 | |
---|
946 | |
---|
947 | #ifdef __STDC__ |
---|
948 | MP_Status_t MP_GetCommonGreekIdentifierPacket(MP_Link_pt link, |
---|
949 | MP_DictTag_t *dtag, |
---|
950 | MP_Common_t *id, |
---|
951 | MP_NumAnnot_t *num_annots) |
---|
952 | #else |
---|
953 | MP_Status_t MP_GetCommonGreekIdentifierPacket(link, dtag, id, num_annots) |
---|
954 | MP_Link_pt link; |
---|
955 | MP_DictTag_t *dtag; |
---|
956 | MP_Common_t *id; |
---|
957 | MP_NumAnnot_t *num_annots; |
---|
958 | #endif |
---|
959 | { |
---|
960 | MP_NumChild_t num_child; |
---|
961 | MP_NodeType_t ntype = MP_CommonGreekIdentifierType; |
---|
962 | |
---|
963 | ERR_CHK(imp_get_node_header(link, &ntype, dtag, id, |
---|
964 | num_annots, &num_child)); |
---|
965 | |
---|
966 | #ifndef NO_LOGGING |
---|
967 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
968 | log_dicttype(link, MP_READ_EVENT, "Greek Id_NP", |
---|
969 | MP_CommonGreekIdentifierType, *num_annots, *dtag, id, 0); |
---|
970 | #endif |
---|
971 | |
---|
972 | return MP_ClearError(link); |
---|
973 | } |
---|
974 | |
---|
975 | |
---|
976 | #ifdef __STDC__ |
---|
977 | MP_Status_t MP_GetConstantPacket(MP_Link_pt link, |
---|
978 | MP_DictTag_t *dtag, |
---|
979 | char **cnst, |
---|
980 | MP_NumAnnot_t *num_annots) |
---|
981 | #else |
---|
982 | MP_Status_t MP_GetConstantPacket(link, dtag, cnst, num_annots) |
---|
983 | MP_Link_pt link; |
---|
984 | MP_DictTag_t *dtag; |
---|
985 | char **cnst; |
---|
986 | MP_NumAnnot_t *num_annots; |
---|
987 | #endif |
---|
988 | { |
---|
989 | MP_NumChild_t num_child; |
---|
990 | MP_NodeType_t ntype = MP_ConstantType; |
---|
991 | MP_Common_t cv; |
---|
992 | |
---|
993 | ERR_CHK(imp_get_node_header(link, &ntype, dtag, &cv, |
---|
994 | num_annots, &num_child)); |
---|
995 | |
---|
996 | if (!IMP_GetStringBasedType(link, cnst)) |
---|
997 | return MP_Failure; |
---|
998 | |
---|
999 | #ifndef NO_LOGGING |
---|
1000 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
1001 | sprintf(fix_log_msg, "%-12s annots: %lu dict: %lu value: %s", |
---|
1002 | "Constant_NP", *num_annots, *dtag, *cnst); |
---|
1003 | MP_LogEvent(link, MP_READ_EVENT, fix_log_msg); |
---|
1004 | } |
---|
1005 | #endif |
---|
1006 | return MP_ClearError(link); |
---|
1007 | } |
---|
1008 | |
---|
1009 | |
---|
1010 | |
---|
1011 | /* |
---|
1012 | * July 7, 1995 - I am not sure how much sense it makes to have Get |
---|
1013 | * routines for the common constant and operator types. The receiver |
---|
1014 | * generally won't know if the type is common or not and once the |
---|
1015 | * header has been retrieved, there is nothing to do but call a utility |
---|
1016 | * routine to do the index lookup in the appropriate dictionary |
---|
1017 | */ |
---|
1018 | #ifdef __STDC__ |
---|
1019 | MP_Status_t MP_GetCommonConstantPacket(MP_Link_pt link, |
---|
1020 | MP_DictTag_t *dtag, |
---|
1021 | MP_Common_t *cnst, |
---|
1022 | MP_NumAnnot_t *num_annots) |
---|
1023 | #else |
---|
1024 | MP_Status_t MP_GetCommonConstantPacket(link, dtag, cnst, num_annots) |
---|
1025 | MP_Link_pt link; |
---|
1026 | MP_DictTag_t *dtag; |
---|
1027 | MP_Common_t *cnst; |
---|
1028 | MP_NumAnnot_t *num_annots; |
---|
1029 | #endif |
---|
1030 | { |
---|
1031 | MP_NumChild_t num_child; |
---|
1032 | MP_NodeType_t ntype = MP_CommonConstantType; |
---|
1033 | |
---|
1034 | ERR_CHK(imp_get_node_header(link, &ntype, dtag, cnst, |
---|
1035 | num_annots, &num_child)); |
---|
1036 | |
---|
1037 | #ifndef NO_LOGGING |
---|
1038 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
1039 | log_dicttype(link, MP_READ_EVENT, "Common Cnst_NP", |
---|
1040 | MP_CommonConstantType, *num_annots, *dtag, cnst, 0); |
---|
1041 | #endif |
---|
1042 | |
---|
1043 | return MP_ClearError(link); |
---|
1044 | } |
---|
1045 | |
---|
1046 | |
---|
1047 | |
---|
1048 | #ifdef __STDC__ |
---|
1049 | MP_Status_t MP_GetCommonMetaTypePacket(MP_Link_pt link, |
---|
1050 | MP_DictTag_t *dtag, |
---|
1051 | MP_Common_t *cm, |
---|
1052 | MP_NumAnnot_t *num_annots) |
---|
1053 | #else |
---|
1054 | MP_Status_t MP_GetCommonMetaTypePacket(link, dtag, cm, num_annots) |
---|
1055 | MP_Link_pt link; |
---|
1056 | MP_DictTag_t *dtag; |
---|
1057 | MP_Common_t *cm; |
---|
1058 | MP_NumAnnot_t *num_annots; |
---|
1059 | #endif |
---|
1060 | { |
---|
1061 | MP_NodeType_t ntype = MP_CommonMetaType; |
---|
1062 | MP_NumChild_t num_child; |
---|
1063 | |
---|
1064 | ERR_CHK(imp_get_node_header(link, &ntype, dtag, cm, |
---|
1065 | num_annots, &num_child)); |
---|
1066 | |
---|
1067 | #ifndef NO_LOGGING |
---|
1068 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
1069 | log_dicttype(link, MP_READ_EVENT, "Common Meta_NP", MP_CommonMetaType, |
---|
1070 | *num_annots, *dtag, cm, 0); |
---|
1071 | #endif |
---|
1072 | |
---|
1073 | return MP_ClearError(link); |
---|
1074 | } |
---|
1075 | |
---|
1076 | |
---|
1077 | |
---|
1078 | #ifdef __STDC__ |
---|
1079 | MP_Status_t MP_GetCommonOperatorPacket(MP_Link_pt link, |
---|
1080 | MP_DictTag_t *dtag, |
---|
1081 | MP_Common_t *op, |
---|
1082 | MP_NumAnnot_t *num_annots, |
---|
1083 | MP_NumChild_t *num_child) |
---|
1084 | #else |
---|
1085 | MP_Status_t MP_GetCommonOperatorPacket(link, dtag, op, num_annots, num_child) |
---|
1086 | MP_Link_pt link; |
---|
1087 | MP_DictTag_t *dtag; |
---|
1088 | MP_Common_t *op; |
---|
1089 | MP_NumAnnot_t *num_annots; |
---|
1090 | MP_NumChild_t *num_child; |
---|
1091 | #endif |
---|
1092 | { |
---|
1093 | MP_NodeType_t ntype = MP_CommonOperatorType; |
---|
1094 | |
---|
1095 | ERR_CHK(imp_get_node_header(link, &ntype, dtag, op, num_annots, num_child)); |
---|
1096 | |
---|
1097 | #ifndef NO_LOGGING |
---|
1098 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
1099 | log_dicttype(link, MP_READ_EVENT, "Common Op_NP", MP_CommonOperatorType, |
---|
1100 | *num_annots, *dtag, op, *num_child); |
---|
1101 | #endif |
---|
1102 | |
---|
1103 | return MP_ClearError(link); |
---|
1104 | } |
---|
1105 | |
---|
1106 | |
---|
1107 | |
---|
1108 | #ifdef __STDC__ |
---|
1109 | MP_Status_t MP_GetOperatorPacket(MP_Link_pt link, |
---|
1110 | MP_DictTag_t *dtag, |
---|
1111 | char **op, |
---|
1112 | MP_NumAnnot_t *num_annots, |
---|
1113 | MP_NumChild_t *num_child) |
---|
1114 | #else |
---|
1115 | MP_Status_t MP_GetOperatorPacket(link, dtag, op, num_annots, num_child) |
---|
1116 | MP_Link_pt link; |
---|
1117 | MP_DictTag_t *dtag; |
---|
1118 | char **op; |
---|
1119 | MP_NumAnnot_t *num_annots; |
---|
1120 | MP_NumChild_t *num_child; |
---|
1121 | #endif |
---|
1122 | { |
---|
1123 | MP_NodeType_t ntype = MP_OperatorType; |
---|
1124 | MP_Common_t cv; |
---|
1125 | |
---|
1126 | ERR_CHK(imp_get_node_header(link, &ntype, dtag, &cv, |
---|
1127 | num_annots, num_child)); |
---|
1128 | |
---|
1129 | if (!IMP_GetStringBasedType(link, op)) |
---|
1130 | return MP_Failure; |
---|
1131 | |
---|
1132 | #ifndef NO_LOGGING |
---|
1133 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
1134 | log_dicttype(link, MP_READ_EVENT, "Operator_NP", MP_OperatorType, |
---|
1135 | *num_annots, *dtag, *op, *num_child); |
---|
1136 | #endif |
---|
1137 | |
---|
1138 | return MP_ClearError(link); |
---|
1139 | } |
---|
1140 | |
---|
1141 | |
---|
1142 | |
---|
1143 | #ifdef __STDC__ |
---|
1144 | MP_Status_t MP_GetMetaTypePacket(MP_Link_pt link, |
---|
1145 | MP_DictTag_t *dtag, |
---|
1146 | char **s, |
---|
1147 | MP_NumAnnot_t *num_annots) |
---|
1148 | #else |
---|
1149 | MP_Status_t MP_GetMetaTypePacket(link, dtag, s, num_annots) |
---|
1150 | MP_Link_pt link; |
---|
1151 | MP_DictTag_t *dtag, |
---|
1152 | char **s; |
---|
1153 | MP_NumAnnot_t *num_annots; |
---|
1154 | #endif |
---|
1155 | { |
---|
1156 | MP_NumChild_t num_child; |
---|
1157 | MP_NodeType_t ntype = MP_MetaType; |
---|
1158 | MP_Common_t cv; |
---|
1159 | |
---|
1160 | ERR_CHK(imp_get_node_header(link, &ntype, dtag, &cv, |
---|
1161 | num_annots, &num_child)); |
---|
1162 | |
---|
1163 | if (!IMP_GetStringBasedType(link, s)) |
---|
1164 | return MP_Failure; |
---|
1165 | |
---|
1166 | #ifndef NO_LOGGING |
---|
1167 | if (link->logmask & MP_LOG_READ_EVENTS) { |
---|
1168 | sprintf(fix_log_msg, "%-12s annots: %lu dict: %lu value: %s", |
---|
1169 | "MetaType_NP", *num_annots, *dtag, *s); |
---|
1170 | MP_LogEvent(link, MP_READ_EVENT, fix_log_msg); |
---|
1171 | } |
---|
1172 | #endif |
---|
1173 | |
---|
1174 | return MP_ClearError(link); |
---|
1175 | } |
---|
1176 | |
---|
1177 | |
---|
1178 | #ifdef __STDC__ |
---|
1179 | MP_Status_t IMP_GetReal32(MP_Link_pt link, MP_Real32_t *fp) |
---|
1180 | #else |
---|
1181 | MP_Status_t IMP_GetReal32(link, fp) |
---|
1182 | MP_Link_pt link; |
---|
1183 | MP_Real32_t *fp; |
---|
1184 | #endif |
---|
1185 | { |
---|
1186 | #ifdef vax |
---|
1187 | struct ieee_single is; |
---|
1188 | struct vax_single vs, *vsp; |
---|
1189 | struct sgl_limits *lim; |
---|
1190 | #endif /* vax */ |
---|
1191 | |
---|
1192 | MP_Status_t status; |
---|
1193 | |
---|
1194 | #ifndef vax |
---|
1195 | status = IMP_GetLong(link, (long *)fp); |
---|
1196 | #else /* not vax */ |
---|
1197 | vsp = (struct vax_single *)fp; |
---|
1198 | if (!IMP_GetLong(link, (long *)&is)) |
---|
1199 | return MP_SetError(link, MP_CantGetDataPacket); |
---|
1200 | |
---|
1201 | for (i = 0, lim = sgl_limits; |
---|
1202 | i < sizeof(sgl_limits)/sizeof(struct sgl_limits); i++, lim++) |
---|
1203 | if (is.exp == lim->ieee.exp |
---|
1204 | && is.mantissa = lim->ieee.mantissa) { |
---|
1205 | *vsp = lim->s; |
---|
1206 | goto doneit; |
---|
1207 | } |
---|
1208 | |
---|
1209 | vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; |
---|
1210 | vsp->mantissa2 = is.mantissa; |
---|
1211 | vsp->mantissa1 = (is.mantissa >> 16); |
---|
1212 | |
---|
1213 | doneit: |
---|
1214 | vsp->sign = is.sign; |
---|
1215 | status = MP_Success; |
---|
1216 | #endif /* not vax */ |
---|
1217 | |
---|
1218 | /* |
---|
1219 | * I _think_ this logging will work for vax floats. April 25, 1996 |
---|
1220 | */ |
---|
1221 | |
---|
1222 | #ifndef NO_LOGGING |
---|
1223 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
1224 | log_fixreal(link, MP_READ_EVENT, "Real32_DP", MP_Real32Type, 0, fp); |
---|
1225 | #endif |
---|
1226 | |
---|
1227 | return status; |
---|
1228 | } |
---|
1229 | |
---|
1230 | |
---|
1231 | |
---|
1232 | #ifdef __STDC__ |
---|
1233 | MP_Status_t IMP_GetReal64(MP_Link_pt link, MP_Real64_t *dp) |
---|
1234 | #else |
---|
1235 | MP_Status_t IMP_GetReal64(link, dp) |
---|
1236 | MP_Link_pt link; |
---|
1237 | MP_Real64_t *dp; |
---|
1238 | #endif |
---|
1239 | { |
---|
1240 | long *lp; |
---|
1241 | |
---|
1242 | #ifdef vax |
---|
1243 | struct ieee_double id; |
---|
1244 | struct vax_double vd; |
---|
1245 | struct dbl_limits *lim; |
---|
1246 | #endif /* vax */ |
---|
1247 | |
---|
1248 | #ifndef vax |
---|
1249 | lp = (long *)dp; |
---|
1250 | # ifdef WORDS_BIGENDIAN |
---|
1251 | |
---|
1252 | if (!IMP_GetLong(link, lp++) || !IMP_GetLong(link, lp)) |
---|
1253 | return MP_SetError(link, MP_CantGetDataPacket); |
---|
1254 | |
---|
1255 | # else /* WORDS_LITTLEENDIAN */ |
---|
1256 | |
---|
1257 | if (!IMP_GetLong(link, lp+1) || !IMP_GetLong(link, lp)) |
---|
1258 | return MP_SetError(link, MP_CantGetDataPacket); |
---|
1259 | |
---|
1260 | # endif /* WORDS_BIGENDIAN */ |
---|
1261 | |
---|
1262 | #else /* vax */ |
---|
1263 | lp = (long *)&id; |
---|
1264 | if (!IMP_GetLong(link, lp++) || !IMP_GetLong(link, lp)) |
---|
1265 | return MP_Failure; |
---|
1266 | |
---|
1267 | for (i = 0, lim = dbl_limits; |
---|
1268 | i < sizeof(dbl_limits)/sizeof(struct dbl_limits); i++, lim++) |
---|
1269 | if (id.mantissa2 == lim->ieee.mantissa2 |
---|
1270 | && id.mantissa1 == lim->ieee.mantissa1 |
---|
1271 | && id.exp == lim->ieee.exp) { |
---|
1272 | vd = lim->d; |
---|
1273 | goto doneit; |
---|
1274 | } |
---|
1275 | |
---|
1276 | vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; |
---|
1277 | vd.mantissa1 = (id.mantissa1 >> 13); |
---|
1278 | vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) |
---|
1279 | | (id.mantissa2 >> 29); |
---|
1280 | vd.mantissa3 = (id.mantissa2 >> 13); |
---|
1281 | vd.mantissa4 = (id.mantissa2 << 3); |
---|
1282 | |
---|
1283 | doneit: |
---|
1284 | vd.sign = id.sign; |
---|
1285 | *dp = *((double *)&vd); |
---|
1286 | #endif /* vax */ |
---|
1287 | |
---|
1288 | #ifndef NO_LOGGING |
---|
1289 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
1290 | log_fixreal(link, MP_READ_EVENT, "Real64_DP", MP_Real64Type, 0, dp); |
---|
1291 | #endif |
---|
1292 | |
---|
1293 | return MP_ClearError(link); |
---|
1294 | } |
---|
1295 | |
---|
1296 | |
---|
1297 | |
---|
1298 | #ifdef __STDC__ |
---|
1299 | MP_Status_t MP_GetReal32Packet(MP_Link_pt link, |
---|
1300 | MP_Real32_t *fp, |
---|
1301 | MP_NumAnnot_t *num_annots) |
---|
1302 | #else |
---|
1303 | MP_Status_t MP_GetReal32Packet(link, fp, num_annots) |
---|
1304 | MP_Link_pt link; |
---|
1305 | MP_Real32_t *fp; |
---|
1306 | MP_NumAnnot_t *num_annots; |
---|
1307 | #endif |
---|
1308 | { |
---|
1309 | MP_NodeType_t ntype = MP_Real32Type; |
---|
1310 | MP_NumChild_t num_child; |
---|
1311 | MP_DictTag_t dtag; |
---|
1312 | MP_Common_t cv; |
---|
1313 | |
---|
1314 | #ifdef vax |
---|
1315 | struct ieee_single is; |
---|
1316 | struct vax_single vs, *vsp; |
---|
1317 | struct sgl_limits *lim; |
---|
1318 | #endif /* vax */ |
---|
1319 | |
---|
1320 | ERR_CHK(imp_get_node_header(link, &ntype, &dtag, &cv, |
---|
1321 | num_annots, &num_child)); |
---|
1322 | |
---|
1323 | #ifndef vax |
---|
1324 | if (!IMP_GetLong(link, (long *)fp)) |
---|
1325 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
1326 | #else /* vax */ |
---|
1327 | vsp = (struct vax_single *)fp; |
---|
1328 | if (!IMP_GetLong(link, (long *)&is)) |
---|
1329 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
1330 | |
---|
1331 | for (i = 0, lim = sgl_limits; |
---|
1332 | i < sizeof(sgl_limits)/sizeof(struct sgl_limits); i++, lim++) |
---|
1333 | if (is.exp == lim->ieee.exp |
---|
1334 | && is.mantissa = lim->ieee.mantissa) { |
---|
1335 | *vsp = lim->s; |
---|
1336 | goto doneit; |
---|
1337 | } |
---|
1338 | |
---|
1339 | vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; |
---|
1340 | vsp->mantissa2 = is.mantissa; |
---|
1341 | vsp->mantissa1 = (is.mantissa >> 16); |
---|
1342 | |
---|
1343 | doneit: |
---|
1344 | vsp->sign = is.sign; |
---|
1345 | #endif /* vax */ |
---|
1346 | |
---|
1347 | #ifndef NO_LOGGING |
---|
1348 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
1349 | log_fixreal(link, MP_READ_EVENT, "Real32_DP", |
---|
1350 | MP_Real32Type, *num_annots,fp); |
---|
1351 | #endif /* NO_LOGGING */ |
---|
1352 | |
---|
1353 | return MP_ClearError(link); |
---|
1354 | } |
---|
1355 | |
---|
1356 | |
---|
1357 | |
---|
1358 | #ifdef __STDC__ |
---|
1359 | MP_Status_t MP_GetReal64Packet(MP_Link_pt link, |
---|
1360 | MP_Real64_t *dp, |
---|
1361 | MP_NumAnnot_t *num_annots) |
---|
1362 | #else |
---|
1363 | MP_Status_t MP_GetReal64Packet(link, dp, num_annots) |
---|
1364 | MP_Link_pt link; |
---|
1365 | MP_Real64_t *dp; |
---|
1366 | MP_NumAnnot_t *num_annots; |
---|
1367 | #endif |
---|
1368 | { |
---|
1369 | MP_NodeType_t ntype = MP_Real64Type; |
---|
1370 | MP_NumChild_t num_child; |
---|
1371 | MP_DictTag_t dtag; |
---|
1372 | MP_Common_t cv; |
---|
1373 | register long *lp; |
---|
1374 | #ifdef vax |
---|
1375 | struct ieee_double id; |
---|
1376 | struct vax_double vd; |
---|
1377 | register struct dbl_limits *lim; |
---|
1378 | #endif /* vax */ |
---|
1379 | |
---|
1380 | ERR_CHK(imp_get_node_header(link,&ntype, &dtag, &cv, |
---|
1381 | num_annots, &num_child)); |
---|
1382 | |
---|
1383 | #ifndef vax |
---|
1384 | lp = (long *)dp; |
---|
1385 | |
---|
1386 | #ifdef WORDS_BIGENDIAN |
---|
1387 | if (!IMP_GetLong(link, lp++) || !IMP_GetLong(link, lp)) |
---|
1388 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
1389 | #else /* not WORDS_BIGENDIAN */ |
---|
1390 | if (!IMP_GetLong(link, lp+1) || !IMP_GetLong(link, lp)) |
---|
1391 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
1392 | #endif /* not WORDS_BIGENDIAN */ |
---|
1393 | |
---|
1394 | #else /* vax */ |
---|
1395 | lp = (long *)&id; |
---|
1396 | if (!IMP_GetLong(link, lp++) || !IMP_GetLong(link, lp)) |
---|
1397 | return MP_SetError(link, MP_CantGetNodePacket); |
---|
1398 | |
---|
1399 | for (i = 0, lim = dbl_limits; |
---|
1400 | i < sizeof(dbl_limits)/sizeof(struct dbl_limits); i++, lim++) |
---|
1401 | if (id.mantissa2 == lim->ieee.mantissa2 |
---|
1402 | && id.mantissa1 == lim->ieee.mantissa1 |
---|
1403 | && id.exp == lim->ieee.exp) { |
---|
1404 | vd = lim->d; |
---|
1405 | goto doneit; |
---|
1406 | } |
---|
1407 | |
---|
1408 | vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; |
---|
1409 | vd.mantissa1 = (id.mantissa1 >> 13); |
---|
1410 | vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) |
---|
1411 | | (id.mantissa2 >> 29); |
---|
1412 | vd.mantissa3 = (id.mantissa2 >> 13); |
---|
1413 | vd.mantissa4 = (id.mantissa2 << 3); |
---|
1414 | |
---|
1415 | doneit: |
---|
1416 | vd.sign = id.sign; |
---|
1417 | *dp = *((double *)&vd); |
---|
1418 | #endif /* vax */ |
---|
1419 | |
---|
1420 | #ifndef NO_LOGGING |
---|
1421 | if (link->logmask & MP_LOG_READ_EVENTS) |
---|
1422 | log_fixreal(link, MP_READ_EVENT, |
---|
1423 | "Real64_NP", MP_Real64Type, *num_annots,dp); |
---|
1424 | #endif /* NO_LOGGING */ |
---|
1425 | |
---|
1426 | return MP_ClearError(link); |
---|
1427 | } |
---|
1428 | |
---|
1429 | |
---|