static void
vlc_player_load_media(GtkVlcPlayer *player, libvlc_media_t *media)
{
	libvlc_media_parse(media);
	libvlc_media_player_set_media(player->priv->media_player, media);

	/* NOTE: media was parsed so get_duration works */
	update_length(player, (gint64)libvlc_media_get_duration(media));
	update_time(player, 0);
}
static void
vlc_length_changed(const struct libvlc_event_t *event, void *user_data)
{
	assert(event->type == libvlc_MediaPlayerLengthChanged);

	/* VLC callbacks may be invoked from another thread! */
	maybe_lock_gdk();
	update_length(GTK_VLC_PLAYER(user_data),
		      (gint64)event->u.media_player_length_changed.new_length);
	maybe_unlock_gdk();
}
Beispiel #3
0
/// @brief Insert a TLV after the last occurance of a another TLV.
/// Used to add mandatory TLVs (broadcast_sm) in order listed in spec.
/// @param tlv The TLV to add.
/// @param tag The id of the previous tlv.
void
Smpp::Header::insert_after_tlv(const Tlv* tlv, Smpp::Uint16 tag)
{
    TlvList::reverse_iterator i;
    i = std::find_if(tlvs_.list_.rbegin(), tlvs_.list_.rend(),
                     Tlv::CompareTag(tag));
    if(i == tlvs_.list_.rend())
        throw Smpp::Error("Missing mandatory TLV");
            
    tlvs_.list_.insert(i.base(), tlv);
    update_length(tlv->length() + 4);
}
static void
on_sequence_length_changed (BtSequence * sequence, GParamSpec * arg,
    gpointer user_data)
{
  BtSequenceGridModel *model = BT_SEQUENCE_GRID_MODEL (user_data);
  gulong old_length = model->priv->length;

  g_object_get ((gpointer) sequence, "length", &model->priv->length, NULL);
  if (model->priv->length != old_length) {
    gulong old_visible_length = model->priv->visible_length;
    model->priv->visible_length = MAX (old_visible_length, model->priv->length);
    GST_INFO ("sequence length changed: %lu -> %lu", old_length,
        model->priv->length);

    update_length (model, old_visible_length, model->priv->visible_length);
  }
}
static void
bt_sequence_grid_model_set_property (GObject * const object,
    const guint property_id, const GValue * const value,
    GParamSpec * const pspec)
{
  BtSequenceGridModel *self = BT_SEQUENCE_GRID_MODEL (object);

  switch (property_id) {
    case SEQUENCE_GRID_MODEL_POS_FORMAT:{
      BtSequenceGridModelPosFormat old_pos_format = self->priv->pos_format;
      self->priv->pos_format = g_value_get_enum (value);
      if (self->priv->pos_format != old_pos_format)
        bt_sequence_grid_model_all_rows_changed (self);
      break;
    }
    case SEQUENCE_GRID_MODEL_BARS:{
      gulong old_bars = self->priv->bars;
      self->priv->bars = g_value_get_ulong (value);
      if (self->priv->bars != old_bars)
        bt_sequence_grid_model_all_rows_changed (self);
      break;
    }
    case SEQUENCE_GRID_MODEL_LENGTH:{
      gulong old_length = self->priv->visible_length;
      self->priv->visible_length = g_value_get_ulong (value);
      self->priv->visible_length =
          MAX (self->priv->visible_length, self->priv->length);
      GST_DEBUG ("visible length changed: %lu", self->priv->visible_length);
      update_length (self, old_length, self->priv->visible_length);
      break;
    }
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
  }
}
Beispiel #6
0
void		get_length(const char *format, t_format *format_var, int *i)
{
	if (format[*i] == 'l' && format[*i + 1] == 'l')
		update_length(format_var, LL);
	else if (format[*i] == 'l')
		update_length(format_var, L);
	else if (format[*i] == 'h' && format[*i + 1] == 'h')
		update_length(format_var, HH);
	else if (format[*i] == 'h')
		update_length(format_var, H);
	else if (format[*i] == 'j')
		update_length(format_var, J);
	else if (format[*i] == 'z')
		update_length(format_var, Z);
	else
		format_var->length = NO_FLAG;
	if (format_var->length == HH || format_var->length == LL)
		(*i) += 2;
	else if (format_var->length != NO_FLAG)
		(*i)++;
}
Beispiel #7
0
/*---------------------------------------------------------------------------*                                            
 * NAME: fuzz_engine
 * DESC: fetch and parse each ad instructions
 *---------------------------------------------------------------------------*/
