Exemplo n.º 1
0
FudgeStatus FudgeCodec_decodeFieldTime ( const fudge_byte * bytes, const fudge_i32 width, FudgeFieldData * data )
{
    FudgeTime * time = &( data->datetime.time );
    const fudge_i32 hiword = FudgeCodec_decodeI32 ( bytes );
    const fudge_i32 loword = FudgeCodec_decodeI32 ( bytes + sizeof ( fudge_i32 ) );
    int timezone;

    timezone = ( hiword ) >> 24;
    time->hasTimezone = ( timezone != -128 );
    time->timezoneOffset = time->hasTimezone ? timezone : 0;

    time->precision = ( hiword >> 20 ) & 0xf;
    time->seconds = hiword & 0x1ffff;
    time->nanoseconds = loword & 0x3fffffff;
    return FUDGE_OK;
}
Exemplo n.º 2
0
FudgeStatus FudgeCodec_decodeFieldAddressDetails ( const fudge_byte * bytes,
        const fudge_i32 width,
        FudgeFieldData * data )
{
    AddressDetails * details;

    /* Make sure that field is of the expected size */
    if ( width != sizeof ( AddressDetails ) )
        return FUDGE_OUT_OF_BYTES;

    /* Allocate the target structure and point the data structure's byte
       pointer at it. This memory will be owned by the parent FudgeMsg. */
    if ( ! ( details = ( AddressDetails * ) malloc ( width ) ) )
        return FUDGE_OUT_OF_MEMORY;
    data->bytes = ( const fudge_byte * ) details;

    /* Decode and copy in the integer values, advancing the source bytes
       pointer after each one */
    details->status = ( AddressStatus ) FudgeCodec_decodeI32 ( bytes );
    bytes += sizeof ( fudge_i32 );
    details->house_number = FudgeCodec_decodeI16 ( bytes );
    bytes += sizeof ( fudge_i16 );

    /* Copy in the string components and advance the source bytes pointer */
    memcpy ( details->street_name, bytes, ADDRESSDETAILS_NAME_FIELD_LEN );
    bytes += ADDRESSDETAILS_NAME_FIELD_LEN;
    memcpy ( details->city, bytes, ADDRESSDETAILS_CITY_FIELD_LEN );
    bytes += ADDRESSDETAILS_CITY_FIELD_LEN;
    memcpy ( details->postal_code, bytes, ADDRESSDETAILS_POST_FIELD_LEN );
    bytes += ADDRESSDETAILS_POST_FIELD_LEN;

    return FUDGE_OK;
}
Exemplo n.º 3
0
FudgeStatus FudgeCodec_decodeFieldDate ( const fudge_byte * bytes, const fudge_i32 width, FudgeFieldData * data )
{
    FudgeDate * date = &( data->datetime.date );
    const fudge_i32 value = FudgeCodec_decodeI32 ( bytes );

    date->year = value >> 9;
    date->month = ( value >> 5 ) & 0xf;
    date->day = value & 0x1f;
    return FUDGE_OK;
}