Пример #1
0
bool
gcd_put_ucs2( GCD_RCB **rcb_ptr, u_i2 length, u_i1 *ptr )
{
    GCD_RCB	*rcb = *rcb_ptr;
    u_i2	len;

    if ( ! rcb )  return( FALSE );

    length *= sizeof( UCS2 );	/* convert array length to byte length */

    while( length )
    {
	if ( RCB_AVAIL( rcb ) < CV_N_I2_SZ )
	    if ( ! gcd_msg_split( rcb_ptr ) )  
		return( FALSE );
	    else
		rcb = *rcb_ptr;

	for( 
	     len = min( length, RCB_AVAIL( rcb ) );
	     len >= sizeof( UCS2 ); 
	     len -= sizeof( UCS2 ) 
	   )
	{
	    STATUS status;

	    CV2N_I2_MACRO( ptr, &rcb->buf_ptr[ rcb->buf_len ], &status );
	    rcb->buf_len += CV_N_I2_SZ;
	    ptr += sizeof( UCS2 );
	    length -= sizeof( UCS2 );
	}
    }

    return( TRUE );
}
Пример #2
0
bool
gcd_put_i2p( GCD_RCB **rcb_ptr, u_i1 *val )
{
    GCD_RCB	*rcb = *rcb_ptr;
    STATUS	status;

    if ( ! rcb )  return( FALSE );

    if ( CV_N_I2_SZ > RCB_AVAIL( rcb ) )  
	if ( ! gcd_msg_split( rcb_ptr ) )  
	    return( FALSE );
	else
	    rcb = *rcb_ptr;

    CV2N_I2_MACRO( val, &rcb->buf_ptr[ rcb->buf_len ], &status );
    rcb->buf_len += CV_N_I2_SZ;

    return( TRUE );
}
Пример #3
0
static void
build_hdr( GCD_RCB *rcb, DAM_TL_HDR *hdr )
{
    STATUS	status;

    /*
    ** Caller is required to provide room prior to
    ** data for TL header, so reserve that space.
    */
    rcb->buf_ptr -= DAM_TL_HDR_SZ;
    rcb->buf_len += DAM_TL_HDR_SZ;

    /*
    ** Now build the header in space reserved.
    */
    CV2N_I4_MACRO( &hdr->tl_id, rcb->buf_ptr, &status );
    CV2N_I2_MACRO( &hdr->msg_id, &rcb->buf_ptr[ CV_N_I4_SZ ], &status );

    return;
}
Пример #4
0
static void
build_cc_parms( GCD_RCB *rcb, u_i1 size, u_i1 *msg_param, u_i2 msg_len )
{
    GCD_CCB		*ccb = rcb->ccb;
    DAM_TL_PARAM	param;
    STATUS		status;

    /*
    ** TL Protocol Level
    */
    param.param_id = DAM_TL_CP_PROTO;
    CV2N_I1_MACRO( &param.param_id, &rcb->buf_ptr[ rcb->buf_len ], &status );
    rcb->buf_len += CV_N_I1_SZ;

    param.pl1 = 1;
    CV2N_I1_MACRO( &param.pl1, &rcb->buf_ptr[ rcb->buf_len ], &status );
    rcb->buf_len += CV_N_I1_SZ;

    CV2N_I1_MACRO( &ccb->tl.proto_lvl, &rcb->buf_ptr[rcb->buf_len], &status );
    rcb->buf_len += CV_N_I1_SZ;

    /*
    ** Packet Buffer Size
    */
    param.param_id = DAM_TL_CP_SIZE;
    CV2N_I1_MACRO( &param.param_id, &rcb->buf_ptr[ rcb->buf_len ], &status );
    rcb->buf_len += CV_N_I1_SZ;

    param.pl1 = 1;
    CV2N_I1_MACRO( &param.pl1, &rcb->buf_ptr[ rcb->buf_len ], &status );
    rcb->buf_len += CV_N_I1_SZ;

    CV2N_I1_MACRO( &size, &rcb->buf_ptr[ rcb->buf_len ], &status );
    rcb->buf_len += CV_N_I1_SZ;

    /*
    ** Character Set
    */
    if ( GCD_global.charset_id  &&  ccb->tl.proto_lvl >= DAM_TL_PROTO_2 )
    {
	param.param_id = DAM_TL_CP_CHRSET_ID;
	CV2N_I1_MACRO( &param.param_id, &rcb->buf_ptr[rcb->buf_len], &status );
	rcb->buf_len += CV_N_I1_SZ;

	param.pl1 = 4;
	CV2N_I1_MACRO( &param.pl1, &rcb->buf_ptr[ rcb->buf_len ], &status );
	rcb->buf_len += CV_N_I1_SZ;

	CV2N_I4_MACRO( &GCD_global.charset_id,
			&rcb->buf_ptr[ rcb->buf_len ], &status );
	rcb->buf_len += CV_N_I4_SZ;
    }

    if ( GCD_global.charset  &&  *GCD_global.charset )
    {
	param.param_id = DAM_TL_CP_CHRSET;
	CV2N_I1_MACRO( &param.param_id, &rcb->buf_ptr[rcb->buf_len], &status );
	rcb->buf_len += CV_N_I1_SZ;

	param.pl1 = STlength( GCD_global.charset );
	CV2N_I1_MACRO( &param.pl1, &rcb->buf_ptr[ rcb->buf_len ], &status );
	rcb->buf_len += CV_N_I1_SZ;

	MEcopy( (PTR)GCD_global.charset, param.pl1,
		(PTR)&rcb->buf_ptr[ rcb->buf_len ] );
	rcb->buf_len += param.pl1;
    }

    /*
    ** Message Layer Info
    */
    if ( msg_len > 0  &&  msg_param )
    {
	/*
	** Send our MSG layer ID to identify the
	** parameters info to follow.
	*/
	if ( ccb->tl.proto_lvl >= DAM_TL_PROTO_2 )
	{
	    u_i4 ml_id = DAM_TL_DMML_ID;

	    param.param_id = DAM_TL_CP_MSG_ID;
	    CV2N_I1_MACRO(&param.param_id,&rcb->buf_ptr[rcb->buf_len],&status);
	    rcb->buf_len += CV_N_I1_SZ;

	    param.pl1 = 4;
	    CV2N_I1_MACRO( &param.pl1, &rcb->buf_ptr[ rcb->buf_len ], &status );
	    rcb->buf_len += CV_N_I1_SZ;

	    CV2N_I4_MACRO( &ml_id, &rcb->buf_ptr[ rcb->buf_len ], &status );
	    rcb->buf_len += CV_N_I4_SZ;
	}

	param.param_id = DAM_TL_CP_MSG;
	CV2N_I1_MACRO( &param.param_id, &rcb->buf_ptr[rcb->buf_len], &status );
	rcb->buf_len += CV_N_I1_SZ;

	if ( msg_len < 255 )
	{
	    param.pl1 = msg_len;
	    CV2N_I1_MACRO( &param.pl1, &rcb->buf_ptr[rcb->buf_len], &status );
	    rcb->buf_len += CV_N_I1_SZ;
	}
	else
	{
	    param.pl1 = 255;
	    CV2N_I1_MACRO( &param.pl1, &rcb->buf_ptr[rcb->buf_len], &status );
	    rcb->buf_len += CV_N_I1_SZ;

	    param.pl2 = msg_len;
	    CV2N_I2_MACRO( &param.pl1, &rcb->buf_ptr[rcb->buf_len], &status );
	    rcb->buf_len += CV_N_I2_SZ;
	}

	MEcopy( (PTR)msg_param, msg_len, (PTR)&rcb->buf_ptr[ rcb->buf_len ] );
	rcb->buf_len += msg_len;
    }

    return;
}