U8, U16, U32 data type changes
[o-du/l2.git] / src / mt / ss_pack.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18 \f
19 /********************************************************************20**
20  
21      Name:     System Services -- packing
22  
23      Type:     C source file
24  
25      Desc:     Source code for System Services packing functions.
26  
27      File:     ss_pack.c
28  
29 *********************************************************************21*/
30
31 \f
32 /* header include files (.h) */
33
34 #include "envopt.h"        /* environment options */
35 #include "envdep.h"        /* environment dependent */
36 #include "envind.h"        /* environment independent */
37   
38 #include "gen.h"           /* general layer */
39 #include "ssi.h"           /* system services */
40
41 #include "ss_err.h"        /* errors */
42 #include "ss_dep.h"        /* implementation-specific */
43 #include "ss_queue.h"      /* queues */
44 #include "ss_msg.h"        /* messaging */
45 #include "ss_mem.h"        /* memory management interface */
46 #include "ss_gen.h"        /* general */
47 #include "cm_mem.h"        /* memory management */
48
49
50
51 /* header/extern include files (.x) */
52
53 #include "gen.x"           /* general layer */
54 #include "ssi.x"           /* system services */
55
56 #include "ss_dep.x"        /* implementation-specific */
57 #include "ss_queue.x"      /* queues */
58 #include "ss_task.x"       /* tasking */
59 #include "ss_timer.x"      /* timers */
60 #include "ss_strm.x"       /* STREAMS */
61 #include "ss_msg.x"        /* messaging */
62 #include "ss_mem.x"        /* memory management interface */
63 #include "ss_drvr.x"       /* driver tasks */
64 #ifdef SS_LOCKLESS_MEMORY
65 #include "cm_llist.x"
66 #include "cm_hash.x"
67 #include "cm_mem_wl.x"        /* common memory manager */
68 #else
69 #include "cm_mem.x"        /* common memory manager */
70 #endif /* SS_LOCKLESS_MEMORY */
71 #include "ss_gen.x"        /* general */
72
73
74 \f  
75 /*
76 *
77 *       Fun:   SPkS8
78 *
79 *       Desc:  This function packs a signed 8 bit value into a message.
80 *
81 *       Ret:   ROK      - ok
82 *              RFAILED  - failed, general (optional)
83 *              ROUTRES  - failed, out of resources (optional)
84 *
85 *       Notes: None
86 *
87 *       File:  ss_pack.c
88 *
89 */
90
91 #ifdef ANSI
92 S16 SPkS8
93 (
94 S8 val,                     /* value */
95 Buffer *mBuf                /* message buffer */
96 )
97 #else
98 S16 SPkS8(val, mBuf)
99 S8 val;                     /* value */
100 Buffer *mBuf;               /* message buffer */
101 #endif
102 {
103    S16 ret;                 /* return code */
104    ret = SAddPreMsg((Data) val, mBuf);
105 #if (ERRCLASS & ERRCLS_ADD_RES)
106    if (ret != ROK)
107       SSLOGERROR(ERRCLS_ADD_RES, ESS242, (ErrVal)ret, "SAddPreMsg() failed");
108 #endif
109    return (ret);
110 } /* end of SPkS8 */
111   
112
113 \f  
114 /*
115 *
116 *       Fun:   oduUnpackUInt8
117 *
118 *       Desc:  This function packs an unsigned 8 bit value into a message.
119 *
120 *       Ret:   ROK      - ok
121 *              RFAILED  - failed, general (optional)
122 *              ROUTRES  - failed, out of resources (optional)
123 *
124 *       Notes: None
125 *
126 *       File:  ss_pack.c
127 *
128 */
129   
130 #ifdef ANSI
131 S16 oduUnpackUInt8
132 (
133 uint8_t val,                     /* value */
134 Buffer *mBuf                /* message buffer */
135 )
136 #else
137 S16 oduUnpackUInt8(val, mBuf)
138 uint8_t val;                     /* value */
139 Buffer *mBuf;               /* message buffer */
140 #endif
141 {
142    S16 ret;                 /* return code */
143    ret = SAddPreMsg((Data) val, mBuf);
144 #if (ERRCLASS & ERRCLS_ADD_RES)
145    if (ret != ROK)
146       SSLOGERROR(ERRCLS_ADD_RES, ESS243, (ErrVal)ret, "SAddPreMsg() failed");
147 #endif
148    return (ret);
149 } /* end of oduUnpackUInt8 */
150 \f  
151 /*
152 *
153 *       Fun:   SPkS16
154 *
155 *       Desc:  This function packs a signed 16 bit value into a message.
156 *
157 *       Ret:   ROK      - ok
158 *              RFAILED  - failed, general (optional)
159 *              ROUTRES  - failed, out of resources (optional)
160 *
161 *       Notes: None
162 *
163 *       File:  ss_pack.c
164 *
165 */
166   
167 #ifdef ANSI
168 S16 SPkS16
169 (
170 S16 val,                    /* value */
171 Buffer *mBuf                /* message buffer */
172 )
173 #else
174 S16 SPkS16(val, mBuf)
175 S16 val;                    /* value */
176 Buffer *mBuf;               /* message buffer */
177 #endif
178 {
179    Data pkArray[2];         /* array for packing */
180    S16 ret;                 /* return code */
181
182 #ifndef FCSPKINT            /* backward compatibility, packing order */
183    pkArray[0] = (Data) GetHiByte(val);
184    pkArray[1] = (Data) GetLoByte(val);
185 #else                   /* forward compatibility, packing order */
186    pkArray[1] = (Data) GetHiByte(val);
187    pkArray[0] = (Data) GetLoByte(val);
188 #endif
189    ret = SAddPreMsgMult(pkArray, (MsgLen) 2, mBuf);
190 #if (ERRCLASS & ERRCLS_ADD_RES)
191    if (ret != ROK)
192       SSLOGERROR(ERRCLS_ADD_RES, ESS244, (ErrVal)ret, "SAddPreMsgMult() failed");
193 #endif
194    return (ret);
195 } /* end of SPkS16 */
196   
197 \f  
198 /*
199 *
200 *       Fun:   oduUnpackUInt16
201 *
202 *       Desc:  This function packs an unsigned 16 bit value into a message.
203 *
204 *       Ret:   ROK      - ok
205 *              RFAILED  - failed, general (optional)
206 *              ROUTRES  - failed, out of resources (optional)
207 *
208 *       Notes: None
209 *
210 *       File:  ss_pack.c
211 *
212 */
213   
214 #ifdef ANSI
215 S16 oduUnpackUInt16
216 (
217 uint16_t val,                    /* value */
218 Buffer *mBuf                /* message buffer */
219 )
220 #else
221 S16 oduUnpackUInt16(val, mBuf)
222 uint16_t val;                    /* value */
223 Buffer *mBuf;               /* message buffer */
224 #endif
225 {
226    Data pkArray[2];         /* array for packing */
227    S16 ret;                 /* return code */
228
229 #ifndef FCSPKINT            /* backward compatibility, packing order */
230    pkArray[0] = (Data) GetHiByte(val);
231    pkArray[1] = (Data) GetLoByte(val);
232 #else                       /* forward compatibility, packing order */
233    pkArray[1] = (Data) GetHiByte(val);
234    pkArray[0] = (Data) GetLoByte(val);
235 #endif
236    ret = SAddPreMsgMult(pkArray, (MsgLen) 2, mBuf);
237 #if (ERRCLASS & ERRCLS_ADD_RES)
238    if (ret != ROK)
239       SSLOGERROR(ERRCLS_ADD_RES, ESS245, (ErrVal)ret, "SAddPreMsgMult() failed");
240 #endif
241    return (ret);
242 } /* end of oduUnpackUInt16 */
243   
244 \f  
245 /*
246 *
247 *       Fun:   SPkS32
248 *
249 *       Desc:  This function packs a signed 32 bit value into a message.
250 *
251 *       Ret:   ROK      - ok
252 *              RFAILED  - failed, general (optional)
253 *              ROUTRES  - failed, out of resources (optional)
254 *
255 *       Notes: None
256 *
257 *       File:  ss_pack.c
258 *
259 */
260   
261 #ifdef ANSI
262 S16 SPkS32
263 (
264 S32 val,                    /* value */
265 Buffer *mBuf                /* message buffer */
266 )
267 #else
268 S16 SPkS32(val, mBuf)
269 S32 val;                    /* value */
270 Buffer *mBuf;               /* message buffer */
271 #endif
272 {
273    uint16_t tmp;                 /* temporary value */
274    Data pkArray[4];         /* packing array */
275    S16 ret;                 /* return code */
276   
277 #ifndef FCSPKINT        /* backward compatibility, packing order */
278    tmp = (uint16_t) GetHiWord(val);
279    pkArray[0] = (Data) GetHiByte(tmp);
280    pkArray[1] = (Data) GetLoByte(tmp);
281    tmp = (uint16_t) GetLoWord(val);
282    pkArray[2] = (Data) GetHiByte(tmp);
283    pkArray[3] = (Data) GetLoByte(tmp);
284 #else                   /* forward compatibility, packing order */
285    tmp = (uint16_t) GetHiWord(val);
286    pkArray[3] = (Data) GetHiByte(tmp);
287    pkArray[2] = (Data) GetLoByte(tmp);
288    tmp = (uint16_t) GetLoWord(val);
289    pkArray[1] = (Data) GetHiByte(tmp);
290    pkArray[0] = (Data) GetLoByte(tmp);
291 #endif
292    ret = SAddPreMsgMult(pkArray, (MsgLen) 4, mBuf);
293 #if (ERRCLASS & ERRCLS_ADD_RES)
294    if (ret != ROK)
295       SSLOGERROR(ERRCLS_ADD_RES, ESS246, (ErrVal)ret, "SAddPreMsgMult() failed");
296 #endif
297    return (ret);
298 } /* end of SPkS32 */
299   
300 \f  
301 /*
302 *
303 *       Fun:   oduUnpackUInt32
304 *
305 *       Desc:  This function packs an unsigned 32 bit value into a message.
306 *
307 *       Ret:   ROK      - ok
308 *              RFAILED  - failed, general (optional)
309 *              ROUTRES  - failed, out of resources (optional)
310 *
311 *       Notes: None
312 *
313 *       File:  ss_pack.c
314 *
315 */
316   
317 #ifdef ANSI
318 S16 oduUnpackUInt32
319 (
320 uint32_t val,                    /* value */
321 Buffer *mBuf                /* message buffer */
322 )
323 #else
324 S16 oduUnpackUInt32(val, mBuf)
325 uint32_t val;                    /* value */
326 Buffer *mBuf;               /* message buffer */
327 #endif
328 {
329    uint16_t tmp;                 /* temporary value */
330    Data pkArray[4];         /* packing array */
331    S16 ret;                 /* return code */
332   
333 #ifndef FCSPKINT        /* backward compatibility, packing order */
334    tmp = (uint16_t) GetHiWord(val);
335    pkArray[0] = (Data) GetHiByte(tmp);
336    pkArray[1] = (Data) GetLoByte(tmp);
337    tmp = (uint16_t) GetLoWord(val);
338    pkArray[2] = (Data) GetHiByte(tmp);
339    pkArray[3] = (Data) GetLoByte(tmp);
340 #else                   /* forward compatibility, packing order */
341    tmp = (uint16_t) GetHiWord(val);
342    pkArray[3] = (Data) GetHiByte(tmp);
343    pkArray[2] = (Data) GetLoByte(tmp);
344    tmp = (uint16_t) GetLoWord(val);
345    pkArray[1] = (Data) GetHiByte(tmp);
346    pkArray[0] = (Data) GetLoByte(tmp);
347 #endif
348    ret = SAddPreMsgMult(pkArray, (MsgLen) 4, mBuf);
349 #if (ERRCLASS & ERRCLS_ADD_RES)
350    if (ret != ROK)
351       SSLOGERROR(ERRCLS_ADD_RES, ESS247, (ErrVal)ret, "SAddPreMsgMult() failed");
352 #endif
353    return (ret);
354 } /* end of oduUnpackUInt32 */
355
356 /*ss038.103  1. Added Floating point support*/
357 #ifdef SS_FLOAT
358 /*
359 *
360 *       Fun:   SPkF32
361 *
362 *       Desc:  This function packs an 32 bit ieee-754 format float value into a message.
363 *
364 *       Ret:   ROK      - ok
365 *              RFAILED  - failed, general (optional)
366 *              ROUTRES  - failed, out of resources (optional)
367 *
368 *       Notes: None
369 *
370 *       File:  ss_pack.c
371 *
372 */
373   
374 #ifdef ANSI
375 S16 SPkF32
376 (
377 F32 val,                    /* value */
378 Buffer *mBuf                /* message buffer */
379 )
380 #else
381 S16 SPkF32(val, mBuf)
382 F32 val;                    /* value */
383 Buffer *mBuf;               /* message buffer */
384 #endif
385 {
386    S16  ret;                /* return code */
387    S8   tmpArray[15];       /* temporary array */
388 #ifdef FCSPKINT             /* backward compatibility, packing order */
389    S32  tIdx = 14;          /* counters */
390    S32  kIdx = 0;           /* counters */
391    S8   pkArray[15];        /* packing array */
392 #endif /*FCSPKINT*/
393   
394    sprintf(tmpArray, "%.7e", val);
395
396 #ifndef FCSPKINT            /* backward compatibility, packing order */
397    ret = SAddPreMsgMult((Data*)tmpArray, (MsgLen) 15, mBuf);
398 #else
399    while(tIdx >= 0)
400    {
401       pkArray[kIdx] = tmpArray[tIdx];
402       tIdx--; kIdx++;
403    }
404    ret = SAddPreMsgMult((Data*)pkArray, (MsgLen) 15, mBuf);
405 #endif
406
407
408 #if (ERRCLASS & ERRCLS_ADD_RES)
409    if (ret != ROK)
410       SSLOGERROR(ERRCLS_ADD_RES, ESS248, (ErrVal)ret, "SAddPreMsgMult() failed");
411 #endif
412    return (ret);
413 } /* end of SPkF32 */
414
415 /*
416 *
417 *       Fun:   SPkF64
418 *
419 *       Desc:  This function packs an 64 bit ieee-754 format float value into a message.
420 *
421 *       Ret:   ROK      - ok
422 *              RFAILED  - failed, general (optional)
423 *              ROUTRES  - failed, out of resources (optional)
424 *
425 *       Notes: None
426 *
427 *       File:  ss_pack.c
428 *
429 */
430   
431 #ifdef ANSI
432 S16 SPkF64
433 (
434 F64 val,                    /* value */
435 Buffer *mBuf                /* message buffer */
436 )
437 #else
438 S16 SPkF64(val, mBuf)
439 F64 val;                    /* value */
440 Buffer *mBuf;               /* message buffer */
441 #endif
442 {
443
444    S16  ret;                /* return code */
445    S8   tmpArray[25];       /* temporary array */
446 #ifdef FCSPKINT             /* backward compatibility, packing order */
447    S32  tIdx = 24;          /* counters */
448    S32  kIdx = 0;           /* counters */
449    S8   pkArray[25];        /* packing array */
450 #endif /*FCSPKINT*/
451   
452    sprintf(tmpArray, "%.16le", val);
453
454 #ifndef FCSPKINT            /* backward compatibility, packing order */
455    ret = SAddPreMsgMult((Data*)tmpArray, (MsgLen) 25, mBuf);
456 #else
457    while(tIdx >= 0)
458    {
459       pkArray[kIdx] = tmpArray[tIdx];
460       tIdx--; kIdx++;
461    }
462    ret = SAddPreMsgMult((Data*)pkArray, (MsgLen) 25, mBuf);
463 #endif
464
465
466 #if (ERRCLASS & ERRCLS_ADD_RES)
467    if (ret != ROK)
468       SSLOGERROR(ERRCLS_ADD_RES, ESS249, (ErrVal)ret, "SAddPreMsgMult() failed");
469 #endif
470    return (ret);
471
472 } /* end of SPkF64 */
473 #endif /* SS_FLOAT */
474 \f  
475 /*
476 *
477 *       Fun:   SUnpkS8
478 *
479 *       Desc:  This function unpacks a signed 8 bit value from a message.
480 *
481 *       Ret:   ROK      - ok
482 *
483 *       Notes: None
484 *
485 *       File:  ss_pack.c
486 *
487 */
488   
489 #ifdef ANSI
490 S16 SUnpkS8
491 (
492 S8 *val,                    /* pointer to value */
493 Buffer *mBuf                /* message buffer */
494 )
495 #else
496 S16 SUnpkS8(val, mBuf)
497 S8 *val;                    /* pointer to value */
498 Buffer *mBuf;               /* message buffer */
499 #endif
500 {
501    Data tmp;                /* temporary value */
502    S16 ret;                 /* return code */
503
504 /* ss021.103 - Addition of data pointer check */
505 #if (ERRCLASS & ERRCLS_INT_PAR)
506    /* check data pointer */
507    if (!val)
508    {
509       SSLOGERROR(ERRCLS_INT_PAR, ESS250, ERRZERO, "SUnpkS8 : Null value");
510       return RFAILED;
511    }
512 #endif /* ERRCLASS & ERRCLS_INT_PAR */
513
514    ret = SRemPreMsg(&tmp, mBuf);
515 #if (ERRCLASS & ERRCLS_DEBUG)
516    if (ret != ROK)
517       SSLOGERROR(ERRCLS_DEBUG, ESS251, (ErrVal)ret, "SRemPreMsg() failed");
518 #endif
519    *val = (S8) tmp;
520    return (ret);
521 } /* end of SUnpkS8 */
522   
523 \f  
524 /*
525 *
526 *       Fun:   oduPackUInt8
527 *
528 *       Desc:  This function unpacks an unsigned 8 bit value from a message.
529 *
530 *       Ret:   ROK      - ok
531 *
532 *       Notes: None
533 *
534 *       File:  ss_pack.c
535 *
536 */
537   
538 #ifdef ANSI
539 S16 oduPackUInt8
540 (
541 uint8_t *val,                    /* pointer to value */
542 Buffer *mBuf                /* message buffer */
543 )
544 #else
545 S16 oduPackUInt8(val, mBuf)
546 uint8_t *val;                    /* pointer to value */
547 Buffer *mBuf;               /* message buffer */
548 #endif
549 {
550    Data tmp;                /* temporary value */
551    S16 ret;                 /* return code */
552
553 /* ss021.103 - Addition of data pointer check */
554 #if (ERRCLASS & ERRCLS_INT_PAR)
555    /* check data pointer */
556    if (!val)
557    {
558       SSLOGERROR(ERRCLS_INT_PAR, ESS252, ERRZERO, "oduPackUInt8 : Null value");
559       return RFAILED;
560    }
561 #endif /* ERRCLASS & ERRCLS_INT_PAR */
562
563    ret = SRemPreMsg(&tmp, mBuf);
564 #if (ERRCLASS & ERRCLS_DEBUG)
565    if (ret != ROK)
566       SSLOGERROR(ERRCLS_DEBUG, ESS253, (ErrVal)ret, "SRemPreMsg() failed");
567 #endif
568    *val = (uint8_t) tmp;
569    return (ret);
570 } /* end of oduPackUInt8 */
571 \f  
572 /*
573 *
574 *       Fun:   SUnpkS16
575 *
576 *       Desc:  This function unpacks a signed 16 bit value from a message.
577 *
578 *       Ret:   ROK      - ok
579 *
580 *       Notes: None
581 *
582 *       File:  ss_pack.c
583 *
584 */
585   
586 #ifdef ANSI
587 S16 SUnpkS16
588 (
589 S16 *val,                   /* pointer to value */
590 Buffer *mBuf                /* message buffer */
591 )
592 #else
593 S16 SUnpkS16(val, mBuf)
594 S16 *val;                   /* pointer to value */
595 Buffer *mBuf;               /* message buffer */
596 #endif
597 {
598    uint16_t tmp16;               /* temporary value */
599    Data unpkArray[2];       /* unpacking array */
600    S16 ret;                 /* return code */
601
602 /* ss021.103 - Addition of data pointer check */
603 #if (ERRCLASS & ERRCLS_INT_PAR)
604    /* check data pointer */
605    if (!val)
606    {
607       SSLOGERROR(ERRCLS_INT_PAR, ESS254, ERRZERO, "SUnpkS16 : Null value");
608       return RFAILED;
609    }
610 #endif /* ERRCLASS & ERRCLS_INT_PAR */
611
612    ret = SRemPreMsgMult(unpkArray, (MsgLen) 2, mBuf);
613 #if (ERRCLASS & ERRCLS_DEBUG)
614    if (ret != ROK)
615       SSLOGERROR(ERRCLS_DEBUG, ESS255, (ErrVal)ret, "SRemPreMsgMult() failed");
616 #endif
617    tmp16 = 0; 
618 #ifndef FCSPKINT            /* backward compatibility, packing order */
619    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[1]);
620    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[0]);
621 #else                       /* forward compatibility, packing order */
622    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[0]);
623    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[1]);
624 #endif
625    *val = (S16) tmp16;
626    return (ret);
627 } /* end of SUnpkS16 */
628   
629 \f  
630 /*
631 *
632 *       Fun:   oduPackUInt16
633 *
634 *       Desc:  This function unpacks an unsigned 16 bit value from a message.
635 *
636 *       Ret:   ROK      - ok
637 *
638 *       Notes: None
639 *
640 *       File:  ss_pack.c
641 *
642 */
643   
644 #ifdef ANSI
645 S16 oduPackUInt16
646 (
647 uint16_t *val,                   /* pointer to value */
648 Buffer *mBuf                /* message buffer */
649 )
650 #else
651 S16 oduPackUInt16(val, mBuf)
652 uint16_t *val;                   /* pointer to value */
653 Buffer *mBuf;               /* message buffer */
654 #endif
655 {
656    uint16_t tmp16;               /* temporary value */
657    Data unpkArray[2];       /* unpacking array */
658    S16 ret;                 /* return code */
659
660 /* ss021.103 - Addition of data pointer check */
661 #if (ERRCLASS & ERRCLS_INT_PAR)
662    /* check data pointer */
663    if (!val)
664    {
665       SSLOGERROR(ERRCLS_INT_PAR, ESS256, ERRZERO, "oduPackUInt16 : Null value");
666       return RFAILED;
667    }
668 #endif /* ERRCLASS & ERRCLS_INT_PAR */
669
670    ret = SRemPreMsgMult(unpkArray, (MsgLen) 2, mBuf);
671 #if (ERRCLASS & ERRCLS_DEBUG)
672    if (ret != ROK)
673       SSLOGERROR(ERRCLS_DEBUG, ESS257, (ErrVal)ret, "SRemPreMsgMult failed");
674 #endif
675    tmp16 = 0; 
676 #ifndef FCSPKINT            /* backward compatibility, packing order */
677    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[1]);
678    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[0]);
679 #else                       /* forward compatibility, packing order */
680    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[0]);
681    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[1]);
682 #endif
683    *val = tmp16;
684    return (ret);
685 } /* end of oduPackUInt16 */
686   
687 \f  
688 /*
689 *
690 *       Fun:   SUnpkS32
691 *
692 *       Desc:  This function unpacks a signed 32 bit value from a message.
693 *
694 *       Ret:   ROK      - ok
695 *
696 *       Notes: None
697 *
698 *       File:  ss_pack.c
699 *
700 */
701   
702 #ifdef ANSI
703 S16 SUnpkS32
704 (
705 S32 *val,                   /* pointer to value */
706 Buffer *mBuf                /* message buffer */
707 )
708 #else
709 S16 SUnpkS32(val, mBuf)
710 S32 *val;                   /* pointer to value */
711 Buffer *mBuf;               /* message buffer */
712 #endif
713 {
714    uint16_t tmp16;               /* temporary value */
715    uint32_t tmp32;               /* temporary value */
716    Data unpkArray[4];       /* unpacking array */
717    S16 ret;                 /* return code */
718
719 /* ss021.103 - Addition of data pointer check */
720 #if (ERRCLASS & ERRCLS_INT_PAR)
721    /* check data pointer */
722    if (!val)
723    {
724       SSLOGERROR(ERRCLS_INT_PAR, ESS258, ERRZERO, "SUnpkS32 : Null value");
725       return RFAILED;
726    }
727 #endif /* ERRCLASS & ERRCLS_INT_PAR */
728
729    ret = SRemPreMsgMult(unpkArray, (MsgLen) 4, mBuf);
730 #if (ERRCLASS & ERRCLS_DEBUG)
731    if (ret != ROK)
732       SSLOGERROR(ERRCLS_DEBUG, ESS259, (ErrVal)ret, "SRemPreMsgMult() failed");
733 #endif
734    tmp16 = 0;
735    tmp32 = 0; 
736 #ifndef FCSPKINT            /* backward compatibility, packing order */
737    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[3]);
738    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[2]);
739    tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
740    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[1]);
741    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[0]);
742    tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
743 #else                       /* forward compatibility, packing order */
744    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[0]);
745    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[1]);
746    tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
747    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[2]);
748    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[3]);
749    tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
750 #endif
751    *val = (S32) tmp32;
752    return (ret);
753 } /* end of SUnpkS32 */
754   
755 \f  
756 /*
757 *
758 *       Fun:   oduPackUInt32
759 *
760 *       Desc:  This function unpacks an unsigned 32 bit value from a message.
761 *
762 *       Ret:   ROK      - ok
763 *
764 *       Notes: None
765 *
766 *       File:  ss_pack.c
767 *
768 */
769   
770 #ifdef ANSI
771 S16 oduPackUInt32
772 (
773 uint32_t *val,                   /* pointer to value */
774 Buffer *mBuf                /* message buffer */
775 )
776 #else
777 S16 oduPackUInt32(val, mBuf)
778 uint32_t *val;                   /* pointer to value */
779 Buffer *mBuf;               /* message buffer */
780 #endif
781 {
782    uint16_t tmp16;               /* temporary value */
783    uint32_t tmp32;               /* temporary value */
784    Data unpkArray[4];       /* unpacking array */
785 #ifdef ERRCLASS
786    S16 ret;                 /* return code */
787 #endif /* ERRCLASS */
788
789 /* ss021.103 - Addition of data pointer check */
790 #if (ERRCLASS & ERRCLS_INT_PAR)
791    /* check data pointer */
792    if (!val)
793    {
794       SSLOGERROR(ERRCLS_INT_PAR, ESS260, ERRZERO, "oduPackUInt32 : Null value");
795       return RFAILED;
796    }
797 #endif /* ERRCLASS & ERRCLS_INT_PAR */
798
799    ret = SRemPreMsgMult(unpkArray, (MsgLen) 4, mBuf);
800 #if (ERRCLASS & ERRCLS_DEBUG)
801    if (ret != ROK)
802       SSLOGERROR(ERRCLS_DEBUG, ESS261, (ErrVal)ret, "SRemPreMsgMult() failed");
803 #endif
804
805    tmp16 = 0;
806    tmp32 = 0; 
807 #ifndef FCSPKINT            /* backward compatibility, packing order */
808    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[3]);
809    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[2]);
810    tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
811    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[1]);
812    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[0]);
813    tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
814 #else                       /* forward compatibility, packing order */
815    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[0]);
816    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[1]);
817    tmp32 = (uint32_t) PutHiWord(tmp32, (uint16_t) tmp16);
818    tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) unpkArray[2]);
819    tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) unpkArray[3]);
820    tmp32 = (uint32_t) PutLoWord(tmp32, (uint16_t) tmp16);
821 #endif
822    *val = tmp32;
823    return (ret);
824 } /* end of oduPackUInt32 */
825
826 /*ss038.103  1. Added Floating point support*/
827 #ifdef SS_FLOAT
828 /*
829 *
830 *       Fun:   SUnpkF32
831 *
832 *       Desc:  This function unpacks an 32 bit ieee-754 format float value from a message.
833 *
834 *       Ret:   ROK      - ok
835 *
836 *       Notes: None
837 *
838 *       File:  ss_pack.c
839 *
840 */
841   
842 #ifdef ANSI
843 S16 SUnpkF32
844 (
845 F32 *val,                   /* pointer to value */
846 Buffer *mBuf                /* message buffer */
847 )
848 #else
849 S16 SUnpkF32(val, mBuf)
850 F32 *val;                   /* pointer to value */
851 Buffer *mBuf;               /* message buffer */
852 #endif
853 {
854    S16 ret;                 /* return code */
855    S8 tmpArray[15];         /* temporary array */
856 #ifndef FCSPKINT            /* backward compatibility, packing order */
857    S32 tIdx = 14;           /* temparory array index */
858    S32 kIdx = 0;            /* unpacking array index */
859    S8 unpkArray[15];        /* unpacking array */
860 #endif /* FCSPKINT */
861
862 #if (ERRCLASS & ERRCLS_INT_PAR)
863    /* check data pointer */
864    if (!val)
865    {
866       SSLOGERROR(ERRCLS_INT_PAR, ESS262, ERRZERO, "SUnpkF32 : Null value");
867       return RFAILED;
868    }
869 #endif /* ERRCLASS & ERRCLS_INT_PAR */
870
871    ret = SRemPreMsgMult((Data*)tmpArray, (MsgLen) 15, mBuf);
872 #if (ERRCLASS & ERRCLS_DEBUG)
873    if (ret != ROK)
874       SSLOGERROR(ERRCLS_DEBUG, ESS263, (ErrVal)ret, "SRemPreMsgMult() failed");
875 #endif
876
877 #ifndef FCSPKINT            /* backward compatibility, packing order */
878    while(tIdx >= 0)
879    {
880       unpkArray[kIdx] = tmpArray[tIdx];
881       tIdx--; kIdx++;
882    }
883    sscanf(unpkArray, "%f", val);
884 #else
885    sscanf(tmpArray, "%f", val);
886 #endif
887
888    return (ret);
889
890 } /* end of SUnpkF32 */
891
892 /*
893 *
894 *       Fun:   SUnpkF64
895 *
896 *       Desc:  This function unpacks an 64 bit ieee-754 format float value from a message.
897 *
898 *       Ret:   ROK      - ok
899 *
900 *       Notes: None
901 *
902 *       File:  ss_pack.c
903 *
904 */
905   
906 #ifdef ANSI
907 S16 SUnpkF64
908 (
909 F64 *val,                   /* pointer to value */
910 Buffer *mBuf                /* message buffer */
911 )
912 #else
913 S16 SUnpkF64(val, mBuf)
914 F64 *val;                   /* pointer to value */
915 Buffer *mBuf;               /* message buffer */
916 #endif
917 {
918
919    S16 ret;                 /* return code */
920    S8 tmpArray[25];         /* temporary array */
921 #ifndef FCSPKINT            /* backward compatibility, packing order */
922    S32 tIdx = 24;           /* temparory array index */
923    S32 kIdx = 0;            /* unpacking array index */
924    S8 unpkArray[25];        /* unpacking array */
925 #endif /* FCSPKINT */
926
927 #if (ERRCLASS & ERRCLS_INT_PAR)
928    /* check data pointer */
929    if (!val)
930    {
931       SSLOGERROR(ERRCLS_INT_PAR, ESS264, ERRZERO, "SUnpkF64 : Null value");
932       return RFAILED;
933    }
934 #endif /* ERRCLASS & ERRCLS_INT_PAR */
935
936    ret = SRemPreMsgMult((Data*)tmpArray, (MsgLen) 25, mBuf);
937 #if (ERRCLASS & ERRCLS_DEBUG)
938    if (ret != ROK)
939       SSLOGERROR(ERRCLS_DEBUG, ESS265, (ErrVal)ret, "SRemPreMsgMult() failed");
940 #endif
941
942 #ifndef FCSPKINT            /* backward compatibility, packing order */
943    while(tIdx >= 0)
944    {
945       unpkArray[kIdx] = tmpArray[tIdx];
946       tIdx--; kIdx++;
947    }
948    sscanf(unpkArray, "%lf", val);
949 #else
950    sscanf(tmpArray, "%lf", val);
951 #endif
952
953    return (ret);
954
955 } /* end of SUnpkF64 */
956 #endif /* SS_FLOAT */
957 \f
958 /**********************************************************************
959          End of file
960  **********************************************************************/