Beispiel #1
0
//////////////////////////////  3. FileReq Protocol  //////////////////////////
bool ProtocolFileReq::encode_body(ByteBuffer *byte_buffer)
{
	////fid
	ENCODE_STRING(m_file_req.fid);
	////index
	ENCODE_INT(m_file_req.index);
	////offset
	ENCODE_INT(m_file_req.offset);
	////size
	ENCODE_INT(m_file_req.size);

	return true;
}
Beispiel #2
0
//////////////////////////////  5. FileSaveResult Protocol  //////////////////////////
bool ProtocolFileSaveResult::encode_body(ByteBuffer *byte_buffer)
{
	int temp;
	//status
	temp = (int)m_save_result.status;
	ENCODE_INT(temp);
	////fid
	ENCODE_STRING(m_save_result.fid);
	////seg index
	ENCODE_INT(m_save_result.index);

	return true;
}
INT TSipBody::encode(CHAR* &buf)
{
	ENCODE_INT( buf , content_length )
	content.encode(buf);

	return size();
}
INT TSipSubscriptionState::encode(CHAR* &buf)
{
	state.encode(buf);
	ENCODE_INT( buf , expires )
	reason.encode(buf);

	return size();
}
////编码协议体数据到io_buffer,成功返回true,失败返回false.
bool TemplateProtocol::encode_body(ByteBuffer *byte_buffer)
{
	////m_value
	ENCODE_INT(m_value);
	////m_str
	ENCODE_STRING(m_str);

	return true;
}
Beispiel #6
0
//////////////////////////////  7. ChunkPingResp Protocol  //////////////////////////
bool ProtocolChunkPingResp::encode_body(ByteBuffer *byte_buffer)
{
	int temp;
	////result
	temp = (int)m_result;
	ENCODE_INT(temp);
	////chunk id
	ENCODE_STRING(m_chunk_id);

	return true;
}
Beispiel #7
0
//////////////////////////////  2. FileInfoSaveResult Protocol  //////////////////////////
bool ProtocolFileInfoSaveResult::encode_body(ByteBuffer *byte_buffer)
{
	int temp;
	////result
	temp = (int)m_save_result.result;
	ENCODE_INT(temp);
	////fid
	ENCODE_STRING(m_save_result.fid);

	return true;
}
Beispiel #8
0
void set_version(little_file *self) {
  int dfd, fd;
  version_t version = ENCODE_VERSION(self->version);
  int nextfreeblock = ENCODE_INT(self->nextfreeblock);

  dfd = open(self->name, O_RDONLY);
  fd  = openat(dfd, version_file, O_WRONLY | O_CREAT, 0666);
  close(dfd);
  write(fd, &version, sizeof(version_t));
  write(fd, &nextfreeblock, sizeof(int));
  close(fd);
}
Beispiel #9
0
//////////////////////////////  4. File Protocol  //////////////////////////
bool ProtocolFile::encode_body(ByteBuffer *byte_buffer)
{
	int temp;
	////flag
	temp = (int)m_file_seg.flag;
	ENCODE_INT(temp);
	////fid
	ENCODE_STRING(m_file_seg.fid);
	////name
	ENCODE_STRING(m_file_seg.name);
	////file size
	ENCODE_INT(m_file_seg.filesize);
	////seg offset
	ENCODE_INT(m_file_seg.offset);
	////seg index
	ENCODE_INT(m_file_seg.index);
	////seg size
	ENCODE_INT(m_file_seg.size);

	return true;
}
//////////////////////  回复数据  /////////////////////
//编码协议体数据到io_buffer.成功返回编码后协议体长度(大于0),失败返回-1;
bool RespondData::encode_body(ByteBuffer *byte_buffer)
{
	int len = 0;
	//file name
	ENCODE_STRING(m_file_name);
	//start pos
	ENCODE_INT64(m_start_pos);
	//size
	ENCODE_INT(m_size);

	return true;
}
Beispiel #11
0
//////////////////////////////  1. FileInfo Protocol  //////////////////////////
bool ProtocolFileInfo::encode_body(ByteBuffer *byte_buffer)
{
	int temp;
	////result
	temp = (int)m_fileinfo.result;
	ENCODE_INT(temp);
	////fid
	ENCODE_STRING(m_fileinfo.fid);
	////file name
	ENCODE_STRING(m_fileinfo.name);
	////file size
	ENCODE_INT(m_fileinfo.size);
	////chunk info
	temp = m_fileinfo.get_chunkpath_count();
	ENCODE_INT(temp);
	while(temp > 0)
	{
		ChunkPath chunkpath = m_fileinfo.get_chunkpath(--temp);
		//chunk id
		ENCODE_STRING(chunkpath.id);
		//chunk ip
		ENCODE_STRING(chunkpath.ip);
		//chunk port
		ENCODE_INT(chunkpath.port);
		//index
		ENCODE_INT(chunkpath.index);
		//chunk offset
		ENCODE_INT(chunkpath.offset);
	}

	return true;
}
Beispiel #12
0
//////////////////////////////  6. ChunkPing Protocol  //////////////////////////
bool ProtocolChunkPing::encode_body(ByteBuffer *byte_buffer)
{
	////chunk id
	ENCODE_STRING(m_chunk_info.id);
	////chunk ip
	ENCODE_STRING(m_chunk_info.ip);
	////chunk port
	ENCODE_INT(m_chunk_info.port);
	//// disk space
	ENCODE_INT64(m_chunk_info.disk_space);
	////disk used
	ENCODE_INT64(m_chunk_info.disk_used);

	return true;
}
Beispiel #13
0
void RRGLevel::encodeWithEncoder(RRGCoding::Encoder* encoder)
{
    ENCODE_OBJECT(_character1);
    ENCODE_OBJECT(_character2);
    ENCODE_OBJECT(_character3);
    
    ENCODE_VECTOR_OBJECTS(_vectChara);
    ENCODE_MAP_OBJECTS(_mapChara);
    
    ENCODE_INT(_testInt);
    ENCODE_FLOAT(_testFloat);
    ENCODE_STRING(_testString);
    
    ENCODE_ARRAY(_intArray, intArraySize);
    
    ENCODE_VALUEVECTOR(_valueVector);
    ENCODE_VALUEMAP(_valueMap);
    
    ENCODE_VECTOR(_intVector);
    ENCODE_VECTOR(_pointVector);
    
    ENCODE_MAP(_doubleMap);
    ENCODE_MAP(_rectMap);
}