unsigned int fuzz_engine(config *conf) {

  int result;
  int error_occured = 0;

  /* debug */
  debug(1, "<-----------------------[enter]\n");

  /* if mode file, open the debugger file */
  if (conf->type == 2) {
    if(create_debugger_file(conf)) return -1;
  }

  do {

    /* parse all the file */
    while (conf->adc->offset < conf->adc->size) {

      /* fetch the instruction */
      if (fetch_instruction(conf)) return -200; 
    }

    /* compute the lengths */
    update_length(conf);

    /* compute the hash values */
    update_hash(conf);

    /* send the start message to the debugger. i.e. the fuzzer cannot speak 
       with the debugger anymore, only the debugger send messages to the fuzzer */
    if ((conf->dbg_mode) && (!conf->ring_zero))
      if (dbg_send_msg(conf, INET_START_A_MSG, 0 , NULL, 0)) return -1;
    
    /* start the fuzzing */
    result = start_fuzz(conf);
    
    if (result == -1)
      error_occured = 1;

    /* free the (big) fuzz buffer */
    if (conf->buf_fuzz) { 
      free(conf->buf_fuzz); 
      conf->buf_fuzz = NULL;
    }

    /* free the blocks */
    free_block(conf);

    /* free the lengths */
    free_length(conf);

    /* free the hashes */
    free_hash(conf);

    /* free the chronos */
    free_chrono(conf);

    /* reset the offset */
    conf->adc->offset = conf->adc->start;

    /* add a value to the fuzz counter */
    conf->fuzz_file_id++;


    /* we close the debugger file */
    if ((conf->type == 2) && (!conf->ring_zero)) {
      if(fclose(conf->fuzz_file_dbg)) {
	error_("error closing the debugger file.\n");
	perror("");
	error_("QUITTING!\n");
	return -1;
      }
    }

    /* we are no more in the ring zero mode */
    conf->ring_zero = 1;

  } while (!fuzz_finished(conf) && (error_occured == 0));


  /* free the fuzz */
  if (conf->fuzz) {
    struct struct_fuzz *fuzz;
    struct struct_fuzz *fuzz_to_free;
    fuzz = conf->fuzz;
    while (fuzz) {
      fuzz_to_free = fuzz;
      fuzz = fuzz->next;

      /* before freeing fuzz, free source */
      if (fuzz_to_free->source) {
	struct struct_source *source;
	struct struct_source *source_to_free;
	source = fuzz_to_free->source;	
	/* free the filename first */


	while(source) {
	  source_to_free = source;
	  source = source->next;
	  debug(3, "free source: %d filename: \"%s\"\n", source_to_free->id, source_to_free->filename);
	  if (source_to_free->filename) free(source_to_free->filename);
	  free(source_to_free);
	}

      }
      debug(3, "free fuzz[%d]\n", fuzz_to_free->id);
      free(fuzz_to_free);
    }
    conf->fuzz = NULL;
  }

  /* debug */
  debug(1, "<-----------------------[quit]\n");

  /* return value */
  return 0;
}
Beispiel #8
0
int main(void)
{
	char *text = "abc123456879754461325456478974564153217897654564132156489768545613214567489465413521231324567489797468545646958798";
	int payload_length, context_length;
	bool esp8266_exist=false, connected=false, test_send=true;
	uint8_t *context;
	
	test[0] = 0x81;
	test[1] = strlen(text);
	strcpy( (char *)test+2, text );
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();

  /* Configure the system clock to 168 MHz */
  SystemClock_Config();

  /*##-1- Configure the UART peripheral ######################################*/
  /* Put the USART peripheral in the Asynchronous mode (UART Mode) */
  /* UART1 configured as follow:
      - Word Length = 8 Bits
      - Stop Bit = One Stop bit
      - Parity = None
      - BaudRate = 9600 baud
      - Hardware flow control disabled (RTS and CTS signals) */
  UartHandle.Instance          = USARTx;
  
  UartHandle.Init.BaudRate     = 115200;
  UartHandle.Init.WordLength   = UART_WORDLENGTH_8B;
  UartHandle.Init.StopBits     = UART_STOPBITS_1;
  UartHandle.Init.Parity       = UART_PARITY_NONE;
  UartHandle.Init.HwFlowCtl    = UART_HWCONTROL_NONE;
  UartHandle.Init.Mode         = UART_MODE_TX_RX;
  UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
    
  if(HAL_UART_Init(&UartHandle) != HAL_OK)
  {
    Error_Handler();
  }

  /* The board receives the message and sends it back */

  /*##-2- Put UART peripheral in reception process ###########################*/  
  if(HAL_UART_Receive_DMA(&UartHandle, (uint8_t *)aRxBuffer8266, RXBUFFERSIZE) != HAL_OK)
  {
    while(1);
  }

	if( esp8266_init() ){
		esp8266_exist = true;
		if(  !esp8266_cmd("AT+CWMODE=2\r\n", "no change\r\n", 100) && !esp8266_cmd("AT+CWMODE=2\r\n", "\r\nOK\r\n", 100) ){
			while(1);
		}
		if( !esp8266_cmd("AT+CIPMUX=1\r\n", "\r\nOK\r\n", 100) ){
			while(1);
		}
		if( !esp8266_cmd("AT+CIPSERVER=1,8080\r\n", "\r\nOK\r\n", 200) ){
			while(1);
		}
	}

  while (1){
		switch( esp8266_parse(payload, &payload_length) ){ //maybe more than one event in the messages, but parse only one each time
			case NO_EVENT :
				break;
			case LINK :
				break;
			case UNLINK :
				connected = 0;
				break;
			case PAYLOAD :
				if( 0 == strncmp((const char *)payload, "GET /chat", 9) ){ //handshake
					web_soket_handshake( (char *)payload );
				}else if( 0x81 == *payload ){ //websocket data
					rm_mask(payload, payload_length, &context, &context_length);
					if( 0 == strncmp( (char *)context, "login:"******"fanlong: stop", 13 ) ){
						test_send = false;
					}else if( 0 == strncmp( (char *)context, "fanlong: start", 14 ) ){
						test_send = true;
					}
				}
				break;
			case SEND_OK :
				break;
			case RST :
				break;
			default :
				break;
		}
		/* at least one char will be received in 1 ms; 
		if you ignore this delay, maybe you update_length() just after one message ended and the next is coming.
		coment it if and only if you are sure there is no message just begin;
		*/
		HAL_Delay(1);
		if( update_length() ){ 
			continue;// still have message
		}
		//now I'm sure there is no more message will come
		if( connected && test_send ){ //make sure rxbuffer is empty
			esp8266_send(0, test, strlen(text)+2);
			HAL_Delay(100);
		}
  }
}