A661_INTERNAL int a661_com_A661_REQ_CURSOR_ON_WIDGET(buffer_el msg[], a661_ushort widget_ident
                                                     , a661_ulong oem_data_field) 
{
  a661_com_A661_CMD_UA_REQUEST_header(msg, 12);
  WRITE_USHORT(msg + 4, A661_REQ_CURSOR_ON_WIDGET);
  WRITE_USHORT(msg + 4 + 2, widget_ident);
  WRITE_ULONG(msg + 4 + 2 + 2, oem_data_field);
  return 12;
}
A661_INTERNAL int a661_com_msg_GpRectangle_A661_SIZE_X(buffer_el msg[], 
  a661_ushort pid,  a661_ulong A661_SIZE_X_SizeX_){
  int n3 = 0;
  int n2 = 0;
  int n1 = 0;
  PARAMETER("A661_SIZE_X");
  WRITE_USHORT(msg + 0, pid);
  WRITE_USHORT(msg + 2, 0);
  WRITE_ULONG(msg + 4, A661_SIZE_X_SizeX_);
  return 8 ;
}
A661_INTERNAL void WRITE_FLOAT(buffer_el msg[], float d) {
 WRITE_ULONG( (msg),* ( (unsigned long *) (&(d)) )  );
}
A661_INTERNAL int a661_com_layer_1(buffer_el msg[], 
  outC_OperationalScenario* scade_ctx,  extern_out_ctx_t * extern_ctx){
  int size = 0;
  int n16 = 0;
  int n15 = 0;
  int n14 = 0;
  int n13 = 0;
  int n12 = 0;
  int n11 = 0;
  int n10 = 0;
  int n9 = 0;
  int n8 = 0;
  int n7 = 0;
  int n6 = 0;
  int n5 = 0;
  int n4 = 0;
  int n3 = 0;
  int n2 = 0;
  int n1 = 0;
  int n0 = 0;
  if (scade_ctx->Emit2CDS ||
  scade_ctx->Layer1Active ||
  scade_ctx->Layer1Visible){
    LAYER("DF_TS02#1");
    n0 = 8 /*include block_size*/;
    a661_msg_cmd_header(msg, 1, DEFAULT_CONTEXT_NUMBER);
    if (scade_ctx->Emit2CDS){
      WIDGET("GpArcCircle_Ground#15");
      n1 = a661_com_csp_widget_GpArcCircle(msg + n0, 15, scade_ctx->Emit2CDS,
        scade_ctx->ColorIndex2);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("GpArcCircle_Launch#16");
      n2 = a661_com_csp_widget_GpArcCircle(msg + n0 + n1, 16,
        scade_ctx->Emit2CDS, scade_ctx->ColorIndex);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("GpArcCircle_Attitude#17");
      n3 = a661_com_csp_widget_GpArcCircle(msg + n0 + n1 + n2, 17,
        scade_ctx->Emit2CDS, scade_ctx->ColorIndex3);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("GpArcCircle_Normal#18");
      n4 = a661_com_csp_widget_GpArcCircle(msg + n0 + n1 + n2 + n3, 18,
        scade_ctx->Emit2CDS, scade_ctx->ColorIndex4);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("Ground_Label#22");
      n5 = a661_com_csp_widget_Label(msg + n0 + n1 + n2 + n3 + n4, 22,
        scade_ctx->Emit2CDS, scade_ctx->GroundVisible);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("Launch_Label#23");
      n6 = a661_com_csp_widget_Label(msg + n0 + n1 + n2 + n3 + n4 + n5, 23,
        scade_ctx->Emit2CDS, scade_ctx->LaunchVisible);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("AttitudeAcquisition_Label#24");
      n7 = a661_com_csp_widget_Label(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6, 24,
        scade_ctx->Emit2CDS, scade_ctx->AttitudeVisible);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("NormalPhase_Label#25");
      n8 = a661_com_csp_widget_Label(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7,
        25, scade_ctx->Emit2CDS, scade_ctx->NormalPhaseVisible);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("GpArcCircle_AtAcquired#27");
      n9 = a661_com_csp_widget_GpArcCircle(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8,
        27, scade_ctx->Emit2CDS, scade_ctx->ColorIndex5);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("AcRd_EditBoxNumeric#43");
      n10 = a661_com_csp_widget_EditBoxNumeric(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9,
        43, scade_ctx->Emit2CDS, scade_ctx->AcRdValue);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("FuelMeter_EditBoxNumeric#57");
      n11 = a661_com_csp_widget_EditBoxNumeric(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10,
        57, scade_ctx->Emit2CDS, scade_ctx->FuelMeter);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("Fuel#59");
      n12 = a661_com_csp_widget_GpRectangle(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + n11,
        59, scade_ctx->Emit2CDS, scade_ctx->FuelMeterGraphic);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("Longitude_EditBoxNumeric#70");
      n13 = a661_com_csp_widget_EditBoxNumeric(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + n11 + n12,
        70, scade_ctx->Emit2CDS, scade_ctx->SAT_Longitude_Value);
    }
    if (scade_ctx->Emit2CDS){
      WIDGET("Latitude_EditBoxNumeric#71");
      n14 = a661_com_csp_widget_EditBoxNumeric(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + n11 + n12 + n13,
        71, scade_ctx->Emit2CDS, scade_ctx->SAT_Latitude_Value);
    }
    if (scade_ctx->Layer1Active ||
    scade_ctx->Layer1Visible){
      n15 = a661_com_A661_CMD_UA_REQUEST_layer_1(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + n11 + n12 + n13 + n14,
        scade_ctx, extern_ctx);
    }
    n16 = 4;
    WRITE_ULONG(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + n11 + n12 + n13 + n14 + n15,
      A661_END_BLOCK);
    size = n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + n11 + n12 + n13 + n14 + n15 + n16;
    WRITE_ULONG(msg + 4, size);
  }
  return n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + n11 + n12 + n13 + n14 + n15 + n16 ;
}
A661_INTERNAL int write_fr32_with_real(buffer_el msg[],  const kcg_real val,  const int max )
{
   WRITE_ULONG(msg, real_to_fr( val, 32, max));   

   return 4;
}
Beispiel #6
0
A661_INTERNAL int a661_com_layer_1(buffer_el msg[],  outC_ts05* scade_ctx, 
  extern_out_ctx_t * extern_ctx){
  int size = 0;
  int n9 = 0;
  int n8 = 0;
  int n7 = 0;
  int n6 = 0;
  int n5 = 0;
  int n4 = 0;
  int n3 = 0;
  int n2 = 0;
  int n1 = 0;
  int n0 = 0;
  if (scade_ctx->CDS_Emit ||
  scade_ctx->CDS_Layer_Req_Active ||
  scade_ctx->CDS_Layer_Req_Visible){
    LAYER("ts05_layer#1");
    n0 = 8 /*include block_size*/;
    a661_msg_cmd_header(msg, 1, DEFAULT_CONTEXT_NUMBER);
    if (scade_ctx->CDS_Emit){
      WIDGET("Auto_Verify#1503");
      n1 = a661_com_csp_widget_GpArcEllipse(msg + n0, 1503, scade_ctx->CDS_Emit,
        scade_ctx->Test_Auto_Verify);
    }
    if (scade_ctx->CDS_Emit){
      WIDGET("Output#1513");
      n2 = a661_com_csp_widget_GpArcEllipse(msg + n0 + n1, 1513,
        scade_ctx->CDS_Emit, scade_ctx->TEST_SAT_GyroscopeState_Signal);
    }
    if (scade_ctx->CDS_Emit){
      WIDGET("Output#1523");
      n3 = a661_com_csp_widget_GpArcEllipse(msg + n0 + n1 + n2, 1523,
        scade_ctx->CDS_Emit, scade_ctx->TEST_SAT_HorizonSensorState_Signal);
    }
    if (scade_ctx->CDS_Emit){
      WIDGET("Output#1533");
      n4 = a661_com_csp_widget_GpArcEllipse(msg + n0 + n1 + n2 + n3, 1533,
        scade_ctx->CDS_Emit, scade_ctx->TEST_SAT_PropellersState_Signal);
    }
    if (scade_ctx->CDS_Emit){
      WIDGET("Output#1543");
      n5 = a661_com_csp_widget_GpArcEllipse(msg + n0 + n1 + n2 + n3 + n4, 1543,
        scade_ctx->CDS_Emit, scade_ctx->TEST_SAT_CameraState_Signal);
    }
    if (scade_ctx->CDS_Emit){
      WIDGET("PedidoEnviaFoto#5104");
      n6 = a661_com_csp_widget_GpArcEllipse(msg + n0 + n1 + n2 + n3 + n4 + n5,
        5104, scade_ctx->CDS_Emit, scade_ctx->display_picture_resquest_state);
    }
    if (scade_ctx->CDS_Emit){
      WIDGET("Initialize#7505");
      n7 = a661_com_csp_widget_GpArcEllipse(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6,
        7505, scade_ctx->CDS_Emit, scade_ctx->TEST_SAT_Initialize_Signal);
    }
    if (scade_ctx->CDS_Layer_Req_Active ||
    scade_ctx->CDS_Layer_Req_Visible){
      n8 = a661_com_A661_CMD_UA_REQUEST_layer_1(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7,
        scade_ctx, extern_ctx);
    }
    n9 = 4;
    WRITE_ULONG(msg + n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8,
      A661_END_BLOCK);
    size = n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9;
    WRITE_ULONG(msg + 4, size);
  }
  return n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 ;
}
Beispiel #7
0
  static FT_Error
  woff_open_font( FT_Stream  stream,
                  TT_Face    face )
  {
    FT_Memory       memory = stream->memory;
    FT_Error        error  = FT_Err_Ok;

    WOFF_HeaderRec  woff;
    WOFF_Table      tables  = NULL;
    WOFF_Table*     indices = NULL;

    FT_ULong        woff_offset;

    FT_Byte*        sfnt        = NULL;
    FT_Stream       sfnt_stream = NULL;

    FT_Byte*        sfnt_header;
    FT_ULong        sfnt_offset;

    FT_Int          nn;
    FT_ULong        old_tag = 0;

    static const FT_Frame_Field  woff_header_fields[] =
    {
#undef  FT_STRUCTURE
#define FT_STRUCTURE  WOFF_HeaderRec

      FT_FRAME_START( 44 ),
        FT_FRAME_ULONG ( signature ),
        FT_FRAME_ULONG ( flavor ),
        FT_FRAME_ULONG ( length ),
        FT_FRAME_USHORT( num_tables ),
        FT_FRAME_USHORT( reserved ),
        FT_FRAME_ULONG ( totalSfntSize ),
        FT_FRAME_USHORT( majorVersion ),
        FT_FRAME_USHORT( minorVersion ),
        FT_FRAME_ULONG ( metaOffset ),
        FT_FRAME_ULONG ( metaLength ),
        FT_FRAME_ULONG ( metaOrigLength ),
        FT_FRAME_ULONG ( privOffset ),
        FT_FRAME_ULONG ( privLength ),
      FT_FRAME_END
    };


    FT_ASSERT( stream == face->root.stream );
    FT_ASSERT( FT_STREAM_POS() == 0 );

    if ( FT_STREAM_READ_FIELDS( woff_header_fields, &woff ) )
      return error;

    /* Make sure we don't recurse back here or hit TTC code. */
    if ( woff.flavor == TTAG_wOFF || woff.flavor == TTAG_ttcf )
      return FT_THROW( Invalid_Table );

    /* Miscellaneous checks. */
    if ( woff.length != stream->size                              ||
         woff.num_tables == 0                                     ||
         44 + woff.num_tables * 20UL >= woff.length               ||
         12 + woff.num_tables * 16UL >= woff.totalSfntSize        ||
         ( woff.totalSfntSize & 3 ) != 0                          ||
         ( woff.metaOffset == 0 && ( woff.metaLength != 0     ||
                                     woff.metaOrigLength != 0 ) ) ||
         ( woff.metaLength != 0 && woff.metaOrigLength == 0 )     ||
         ( woff.privOffset == 0 && woff.privLength != 0 )         )
      return FT_THROW( Invalid_Table );

    if ( FT_ALLOC( sfnt, woff.totalSfntSize ) ||
         FT_NEW( sfnt_stream )                )
      goto Exit;

    sfnt_header = sfnt;

    /* Write sfnt header. */
    {
      FT_UInt  searchRange, entrySelector, rangeShift, x;


      x             = woff.num_tables;
      entrySelector = 0;
      while ( x )
      {
        x            >>= 1;
        entrySelector += 1;
      }
      entrySelector--;

      searchRange = ( 1 << entrySelector ) * 16;
      rangeShift  = woff.num_tables * 16 - searchRange;

      WRITE_ULONG ( sfnt_header, woff.flavor );
      WRITE_USHORT( sfnt_header, woff.num_tables );
      WRITE_USHORT( sfnt_header, searchRange );
      WRITE_USHORT( sfnt_header, entrySelector );
      WRITE_USHORT( sfnt_header, rangeShift );
    }

    /* While the entries in the sfnt header must be sorted by the */
    /* tag value, the tables themselves are not.  We thus have to */
    /* sort them by offset and check that they don't overlap.     */

    if ( FT_NEW_ARRAY( tables, woff.num_tables )  ||
         FT_NEW_ARRAY( indices, woff.num_tables ) )
      goto Exit;

    FT_TRACE2(( "\n"
                "  tag    offset    compLen  origLen  checksum\n"
                "  -------------------------------------------\n" ));

    if ( FT_FRAME_ENTER( 20L * woff.num_tables ) )
      goto Exit;

    for ( nn = 0; nn < woff.num_tables; nn++ )
    {
      WOFF_Table  table = tables + nn;

      table->Tag        = FT_GET_TAG4();
      table->Offset     = FT_GET_ULONG();
      table->CompLength = FT_GET_ULONG();
      table->OrigLength = FT_GET_ULONG();
      table->CheckSum   = FT_GET_ULONG();

      FT_TRACE2(( "  %c%c%c%c  %08lx  %08lx  %08lx  %08lx\n",
                  (FT_Char)( table->Tag >> 24 ),
                  (FT_Char)( table->Tag >> 16 ),
                  (FT_Char)( table->Tag >> 8  ),
                  (FT_Char)( table->Tag       ),
                  table->Offset,
                  table->CompLength,
                  table->OrigLength,
                  table->CheckSum ));

      if ( table->Tag <= old_tag )
      {
        FT_FRAME_EXIT();
        error = FT_THROW( Invalid_Table );
        goto Exit;
      }

      old_tag     = table->Tag;
      indices[nn] = table;
    }

    FT_FRAME_EXIT();

    /* Sort by offset. */

    ft_qsort( indices,
              woff.num_tables,
              sizeof ( WOFF_Table ),
              compare_offsets );

    /* Check offsets and lengths. */

    woff_offset = 44 + woff.num_tables * 20L;
    sfnt_offset = 12 + woff.num_tables * 16L;

    for ( nn = 0; nn < woff.num_tables; nn++ )
    {
      WOFF_Table  table = indices[nn];


      if ( table->Offset != woff_offset                         ||
           table->CompLength > woff.length                      ||
           table->Offset > woff.length - table->CompLength      ||
           table->OrigLength > woff.totalSfntSize               ||
           sfnt_offset > woff.totalSfntSize - table->OrigLength ||
           table->CompLength > table->OrigLength                )
      {
        error = FT_THROW( Invalid_Table );
        goto Exit;
      }

      table->OrigOffset = sfnt_offset;

      /* The offsets must be multiples of 4. */
      woff_offset += ( table->CompLength + 3 ) & ~3U;
      sfnt_offset += ( table->OrigLength + 3 ) & ~3U;
    }

    /*
     * Final checks!
     *
     * We don't decode and check the metadata block.
     * We don't check table checksums either.
     * But other than those, I think we implement all
     * `MUST' checks from the spec.
     */

    if ( woff.metaOffset )
    {
      if ( woff.metaOffset != woff_offset                  ||
           woff.metaOffset + woff.metaLength > woff.length )
      {
        error = FT_THROW( Invalid_Table );
        goto Exit;
      }

      /* We have padding only ... */
      woff_offset += woff.metaLength;
    }

    if ( woff.privOffset )
    {
      /* ... if it isn't the last block. */
      woff_offset = ( woff_offset + 3 ) & ~3U;

      if ( woff.privOffset != woff_offset                  ||
           woff.privOffset + woff.privLength > woff.length )
      {
        error = FT_THROW( Invalid_Table );
        goto Exit;
      }

      /* No padding for the last block. */
      woff_offset += woff.privLength;
    }

    if ( sfnt_offset != woff.totalSfntSize ||
         woff_offset != woff.length        )
    {
      error = FT_THROW( Invalid_Table );
      goto Exit;
    }

    /* Write the tables. */

    for ( nn = 0; nn < woff.num_tables; nn++ )
    {
      WOFF_Table  table = tables + nn;


      /* Write SFNT table entry. */
      WRITE_ULONG( sfnt_header, table->Tag );
      WRITE_ULONG( sfnt_header, table->CheckSum );
      WRITE_ULONG( sfnt_header, table->OrigOffset );
      WRITE_ULONG( sfnt_header, table->OrigLength );

      /* Write table data. */
      if ( FT_STREAM_SEEK( table->Offset )     ||
           FT_FRAME_ENTER( table->CompLength ) )
        goto Exit;

      if ( table->CompLength == table->OrigLength )
      {
        /* Uncompressed data; just copy. */
        ft_memcpy( sfnt + table->OrigOffset,
                   stream->cursor,
                   table->OrigLength );
      }
      else
      {
#ifdef FT_CONFIG_OPTION_USE_ZLIB

        /* Uncompress with zlib. */
        FT_ULong  output_len = table->OrigLength;


        error = FT_Gzip_Uncompress( memory,
                                    sfnt + table->OrigOffset, &output_len,
                                    stream->cursor, table->CompLength );
        if ( error )
          goto Exit;
        if ( output_len != table->OrigLength )
        {
          error = FT_THROW( Invalid_Table );
          goto Exit;
        }

#else /* !FT_CONFIG_OPTION_USE_ZLIB */

        error = FT_THROW( Unimplemented_Feature );
        goto Exit;

#endif /* !FT_CONFIG_OPTION_USE_ZLIB */
      }

      FT_FRAME_EXIT();

      /* We don't check whether the padding bytes in the WOFF file are     */
      /* actually '\0'.  For the output, however, we do set them properly. */
      sfnt_offset = table->OrigOffset + table->OrigLength;
      while ( sfnt_offset & 3 )
      {
        sfnt[sfnt_offset] = '\0';
        sfnt_offset++;
      }
    }

    /* Ok!  Finally ready.  Swap out stream and return. */
    FT_Stream_OpenMemory( sfnt_stream, sfnt, woff.totalSfntSize );
    sfnt_stream->memory = stream->memory;
    sfnt_stream->close  = sfnt_stream_close;

    FT_Stream_Free(
      face->root.stream,
      ( face->root.face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 );

    face->root.stream = sfnt_stream;

    face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;

  Exit:
    FT_FREE( tables );
    FT_FREE( indices );

    if ( error )
    {
      FT_FREE( sfnt );
      FT_Stream_Close( sfnt_stream );
      FT_FREE( sfnt_stream );
    }

    return error;
  }