?? ss_pack.c
字號(hào):
/********************************************************************20**
Name: System Services -- packing
Type: C source file
Desc: Source code for System Services packing functions.
File: ss_pack.c
Sid: ss_pack.c 1.2 - 08/10/98 18:43:22
Prg: kp
*********************************************************************21*/
/* header include files (.h) */
#include "envopt.h" /* environment options */
#include "envdep.h" /* environment dependent */
#include "envind.h" /* environment independent */
#include "gen.h" /* general layer */
#include "ssi.h" /* system services */
#include "ss_err.h" /* errors */
#include "ss_dep.h" /* implementation-specific */
#include "ss_queue.h" /* queues */
#include "ss_msg.h" /* messaging */
#include "ss_mem.h" /* memory management interface */
#include "ss_gen.h" /* general */
/* header/extern include files (.x) */
#include "gen.x" /* general layer */
#include "ssi.x" /* system services */
#include "ss_dep.x" /* implementation-specific */
#include "ss_queue.x" /* queues */
#include "ss_task.x" /* tasking */
#include "ss_timer.x" /* timers */
#include "ss_strm.x" /* STREAMS */
#include "ss_msg.x" /* messaging */
#include "ss_mem.x" /* memory management interface */
#include "ss_drvr.x" /* driver tasks */
#include "ss_gen.x" /* general */
/*
*
* Fun: SPkS8
*
* Desc: This function packs a signed 8 bit value into a message.
*
* Ret: ROK - ok
* RFAILED - failed, general (optional)
* ROUTRES - failed, out of resources (optional)
*
* Notes: None
*
* File: ss_pack.c
*
*/
#ifdef ANSI
PUBLIC S16 SPkS8
(
S8 val, /* value */
Buffer *mBuf /* message buffer */
)
#else
PUBLIC S16 SPkS8(val, mBuf)
S8 val; /* value */
Buffer *mBuf; /* message buffer */
#endif
{
S16 ret; /* return code */
TRC1(SPkS8)
ret = SAddPreMsg((Data) val, mBuf);
#if (ERRCLASS & ERRCLS_ADD_RES)
if (ret != ROK)
SSLOGERROR(ERRCLS_ADD_RES, ESS368, (ErrVal)ret, "SAddPreMsg() failed");
#endif
RETVALUE(ret);
} /* end of SPkS8 */
/*
*
* Fun: SPkU8
*
* Desc: This function packs an unsigned 8 bit value into a message.
*
* Ret: ROK - ok
* RFAILED - failed, general (optional)
* ROUTRES - failed, out of resources (optional)
*
* Notes: None
*
* File: ss_pack.c
*
*/
#ifdef ANSI
PUBLIC S16 SPkU8
(
U8 val, /* value */
Buffer *mBuf /* message buffer */
)
#else
PUBLIC S16 SPkU8(val, mBuf)
U8 val; /* value */
Buffer *mBuf; /* message buffer */
#endif
{
S16 ret; /* return code */
TRC1(SPkU8)
ret = SAddPreMsg((Data) val, mBuf);
#if (ERRCLASS & ERRCLS_ADD_RES)
if (ret != ROK)
SSLOGERROR(ERRCLS_ADD_RES, ESS369, (ErrVal)ret, "SAddPreMsg() failed");
#endif
RETVALUE(ret);
} /* end of SPkU8 */
/*
*
* Fun: SPkS16
*
* Desc: This function packs a signed 16 bit value into a message.
*
* Ret: ROK - ok
* RFAILED - failed, general (optional)
* ROUTRES - failed, out of resources (optional)
*
* Notes: None
*
* File: ss_pack.c
*
*/
#ifdef ANSI
PUBLIC S16 SPkS16
(
S16 val, /* value */
Buffer *mBuf /* message buffer */
)
#else
PUBLIC S16 SPkS16(val, mBuf)
S16 val; /* value */
Buffer *mBuf; /* message buffer */
#endif
{
Data pkArray[2]; /* array for packing */
S16 ret; /* return code */
TRC1(SPkS16)
#ifndef FCSPKINT /* backward compatibility, packing order */
pkArray[0] = (Data) GetHiByte(val);
pkArray[1] = (Data) GetLoByte(val);
#else /* forward compatibility, packing order */
pkArray[1] = (Data) GetHiByte(val);
pkArray[0] = (Data) GetLoByte(val);
#endif
ret = SAddPreMsgMult(pkArray, (MsgLen) 2, mBuf);
#if (ERRCLASS & ERRCLS_ADD_RES)
if (ret != ROK)
SSLOGERROR(ERRCLS_ADD_RES, ESS370, (ErrVal)ret, "SAddPreMsgMult() failed");
#endif
RETVALUE(ret);
} /* end of SPkS16 */
/*
*
* Fun: SPkU16
*
* Desc: This function packs an unsigned 16 bit value into a message.
*
* Ret: ROK - ok
* RFAILED - failed, general (optional)
* ROUTRES - failed, out of resources (optional)
*
* Notes: None
*
* File: ss_pack.c
*
*/
#ifdef ANSI
PUBLIC S16 SPkU16
(
U16 val, /* value */
Buffer *mBuf /* message buffer */
)
#else
PUBLIC S16 SPkU16(val, mBuf)
U16 val; /* value */
Buffer *mBuf; /* message buffer */
#endif
{
Data pkArray[2]; /* array for packing */
S16 ret; /* return code */
TRC1(SPkU16)
#ifndef FCSPKINT /* backward compatibility, packing order */
pkArray[0] = (Data) GetHiByte(val);
pkArray[1] = (Data) GetLoByte(val);
#else /* forward compatibility, packing order */
pkArray[1] = (Data) GetHiByte(val);
pkArray[0] = (Data) GetLoByte(val);
#endif
ret = SAddPreMsgMult(pkArray, (MsgLen) 2, mBuf);
#if (ERRCLASS & ERRCLS_ADD_RES)
if (ret != ROK)
SSLOGERROR(ERRCLS_ADD_RES, ESS371, (ErrVal)ret, "SAddPreMsgMult() failed");
#endif
RETVALUE(ret);
} /* end of SPkU16 */
/*
*
* Fun: SPkS32
*
* Desc: This function packs a signed 32 bit value into a message.
*
* Ret: ROK - ok
* RFAILED - failed, general (optional)
* ROUTRES - failed, out of resources (optional)
*
* Notes: None
*
* File: ss_pack.c
*
*/
#ifdef ANSI
PUBLIC S16 SPkS32
(
S32 val, /* value */
Buffer *mBuf /* message buffer */
)
#else
PUBLIC S16 SPkS32(val, mBuf)
S32 val; /* value */
Buffer *mBuf; /* message buffer */
#endif
{
U16 tmp; /* temporary value */
Data pkArray[4]; /* packing array */
S16 ret; /* return code */
TRC1(SPkS32)
#ifndef FCSPKINT /* backward compatibility, packing order */
tmp = (U16) GetHiWord(val);
pkArray[0] = (Data) GetHiByte(tmp);
pkArray[1] = (Data) GetLoByte(tmp);
tmp = (U16) GetLoWord(val);
pkArray[2] = (Data) GetHiByte(tmp);
pkArray[3] = (Data) GetLoByte(tmp);
#else /* forward compatibility, packing order */
tmp = (U16) GetHiWord(val);
pkArray[3] = (Data) GetHiByte(tmp);
pkArray[2] = (Data) GetLoByte(tmp);
tmp = (U16) GetLoWord(val);
pkArray[1] = (Data) GetHiByte(tmp);
pkArray[0] = (Data) GetLoByte(tmp);
#endif
ret = SAddPreMsgMult(pkArray, (MsgLen) 4, mBuf);
#if (ERRCLASS & ERRCLS_ADD_RES)
if (ret != ROK)
SSLOGERROR(ERRCLS_ADD_RES, ESS372, (ErrVal)ret, "SAddPreMsgMult() failed");
#endif
RETVALUE(ret);
} /* end of SPkS32 */
/*
*
* Fun: SPkU32
*
* Desc: This function packs an unsigned 32 bit value into a message.
*
* Ret: ROK - ok
* RFAILED - failed, general (optional)
* ROUTRES - failed, out of resources (optional)
*
* Notes: None
*
* File: ss_pack.c
*
*/
#ifdef ANSI
PUBLIC S16 SPkU32
(
U32 val, /* value */
Buffer *mBuf /* message buffer */
)
#else
PUBLIC S16 SPkU32(val, mBuf)
U32 val; /* value */
Buffer *mBuf; /* message buffer */
#endif
{
U16 tmp; /* temporary value */
Data pkArray[4]; /* packing array */
S16 ret; /* return code */
TRC1(SPkU32)
#ifndef FCSPKINT /* backward compatibility, packing order */
tmp = (U16) GetHiWord(val);
pkArray[0] = (Data) GetHiByte(tmp);
pkArray[1] = (Data) GetLoByte(tmp);
tmp = (U16) GetLoWord(val);
pkArray[2] = (Data) GetHiByte(tmp);
pkArray[3] = (Data) GetLoByte(tmp);
#else /* forward compatibility, packing order */
tmp = (U16) GetHiWord(val);
pkArray[3] = (Data) GetHiByte(tmp);
pkArray[2] = (Data) GetLoByte(tmp);
tmp = (U16) GetLoWord(val);
pkArray[1] = (Data) GetHiByte(tmp);
pkArray[0] = (Data) GetLoByte(tmp);
#endif
ret = SAddPreMsgMult(pkArray, (MsgLen) 4, mBuf);
#if (ERRCLASS & ERRCLS_ADD_RES)
if (ret != ROK)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -