示例#1
0
// Tracks progress of a file, displays update output
// @param file a pointer to a file variable
static void update_progress(file_info *file) {
    
    file->file_count++;
    file->packets_in_buffer++;
    file->file_buffer_size += get_data_length(file);
    file->bytes_sent += get_data_length(file);
    file->pos += MAX_DATA_LENGTH;
    
    // Display progress if its more than X && X%
    if ((file->file_buffer_size >= file->transfer_threshold) &&
        (file->packets_in_buffer >= TRANSFER_THRESHOLD_PACKETS)) {
        
        file->percent = ((double)file->bytes_sent / (double)file->file_length) * 100;
        syslog(LOG_INFO, "...Bytes sent: %d of %d (%.2f%%)", file->bytes_sent, file->file_length, file->percent);
        
        file->file_buffer_size = 0;
        file->packets_in_buffer = 0;
        
    } //end if
    
    // Update the file transferred
    if (file->bytes_sent == file->file_length) {
        
        file->file_transferred = true;
        
    } //end if
    
} //end update_progress
示例#2
0
void Bridge::onStatusByte(uint8_t byte) {
  if(byte == MSG_SYSEX_END && bufferStartsWith(MSG_SYSEX_START)) {
    this->msg_data.append(byte); // bookends of a complete SysEx message
    sendMidiMessage();
    return;
  }

  if(this->data_expected > 0) {
    emit displayMessage(applyTimeStamp(QString("Warning: got a status byte when we were expecting %1 more data bytes, sending possibly incomplete MIDI message 0x%2").arg(this->data_expected).arg((uint8_t)this->msg_data[0], 0, 16)));
    sendMidiMessage();
  }

  if(is_voice_msg(byte))
    this->running_status = byte;
  if(is_syscommon_msg(byte))
    this->running_status = 0;

  this->data_expected = get_data_length(byte);
  if(this->data_expected == UNKNOWN_MIDI) {
      emit displayMessage(applyTimeStamp(QString("Warning: got unexpected status byte %1").arg((uint8_t)byte,0,16)));
      this->data_expected = 0;
  }
  this->msg_data.clear();
  this->msg_data.append(byte);
}
示例#3
0
static gboolean
daap_request_stream (GIOChannel *chan, gchar *path, gchar *host,
                     guint request_id, guint *size)
{
	guint status;
	gchar *request, *header = NULL;

	request = daap_generate_request (path, host, request_id);
	daap_send_request (chan, request);
	g_free (request);

	daap_receive_header (chan, &header);
	if (!header) {
		return FALSE;
	}

	status = get_server_status (header);
	if (HTTP_OK != status) {
		g_free (header);
		return FALSE;
	}

	*size = get_data_length (header);

	g_free (header);

	return TRUE;
}
/*******************************************************
   函数返回值的字节长度;通过序号找到对应的值
 ********************************************************/
static int snmp_get_data_parameter(MIBIDSTRUCT *pN,void *pV)
{
	if( NULL != pN && NULL != pV)
		if( snmp_get_data(SHM_PARAMETER,pN->t_tacheID.ipcNo,MAX_CHAR_LEN,pV) >0 )
			return get_data_length( pN,pV );
	return 0;
}
示例#5
0
// Sends a data message to the server
// @param sockfd the socket file descriptor
// @param server the server being sent to
// @param seq the sequence number of the message
// @param file a pointer to the file variable
static void send_data(int sockfd, host *server, int *seq, file_info *file) {
    
    char data_buffer[MAX_DATA_LENGTH];  // A data segment
    
    memcpy(data_buffer, file->pos, get_data_length(file));
    hftp_data_message *data = (hftp_data_message*)create_data_message(DATA, *seq, data_buffer, get_data_length(file));
    
    syslog(LOG_DEBUG, "Type: Data, Sequence: %d, Data length: %d", data->sequence, ntohs(data->data_length));
    transmit(sockfd, (message**)&data, server, seq);
    
} //end send data
示例#6
0
	void S::finish_sig(Integer r, Integer cb){
		this->r = r;
		Integer s2 = paillier.dec(cb) % n;
		s = a_times_b_mod_c(ks.InverseMod(n), s2, n);
		if (s == 0){
			throw ProtocolException("ERR s==0 restart protocol");
		}
    if (s > n - s) {
      s = n - s;
    }

		// bool result = verifier.VerifyMessage(get_data(), get_data_length(), signature, 64);
		bool result = verify(Q, get_data(), get_data_length(), r, s);
		if (!result){
			throw ProtocolException("Invalid signature generated!");
		} else {
    }
	}